[libvirt] [PATCH] virDomainDeviceDefValidateAliasesIterator: Ignore some hostdevs

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/c47c24d36d79ef741f4e8f29d8d3255993d1322e.1521200399.git.mprivozn@redhat.com
Test syntax-check passed
src/conf/domain_conf.c | 7 +++++++
1 file changed, 7 insertions(+)
[libvirt] [PATCH] virDomainDeviceDefValidateAliasesIterator: Ignore some hostdevs
Posted by Michal Privoznik 6 years, 1 month ago
https://bugzilla.redhat.com/show_bug.cgi?id=1556828

When defining a domain that has <interface type='hostdev'/> our
parser creates two entries in virDomainDef: one for <interface/>
and one for <hostdev/>. However, some info is shared between the
two which makes user alias validation fail because alias belongs
to the set of shared info.

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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 86fc275116..c8d051fa9f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5584,6 +5584,13 @@ virDomainDeviceDefValidateAliasesIterator(virDomainDefPtr def,
         virDomainChrEquals(def->serials[0], dev->data.chr))
         return 0;
 
+    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
+        dev->data.hostdev->parent.type == VIR_DOMAIN_DEVICE_NET) {
+        /* This hostdev is a copy of some previous interface.
+         * Aliases are duplicated. */
+        return 0;
+    }
+
     if (virHashLookup(data->aliases, alias)) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("non unique alias detected: %s"),
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virDomainDeviceDefValidateAliasesIterator: Ignore some hostdevs
Posted by Jiri Denemark 6 years ago
On Fri, Mar 16, 2018 at 12:39:59 +0100, Michal Privoznik wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1556828
> 
> When defining a domain that has <interface type='hostdev'/> our
> parser creates two entries in virDomainDef: one for <interface/>
> and one for <hostdev/>. However, some info is shared between the
> two which makes user alias validation fail because alias belongs
> to the set of shared info.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/conf/domain_conf.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 86fc275116..c8d051fa9f 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -5584,6 +5584,13 @@ virDomainDeviceDefValidateAliasesIterator(virDomainDefPtr def,
>          virDomainChrEquals(def->serials[0], dev->data.chr))
>          return 0;
>  
> +    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
> +        dev->data.hostdev->parent.type == VIR_DOMAIN_DEVICE_NET) {
> +        /* This hostdev is a copy of some previous interface.
> +         * Aliases are duplicated. */
> +        return 0;
> +    }
> +
>      if (virHashLookup(data->aliases, alias)) {
>          virReportError(VIR_ERR_XML_ERROR,
>                         _("non unique alias detected: %s"),

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>

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