From fc03eb53c0bf3f654b3c0a10e349d87eb2f511e6 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Wed, 11 Nov 2015 15:20:15 +0100 Subject: [PATCH] domain-conf: reorder usb controllers so the master is first USB controllers can share the same 'index' which indicates, that there is some sort of master-companion relationship. Reorder the controllers in XML in to place the master controller before its companions. This is required by QEMU to not fail with error message: error: internal error: process exited while connecting to monitor: 2015-10-26T16:25:17.630265Z qemu-system-x86_64: -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6: USB bus 'usb.0' not found Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1166452 Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 8 +++++ .../qemuxml2argv-controller-usb-order.xml | 31 +++++++++++++++++ .../qemuxml2xmlout-controller-usb-order.xml | 34 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 4 files changed, 74 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-controller-usb-order.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-controller-usb-order.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9fb68338b..eb0044449a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13412,6 +13412,14 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def, * new controller, then new controller should go here * */ insertAt = idx; + } else if (controller->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE && + current->info.mastertype != VIR_DOMAIN_CONTROLLER_MASTER_NONE && + current->idx == controller->idx) { + /* If bus matches and index matches and new controller is + * master and current isn't a master, then new controller + * should go here to be placed before its companion + */ + insertAt = idx; } else if (insertAt == -1) { /* Last controller with match bus is before the * new controller, then put new controller just after diff --git a/tests/qemuxml2argvdata/qemuxml2argv-controller-usb-order.xml b/tests/qemuxml2argvdata/qemuxml2argv-controller-usb-order.xml new file mode 100644 index 0000000000..6cc0f503ff --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-controller-usb-order.xml @@ -0,0 +1,31 @@ + + rhel7 + c9b867fb-7274-4a22-8884-0867d05b38cf + 2097152 + 2097152 + 2 + + hvm + + + destroy + restart + restart + + + + + + /usr/bin/qemu-system-x86_64 + + +
+ + +
+ + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-controller-usb-order.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-controller-usb-order.xml new file mode 100644 index 0000000000..a3c22e803f --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-controller-usb-order.xml @@ -0,0 +1,34 @@ + + rhel7 + c9b867fb-7274-4a22-8884-0867d05b38cf + 2097152 + 2097152 + 2 + + hvm + + + + destroy + restart + restart + + + + + + /usr/bin/qemu-system-x86_64 + +
+ + + +
+ + +
+ + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 103fb79ae8..cbd4d0d1dd 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -507,6 +507,7 @@ mymain(void) DO_TEST_DIFFERENT("usb-redir-filter"); DO_TEST_DIFFERENT("usb-redir-filter-version"); DO_TEST("blkdeviotune"); + DO_TEST_DIFFERENT("controller-usb-order"); DO_TEST_FULL("seclabel-dynamic-baselabel", false, WHEN_INACTIVE); DO_TEST_FULL("seclabel-dynamic-override", false, WHEN_INACTIVE); -- GitLab