A "usb" controller has an optional attribute <code>model</code>,
which is one of "piix3-uhci", "piix4-uhci", "ehci",
"ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
- "vt82c686b-uhci", "pci-ohci" or "nec-xhci". The PowerPC64
- "spapr-vio" addresses do not have an associated controller.
+ "vt82c686b-uhci", "pci-ohci" or "nec-xhci". Additionally,
+ <span class="since">since 0.10.0</span>, if the USB bus needs to be
+ explicitly disabled for the guest, <code>model='none'</code> may be used.
+ The PowerPC64 "spapr-vio" addresses do not have an associated controller.
</p>
<p>
"ich9-uhci3",
"vt82c686b-uhci",
"pci-ohci",
- "nec-xhci")
+ "nec-xhci",
+ "none")
VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
"mount",
virBitmapPtr bootMap = NULL;
unsigned long bootMapSize = 0;
xmlNodePtr cur;
+ bool usb_none = false;
+ bool usb_other = false;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
if (!controller)
goto error;
+ /* sanitize handling of "none" usb controller */
+ if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) {
+ if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
+ if (usb_other || usb_none) {
+ virReportError(VIR_ERR_XML_DETAIL, "%s",
+ _("Can't add another USB controller: "
+ "USB is disabled for this domain"));
+ goto error;
+ }
+ usb_none = true;
+ } else {
+ if (usb_none) {
+ virReportError(VIR_ERR_XML_DETAIL, "%s",
+ _("Can't add another USB controller: "
+ "USB is disabled for this domain"));
+ goto error;
+ }
+ usb_other = true;
+ }
+ }
+
virDomainControllerInsertPreAlloced(def, controller);
}
VIR_FREE(nodes);
if (!input)
goto error;
+ /* Check if USB bus is required */
+ if (input->bus == VIR_DOMAIN_INPUT_BUS_USB && usb_none) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Can't add USB input device. "
+ "USB bus is disabled"));
+ goto error;
+ }
/* With QEMU / KVM / Xen graphics, mouse + PS/2 is implicit
* with graphics, so don't store it.
if (!hostdev)
goto error;
+ if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
+ usb_none) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Can't add host USB device: "
+ "USB is disabled in this host"));
+ goto error;
+ }
+
def->hostdevs[def->nhostdevs++] = hostdev;
}
VIR_FREE(nodes);
if (!hub)
goto error;
+ if (hub->type == VIR_DOMAIN_HUB_TYPE_USB && usb_none) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Can't add USB hub: "
+ "USB is disabled for this domain"));
+ goto error;
+ }
+
def->hubs[def->nhubs++] = hub;
}
VIR_FREE(nodes);
if (!redirdev)
goto error;
+ if (redirdev->bus == VIR_DOMAIN_REDIRDEV_BUS_USB && usb_none) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Can't add redirected USB device: "
+ "USB is disabled for this domain"));
+ goto error;
+ }
+
def->redirdevs[def->nredirdevs++] = redirdev;
}
VIR_FREE(nodes);