From nobody Sat Apr 20 09:56:59 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 1548942262315578.6671088408423; Thu, 31 Jan 2019 05:44:22 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A60B141A5D; Thu, 31 Jan 2019 13:44: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 311FA60BF7; Thu, 31 Jan 2019 13:44: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 9BFC04ED29; Thu, 31 Jan 2019 13:44:16 +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 x0VDhupr017898 for ; Thu, 31 Jan 2019 08:43:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id DA9B2608C6; Thu, 31 Jan 2019 13:43:56 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61E35608E6 for ; Thu, 31 Jan 2019 13:43:56 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 31 Jan 2019 14:43:47 +0100 Message-Id: <6c1458a293e5a915f06096c891aea5bdfd006f49.1548942191.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] qemu: Always save status XML in qemuDomainBlockJobAbort 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 31 Jan 2019 13:44:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" For copy and active commit jobs we record the state of the mirror so that we can recover. The status XML was not saved in case of qemuDomainBlockPivot due to an oversight. Save the XML always when invoking qemuDomainBlockJobAbort even if the job is not currently tracking any state. This will change later and also this is not a particularly hot code path. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2485dd93eb..e422a44b2e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17311,7 +17311,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom, char *device =3D NULL; virDomainDiskDefPtr disk =3D NULL; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); - bool save =3D false; bool pivot =3D !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT); bool async =3D !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC); qemuBlockJobDataPtr job =3D NULL; @@ -17363,10 +17362,8 @@ qemuDomainBlockJobAbort(virDomainPtr dom, if ((ret =3D qemuDomainBlockPivot(driver, vm, device, disk)) < 0) goto endjob; } else { - if (disk->mirror) { + if (disk->mirror) disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_ABORT; - save =3D true; - } qemuDomainObjEnterMonitor(driver, vm); ret =3D qemuMonitorBlockJobCancel(qemuDomainGetMonitor(vm), device= ); @@ -17382,11 +17379,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, } } - /* If we have made changes to XML due to a copy job, make a best - * effort to save it now. But we can ignore failure, since there - * will be further changes when the event marks completion. */ - if (save) - ignore_value(virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm= , driver->caps)); + ignore_value(virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, dr= iver->caps)); /* * With the ABORT_ASYNC flag we don't need to do anything, the event w= ill --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 09:56:59 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 1548942260802302.5202543415478; Thu, 31 Jan 2019 05:44:20 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54BCFC08732B; Thu, 31 Jan 2019 13:44:16 +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 1E91D1048122; Thu, 31 Jan 2019 13:44:12 +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 7106B18033A2; Thu, 31 Jan 2019 13:44:11 +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 x0VDhvEc017906 for ; Thu, 31 Jan 2019 08:43:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id ACA7B608C6; Thu, 31 Jan 2019 13:43:57 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33FE0608E6 for ; Thu, 31 Jan 2019 13:43:57 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 31 Jan 2019 14:43:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] qemu: Move shareable disk check for block copy 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 31 Jan 2019 13:44:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The writing to an image actually starts when the copy job is initiated, so checking this at the time of the pivot operation is too late. Move the check to qemuDomainBlockCopyCommon. Note that modern qemu would have prevented two writers with qcow2 so the slim possibility of a job started with libvirtd without this patch missing the check is not really worth worrying about. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e422a44b2e..6674db7d20 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17140,16 +17140,6 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, goto cleanup; } - /* When pivoting to a shareable disk we need to make sure that the dis= k can - * be safely shared, since block copy might have changed the format. */ - if (disk->src->shared && !disk->src->readonly && - !qemuBlockStorageSourceSupportsConcurrentAccess(disk->mirror)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("can't pivot a shared disk to a storage volume no= t " - "supporting sharing")); - goto cleanup; - } - /* Attempt the pivot. Record the attempt now, to prevent duplicate * attempts; but the actual disk change will be made when emitting * the event. @@ -17780,6 +17770,16 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } } + /* When copying a shareable disk we need to make sure that the disk can + * be safely shared, since block copy may change the format. */ + if (disk->src->shared && !disk->src->readonly && + !qemuBlockStorageSourceSupportsConcurrentAccess(mirror)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("can't pivot a shared disk to a storage volume no= t " + "supporting sharing")); + goto endjob; + } + /* pre-create the image file */ if (!reuse) { if (virStorageFileCreate(mirror) < 0) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 09:56:59 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 1548942259035955.5309247194912; Thu, 31 Jan 2019 05:44:19 -0800 (PST) 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 022D913ABF8; Thu, 31 Jan 2019 13:44:15 +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 6523B5D744; Thu, 31 Jan 2019 13:44:15 +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 D64E84ED28; Thu, 31 Jan 2019 13:44:14 +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 x0VDhwL3017913 for ; Thu, 31 Jan 2019 08:43:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7EB8B608C6; Thu, 31 Jan 2019 13:43:58 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06DB2608E6 for ; Thu, 31 Jan 2019 13:43:57 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 31 Jan 2019 14:43:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/4] qemu: Remove unused 'cfg' qemuDomainBlockPivot 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]); Thu, 31 Jan 2019 13:44:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6674db7d20..c80d126276 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17124,7 +17124,6 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, { int ret =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; - virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); if (!disk->mirror) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -17165,7 +17164,6 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, } cleanup: - virObjectUnref(cfg); return ret; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 09:56:59 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 1548942268575750.5122535310829; Thu, 31 Jan 2019 05:44:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF50FC075BF5; Thu, 31 Jan 2019 13:44:24 +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 41EA55C23E; Thu, 31 Jan 2019 13:44:24 +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 C08B74ED41; Thu, 31 Jan 2019 13:44:23 +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 x0VDhxh5017920 for ; Thu, 31 Jan 2019 08:43:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5149C608E6; Thu, 31 Jan 2019 13:43:59 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD67E608C6 for ; Thu, 31 Jan 2019 13:43:58 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 31 Jan 2019 14:43:50 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] qemu: Use data in qemuBlockJobDataPtr instead of re-generating job name 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 31 Jan 2019 13:44:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuDomainBlockPivot and qemuDomainBlockJobAbort need the job name for cancelling or pivoting but were generating it locally instead of accessing the existing copy in the job data structure. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c80d126276..f790ffdf36 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17119,7 +17119,7 @@ qemuDomainOpenChannel(virDomainPtr dom, static int qemuDomainBlockPivot(virQEMUDriverPtr driver, virDomainObjPtr vm, - const char *device, + qemuBlockJobDataPtr job, virDomainDiskDefPtr disk) { int ret =3D -1; @@ -17151,7 +17151,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, * overall return value. */ disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT; qemuDomainObjEnterMonitor(driver, vm); - ret =3D qemuMonitorDrivePivot(priv->mon, device); + ret =3D qemuMonitorDrivePivot(priv->mon, job->name); if (qemuDomainObjExitMonitor(driver, vm) < 0) { ret =3D -1; goto cleanup; @@ -17296,7 +17296,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom, unsigned int flags) { virQEMUDriverPtr driver =3D dom->conn->privateData; - char *device =3D NULL; virDomainDiskDefPtr disk =3D NULL; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); bool pivot =3D !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT); @@ -17326,9 +17325,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom, if (!(disk =3D qemuDomainDiskByName(vm->def, path))) goto endjob; - if (!(device =3D qemuAliasDiskDriveFromDisk(disk))) - goto endjob; - if (!(job =3D qemuBlockJobDiskGetJob(disk))) { virReportError(VIR_ERR_INVALID_ARG, _("disk %s does not have an active block job"), dis= k->dst); @@ -17347,14 +17343,14 @@ qemuDomainBlockJobAbort(virDomainPtr dom, qemuBlockJobSyncBegin(job); if (pivot) { - if ((ret =3D qemuDomainBlockPivot(driver, vm, device, disk)) < 0) + if ((ret =3D qemuDomainBlockPivot(driver, vm, job, disk)) < 0) goto endjob; } else { if (disk->mirror) disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_ABORT; qemuDomainObjEnterMonitor(driver, vm); - ret =3D qemuMonitorBlockJobCancel(qemuDomainGetMonitor(vm), device= ); + ret =3D qemuMonitorBlockJobCancel(qemuDomainGetMonitor(vm), job->n= ame); if (qemuDomainObjExitMonitor(driver, vm) < 0) { ret =3D -1; goto endjob; @@ -17394,7 +17390,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom, cleanup: virObjectUnref(job); virObjectUnref(cfg); - VIR_FREE(device); virDomainObjEndAPI(&vm); return ret; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list