[libvirt] [PATCH] conf: fix bogus error when <boot order='1'/> is in an <interface type='hostdev'>

Ján Tomko jtomko at redhat.com
Fri Sep 7 10:41:07 UTC 2018


conf: fix boot order with <interface type='hostdev'>

You don't need the whole reproducer in the commit summary

On Thu, Sep 06, 2018 at 09:14:26PM -0400, Laine Stump wrote:
>virDomainDefCollectBootOrder() is called for every item on the list
>for each type of device. Since an <interface type='hostdev'> is on
>both the list of hostdev devices and the list of network devices, it
>will be counted twice, and the code that checks for multiple devices
>with the same boot order will give a false positive.
>
>To remedy this, we make sure to return early for hostdev devices that
>have a parent.type != NONE.
>
>This was introduced in commit 5b75a4, which was first in libvirt-4.4.0.
>

Yay, me!

>Resolves: https://bugzilla.redhat.com/1601318
>Signed-off-by: Laine Stump <laine at laine.org>
>---
> src/conf/domain_conf.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 77cc73744f..71a2fb0426 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -5062,6 +5062,14 @@ virDomainDefCollectBootOrder(virDomainDefPtr def ATTRIBUTE_UNUSED,
>     if (info->bootIndex == 0)
>         return 0;
>
>+    if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
>+        dev->data.hostdev->parent.type != VIR_DOMAIN_DEVICE_NONE) {
>+        /* This hostdev is a child of a higher level device
>+         * (e.g. interface), and thus already being counted on the
>+         * list for the other device type.
>+         */
>+        return 0;
>+    }

An extra newline here would be nice.

>     if (virAsprintf(&order, "%u", info->bootIndex) < 0)
>         goto cleanup;
>

But more importantly, a test case to catch it in the future.

With the test case added:
Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180907/0ec4a0b1/attachment-0001.sig>


More information about the libvir-list mailing list