diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f9fb68338b4d9563216b9af1cab59a1582f7e0c8..eb0044449ab780c690fc4ede6c33a3d977f17364 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 0000000000000000000000000000000000000000..6cc0f503ff53c805fdbc32371a7cd6f7f7d6a801 --- /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 0000000000000000000000000000000000000000..a3c22e803f6275a9d5cde5bf74555051541a27ca --- /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 103fb79ae800d32f5d7a95dcdc093f15106b0d02..cbd4d0d1dd28a84518839bde142e87fc544a1cb4 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);