diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9d059044e4..d886b60a84 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4035,6 +4035,28 @@ virDomainControllerDefParseXML(xmlNodePtr node,
VIR_FREE(vectors);
break;
}
+ case VIR_DOMAIN_CONTROLLER_TYPE_USB: {
+ /* If the XML has a uhci1, uhci2, uhci3 controller and no
+ * master port was given, we should set a sensible one */
+ int masterPort = -1;
+ switch (def->model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1:
+ masterPort = 0;
+ break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2:
+ masterPort = 2;
+ break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3:
+ masterPort = 4;
+ break;
+ }
+ if (masterPort != -1 &&
+ def->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE) {
+ def->info.mastertype = VIR_DOMAIN_CONTROLLER_MASTER_USB;
+ def->info.master.usb.startport = masterPort;
+ }
+ break;
+ }
default:
break;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml
index bf35b5548b..634d6c5e32 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-ehci-addr.xml
@@ -19,19 +19,13 @@
-
-
-
-
-
-
+
+
-
-
-
+
@@ -39,15 +33,9 @@
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-ich9-ehci-addr.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-ich9-ehci-addr.xml
index e7592e995a..2bb1661b4a 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-ich9-ehci-addr.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-ich9-ehci-addr.xml
@@ -3,7 +3,7 @@
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
219136
- 1
+ 1
hvm