From nobody Sun Feb 8 17:42:20 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552661120724917.5041037796594; Fri, 15 Mar 2019 07:45:20 -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 E8843F3FC4; Fri, 15 Mar 2019 14:45:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC4935DA2A; Fri, 15 Mar 2019 14:45:18 +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 7AF023FAF5; Fri, 15 Mar 2019 14:45:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2FEj8vB025574 for ; Fri, 15 Mar 2019 10:45:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id EABB45DA2A; Fri, 15 Mar 2019 14:45:08 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14BD45DD93; Fri, 15 Mar 2019 14:45:07 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 15 Mar 2019 15:44:58 +0100 Message-Id: <05c0e9aed89e1a2d7ee87c42c7126008bf387484.1552660971.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 4/4] qemu: hotplug: Merge virtio and non-virtio disk unplug 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: , 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.38]); Fri, 15 Mar 2019 14:45:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The functions do basically exactly the same thing modulo few checks. In case of virtio disks we check that the device is not multifunction as that can't be unplugged at once. In case of USB and SCSI disks we checked that no active block job is running. The check for running blockjobs should have also been done for virtio disks. By moving the multifunction check into the common function we fix this case and also simplify the code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 49 ++++++++--------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ffe0031362..41d60277d1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5276,43 +5276,6 @@ qemuDomainSignalDeviceRemoval(virDomainObjPtr vm, } -static int -qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDiskDefPtr detach, - bool async) -{ - int ret =3D -1; - - if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("cannot hot unplug multifunction PCI device: %s"), - detach->dst); - goto cleanup; - } - - if (!async) - qemuDomainMarkDeviceForRemoval(vm, &detach->info); - - if (qemuDomainDeleteDevice(vm, detach->info.alias) < 0) { - if (virDomainObjIsActive(vm)) - virDomainAuditDisk(vm, detach->src, NULL, "detach", false); - goto cleanup; - } - - if (async) { - ret =3D 0; - } else { - if ((ret =3D qemuDomainWaitForDeviceRemoval(vm)) =3D=3D 1) - ret =3D qemuDomainRemoveDiskDevice(driver, vm, detach); - } - - cleanup: - if (!async) - qemuDomainResetDeviceRemoval(vm); - return ret; -} - static int qemuDomainDetachDiskDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -5322,7 +5285,15 @@ qemuDomainDetachDiskDevice(virQEMUDriverPtr driver, int ret =3D -1; if (qemuDomainDiskBlockJobIsActive(detach)) - goto cleanup; + return -1; + + if (detach->bus =3D=3D VIR_DOMAIN_DISK_BUS_VIRTIO && + qemuIsMultiFunctionDevice(vm->def, &detach->info)) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("cannot hot unplug multifunction PCI device: %s"), + detach->dst); + return -1; + } if (!async) qemuDomainMarkDeviceForRemoval(vm, &detach->info); @@ -5381,8 +5352,6 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr drive= r, switch ((virDomainDiskBus) disk->bus) { case VIR_DOMAIN_DISK_BUS_VIRTIO: - return qemuDomainDetachVirtioDiskDevice(driver, vm, disk, asyn= c); - case VIR_DOMAIN_DISK_BUS_USB: case VIR_DOMAIN_DISK_BUS_SCSI: return qemuDomainDetachDiskDevice(driver, vm, disk, async); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list