qemu_domain: cleanup the controller post parse code
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
57404ff7a7
commit
3ffea19acd
@ -3014,41 +3014,60 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
|
|||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
/* set the default USB model to none for s390 unless an address is found */
|
switch ((virDomainControllerType)cont->type) {
|
||||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
|
||||||
cont->model == -1 &&
|
/* set the default SCSI controller model for S390 arches */
|
||||||
cont->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
if (cont->model == -1 &&
|
||||||
ARCH_IS_S390(def->os.arch))
|
ARCH_IS_S390(def->os.arch)) {
|
||||||
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
|
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
/* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */
|
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
|
||||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
if (cont->model == -1) {
|
||||||
(cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1 ||
|
/* Pick a suitable default model for the USB controller if none
|
||||||
cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2)) {
|
* has been selected by the user.
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
*
|
||||||
_("USB controller model type 'qusb1' or 'qusb2' "
|
* We rely on device availability instead of setting the model
|
||||||
"is not supported in %s"),
|
* unconditionally because, for some machine types, there's a
|
||||||
virDomainVirtTypeToString(def->virtType));
|
* chance we will get away with using the legacy USB controller
|
||||||
return -1;
|
* 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;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
|
||||||
/* 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) {
|
|
||||||
if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
|
if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS &&
|
||||||
!qemuDomainMachineIsI440FX(def)) {
|
!qemuDomainMachineIsI440FX(def)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
@ -3083,26 +3102,15 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
|
|||||||
virDomainNumaGetNodeCount(def->numa));
|
virDomainNumaGetNodeCount(def->numa));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
break;
|
||||||
cont->model == -1) {
|
|
||||||
/* Pick a suitable default model for the USB controller if none
|
case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
|
||||||
* has been selected by the user.
|
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
|
||||||
*
|
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
|
||||||
* We rely on device availability instead of setting the model
|
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
|
||||||
* unconditionally because, for some machine types, there's a
|
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
|
||||||
* chance we will get away with using the legacy USB controller
|
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
|
||||||
* when the relevant device is not available.
|
break;
|
||||||
*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user