[libvirt] [PATCH v3] qemu: avoid slash characters to the new domain name.

John Ferlan jferlan at redhat.com
Mon Apr 30 13:23:01 UTC 2018



On 04/23/2018 09:26 PM, Julio Faracco wrote:
> The 'domrename' command needs to check if the new domain name contains
> the slash character. This character is not accepted by libvirt XML
> definition because it is an invalid char (see Cole's commit b1fc6a7b7).
> This commit enhace the 'domrename' command adding this check.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1333232
> 
> Signed-off-by: Julio Faracco <jcfaracco at gmail.com>
> ---
>  src/qemu/qemu_driver.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

The change/check could have gone right after virCheckFlags and used
@new_name (we're already guaranteed @new_name is not NULL from the
virDomainRename API) and just return -1 directly.

Reviewed-by: John Ferlan <jferlan at redhat.com>

John

I will push after the freeze.  If you'd like I can also move the check.

> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 7484b00e2..70ae18524 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -20757,6 +20757,12 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
>      if (VIR_STRDUP(new_dom_name, new_name) < 0)
>          goto cleanup;
>  
> +    if (strchr(new_dom_name, '/')) {
> +        virReportError(VIR_ERR_XML_ERROR,
> +                       _("name %s cannot contain '/'"), new_dom_name);
> +        goto cleanup;
> +    }
> +
>      if (!(new_dom_cfg_file = virDomainConfigFile(cfg->configDir,
>                                                   new_dom_name)) ||
>          !(old_dom_cfg_file = virDomainConfigFile(cfg->configDir,
> 




More information about the libvir-list mailing list