From nobody Sun Feb 8 19:49:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508252717122605.5660202845049; Tue, 17 Oct 2017 08:05:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AACB7A82D; Tue, 17 Oct 2017 15:05:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B5E95E26D; Tue, 17 Oct 2017 15:05:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 97D42180BAD5; Tue, 17 Oct 2017 15:05:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9HF4s7V003096 for ; Tue, 17 Oct 2017 11:04:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C0AC60603; Tue, 17 Oct 2017 15:04:54 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7D086062B for ; Tue, 17 Oct 2017 15:04:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AACB7A82D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 17 Oct 2017 17:04:38 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/12] Use qemuDomainEnsureVirtioAddress where possible 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 17 Oct 2017 15:05:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There are two more cases where we set an S390/CCW/PCI address type based on the machine type. Reuse qemuDomainEnsureVirtioAddress to reduce repetition. --- src/qemu/qemu_hotplug.c | 56 ++++-----------------------------------------= ---- 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 177c8a01d..c65e7e500 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -498,7 +498,6 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr d= river, qemuDomainObjPrivatePtr priv =3D vm->privateData; virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_CONTROLLER, { .controller =3D controller } }; - virDomainCCWAddressSetPtr ccwaddrs =3D NULL; bool releaseaddr =3D false; =20 if (controller->type !=3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI) { @@ -523,30 +522,9 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr = driver, return -1; } =20 - if (controller->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (qemuDomainIsS390CCW(vm->def) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) - controller->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; - else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) - controller->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTI= O_S390; - } else { - if (!qemuCheckCCWS390AddressSupport(vm->def, controller->info, - priv->qemuCaps, "controller")) - goto cleanup; - } + if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "controller"= ) < 0) + return -1; =20 - if (controller->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || - controller->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) - goto cleanup; - } else if (controller->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _CCW) { - if (!(ccwaddrs =3D qemuDomainCCWAddrSetCreateFromDomain(vm->def))) - goto cleanup; - if (virDomainCCWAddressAssign(&controller->info, ccwaddrs, - !controller->info.addr.ccw.assigned)= < 0) - goto cleanup; - } - releaseaddr =3D true; if (qemuAssignDeviceControllerAlias(vm->def, priv->qemuCaps, controlle= r) < 0) goto cleanup; =20 @@ -575,7 +553,6 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr d= river, qemuDomainReleaseDeviceAddress(vm, &controller->info, NULL); =20 VIR_FREE(devstr); - virDomainCCWAddressSetFree(ccwaddrs); return ret; } =20 @@ -2115,7 +2092,6 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, bool chardevAdded =3D false; bool objAdded =3D false; virJSONValuePtr props =3D NULL; - virDomainCCWAddressSetPtr ccwaddrs =3D NULL; const char *type; int ret =3D -1; int rv; @@ -2127,31 +2103,8 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, if (VIR_REALLOC_N(vm->def->rngs, vm->def->nrngs + 1) < 0) goto cleanup; =20 - if (rng->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - if (qemuDomainIsS390CCW(vm->def) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) { - rng->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW; - } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) { - rng->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390; - } - } else { - if (!qemuCheckCCWS390AddressSupport(vm->def, rng->info, priv->qemu= Caps, - "rng")) - goto cleanup; - } - - if (rng->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || - rng->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { - if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) - goto cleanup; - } else if (rng->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { - if (!(ccwaddrs =3D qemuDomainCCWAddrSetCreateFromDomain(vm->def))) - goto cleanup; - if (virDomainCCWAddressAssign(&rng->info, ccwaddrs, - !rng->info.addr.ccw.assigned) < 0) - goto cleanup; - } - releaseaddr =3D true; + if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, "rng") < 0) + return -1; =20 if (qemuDomainNamespaceSetupRNG(driver, vm, rng) < 0) goto cleanup; @@ -2226,7 +2179,6 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, VIR_FREE(charAlias); VIR_FREE(objAlias); VIR_FREE(devstr); - virDomainCCWAddressSetFree(ccwaddrs); return ret; =20 exit_monitor: --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list