From nobody Sun May 5 09:17:47 2024 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 From nobody Sun May 5 09:17:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 148844481346288.73920205654872; Thu, 2 Mar 2017 00:53:33 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v228oZwb000919; Thu, 2 Mar 2017 03:50:35 -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 v228mkRC018824 for ; Thu, 2 Mar 2017 03:48:46 -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 v228mhLM008375 for ; Thu, 2 Mar 2017 03:48:45 -0500 From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 2 Mar 2017 09:48:41 +0100 Message-Id: <3bb55e74a1315f719c9d055a1941f409722847fa.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 2/3] qemu_domain: cleanup the controller post parse code 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 | 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(virDomainControlle= rDefPtr 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; + switch ((virDomainControllerType)cont->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: + /* set the default SCSI controller model for S390 arches */ + if (cont->model =3D=3D -1 && + ARCH_IS_S390(def->os.arch)) { + cont->model =3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI; + } + break; =20 - /* 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; - } + case VIR_DOMAIN_CONTROLLER_TYPE_USB: + if (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_S390(def->os.arch) && + cont->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE= ) { + /* set the default USB model to none for s390 unless an + * address is found */ + cont->model =3D 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 =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; + } + } + /* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr= */ + if (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; + } + if (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); + return -1; + } + break; =20 - - /* 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) { + case 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", @@ -3083,26 +3102,15 @@ qemuDomainControllerDefPostParse(virDomainControlle= rDefPtr cont, 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; - } + 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; } =20 return 0; --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 09:17:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1488444736383874.5715898928148; Thu, 2 Mar 2017 00:52:16 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v228mlCg000824; Thu, 2 Mar 2017 03:48:47 -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 v228mk68018829 for ; Thu, 2 Mar 2017 03:48:47 -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 v228mhLN008375 for ; Thu, 2 Mar 2017 03:48:46 -0500 From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 2 Mar 2017 09:48:42 +0100 Message-Id: <587207c2c8f9ea2869cfa822d1950e5fd82f4f6c.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 3/3] qemu_domain: use correct default USB controller on ppc64 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" The history of USB controller for ppc64 guest is complex and goes back to libvirt 1.3.1 where the fun started. Prior Libvirt 1.3.1 if no model for USB controller was specified we've simply passed "-usb" on QEMU command line. Since Libvirt 1.3.1 there is a patch (8156493d8db) that fixes this issue by using "-device pci-ohci,..." but it breaks migration with older Libvirts which was agreed that's acceptable. However this patch didn't reflect this change in the domain XML and the model was still missing. Since Libvirt 2.2.0 there is a patch (f55eaccb0c5) that fixes the issue with not setting the USB model into domain XML which we need to know about to not break the migration and since the default model was *pci-ohci* it was used as default in this patch as well. This patch tries to take all the previous changes into account and also change the default for newly defined domains that don't specify any model for USB controller. The VIR_DOMAIN_DEF_PARSE_ABI_UPDATE is set only if new domain is defined or new device is added into a domain which means that in all other cases we will use the old *pci-ohci* model instead of the better and not broken *nec-usb-xhci* model. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1373184 Signed-off-by: Pavel Hrdina --- src/qemu/qemu_domain.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 10e831b779..64dbd0a491 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3012,7 +3012,8 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr shm) static int qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, const virDomainDef *def, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps, + unsigned int parseFlags) { switch ((virDomainControllerType)cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: @@ -3040,9 +3041,16 @@ qemuDomainControllerDefPostParse(virDomainController= DefPtr cont, * address is found */ cont->model =3D 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)) + /* To not break migration we need to set default USB contr= oller + * for ppc64 to pci-ohci if we cannot change ABI of the VM. + * The nec-usb-xhci controller is used as default only for + * newly defined domains or devices. */ + if ((parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) { + cont->model =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XH= CI; + } else 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)) @@ -3241,7 +3249,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_CONTROLLER && qemuDomainControllerDefPostParse(dev->data.controller, def, - qemuCaps) < 0) + qemuCaps, parseFlags) < 0) goto cleanup; =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_SHMEM && --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list