From nobody Wed May 1 23:08:19 2024 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 1527773194059586.4699722555396; Thu, 31 May 2018 06:26:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABCD7641D2; Thu, 31 May 2018 13:26:31 +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 E702E308BDA8; Thu, 31 May 2018 13:26:30 +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 526144CA81; Thu, 31 May 2018 13:26:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4VDQQEl024883 for ; Thu, 31 May 2018 09:26:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 98062208C6C2; Thu, 31 May 2018 13:26:26 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AD66208C6C1; Thu, 31 May 2018 13:26:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 31 May 2018 15:26:12 +0200 Message-Id: <32aa3260ceff7020f0ea0f6575afaf37a9d56126.1527773172.git.pkrempa@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH] qemu: hotplug: Fix detach of disk with managed persistent reservations 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.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 31 May 2018 13:26:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In commit 8bebb2b735d I've refactored how the detach of disk with a managed persistent reservations object is handled. After the commit if any disk with a managed PR object would be removed libvirt would also attempt to remove the shared 'pr-manager-helper' object potentially used by other disks. Thankfully this should not have practical impact as qemu should reject deletion of the object if it was still used and the rest of the code is correct. Fix this by removing the disk from the definition earlier and checking if the shared/managed pr-manager-helper object is still needed. This basically splits the detach code for the managed PR object from the unmanaged ones. The same separation will follow for the attachment code as well as it greatly simplifies -blockdev support for this. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b4bbe62c75..a14281203a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3839,6 +3839,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, char *drivestr; char *objAlias =3D NULL; char *encAlias =3D NULL; + bool prManaged =3D priv->prDaemonRunning; + bool prUsed =3D false; VIR_DEBUG("Removing disk %s from domain %p %s", disk->info.alias, vm, vm->def->name); @@ -3876,6 +3878,16 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, } } + for (i =3D 0; i < vm->def->ndisks; i++) { + if (vm->def->disks[i] =3D=3D disk) { + virDomainDiskRemove(vm->def, i); + break; + } + } + + /* check if the last disk with managed PR was just removed */ + prUsed =3D virDomainDefHasManagedPR(vm->def); + qemuDomainObjEnterMonitor(driver, vm); qemuMonitorDriveDel(priv->mon, drivestr); @@ -3892,12 +3904,16 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, VIR_FREE(encAlias); /* If it fails, then so be it - it was a best shot */ - if (disk->src->pr) + if (disk->src->pr && + !virStoragePRDefIsManaged(disk->src->pr)) ignore_value(qemuMonitorDelObject(priv->mon, disk->src->pr->mgrali= as)); if (disk->src->haveTLS) ignore_value(qemuMonitorDelObject(priv->mon, disk->src->tlsAlias)); + if (prManaged && !prUsed) + ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedP= RAlias())); + if (qemuDomainObjExitMonitor(driver, vm) < 0) return -1; @@ -3906,16 +3922,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, event =3D virDomainEventDeviceRemovedNewFromObj(vm, disk->info.alias); qemuDomainEventQueue(driver, event); - for (i =3D 0; i < vm->def->ndisks; i++) { - if (vm->def->disks[i] =3D=3D disk) { - virDomainDiskRemove(vm->def, i); - break; - } - } - - /* check if the last disk with managed PR was just removed */ - if (priv->prDaemonRunning && - !virDomainDefHasManagedPR(vm->def)) + if (prManaged && !prUsed) qemuProcessKillManagedPRDaemon(vm); qemuDomainReleaseDeviceAddress(vm, &disk->info, src); --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list