mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
domain_conf: Add USB controler model "none"
Libvirt adds a USB controller to the guest even if the user does not specify any in the XML. This is due to back-compat reasons. To allow disabling USB for a guest this patch adds a new USB controller type "none" that disables USB support for the guest.
This commit is contained in:
parent
7ee395a80d
commit
0925189713
@ -1839,8 +1839,10 @@
|
|||||||
A "usb" controller has an optional attribute <code>model</code>,
|
A "usb" controller has an optional attribute <code>model</code>,
|
||||||
which is one of "piix3-uhci", "piix4-uhci", "ehci",
|
which is one of "piix3-uhci", "piix4-uhci", "ehci",
|
||||||
"ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
|
"ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3",
|
||||||
"vt82c686b-uhci", "pci-ohci" or "nec-xhci". The PowerPC64
|
"vt82c686b-uhci", "pci-ohci" or "nec-xhci". Additionally,
|
||||||
"spapr-vio" addresses do not have an associated controller.
|
<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>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -1222,6 +1222,7 @@
|
|||||||
<value>vt82c686b-uhci</value>
|
<value>vt82c686b-uhci</value>
|
||||||
<value>pci-ohci</value>
|
<value>pci-ohci</value>
|
||||||
<value>nec-xhci</value>
|
<value>nec-xhci</value>
|
||||||
|
<value>none</value>
|
||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
@ -259,7 +259,8 @@ VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
|
|||||||
"ich9-uhci3",
|
"ich9-uhci3",
|
||||||
"vt82c686b-uhci",
|
"vt82c686b-uhci",
|
||||||
"pci-ohci",
|
"pci-ohci",
|
||||||
"nec-xhci")
|
"nec-xhci",
|
||||||
|
"none")
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
|
VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
|
||||||
"mount",
|
"mount",
|
||||||
@ -7918,6 +7919,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
virBitmapPtr bootMap = NULL;
|
virBitmapPtr bootMap = NULL;
|
||||||
unsigned long bootMapSize = 0;
|
unsigned long bootMapSize = 0;
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
bool usb_none = false;
|
||||||
|
bool usb_other = false;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -8643,6 +8646,27 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
if (!controller)
|
if (!controller)
|
||||||
goto error;
|
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);
|
virDomainControllerInsertPreAlloced(def, controller);
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
@ -8917,6 +8941,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
if (!input)
|
if (!input)
|
||||||
goto error;
|
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 QEMU / KVM / Xen graphics, mouse + PS/2 is implicit
|
||||||
* with graphics, so don't store it.
|
* with graphics, so don't store it.
|
||||||
@ -9044,6 +9075,14 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
if (!hostdev)
|
if (!hostdev)
|
||||||
goto error;
|
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;
|
def->hostdevs[def->nhostdevs++] = hostdev;
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
@ -9113,6 +9152,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
if (!hub)
|
if (!hub)
|
||||||
goto error;
|
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;
|
def->hubs[def->nhubs++] = hub;
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
@ -9129,6 +9175,13 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
|
|||||||
if (!redirdev)
|
if (!redirdev)
|
||||||
goto error;
|
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;
|
def->redirdevs[def->nredirdevs++] = redirdev;
|
||||||
}
|
}
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
|
@ -634,6 +634,7 @@ enum virDomainControllerModelUSB {
|
|||||||
VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI,
|
VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI,
|
||||||
VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI,
|
VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI,
|
||||||
VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
|
VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI,
|
||||||
|
VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE,
|
||||||
|
|
||||||
VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
|
VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
|
||||||
};
|
};
|
||||||
|
@ -107,7 +107,8 @@ VIR_ENUM_IMPL(qemuControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
|
|||||||
"ich9-usb-uhci3",
|
"ich9-usb-uhci3",
|
||||||
"vt82c686b-usb-uhci",
|
"vt82c686b-usb-uhci",
|
||||||
"pci-ohci",
|
"pci-ohci",
|
||||||
"nec-usb-xhci");
|
"nec-usb-xhci",
|
||||||
|
"none");
|
||||||
|
|
||||||
VIR_ENUM_DECL(qemuDomainFSDriver)
|
VIR_ENUM_DECL(qemuDomainFSDriver)
|
||||||
VIR_ENUM_IMPL(qemuDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
|
VIR_ENUM_IMPL(qemuDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
|
||||||
|
Loading…
Reference in New Issue
Block a user