Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_domain.c | 114 ++++++++++++++++++++++++++-----------------------
1 file changed, 61 insertions(+), 53 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5c5a055354..10e831b779 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3014,41 +3014,60 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
- /* set the default USB model to none for s390 unless an address is found */
- if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
- cont->model == -1 &&
- cont->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
- ARCH_IS_S390(def->os.arch))
- cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
+ switch ((virDomainControllerType)cont->type) {
+ case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+ /* set the default SCSI controller model for S390 arches */
+ if (cont->model == -1 &&
+ ARCH_IS_S390(def->os.arch)) {
+ cont->model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
+ }
+ break;
- /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr
*/
- if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
- (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1 ||
- cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("USB controller model type 'qusb1' or
'qusb2' "
- "is not supported in %s"),
- virDomainVirtTypeToString(def->virtType));
- return -1;
- }
+ case VIR_DOMAIN_CONTROLLER_TYPE_USB:
+ if (cont->model == -1) {
+ /* Pick a suitable default model for the USB controller if none
+ * has been selected by the user.
+ *
+ * We rely on device availability instead of setting the model
+ * unconditionally because, for some machine types, there's a
+ * chance we will get away with using the legacy USB controller
+ * when the relevant device is not available.
+ *
+ * See qemuBuildControllerDevCommandLine() */
+ if (ARCH_IS_S390(def->os.arch) &&
+ cont->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+ /* set the default USB model to none for s390 unless an
+ * address is found */
+ cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
+ } else if (ARCH_IS_PPC64(def->os.arch)) {
+ /* Default USB controller for ppc64 is pci-ohci */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
+ cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
+ } else {
+ /* Default USB controller for anything else is piix3-uhci */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
+ cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
+ }
+ }
+ /* forbid usb model 'qusb1' and 'qusb2' in this kind of
hyperviosr */
+ if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1 ||
+ cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("USB controller model type 'qusb1' or
'qusb2' "
+ "is not supported in %s"),
+ virDomainVirtTypeToString(def->virtType));
+ return -1;
+ }
+ if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI &&
+ cont->opts.usbopts.ports > QEMU_USB_NEC_XHCI_MAXPORTS) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("nec-xhci controller only supports up to %u
ports"),
+ QEMU_USB_NEC_XHCI_MAXPORTS);
+ return -1;
+ }
+ break;
-
- /* set the default SCSI controller model for S390 arches */
- if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
- cont->model == -1 &&
- ARCH_IS_S390(def->os.arch))
- cont->model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
-
- if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
- cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI &&
- cont->opts.usbopts.ports > QEMU_USB_NEC_XHCI_MAXPORTS) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("nec-xhci controller only supports up to %u ports"),
- QEMU_USB_NEC_XHCI_MAXPORTS);
- return -1;
- }
-
- if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
+ case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
!qemuDomainMachineIsI440FX(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -3083,26 +3102,15 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
virDomainNumaGetNodeCount(def->numa));
return -1;
}
- } else if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
- cont->model == -1) {
- /* Pick a suitable default model for the USB controller if none
- * has been selected by the user.
- *
- * We rely on device availability instead of setting the model
- * unconditionally because, for some machine types, there's a
- * chance we will get away with using the legacy USB controller
- * when the relevant device is not available.
- *
- * See qemuBuildControllerDevCommandLine() */
- if (ARCH_IS_PPC64(def->os.arch)) {
- /* Default USB controller for ppc64 is pci-ohci */
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
- cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
- } else {
- /* Default USB controller for anything else is piix3-uhci */
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
- cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
- }
+ break;
+
+ case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
+ case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+ case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
+ case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
+ case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
+ case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ break;
}
return 0;
--
2.12.0