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

Julio Faracco posted 1 patch 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180424012621.2518-1-jcfaracco@gmail.com
Test syntax-check passed
src/qemu/qemu_driver.c | 6 ++++++
1 file changed, 6 insertions(+)
[libvirt] [PATCH v3] qemu: avoid slash characters to the new domain name.
Posted by Julio Faracco 6 years ago
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@gmail.com>
---
 src/qemu/qemu_driver.c | 6 ++++++
 1 file changed, 6 insertions(+)

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,
-- 
2.14.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] qemu: avoid slash characters to the new domain name.
Posted by John Ferlan 6 years ago

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@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@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,
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] qemu: avoid slash characters to the new domain name.
Posted by Julio Faracco 6 years ago
Hi John,

Thanks for your comments.
Probably, this is a requirement for test driver too.
See my tests:

    # virsh -c test:///default

    virsh # shutdown test
    Domain test is being shutdown

    virsh # domrename test /
    Domain successfully renamed

    virsh # start /
    error: Failed to start domain /
    error: XML error: name / cannot contain '/'

The same behavior of QEMU driver.

--
Julio Cesar Faracco

2018-04-30 10:23 GMT-03:00 John Ferlan <jferlan@redhat.com>:
>
>
> 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@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@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,
>>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] qemu: avoid slash characters to the new domain name.
Posted by John Ferlan 6 years ago

On 04/30/2018 02:28 PM, Julio Faracco wrote:
> Hi John,
> 
> Thanks for your comments.
> Probably, this is a requirement for test driver too.
> See my tests:
> 
>     # virsh -c test:///default
> 
>     virsh # shutdown test
>     Domain test is being shutdown
> 
>     virsh # domrename test /
>     Domain successfully renamed
> 
>     virsh # start /
>     error: Failed to start domain /
>     error: XML error: name / cannot contain '/'
> 
> The same behavior of QEMU driver.
> 

ah true - so post a v4 where patch 1 is the qemu patch and patch 2 is
the test patch... We have another day or so of waiting for the release
anyway...

Tks,

John

> --
> Julio Cesar Faracco
> 
> 2018-04-30 10:23 GMT-03:00 John Ferlan <jferlan@redhat.com>:
>>
>>
>> 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@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@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,
>>>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list