[libvirt] [PATCH] conf: Check for user aliases duplicates only

Michal Privoznik posted 1 patch 6 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1c72961bd02f0f93ecd6a5476bd6694e2fab2b67.1517928018.git.mprivozn@redhat.com
src/conf/domain_conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] conf: Check for user aliases duplicates only
Posted by Michal Privoznik 6 years, 1 month ago
When validating a device XML config we check if user provided
alias is unique. We do this by maintaining a hash table of device
aliases as we iterated over all devices defined for the domain.
However, it may happen that what appears as two devices in domain
XML is in fact just one interface in hypervisor. For instance in
qemu driver this is true for uhci/ehci controllers. In that case
an error is reported even though it is not actually an error. At
any rate, we can assume libvirt generated aliases to be unique
and thus really check user provided ones only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 34aae82f1..44724bd01 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5569,7 +5569,7 @@ virDomainDeviceDefValidateAliasesIterator(virDomainDefPtr def,
     struct virDomainDefValidateAliasesData *data = opaque;
     const char *alias = info->alias;
 
-    if (!alias)
+    if (!alias || !STRPREFIX(alias, "ua-"))
         return 0;
 
     /* Some crazy backcompat for consoles. */
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Check for user aliases duplicates only
Posted by Daniel P. Berrangé 6 years, 1 month ago
On Tue, Feb 06, 2018 at 03:40:18PM +0100, Michal Privoznik wrote:
> When validating a device XML config we check if user provided
> alias is unique. We do this by maintaining a hash table of device
> aliases as we iterated over all devices defined for the domain.
> However, it may happen that what appears as two devices in domain
> XML is in fact just one interface in hypervisor. For instance in
> qemu driver this is true for uhci/ehci controllers. In that case
> an error is reported even though it is not actually an error. At
> any rate, we can assume libvirt generated aliases to be unique
> and thus really check user provided ones only.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/conf/domain_conf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 34aae82f1..44724bd01 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -5569,7 +5569,7 @@ virDomainDeviceDefValidateAliasesIterator(virDomainDefPtr def,
>      struct virDomainDefValidateAliasesData *data = opaque;
>      const char *alias = info->alias;
>  
> -    if (!alias)
> +    if (!alias || !STRPREFIX(alias, "ua-"))
>          return 0;

nitpick  - use USER_ALIAS_PREFIX constant


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Check for user aliases duplicates only
Posted by Michal Privoznik 6 years, 1 month ago
On 02/06/2018 03:52 PM, Daniel P. Berrangé wrote:
> On Tue, Feb 06, 2018 at 03:40:18PM +0100, Michal Privoznik wrote:
>> When validating a device XML config we check if user provided
>> alias is unique. We do this by maintaining a hash table of device
>> aliases as we iterated over all devices defined for the domain.
>> However, it may happen that what appears as two devices in domain
>> XML is in fact just one interface in hypervisor. For instance in
>> qemu driver this is true for uhci/ehci controllers. In that case
>> an error is reported even though it is not actually an error. At
>> any rate, we can assume libvirt generated aliases to be unique
>> and thus really check user provided ones only.
>>
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>> ---
>>  src/conf/domain_conf.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 34aae82f1..44724bd01 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -5569,7 +5569,7 @@ virDomainDeviceDefValidateAliasesIterator(virDomainDefPtr def,
>>      struct virDomainDefValidateAliasesData *data = opaque;
>>      const char *alias = info->alias;
>>  
>> -    if (!alias)
>> +    if (!alias || !STRPREFIX(alias, "ua-"))
>>          return 0;
> 
> nitpick  - use USER_ALIAS_PREFIX constant

Even better, I can call virDomainDeviceAliasIsUserAlias().

Michal

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