From nobody Sun Feb 8 17:41:44 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 ARC-Seal: i=1; a=rsa-sha256; t=1569513123; cv=none; d=zoho.com; s=zohoarc; b=BxC4d79r4mMYUlTaescP1yVPsE5LheEszYqmVv9UUUNC2OXGUvpLXKQyZvceYrwDw/OuNkRgC/14FPa1OA8wqBhxlIgLTJKhXeagJdhCC5nbeQOX1jgAgpiPORitIGB1FwRP5Fbfa70n8xZc2JCmeZcwVmscqgnNsIjVg9r/eyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569513123; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/lYTq9tdrqWS2K5LKp2iqBgD72p46SeDZ+v2hqjyzTI=; b=XN+I2szyD9u+/gDTmsH4O+yBVunL40UdWrNf5orzrkElrEob1gzp2nPm4KnF5V8nTwfoBe5rOs0DANzt8nF7uO9WuFGBFfUohOcL/hlQyFVfoNcj9PIlxDE6v6EEg+Dyw6XPjwiuDDBMepvG9jVDBHY6z8hHYp9XxqzK2P94uAU= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1569513123084142.59311593267148; Thu, 26 Sep 2019 08:52:03 -0700 (PDT) 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 2B90CC04AC69; Thu, 26 Sep 2019 15:52:01 +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 06D415E1B0; Thu, 26 Sep 2019 15:52:01 +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 BE6454EE69; Thu, 26 Sep 2019 15:52:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8QFpPwF000828 for ; Thu, 26 Sep 2019 11:51:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 60A1860C5D; Thu, 26 Sep 2019 15:51:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB48A60F80 for ; Thu, 26 Sep 2019 15:51:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 26 Sep 2019 17:51:11 +0200 Message-Id: <9d264be89952e426142bf623daeb7e27bcff9614.1569512942.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] qemu: Aggregate interlocking of blockjobs by checkpoints in one place 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, 26 Sep 2019 15:52:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than having to fix 5 places once we support the combination add a function called by all the blockjob/snapshot APIs. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 21 +++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_driver.c | 25 +++++-------------------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 19fa5420e7..e8a82fee0b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -15513,3 +15513,24 @@ qemuDomainDefHasManagedPR(virDomainObjPtr vm) return jobPR; } + + +/** + * qemuDomainSupportsCheckpointsBlockjobs: + * @vm: domain object + * + * Checks whether a block job is supported in possible combination with + * checkpoints (qcow2 bitmaps). Returns -1 if unsupported and reports an e= rror + * 0 in case everything is supported. + */ +int +qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm) +{ + if (virDomainListCheckpoints(vm->checkpoints, NULL, NULL, NULL, 0) > 0= ) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cannot perform block operations while checkpoint= exists")); + return -1; + } + + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index f45da882a8..01a54d4265 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1217,3 +1217,7 @@ qemuDomainPausedReasonToSuspendedEvent(virDomainPause= dReason reason); int qemuDomainValidateActualNetDef(const virDomainNetDef *net, virQEMUCapsPtr qemuCaps); + +int +qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm) + ATTRIBUTE_RETURN_CHECK; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3ad1699eb1..3847c727cf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15846,11 +15846,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, if (virDomainSnapshotCreateXMLEnsureACL(domain->conn, vm->def, flags) = < 0) goto cleanup; - if (virDomainListCheckpoints(vm->checkpoints, NULL, domain, NULL, 0) >= 0) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot create snapshot while checkpoint exists")= ); + if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) goto cleanup; - } if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto cleanup; @@ -18374,11 +18371,8 @@ qemuDomainBlockRebase(virDomainPtr dom, const char= *path, const char *base, if (virDomainBlockRebaseEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0)= { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot perform block rebase while checkpoint exi= sts")); + if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) goto cleanup; - } /* For normal rebase (enhanced blockpull), the common code handles * everything, including vm cleanup. */ @@ -18464,11 +18458,8 @@ qemuDomainBlockCopy(virDomainPtr dom, const char *= disk, const char *destxml, if (virDomainBlockCopyEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0)= { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot perform block copy while checkpoint exist= s")); + if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) goto cleanup; - } for (i =3D 0; i < nparams; i++) { virTypedParameterPtr param =3D ¶ms[i]; @@ -18532,11 +18523,8 @@ qemuDomainBlockPull(virDomainPtr dom, const char *= path, unsigned long bandwidth, if (virDomainBlockPullEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0)= { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot perform block pull while checkpoint exist= s")); + if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) goto cleanup; - } ret =3D qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags); @@ -18591,11 +18579,8 @@ qemuDomainBlockCommit(virDomainPtr dom, if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (virDomainListCheckpoints(vm->checkpoints, NULL, dom, NULL, 0) > 0)= { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot perform block commit while checkpoint exi= sts")); + if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) goto cleanup; - } if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list