From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027543; cv=none; d=zohomail.com; s=zohoarc; b=cgQLWfBKgXIooIdkW8NADHFiNy1rbU4hONwuY/voQupo/JaGS5TRG9IzPNOK2LqY1mBPoVTmg+ISrzqYyB4VCcCg5Z9oqrdrQF8w8CJThBLqdz2vszqxEuts0LRIb8jH3RL/HMi+52MvlywTbQ+69QIQxQnsG7w9BI5f3c8QwTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027543; 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; bh=zV2G8l6hCPOU0/fm8wba2BSoCSR8llhyRGL8WJdegt0=; b=YjDN2xY1XAlbYuCoKRTuLaVWS6s6yScCxdWofIHnoEawhidEtidWGdXggfkXyrvO30QbVUDq89wc1BjlBeRA14yKUK/Hcaqld1mM/OY1TZmpsmBUe2p6tAXVjNb2TOTgsxaMiB4JFe5tos5bzAhnX4Iz1sfSt9yLMvq8V9k4olI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167302754315395.3937138977476; Fri, 6 Jan 2023 09:52:23 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-522-2g7wojNPOKGGVyFaKYPD8A-1; Fri, 06 Jan 2023 12:52:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A33B5281723B; Fri, 6 Jan 2023 17:52:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 597D22026D4B; Fri, 6 Jan 2023 17:52:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9EB51194706E; Fri, 6 Jan 2023 17:52:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7DCF31947073 for ; Fri, 6 Jan 2023 17:52:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6D4A440C2064; Fri, 6 Jan 2023 17:52:15 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AED940C2005 for ; Fri, 6 Jan 2023 17:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027542; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zV2G8l6hCPOU0/fm8wba2BSoCSR8llhyRGL8WJdegt0=; b=ZueScNbLj7xQwr0Aqv3DrYOmpTIS29YjXnJFfeFssAMpDHCbJ18xnfIeZxVbDSsgY8FWiu eu3HzViSI1UyfC2pf8uawSP1VsPvXKI6j8U7j0QDVeAN1Vd5cFy7wfnKqkYlNzogbwth5X mCYvf73Dd3uFxiZ2E+FoDBE0FMgNcg4= X-MC-Unique: 2g7wojNPOKGGVyFaKYPD8A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 01/32] libvirt: introduce VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE Date: Fri, 6 Jan 2023 18:51:36 +0100 Message-Id: <44e2e8186ffab32465eff0f5ac8b3a4f82b4be08.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027545006100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This will be used by snapshot delete async domain job. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- include/libvirt/libvirt-domain.h | 1 + tools/virsh-domain.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 295fd30c93..4b1de1d5b8 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4172,6 +4172,7 @@ typedef enum { VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT =3D 7, /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_DUMP =3D 8, /* (Since: 3.3.0) */ VIR_DOMAIN_JOB_OPERATION_BACKUP =3D 9, /* (Since: 6.0.0) */ + VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE =3D 10, /* (Since: 9.0.0) */ =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_JOB_OPERATION_LAST /* (Since: 3.3.0) */ diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 2d162cf8c0..3e94744c95 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6141,6 +6141,7 @@ VIR_ENUM_IMPL(virshDomainJobOperation, N_("Snapshot revert"), N_("Dump"), N_("Backup"), + N_("Snapshot delete"), ); =20 static const char * --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027550; cv=none; d=zohomail.com; s=zohoarc; b=VjCTBvg5d+nBVlQ7ovECgGVfGpW1fYROeIMJwihERtCcSROBoeepWYY6D00faE70oMVRRb9VewDhXq2vYqZjJiy9jDjY41iAuuUV2QMNXvk7d+2AbpdFtcBybmHDdG/6/6m5BVt6rU9G5mWxjK1QfRK2v1Demew1Z0+ZOjELjpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027550; 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; bh=5GtxUf+lqVNlAuJ9dC7QJnscx5k06MX+9ykJxoONu50=; b=cCkuTZG1Ji8RLJA5wviEw7A1/8dp7L+vmjKy4SUE6Sc0Dlvpbcjjs68BB1DOErVaVJyv5i57dSmfftl0tNOjGcTspttzDNeeci96Uodbymt6ELc8nQVE2P5/vKA6vCuMeUHPZai6TJKN+SNSvh29BETqduCDB3yAeHXqfLoOza0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 167302755055989.45744683500163; Fri, 6 Jan 2023 09:52:30 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-o0D2FXftM8qAlbQsTfL6XA-1; Fri, 06 Jan 2023 12:52:23 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90B8A805563; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 775372166B3A; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1913D19459D0; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 29714194707C for ; Fri, 6 Jan 2023 17:52:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1BDD340C2005; Fri, 6 Jan 2023 17:52:16 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA83040C2064 for ; Fri, 6 Jan 2023 17:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027549; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5GtxUf+lqVNlAuJ9dC7QJnscx5k06MX+9ykJxoONu50=; b=HmAlfcJZMtnzxRJtetIFuPYMPWiKmOnU/+mRMmoa1ny3du2BJdKpl/G0kLMRGH2UuOYnxi HNMZd2DpScrvst5GaFqfQH1OZeh8PtpaPZfU7eE1acckmkssFBfnFvx+GM1vkw+2I/3u3W BrN8anMulR2Fhftg6F8izv5bIB8nPEc= X-MC-Unique: o0D2FXftM8qAlbQsTfL6XA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 02/32] qemu_block: extract block commit code to separate function Date: Fri, 6 Jan 2023 18:51:37 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027551131100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 177 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 9 +++ src/qemu/qemu_driver.c | 162 +------------------------------------ 3 files changed, 187 insertions(+), 161 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8a6f601b29..825db3e088 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3196,3 +3196,180 @@ qemuBlockExportAddNBD(virDomainObj *vm, =20 return qemuMonitorBlockExportAdd(priv->mon, &nbdprops); } + + +int +qemuBlockCommit(virDomainObj *vm, + virDomainDiskDef *disk, + virStorageSource *baseSource, + virStorageSource *topSource, + virStorageSource *top_parent, + unsigned long bandwidth, + unsigned int flags) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + int ret =3D -1; + bool clean_access =3D false; + g_autofree char *backingPath =3D NULL; + qemuBlockJobData *job =3D NULL; + g_autoptr(virStorageSource) mirror =3D NULL; + + if (virDomainObjCheckActive(vm) < 0) + return -1; + + /* Convert bandwidth MiB to bytes, if necessary */ + if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) { + if (bandwidth > LLONG_MAX >> 20) { + virReportError(VIR_ERR_OVERFLOW, + _("bandwidth must be less than %llu"), + LLONG_MAX >> 20); + return -1; + } + bandwidth <<=3D 20; + } + + if (!qemuDomainDiskBlockJobIsSupported(disk)) + return -1; + + if (virStorageSourceIsEmpty(disk->src)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk %s has no source file to be committed"), + disk->dst); + return -1; + } + + if (qemuDomainDiskBlockJobIsActive(disk)) + return -1; + + if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) + return -1; + + if (topSource =3D=3D disk->src) { + /* XXX Should we auto-pivot when COMMIT_ACTIVE is not specified? */ + if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_ACTIVE)) { + virReportError(VIR_ERR_INVALID_ARG, + _("commit of '%s' active layer requires active = flag"), + disk->dst); + return -1; + } + } else if (flags & VIR_DOMAIN_BLOCK_COMMIT_ACTIVE) { + virReportError(VIR_ERR_INVALID_ARG, + _("active commit requested but '%s' is not active"), + topSource->path); + return -1; + } + + if (!virStorageSourceHasBacking(topSource)) { + virReportError(VIR_ERR_INVALID_ARG, + _("top '%s' in chain for '%s' has no backing file"), + topSource->path, disk->src->path); + return -1; + } + + if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) && + baseSource !=3D topSource->backingStore) { + virReportError(VIR_ERR_INVALID_ARG, + _("base '%s' is not immediately below '%s' in chain= " + "for '%s'"), + baseSource->path, topSource->path, disk->src->path); + return -1; + } + + /* For an active commit, clone enough of the base to act as the mirror= */ + if (topSource =3D=3D disk->src) { + if (!(mirror =3D virStorageSourceCopy(baseSource, false))) + return -1; + if (virStorageSourceInitChainElement(mirror, + disk->src, + true) < 0) + return -1; + } + + if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE && + topSource !=3D disk->src) { + if (top_parent && + qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0) + return -1; + + if (virStorageSourceGetRelativeBackingPath(topSource, baseSource, + &backingPath) < 0) + return -1; + + if (!backingPath) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("can't keep relative backing relationship")); + return -1; + } + } + + /* For the commit to succeed, we must allow qemu to open both the + * 'base' image and the parent of 'top' as read/write; 'top' might + * not have a parent, or might already be read-write. XXX It + * would also be nice to revert 'base' to read-only, as well as + * revoke access to files removed from the chain, when the commit + * operation succeeds, but doing that requires tracking the + * operation in XML across libvirtd restarts. */ + clean_access =3D true; + if (qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, + false, false, false) < 0) + goto cleanup; + + if (top_parent && top_parent !=3D disk->src) { + /* While top_parent is topmost image, we don't need to remember its + * owner as it will be overwritten upon finishing the commit. Henc= e, + * pass chainTop =3D false. */ + if (qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, + false, false, false) < 0) + goto cleanup; + } + + if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, + baseSource, + flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE, + flags))) + goto cleanup; + + disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; + + if (!backingPath && top_parent && + !(backingPath =3D qemuBlockGetBackingStoreString(baseSource, false= ))) + goto cleanup; + + qemuDomainObjEnterMonitor(vm); + + ret =3D qemuMonitorBlockCommit(priv->mon, + qemuDomainDiskGetTopNodename(disk), + job->name, + topSource->nodeformat, + baseSource->nodeformat, + backingPath, bandwidth); + + qemuDomainObjExitMonitor(vm); + + if (ret < 0) + goto cleanup; + + if (mirror) { + disk->mirror =3D g_steal_pointer(&mirror); + disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT; + } + qemuBlockJobStarted(job, vm); + + cleanup: + if (ret < 0 && clean_access) { + virErrorPtr orig_err; + virErrorPreserveLast(&orig_err); + /* Revert access to read-only, if possible. */ + qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, + true, false, false); + if (top_parent && top_parent !=3D disk->src) + qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, + true, false, false); + + virErrorRestore(&orig_err); + } + qemuBlockJobStartupFinalize(vm, job); + + return ret; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 8a3a10344e..85b4805d89 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -276,3 +276,12 @@ qemuBlockExportAddNBD(virDomainObj *vm, const char *exportname, bool writable, const char *bitmap); + +int +qemuBlockCommit(virDomainObj *vm, + virDomainDiskDef *disk, + virStorageSource *baseSource, + virStorageSource *topSource, + virStorageSource *top_parent, + unsigned long bandwidth, + unsigned int flags); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f4bd081f3c..331e6ca50b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15109,19 +15109,12 @@ qemuDomainBlockCommit(virDomainPtr dom, unsigned long bandwidth, unsigned int flags) { - virQEMUDriver *driver =3D dom->conn->privateData; - qemuDomainObjPrivate *priv; virDomainObj *vm =3D NULL; int ret =3D -1; virDomainDiskDef *disk =3D NULL; virStorageSource *topSource; virStorageSource *baseSource =3D NULL; virStorageSource *top_parent =3D NULL; - bool clean_access =3D false; - g_autofree char *backingPath =3D NULL; - unsigned long long speed =3D bandwidth; - qemuBlockJobData *job =3D NULL; - g_autoptr(virStorageSource) mirror =3D NULL; =20 virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW | VIR_DOMAIN_BLOCK_COMMIT_ACTIVE | @@ -15131,7 +15124,6 @@ qemuDomainBlockCommit(virDomainPtr dom, =20 if (!(vm =3D qemuDomainObjFromDomain(dom))) goto cleanup; - priv =3D vm->privateData; =20 if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -15139,176 +15131,24 @@ qemuDomainBlockCommit(virDomainPtr dom, if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 - if (virDomainObjCheckActive(vm) < 0) - goto endjob; - - /* Convert bandwidth MiB to bytes, if necessary */ - if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) { - if (speed > LLONG_MAX >> 20) { - virReportError(VIR_ERR_OVERFLOW, - _("bandwidth must be less than %llu"), - LLONG_MAX >> 20); - goto endjob; - } - speed <<=3D 20; - } - if (!(disk =3D qemuDomainDiskByName(vm->def, path))) goto endjob; =20 - if (!qemuDomainDiskBlockJobIsSupported(disk)) - goto endjob; - - if (virStorageSourceIsEmpty(disk->src)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("disk %s has no source file to be committed"), - disk->dst); - goto endjob; - } - - if (qemuDomainDiskBlockJobIsActive(disk)) - goto endjob; - - if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) - goto endjob; - if (!top || STREQ(top, disk->dst)) topSource =3D disk->src; else if (!(topSource =3D virStorageSourceChainLookup(disk->src, NULL, = top, disk->dst, &top_par= ent))) goto endjob; =20 - if (topSource =3D=3D disk->src) { - /* XXX Should we auto-pivot when COMMIT_ACTIVE is not specified? */ - if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_ACTIVE)) { - virReportError(VIR_ERR_INVALID_ARG, - _("commit of '%s' active layer requires active = flag"), - disk->dst); - goto endjob; - } - } else if (flags & VIR_DOMAIN_BLOCK_COMMIT_ACTIVE) { - virReportError(VIR_ERR_INVALID_ARG, - _("active commit requested but '%s' is not active"), - topSource->path); - goto endjob; - } - - if (!virStorageSourceHasBacking(topSource)) { - virReportError(VIR_ERR_INVALID_ARG, - _("top '%s' in chain for '%s' has no backing file"), - topSource->path, path); - goto endjob; - } - if (!base && (flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW)) baseSource =3D topSource->backingStore; else if (!(baseSource =3D virStorageSourceChainLookup(disk->src, topSo= urce, base, disk->dst, N= ULL))) goto endjob; =20 - if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) && - baseSource !=3D topSource->backingStore) { - virReportError(VIR_ERR_INVALID_ARG, - _("base '%s' is not immediately below '%s' in chain= " - "for '%s'"), - base, topSource->path, path); - goto endjob; - } - - /* For an active commit, clone enough of the base to act as the mirror= */ - if (topSource =3D=3D disk->src) { - if (!(mirror =3D virStorageSourceCopy(baseSource, false))) - goto endjob; - if (virStorageSourceInitChainElement(mirror, - disk->src, - true) < 0) - goto endjob; - } - - if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE && - topSource !=3D disk->src) { - if (top_parent && - qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0) - goto endjob; - - if (virStorageSourceGetRelativeBackingPath(topSource, baseSource, - &backingPath) < 0) - goto endjob; - - if (!backingPath) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("can't keep relative backing relationship")); - goto endjob; - } - } - - /* For the commit to succeed, we must allow qemu to open both the - * 'base' image and the parent of 'top' as read/write; 'top' might - * not have a parent, or might already be read-write. XXX It - * would also be nice to revert 'base' to read-only, as well as - * revoke access to files removed from the chain, when the commit - * operation succeeds, but doing that requires tracking the - * operation in XML across libvirtd restarts. */ - clean_access =3D true; - if (qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, - false, false, false) < 0) - goto endjob; - - if (top_parent && top_parent !=3D disk->src) { - /* While top_parent is topmost image, we don't need to remember its - * owner as it will be overwritten upon finishing the commit. Henc= e, - * pass chainTop =3D false. */ - if (qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, - false, false, false) < 0) - goto endjob; - } - - if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, - baseSource, - flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE, - flags))) - goto endjob; - - disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; - - if (!backingPath && top_parent && - !(backingPath =3D qemuBlockGetBackingStoreString(baseSource, false= ))) - goto endjob; - - qemuDomainObjEnterMonitor(vm); - - ret =3D qemuMonitorBlockCommit(priv->mon, - qemuDomainDiskGetTopNodename(disk), - job->name, - topSource->nodeformat, - baseSource->nodeformat, - backingPath, speed); - - qemuDomainObjExitMonitor(vm); - - if (ret < 0) - goto endjob; - - if (mirror) { - disk->mirror =3D g_steal_pointer(&mirror); - disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT; - } - qemuBlockJobStarted(job, vm); + ret =3D qemuBlockCommit(vm, disk, baseSource, topSource, top_parent, b= andwidth, flags); =20 endjob: - if (ret < 0 && clean_access) { - virErrorPtr orig_err; - virErrorPreserveLast(&orig_err); - /* Revert access to read-only, if possible. */ - qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, - true, false, false); - if (top_parent && top_parent !=3D disk->src) - qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, - true, false, false); - - virErrorRestore(&orig_err); - } - qemuBlockJobStartupFinalize(vm, job); virDomainObjEndJob(vm); =20 cleanup: --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027545; cv=none; d=zohomail.com; s=zohoarc; b=H54/D+CM0EJ8msod4O5+iU73tY1oTBxB3guxd7cDT5wFMat39MgfSOesKmX92ROQytijCtmi9CqfawW/r2snm72CWOtmYGyGLTZHsOkoHkVfSfyPXaDP0QiXFI4bQzdAzlATiBsqh1qeWcXFSoviCEKq9jd1ilI4oBDydNT6Jms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027545; 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; bh=9gij5Hg+lbTYcHNpZybp1SKsW/C2tgtglwn0khuwQJo=; b=ieBmMu3Pm0NPgdGgj7ypWACKCucIQPZqEdWLc5udwiu5KDDmhsr5NqlFwO68akGVb70gcughSAgKs0PMqso/VBhonqYuyQAbjIPjWf9K2llQkYcuESjWkv1kaUfxDQXuLQeuOkOGM8r6fK5sLGyl9zk2evfDzkIuRgpx4fVKPVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027545591744.0210396972061; Fri, 6 Jan 2023 09:52:25 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-2Zn5d46dNPChv68qR0p1sQ-1; Fri, 06 Jan 2023 12:52:20 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FDF9281722E; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEB1040C2006; Fri, 6 Jan 2023 17:52:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D5BCB194706F; Fri, 6 Jan 2023 17:52:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D751A19459C7 for ; Fri, 6 Jan 2023 17:52:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BB8AA40C2005; Fri, 6 Jan 2023 17:52:16 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5967240C2064 for ; Fri, 6 Jan 2023 17:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027544; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9gij5Hg+lbTYcHNpZybp1SKsW/C2tgtglwn0khuwQJo=; b=TosHg3qJ61O3y1gnD/59eUkqfLokXxbbZavOK6Jku9Qg8JPRlKBWjt3C0z0NtaNnRbNrGU 4ejiNn8nPiiryd7YmKC5WPlClj8p/VqRdjeW4hxdPYg/jgv5A/LHtU4a94qm3nbi67ubBl g59uMYoxkH9A5O/e1E9jNVoMsEYaMbw= X-MC-Unique: 2Zn5d46dNPChv68qR0p1sQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 03/32] qemu_block: move qemuDomainBlockPivot out of qemu_driver Date: Fri, 6 Jan 2023 18:51:38 +0100 Message-Id: <8aef87dbbc90dd20cc3d204d3d8848cfc7304ab7.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027547133100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Move the code for finishing a job in the ready state to qemu_block.c. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 121 ++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 5 ++ src/qemu/qemu_driver.c | 123 +---------------------------------------- 3 files changed, 127 insertions(+), 122 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 825db3e088..6d31269ddd 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3373,3 +3373,124 @@ qemuBlockCommit(virDomainObj *vm, =20 return ret; } + + +/* Called while holding the VM job lock, to implement a block job + * abort with pivot; this updates the VM definition as appropriate, on + * either success or failure. */ +int +qemuBlockPivot(virDomainObj *vm, + qemuBlockJobData *job, + virDomainDiskDef *disk) +{ + g_autoptr(qemuBlockStorageSourceChainData) chainattachdata =3D NULL; + int ret =3D -1; + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(virJSONValue) bitmapactions =3D NULL; + g_autoptr(virJSONValue) reopenactions =3D NULL; + int rc =3D 0; + + if (job->state !=3D QEMU_BLOCKJOB_STATE_READY) { + virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, + _("block job '%s' not ready for pivot yet"), + job->name); + return -1; + } + + switch ((qemuBlockJobType) job->type) { + case QEMU_BLOCKJOB_TYPE_NONE: + case QEMU_BLOCKJOB_TYPE_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid job type '%d'"), job->type); + return -1; + + case QEMU_BLOCKJOB_TYPE_PULL: + case QEMU_BLOCKJOB_TYPE_COMMIT: + case QEMU_BLOCKJOB_TYPE_BACKUP: + case QEMU_BLOCKJOB_TYPE_INTERNAL: + case QEMU_BLOCKJOB_TYPE_CREATE: + case QEMU_BLOCKJOB_TYPE_BROKEN: + virReportError(VIR_ERR_OPERATION_INVALID, + _("job type '%s' does not support pivot"), + qemuBlockjobTypeToString(job->type)); + return -1; + + case QEMU_BLOCKJOB_TYPE_COPY: + if (!job->jobflagsmissing) { + bool shallow =3D job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW; + bool reuse =3D job->jobflags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT; + + bitmapactions =3D virJSONValueNewArray(); + + if (qemuMonitorTransactionBitmapAdd(bitmapactions, + disk->mirror->nodeformat, + "libvirt-tmp-activewrite", + false, + false, + 0) < 0) + return -1; + + /* Open and install the backing chain of 'mirror' late if we c= an use + * blockdev-snapshot to do it. This is to appease oVirt that w= ants + * to copy data into the backing chain while the top image is = being + * copied shallow */ + if (reuse && shallow && + virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_SNAPSHOT= _ALLOW_WRITE_ONLY) && + virStorageSourceHasBacking(disk->mirror)) { + + if (!(chainattachdata =3D qemuBuildStorageSourceChainAttac= hPrepareBlockdev(disk->mirror->backingStore))) + return -1; + + reopenactions =3D virJSONValueNewArray(); + + if (qemuMonitorTransactionSnapshotBlockdev(reopenactions, + disk->mirror->b= ackingStore->nodeformat, + disk->mirror->n= odeformat)) + return -1; + } + + } + break; + + case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: + bitmapactions =3D virJSONValueNewArray(); + + if (qemuMonitorTransactionBitmapAdd(bitmapactions, + job->data.commit.base->nodefor= mat, + "libvirt-tmp-activewrite", + false, + false, + 0) < 0) + return -1; + + break; + } + + qemuDomainObjEnterMonitor(vm); + + if (chainattachdata) { + if ((rc =3D qemuBlockStorageSourceChainAttach(priv->mon, chainatta= chdata)) =3D=3D 0) { + /* install backing images on success, or unplug them on failur= e */ + if ((rc =3D qemuMonitorTransaction(priv->mon, &reopenactions))= !=3D 0) + qemuBlockStorageSourceChainDetach(priv->mon, chainattachda= ta); + } + } + + if (bitmapactions && rc =3D=3D 0) + ignore_value(qemuMonitorTransaction(priv->mon, &bitmapactions)); + + if (rc =3D=3D 0) + ret =3D qemuMonitorJobComplete(priv->mon, job->name); + + qemuDomainObjExitMonitor(vm); + + /* The pivot failed. The block job in QEMU remains in the synchronised= state */ + if (ret < 0) + return -1; + + if (disk && disk->mirror) + disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT; + job->state =3D QEMU_BLOCKJOB_STATE_PIVOTING; + + return ret; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 85b4805d89..52deb15a3d 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -285,3 +285,8 @@ qemuBlockCommit(virDomainObj *vm, virStorageSource *top_parent, unsigned long bandwidth, unsigned int flags); + +int +qemuBlockPivot(virDomainObj *vm, + qemuBlockJobData *job, + virDomainDiskDef *disk); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 331e6ca50b..c35e5e1a31 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13996,127 +13996,6 @@ qemuDomainOpenChannel(virDomainPtr dom, } =20 =20 -/* Called while holding the VM job lock, to implement a block job - * abort with pivot; this updates the VM definition as appropriate, on - * either success or failure. */ -static int -qemuDomainBlockPivot(virDomainObj *vm, - qemuBlockJobData *job, - virDomainDiskDef *disk) -{ - g_autoptr(qemuBlockStorageSourceChainData) chainattachdata =3D NULL; - int ret =3D -1; - qemuDomainObjPrivate *priv =3D vm->privateData; - g_autoptr(virJSONValue) bitmapactions =3D NULL; - g_autoptr(virJSONValue) reopenactions =3D NULL; - int rc =3D 0; - - if (job->state !=3D QEMU_BLOCKJOB_STATE_READY) { - virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, - _("block job '%s' not ready for pivot yet"), - job->name); - return -1; - } - - switch ((qemuBlockJobType) job->type) { - case QEMU_BLOCKJOB_TYPE_NONE: - case QEMU_BLOCKJOB_TYPE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid job type '%d'"), job->type); - return -1; - - case QEMU_BLOCKJOB_TYPE_PULL: - case QEMU_BLOCKJOB_TYPE_COMMIT: - case QEMU_BLOCKJOB_TYPE_BACKUP: - case QEMU_BLOCKJOB_TYPE_INTERNAL: - case QEMU_BLOCKJOB_TYPE_CREATE: - case QEMU_BLOCKJOB_TYPE_BROKEN: - virReportError(VIR_ERR_OPERATION_INVALID, - _("job type '%s' does not support pivot"), - qemuBlockjobTypeToString(job->type)); - return -1; - - case QEMU_BLOCKJOB_TYPE_COPY: - if (!job->jobflagsmissing) { - bool shallow =3D job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW; - bool reuse =3D job->jobflags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT; - - bitmapactions =3D virJSONValueNewArray(); - - if (qemuMonitorTransactionBitmapAdd(bitmapactions, - disk->mirror->nodeformat, - "libvirt-tmp-activewrite", - false, - false, - 0) < 0) - return -1; - - /* Open and install the backing chain of 'mirror' late if we c= an use - * blockdev-snapshot to do it. This is to appease oVirt that w= ants - * to copy data into the backing chain while the top image is = being - * copied shallow */ - if (reuse && shallow && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_SNAPSHOT= _ALLOW_WRITE_ONLY) && - virStorageSourceHasBacking(disk->mirror)) { - - if (!(chainattachdata =3D qemuBuildStorageSourceChainAttac= hPrepareBlockdev(disk->mirror->backingStore))) - return -1; - - reopenactions =3D virJSONValueNewArray(); - - if (qemuMonitorTransactionSnapshotBlockdev(reopenactions, - disk->mirror->b= ackingStore->nodeformat, - disk->mirror->n= odeformat)) - return -1; - } - - } - break; - - case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: - bitmapactions =3D virJSONValueNewArray(); - - if (qemuMonitorTransactionBitmapAdd(bitmapactions, - job->data.commit.base->nodefor= mat, - "libvirt-tmp-activewrite", - false, - false, - 0) < 0) - return -1; - - break; - } - - qemuDomainObjEnterMonitor(vm); - - if (chainattachdata) { - if ((rc =3D qemuBlockStorageSourceChainAttach(priv->mon, chainatta= chdata)) =3D=3D 0) { - /* install backing images on success, or unplug them on failur= e */ - if ((rc =3D qemuMonitorTransaction(priv->mon, &reopenactions))= !=3D 0) - qemuBlockStorageSourceChainDetach(priv->mon, chainattachda= ta); - } - } - - if (bitmapactions && rc =3D=3D 0) - ignore_value(qemuMonitorTransaction(priv->mon, &bitmapactions)); - - if (rc =3D=3D 0) - ret =3D qemuMonitorJobComplete(priv->mon, job->name); - - qemuDomainObjExitMonitor(vm); - - /* The pivot failed. The block job in QEMU remains in the synchronised= state */ - if (ret < 0) - return -1; - - if (disk && disk->mirror) - disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT; - job->state =3D QEMU_BLOCKJOB_STATE_PIVOTING; - - return ret; -} - - /* bandwidth in MiB/s per public API. Caller must lock vm beforehand, * and not access it afterwards. */ static int @@ -14279,7 +14158,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, qemuBlockJobSyncBegin(job); =20 if (pivot) { - if ((ret =3D qemuDomainBlockPivot(vm, job, disk)) < 0) + if ((ret =3D qemuBlockPivot(vm, job, disk)) < 0) goto endjob; } else { qemuDomainObjEnterMonitor(vm); --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027554; cv=none; d=zohomail.com; s=zohoarc; b=UzyGpIPkrvPkPfz0ZjF3LwGXEqdluhqHyE3dp9FA+Wlth9KzCd4D+xA+2PX2y15HBKkvImkujaJfyd+0nq42pbrlSL3fQgKH4skca7bd1+zD+Lgi7CNAznouaZVYMVmynox/IPVnvqHDvvXMRNbQyIKVF+c2rSWBo+zLXK1dTz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027554; 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; bh=kjFjsnodDajed35Vx7Qcn7uK7QZqeCxW/AoyxacIWrY=; b=IKXgekq5YxrVxLJddwKplYsV3d+uzsd02g0M3sZAC76TNJ+xndLTnIE3TpTgIhTBgR8wwMQKOD+Thi5nCaE6eWvRTN2NmxOf010/bM1kFvMK4qFm3JAylW+limVh0DSPlyJfCEUv+MQQXCXJPqVnEELRFdOprOkND6WY/u6e4+4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027554598296.0590021371921; Fri, 6 Jan 2023 09:52:34 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-302-v45qepdxNJCAYpiG0NKDNA-1; Fri, 06 Jan 2023 12:52:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E612A3C0253D; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDC33C15BAD; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A89C91947073; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7033F1946586 for ; Fri, 6 Jan 2023 17:52:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6602C40C2007; Fri, 6 Jan 2023 17:52:17 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0448640C2005 for ; Fri, 6 Jan 2023 17:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027553; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kjFjsnodDajed35Vx7Qcn7uK7QZqeCxW/AoyxacIWrY=; b=XMRUXKVqUzXguVBWs+71udM4hWuq0HLgEah1JehVQMurCqASmH+abJ0UvOo745PmBLdTeS Hc5cOgdxzV9AbEvfi6+7MKzGMl8ybKY9L1WNWThJqXWJ+0bn8vIG+UOrcrls8yL28fN1OV IvHcjnjEJn5XBQG96BQCrHn1LNFzXLg= X-MC-Unique: v45qepdxNJCAYpiG0NKDNA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 04/32] qemu_block: add async domain job support to qemuBlockCommit Date: Fri, 6 Jan 2023 18:51:39 +0100 Message-Id: <84e64ce20201ca7ec11f55ed285c5f764c6570b1.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027555059100014 Content-Type: text/plain; charset="utf-8"; x-default="true" This will allow to use it while having async domain job active which we will use when deleting external snapshots. At the same time we will need to have the block job started as synchronous. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 23 ++++++++++++++++++++++- src/qemu/qemu_block.h | 1 + src/qemu/qemu_driver.c | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 6d31269ddd..d2a56ba19c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3198,6 +3198,22 @@ qemuBlockExportAddNBD(virDomainObj *vm, } =20 =20 +/** + * qemuBlockCommit: + * @vm: domain object + * @disk: disk object where we are about to block commit + * @baseSource: disk source within backing chain to commit data into + * @topSource: disk source within backing chain with data we will commit + * @top_parent: disk source that has @topSource as backing disk + * @bandwidth: bandwidth limit, flags determine the unit + * @asyncJob: qemu async job type + * @flags: bitwise-OR of virDomainBlockCommitFlags + * + * Starts a block commit job for @disk. If @asyncJob is different then + * VIR_ASYNC_JOB_NONE the job will be started as synchronous. + * + * Returns -1 on error, 0 on success. + */ int qemuBlockCommit(virDomainObj *vm, virDomainDiskDef *disk, @@ -3205,6 +3221,7 @@ qemuBlockCommit(virDomainObj *vm, virStorageSource *topSource, virStorageSource *top_parent, unsigned long bandwidth, + virDomainAsyncJob asyncJob, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -3336,7 +3353,11 @@ qemuBlockCommit(virDomainObj *vm, !(backingPath =3D qemuBlockGetBackingStoreString(baseSource, false= ))) goto cleanup; =20 - qemuDomainObjEnterMonitor(vm); + if (asyncJob !=3D VIR_ASYNC_JOB_NONE) + qemuBlockJobSyncBegin(job); + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + goto cleanup; =20 ret =3D qemuMonitorBlockCommit(priv->mon, qemuDomainDiskGetTopNodename(disk), diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 52deb15a3d..a76d9be711 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -284,6 +284,7 @@ qemuBlockCommit(virDomainObj *vm, virStorageSource *topSource, virStorageSource *top_parent, unsigned long bandwidth, + virDomainAsyncJob asyncJob, unsigned int flags); =20 int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c35e5e1a31..f7a7086b3d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15025,7 +15025,8 @@ qemuDomainBlockCommit(virDomainPtr dom, base, disk->dst, N= ULL))) goto endjob; =20 - ret =3D qemuBlockCommit(vm, disk, baseSource, topSource, top_parent, b= andwidth, flags); + ret =3D qemuBlockCommit(vm, disk, baseSource, topSource, top_parent, + bandwidth, VIR_ASYNC_JOB_NONE, flags); =20 endjob: virDomainObjEndJob(vm); --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027546; cv=none; d=zohomail.com; s=zohoarc; b=IOVwLCcJNTORfLWnWuOyqrB6C0K05QzjsTHaSYXFP16+OH3hn1RKDl7tGaLaklCkdqG7fxE2/7bQA3zPQkPEJBQ5GSFAdPp5e/zaUWsFDtL9o0owQKHLjNdeSZagOMOC6BujAZ0TcKuLgk8kKtXqNcs2HxcNrc7X8sl2E46/lV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027546; 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; bh=+aXQLqpIZTW6Qpmi97ZyGOmxbM+HsL7RUbTHXiqlySc=; b=OgtyGQB3vkG+ko0EgWgC1lj3cFbueIoYV3EIJJl49Ja6pSumTCHiIG2dikGW3laTy8imnpj3vFs+bEcPRhxEk7lo2MRXBiD66d9V37WrLT5wGW+sFpYGj0HDuP8i5OTF0yIRzj8PAVel0uiTVHTxD1JDEbrQW311wK0yGHPlDYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027546882926.4469244489538; Fri, 6 Jan 2023 09:52:26 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-HUL1Pu-xMmmNGOLly7IeAw-1; Fri, 06 Jan 2023 12:52:22 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 49BEA1875043; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 336F32027001; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F118119459C5; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2AA0E1947074 for ; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 10F2340C2008; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id A348840C2064 for ; Fri, 6 Jan 2023 17:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027545; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+aXQLqpIZTW6Qpmi97ZyGOmxbM+HsL7RUbTHXiqlySc=; b=ZJ1HM7mUl3lv0rjsV+AwizFjKMiK6JLBA8UzjGyuHKxLJuEiz6eigw7sKk4h9ig1RKrWty e2nf5A2amCPrqwrGIjt/oYkhLWs4YIG+QDhFpJjmNYA0gVyXluWjXtkq60ZdoqQyQv+MKn wE3izxoTCY2TXxUxTvtTCVLuPP9/3Qo= X-MC-Unique: HUL1Pu-xMmmNGOLly7IeAw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 05/32] qemu_block: add async domain job support to qemuBlockPivot Date: Fri, 6 Jan 2023 18:51:40 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027549006100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This will allow to use it while having async domain job active which we will use when deleting external snapshots. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 4 +++- src/qemu/qemu_block.h | 1 + src/qemu/qemu_driver.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index d2a56ba19c..6a68362708 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3402,6 +3402,7 @@ qemuBlockCommit(virDomainObj *vm, int qemuBlockPivot(virDomainObj *vm, qemuBlockJobData *job, + virDomainAsyncJob asyncJob, virDomainDiskDef *disk) { g_autoptr(qemuBlockStorageSourceChainData) chainattachdata =3D NULL; @@ -3487,7 +3488,8 @@ qemuBlockPivot(virDomainObj *vm, break; } =20 - qemuDomainObjEnterMonitor(vm); + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return -1; =20 if (chainattachdata) { if ((rc =3D qemuBlockStorageSourceChainAttach(priv->mon, chainatta= chdata)) =3D=3D 0) { diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index a76d9be711..3f2082f102 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -290,4 +290,5 @@ qemuBlockCommit(virDomainObj *vm, int qemuBlockPivot(virDomainObj *vm, qemuBlockJobData *job, + virDomainAsyncJob asyncJob, virDomainDiskDef *disk); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f7a7086b3d..970cc29eaf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14158,7 +14158,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, qemuBlockJobSyncBegin(job); =20 if (pivot) { - if ((ret =3D qemuBlockPivot(vm, job, disk)) < 0) + if ((ret =3D qemuBlockPivot(vm, job, VIR_ASYNC_JOB_NONE, disk)) < = 0) goto endjob; } else { qemuDomainObjEnterMonitor(vm); --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027644; cv=none; d=zohomail.com; s=zohoarc; b=GAYqGYJMksHarNhfr3zlVa6u9WO6MmuRz2d6OXLMSosiG+pHi2O6bvKT1R7AfAO98m9cdp7yFXQuGYQcTJAHnyvamk9pvLupraaEni+uxYcZ0LkjHZJYENwuQzQ+Odt48EWlRDdrx8Pj9Aa92Kevsui1dPwNVeIA84zE8E4nqDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027644; 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; bh=3bePwfa0Y0pdQISCaxeCIIr4GEeRFtpeGpM70C+kMS0=; b=DBG4EgPWY3MwZXFFnwGYlfm1WI29vHVKL+/S017qd4aqxnz5SNqyLo/qztsXmqQuJFMFwrJh+HzKBWsA0G5EhbbMYY62YGMRFRymXAbdl7Vb9eo2O2IX70Hb8pEJrqNFCAcnt7vRVh8eEpoDHVm3cjaxRrF9WqrHI6sJSQ5wy5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027644263443.32516086500857; Fri, 6 Jan 2023 09:54:04 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-PrSWXvYqOXyYYC8RBSK25w-1; Fri, 06 Jan 2023 12:52:24 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 490F2101A55E; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3026240ED784; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5BE6F19459C2; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BD639194707C for ; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B094B40C2064; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4ED9A40C2009 for ; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027643; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3bePwfa0Y0pdQISCaxeCIIr4GEeRFtpeGpM70C+kMS0=; b=EthWxnep+3Vhs5934xJaNH8e8113BljfXf/7yiUHiv0AduQ6rywhUNB1NK+dw/4efbYhoG SVz2GIKm8DLY0kszfqaLMv54D4sAFYi76NI7vqlJvvuKc1/tCdP+fnWeDouV0NFN+7iHRW jQEoA8oHbquEdZtCkXhXfpBa6JokouQ= X-MC-Unique: PrSWXvYqOXyYYC8RBSK25w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 06/32] qemu_monitor: introduce qemuMonitorJobFinalize Date: Fri, 6 Jan 2023 18:51:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027645759100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Upcoming snapshot deletion code will require that multiple commit jobs are finished in sync. To allow aborting then if one fails we will need to use manual finalization of the jobs. This commit implements the monitor code for `job-finalize`. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_monitor.c | 12 ++++++++++++ src/qemu/qemu_monitor.h | 5 +++++ src/qemu/qemu_monitor_json.c | 22 ++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 5 +++++ tests/qemumonitorjsontest.c | 2 ++ 5 files changed, 46 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6303200d1e..771b1b6d59 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2932,6 +2932,18 @@ qemuMonitorJobDismiss(qemuMonitor *mon, } =20 =20 +int +qemuMonitorJobFinalize(qemuMonitor *mon, + const char *jobname) +{ + VIR_DEBUG("jobname=3D%s", jobname); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONJobFinalize(mon, jobname); +} + + int qemuMonitorJobComplete(qemuMonitor *mon, const char *jobname) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 324eee5a89..f51146a13a 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1029,6 +1029,11 @@ int qemuMonitorJobDismiss(qemuMonitor *mon, const char *jobname) ATTRIBUTE_NONNULL(2); =20 +int +qemuMonitorJobFinalize(qemuMonitor *mon, + const char *jobname) + ATTRIBUTE_NONNULL(2); + int qemuMonitorJobComplete(qemuMonitor *mon, const char *jobname) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3b96f4e037..4495f8f2cf 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4405,6 +4405,28 @@ qemuMonitorJSONJobDismiss(qemuMonitor *mon, } =20 =20 +int +qemuMonitorJSONJobFinalize(qemuMonitor *mon, + const char *jobname) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("job-finalize", + "s:id", jobname, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0) + return -1; + + return 0; +} + + int qemuMonitorJSONJobComplete(qemuMonitor *mon, const char *jobname) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index a86f054b8b..d774cbaf14 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -377,6 +377,11 @@ qemuMonitorJSONJobDismiss(qemuMonitor *mon, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +int +qemuMonitorJSONJobFinalize(qemuMonitor *mon, + const char *jobname) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorJSONJobComplete(qemuMonitor *mon, const char *jobname) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 59f7322711..f224ccb364 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1223,6 +1223,7 @@ GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumInsert, "f= oodev", "newnode") GEN_TEST_FUNC(qemuMonitorJSONBitmapRemove, "foodev", "newnode") GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname") GEN_TEST_FUNC(qemuMonitorJSONJobComplete, "jobname") +GEN_TEST_FUNC(qemuMonitorJSONJobFinalize, "jobname") GEN_TEST_FUNC(qemuMonitorJSONBlockJobCancel, "jobname", true) GEN_TEST_FUNC(qemuMonitorJSONSetAction, QEMU_MONITOR_ACTION_SHUTDOWN_PAUSE, @@ -2921,6 +2922,7 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONBitmapRemove); DO_TEST_GEN(qemuMonitorJSONJobDismiss); DO_TEST_GEN(qemuMonitorJSONJobComplete); + DO_TEST_GEN(qemuMonitorJSONJobFinalize); DO_TEST_GEN(qemuMonitorJSONBlockJobCancel); DO_TEST_GEN(qemuMonitorJSONSetAction); DO_TEST_GEN(qemuMonitorJSONSetLaunchSecurityState); --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027588; cv=none; d=zohomail.com; s=zohoarc; b=j+/KerVvk5k1MzAvOeyqaESRWn2hi146fDkYPcWCOagANMMyVuy3s5S2h/QjpFWXLO8U6Gf6LMqT9CSn2lm3r05FrupmjvEGGTlbR46MHdzvehVhlQePYAkIDesaOY/muNWjic9ihA4QfRYJ7V7GFHD+KlqfAi3bscCH3exePZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027588; 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; bh=krW2E+kn6GlHTU6XSx1YjnskxJ5jaMKVNTm+VLbvo1Q=; b=SZSdO5fn4hODizyR+VGVoiXnDPoLPwKZhCp//Qz9S/ikPyBtUlkhPdEhwn2Wpv568y6058m6d8os7ee9xoBGdLaqfqynesEm8sTgH9LxrSZSSG4gbjgAHbpeh+JWQuqfs/DaHe2A7RYclKKZh9CG1MerrvlfKlXwGQh8KTyQogI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027588149967.6205822503055; Fri, 6 Jan 2023 09:53:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-Qym_GgKVNs6LDf6YQ95Dkg-1; Fri, 06 Jan 2023 12:52:24 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5B5881C07831; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4571451FF; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 393201947072; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6CBD519459DC for ; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 61D1F40C200A; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDDEF40C2007 for ; Fri, 6 Jan 2023 17:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027587; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=krW2E+kn6GlHTU6XSx1YjnskxJ5jaMKVNTm+VLbvo1Q=; b=TQbRD3TuuCBj5sD0Wnvmf0nqJrOIzGGH7OKVS/ZladaH2N0GaWeOGQqn/fmdkkUNrIOl1g xF+2J2xPjSn+Hf4Ox9ib6BU3sfigZYllKoqgTmcPssC2jq8HNhV/3AdcOA7f73c8VAbJFu +wuEDWD5ff6leTSSSdEpG68XrSeSWE4= X-MC-Unique: Qym_GgKVNs6LDf6YQ95Dkg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 07/32] qemu_monitor_json: allow configuring autofinalize for block commit Date: Fri, 6 Jan 2023 18:51:42 +0100 Message-Id: <581f8cd4f5f7552bcaa869f25621c11ab3e85c1d.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027589310100006 Content-Type: text/plain; charset="utf-8"; x-default="true" Deleting external snapshots will require configuring autofinalize to synchronize the block jobs for disks withing single snapshot in order to be able safely abort of one of the jobs fails. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 3 ++- src/qemu/qemu_monitor.c | 9 +++++---- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 4 ++-- src/qemu/qemu_monitor_json.h | 3 ++- tests/qemumonitorjsontest.c | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 6a68362708..99409a969b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3364,7 +3364,8 @@ qemuBlockCommit(virDomainObj *vm, job->name, topSource->nodeformat, baseSource->nodeformat, - backingPath, bandwidth); + backingPath, bandwidth, + VIR_TRISTATE_BOOL_YES); =20 qemuDomainObjExitMonitor(vm); =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 771b1b6d59..38f89167e0 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2795,16 +2795,17 @@ qemuMonitorBlockCommit(qemuMonitor *mon, const char *topNode, const char *baseNode, const char *backingName, - unsigned long long bandwidth) + unsigned long long bandwidth, + virTristateBool autofinalize) { - VIR_DEBUG("device=3D%s, jobname=3D%s, topNode=3D%s, baseNode=3D%s, bac= kingName=3D%s, bandwidth=3D%llu", + VIR_DEBUG("device=3D%s, jobname=3D%s, topNode=3D%s, baseNode=3D%s, bac= kingName=3D%s, bandwidth=3D%llu, autofinalize=3D%d", device, NULLSTR(jobname), NULLSTR(topNode), - NULLSTR(baseNode), NULLSTR(backingName), bandwidth); + NULLSTR(baseNode), NULLSTR(backingName), bandwidth, autofina= lize); =20 QEMU_CHECK_MONITOR(mon); =20 return qemuMonitorJSONBlockCommit(mon, device, jobname, topNode, baseN= ode, - backingName, bandwidth); + backingName, bandwidth, autofinalize= ); } =20 =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f51146a13a..2d16214ba2 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -973,7 +973,8 @@ int qemuMonitorBlockCommit(qemuMonitor *mon, const char *topNode, const char *baseNode, const char *backingName, - unsigned long long bandwidth) + unsigned long long bandwidth, + virTristateBool autofinalize) ATTRIBUTE_NONNULL(2); =20 int qemuMonitorArbitraryCommand(qemuMonitor *mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4495f8f2cf..db99017555 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4028,11 +4028,11 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, const char *topNode, const char *baseNode, const char *backingName, - unsigned long long speed) + unsigned long long speed, + virTristateBool autofinalize) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_YES; virTristateBool autodismiss =3D VIR_TRISTATE_BOOL_NO; =20 cmd =3D qemuMonitorJSONMakeCommand("block-commit", diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index d774cbaf14..6f376cf9b7 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -315,7 +315,8 @@ qemuMonitorJSONBlockCommit(qemuMonitor *mon, const char *topNode, const char *baseNode, const char *backingName, - unsigned long long bandwidth) + unsigned long long bandwidth, + virTristateBool autofinalize) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 int diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f224ccb364..1db1f2b949 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1211,7 +1211,7 @@ GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0") GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targ= etnode", 1024, 1234, 31234, true, true) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", "backingnode",= "backingfilename", 1024) -GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", "topnode", "ba= senode", "backingfilename", 1024) +GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", "topnode", "ba= senode", "backingfilename", 1024, VIR_TRISTATE_BOOL_YES) GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, NULL, "/foo/bar") GEN_TEST_FUNC(qemuMonitorJSONOpenGraphics, "spice", "spicefd", false) GEN_TEST_FUNC(qemuMonitorJSONNBDServerAdd, "vda", "export", true, "bitmap") --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027551; cv=none; d=zohomail.com; s=zohoarc; b=hKssoWR82U2NidoPTQAXQUNOLikb4Vn8pJT7ohmyk7I4dgIM7dYS6nOtB7NtV6Gu5MgxFITXfs4o/EDphRZNt2HFytluhdKAItGq/FuxrlQHSajDYkqVHlpbU9ymAnZLedRpok8ZAVio4V1b1MqR37rIF3ImpLQgDBWsChtdIpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027551; 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; bh=VtA8D045pYtCzGnl/mvx5gYiB6TXtkqoWHDdy9g4Dmw=; b=Wkha2wj3YgAbiFL/N8DdbMvtjjFU7qE35eHE40uATqkZL/ZSrODYixpGMkgwJWS5Q6NfEJ1yxkJvTMKllZWlfRIyRY7acq2JdS4lwVIikvfDQGfkJFo4s5CryJNHfIeanzGu6bsN0DArn2CANxgZFng8nPKF5k0ai7clBj6A68A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167302755116019.90000035823141; Fri, 6 Jan 2023 09:52:31 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-316-GzRWE7W_PMSJAPdG19NC8w-1; Fri, 06 Jan 2023 12:52:27 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3474830F86; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB3D72026D76; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A517F194707B; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1B4551947072 for ; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0E51C40C200F; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DFAC40C2004 for ; Fri, 6 Jan 2023 17:52:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027550; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VtA8D045pYtCzGnl/mvx5gYiB6TXtkqoWHDdy9g4Dmw=; b=XLo7rXje0AY6b+bslT2jN4OokGv96AZhLzyKSfIamT1Oq4cLR2UY5V8Amhvfew4leQquHg 2eibC72t4Spg2lrwGDcrMOgtzzsCWpf0E8CG1Nvx63Bf36L6VJLxKfSwhM6U/rH7KNdZVP NjfU3DhfW/Aadu0QEJ/JXm8UsYaZ5xM= X-MC-Unique: GzRWE7W_PMSJAPdG19NC8w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 08/32] qemu_block: allow configuring autofinalize for block commit Date: Fri, 6 Jan 2023 18:51:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027553042100005 Content-Type: text/plain; charset="utf-8"; x-default="true" External snapshots will use this to synchronize qemu block jobs. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 9 ++++++++- src/qemu/qemu_block.h | 1 + src/qemu/qemu_driver.c | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 99409a969b..da3a1e8557 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3207,11 +3207,17 @@ qemuBlockExportAddNBD(virDomainObj *vm, * @top_parent: disk source that has @topSource as backing disk * @bandwidth: bandwidth limit, flags determine the unit * @asyncJob: qemu async job type + * @autofinalize: virTristateBool controlling qemu block job finalization * @flags: bitwise-OR of virDomainBlockCommitFlags * * Starts a block commit job for @disk. If @asyncJob is different then * VIR_ASYNC_JOB_NONE the job will be started as synchronous. * + * The @autofinalize argument controls if the qemu block job will be autom= atically + * finalized. This is used when deleting external snapshots where we need = to + * disable automatic finalization for some use-case. The default value pas= sed + * to this argument should be VIR_TRISTATE_BOOL_YES. + * * Returns -1 on error, 0 on success. */ int @@ -3222,6 +3228,7 @@ qemuBlockCommit(virDomainObj *vm, virStorageSource *top_parent, unsigned long bandwidth, virDomainAsyncJob asyncJob, + virTristateBool autofinalize, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -3365,7 +3372,7 @@ qemuBlockCommit(virDomainObj *vm, topSource->nodeformat, baseSource->nodeformat, backingPath, bandwidth, - VIR_TRISTATE_BOOL_YES); + autofinalize); =20 qemuDomainObjExitMonitor(vm); =20 diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 3f2082f102..7b6aec2a7d 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -285,6 +285,7 @@ qemuBlockCommit(virDomainObj *vm, virStorageSource *top_parent, unsigned long bandwidth, virDomainAsyncJob asyncJob, + virTristateBool autofinalize, unsigned int flags); =20 int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 970cc29eaf..c6bca8a24e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15026,7 +15026,8 @@ qemuDomainBlockCommit(virDomainPtr dom, goto endjob; =20 ret =3D qemuBlockCommit(vm, disk, baseSource, topSource, top_parent, - bandwidth, VIR_ASYNC_JOB_NONE, flags); + bandwidth, VIR_ASYNC_JOB_NONE, VIR_TRISTATE_BOOL= _YES, + flags); =20 endjob: virDomainObjEndJob(vm); --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027548; cv=none; d=zohomail.com; s=zohoarc; b=ZplMAJEZ5xiq1NX8BA1BJwRUd2nsnX7RBCSQsPljD1nTqmcfk3jQjKB7OLeBiWMNyyNRMLWyO701qMpE3MqFtSdZWZegp3PeSG8NW9DaKmsfbLwQ8TdLKHQLFhZC9g5TUZ8BvX1J0HUlbIRaSTptxFmQUJiEIcpd4susPf7Tiac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027548; 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; bh=r+a8T1KNaFS/VkkotGecRAoJ8WoxZgc5wrQtQCovLzc=; b=VYu2mtGIgUNJMAsJWbEmfLC4uqx63vwBKz/P23sPmMrKpA5iFoap+fHgLBhwX3k+2m4Rw8e5ITGGez9pyTU+M3BrSOK2GqkuiRe0+sPjgeg+t7QqKRb2eZIHDLsn942tlBIGjSqnxvAEbh4Z+nJikh1Fd1bSR25YXA6IDB5PoqY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027548146895.0343795405478; Fri, 6 Jan 2023 09:52:28 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-EJrxzTRCPH-KMPE7Nfm7xA-1; Fri, 06 Jan 2023 12:52:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C7D52803499; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96E53111F3BB; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6CFE319459CA; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BAEA31946586 for ; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AAE9F40C2004; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 497A140C2064 for ; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027546; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=r+a8T1KNaFS/VkkotGecRAoJ8WoxZgc5wrQtQCovLzc=; b=ieytmJBK8STKSy70C1aLUeBfHc9qbx6YHKj6ryQD9aAGT7SgVRxsCauQ6k2HhJb6pPRlK4 x2jJgp+yqDq5dG5QixxCc0l69pKLYyB5ec06PWHitSkH0iwz+alrgQEtRCDHwXwc7PzPXD HDQwtSQAEuWOT3kanoB0f8VTIQO2NSY= X-MC-Unique: EJrxzTRCPH-KMPE7Nfm7xA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 09/32] qemu_block: introduce qemuBlockFinalize Date: Fri, 6 Jan 2023 18:51:44 +0100 Message-Id: <3c0f93122be6afd09648ca6a4a4f31696e715d21.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027549012100004 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 32 ++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 5 +++++ 2 files changed, 37 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index da3a1e8557..70811aa861 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3525,3 +3525,35 @@ qemuBlockPivot(virDomainObj *vm, =20 return ret; } + + +/** + * qemuBlockFinalize: + * @vm: domain object + * @job: qemu block job data object + * @asyncJob: qemu async job type + * + * When qemu job is started with autofinalize disabled it will wait in pen= ding + * state for block job finalize to be called manually in order to finish t= he + * job. This is useful when we are running jobs on multiple disks to make + * a synchronization point before we finish. + * + * Return -1 on error, 0 on success. + */ +int +qemuBlockFinalize(virDomainObj *vm, + qemuBlockJobData *job, + virDomainAsyncJob asyncJob) +{ + int ret; + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + return -1; + + ret =3D qemuMonitorJobFinalize(priv->mon, job->name); + + qemuDomainObjExitMonitor(vm); + + return ret; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 7b6aec2a7d..c169432d9c 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -293,3 +293,8 @@ qemuBlockPivot(virDomainObj *vm, qemuBlockJobData *job, virDomainAsyncJob asyncJob, virDomainDiskDef *disk); + +int +qemuBlockFinalize(virDomainObj *vm, + qemuBlockJobData *job, + virDomainAsyncJob asyncJob); --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027652; cv=none; d=zohomail.com; s=zohoarc; b=aSnXA3vxHhZIw/SNAa1GPTlkkZR/lRNO7xC3M+0R4yQKKQYpufcr/YclA5qsYNr7L4+VLzjdbX8nOv4NB7Qz8DZLmxA2lAyEAy3hEAElBRKpQytagrrfslNI7ftat/LI76TCHzPyh7j/CCfwYdKuRJ9XGQTWDn4xIQVc91qVuoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027652; 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; bh=rpFqZOFgEEdWMEbOfQnXIqEKXTZlxSA9mFaMi5h9ZMw=; b=XmYxCo8fMfhyUsDOsq7C/Ze5cn885avxN+BBBO1gzChBSn0gYTJAm7Z5iUFLXuoJT7nQVI12n9F+G9OxEmbpoZqwM/cucCqY/4lvOF1iaySEUsSFFjLeV+p/RzfmqXpBjh2dy+xjpRzAJMbTiiUjt+Dv2KcVQnt2R+DuDV3wSM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027652105886.7250723231415; Fri, 6 Jan 2023 09:54:12 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-kui_NzpwO8Ctc9s7L-rLcw-1; Fri, 06 Jan 2023 12:52:27 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BA11A3C0DDBD; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A34A3C15BAD; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 94B661947075; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6E40219459CB for ; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5514440C2008; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7E3240C2064 for ; Fri, 6 Jan 2023 17:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027651; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rpFqZOFgEEdWMEbOfQnXIqEKXTZlxSA9mFaMi5h9ZMw=; b=EU5uNlmdSiflvfZn11ahd1yKzy3Qb6TdNS//gXRpYxJwDqK+9gXo/OrW5YWn4qgDsvLe4r Qm+/TiQyl9wUAzpSuImtMS0zE3oUNl+tMcJ6CP4aLLfBgK6L53zlySMBPJaWSkzG6REBpM rALrgr4v+3jyveXEoi2vvu2r504h8Zo= X-MC-Unique: kui_NzpwO8Ctc9s7L-rLcw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 10/32] qemu_block: change qemuBlockCommit to return job pointer Date: Fri, 6 Jan 2023 18:51:45 +0100 Message-Id: <9b092e6a3b317c6e39d52fe099755c7990c25fab.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027653789100003 Content-Type: text/plain; charset="utf-8"; x-default="true" The created job will be needed by external snapshot delete code so rework qemuBlockCommit to return that pointer. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 57 ++++++++++++++++++++++-------------------- src/qemu/qemu_block.h | 2 +- src/qemu/qemu_driver.c | 5 +++- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 70811aa861..7ea42961b6 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3218,9 +3218,10 @@ qemuBlockExportAddNBD(virDomainObj *vm, * disable automatic finalization for some use-case. The default value pas= sed * to this argument should be VIR_TRISTATE_BOOL_YES. * - * Returns -1 on error, 0 on success. + * Returns qemuBlockJobData pointer on success, NULL on error. Caller is r= esponsible + * to call virObjectUnref on the pointer. */ -int +qemuBlockJobData * qemuBlockCommit(virDomainObj *vm, virDomainDiskDef *disk, virStorageSource *baseSource, @@ -3233,14 +3234,15 @@ qemuBlockCommit(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; - int ret =3D -1; + int rc =3D -1; bool clean_access =3D false; g_autofree char *backingPath =3D NULL; qemuBlockJobData *job =3D NULL; + qemuBlockJobData *ret =3D NULL; g_autoptr(virStorageSource) mirror =3D NULL; =20 if (virDomainObjCheckActive(vm) < 0) - return -1; + return NULL; =20 /* Convert bandwidth MiB to bytes, if necessary */ if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) { @@ -3248,26 +3250,26 @@ qemuBlockCommit(virDomainObj *vm, virReportError(VIR_ERR_OVERFLOW, _("bandwidth must be less than %llu"), LLONG_MAX >> 20); - return -1; + return NULL; } bandwidth <<=3D 20; } =20 if (!qemuDomainDiskBlockJobIsSupported(disk)) - return -1; + return NULL; =20 if (virStorageSourceIsEmpty(disk->src)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk %s has no source file to be committed"), disk->dst); - return -1; + return NULL; } =20 if (qemuDomainDiskBlockJobIsActive(disk)) - return -1; + return NULL; =20 if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) - return -1; + return NULL; =20 if (topSource =3D=3D disk->src) { /* XXX Should we auto-pivot when COMMIT_ACTIVE is not specified? */ @@ -3275,20 +3277,20 @@ qemuBlockCommit(virDomainObj *vm, virReportError(VIR_ERR_INVALID_ARG, _("commit of '%s' active layer requires active = flag"), disk->dst); - return -1; + return NULL; } } else if (flags & VIR_DOMAIN_BLOCK_COMMIT_ACTIVE) { virReportError(VIR_ERR_INVALID_ARG, _("active commit requested but '%s' is not active"), topSource->path); - return -1; + return NULL; } =20 if (!virStorageSourceHasBacking(topSource)) { virReportError(VIR_ERR_INVALID_ARG, _("top '%s' in chain for '%s' has no backing file"), topSource->path, disk->src->path); - return -1; + return NULL; } =20 if ((flags & VIR_DOMAIN_BLOCK_COMMIT_SHALLOW) && @@ -3297,33 +3299,33 @@ qemuBlockCommit(virDomainObj *vm, _("base '%s' is not immediately below '%s' in chain= " "for '%s'"), baseSource->path, topSource->path, disk->src->path); - return -1; + return NULL; } =20 /* For an active commit, clone enough of the base to act as the mirror= */ if (topSource =3D=3D disk->src) { if (!(mirror =3D virStorageSourceCopy(baseSource, false))) - return -1; + return NULL; if (virStorageSourceInitChainElement(mirror, disk->src, true) < 0) - return -1; + return NULL; } =20 if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE && topSource !=3D disk->src) { if (top_parent && qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0) - return -1; + return NULL; =20 if (virStorageSourceGetRelativeBackingPath(topSource, baseSource, &backingPath) < 0) - return -1; + return NULL; =20 if (!backingPath) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("can't keep relative backing relationship")); - return -1; + return NULL; } } =20 @@ -3366,17 +3368,17 @@ qemuBlockCommit(virDomainObj *vm, if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) goto cleanup; =20 - ret =3D qemuMonitorBlockCommit(priv->mon, - qemuDomainDiskGetTopNodename(disk), - job->name, - topSource->nodeformat, - baseSource->nodeformat, - backingPath, bandwidth, - autofinalize); + rc =3D qemuMonitorBlockCommit(priv->mon, + qemuDomainDiskGetTopNodename(disk), + job->name, + topSource->nodeformat, + baseSource->nodeformat, + backingPath, bandwidth, + autofinalize); =20 qemuDomainObjExitMonitor(vm); =20 - if (ret < 0) + if (rc < 0) goto cleanup; =20 if (mirror) { @@ -3384,9 +3386,10 @@ qemuBlockCommit(virDomainObj *vm, disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT; } qemuBlockJobStarted(job, vm); + ret =3D virObjectRef(job); =20 cleanup: - if (ret < 0 && clean_access) { + if (rc < 0 && clean_access) { virErrorPtr orig_err; virErrorPreserveLast(&orig_err); /* Revert access to read-only, if possible. */ diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index c169432d9c..a8079c2207 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -277,7 +277,7 @@ qemuBlockExportAddNBD(virDomainObj *vm, bool writable, const char *bitmap); =20 -int +qemuBlockJobData * qemuBlockCommit(virDomainObj *vm, virDomainDiskDef *disk, virStorageSource *baseSource, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c6bca8a24e..a2ebd8093a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14994,6 +14994,7 @@ qemuDomainBlockCommit(virDomainPtr dom, virStorageSource *topSource; virStorageSource *baseSource =3D NULL; virStorageSource *top_parent =3D NULL; + g_autoptr(qemuBlockJobData) job =3D NULL; =20 virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW | VIR_DOMAIN_BLOCK_COMMIT_ACTIVE | @@ -15025,9 +15026,11 @@ qemuDomainBlockCommit(virDomainPtr dom, base, disk->dst, N= ULL))) goto endjob; =20 - ret =3D qemuBlockCommit(vm, disk, baseSource, topSource, top_parent, + job =3D qemuBlockCommit(vm, disk, baseSource, topSource, top_parent, bandwidth, VIR_ASYNC_JOB_NONE, VIR_TRISTATE_BOOL= _YES, flags); + if (job) + ret =3D 0; =20 endjob: virDomainObjEndJob(vm); --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027596; cv=none; d=zohomail.com; s=zohoarc; b=W494pExY8S2RHV1+wGxwIz/ef8VPTPDRb3pzWlqOEvlwcbu36A1aDnMb18D5ixk9GD/yHL7WS9JrD4dW+6iQ0RQ4V0fv8oNLjsdLeT1MaCNXuW9G6qdyzv4TiKLElZ9GQ0VZtkUtWo6Mf1xPfG+Efpy4aZvrOUXLztJD6LKVdZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027596; 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; bh=93PFEPbei97oAHMj59QFPbLRfX87smO5C0k1qu7pUmg=; b=hzHGXynHXReSTy38dYWPD8QOD4PAJCWhwb9OWUSUWtBfiEJYcW3gLX0jddVXgQ4vkjQ//rSi2XUuGd/GCRtftR0JsbX4haDe/TSgr+I7LVxke9P/GDO93an9duMi+kzaNygin1lGxX7O4ERWwSFDvFfj209hOOZTUCdDf898vx4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167302759623618.07479661722175; Fri, 6 Jan 2023 09:53:16 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-484-B_GRkSvXPTi_a51s44DEwQ-1; Fri, 06 Jan 2023 12:52:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C89C3C0ED44; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FA5940C200B; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 325EE19459D1; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0FFFB1947077 for ; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0484E40C200A; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9465C40C2064 for ; Fri, 6 Jan 2023 17:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027594; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=93PFEPbei97oAHMj59QFPbLRfX87smO5C0k1qu7pUmg=; b=dLUERbJyP+hdFW2BSHx62cAzIaEFYj+aKqswtTQY2x2PcdCD3vIy00J8puvSErLN4FzOKd PPYoM9+6qhuHAWAefc9OEhJT6/fRwhiEzfhqpc6mRymaItFV5R5dFzLV4MlQmtsJ7CR3EG bPW9EWSkRdJM3Jec5+JEoOHEQNW2Rro= X-MC-Unique: B_GRkSvXPTi_a51s44DEwQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 11/32] qemu_blockjob: process QEMU_MONITOR_JOB_STATUS_PENDING signal Date: Fri, 6 Jan 2023 18:51:46 +0100 Message-Id: <23fde2d52ae4970da7c80019c03391bc7b6e18f1.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027597326100003 Content-Type: text/plain; charset="utf-8"; x-default="true" QEMU emits this signal when the job finished its work and is about to be finalized. If the job is started with autofinalize disabled the job waits for user input to finalize the job. This will be used by snapshot delete code. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_backup.c | 1 + src/qemu/qemu_blockjob.c | 21 ++++++++++++++++++++- src/qemu/qemu_blockjob.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index c7721812a5..6a5aacd9f6 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -1035,6 +1035,7 @@ qemuBackupNotifyBlockjobEnd(virDomainObj *vm, case QEMU_BLOCKJOB_STATE_NEW: case QEMU_BLOCKJOB_STATE_RUNNING: case QEMU_BLOCKJOB_STATE_ABORTING: + case QEMU_BLOCKJOB_STATE_PENDING: case QEMU_BLOCKJOB_STATE_PIVOTING: case QEMU_BLOCKJOB_STATE_LAST: default: diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index a7aa7b3940..cb2d05d71d 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -55,6 +55,7 @@ VIR_ENUM_IMPL(qemuBlockjobState, "running", "concluded", "aborting", + "pending", "pivoting"); =20 VIR_ENUM_IMPL(qemuBlockjob, @@ -531,6 +532,8 @@ qemuBlockJobRefreshJobs(virDomainObj *vm) if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW || job->state =3D=3D QEMU_BLOCKJOB_STATE_RUNNING) job->newstate =3D newstate; + } else if (newstate =3D=3D QEMU_BLOCKJOB_STATE_PENDING) { + job->newstate =3D newstate; } /* don't update the job otherwise */ } @@ -1563,6 +1566,19 @@ qemuBlockJobEventProcess(virQEMUDriver *driver, job->newstate =3D -1; break; =20 + case QEMU_BLOCKJOB_STATE_PENDING: + /* Similarly as for 'ready' state we should handle it only when + * previous state was 'new' or 'running' as there are other cases + * when it can be emitted by QEMU. Currently we need this only when + * deleting non-active external snapshots. */ + if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW || + job->state =3D=3D QEMU_BLOCKJOB_STATE_RUNNING) { + job->state =3D job->newstate; + qemuDomainSaveStatus(vm); + } + job->newstate =3D -1; + break; + case QEMU_BLOCKJOB_STATE_NEW: case QEMU_BLOCKJOB_STATE_RUNNING: case QEMU_BLOCKJOB_STATE_LAST: @@ -1684,13 +1700,16 @@ qemuBlockjobConvertMonitorStatus(int monitorstatus) ret =3D QEMU_BLOCKJOB_STATE_CONCLUDED; break; =20 + case QEMU_MONITOR_JOB_STATUS_PENDING: + ret =3D QEMU_BLOCKJOB_STATE_PENDING; + break; + case QEMU_MONITOR_JOB_STATUS_UNKNOWN: case QEMU_MONITOR_JOB_STATUS_CREATED: case QEMU_MONITOR_JOB_STATUS_RUNNING: case QEMU_MONITOR_JOB_STATUS_PAUSED: case QEMU_MONITOR_JOB_STATUS_STANDBY: case QEMU_MONITOR_JOB_STATUS_WAITING: - case QEMU_MONITOR_JOB_STATUS_PENDING: case QEMU_MONITOR_JOB_STATUS_ABORTING: case QEMU_MONITOR_JOB_STATUS_UNDEFINED: case QEMU_MONITOR_JOB_STATUS_NULL: diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 741d8df6c5..e9b283da20 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -41,6 +41,7 @@ typedef enum { QEMU_BLOCKJOB_STATE_CONCLUDED, /* job has finished, but it's unknown whether it has failed or not */ QEMU_BLOCKJOB_STATE_ABORTING, + QEMU_BLOCKJOB_STATE_PENDING, QEMU_BLOCKJOB_STATE_PIVOTING, QEMU_BLOCKJOB_STATE_LAST } qemuBlockjobState; --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027596; cv=none; d=zohomail.com; s=zohoarc; b=LctBFU3nA0qjM9fuX2o/8l8q8nnDWDDtaJRojumjoBXFPEJcwOHrSZHAw0qbW1Oenh6YnKgpwnhh1zrI/ExEr7vNEMt4IYkCDnOLmOMMV/amm1c2wfJb1q2uUfA+k81XGOD+QFnxXJ4M7LJNT9IMuB49C4ffzrylj6Wq1MGz8qI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027596; 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; bh=6jszNxA67dnmSHZT+VlwW94qlbZ+OIKdnN8Ze9OmLCY=; b=BW6o29N2AYnDJMx3l4W99yqLnBK/ChnRXHCg9Yu2w6TlWjuLO1cptGcAPzAG/RWdiWS1IJ0Oi3qdUGsBFHYJt53q5GeJM4uglnT9fwlfqwVnZPVDAiRfWyfVcCyCtwHbfmUshEZx2Va9YkDIkfjNqftvpIAvt27mBjnC9YaekJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027596279821.5440547969266; Fri, 6 Jan 2023 09:53:16 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-X24ujRMKNoeNGh-v39c3Pw-1; Fri, 06 Jan 2023 12:52:30 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39D5C183B3C8; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2663D492B00; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EF6B41947074; Fri, 6 Jan 2023 17:52:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AEFB4194707E for ; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A193E40C2064; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F38D40C2004 for ; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027595; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6jszNxA67dnmSHZT+VlwW94qlbZ+OIKdnN8Ze9OmLCY=; b=PtoGofv9Nwa1CVfrtVuqt7HAluiqnuYpZ66w4a2simu+twfNLfGdvY1owBO6jXzUEWEvRq Om4MRSa3vKUFIc7Fn2XN1BzliHifoMAovXojVlRRg0wu9zgVKqh20iDsvPNhQnCN1IovsS /X6VvSRxv27kF+VL837BWH8xt3LrHTk= X-MC-Unique: X24ujRMKNoeNGh-v39c3Pw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 12/32] storage_source: introduce virStorageSourceChainLookupBySource Date: Fri, 6 Jan 2023 18:51:47 +0100 Message-Id: <258c5385985a279549d68afb1e92c398932afef2.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027597338100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Looks up disk storage source within storage source chain using storage source object instead of path to make it work with all disk types. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 + src/storage_file/storage_source.c | 40 +++++++++++++++++++++++++++++++ src/storage_file/storage_source.h | 6 +++++ 3 files changed, 47 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b81c2cc7da..0aef539dc8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1780,6 +1780,7 @@ virStorageFileProbeGetMetadata; # storage_file/storage_source.h virStorageSourceAccess; virStorageSourceChainLookup; +virStorageSourceChainLookupBySource; virStorageSourceChown; virStorageSourceCreate; virStorageSourceDeinit; diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index ab0cdf2b12..0db6e69591 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -322,6 +322,46 @@ virStorageSourceChainLookup(virStorageSource *chain, } =20 =20 +/** + * virStorageSourceChainLookupBySource: + * @chain: chain top to look in + * @base: storage source to look for in @chain + * @parent: Filled with parent virStorageSource of the returned value if n= on-NULL. + * + * Looks up a storage source definition corresponding to @base in @chain. + * + * Returns virStorageSource withing chain or NULL if not found. + */ +virStorageSource * +virStorageSourceChainLookupBySource(virStorageSource *chain, + virStorageSource *base, + virStorageSource **parent) +{ + virStorageSource *prev =3D NULL; + + if (parent) + *parent =3D NULL; + + while (virStorageSourceIsBacking(chain)) { + if (virStorageSourceIsSameLocation(chain, base)) + break; + + prev =3D chain; + chain =3D chain->backingStore; + } + + if (!virStorageSourceIsBacking(chain)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("could not find base disk source in disk source c= hain")); + return NULL; + } + + if (parent) + *parent =3D prev; + return chain; +} + + static virStorageSource * virStorageSourceNewFromBackingRelative(virStorageSource *parent, const char *rel) diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_s= ource.h index 0ae06f4e7d..63fefb6919 100644 --- a/src/storage_file/storage_source.h +++ b/src/storage_file/storage_source.h @@ -47,6 +47,12 @@ virStorageSourceChainLookup(virStorageSource *chain, virStorageSource **parent) ATTRIBUTE_NONNULL(1); =20 +virStorageSource * +virStorageSourceChainLookupBySource(virStorageSource *chain, + virStorageSource *base, + virStorageSource **parent) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int virStorageSourceUpdatePhysicalSize(virStorageSource *src, int fd, --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027564; cv=none; d=zohomail.com; s=zohoarc; b=bvj7HsPyKTKlfzO4bMBnza5hCDUX7kcHMTnxLieHhNH9K8oFsCDM934Q1LgqXnDagjeBC/aBN9dWPrkJuB11cpXEI4WbzUtTMrKXHJEDV3SC9wqh3c/J90c5ehJoUbH3Cj/AWoU+LxyLxyUHMzcqBkck5I4dvAG+GYjbA0G6cjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027564; 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; bh=70M1g1FeIJYEjHNoyR1mvRAg+mYreJSo6osgVrj7IMc=; b=eCbALdBsZh7XUYkPYeOqS28UmkUHQtg4rDtmXSb6kW3DYEhvnpp32Cj1bS3ytUIE71iKRhGuLklcws2NFkRoYGuWZEss1J6EqTLWOM44Afg/6XRzkC8jiMWRj9Y8V0xtGAs9d9ECza5v51MHxIOerJLe2oftNu+BtBf0akb4wXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 167302756419286.75852741127926; Fri, 6 Jan 2023 09:52:44 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-261-iyxQtFpXMzyMBTi41CPrNg-1; Fri, 06 Jan 2023 12:52:35 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07A133810D40; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7052492B00; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D97931947076; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5D7EC1946586 for ; Fri, 6 Jan 2023 17:52:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4FDCC40C2005; Fri, 6 Jan 2023 17:52:23 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDF5940C2004 for ; Fri, 6 Jan 2023 17:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027562; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=70M1g1FeIJYEjHNoyR1mvRAg+mYreJSo6osgVrj7IMc=; b=MA6H4+P27LRlvZvO2ytNCVwEj5TqS9/Xwj3+LGAqjnO1Hx2p04/+OtIEFZqfvLwj2EunpB vYT0fg9Z8pUj62FasX8uBvEB6NF1Aa5vKV8W2JeYmkHi6zNEGeZ/7qZ3nnvw7pqd/L0/dN fzDsQFU/Dw45KI3cgGtDz3xt2yRDRqk= X-MC-Unique: iyxQtFpXMzyMBTi41CPrNg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 13/32] qemu_snapshot: refactor qemuSnapshotDelete Date: Fri, 6 Jan 2023 18:51:48 +0100 Message-Id: <413b7f2c2855a2b23829b7c57374a721abdb572d.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027565131100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Move code around to make it clear what is called when deleting single snapshot or children snapshots. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 8b5bcd9770..4cc74fb092 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2350,25 +2350,28 @@ qemuSnapshotDelete(virDomainObj *vm, } } } - } else if (snap->nchildren) { - rep.dir =3D cfg->snapshotDir; - rep.parent =3D snap->parent; - rep.vm =3D vm; - rep.err =3D 0; - rep.xmlopt =3D driver->xmlopt; - rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; - virDomainMomentForEachChild(snap, - qemuSnapshotChildrenReparent, - &rep); - if (rep.err < 0) - goto endjob; - virDomainMomentMoveChildren(snap, snap->parent); - } =20 - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { - virDomainMomentDropChildren(snap); - ret =3D 0; + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { + virDomainMomentDropChildren(snap); + ret =3D 0; + } else { + ret =3D qemuDomainSnapshotDiscard(driver, vm, snap, true, meta= data_only); + } } else { + if (snap->nchildren) { + rep.dir =3D cfg->snapshotDir; + rep.parent =3D snap->parent; + rep.vm =3D vm; + rep.err =3D 0; + rep.xmlopt =3D driver->xmlopt; + rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; + virDomainMomentForEachChild(snap, + qemuSnapshotChildrenReparent, + &rep); + if (rep.err < 0) + goto endjob; + virDomainMomentMoveChildren(snap, snap->parent); + } ret =3D qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata= _only); } =20 --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027552; cv=none; d=zohomail.com; s=zohoarc; b=D/Netd11ruMpKMhguCjqXaV2hWq1EaQvPMMJbmzLLbWuzgHnKkHPgk8zm6ydSxqi216CDhSRt7IOe/LYFXsKp6as6iQHq2jjyOx82M/tQHXD0gM0nLnLvDoos64QrjRZJodoxNR/tR9B6pXl8hvG510VUEge6xMlyTERby75dZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027552; 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; bh=jNPOi/lphCQlSdRXqaeINQKGAlCBLFLoefBPMupTgQ4=; b=aKargAi/3j2aC/Kt8OmLg4u65MQ/YPdS6/cl4w+WmKwBvWwZUWBKo2Jc2Qg5rTFHA9x0VSfU4MQ9mdk3yvphghDEXbfXKOk5j4BoQ7PaT9veo5V4Qevvzx5Dgn6syEnp8x/cVzr/hl/vgxaY9hvdHO+S0zfuf06gFoxyJrNvZsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027552917879.8354184953182; Fri, 6 Jan 2023 09:52:32 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-510-ua34ynbsNRihH-v2ilRuWw-1; Fri, 06 Jan 2023 12:52:29 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFA17857F5C; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D2EA2166B4C; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8A5DE1947079; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 10994194707D for ; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EB8D740C2004; Fri, 6 Jan 2023 17:52:23 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8982840C2064 for ; Fri, 6 Jan 2023 17:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027551; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jNPOi/lphCQlSdRXqaeINQKGAlCBLFLoefBPMupTgQ4=; b=PjTtpK0mcqqvXuIxan7sx2aC8wLkJocnMulfQsodPiRX0onGvmrwuEnjQosejSTU0+N9fi vnF0Fa5pagJHdPo/TC1AchU56+RfoauUtdiSmPnBjRvCZcBCHRi3zZAm6JrN7KMLMUpWGl tYctsyBkOXVzXhHMLlTcVZFMaa6zDV8= X-MC-Unique: ua34ynbsNRihH-v2ilRuWw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 14/32] qemu_snapshot: introduce qemuSnapshotDeleteSingle Date: Fri, 6 Jan 2023 18:51:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027555039100013 Content-Type: text/plain; charset="utf-8"; x-default="true" Extract code that deletes single snapshot to separate function. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 47 ++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 4cc74fb092..e85655924a 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2281,6 +2281,36 @@ qemuSnapshotChildrenReparent(void *payload, } =20 =20 +static int +qemuSnapshotDeleteSingle(virDomainObj *vm, + virDomainMomentObj *snap, + bool metadata_only) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + + if (snap->nchildren) { + virQEMUMomentReparent rep; + + rep.dir =3D cfg->snapshotDir; + rep.parent =3D snap->parent; + rep.vm =3D vm; + rep.err =3D 0; + rep.xmlopt =3D driver->xmlopt; + rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; + virDomainMomentForEachChild(snap, + qemuSnapshotChildrenReparent, + &rep); + if (rep.err < 0) + return -1; + virDomainMomentMoveChildren(snap, snap->parent); + } + + return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only= ); +} + + int qemuSnapshotDelete(virDomainObj *vm, virDomainSnapshotPtr snapshot, @@ -2290,7 +2320,6 @@ qemuSnapshotDelete(virDomainObj *vm, int ret =3D -1; virDomainMomentObj *snap =3D NULL; virQEMUMomentRemove rem; - virQEMUMomentReparent rep; bool metadata_only =3D !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_= ONLY); int external =3D 0; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); @@ -2358,21 +2387,7 @@ qemuSnapshotDelete(virDomainObj *vm, ret =3D qemuDomainSnapshotDiscard(driver, vm, snap, true, meta= data_only); } } else { - if (snap->nchildren) { - rep.dir =3D cfg->snapshotDir; - rep.parent =3D snap->parent; - rep.vm =3D vm; - rep.err =3D 0; - rep.xmlopt =3D driver->xmlopt; - rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; - virDomainMomentForEachChild(snap, - qemuSnapshotChildrenReparent, - &rep); - if (rep.err < 0) - goto endjob; - virDomainMomentMoveChildren(snap, snap->parent); - } - ret =3D qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata= _only); + ret =3D qemuSnapshotDeleteSingle(vm, snap, metadata_only); } =20 endjob: --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027600; cv=none; d=zohomail.com; s=zohoarc; b=E9PhTpHl3AaOUwlnc9mR62gbtc4e3DqQCdFxAcRSPS42M18bmUB8ZdwcABgohKjQb0FxohJ3KvjcDMa7nIg6zg4w0rqY9EVeBqCiMCxrO+nIoLwAdKFwXZXZkAkEKGnrrOjgZVQou3RmXonK0AQkymxFhWUeEdKnYDt4k/rfolg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027600; 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; bh=ZqLC/OhzVfwHrLRey9maong1T76x4IObgQ1sJPb8ESk=; b=a2ywRZPWTNx2wfHhW1fejA2/Icf1Lq0ltjnMlVGkHqjdbyml5pzn/cINUVY6E0bbJJL6sigp6EeuTReLGv0XbsGh2M1Gh1wARs6F5O7dkvKwB/rpw/1H/MSW1kNJHbv6PHxEXI+uqUwyz574Qz9jbbmW0yp8+BV8lqwLwpvykqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027600480600.043596511889; Fri, 6 Jan 2023 09:53:20 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-RhsRJa4UNY6Yy-5vGPiH1Q-1; Fri, 06 Jan 2023 12:52:31 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4360D1833FDF; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E54B40C2004; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 21D42194707C; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B09501946586 for ; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9612040C2004; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34A0940C2064 for ; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027599; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZqLC/OhzVfwHrLRey9maong1T76x4IObgQ1sJPb8ESk=; b=bTmLqnrJI0zQ6XnWTt2gHI2dCdk3HljRM8tTHJbibW+GkOC0+2FK0nngJiejhKrg5ajhIO deYRXdMIvxYLjhibJrKILpt0R5OL4atNjJIpX5HPO0HaH68iDZu6PaAhtx233+R8c57un9 ys6QA1mcXN7fiHkkxMIe7mD6cmdGwtY= X-MC-Unique: RhsRJa4UNY6Yy-5vGPiH1Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 15/32] qemu_snapshot: introduce qemuSnapshotDeleteChildren Date: Fri, 6 Jan 2023 18:51:50 +0100 Message-Id: <1e683f8c4e32d81c076a5ceeb79775d64646ec1d.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027601355100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Extract code that deletes children of specific snapshot to separate function. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 109 ++++++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index e85655924a..e65eef8a0d 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2311,18 +2311,76 @@ qemuSnapshotDeleteSingle(virDomainObj *vm, } =20 =20 -int -qemuSnapshotDelete(virDomainObj *vm, - virDomainSnapshotPtr snapshot, - unsigned int flags) +/** + * qemuSnapshotDeleteChildren: + * @vm: domain object + * @snap: snapshot object + * @metadata_only: if true only snapshots metadata are deleted + * @children_only: if true only snapshot children are deleted + * + * Delete children snapshots of snapshot provided by @snap. If @metadata_o= nly + * is true only snapshot metadata files are delete, disk data are left int= act. + * If @children_only is true it will delete only children snapshots of @sn= ap + * and leave @snap intact. + * + * Returns 0 on success, -1 on error. + */ +static int +qemuSnapshotDeleteChildren(virDomainObj *vm, + virDomainMomentObj *snap, + bool metadata_only, + bool children_only) { - virQEMUDriver *driver =3D snapshot->domain->conn->privateData; - int ret =3D -1; - virDomainMomentObj *snap =3D NULL; virQEMUMomentRemove rem; + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + + rem.driver =3D driver; + rem.vm =3D vm; + rem.metadata_only =3D metadata_only; + rem.err =3D 0; + rem.current =3D virDomainSnapshotGetCurrent(vm->snapshots); + rem.found =3D false; + rem.momentDiscard =3D qemuDomainSnapshotDiscard; + virDomainMomentForEachDescendant(snap, qemuDomainMomentDiscardAll, + &rem); + if (rem.err < 0) + return -1; + if (rem.found) { + qemuSnapshotSetCurrent(vm, snap); + + if (children_only) { + if (qemuDomainSnapshotWriteMetadata(vm, snap, + driver->xmlopt, + cfg->snapshotDir) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to set snapshot '%s' as current"), + snap->def->name); + virDomainSnapshotSetCurrent(vm->snapshots, NULL); + return -1; + } + } + } + + if (children_only) { + virDomainMomentDropChildren(snap); + return 0; + } + + return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only= ); +} + + +int +qemuSnapshotDelete(virDomainObj *vm, + virDomainSnapshotPtr snapshot, + unsigned int flags) +{ + int ret =3D -1; + virDomainMomentObj *snap =3D NULL; bool metadata_only =3D !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_= ONLY); int external =3D 0; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); =20 virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY | @@ -2353,39 +2411,8 @@ qemuSnapshotDelete(virDomainObj *vm, =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { - rem.driver =3D driver; - rem.vm =3D vm; - rem.metadata_only =3D metadata_only; - rem.err =3D 0; - rem.current =3D virDomainSnapshotGetCurrent(vm->snapshots); - rem.found =3D false; - rem.momentDiscard =3D qemuDomainSnapshotDiscard; - virDomainMomentForEachDescendant(snap, qemuDomainMomentDiscardAll, - &rem); - if (rem.err < 0) - goto endjob; - if (rem.found) { - qemuSnapshotSetCurrent(vm, snap); - - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { - if (qemuDomainSnapshotWriteMetadata(vm, snap, - driver->xmlopt, - cfg->snapshotDir) < 0)= { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to set snapshot '%s' as curre= nt"), - snap->def->name); - virDomainSnapshotSetCurrent(vm->snapshots, NULL); - goto endjob; - } - } - } - - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { - virDomainMomentDropChildren(snap); - ret =3D 0; - } else { - ret =3D qemuDomainSnapshotDiscard(driver, vm, snap, true, meta= data_only); - } + bool children_only =3D !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILD= REN_ONLY); + ret =3D qemuSnapshotDeleteChildren(vm, snap, metadata_only, childr= en_only); } else { ret =3D qemuSnapshotDeleteSingle(vm, snap, metadata_only); } --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027559; cv=none; d=zohomail.com; s=zohoarc; b=cZ/a+efcAxAzckQaScWVT7VyGENakZh9Sp1aCVxssERD3B1LBEtNlOofp7HI3pLdbDihnOLDdt70EurgHK9ynAU+LAYr1zqcj6I17MtvQKwmAEy1NyX6nsZ8pIUzLlSEi+9mX15UIcikLizp3xlSQrJSo3d0PL3WmHFiFq9Z/KM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027559; 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; bh=Mt6/PEMzgk/QrY6QZYnY4IvM+rqDIad4ktQ/EQkC814=; b=EvLCvxHV/7yTjY4/2YJFcO6ccBb2TZUwmw20jpjsKAXNVY4j8sogdN0SryaEiF0hmRH6CUWeFsSZdzI6fAQuJkPohf6hMCaM7TpjDjoFsZ8ES8u1QTfJxHJr2Ow5whozpuKxYyDq8QcVE2wtzG0FD3le4l0GlNAVJKYtQ5N/Z70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027559801950.5469120846152; Fri, 6 Jan 2023 09:52:39 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-RE5utYREMGiR_J5EOT5vOw-1; Fri, 06 Jan 2023 12:52:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9A9451C0A5B1; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 803AFC15BAD; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 631B819459E1; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4F0C319459C8 for ; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 427E040C2010; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id D372140C2064 for ; Fri, 6 Jan 2023 17:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027558; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Mt6/PEMzgk/QrY6QZYnY4IvM+rqDIad4ktQ/EQkC814=; b=ZXSQ9SpRXbGEJbJoG7UoRV76aFR/cvNn1Gy5tU9Eyeig8V8InjWU3StyDMOqOzWUMj915y 6C2NT9TybEimMEpFDJPW+qhP81mQMs+YA7dbP7ewdo5EWm8HmeUevnCuHcGL/aBXOhbvhV KpFtpuNZo7M77t4f2+dNyzswzsnInk4= X-MC-Unique: RE5utYREMGiR_J5EOT5vOw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 16/32] qemu_snapshot: rework snapshot children deletion Date: Fri, 6 Jan 2023 18:51:51 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027561081100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This simplifies the code a bit by reusing existing parts that deletes a single snapshot. The drawback of this change is that we will now call the re-parent bits to keep the metadata in sync for every child even though it will get deleted as well. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 69 +++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index e65eef8a0d..37a52028a5 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2311,6 +2311,31 @@ qemuSnapshotDeleteSingle(virDomainObj *vm, } =20 =20 +struct qemuSnapshotDeleteAllData { + virDomainObj *vm; + bool metadata_only; + int error; +}; + + +static int +qemuSnapshotDeleteAllHelper(void *payload, + const char *name G_GNUC_UNUSED, + void *opaque) +{ + int error; + virDomainMomentObj *snap =3D payload; + struct qemuSnapshotDeleteAllData *data =3D opaque; + + error =3D qemuSnapshotDeleteSingle(data->vm, snap, data->metadata_only= ); + + if (error !=3D 0) + data->error =3D error; + + return 0; +} + + /** * qemuSnapshotDeleteChildren: * @vm: domain object @@ -2331,44 +2356,22 @@ qemuSnapshotDeleteChildren(virDomainObj *vm, bool metadata_only, bool children_only) { - virQEMUMomentRemove rem; - qemuDomainObjPrivate *priv =3D vm->privateData; - virQEMUDriver *driver =3D priv->driver; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + struct qemuSnapshotDeleteAllData data =3D { + .vm =3D vm, + .metadata_only =3D metadata_only, + }; =20 - rem.driver =3D driver; - rem.vm =3D vm; - rem.metadata_only =3D metadata_only; - rem.err =3D 0; - rem.current =3D virDomainSnapshotGetCurrent(vm->snapshots); - rem.found =3D false; - rem.momentDiscard =3D qemuDomainSnapshotDiscard; - virDomainMomentForEachDescendant(snap, qemuDomainMomentDiscardAll, - &rem); - if (rem.err < 0) - return -1; - if (rem.found) { - qemuSnapshotSetCurrent(vm, snap); + virDomainMomentForEachDescendant(snap, qemuSnapshotDeleteAllHelper, &d= ata); =20 - if (children_only) { - if (qemuDomainSnapshotWriteMetadata(vm, snap, - driver->xmlopt, - cfg->snapshotDir) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to set snapshot '%s' as current"), - snap->def->name); - virDomainSnapshotSetCurrent(vm->snapshots, NULL); - return -1; - } - } - } + if (data.error < 0) + return -1; =20 - if (children_only) { - virDomainMomentDropChildren(snap); - return 0; + if (!children_only && + qemuSnapshotDeleteSingle(vm, snap, metadata_only) < 0) { + return -1; } =20 - return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only= ); + return 0; } =20 =20 --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027584; cv=none; d=zohomail.com; s=zohoarc; b=Lu1R41JfkOs8yjJWLqFiaWiCifiUCNAbk0LgiqVw46FUyu7PJYI5v+6bA00pfrm1TOcyNyJPjSCyDOB9o30pBc2fP7stGlW0JNU8ao+YTGyYGq9huheksJgmy69Ud9FhjkG3QxLV0AX7u+Xh44QDGrHDgMmwBeIim5WThuJtgVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027584; 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; bh=CkRNiJ/zw6xy2bC4ridgn8BEu2OYuPp6szoGa8Z8GeE=; b=l80lkfE1+BLZVZvyZBZvHvuDcKz13+SmZhkqyG+pBG21SUYHPXQfFBG8LTYYDW6biFfKEaeUCzjJFx3ptqdxKVFDDvgn2rbn+cFKzdcUIVXhgVvgu+FP7/QPtWU6tPOFAFQY401/6s99/qE2IXQD9uhXTcrA670TJu/LlY6DEQo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027584957224.73357039124028; Fri, 6 Jan 2023 09:53:04 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-443-I-279mFtMuWudO2T2EmMcg-1; Fri, 06 Jan 2023 12:52:34 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2179485CBE2; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06A061121315; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E9B79194707A; Fri, 6 Jan 2023 17:52:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0BD821946586 for ; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E25C940C2006; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FA0A40C2008 for ; Fri, 6 Jan 2023 17:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027583; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CkRNiJ/zw6xy2bC4ridgn8BEu2OYuPp6szoGa8Z8GeE=; b=Fpz5HsNEnSTOTsxfM5U4Bn5RFYL63shZfqh2zJIQSlnQnYllUI2dNaizNgrpYZSqAzwBFV jXIEgMJDJJ/1QJkdOt8fhzh7amXrutNVlaJz+K+rf76eUAzHchJxiXUnpGZJk8t6V47xmn ecGUW1pkadE/sD/JdkbycV80Wc8uSE0= X-MC-Unique: I-279mFtMuWudO2T2EmMcg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 17/32] qemu_snapshot: move snapshot discard out of qemu_domain.c Date: Fri, 6 Jan 2023 18:51:52 +0100 Message-Id: <87757f1c226b0ad6da79ff6a4cae6d09f6bc28de.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027585270100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 95 +-------------------------------------- src/qemu/qemu_domain.h | 9 ---- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_snapshot.c | 96 +++++++++++++++++++++++++++++++++++++++- src/qemu/qemu_snapshot.h | 4 ++ 5 files changed, 102 insertions(+), 104 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5c05032ce3..73dc13e178 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -31,6 +31,7 @@ #include "qemu_migration_params.h" #include "qemu_security.h" #include "qemu_slirp.h" +#include "qemu_snapshot.h" #include "qemu_extdevice.h" #include "qemu_blockjob.h" #include "qemu_checkpoint.h" @@ -7140,81 +7141,6 @@ qemuDomainSnapshotForEachQcow2(virQEMUDriver *driver, op, try_all, def->ndisks); } =20 -/* Discard one snapshot (or its metadata), without reparenting any childre= n. */ -int -qemuDomainSnapshotDiscard(virQEMUDriver *driver, - virDomainObj *vm, - virDomainMomentObj *snap, - bool update_parent, - bool metadata_only) -{ - g_autofree char *snapFile =3D NULL; - qemuDomainObjPrivate *priv; - virDomainMomentObj *parentsnap =3D NULL; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - - if (!metadata_only) { - if (!virDomainObjIsActive(vm)) { - size_t i; - /* Ignore any skipped disks */ - - /* Prefer action on the disks in use at the time the snapshot = was - * created; but fall back to current definition if dealing wit= h a - * snapshot created prior to libvirt 0.9.5. */ - virDomainDef *def =3D snap->def->dom; - - if (!def) - def =3D vm->def; - - for (i =3D 0; i < def->ndisks; i++) { - if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0) - return -1; - } - - if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 0) - return -1; - } else { - priv =3D vm->privateData; - qemuDomainObjEnterMonitor(vm); - /* we continue on even in the face of error */ - qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); - qemuDomainObjExitMonitor(vm); - } - } - - snapFile =3D g_strdup_printf("%s/%s/%s.xml", cfg->snapshotDir, vm->def= ->name, - snap->def->name); - - if (snap =3D=3D virDomainSnapshotGetCurrent(vm->snapshots)) { - virDomainSnapshotSetCurrent(vm->snapshots, NULL); - if (update_parent && snap->def->parent_name) { - parentsnap =3D virDomainSnapshotFindByName(vm->snapshots, - snap->def->parent_nam= e); - if (!parentsnap) { - VIR_WARN("missing parent snapshot matching name '%s'", - snap->def->parent_name); - } else { - virDomainSnapshotSetCurrent(vm->snapshots, parentsnap); - if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, - driver->xmlopt, - cfg->snapshotDir) < 0)= { - VIR_WARN("failed to set parent snapshot '%s' as curren= t", - snap->def->parent_name); - virDomainSnapshotSetCurrent(vm->snapshots, NULL); - } - } - } - } - - if (unlink(snapFile) < 0) - VIR_WARN("Failed to unlink %s", snapFile); - if (update_parent) - virDomainMomentDropParent(snap); - virDomainSnapshotObjListRemove(vm->snapshots, snap); - - return 0; -} - /* Hash iterator callback to discard multiple snapshots. */ int qemuDomainMomentDiscardAll(void *payload, const char *name G_GNUC_UNUSED, @@ -7233,23 +7159,6 @@ int qemuDomainMomentDiscardAll(void *payload, return 0; } =20 -int -qemuDomainSnapshotDiscardAllMetadata(virQEMUDriver *driver, - virDomainObj *vm) -{ - virQEMUMomentRemove rem =3D { - .driver =3D driver, - .vm =3D vm, - .metadata_only =3D true, - .momentDiscard =3D qemuDomainSnapshotDiscard, - }; - - virDomainSnapshotForEach(vm->snapshots, qemuDomainMomentDiscardAll, &r= em); - virDomainSnapshotObjListRemoveAll(vm->snapshots); - - return rem.err; -} - =20 static void qemuDomainRemoveInactiveCommon(virQEMUDriver *driver, @@ -7262,7 +7171,7 @@ qemuDomainRemoveInactiveCommon(virQEMUDriver *driver, g_autofree char *chkDir =3D NULL; =20 /* Remove any snapshot metadata prior to removing the domain */ - if (qemuDomainSnapshotDiscardAllMetadata(driver, vm) < 0) { + if (qemuSnapshotDiscardAllMetadata(driver, vm) < 0) { VIR_WARN("unable to remove all snapshots for domain %s", vm->def->name); } else { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2f027fad87..e34d52c033 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -681,12 +681,6 @@ int qemuDomainSnapshotForEachQcow2(virQEMUDriver *driv= er, const char *op, bool try_all); =20 -int qemuDomainSnapshotDiscard(virQEMUDriver *driver, - virDomainObj *vm, - virDomainMomentObj *snap, - bool update_current, - bool metadata_only); - typedef struct _virQEMUMomentRemove virQEMUMomentRemove; struct _virQEMUMomentRemove { virQEMUDriver *driver; @@ -703,9 +697,6 @@ int qemuDomainMomentDiscardAll(void *payload, const char *name, void *data); =20 -int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriver *driver, - virDomainObj *vm); - void qemuDomainRemoveInactive(virQEMUDriver *driver, virDomainObj *vm, virDomainUndefineFlagsValues flags, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a2ebd8093a..3ea48c9049 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6520,7 +6520,7 @@ qemuDomainUndefineFlags(virDomainPtr dom, nsnapshots); goto endjob; } - if (qemuDomainSnapshotDiscardAllMetadata(driver, vm) < 0) + if (qemuSnapshotDiscardAllMetadata(driver, vm) < 0) goto endjob; } if (!virDomainObjIsActive(vm) && diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 37a52028a5..3eb0ec2998 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2281,6 +2281,100 @@ qemuSnapshotChildrenReparent(void *payload, } =20 =20 +/* Discard one snapshot (or its metadata), without reparenting any childre= n. */ +static int +qemuSnapshotDiscard(virQEMUDriver *driver, + virDomainObj *vm, + virDomainMomentObj *snap, + bool update_parent, + bool metadata_only) +{ + g_autofree char *snapFile =3D NULL; + qemuDomainObjPrivate *priv; + virDomainMomentObj *parentsnap =3D NULL; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + + if (!metadata_only) { + if (!virDomainObjIsActive(vm)) { + size_t i; + /* Ignore any skipped disks */ + + /* Prefer action on the disks in use at the time the snapshot = was + * created; but fall back to current definition if dealing wit= h a + * snapshot created prior to libvirt 0.9.5. */ + virDomainDef *def =3D snap->def->dom; + + if (!def) + def =3D vm->def; + + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0) + return -1; + } + + if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 0) + return -1; + } else { + priv =3D vm->privateData; + qemuDomainObjEnterMonitor(vm); + /* we continue on even in the face of error */ + qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); + qemuDomainObjExitMonitor(vm); + } + } + + snapFile =3D g_strdup_printf("%s/%s/%s.xml", cfg->snapshotDir, vm->def= ->name, + snap->def->name); + + if (snap =3D=3D virDomainSnapshotGetCurrent(vm->snapshots)) { + virDomainSnapshotSetCurrent(vm->snapshots, NULL); + if (update_parent && snap->def->parent_name) { + parentsnap =3D virDomainSnapshotFindByName(vm->snapshots, + snap->def->parent_nam= e); + if (!parentsnap) { + VIR_WARN("missing parent snapshot matching name '%s'", + snap->def->parent_name); + } else { + virDomainSnapshotSetCurrent(vm->snapshots, parentsnap); + if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, + driver->xmlopt, + cfg->snapshotDir) < 0)= { + VIR_WARN("failed to set parent snapshot '%s' as curren= t", + snap->def->parent_name); + virDomainSnapshotSetCurrent(vm->snapshots, NULL); + } + } + } + } + + if (unlink(snapFile) < 0) + VIR_WARN("Failed to unlink %s", snapFile); + if (update_parent) + virDomainMomentDropParent(snap); + virDomainSnapshotObjListRemove(vm->snapshots, snap); + + return 0; +} + + +int +qemuSnapshotDiscardAllMetadata(virQEMUDriver *driver, + virDomainObj *vm) +{ + virQEMUMomentRemove rem =3D { + .driver =3D driver, + .vm =3D vm, + .metadata_only =3D true, + .momentDiscard =3D qemuSnapshotDiscard, + }; + + virDomainSnapshotForEach(vm->snapshots, qemuDomainMomentDiscardAll, &r= em); + virDomainSnapshotObjListRemoveAll(vm->snapshots); + + return rem.err; +} + + static int qemuSnapshotDeleteSingle(virDomainObj *vm, virDomainMomentObj *snap, @@ -2307,7 +2401,7 @@ qemuSnapshotDeleteSingle(virDomainObj *vm, virDomainMomentMoveChildren(snap, snap->parent); } =20 - return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only= ); + return qemuSnapshotDiscard(driver, vm, snap, true, metadata_only); } =20 =20 diff --git a/src/qemu/qemu_snapshot.h b/src/qemu/qemu_snapshot.h index f69c05f68c..38437a2fd7 100644 --- a/src/qemu/qemu_snapshot.h +++ b/src/qemu/qemu_snapshot.h @@ -49,6 +49,10 @@ qemuSnapshotRevert(virDomainObj *vm, virDomainSnapshotPtr snapshot, unsigned int flags); =20 +int +qemuSnapshotDiscardAllMetadata(virQEMUDriver *driver, + virDomainObj *vm); + int qemuSnapshotDelete(virDomainObj *vm, virDomainSnapshotPtr snapshot, --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027647; cv=none; d=zohomail.com; s=zohoarc; b=gQp0nWuJaeoVQmIA6Y7oByziTt7bUc53FaFdekX2xUJ4i2rPxWP8vo/AXoSd3YpV8xcpQWg54Pu+S3CDl9ckRBTX6XAwuhLi20nBmLSLYFrHxgBKg4ci8hNHFQyuMZvTJnreZ+wtus1C2tEjmG/XQ9jTb4lGu2HRt6JBj+jX7/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027647; 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; bh=ipxL2AVZnNluDikWiHvvoxbD46GfhExI8EkycszLt3E=; b=Y1dLCNOR1Nx5ifVHzZco+a/Z8hiymNY94WT6WIcqjIH5UbnUGYvHqGVm5l9+itwVaqo4bbMyJNls38GF5NTwXsaBrD3GsfM7lEtQJe5jFnQaOzbJAQ/lsIDA3dS2lPgWQhClrw/A0m2RAe7fFJ6k+es1IKyTCZm0kSKWDrWaXmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027647457573.385530271116; Fri, 6 Jan 2023 09:54:07 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-W1Jmu_nuMuyVYv63wDTVig-1; Fri, 06 Jan 2023 12:52:34 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 18F8E28055AF; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFBD7C16020; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DA560194707D; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC2731946586 for ; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8E8B540C2004; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B11140C2064 for ; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027646; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ipxL2AVZnNluDikWiHvvoxbD46GfhExI8EkycszLt3E=; b=LR99zpupU8d3JpdwUQo3/qSotC3eLvpj1rDGhSsnfBa1ppoNsIqcWKcDTpNp90YanYbbK9 AyEbx7oErZT6qvFrYXtGAwkr3hB6mloR207yLF+M31q+SvWM3LkxuHGPLdXuDT38ht7cRK if57ehlkOxF+gHFal1NhuBAoW+1nw8M= X-MC-Unique: W1Jmu_nuMuyVYv63wDTVig-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 18/32] qemu_snapshot: move snapshot metadata reparent code Date: Fri, 6 Jan 2023 18:51:53 +0100 Message-Id: <7ed99d575ccc103573f6d66908d5c59ff90d32c0.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027647894100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Previously the reparent happened before the actual snapshot deletion. This change moves the code closer to the rest of the code handling snapshot metadata when deletion happens. This makes the metadate deletion happen after the data files are deleted. Following patch will extract it into separate function Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 3eb0ec2998..e7893f285a 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2323,6 +2323,25 @@ qemuSnapshotDiscard(virQEMUDriver *driver, } } =20 + if (update_parent) { + if (snap->nchildren) { + virQEMUMomentReparent rep; + + rep.dir =3D cfg->snapshotDir; + rep.parent =3D snap->parent; + rep.vm =3D vm; + rep.err =3D 0; + rep.xmlopt =3D driver->xmlopt; + rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; + virDomainMomentForEachChild(snap, + qemuSnapshotChildrenReparent, + &rep); + if (rep.err < 0) + return -1; + virDomainMomentMoveChildren(snap, snap->parent); + } + } + snapFile =3D g_strdup_printf("%s/%s/%s.xml", cfg->snapshotDir, vm->def= ->name, snap->def->name); =20 @@ -2382,24 +2401,6 @@ qemuSnapshotDeleteSingle(virDomainObj *vm, { qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - - if (snap->nchildren) { - virQEMUMomentReparent rep; - - rep.dir =3D cfg->snapshotDir; - rep.parent =3D snap->parent; - rep.vm =3D vm; - rep.err =3D 0; - rep.xmlopt =3D driver->xmlopt; - rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; - virDomainMomentForEachChild(snap, - qemuSnapshotChildrenReparent, - &rep); - if (rep.err < 0) - return -1; - virDomainMomentMoveChildren(snap, snap->parent); - } =20 return qemuSnapshotDiscard(driver, vm, snap, true, metadata_only); } --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027651; cv=none; d=zohomail.com; s=zohoarc; b=dbdvGlRuXZNzy5zU5En+3Ge7X1qAOnLxB11YchF+P9ogtaVZMuHiJXnS1TXaCUPz5ufGziSxl495ZBoBJPRlcAQsYl+lfIfYjktX4i9cbhIzDfUqqUkNh9hqZH4xYMrQHvPDBeHx5K26HH7VICiygSifYmAC0lN5geKDodM29iw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027651; 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; bh=QBVGK207WfE3nokIL+WuGohNK8gvWpqa6RgIYBL5M9g=; b=cc5+9QSNru23sTVIzWthF6QDP+NymzrIVwveclkBhkycCAfuNntaQQI7KmcVma7liiJEcWy0rq49Dvs0RgkYT3nuVzcHOKStc0pf3KIvEwpeUUDsyuGBNN0A0V15mQDC0O6nmVRLXLA8h02djn6rKXYTBtwFAsimLk78J+rIIzo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027651269545.8541993282722; Fri, 6 Jan 2023 09:54:11 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-2CK0yp9nNrWX6K_K9ZBaGw-1; Fri, 06 Jan 2023 12:52:35 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 83D17857F52; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B8782026DEF; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 42BD919459D8; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 46A0B1947077 for ; Fri, 6 Jan 2023 17:52:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 38D5440C2004; Fri, 6 Jan 2023 17:52:27 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAE5B40C2064 for ; Fri, 6 Jan 2023 17:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027650; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QBVGK207WfE3nokIL+WuGohNK8gvWpqa6RgIYBL5M9g=; b=bHwUIOJLXmi49N5AQReIhHshZNYv9HXicwlIPHQyILl0MHGon4+b+XHic053oesL2441G3 oAHkzSGTFqwwB3xdX+rNb9gwlHkVhoQNzq3lEKSBKnuYXauZBvUb9W5Zl26yjRJMRAS2rp 7B1zgtVIOsLLE6MgQkQq89ZYlG//ckY= X-MC-Unique: 2CK0yp9nNrWX6K_K9ZBaGw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 19/32] qemu_snapshot: introduce qemuSnapshotDiscardMetadata Date: Fri, 6 Jan 2023 18:51:54 +0100 Message-Id: <5faa56a9918685f950a968aae6065e69cb73c9af.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027651786100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Extract the code deleting external snapshot metadata to separate function. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 88 +++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index e7893f285a..359f0a3671 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2281,47 +2281,15 @@ qemuSnapshotChildrenReparent(void *payload, } =20 =20 -/* Discard one snapshot (or its metadata), without reparenting any childre= n. */ static int -qemuSnapshotDiscard(virQEMUDriver *driver, - virDomainObj *vm, - virDomainMomentObj *snap, - bool update_parent, - bool metadata_only) +qemuSnapshotDiscardMetadata(virDomainObj *vm, + virDomainMomentObj *snap, + bool update_parent) { + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autofree char *snapFile =3D NULL; - qemuDomainObjPrivate *priv; - virDomainMomentObj *parentsnap =3D NULL; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - - if (!metadata_only) { - if (!virDomainObjIsActive(vm)) { - size_t i; - /* Ignore any skipped disks */ - - /* Prefer action on the disks in use at the time the snapshot = was - * created; but fall back to current definition if dealing wit= h a - * snapshot created prior to libvirt 0.9.5. */ - virDomainDef *def =3D snap->def->dom; - - if (!def) - def =3D vm->def; - - for (i =3D 0; i < def->ndisks; i++) { - if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0) - return -1; - } - - if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 0) - return -1; - } else { - priv =3D vm->privateData; - qemuDomainObjEnterMonitor(vm); - /* we continue on even in the face of error */ - qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); - qemuDomainObjExitMonitor(vm); - } - } =20 if (update_parent) { if (snap->nchildren) { @@ -2348,6 +2316,7 @@ qemuSnapshotDiscard(virQEMUDriver *driver, if (snap =3D=3D virDomainSnapshotGetCurrent(vm->snapshots)) { virDomainSnapshotSetCurrent(vm->snapshots, NULL); if (update_parent && snap->def->parent_name) { + virDomainMomentObj *parentsnap =3D NULL; parentsnap =3D virDomainSnapshotFindByName(vm->snapshots, snap->def->parent_nam= e); if (!parentsnap) { @@ -2376,6 +2345,49 @@ qemuSnapshotDiscard(virQEMUDriver *driver, } =20 =20 +/* Discard one snapshot (or its metadata), without reparenting any childre= n. */ +static int +qemuSnapshotDiscard(virQEMUDriver *driver, + virDomainObj *vm, + virDomainMomentObj *snap, + bool update_parent, + bool metadata_only) +{ + if (!metadata_only) { + if (!virDomainObjIsActive(vm)) { + size_t i; + /* Ignore any skipped disks */ + + /* Prefer action on the disks in use at the time the snapshot = was + * created; but fall back to current definition if dealing wit= h a + * snapshot created prior to libvirt 0.9.5. */ + virDomainDef *def =3D snap->def->dom; + + if (!def) + def =3D vm->def; + + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0) + return -1; + } + + if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 0) + return -1; + } else { + qemuDomainObjEnterMonitor(vm); + /* we continue on even in the face of error */ + qemuMonitorDeleteSnapshot(qemuDomainGetMonitor(vm), snap->def-= >name); + qemuDomainObjExitMonitor(vm); + } + } + + if (qemuSnapshotDiscardMetadata(vm, snap, update_parent) < 0) + return -1; + + return 0; +} + + int qemuSnapshotDiscardAllMetadata(virQEMUDriver *driver, virDomainObj *vm) --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027564; cv=none; d=zohomail.com; s=zohoarc; b=cCkaJgrO6WwhvDLGt0PHXQOLAvm9yjvzBmXZWa9A4NVs3PdVpiNem7bhKoySUEQQspsuyxfqmHZc5rxZXbJnysj/Zwx4PGQxeJF1YBBuI/wcwbu+mUPbnivm+pOiqxSrIBaBbFgJMFLQcv2HMddhv4rJgI6+DjjLwgs1xrPk5qI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027564; 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; bh=izYYwQ33d/YVyAIFLfr5ELK6ukS5Jt25VCLESmRTAqc=; b=LWMlpT/I13RZO3W6pkbSW+dH3W7rpJno5hY0p71YtVhU5H8PLbUTW3lEXGBgstpmxtyIqLRBqDfjj4wwx+jFoXuBczWS8FcehhsBYTlU9SRQkLLGsyKn7NTtefziO5wFAIQfTqSEBVJjK116rHRecqWKSxx8Ynvdizv707UhjYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027564965635.4440242165948; Fri, 6 Jan 2023 09:52:44 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-9-yyUjX4qEPPW3H4PoZ1GauQ-1; Fri, 06 Jan 2023 12:52:38 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6818C2804153; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4515D40C115E; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2B62A19459CD; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E2AF2194707D for ; Fri, 6 Jan 2023 17:52:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D725B40C2064; Fri, 6 Jan 2023 17:52:27 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75DD940C2004 for ; Fri, 6 Jan 2023 17:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027563; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=izYYwQ33d/YVyAIFLfr5ELK6ukS5Jt25VCLESmRTAqc=; b=I1fidTQ/1qr4G01WGRLeDFfII9V4btE2HdOpSV+NrMqOXdCtGzhORxupCJGakvkJc9RMHw iJSiTwtESmeTEkI/7Y+sLTFyn7VbESwz+SM0qcrQkIp8fnK31kzCqOobWMPCC6Pz6ySPj+ cdvhvtWWAHKNn+I52DSxBZsj4e3nTrA= X-MC-Unique: yyUjX4qEPPW3H4PoZ1GauQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 20/32] qemu_snapshot: introduce qemuSnapshotDeleteValidate function Date: Fri, 6 Jan 2023 18:51:55 +0100 Message-Id: <57caba1cfc21a79b1e30d98de1b4b9ffd6175ff6.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027567079100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 359f0a3671..2e0e4896f5 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2482,6 +2482,33 @@ qemuSnapshotDeleteChildren(virDomainObj *vm, } =20 =20 +static int +qemuSnapshotDeleteValidate(virDomainMomentObj *snap, + unsigned int flags) +{ + int external =3D 0; + + if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) && + virDomainSnapshotIsExternal(snap)) + external++; + + if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) + virDomainMomentForEachDescendant(snap, + qemuSnapshotCountExternal, + &external); + + if (external) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("deletion of %d external disk snapshots not " + "supported yet"), external); + return -1; + } + + return 0; +} + + int qemuSnapshotDelete(virDomainObj *vm, virDomainSnapshotPtr snapshot, @@ -2490,7 +2517,6 @@ qemuSnapshotDelete(virDomainObj *vm, int ret =3D -1; virDomainMomentObj *snap =3D NULL; bool metadata_only =3D !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_= ONLY); - int external =3D 0; =20 virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY | @@ -2503,20 +2529,8 @@ qemuSnapshotDelete(virDomainObj *vm, goto endjob; =20 if (!metadata_only) { - if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) && - virDomainSnapshotIsExternal(snap)) - external++; - if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | - VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) - virDomainMomentForEachDescendant(snap, - qemuSnapshotCountExternal, - &external); - if (external) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("deletion of %d external disk snapshots not " - "supported yet"), external); + if (qemuSnapshotDeleteValidate(snap, flags) < 0) goto endjob; - } } =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027594; cv=none; d=zohomail.com; s=zohoarc; b=g99dFa/9mp7/f9+9GhdiLeqIrzI+IBTyelFkSFsmYwD8poe4A24NX6bHJf0qm9Ufy53U4/BAKWPt6oVlPmtO45KqjQVKU8nn2sFqPw3CeEH3hLZ1/D9AEXBfB0ssWF1cfO7EUwjCq0v5tFNyabx/FPv9+4hpZ6s9Nh1QHZVy4f4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027594; 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; bh=rgKdQ7uDiXkzagDzTbUS/5yZgYtCWTxABckyLVcU59U=; b=WSIMfkNLcOhUBexJP5Fn+o608JaC9Fr3EYYg77Y9UTSRG79WPPVRcm68YRzk7PFTsPF1mvpgW3hMMBxYODZdjLFiVZXdDf+AbqoitCCxy5VJBdzYT0ynhrlAF5JXjg2ucZiQxdxo7YK10xmG25n8XIT022bHjfvDWZ1Z8or7rqY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027594428728.6548310432124; Fri, 6 Jan 2023 09:53:14 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-542-oPOTB-kqP_Kh_WKy6VyPtQ-1; Fri, 06 Jan 2023 12:52:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D270B811E6E; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDA4C39D6D; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ADAFB194707E; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 930D41947B8C for ; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 824A740C2004; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FEC140C2064 for ; Fri, 6 Jan 2023 17:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027593; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rgKdQ7uDiXkzagDzTbUS/5yZgYtCWTxABckyLVcU59U=; b=hYX/oTh8/bY/vcYQdwc7K0nblLAc6J3fPoK8mybC8g2fooyOPaDKYVc/rWUm33B1hlUdvo zShMAlrotcuBaSGQECSzg2AQAP+6l4x2RNHEXmDfzWkM6e1hrGKi/i8obNr/xC+c9ZU+th mCyJaDXEtxZl8LIkBIix8xTiReJOIi8= X-MC-Unique: oPOTB-kqP_Kh_WKy6VyPtQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 21/32] qemu_snapshot: refactor validation of snapshot delete Date: Fri, 6 Jan 2023 18:51:56 +0100 Message-Id: <08f0df2be2c60e3545e94da1728404bbb3e69060.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027595328100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Prepare the validation function for external snapshot delete support. There is one exception when deleting `children-only` snapshots. If the snapshot tree is like this example: snap1 (external) | +- snap2 (internal) | +- snap3 (internal) | +- snap4 (internal) and user calls `snapshot-delete snap1 --children-only` the current snapshot is external but all the children snapshots are internal only and we are able to delete it. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 73 +++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 2e0e4896f5..c23f629e9f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -100,21 +100,6 @@ qemuSnapObjFromSnapshot(virDomainObj *vm, } =20 =20 -/* Count how many snapshots in a set are external snapshots. */ -static int -qemuSnapshotCountExternal(void *payload, - const char *name G_GNUC_UNUSED, - void *data) -{ - virDomainMomentObj *snap =3D payload; - int *count =3D data; - - if (virDomainSnapshotIsExternal(snap)) - (*count)++; - return 0; -} - - int qemuSnapshotFSFreeze(virDomainObj *vm, const char **mountpoints, @@ -2482,26 +2467,60 @@ qemuSnapshotDeleteChildren(virDomainObj *vm, } =20 =20 +typedef struct { + int external; + int internal; +} qemuSnapshotCount; + + +static int +qemuSnapshotCountExternalInternal(void *payload, + const char *name G_GNUC_UNUSED, + void *data) +{ + virDomainMomentObj *snap =3D payload; + qemuSnapshotCount *count =3D data; + + if (virDomainSnapshotIsExternal(snap)) { + count->external++; + } else { + count->internal++; + } + + return 0; +} + + static int qemuSnapshotDeleteValidate(virDomainMomentObj *snap, unsigned int flags) { - int external =3D 0; - - if (!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) && - virDomainSnapshotIsExternal(snap)) - external++; =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | - VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { + qemuSnapshotCount count =3D { 0 }; + virDomainMomentForEachDescendant(snap, - qemuSnapshotCountExternal, - &external); + qemuSnapshotCountExternalInternal, + &count); =20 - if (external) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("deletion of %d external disk snapshots not " - "supported yet"), external); + if (count.external > 0 && count.internal > 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of external and internal children d= isk snapshots not supported")); + return -1; + } + + if (count.external > 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of external children disk snapshots= not supported")); + return -1; + } + } + + if (virDomainSnapshotIsExternal(snap) && + !(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of external disk snapshots not supporte= d")); return -1; } =20 --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027588; cv=none; d=zohomail.com; s=zohoarc; b=Yx2B4J1Uxt7umUxP+ysoSG7yGqPn/ZzxloyD31RIMFER/OLP2XR4F6snkRLWDAqnqhmdKIZ78J0PgaH1i36zL9TAchr1xZEaPIW6qj3qJvF05FQjUvzOQA8tkSkA/BiuFj23x6pHwFy6MULsamWZur4O75vUDVe/FXYf/V9d6Rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027588; 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; bh=Mt2rQeDXmeo96TqANESzD64QKkxJeKffvWjAcsN1lks=; b=fnq2Ht/VC+xihLGfHTf7DMsv8enhTph0yRt2GLhppCF5ItwvLFxwYb9T2zzekdl8YDKkKqm5s3oKSsOuYhUMTpMEL6hfsIp+T7xeurAik1ecTsPLd1aHAj3KT8HrAi69LfBFkQ3bCggh/thkjQTxYVf6yjRSoxh+SMws4toyXZE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027588360886.6327841883856; Fri, 6 Jan 2023 09:53:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-133-MazbGZf6MqOgcc1cN225pg-1; Fri, 06 Jan 2023 12:52:37 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4319A181E40E; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C7AFC1602D; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F2E4019459D4; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3C4C519459C1 for ; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 31BB240C200C; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE99340C2064 for ; Fri, 6 Jan 2023 17:52:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027587; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Mt2rQeDXmeo96TqANESzD64QKkxJeKffvWjAcsN1lks=; b=V0Ki+IHEIsteg+u8iOVn3BZWqAd1wiqxHioKUhaY4al4IfXktWDLsl4k5kcfaD/ZTFDLXa uQjZEtepgcPJL5EsF9ncTXFIO0T75EIaL2Mw6kLgIJoA4eT87t/mHezWE2jxIF+o3xK701 +pyRijzUpRSSJ0/5qI6DoCQ1uLfEtj0= X-MC-Unique: MazbGZf6MqOgcc1cN225pg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 22/32] qemu_snapshot: error out when deleting internal snapshot on non-active disk Date: Fri, 6 Jan 2023 18:51:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027589301100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Deleting internal snapshot when the currently active disk image is different than where the internal snapshot was taken doesn't work correctly. This applies to a running VM only as we are using QMP command and talking to the QEMU process that is using different disk. This works correctly when the VM is shut of as in this case we spawn qemu-img process to delete the snapshot. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c23f629e9f..30137a2b8f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2492,9 +2492,31 @@ qemuSnapshotCountExternalInternal(void *payload, =20 =20 static int -qemuSnapshotDeleteValidate(virDomainMomentObj *snap, +qemuSnapshotDeleteValidate(virDomainObj *vm, + virDomainMomentObj *snap, unsigned int flags) { + if (!virDomainSnapshotIsExternal(snap) && + virDomainObjIsActive(vm)) { + ssize_t i; + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDef *snapDisk =3D &(snapdef->disks[i]); + virDomainDiskDef *vmdisk =3D NULL; + virDomainDiskDef *disk =3D NULL; + + vmdisk =3D qemuDomainDiskByName(vm->def, snapDisk->name); + disk =3D qemuDomainDiskByName(snapdef->parent.dom, snapDisk->n= ame); + + if (!virStorageSourceIsSameLocation(vmdisk->src, disk->src)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("disk image '%s' for internal snapshot '%= s' is not the same as disk image currently used by VM"), + snapDisk->name, snap->def->name); + return -1; + } + } + } =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { @@ -2548,7 +2570,7 @@ qemuSnapshotDelete(virDomainObj *vm, goto endjob; =20 if (!metadata_only) { - if (qemuSnapshotDeleteValidate(snap, flags) < 0) + if (qemuSnapshotDeleteValidate(vm, snap, flags) < 0) goto endjob; } =20 --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027566; cv=none; d=zohomail.com; s=zohoarc; b=D72cPwaYp01EZnlm0jXqay71Z+grIBnOSMYbCNaHYEqC9uR/8V27HkP+IEta/Ep8uFLllG6WAMp+46CSb+ikXD9BeJdimJGGT5uD+krJcRKK5gEJKvP1Nt7d/yymmRwICS+28Tr+SpPB1eF2GKCLlql432JIRbuJuL2e+uteXRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027566; 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; bh=JYK7B4x9CkcboWC0o791R94WH94qlykYXWcOyQc2Ef0=; b=BG17dWC8bXnQFt1CQyiWzwcdXhHQBHgjJNSYYoFM9K35rX5991rZtYH0/6omTHgK2RGYBztWcJKygkSTVN2UE8qQUL84PQlPm5SKBM5GyX/+ZAALtNFjrAwyibVV6VWL/kNzno6GmlBXgN2VYGHBeV08U2t+ASg9odCu8/ImIxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027566973671.4189025967245; Fri, 6 Jan 2023 09:52:46 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-199-_-6BN5fXPJebmZnzsCdDsg-1; Fri, 06 Jan 2023 12:52:40 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E672A857A99; Fri, 6 Jan 2023 17:52:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D348D400E40A; Fri, 6 Jan 2023 17:52:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C3F4C1947077; Fri, 6 Jan 2023 17:52:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D76ED19459CB for ; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CDCE440C2004; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BD4440C2064 for ; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027566; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JYK7B4x9CkcboWC0o791R94WH94qlykYXWcOyQc2Ef0=; b=aFdi2wPm/AeLD2yovcJ4brI7lcJ86U5qdzIZOCIEmV9xGNtdqMpnn7zQ8q/lsiyC0jZNx1 Y9n2CRkSzE3Gw1sCAvgvnbI39YJ2i5+OnPCPgM7M0SZOZzXE5Jq+LxLU+uH2Rx7AdSq3J9 j7cEjfaTv7xS906eH48lbprHJFuMo48= X-MC-Unique: _-6BN5fXPJebmZnzsCdDsg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 23/32] qemu_snapshot: convert snapshot delete to async domain job Date: Fri, 6 Jan 2023 18:51:58 +0100 Message-Id: <4aa133c57d5a508153dbcd9e3ddc10597fb16aee.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027569167100007 Content-Type: text/plain; charset="utf-8"; x-default="true" Deleting external snapshots will require to run it as async domain job, the same way as we do for snapshot creation. For internal snapshots modify the job mask in order to forbid any other job to be started. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 30137a2b8f..3fd348efd3 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2359,10 +2359,15 @@ qemuSnapshotDiscard(virQEMUDriver *driver, if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 0) return -1; } else { - qemuDomainObjEnterMonitor(vm); + /* Similarly as internal snapshot creation we would use a regu= lar job + * here so set a mask to forbid any other job. */ + qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_NONE); + if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT)= < 0) + return -1; /* we continue on even in the face of error */ qemuMonitorDeleteSnapshot(qemuDomainGetMonitor(vm), snap->def-= >name); qemuDomainObjExitMonitor(vm); + qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_DEFAULT_MASK); } } =20 @@ -2563,8 +2568,11 @@ qemuSnapshotDelete(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY | VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, -1); =20 - if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SNAPSHOT, + VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE, + flags) < 0) { return -1; + } =20 if (!(snap =3D qemuSnapObjFromSnapshot(vm, snapshot))) goto endjob; @@ -2583,7 +2591,7 @@ qemuSnapshotDelete(virDomainObj *vm, } =20 endjob: - virDomainObjEndJob(vm); + virDomainObjEndAsyncJob(vm); =20 return ret; } --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027645; cv=none; d=zohomail.com; s=zohoarc; b=Wmccb3I6gNPIzKQspcIc+zc2FMoKOlw8helP/ThxLrahJVIXIgo6Z4KNNgbVtA8THF4kK+AaHJYspEBkVXHshTiVBsw9Sy0ESya7sd4Nu2vXUyrTnHjMFntVYJG+6E77FjoGtfuQkmEbVmYZuyV+P6JD7R4daQ5J13VY6shjAeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027645; 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; bh=+PKSo7a7FlUl2Cpo9rd8/+ltkNtlrmvfL1zuAgA0olQ=; b=geKc3Ka/wJPfQbpCbCZ2N+L54A9j2QO7k47FbIVKlIuIbC0OYlsVsthrP2BwP5r/Zib4kdmbjDzjPAOmoFRW6Ps2fMXHwBRK77zP40H7TMTKL2JrNGRNsnt0Nzf6O2+/2lsa39K5JbuzlQ6DBmF6I5518bqiGNv7GfTcFHLf0Jk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027645427847.3774132797131; Fri, 6 Jan 2023 09:54:05 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-Gdsi8VEPNMK8OasAhekPAA-1; Fri, 06 Jan 2023 12:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFD782802E27; Fri, 6 Jan 2023 17:52:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B1FB40C1074; Fri, 6 Jan 2023 17:52:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7BC1919459CF; Fri, 6 Jan 2023 17:52:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 88D8419459C1 for ; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7AFFF40C2007; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17B3D40C2005 for ; Fri, 6 Jan 2023 17:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027644; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+PKSo7a7FlUl2Cpo9rd8/+ltkNtlrmvfL1zuAgA0olQ=; b=fYEQFTZiAPcaeETWSveOSDkGYycs4G3aCOgoTOf3iZ0BI/yLyvV2pV6or7ARzH92qI4/gH JxAsDmI85xqtfWqGOHctVygvTx2wKUxNCdug1A0gDXTFVbuFbauZtMShTN8Fytuxs1vRpc bS9yfz22bulDl9pJXbKzrpXyAHoDkdE= X-MC-Unique: Gdsi8VEPNMK8OasAhekPAA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 24/32] qemu_snapshot: prepare data for external snapshot deletion Date: Fri, 6 Jan 2023 18:51:59 +0100 Message-Id: <310cd259c190d411c020e55405b1295e19051cbe.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027645842100003 Content-Type: text/plain; charset="utf-8"; x-default="true" In order to save some CPU cycles we will collect all the necessary data to delete external snapshot before we even start. They will be later used by code that deletes the snapshots and updates metadata when needed. With external snapshots we need data that libvirt gets from running QEMU process so if the VM is not running we need to start paused QEMU process for the snapshot deletion and kill at afterwards. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 181 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 3fd348efd3..c7136efe93 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2232,6 +2232,150 @@ qemuSnapshotRevert(virDomainObj *vm, } =20 =20 +typedef struct _qemuSnapshotDeleteExternalData { + virDomainSnapshotDiskDef *snapDisk; /* snapshot disk definition */ + virDomainDiskDef *domDisk; /* VM disk definition */ + virStorageSource *diskSrc; /* source of disk we are deleting */ + virDomainMomentObj *parentSnap; + virDomainDiskDef *parentDomDisk; /* disk definition from snapshot meta= data */ + virStorageSource *parentDiskSrc; /* backing disk source of the @diskSr= c */ + virStorageSource *prevDiskSrc; /* source of disk for which @diskSrc is + backing disk */ + qemuBlockJobData *job; +} qemuSnapshotDeleteExternalData; + + +static void +qemuSnapshotDeleteExternalDataFree(qemuSnapshotDeleteExternalData *data) +{ + if (!data) + return; + + virObjectUnref(data->job); + + g_free(data); +} + + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuSnapshotDeleteExternalData, qemuSnapshot= DeleteExternalDataFree); + + +/** + * qemuSnapshotFindParentSnapForDisk: + * @snap: snapshot object that is about to be deleted + * @snapDisk: snapshot disk definition + * + * Find parent snapshot object that contains snapshot of the @snapDisk. + * It may not be the next snapshot in the snapshot tree as the disk in + * question may be skipped by using VIR_DOMAIN_SNAPSHOT_LOCATION_NO. + * + * Returns virDomainMomentObj* on success or NULL if there is no parent + * snapshot containing the @snapDisk. + * */ +static virDomainMomentObj* +qemuSnapshotFindParentSnapForDisk(virDomainMomentObj *snap, + virDomainSnapshotDiskDef *snapDisk) +{ + virDomainMomentObj *parentSnap =3D snap->parent; + + while (parentSnap) { + ssize_t i; + virDomainSnapshotDef *parentSnapdef =3D virDomainSnapshotObjGetDef= (parentSnap); + + if (!parentSnapdef) + break; + + for (i =3D 0; i < parentSnapdef->ndisks; i++) { + virDomainSnapshotDiskDef *parentSnapDisk =3D &(parentSnapdef->= disks[i]); + + if (parentSnapDisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NO && + STREQ(snapDisk->name, parentSnapDisk->name)) { + return parentSnap; + } + } + + parentSnap =3D parentSnap->parent; + } + + return NULL; +} + + +static GSList* +qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, + virDomainMomentObj *snap) +{ + ssize_t i; + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + g_autoslist(qemuSnapshotDeleteExternalData) ret =3D NULL; + + for (i =3D 0; i < snapdef->ndisks; i++) { + g_autofree qemuSnapshotDeleteExternalData *data =3D NULL; + virDomainSnapshotDiskDef *snapDisk =3D &(snapdef->disks[i]); + + if (snapDisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) + continue; + + data =3D g_new0(qemuSnapshotDeleteExternalData, 1); + data->snapDisk =3D snapDisk; + + data->domDisk =3D qemuDomainDiskByName(vm->def, snapDisk->name); + if (!data->domDisk) + return NULL; + + data->diskSrc =3D virStorageSourceChainLookupBySource(data->domDis= k->src, + data->snapDisk= ->src, + &data->prevDis= kSrc); + if (!data->diskSrc) + return NULL; + + if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapDisk-= >src)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("VM disk source and snapshot disk source are = not the same")); + return NULL; + } + + data->parentDomDisk =3D virDomainDiskByTarget(snapdef->parent.dom, + data->snapDisk->name); + if (!data->parentDomDisk) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("failed to find disk '%s' in snapshot VM XML"= ), + snapDisk->name); + return NULL; + } + + if (virDomainObjIsActive(vm)) { + data->parentDiskSrc =3D data->diskSrc->backingStore; + if (!virStorageSourceIsBacking(data->parentDiskSrc)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("failed to find parent disk source in bac= king chain")); + return NULL; + } + + if (!virStorageSourceIsSameLocation(data->parentDiskSrc, data-= >parentDomDisk->src)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("snapshot VM disk source and parent disk = source are not the same")); + return NULL; + } + } + + data->parentSnap =3D qemuSnapshotFindParentSnapForDisk(snap, data-= >snapDisk); + + if (data->parentSnap && !virDomainSnapshotIsExternal(data->parentS= nap)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("deleting external snapshot that has internal= snapshot as parent not supported")); + return NULL; + } + + ret =3D g_slist_prepend(ret, g_steal_pointer(&data)); + } + + ret =3D g_slist_reverse(ret); + + return g_steal_pointer(&ret); +} + + typedef struct _virQEMUMomentReparent virQEMUMomentReparent; struct _virQEMUMomentReparent { const char *dir; @@ -2563,6 +2707,10 @@ qemuSnapshotDelete(virDomainObj *vm, int ret =3D -1; virDomainMomentObj *snap =3D NULL; bool metadata_only =3D !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_= ONLY); + bool stop_qemu =3D false; + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoslist(qemuSnapshotDeleteExternalData) externalData =3D NULL; =20 virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY | @@ -2580,6 +2728,34 @@ qemuSnapshotDelete(virDomainObj *vm, if (!metadata_only) { if (qemuSnapshotDeleteValidate(vm, snap, flags) < 0) goto endjob; + + if (virDomainSnapshotIsExternal(snap) && + !(flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY))) { + + externalData =3D qemuSnapshotDeleteExternalPrepare(vm, snap); + + if (!virDomainObjIsActive(vm)) { + g_autoslist(qemuSnapshotDeleteExternalData) delData =3D NU= LL; + + if (qemuProcessStart(NULL, driver, vm, NULL, VIR_ASYNC_JOB= _SNAPSHOT, + NULL, -1, NULL, NULL, + VIR_NETDEV_VPORT_PROFILE_OP_CREATE, + VIR_QEMU_PROCESS_START_PAUSED) < 0) { + goto endjob; + } + + stop_qemu =3D true; + + /* Call the prepare again as some data require that the VM= is + * running to get everything we need. */ + delData =3D g_steal_pointer(&externalData); + externalData =3D qemuSnapshotDeleteExternalPrepare(vm, sna= p); + } + + if (!externalData) + goto endjob; + } } =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | @@ -2591,6 +2767,11 @@ qemuSnapshotDelete(virDomainObj *vm, } =20 endjob: + if (stop_qemu) { + qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN, + VIR_ASYNC_JOB_SNAPSHOT, 0); + } + virDomainObjEndAsyncJob(vm); =20 return ret; --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027565; cv=none; d=zohomail.com; s=zohoarc; b=Jy0oCWFnfHP4P/n0n8amIjnPxTahJ4qm7v1f1T3dH65nkttXkSfwS33HWDVIiyvXRRpWkOclFX99el09Jc80fmThMM2XJRSovh+l2BNfrHdX4lvyhD3ZOj/XdfUD0vzUcQBEFUbMAryYlmGbt0EpRv0rMmSjeFpkPYdKhADIK0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027565; 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; bh=BLrZcqRJIE5bL9vvs6mSi+g3n30ufBj2vfekap1rr4U=; b=YyEv0ExJGGrkq45Iqna3IghD4X6uOPLD7am09YKDO2X5gAQTqQSQ2olMZhEBWWHAhISzwoMHXSiVVrfVXBYD/EOKxlQTRY2G+XgaMnrOdRuh5MRNBXmKjBgGQLjxMDyn9VsrUlzy+2LWtwhstVCNVkxr3F1n/rLRRvpRDshwYkM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 16730275655505.580603846912709; Fri, 6 Jan 2023 09:52:45 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-595-JlqU0VhTMp2OpK_3aOep6w-1; Fri, 06 Jan 2023 12:52:38 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D29A3C10ED6; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 850972166B32; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 70D451947B81; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 40BAF19459C3 for ; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 24EF740C2004; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id B758E40C2064 for ; Fri, 6 Jan 2023 17:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027564; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BLrZcqRJIE5bL9vvs6mSi+g3n30ufBj2vfekap1rr4U=; b=F42mNmIFPHHGN1Uz2shdrkvVD/Fs5GIJP9a0KHnT+Bx31tTz0kssKx5Q7oi0qKpW039bU+ UftpldtfBWT1UQk7xjiRl4lNkJw3Nn5vzrCwb7Q33TJeAKL7ZPfUB5FrsY9FKSgFh5/Uh2 LbnCjrMgjzSGVMRIIMYkPA+cF6rK6tM= X-MC-Unique: JlqU0VhTMp2OpK_3aOep6w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 25/32] qemu_snapshot: implement deletion of external snapshot Date: Fri, 6 Jan 2023 18:52:00 +0100 Message-Id: <50e4504a9ab13bc7f97616376a041698b11ac304.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027567149100005 Content-Type: text/plain; charset="utf-8"; x-default="true" When deleting snapshot we are starting block-commit job over all disks that are part of the snapshot. This operation may fail as it writes data changes to the backing qcow2 image so we need to wait for all the disks to finish the operation and wait for correct signal from QEMU. If deleting active snapshot we will get `ready` signal and for inactive snapshots we need to disable autofinalize in order to get `pending` signal. At this point if commit for any disk fails for some reason and we abort the VM is still in consistent state and user can fix the reason why the deletion failed. After that we do `pivot` or `finalize` if it's active snapshot or not to finish the block job. It still may fail but there is nothing else we can do about it. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 256 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 236 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c7136efe93..26f962ce82 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2410,6 +2410,199 @@ qemuSnapshotChildrenReparent(void *payload, } =20 =20 +/* Deleting external snapshot is started by running qemu block-commit job. + * We need to wait for all block-commit jobs to be 'ready' or 'pending' to + * continue with external snapshot deletion. */ +static int +qemuSnapshotDeleteBlockJobIsRunning(qemuBlockjobState state) +{ + switch (state) { + case QEMU_BLOCKJOB_STATE_NEW: + case QEMU_BLOCKJOB_STATE_RUNNING: + case QEMU_BLOCKJOB_STATE_ABORTING: + case QEMU_BLOCKJOB_STATE_PIVOTING: + return 1; + + case QEMU_BLOCKJOB_STATE_COMPLETED: + case QEMU_BLOCKJOB_STATE_FAILED: + case QEMU_BLOCKJOB_STATE_CANCELLED: + case QEMU_BLOCKJOB_STATE_READY: + case QEMU_BLOCKJOB_STATE_CONCLUDED: + case QEMU_BLOCKJOB_STATE_PENDING: + case QEMU_BLOCKJOB_STATE_LAST: + break; + } + + return 0; +} + + +/* When finishing or aborting qemu blockjob we only need to know if the + * job is still active or not. */ +static int +qemuSnapshotDeleteBlockJobIsActive(qemuBlockjobState state) +{ + switch (state) { + case QEMU_BLOCKJOB_STATE_READY: + case QEMU_BLOCKJOB_STATE_NEW: + case QEMU_BLOCKJOB_STATE_RUNNING: + case QEMU_BLOCKJOB_STATE_ABORTING: + case QEMU_BLOCKJOB_STATE_PENDING: + case QEMU_BLOCKJOB_STATE_PIVOTING: + return 1; + + case QEMU_BLOCKJOB_STATE_COMPLETED: + case QEMU_BLOCKJOB_STATE_FAILED: + case QEMU_BLOCKJOB_STATE_CANCELLED: + case QEMU_BLOCKJOB_STATE_CONCLUDED: + case QEMU_BLOCKJOB_STATE_LAST: + break; + } + + return 0; +} + + +/* Wait for qemu blockjob to finish 'block-commit' operation until it is + * ready to be finished by calling 'block-pivot' or 'block-finalize'. */ +static int +qemuSnapshotDeleteBlockJobRunning(virDomainObj *vm, + qemuBlockJobData *job) +{ + int rc; + qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); + + while ((rc =3D qemuSnapshotDeleteBlockJobIsRunning(job->state)) > 0) { + if (qemuDomainObjWait(vm) < 0) + return -1; + qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); + } + + if (rc < 0) + return -1; + + return 0; +} + + +/* Wait for qemu blockjob to be done after 'block-pivot' or 'block-finaliz= e' + * was started. */ +static int +qemuSnapshotDeleteBlockJobFinishing(virDomainObj *vm, + qemuBlockJobData *job) +{ + int rc; + qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); + + while ((rc =3D qemuSnapshotDeleteBlockJobIsActive(job->state)) > 0) { + if (qemuDomainObjWait(vm) < 0) + return -1; + qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); + } + + if (rc < 0) + return -1; + + return 0; +} + + +static int +qemuSnapshotDiscardExternal(virDomainObj *vm, + GSList *externalData) +{ + GSList *cur =3D NULL; + + for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { + qemuSnapshotDeleteExternalData *data =3D cur->data; + virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_NO; + unsigned int commitFlags =3D VIR_DOMAIN_BLOCK_COMMIT_DELETE; + + if (data->domDisk->src =3D=3D data->diskSrc) { + commitFlags |=3D VIR_DOMAIN_BLOCK_COMMIT_ACTIVE; + autofinalize =3D VIR_TRISTATE_BOOL_YES; + } + + data->job =3D qemuBlockCommit(vm, + data->domDisk, + data->parentDiskSrc, + data->diskSrc, + data->prevDiskSrc, + 0, + VIR_ASYNC_JOB_SNAPSHOT, + autofinalize, + commitFlags); + + if (!data->job) + goto error; + } + + for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { + qemuSnapshotDeleteExternalData *data =3D cur->data; + + if (qemuSnapshotDeleteBlockJobRunning(vm, data->job) < 0) + goto error; + + if (data->job->state =3D=3D QEMU_BLOCKJOB_STATE_FAILED) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("block commit failed while deleting disk '%s'= snapshot: '%s'"), + data->snapDisk->name, data->job->errmsg); + goto error; + } + } + + for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { + qemuSnapshotDeleteExternalData *data =3D cur->data; + + if (data->job->state =3D=3D QEMU_BLOCKJOB_STATE_READY) { + if (qemuBlockPivot(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT, NULL= ) < 0) + goto error; + } else if (data->job->state =3D=3D QEMU_BLOCKJOB_STATE_PENDING) { + if (qemuBlockFinalize(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT) <= 0) + goto error; + } + + if (qemuSnapshotDeleteBlockJobFinishing(vm, data->job) < 0) + goto error; + + if (data->job->state =3D=3D QEMU_BLOCKJOB_STATE_FAILED) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("finishing block job failed while deleting di= sk '%s' snapshot: '%s'"), + data->snapDisk->name, data->job->errmsg); + goto error; + } + + qemuBlockJobSyncEnd(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT); + } + + return 0; + + error: + for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuSnapshotDeleteExternalData *data =3D cur->data; + + if (!data->job) + continue; + + qemuBlockJobUpdate(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT); + + if (qemuSnapshotDeleteBlockJobIsActive(data->job->state)) { + if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT)= =3D=3D 0) { + ignore_value(qemuMonitorBlockJobCancel(priv->mon, data->jo= b->name, false)); + qemuDomainObjExitMonitor(vm); + + data->job->state =3D QEMU_BLOCKJOB_STATE_ABORTING; + } + } + + qemuBlockJobSyncEnd(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT); + } + + return -1; +} + + static int qemuSnapshotDiscardMetadata(virDomainObj *vm, virDomainMomentObj *snap, @@ -2476,11 +2669,12 @@ qemuSnapshotDiscardMetadata(virDomainObj *vm, =20 /* Discard one snapshot (or its metadata), without reparenting any childre= n. */ static int -qemuSnapshotDiscard(virQEMUDriver *driver, - virDomainObj *vm, - virDomainMomentObj *snap, - bool update_parent, - bool metadata_only) +qemuSnapshotDiscardImpl(virQEMUDriver *driver, + virDomainObj *vm, + virDomainMomentObj *snap, + GSList *externalData, + bool update_parent, + bool metadata_only) { if (!metadata_only) { if (!virDomainObjIsActive(vm)) { @@ -2500,18 +2694,28 @@ qemuSnapshotDiscard(virQEMUDriver *driver, return -1; } =20 - if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 0) - return -1; + if (virDomainSnapshotIsExternal(snap)) { + if (qemuSnapshotDiscardExternal(vm, externalData) < 0) + return -1; + } else { + if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d"= , true) < 0) + return -1; + } } else { - /* Similarly as internal snapshot creation we would use a regu= lar job - * here so set a mask to forbid any other job. */ - qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_NONE); - if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT)= < 0) - return -1; - /* we continue on even in the face of error */ - qemuMonitorDeleteSnapshot(qemuDomainGetMonitor(vm), snap->def-= >name); - qemuDomainObjExitMonitor(vm); - qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_DEFAULT_MASK); + if (virDomainSnapshotIsExternal(snap)) { + if (qemuSnapshotDiscardExternal(vm, externalData) < 0) + return -1; + } else { + /* Similarly as internal snapshot creation we would use a = regular job + * here so set a mask to forbid any other job. */ + qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_NONE); + if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPS= HOT) < 0) + return -1; + /* we continue on even in the face of error */ + qemuMonitorDeleteSnapshot(qemuDomainGetMonitor(vm), snap->= def->name); + qemuDomainObjExitMonitor(vm); + qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_DEFAULT_MASK); + } } } =20 @@ -2522,6 +2726,17 @@ qemuSnapshotDiscard(virQEMUDriver *driver, } =20 =20 +static int +qemuSnapshotDiscard(virQEMUDriver *driver, + virDomainObj *vm, + virDomainMomentObj *snap, + bool update_parent, + bool metadata_only) +{ + return qemuSnapshotDiscardImpl(driver, vm, snap, NULL, update_parent, = metadata_only); +} + + int qemuSnapshotDiscardAllMetadata(virQEMUDriver *driver, virDomainObj *vm) @@ -2543,12 +2758,13 @@ qemuSnapshotDiscardAllMetadata(virQEMUDriver *drive= r, static int qemuSnapshotDeleteSingle(virDomainObj *vm, virDomainMomentObj *snap, + GSList *externalData, bool metadata_only) { qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; =20 - return qemuSnapshotDiscard(driver, vm, snap, true, metadata_only); + return qemuSnapshotDiscardImpl(driver, vm, snap, externalData, true, m= etadata_only); } =20 =20 @@ -2568,7 +2784,7 @@ qemuSnapshotDeleteAllHelper(void *payload, virDomainMomentObj *snap =3D payload; struct qemuSnapshotDeleteAllData *data =3D opaque; =20 - error =3D qemuSnapshotDeleteSingle(data->vm, snap, data->metadata_only= ); + error =3D qemuSnapshotDeleteSingle(data->vm, snap, NULL, data->metadat= a_only); =20 if (error !=3D 0) data->error =3D error; @@ -2608,7 +2824,7 @@ qemuSnapshotDeleteChildren(virDomainObj *vm, return -1; =20 if (!children_only && - qemuSnapshotDeleteSingle(vm, snap, metadata_only) < 0) { + qemuSnapshotDeleteSingle(vm, snap, NULL, metadata_only) < 0) { return -1; } =20 @@ -2763,7 +2979,7 @@ qemuSnapshotDelete(virDomainObj *vm, bool children_only =3D !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILD= REN_ONLY); ret =3D qemuSnapshotDeleteChildren(vm, snap, metadata_only, childr= en_only); } else { - ret =3D qemuSnapshotDeleteSingle(vm, snap, metadata_only); + ret =3D qemuSnapshotDeleteSingle(vm, snap, externalData, metadata_= only); } =20 endjob: --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027595; cv=none; d=zohomail.com; s=zohoarc; b=CxGUVVRGdm69UbON+/ojRIkms3b/MDWpqx/O+Hct7jpD07WqKCh0aODOIMeQFdHjPZ3nVDq4zDa5O6c92j1YPYNHV3/NKy4CbkcPgNyDS2eCBJa89fNxIi1lzLtgJ/bNESHGu4NjGTTBmDl1hmvngh5AzjGWBcCIIz8N6fxPMvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027595; 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; bh=bj3qcnvpAgpPPVgeRnopMV06I37gXLTPiC72ewXPh0k=; b=JrkszNiHl84JmyWKduOwp3UHmPWoeo3bdMD9NVKTL/zLQ6IFOGpy95M+CAjo4j2I0buJHhwxToLQeeooCfuHVc7lDVOMTKIpDWNwTefWTv9/yu9/Jy5km5ZIJjXmQTUpEvzK0amp+C969BZN4XrcY3K/m30luuLAHGkkJ/1fJfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027595921468.9009613285557; Fri, 6 Jan 2023 09:53:15 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-373-0fmVY1JoOWWL3yRFR6eraQ-1; Fri, 06 Jan 2023 12:52:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 668BF2802E44; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 511982166B30; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 15A8C19459D7; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D0C3C19459D3 for ; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C6AA440C2005; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6234E40C2064 for ; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027595; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bj3qcnvpAgpPPVgeRnopMV06I37gXLTPiC72ewXPh0k=; b=U+9nYN/uQTZwcuPEN9aVWMKamp4z8FPgPip9caUN+fzffCp57sFSzogFgYtCEqMDqQAhNB 1UrJs1WbpHApVGfWC2cw5J/VjfYC95hbiOufIzqgCDQ9mJLUoahTq3N0fLRjjKtfnt05S9 szunpvyanwLgcLWKgtJHxpxqV+jHnm8= X-MC-Unique: 0fmVY1JoOWWL3yRFR6eraQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 26/32] qemu_snapshot: update metadata when deleting snapshots Date: Fri, 6 Jan 2023 18:52:01 +0100 Message-Id: <5d47a044cf03faf1884734cbf180af17f1bd70bb.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027597334100004 Content-Type: text/plain; charset="utf-8"; x-default="true" With external snapshots we need to modify the metadata bit more then what is required for internal snapshots. Mainly the storage source location changes with every external snapshot. This means that if we delete non-leaf snapshot we need to update all children snapshots and modify the disk sources for all affected disks. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 165 +++++++++++++++++++++++++++++++++++---- 1 file changed, 148 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 26f962ce82..06cc6ef8c0 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2410,6 +2410,127 @@ qemuSnapshotChildrenReparent(void *payload, } =20 =20 +typedef struct _qemuSnapshotUpdateDisksData qemuSnapshotUpdateDisksData; +struct _qemuSnapshotUpdateDisksData { + virDomainMomentObj *snap; + virDomainObj *vm; + int error; +}; + + +/** + * qemuSnapshotUpdateDisksSingle: + * @snap: snapshot object where we are updating disks + * @def: active or inactive definition from @snap + * @parentDef: parent snapshot object of snapshot that we are deleting + * @snapDisk: snapshot disk definition from snapshot we are deleting + * + * When deleting external snapshots we need to modify remaining metadata + * files stored by libvirt. + * + * The first part updates only metadata for external snapshots where we ne= ed + * to update the disk source in the domain definition stored within the + * snapshot metadata. There is no need to do it for internal snapshots as + * they don't create new disk files. + * + * The second part needs to be done for all metadata files. Both internal = and + * external snapshot metadata files have in the domain definition backingS= tore + * that could contain the deleted disk. + * + * Returns 0 on success, -1 on error. + * */ +static int +qemuSnapshotUpdateDisksSingle(virDomainMomentObj *snap, + virDomainDef *def, + virDomainDef *parentDef, + virDomainSnapshotDiskDef *snapDisk) +{ + virDomainDiskDef *disk =3D NULL; + + if (!(disk =3D qemuDomainDiskByName(def, snapDisk->name))) + return -1; + + if (virDomainSnapshotIsExternal(snap)) { + virDomainDiskDef *parentDisk =3D NULL; + + if (!(parentDisk =3D qemuDomainDiskByName(parentDef, snapDisk->nam= e))) + return -1; + + if (virStorageSourceIsSameLocation(snapDisk->src, disk->src)) { + virObjectUnref(disk->src); + disk->src =3D virStorageSourceCopy(parentDisk->src, false); + } + } + + if (disk->src->backingStore) { + virStorageSource *cur =3D disk->src; + virStorageSource *next =3D disk->src->backingStore; + + while (next) { + if (virStorageSourceIsSameLocation(snapDisk->src, next)) { + cur->backingStore =3D next->backingStore; + next->backingStore =3D NULL; + virObjectUnref(next); + break; + } + + cur =3D next; + next =3D cur->backingStore; + } + } + + return 0; +} + + +static int +qemuSnapshotDeleteUpdateDisks(void *payload, + const char *name G_GNUC_UNUSED, + void *opaque) +{ + virDomainMomentObj *snap =3D payload; + qemuSnapshotUpdateDisksData *data =3D opaque; + qemuDomainObjPrivate *priv =3D data->vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(data->sna= p); + ssize_t i; + + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDef *snapDisk =3D &(snapdef->disks[i]); + + if (snapDisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) + continue; + + if (qemuSnapshotUpdateDisksSingle(snap, snap->def->dom, + data->snap->def->dom, snapDisk) = < 0) { + data->error =3D -1; + } + + if (snap->def->inactiveDom) { + virDomainDef *dom =3D data->snap->def->inactiveDom; + + if (!dom) + dom =3D data->snap->def->dom; + + if (qemuSnapshotUpdateDisksSingle(snap, snap->def->inactiveDom, + dom, snapDisk) < 0) { + data->error =3D -1; + } + } + } + + if (qemuDomainSnapshotWriteMetadata(data->vm, + snap, + driver->xmlopt, + cfg->snapshotDir) < 0) { + data->error =3D -1; + } + + return 0; +} + + /* Deleting external snapshot is started by running qemu block-commit job. * We need to wait for all block-commit jobs to be 'ready' or 'pending' to * continue with external snapshot deletion. */ @@ -2612,24 +2733,34 @@ qemuSnapshotDiscardMetadata(virDomainObj *vm, virQEMUDriver *driver =3D priv->driver; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autofree char *snapFile =3D NULL; + int ret =3D 0; =20 - if (update_parent) { - if (snap->nchildren) { - virQEMUMomentReparent rep; + if (update_parent && snap->nchildren) { + virQEMUMomentReparent rep; + qemuSnapshotUpdateDisksData data; =20 - rep.dir =3D cfg->snapshotDir; - rep.parent =3D snap->parent; - rep.vm =3D vm; - rep.err =3D 0; - rep.xmlopt =3D driver->xmlopt; - rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; - virDomainMomentForEachChild(snap, - qemuSnapshotChildrenReparent, - &rep); - if (rep.err < 0) - return -1; - virDomainMomentMoveChildren(snap, snap->parent); - } + rep.dir =3D cfg->snapshotDir; + rep.parent =3D snap->parent; + rep.vm =3D vm; + rep.err =3D 0; + rep.xmlopt =3D driver->xmlopt; + rep.writeMetadata =3D qemuDomainSnapshotWriteMetadata; + virDomainMomentForEachChild(snap, + qemuSnapshotChildrenReparent, + &rep); + if (rep.err < 0) + ret =3D -1; + + data.snap =3D snap; + data.vm =3D vm; + data.error =3D 0; + virDomainMomentForEachDescendant(snap, + qemuSnapshotDeleteUpdateDisks, + &data); + if (data.error < 0) + ret =3D -1; + + virDomainMomentMoveChildren(snap, snap->parent); } =20 snapFile =3D g_strdup_printf("%s/%s/%s.xml", cfg->snapshotDir, vm->def= ->name, @@ -2663,7 +2794,7 @@ qemuSnapshotDiscardMetadata(virDomainObj *vm, virDomainMomentDropParent(snap); virDomainSnapshotObjListRemove(vm->snapshots, snap); =20 - return 0; + return ret; } =20 =20 --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027656; cv=none; d=zohomail.com; s=zohoarc; b=RO5FuGmd0fyuR0wlKHuumA3+05zy8b+Wpz7kiQif6FsNeP/LE0ETsyTnM1zCyfuJ3J8Ee7sWBL5btY8C6RtFksWzUKeGSUrCNQPiI2flPP1tZJ3kjR1Kj9f1xSelZX3qYiYxB0W2htAOS0rFHMY69H+hVWyxLwuHbMyrVenO49g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027656; 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; bh=SE6R02L4opQ0ZGNSZvDKIEDpizcims6C7pNaWvh0hqc=; b=ZvLIycCjS2rq1BYxgR2ce1UWVEKqqkJGjuNlMGzMAoaDiTq6cthkcg0fIpkYp6Ktdd90GiHxTjW0SaHSIEQB/caF8JuHMgfA0R604tZ24IbDU/448C+Jq8y+j8gAX0lQTY/tVnEEeLmMAA4WeKWwKp2V4qmswkKTk8nfoSMkWn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027656264837.7469367406358; Fri, 6 Jan 2023 09:54:16 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-E4sJqMlXP02e_S3huwNjtw-1; Fri, 06 Jan 2023 12:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7FDFB855719; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A4AF2166B30; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 58D5F19459CB; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7999E19459C6 for ; Fri, 6 Jan 2023 17:52:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 70CA440C2064; Fri, 6 Jan 2023 17:52:32 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EDF140C2004 for ; Fri, 6 Jan 2023 17:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027655; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=SE6R02L4opQ0ZGNSZvDKIEDpizcims6C7pNaWvh0hqc=; b=CGRdkCCXiF1j5JP+FaVwmeTU/P4jWQmYBz9nICvn2yhcfX6qjxkcgXw3la3a4nkSCYWcCg J1CpYOm7KPKL/b/HF4f8hlqtqBX3bUOfgRd8qoC8nMNsbHkns+iI+GrgyNSMVl/kEPuw4a CNhP98a2lbdWJ60vX2GIg13C55tfVew= X-MC-Unique: E4sJqMlXP02e_S3huwNjtw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 27/32] qemu_snapshot: when deleting snapshot invalidate parent snapshot Date: Fri, 6 Jan 2023 18:52:02 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027657774100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When deleting external snapshots the operation may fail at any point which could lead to situation that some disks finished the block commit operation but for some disks it failed and the libvirt job ends. In order to make sure that the qcow2 images are in consistent state introduce new element "" that will mark the disk in snapshot metadata as invalid until the snapshot delete is completed successfully. This will prevent deleting snapshot with the invalid disk and in future reverting to snapshot with the invalid disk. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/snapshot_conf.c | 8 ++++++ src/conf/snapshot_conf.h | 1 + src/qemu/qemu_snapshot.c | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 4b5b908d66..9bf3c78353 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -158,6 +158,11 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, return -1; } =20 + if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { + def->snapshotDeleteInProgress =3D !!virXPathNode("./snapshotDelete= InProgress", + ctxt); + } + if ((cur =3D virXPathNode("./source", ctxt)) && virDomainStorageSourceParse(cur, ctxt, src, flags, xmlopt) < 0) return -1; @@ -744,6 +749,9 @@ virDomainSnapshotDiskDefFormat(virBuffer *buf, virBufferAsprintf(&attrBuf, " snapshot=3D'%s'", virDomainSnapshotLocationTypeToString(disk->snap= shot)); =20 + if (disk->snapshotDeleteInProgress) + virBufferAddLit(&childBuf, "\n"); + if (disk->src->path || disk->src->format !=3D 0) { g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) driverChildBuf =3D VIR_BUFFER_INIT_CHILD(&childB= uf); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index fec4a5a912..96c77ef42b 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -52,6 +52,7 @@ typedef struct _virDomainSnapshotDiskDef virDomainSnapsho= tDiskDef; struct _virDomainSnapshotDiskDef { char *name; /* name matching the snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO) continue; =20 + if (snapDisk->snapshotDeleteInProgress) { + virReportError(VIR_ERR_OPERATION_INVALID, + _("snapshot disk '%s' was target of not complet= ed snapshot delete"), + snapDisk->name); + return NULL; + } + data =3D g_new0(qemuSnapshotDeleteExternalData, 1); data->snapDisk =3D snapDisk; =20 @@ -2628,6 +2635,53 @@ qemuSnapshotDeleteBlockJobFinishing(virDomainObj *vm, } =20 =20 +/** + * qemuSnapshotSetInvalid: + * @vm: vm object + * @snap: snapshot object that contains parent disk + * @disk: disk from the snapshot we are deleting + * @invalid: boolean to set/unset invalid state + * + * @snap should point to a ancestor snapshot from the snapshot tree that + * affected the @disk which doesn't have to be the direct parent. + * + * When setting snapshot with parent disk as invalid due to snapshot being + * deleted we should not mark the whole snapshot as invalid but only the + * affected disks because the snapshot can contain other disks that we are + * not modifying at the moment. + * + * Return 0 on success, -1 on error. + * */ +static int +qemuSnapshotSetInvalid(virDomainObj *vm, + virDomainMomentObj *snap, + virDomainSnapshotDiskDef *disk, + bool invalid) +{ + ssize_t i; + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virDomainSnapshotDef *snapdef =3D NULL; + + if (!snap) + return 0; + + snapdef =3D virDomainSnapshotObjGetDef(snap); + if (!snapdef) + return 0; + + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDef *snapDisk =3D &(snapdef->disks[i]); + + if (STREQ(snapDisk->name, disk->name)) + snapDisk->snapshotDeleteInProgress =3D invalid; + } + + return qemuDomainSnapshotWriteMetadata(vm, snap, driver->xmlopt, cfg->= snapshotDir); +} + + static int qemuSnapshotDiscardExternal(virDomainObj *vm, GSList *externalData) @@ -2644,6 +2698,9 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, autofinalize =3D VIR_TRISTATE_BOOL_YES; } =20 + if (qemuSnapshotSetInvalid(vm, data->parentSnap, data->snapDisk, t= rue) < 0) + goto error; + data->job =3D qemuBlockCommit(vm, data->domDisk, data->parentDiskSrc, @@ -2694,6 +2751,9 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, } =20 qemuBlockJobSyncEnd(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT); + + if (qemuSnapshotSetInvalid(vm, data->parentSnap, data->snapDisk, f= alse) < 0) + goto error; } =20 return 0; --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027586; cv=none; d=zohomail.com; s=zohoarc; b=AyaxgZW8NxZbCIzkf9/AeTvCg37fZ433J0SDzdpNVSdfE9amWCnqYhstNsUXKRjv8vnxmkWFfPqKDGfRpEoovoqeW4LafIo+BOj6l6xSkfO+km3Wy6eVYBC3Q2fSMvbOX5PnVae6UGl4QQHM6+ttB2ho2uWY152bwKzThfHqskQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027586; 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; bh=bOQrHZORnKmH6Od4hrS5B4qXoPWOQiVUKUNNUbYzUBQ=; b=YiGx3Ea4qGCAFwn7/mmP+DbAxZh151Sh+hDKw+h+oUCRlN+wTod1vt+uhmbm/pjgOUPwazjtIUi47Gb7vmV0WgyvprSyKKCdSdiKPjoVphXl7mdzn+DwmNAw9ELRb9YLWB0Fv4lUmGIgUuxedGtQxJOeyjszHuqIvFtbNgwEhJU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167302758671288.63133120470388; Fri, 6 Jan 2023 09:53:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-tZspjXDSOoi9yLV6LkSbYQ-1; Fri, 06 Jan 2023 12:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0E803810BCD; Fri, 6 Jan 2023 17:52:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E306B1121315; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA8A219459D3; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 284E919459DC for ; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1B74B40C2004; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD96140C2064 for ; Fri, 6 Jan 2023 17:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027585; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bOQrHZORnKmH6Od4hrS5B4qXoPWOQiVUKUNNUbYzUBQ=; b=SHx0OjLXPRRwjluJTyL9okiWubvHYb+4b6L9Go8jQvQy7KnLd4fstRu8a+oOYCCeio7hzD jma46reFQzZq/EK78jHVhP5ZMHhZa142wm6rmRQFy1NnNaeog0VEoQzzoHcIOhTdH+g5g1 UbT74C7MuH9d41i3EAXkToEDeQlDTas= X-MC-Unique: tZspjXDSOoi9yLV6LkSbYQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 28/32] qemu_domain: store snapshotDelete in qemuDomainJobPrivate Date: Fri, 6 Jan 2023 18:52:03 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027587276100003 Content-Type: text/plain; charset="utf-8"; x-default="true" When daemon is restarted and libvirt tries to recover domain jobs we need to know if the snapshot job was a snapshot delete in order to safely abort running QEMU block jobs. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 23 +++++++++++++++++++++++ src/qemu/qemu_domain.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 73dc13e178..7be431dd19 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -197,6 +197,15 @@ qemuDomainObjPrivateXMLFormatMigrateTempBitmap(virBuff= er *buf, } =20 =20 +static void +qemuDomainFormatJobPrivateSnapshot(virBuffer *buf, + qemuDomainJobPrivate *priv) +{ + if (priv->snapshotDelete) + virBufferAddLit(buf, "\n"); +} + + static int qemuDomainFormatJobPrivate(virBuffer *buf, virDomainJobObj *job, @@ -214,6 +223,9 @@ qemuDomainFormatJobPrivate(virBuffer *buf, if (priv->migParams) qemuMigrationParamsFormat(buf, priv->migParams); =20 + if (job->asyncJob =3D=3D VIR_ASYNC_JOB_SNAPSHOT) + qemuDomainFormatJobPrivateSnapshot(buf, priv); + return 0; } =20 @@ -340,6 +352,15 @@ qemuDomainObjPrivateXMLParseMigrateTempBitmap(qemuDoma= inJobPrivate *jobPriv, } =20 =20 +static void +qemuDomainParseJobPrivateSnapshot(xmlXPathContextPtr ctxt, + qemuDomainJobPrivate *priv) +{ + if (virXPathNode("./snapshotDelete", ctxt)) + priv->snapshotDelete =3D true; +} + + static int qemuDomainParseJobPrivate(xmlXPathContextPtr ctxt, virDomainJobObj *job, @@ -356,6 +377,8 @@ qemuDomainParseJobPrivate(xmlXPathContextPtr ctxt, if (qemuMigrationParamsParse(ctxt, &priv->migParams) < 0) return -1; =20 + qemuDomainParseJobPrivateSnapshot(ctxt, priv); + return 0; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index e34d52c033..4b0593d5db 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -550,6 +550,8 @@ struct _qemuDomainJobPrivate { * should wait for it to finish */ bool spiceMigrated; /* spice migration completed */ bool dumpCompleted; /* dump completed */ + bool snapshotDelete; /* indicate that snapshot job is + * deleting snapshot */ qemuMigrationParams *migParams; GSList *migTempBitmaps; /* temporary block dirty bitmaps - qemuDomain= JobPrivateMigrateTempBitmap */ }; --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1673027604; cv=none; d=zohomail.com; s=zohoarc; b=fY4+xTtOIVUpNsXhehMsEYGizZOH7OJV2iIgAXnjWXVz+CJYDV3KdNiLlHAZQMUbU6eUr30aSzRkYLti4jq8TCrkwqMBYrRk2drKlsq9WoK2jXSXi9ZLyfvuNXDLNOA7qNy6iYitwxG57uUvB920wLYbooyrw/TjPiteyNawkXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027604; 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; bh=o1uuVs/QHrAyN/Aty8F/77l37falEr5kzayYhAEwfMo=; b=h7x6VnffDtki6mZFxZL4a39P8A3Y0niFi+RXk0nULbNSc2MXxoGTniYdyipECpdBXQ/lvGquoii+fd53FqpyUk6na1mFWePSKXrKxKaIP3RwGXZelAdh4jD1xiIIjPAtUhpRx5Sa7v33KWPD/nP0GENNIvtld5dTaPo9VNQK9cU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1673027604301229.1017465958081; Fri, 6 Jan 2023 09:53:24 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-573--yb7N3FUOYCy6KcudhpisA-1; Fri, 06 Jan 2023 12:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DB253C13A0F; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A5551121319; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CFED619459DA; Fri, 6 Jan 2023 17:52:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D43DB19459C3 for ; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BB4A440C2064; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 582F240C2004 for ; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027603; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=o1uuVs/QHrAyN/Aty8F/77l37falEr5kzayYhAEwfMo=; b=YzAVVLGQCwYxVdCm/OXt5ihE1jil5J+BcWL+fJwUwd6Kv3X12SF3oc+A2hUtqj3/yYfXNw PfkCCAjGd0Hdmh2U80bw57vZw/if6rGRc4TdRZUU2L4Zc3LLTwQ1Ck2Zi+WF8qg+PHaq3G KDaeQD99JCho2itWNaE9N3ppXKC/NFc= X-MC-Unique: -yb7N3FUOYCy6KcudhpisA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 29/32] qemu_process: abort snapshot delete when daemon starts Date: Fri, 6 Jan 2023 18:52:04 +0100 Message-Id: <792c1aadb2f72ec2191a44a0a47b0cdb78b8ea6e.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027605369100001 Content-Type: text/plain; charset="utf-8"; x-default="true" If the daemon crashes or is restarted while the snapshot delete is in progress we have to handle it gracefully to not leave any block jobs active. For now we will simply abort the snapshot delete operation so user can start it again. We need to refuse deleting external snapshots if there is already another active job as we would have to figure out which jobs we can abort. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_process.c | 37 +++++++++++++++++++++++++++++++++++++ src/qemu/qemu_snapshot.c | 15 +++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 49ae7b688b..cc65e6befa 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3692,6 +3692,42 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, } =20 =20 +static void +qemuProcessAbortSnapshotDelete(virDomainObj *vm, + virDomainJobObj *job) +{ + size_t i; + qemuDomainObjPrivate *priv =3D vm->privateData; + qemuDomainJobPrivate *jobPriv =3D job->privateData; + + if (!jobPriv->snapshotDelete) + return; + + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDef *disk =3D vm->def->disks[i]; + g_autoptr(qemuBlockJobData) diskJob =3D qemuBlockJobDiskGetJob(dis= k); + + if (!diskJob) + continue; + + if (diskJob->type !=3D QEMU_BLOCKJOB_TYPE_COMMIT && + diskJob->type !=3D QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT) { + continue; + } + + qemuBlockJobSyncBegin(diskJob); + + qemuDomainObjEnterMonitor(vm); + ignore_value(qemuMonitorBlockJobCancel(priv->mon, diskJob->name, f= alse)); + qemuDomainObjExitMonitor(vm); + + diskJob->state =3D QEMU_BLOCKJOB_STATE_ABORTING; + + qemuBlockJobSyncEnd(vm, diskJob, VIR_ASYNC_JOB_NONE); + } +} + + static int qemuProcessRecoverJob(virQEMUDriver *driver, virDomainObj *vm, @@ -3741,6 +3777,7 @@ qemuProcessRecoverJob(virQEMUDriver *driver, vm->def->name); } } + qemuProcessAbortSnapshotDelete(vm, job); break; =20 case VIR_ASYNC_JOB_START: diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 189fe98299..348d3260c8 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3095,6 +3095,13 @@ qemuSnapshotDeleteValidate(virDomainObj *vm, } } =20 + if (virDomainSnapshotIsExternal(snap) && + qemuDomainHasBlockjob(vm, false)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cannot delete external snapshots when there is a= nother active block job")); + return -1; + } + if (virDomainSnapshotIsExternal(snap) && !(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -3158,6 +3165,14 @@ qemuSnapshotDelete(virDomainObj *vm, * running to get everything we need. */ delData =3D g_steal_pointer(&externalData); externalData =3D qemuSnapshotDeleteExternalPrepare(vm, sna= p); + } else { + qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; + + /* If the VM is running we need to indicate that the async= snapshot + * job is snapshot delete job. */ + jobPriv->snapshotDelete =3D true; + + qemuDomainSaveStatus(vm); } =20 if (!externalData) --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027717; cv=none; d=zohomail.com; s=zohoarc; b=lLtHPhycLubGQCglS9jMmnZ2sgXEw46rEg5zCdMKNY+eO5vZHRoiSxAxcCeCXRMVYPTmQTEeCgrYZVN2rjzAPwTkwodkPsjNFhU464k4Mokar36gX3egkl+t/cWL96b/eU4akyid8hmtUi5eAKpP6LZF1D+Imrt7CMIKpMMR8i8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027717; 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; bh=xagrMioRnF+yRNoHU8DmwNI0w8Rbmg22n+LjiU7Ch08=; b=WpA6iLuAmfdgCZ4jQxnXu8dJEOkDm9JrPsWxo8rD4GMuV8rHrPQPeYCDFMVtCs2/ami9voElspdwbEtuX9kYzHZVnSfNp/XVsiJnBblLM7CCXXxNZ8el2jLvUQE2KJLobP+lw39q3DdfM8qpOZ/ToV3kpqAkT0oHdndFyT25YVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027717211713.1362769740435; Fri, 6 Jan 2023 09:55:17 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-388-gmilGkZbMNO3N9JiRKGGGw-1; Fri, 06 Jan 2023 12:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 444C93815F62; Fri, 6 Jan 2023 17:52:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EB14C16021; Fri, 6 Jan 2023 17:52:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2438A19452D2; Fri, 6 Jan 2023 17:52:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7001E19459CB for ; Fri, 6 Jan 2023 17:52:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 64D7E40C2064; Fri, 6 Jan 2023 17:52:34 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0393640C2004 for ; Fri, 6 Jan 2023 17:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027716; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xagrMioRnF+yRNoHU8DmwNI0w8Rbmg22n+LjiU7Ch08=; b=We4/6GBMElTNJ3YhbxTSwXq0oNEKWCws9YJCh599E4WGU4GH8dgKq1djIZ41pgxYl5/Xp/ OLt5N1JZGTLGQItmZk4tDbtsbYV1vVswH3oXoV1v0rCnaxxZpqAAanS7lDIwmfqCaIqhVe bXq5vhuD4CTaV+m05+dcnwyeQd5BGTU= X-MC-Unique: gmilGkZbMNO3N9JiRKGGGw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 30/32] qemu_snapshot: enable deletion of external snapshots Date: Fri, 6 Jan 2023 18:52:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027718114100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 348d3260c8..32f7011cbe 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3103,9 +3103,9 @@ qemuSnapshotDeleteValidate(virDomainObj *vm, } =20 if (virDomainSnapshotIsExternal(snap) && - !(flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { + (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("deletion of external disk snapshots not supporte= d")); + _("deletion of external disk snapshots with childre= n not supported")); return -1; } =20 --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027572; cv=none; d=zohomail.com; s=zohoarc; b=kKEhdJSlaGZKgUmVXv6ETXPwFl6yuFLhK6MmSFXBflEKknsqI91caOTQILwpN/Mvo87wZFxtcB0aV2S9IrWJyYfFc4QhdJ2lkhQX+q8qzhOCmrCarg1Pd8HZDE7Y8kRjjtmwRlE3zQDCe+yk2eHSt4dwb7UUz1Vi0Gv/jZMRTL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027572; 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; bh=5hFuVp1qgSjEEaPegch2x1wQZrRzbG61jGsILFE7gGk=; b=Hq5BKaMJJ2+KnSIiuZwO6ISPQilUtzNFUrn/J//HR0jJjcSC0fzoo0+jk8TYROAB6toJbwfHpLSX+qYT/LQ7bfloOPfLO9nbGqLCGmNuBvvxxvxTM29zU2NELGGmA8p5xPQeS3dX/+hYLqprFOih5Jzn5o+f+TA9Y+iRiaW8Lk4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 167302757280793.25163874720306; Fri, 6 Jan 2023 09:52:52 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-251--0BgS9inNWurN41zIAfvxQ-1; Fri, 06 Jan 2023 12:52:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93C8C80234E; Fri, 6 Jan 2023 17:52:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80A8C2026D68; Fri, 6 Jan 2023 17:52:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 70CEF19459DF; Fri, 6 Jan 2023 17:52:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1D37519459C1 for ; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0F04740C2064; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1C0B40C2004 for ; Fri, 6 Jan 2023 17:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027570; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5hFuVp1qgSjEEaPegch2x1wQZrRzbG61jGsILFE7gGk=; b=ifTaJ1sF8+5Y9jAhe6uIRDV0qr/vsR4VkdMV006a/g74FESXdUgQJJPEck+Efpl/aBB0zm 25njIhClmecHQZD8jMyiUXaKfn+90G89MKFtXlLpnEW11qG7SU5A9BYJsQ2+5iopQKFAnH bN+6zrMs97RxASB/Y5N2/iI12fkR+PU= X-MC-Unique: -0BgS9inNWurN41zIAfvxQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 31/32] api: document support for external snapshot deletion Date: Fri, 6 Jan 2023 18:52:06 +0100 Message-Id: <169b68c4ac0ccc70a5bbf339a13c45e338e99600.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027573192100011 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that deletion of external snapshot is implemented document the current virDomainSnapshotDelete supported state. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt-domain-snapshot.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libvirt-domain-snapshot.c b/src/libvirt-domain-snapshot.c index 2917b8bd90..ab6a029915 100644 --- a/src/libvirt-domain-snapshot.c +++ b/src/libvirt-domain-snapshot.c @@ -1075,6 +1075,13 @@ virDomainRevertToSnapshot(virDomainSnapshotPtr snaps= hot, * libvirt metadata to track snapshots, then this flag is silently * ignored. * + * Since libvirt 9.0.0 deletion of external snapshots is supported + * for QEMU driver. Using @flags VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN + * and VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY is not supported with + * external snapshots. In case that daemon process is terminated + * while the snapshot delete is in process the operation will be + * aborted when the daemon starts again. + * * Returns 0 if the selected snapshot(s) were successfully deleted, * -1 on error. * --=20 2.39.0 From nobody Fri May 17 07:08:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1673027569; cv=none; d=zohomail.com; s=zohoarc; b=SCQl3WKIyKyiUcTml6/QGS1bzpmps/SC/U1lLNCTXdCu68NHFlhpJQyT6sCW+ze5xM11KESgLNmlFGKqhBh2vpyEwsR2mCmqRv9ksYfZ6i1Gxj28l/3a/coey+B/Uby4g4RQ2rtMT33M/kQn0b/1x3bhGwTNwzhBkTkeiEj8lRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673027569; 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; bh=AVJAYjchmRIAZMbw84HPs+J92Y7aRcCyqAT6ba73SSY=; b=YqyK4lfEts+7Z8RFHWIyITHgO1xTu1aW+HZ2fBJ14fmWfeTiGzPjDmNTL847lsWF0INkRMEzzyPUzqgZrbd4kxr57/dFbcVp/oxt/yiPw7morDaHay8FnYYIICzulwu4efilG3enw+kr4Yqb2RwbrkOzOcB8go+r+s0VN/OVLEE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673027569028280.0224394383199; Fri, 6 Jan 2023 09:52:49 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-407-omEj6aYONeKbR3OAHAbSEQ-1; Fri, 06 Jan 2023 12:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5055785D067; Fri, 6 Jan 2023 17:52:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CA47492B00; Fri, 6 Jan 2023 17:52:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2E3EA19459C8; Fri, 6 Jan 2023 17:52:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CBF2219459DF for ; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B129140C2009; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) Received: from antique-work.redhat.com (ovpn-193-172.brq.redhat.com [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E03E40C200A for ; Fri, 6 Jan 2023 17:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673027568; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AVJAYjchmRIAZMbw84HPs+J92Y7aRcCyqAT6ba73SSY=; b=Ov+APX695ZiI4EKn/9wymItnvXC2DWh6yHdNxBvWWaIGENzHcT7xd0yJUnJTJoDEyf3HFz 74ule28X4dsaRg8n1+Lo5uaDO+vd8D/OLCNeTYFRcxW8u58jBrYU5kKK+YBD07J+baFPFo O18QrYAYJP6+aBwnvOIqvuO5YbjKfoE= X-MC-Unique: omEj6aYONeKbR3OAHAbSEQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 32/32] NEWS: document support for external snapshot deletion Date: Fri, 6 Jan 2023 18:52:07 +0100 Message-Id: <849964b29e2c123bd76141581e7bc7f3197a5495.1673027206.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673027571182100009 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- NEWS.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 39f508a6ce..fecca64344 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -17,6 +17,12 @@ v9.0.0 (unreleased) =20 * **New features** =20 + * QEMU: implement external snapshot deletion + + External snapshot deletion is now possible using the existing API + ``virDomainSnapshotDelete()``. Flags that allow deleting children + or children only are not supported. + * **Improvements** =20 * qemu: Prefer PNG for domain screenshots --=20 2.39.0