From nobody Sun Feb 8 12:20:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1488444799665120.17656702264492; Thu, 2 Mar 2017 00:53:19 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v228ntSU010966; Thu, 2 Mar 2017 03:49:56 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v228mjBM018817 for ; Thu, 2 Mar 2017 03:48:45 -0500 Received: from antique-work.brq.redhat.com (dhcp129-175.brq.redhat.com [10.34.129.175]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v228mhLL008375 for ; Thu, 2 Mar 2017 03:48:44 -0500 From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 2 Mar 2017 09:48:40 +0100 Message-Id: <0fb72079dce2a62334b9cad558cca7365abdecfc.1488444435.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] qemu_domain: move controller post parse code into its own function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/qemu/qemu_domain.c | 202 +++++++++++++++++++++++++--------------------= ---- 1 file changed, 104 insertions(+), 98 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c187214dc3..5c5a055354 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3010,6 +3010,106 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr sh= m) =20 =20 static int +qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + /* set the default USB model to none for s390 unless an address is fou= nd */ + if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && + cont->model =3D=3D -1 && + cont->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + ARCH_IS_S390(def->os.arch)) + cont->model =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE; + + /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */ + if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && + (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB1 || + cont->model =3D=3D 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; + } + + + /* set the default SCSI controller model for S390 arches */ + if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI && + cont->model =3D=3D -1 && + ARCH_IS_S390(def->os.arch)) + cont->model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; + + if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && + cont->model =3D=3D 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 =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BU= S && + !qemuDomainMachineIsI440FX(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("pci-expander-bus controllers are only suppor= ted " + "on 440fx-based machinetypes")); + return -1; + } + if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_B= US && + !qemuDomainMachineIsQ35(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("pcie-expander-bus controllers are only suppo= rted " + "on q35-based machinetypes")); + return -1; + } + + /* if a PCI expander bus has a NUMA node set, make sure + * that NUMA node is configured in the guest + * array. NUMA cell id's in this array are numbered + * from 0 .. size-1. + */ + if ((cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_B= US || + cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_= BUS) && + (int) virDomainNumaGetNodeCount(def->numa) + <=3D cont->opts.pciopts.numaNode) { + virReportError(VIR_ERR_XML_ERROR, + _("%s with index %d is " + "configured for a NUMA node (%d) " + "not present in the domain's " + " array (%zu)"), + virDomainControllerModelPCITypeToString(cont->m= odel), + cont->idx, cont->opts.pciopts.numaNode, + virDomainNumaGetNodeCount(def->numa)); + return -1; + } + } else if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && + cont->model =3D=3D -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 =3D 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 =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI; + } + } + + return 0; +} + + +static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, virCapsPtr caps, @@ -3087,34 +3187,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, ARCH_IS_S390(def->os.arch)) dev->data.chr->targetType =3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_V= IRTIO; =20 - /* set the default USB model to none for s390 unless an address is fou= nd */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CONTROLLER && - dev->data.controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && - dev->data.controller->model =3D=3D -1 && - dev->data.controller->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_T= YPE_NONE && - ARCH_IS_S390(def->os.arch)) - dev->data.controller->model =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NO= NE; - - /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CONTROLLER && - dev->data.controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && - (dev->data.controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_US= B_QUSB1 || - dev->data.controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_US= B_QUSB2)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("USB controller model type 'qusb1' or 'qusb2' " - "is not supported in %s"), - virDomainVirtTypeToString(def->virtType)); - goto cleanup; - } - - - /* set the default SCSI controller model for S390 arches */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CONTROLLER && - dev->data.controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI = && - dev->data.controller->model =3D=3D -1 && - ARCH_IS_S390(def->os.arch)) - dev->data.controller->model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_V= IRTIO_SCSI; - /* clear auto generated unix socket path for inactive definitions */ if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && dev->type =3D=3D VIR_DOMAIN_DEVICE_CHR) @@ -3159,76 +3231,10 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr = dev, dev->data.panic->model =3D VIR_DOMAIN_PANIC_MODEL_ISA; } =20 - - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CONTROLLER) { - virDomainControllerDefPtr cont =3D dev->data.controller; - - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && - cont->model =3D=3D 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 p= orts"), - QEMU_USB_NEC_XHCI_MAXPORTS); - goto cleanup; - } - - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDE= R_BUS && - !qemuDomainMachineIsI440FX(def)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("pci-expander-bus controllers are only su= pported " - "on 440fx-based machinetypes")); - goto cleanup; - } - if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPAND= ER_BUS && - !qemuDomainMachineIsQ35(def)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("pcie-expander-bus controllers are only s= upported " - "on q35-based machinetypes")); - goto cleanup; - } - - /* if a PCI expander bus has a NUMA node set, make sure - * that NUMA node is configured in the guest - * array. NUMA cell id's in this array are numbered - * from 0 .. size-1. - */ - if ((cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPAND= ER_BUS || - cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPAN= DER_BUS) && - (int) virDomainNumaGetNodeCount(def->numa) - <=3D cont->opts.pciopts.numaNode) { - virReportError(VIR_ERR_XML_ERROR, - _("%s with index %d is " - "configured for a NUMA node (%d) " - "not present in the domain's " - " array (%zu)"), - virDomainControllerModelPCITypeToString(con= t->model), - cont->idx, cont->opts.pciopts.numaNode, - virDomainNumaGetNodeCount(def->numa)); - goto cleanup; - } - } else if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && - cont->model =3D=3D -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 =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OH= CI; - } else { - /* Default USB controller for anything else is piix3-uhci = */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) - cont->model =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_= UHCI; - } - } - } + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CONTROLLER && + qemuDomainControllerDefPostParse(dev->data.controller, def, + qemuCaps) < 0) + goto cleanup; =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_SHMEM && qemuDomainShmemDefPostParse(dev->data.shmem) < 0) --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list