On 23/06/16 09:45, Ján Tomko wrote:
Walk through all the usb controllers in the domain definition
and create the corresponding structures in the virDomainUSBAddressSet.
---
src/conf/domain_addr.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_addr.h | 4 ++
src/libvirt_private.syms | 1 +
3 files changed, 126 insertions(+)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index a43657b..9ae9570 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -1323,3 +1323,124 @@ virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs)
VIR_FREE(addrs->buses);
VIR_FREE(addrs);
}
+
+
+static size_t
+virDomainUSBAddressControllerModelToPorts(virDomainControllerDefPtr cont)
+{
+ int model = cont->model;
+
+ if (model == -1)
+ model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
+
+ switch ((virDomainControllerModelUSB) model) {
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI:
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX4_UHCI:
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI:
+ return 2;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_EHCI:
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1:
+ return 6;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1:
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2:
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3:
+ /* These have two ports each and are used to provide USB1.1
+ * ports while ICH9_EHCI1 provides 6 USB2.0 ports.
+ * Ignore these since we will add the EHCI1 too. */
+ return 0;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI:
+ return 3;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI:
+ if (cont->opts.usbopts.ports != -1)
+ return cont->opts.usbopts.ports;
Since you incorporated Gerd's comment on making xHCI controller's port
range configurable, I didn't find anything else (besides the line
below), so I'm tempted to say ACK, but maybe someone who knows more
about usb controllers might want to put their two cents in.
Erik
+ return 4;
+
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE:
+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
+ /* yoda */
please remove this ^^ line
+ break;
+ }
+ return 0;
+}
+