From nobody Fri May 17 09:01:44 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=1670506307; cv=none; d=zohomail.com; s=zohoarc; b=PVpDtGDAf63ws2y61yXsC132C2L5WAhH/qeer/pTjbpn2UyGIatW4Y5FA2V7N3sN5Bz1s2fK4CgBnCt141C5kh7XTzXaDTdaTUNDe2UxuVXzVi4e6zYHZ+ISKWtauAdkJG/gwLHQSm9oV13kHImkxcsknswh8AO4k8rYaT9tEz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506307; 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=Zy67V3OgXfXwCNTKtyz4wDbJ/Ry8KH3Hoq4vm/voxRk=; b=EreB6WPkU+/a8jXLuLgQvY9uQK6IAn9Fbk9LA6itLKAO6kpymkIr5ecmTNTM5Xb4m9wd7U5399L2atPvBgVGo3zCiuzqd+6ChR+1tZOrUHwDdVKEwOoxNoSEIIptmNn5YVfriGzZD0HrSO3B+sGV83/ZPo3nLrN3bvRm4YPXM4g= 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 167050630773556.95631927999352; Thu, 8 Dec 2022 05:31:47 -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-283-ruORDh2PO3aHQFRJknm3tw-1; Thu, 08 Dec 2022 08:31:36 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0323E85CE16; Thu, 8 Dec 2022 13:31:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8D8B477F62; Thu, 8 Dec 2022 13:31: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 7A4611947042; Thu, 8 Dec 2022 13:31:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D1B861946A4B for ; Thu, 8 Dec 2022 13:31:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D1CD240C6EC4; Thu, 8 Dec 2022 13:31:15 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BCA440C6EC2 for ; Thu, 8 Dec 2022 13:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506306; 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=Zy67V3OgXfXwCNTKtyz4wDbJ/Ry8KH3Hoq4vm/voxRk=; b=HN83htzi7Juox2lUfxwrDZDDy01z3L3wphLtEm7s5rJnQgSLRimv3wjc+RX29X8b/ZgCVY CVdHTlqRQvKqIvy2Pu1oR0Lj4Rw1HWdDn8aXG5a1GzHeM+BPBdEbYG/xsLOGkodvfLPl9Z p8wO1AlDQOrWBxmI691flFnu04wt9Bg= X-MC-Unique: ruORDh2PO3aHQFRJknm3tw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 01/30] libvirt: introduce VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE Date: Thu, 8 Dec 2022 14:30:37 +0100 Message-Id: <3214808f966888d0115ad2b2ab148643df010478.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.9 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: 1670506308300100002 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.38.1 From nobody Fri May 17 09:01:44 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=1670506294; cv=none; d=zohomail.com; s=zohoarc; b=B9yatb/vpmEjl6zf0jqVRzD0wKXViJukyIYM3JVeYCpMk+JDO4PojbOJqtzgNbrTyZ7xI14oevvBNEOMsAjpLL593nQmUdxK7Hr88zqxUl7dYy+iQGPVvFr1u0fKj/qPLzf+oRXa5QMkpr2c2hJuIRZ2NvwGfSGylDur0U+G/AE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506294; 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=cHYmSjWt46kQqExoeH7ZGv2A3ZbkAfe4sE6lT3uPFDM=; b=J7VZlKo9eYYNVyIEggvT5S0JoWc2KWRO1iE1i015ouFRolQqvT6SnPEhTvy/yZyqU1xmc5pDqv8FadDGOEpktZUPj65Xa5SlM4rLS58zwtet+oJxP6BcyExZ7OqpNbxYSSLCPEoTCR0OhVEfCyZTugAmzj/LD1aVhnXVctsHw6A= 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 1670506294424106.08362255571399; Thu, 8 Dec 2022 05:31:34 -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-662-Ap9xhPX6MzmvVUiaDbSaAA-1; Thu, 08 Dec 2022 08:31:29 -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 C112C858F13; Thu, 8 Dec 2022 13:31:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40D0717582; Thu, 8 Dec 2022 13:31:27 +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 07ACE1946A72; Thu, 8 Dec 2022 13:31:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CBC9C1946A41 for ; Thu, 8 Dec 2022 13:31:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A5C6440C6EC5; Thu, 8 Dec 2022 13:31:16 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D3E340C6EC2 for ; Thu, 8 Dec 2022 13:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506293; 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=cHYmSjWt46kQqExoeH7ZGv2A3ZbkAfe4sE6lT3uPFDM=; b=ie0JoD5L96hjDQXS0letbUNM9lFJVrV/WYK62ucxO36/ELUH/9jvkamGjoDr7GW9qacNeF JGPYVenmbxaQ3D+jpskwbC9wW74BMzRjFeFdJUI7B10HspF6JSHNrgYA3thR79A4M0ek6b 306XxxjZiWIuJ/N5vB1Obrtzu27J/+c= X-MC-Unique: Ap9xhPX6MzmvVUiaDbSaAA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 02/30] qemu_block: extract block commit code to separate function Date: Thu, 8 Dec 2022 14:30:38 +0100 Message-Id: <4c5c2f73fcc26e9db5a00d81e1a4d88fcd0d4c9c.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506296282100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 179 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 9 +++ src/qemu/qemu_driver.c | 162 +------------------------------------ 3 files changed, 189 insertions(+), 161 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8a6f601b29..4cca7555f3 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3196,3 +3196,182 @@ 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 rc =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 error; + + 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 error; + } + + if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, + baseSource, + flags & VIR_DOMAIN_BLOCK_COMMIT_= DELETE, + flags))) + goto error; + + disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; + + if (!backingPath && top_parent && + !(backingPath =3D qemuBlockGetBackingStoreString(baseSource, false= ))) + goto error; + + qemuDomainObjEnterMonitor(vm); + + rc =3D qemuMonitorBlockCommit(priv->mon, + qemuDomainDiskGetTopNodename(disk), + job->name, + topSource->nodeformat, + baseSource->nodeformat, + backingPath, bandwidth); + + qemuDomainObjExitMonitor(vm); + + if (rc < 0) + goto error; + + if (mirror) { + disk->mirror =3D g_steal_pointer(&mirror); + disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT; + } + qemuBlockJobStarted(job, vm); + + return 0; + + error: + if (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 -1; +} 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 d509582719..2f05da3d8c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15114,19 +15114,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 | @@ -15136,7 +15129,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; @@ -15144,176 +15136,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.38.1 From nobody Fri May 17 09:01:44 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=1670506387; cv=none; d=zohomail.com; s=zohoarc; b=noS5f2mqZslgzLadzWWG5CUYL1Rv5d2viAi/5rpyk15DIXbeVZkYmCgGu7fqpmyTDfw0h4ggSqIw4VG7TluzU1MDJcc3dq8bEeQY2Q6aD5EN7FsmBBKQ0WdzC7BWg11PAgICi3eGgOspyEJC/9aIMCZ1UyhUOqpxORxipk6AT+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506387; 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=3wlh+K7n+ga4P5a7pJ5ArMofqS2kVze+60rhfyhh2fE=; b=CIiq2HlhJ2hDjKrY6KWNXkzVVsqvj9TrUb7PZPc7x7d8bBOiHsPjzLXXyILgoDAV+rZbRxVn4G6BaEiMQ3W4zV3WrHivG4YTcUaCU4CsfSTYwvE1tpQ5pxhya4k0rkf4rpoTQtWv2ik/FRImSgxZ53Aiap3PBFL6fRE9z9/e9Mk= 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 1670506387336627.3586140532259; Thu, 8 Dec 2022 05:33: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-308-rmA3Wa0mNT-scuLWdLIz0g-1; Thu, 08 Dec 2022 08:31:38 -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 E75F338123B6; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3B9440C2064; Thu, 8 Dec 2022 13:31: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 645861946A75; Thu, 8 Dec 2022 13:31:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CF70F1946A44 for ; Thu, 8 Dec 2022 13:31:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 592B140C6EC6; Thu, 8 Dec 2022 13:31:17 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id E69B540C6EC2 for ; Thu, 8 Dec 2022 13:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506386; 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=3wlh+K7n+ga4P5a7pJ5ArMofqS2kVze+60rhfyhh2fE=; b=d5aLjsniTsTkbKH5j+MlBE04aIS7H+U0tCmYVwN3TPhXs8vXJeQw0YjKSGbuOB6eRfltrq gBBk0o5WRBicNfvqrxJ+Bq/7A6KaNlJWoJgx7ntoO1Tk/U4WmoqFdXhxDddvbmxSZVWxH9 oYB95V1p4+tkdFY4jfvJ+0UVrhITbqo= X-MC-Unique: rmA3Wa0mNT-scuLWdLIz0g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 03/30] qemu_block: move qemuDomainBlockPivot out of qemu_driver Date: Thu, 8 Dec 2022 14:30:39 +0100 Message-Id: <909764c555691d9c22e5ab6ecf4649ccd5f1436f.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506388711100005 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 4cca7555f3..721145fa42 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3375,3 +3375,124 @@ qemuBlockCommit(virDomainObj *vm, =20 return -1; } + + +/* 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 2f05da3d8c..d8db7188f7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14001,127 +14001,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 @@ -14284,7 +14163,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.38.1 From nobody Fri May 17 09:01:44 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=1670506395; cv=none; d=zohomail.com; s=zohoarc; b=kN81MJwxICTP1wCqDxq/8pevcb8Yth2DrmObwuyTqxSyT01/g+Nr8rcaUvldVLkAXBlL7G4j4XPuu0qaiFmaSAQdBIam95+mVDNgTeWiumaYLKqfxebnWdTaVgzqvYLe87Jqs3xoFFa8Uh7HeqjqWJKlTzerU0iumkuyejxtADE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506395; 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=bHF1GNJPjPYN4vWcRCdBKyLF4Jr10O8wXBzofYQU3EA=; b=UBuvHZTDFayrkCoGgAgVVXJfYtEGzSKKeirW1gVXV83gs7pH3Fywp5k4qI/ll8FbnIscR99DHQcA/KVgcCvV5hrw91QfB9tf/Y/46DySjM18aDt7IJ9QbsI8/jKO7fhfpFBmLBbw4X60+ROrOrN+an89A32KJcGXqLC4xxWgc5I= 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 1670506395923482.389574718791; Thu, 8 Dec 2022 05:33:15 -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-126-b40wnV_5Pd6setiBPbkeRA-1; Thu, 08 Dec 2022 08:31:48 -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 1AA50857021; Thu, 8 Dec 2022 13:31:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0192517582; Thu, 8 Dec 2022 13:31: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 C4F311946A41; Thu, 8 Dec 2022 13:31:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D47D11946A72 for ; Thu, 8 Dec 2022 13:31:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0A43F40C6EE9; Thu, 8 Dec 2022 13:31:18 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9820340C6EC2 for ; Thu, 8 Dec 2022 13:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506394; 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=bHF1GNJPjPYN4vWcRCdBKyLF4Jr10O8wXBzofYQU3EA=; b=P5GimsuS3Af3e3FuhPJxCE9Cw+ADC+5/vHy8E46xSRF8R5lPM3blH840DuEWNiDEkU0VgS sx4prUzaeiTjml22Bx/qTkll/Pl7pTwJfDFFonvfZRLd3HoYQraddrgprAzzdswZWc9sne P8XFub2j1RYAsXhvHDbvkmV+12PPtng= X-MC-Unique: b40wnV_5Pd6setiBPbkeRA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 04/30] qemu_block: add async domain job support to qemuBlockCommit Date: Thu, 8 Dec 2022 14:30:40 +0100 Message-Id: <6b071193cdcc16f1e7b39ed7afd43a5a7d1e834a.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506396716100001 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 | 7 ++++++- src/qemu/qemu_block.h | 1 + src/qemu/qemu_driver.c | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 721145fa42..999e43c630 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3205,6 +3205,7 @@ qemuBlockCommit(virDomainObj *vm, virStorageSource *topSource, virStorageSource *top_parent, unsigned long bandwidth, + virDomainAsyncJob asyncJob, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -3336,7 +3337,11 @@ qemuBlockCommit(virDomainObj *vm, !(backingPath =3D qemuBlockGetBackingStoreString(baseSource, false= ))) goto error; =20 - qemuDomainObjEnterMonitor(vm); + if (asyncJob !=3D VIR_ASYNC_JOB_NONE) + qemuBlockJobSyncBegin(job); + + if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) + goto error; =20 rc =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 d8db7188f7..5ee6e2698d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15030,7 +15030,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.38.1 From nobody Fri May 17 09:01:44 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=1670506294; cv=none; d=zohomail.com; s=zohoarc; b=YAvgOYacr4OadnF0IdpUaThQKIUvz84M42JrjCCRs593x8wo6MfcXFXcnll1SVZ0AEss1jXfe21k/rPmoC7tW/xn8RdVM+v4hi7A42cXZp3jNLj34d06DfJHj1rnyLGevzYX97EKhAE87TRqrk6LYB8u4NW+0TGcJ42PUMITY5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506294; 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=dS3JCy73EEbN6hZSBJ/W63AdsTfuE7+9P9a38+URjQ0=; b=JxQM48Jhb1jFmSWR90sIFXjZHiat67QbA0U09DrbJ1zgB07DHEwtqD8T0Qz5CT7/Jx3JKoa2CpKsxe8uvxE0aIoGmpLHfcY6q3W0ir58jxFrBwm+k38hu+MQ6Wbz3JKT3xtfCsMl10S73nuZ9lorT5VDCcwmV0q2zcP1PELohJ4= 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 167050629399385.65609362036685; Thu, 8 Dec 2022 05:31:33 -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-518-6yNDYvR3Mhy3jF21MUKiHw-1; Thu, 08 Dec 2022 08:31:29 -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 BEFE93811F37; Thu, 8 Dec 2022 13:31:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4194F40C2065; Thu, 8 Dec 2022 13:31:27 +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 04A641946A68; Thu, 8 Dec 2022 13:31:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 191C51946A7C for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B07B540C6E13; Thu, 8 Dec 2022 13:31:18 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B33740C6EC2 for ; Thu, 8 Dec 2022 13:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506293; 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=dS3JCy73EEbN6hZSBJ/W63AdsTfuE7+9P9a38+URjQ0=; b=Xd3/ER5uNVs69/Q/jpFwpK+bVwiAOJK6NfO8TBF7hR3Geb3WOpx4WHIYJ2vtVwAO91qZYR 64wNDtQ/OhC3Jjb8L8QO/91nL8svFrfFeY4dg2fMMmffjEfKV91f5kHbVibe653yXHnY7v N8F5KvHj8sztwUwG6pfhV4MXFtWCpgQ= X-MC-Unique: 6yNDYvR3Mhy3jF21MUKiHw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 05/30] qemu_block: add async domain job support to qemuBlockPivot Date: Thu, 8 Dec 2022 14:30:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506294261100001 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 999e43c630..8a633d4423 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3388,6 +3388,7 @@ qemuBlockCommit(virDomainObj *vm, int qemuBlockPivot(virDomainObj *vm, qemuBlockJobData *job, + virDomainAsyncJob asyncJob, virDomainDiskDef *disk) { g_autoptr(qemuBlockStorageSourceChainData) chainattachdata =3D NULL; @@ -3473,7 +3474,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 5ee6e2698d..acd67b1f5a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14163,7 +14163,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.38.1 From nobody Fri May 17 09:01:44 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=1670506407; cv=none; d=zohomail.com; s=zohoarc; b=f2eCkiyFrkHEbFnw7Hr4U1fP91/FFXgY4MBql76Vmmyu2Dl7sDTIzwjhGHbBkcW7h9UGsll65Tg++KXGQxnhrbWvvOnY08K3+d7Fjqyqsai90o73vn1JjHg7w2EGxDGI43W+xTCJ4ypsxk/7VVetb86h+msvqmoVUC7+8Wl+hT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506407; 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=uisCLuRGqmZUM+L9jN4K6lAdpFLI/w7I7dpdpoGqol8=; b=T8tCycVd++3bznOCRZt0FNXOSBSJmltSwrNFwAqUZRX1BYUsqlRth1SLMAdnBp5JCxKpkAEeZ4CJJk76y8TOPOpe5KHcJp56ljfrFNoGJuHOBaA+lHOF8vZlAyYPO1zPqzgSYyoFiZ/Z0rmMhNbL7FNLMkbcQzYLsESAKAFBZpQ= 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 1670506407109326.5256936914582; Thu, 8 Dec 2022 05:33:27 -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-669-eGyEXOd_Nu2OIbqknoFxIQ-1; Thu, 08 Dec 2022 08:31:37 -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 D06011C0690A; Thu, 8 Dec 2022 13:31:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAFFC40C2065; Thu, 8 Dec 2022 13:31: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 F14C11947064; Thu, 8 Dec 2022 13:31:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 13E4D1946A44 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6374C40C6E14; Thu, 8 Dec 2022 13:31:19 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0CAF40C6EC2 for ; Thu, 8 Dec 2022 13:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506406; 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=uisCLuRGqmZUM+L9jN4K6lAdpFLI/w7I7dpdpoGqol8=; b=NNfxYzBqBsVATTUBkPtlDUhxu+qRc7lo/W2vtAaW03iVpc1uzfAX/0bEvI7jJvx5i6M6fK KmSiFJel/DrJkYFFjzI9zJy2gPNb20p4Ud6Hl6rrC6jX5fwddbsf8XhrINCRco4GmOqrv8 pizCtEpMGQ4XwlpvHCw8z5/g+f6c6x0= X-MC-Unique: eGyEXOd_Nu2OIbqknoFxIQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 06/30] qemu_monitor: introduce qemuMonitorJobFinalize Date: Thu, 8 Dec 2022 14:30:42 +0100 Message-Id: <9d06be556ced5ea0b0cca307f470f27adc19d416.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506408837100001 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 734364e070..0354832fa5 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 906a919f52..eebac918c1 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 9822097bd7..baf01a7206 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 484cb09830..073a0579b5 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.38.1 From nobody Fri May 17 09:01:44 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=1670506329; cv=none; d=zohomail.com; s=zohoarc; b=h3CeqFaaB5XAG/J6JslGyFk3io10syCiqRf1oWGI52Qhdoujzp5oA+4aQiVemacoiZFsh5yT+Xn02QZvJd/SPiPN9df5Cad+K1x/aolQBcIc+ByJ/gf67FqbHKhwes+VSM8P3WTJzry+ntXg2HMpYBfrkQEwG1FAbCXzUwljhnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506329; 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=gQHAjHKAXjblf/QNFU1zwVr0eFCWGmVllVNO6Hv0/So=; b=NwirPXqtOrs61invdogtzLJ9zyEDt28ts4qRs2lemc7HmIzwFD54XhoU6y+LdIwK5ndIHdAVa+PU5CWJKhtyZSebp+fBtj8mHtrZH43X4YAY82Kj3IyPLMbKFI9gDKvRnS33eS7e8GcNydAjGOwDSmb63XEqPhffiPIuYGgFSBE= 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 167050632905752.06341956119422; Thu, 8 Dec 2022 05:32:09 -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-453-QycyxE7mNbyG1HibqJFvZw-1; Thu, 08 Dec 2022 08:31:50 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7628D100F7FE; Thu, 8 Dec 2022 13:31:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 619C24A9255; Thu, 8 Dec 2022 13:31: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 2D3BA1946A41; Thu, 8 Dec 2022 13:31:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 250E11947041 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 145FD40C6E15; Thu, 8 Dec 2022 13:31:20 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2C2E40C6EC2 for ; Thu, 8 Dec 2022 13:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506327; 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=gQHAjHKAXjblf/QNFU1zwVr0eFCWGmVllVNO6Hv0/So=; b=A9W82vd8q4akozJMHiH9bVmr23GATjptkTXDtPHo9OKlug5/HvoO9pnln9PU5I6BNQvYOJ jXZETF6b7cRennizKZjah7WX0O+aPKYO/PiT9VK4qlpu9zIYRDpXjnYdZeHYbgbUCwnedp Le52W1BID8Bvrptq6CG/MqSLqaCI2uE= X-MC-Unique: QycyxE7mNbyG1HibqJFvZw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 07/30] qemu_monitor_json: allow configuring autofinalize for block commit Date: Thu, 8 Dec 2022 14:30:43 +0100 Message-Id: <6383d5c4d62b64dba71b5bedf11a229a2bdb28be.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.9 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: 1670506330451100001 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 8a633d4423..5600abf6aa 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3348,7 +3348,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 0354832fa5..43525def0c 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 eebac918c1..d09439911f 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 baf01a7206..9aee84084e 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 073a0579b5..a03caf7740 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.38.1 From nobody Fri May 17 09:01:44 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=1670506322; cv=none; d=zohomail.com; s=zohoarc; b=a2ripgex1pSwILimk6vUBC4yIUdi+uGhl9tpYVzsiE7OEW7Ieyl2lShU1tlbEjr6TnxWoZd6QXWZKWA8H6s8YDLjMatmt4bFlj+ZbPdEnZ6gom+mR6sG/SXt6ty+ToazBJcdmTVJxoOgMUZVSin/4m0y4D5QYvsDlm4mcMhHf/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506322; 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=8aRx2qz3A+JIX6KM7wHRUOnwYEaqGFImokjSuAnJL9Y=; b=h3mlOKpcVeL5rdF3kpNSoeSIdG3iLnzAC81bMtnJl19yupEXW3UHWHtBhXmZppCHqpiQO9DZ4/iVjqD4IdypXUx7C1+XWbPKE3ZNY9rBs0lggEUSC34Q3qbTNFupToVBldqS4g4H26E7vTg8s6smWmL/i5l51Lj5mIBvG6gPHG8= 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 1670506322411967.9837629453389; Thu, 8 Dec 2022 05:32:02 -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-146-wMacmSCuMSC_iw3OsmT2-Q-1; Thu, 08 Dec 2022 08:31:56 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD3FF106D18B; Thu, 8 Dec 2022 13:31:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0B3749BB61; Thu, 8 Dec 2022 13:31:46 +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 D265F1946A68; Thu, 8 Dec 2022 13:31:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 194501946A7E for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B98A440C6E17; Thu, 8 Dec 2022 13:31:20 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53E0540C6EC2 for ; Thu, 8 Dec 2022 13:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506321; 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=8aRx2qz3A+JIX6KM7wHRUOnwYEaqGFImokjSuAnJL9Y=; b=fH9tvB/22E3ykXINWwITOHQxjfQHMOGOALenufegor96hPz6KszNr/mcEP5XeMPwfwmC4G 03Bk+SKpRd8qtMChpL/X53/sgNjFo2ggzb1H4yHjXBVN1Y4YRvzkadl2Vc7LxYFu6QrbMh 0HBvZLd8PCX5Ne0COOkawRJnzaZteAg= X-MC-Unique: wMacmSCuMSC_iw3OsmT2-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 08/30] qemu_block: allow configuring autofinalize for block commit Date: Thu, 8 Dec 2022 14:30:44 +0100 Message-Id: <6b9bdb5755134227f5b7a6d960c581a4d2b2ca35.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.9 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: 1670506324389100007 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 | 7 ++++++- src/qemu/qemu_block.h | 1 + src/qemu/qemu_driver.c | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 5600abf6aa..2abddf904f 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3198,6 +3198,10 @@ qemuBlockExportAddNBD(virDomainObj *vm, } =20 =20 +/* The autofinalize argument controls if the qemu block job will be automa= tically + * 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.*/ int qemuBlockCommit(virDomainObj *vm, virDomainDiskDef *disk, @@ -3206,6 +3210,7 @@ qemuBlockCommit(virDomainObj *vm, virStorageSource *top_parent, unsigned long bandwidth, virDomainAsyncJob asyncJob, + virTristateBool autofinalize, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -3349,7 +3354,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 acd67b1f5a..12fca22616 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15031,7 +15031,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.38.1 From nobody Fri May 17 09:01:44 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=1670506400; cv=none; d=zohomail.com; s=zohoarc; b=Lz6VTXy+5EB2HvBBaEB1Ix2Mark3sES/M3jEONOLx1416OfWmH6oMUMJF6E1h/03UMVB51FkUDX0jzP4yvSPXI1EzOkpio1UuU/CUX5tF8eO3bFQhtdq75SBlqtYu2WwjMLpMfCk4WNxMP6lollWoOpl/LMQ7GuYdLVSjDcTO88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506400; 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=2kxqyTAGC3tnlW3GD4VgtSL4ynB+Z7NZ9qbKdGx98zU=; b=dGKU1kueZNn5RDt+5CLWKyElX3C65+vRVIsLGHy59vxp1TzPWLhbVHrUHrfNAeuG0cI4AZFdYbDH3Gv1yvwM97cclg93bONwYJ4PwxwD/R7tH0a5e0mMGHP+CqhGl+CViEvUFz8McpeO2aUAoiL4DtywcGTcgFgZZG9dFTMYiYA= 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 1670506400978359.7845557415925; Thu, 8 Dec 2022 05:33:20 -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-99-P5BhJx0vPcGO4qFm0fFIbQ-1; Thu, 08 Dec 2022 08:31:56 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5D4D3C1106E; Thu, 8 Dec 2022 13:31:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CAF649BB60; Thu, 8 Dec 2022 13:31:41 +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 F15391946A44; Thu, 8 Dec 2022 13:31:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F19A21946A41 for ; Thu, 8 Dec 2022 13:31:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6BA4340C6E16; Thu, 8 Dec 2022 13:31:21 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04F6940C6EC2 for ; Thu, 8 Dec 2022 13:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506399; 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=2kxqyTAGC3tnlW3GD4VgtSL4ynB+Z7NZ9qbKdGx98zU=; b=AL21SFdEv4YjCXVg+HYOwnbxwnOeYPTTU6MWzyYC1MEdNIBL5tr60fYZpYOXq4K2OfPb/H aZTsQiWiFikQ6h4GYiwo9cZ+9n17mycsduYLIo/RTuZ5zWsyHekVZqic3zDN4Wik2sD6hz chW+5EJv1GSrS7vaW8V2EJSvc/olJoA= X-MC-Unique: P5BhJx0vPcGO4qFm0fFIbQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 09/30] qemu_block: introduce qemuBlockFinalize Date: Thu, 8 Dec 2022 14:30:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.9 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: 1670506402730100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 19 +++++++++++++++++++ src/qemu/qemu_block.h | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 2abddf904f..24c82377b0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3509,3 +3509,22 @@ qemuBlockPivot(virDomainObj *vm, =20 return ret; } + + +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.38.1 From nobody Fri May 17 09:01:44 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=1670506319; cv=none; d=zohomail.com; s=zohoarc; b=QFdmwe3Zr7C/ncCdVEBnSsyHuEIlpde8uuXaUpeuUabfB1TiHaf4+FGsJ86Uj7rQ5aqzZ3MgEKQJ15zwBbV7uj00jeAyX6YUMgghQ3YU20AVXRZ9OkFZXx3NY1dm9p6yST/bWLqJQs9t8nEexx/grA2q86SWyRm2j8qX4DB5qAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506319; 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=U+0Cu9zBEsommcg4VInAzdm5n8dIKVPRKgxCJAnZIzM=; b=ZY8HLOIOuaZXcy2KiyeZvfa4gwPFTqj2kP9l5sYwiBxl+NaxXunvZII5wCuI5n6EFe39PySt10vIT5Ss3lPvsC/F0raSRCfcLbBICJIdeR5Ls5/oE6kyFjb4ql/xUtfARyCesJCxwm2HlOtC82NfoeT+HK7/YBTOTyqGvdEI1yo= 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 1670506319746550.3374845626959; Thu, 8 Dec 2022 05:31:59 -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-259-fupVb6nJNnesdiuhYqnufw-1; Thu, 08 Dec 2022 08:31:55 -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 82D3D86C14A; Thu, 8 Dec 2022 13:31:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EB8A17582; Thu, 8 Dec 2022 13:31: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 2A2951946A7E; Thu, 8 Dec 2022 13:31:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2542A1947042 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1C97640C6EC2; Thu, 8 Dec 2022 13:31:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB16D40C6F73 for ; Thu, 8 Dec 2022 13:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506318; 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=U+0Cu9zBEsommcg4VInAzdm5n8dIKVPRKgxCJAnZIzM=; b=YO26qKhqShAeWTMs9oUC2bkSaGImPMXTdf5pfXh+khhobVhVQ9B6mco5+4POZ1/YOcXwuf EskUSCmJ2MvgLe9kSdkQ2Po8sFyNYGUvmdDnGfUFMmGshj9WZ+SHL9HVFlNVdNkP/3S8PM Cm6DnPQnWuSJXIS360F3VgTrbVbY8gw= X-MC-Unique: fupVb6nJNnesdiuhYqnufw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 10/30] qemu_block: change qemuBlockCommit to return job pointer Date: Thu, 8 Dec 2022 14:30:46 +0100 Message-Id: <301eae206a9325b45f63624e1df2c8fe279d9054.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506320446100002 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 | 42 +++++++++++++++++++++++------------------- src/qemu/qemu_block.h | 2 +- src/qemu/qemu_driver.c | 5 ++++- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 24c82377b0..0a0d942e71 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3201,8 +3201,12 @@ qemuBlockExportAddNBD(virDomainObj *vm, /* The autofinalize argument controls if the qemu block job will be automa= tically * 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.*/ -int + * to this argument should be VIR_TRISTATE_BOOL_YES. + * + * Returns qemuBlockJobData pointer on success, NULL on error. Caller is r= esponsible + * to call virObjectUnref on the pointer. + */ +qemuBlockJobData * qemuBlockCommit(virDomainObj *vm, virDomainDiskDef *disk, virStorageSource *baseSource, @@ -3222,7 +3226,7 @@ qemuBlockCommit(virDomainObj *vm, 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)) { @@ -3230,26 +3234,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? */ @@ -3257,20 +3261,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) && @@ -3279,33 +3283,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 @@ -3367,7 +3371,7 @@ qemuBlockCommit(virDomainObj *vm, } qemuBlockJobStarted(job, vm); =20 - return 0; + return job; =20 error: if (clean_access) { @@ -3384,7 +3388,7 @@ qemuBlockCommit(virDomainObj *vm, } qemuBlockJobStartupFinalize(vm, job); =20 - return -1; + return NULL; } =20 =20 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 12fca22616..53533062e1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14999,6 +14999,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 | @@ -15030,9 +15031,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.38.1 From nobody Fri May 17 09:01:44 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=1670506307; cv=none; d=zohomail.com; s=zohoarc; b=CM2ie24m/cDzgWuaIUjoW7i5+TdbtJMobWtTeUnIWe8EfuLMXePdtDTyfCwCns+iQOx4uJYfVYuwTc+kU7h3IALGqkl9OY4owd9kPlzgw8f+1D3MbIlfDkBSNytlHY51ZcPskPSMxYE3RWtS3dnUlt7azDin8mlFGDEPXrID8t0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506307; 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=lhBM+8qVXPkHQi87LOQW1jkpOoOoH+oGLzPkC4vAlU4=; b=nX5uJsWPBBQYABkz0T/kQBN5N4TCPDHL7io8RXo+YGJb84S1Yb8giauPVOPWGeZES4wicj2RMb7qkQ8ckO0fFns8A3qTzi4i64bHq68yPQDrnpR1kKSpVScHIt3Ju9UiA+RVErmELHcSgLBWfke5xcK8eLxJE3VS8tNfwOOFHOo= 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 1670506307704750.2614392158658; Thu, 8 Dec 2022 05:31:47 -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-411-K4lR3PIQOJugP3Nm2OPR3g-1; Thu, 08 Dec 2022 08:31:39 -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 BEB3B3806723; Thu, 8 Dec 2022 13:31:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8595C15BA5; Thu, 8 Dec 2022 13:31: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 CD9E3194705D; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 191121946A75 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C1FC140C6F75; Thu, 8 Dec 2022 13:31:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BF5840C6F73 for ; Thu, 8 Dec 2022 13:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506306; 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=lhBM+8qVXPkHQi87LOQW1jkpOoOoH+oGLzPkC4vAlU4=; b=NPLtFR3cKhYusUWrTyaHGFWM7ZWPoogJ6aW3CgxrdMcrmOZ0CS/6z7vrbaranN+ZR81mIE g9hh8jLkoKwWuxIJMfmmIZvtql2VE7EEYLCHJ97uvhEBA1iHDJIvB8LSgzEWneflCrd//u Jg07jJCB+l7FS/cBn5dMjIsL16hp/iY= X-MC-Unique: K4lR3PIQOJugP3Nm2OPR3g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 11/30] qemu_blockjob: process QEMU_MONITOR_JOB_STATUS_PENDING signal Date: Thu, 8 Dec 2022 14:30:47 +0100 Message-Id: <4950b08799e91deabc06238302c0a7ad4ae9e2d1.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506308289100001 Content-Type: text/plain; charset="utf-8"; x-default="true" QEMU emits this signal when autofinalize is disabled and QEMU is waiting for the caller to start the finalization manually. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_backup.c | 1 + src/qemu/qemu_blockjob.c | 20 +++++++++++++++++++- src/qemu/qemu_blockjob.h | 1 + 3 files changed, 21 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..71dddc256c 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,18 @@ 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 when aborting job it c= an + * reset the internally set job state */ + 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 +1699,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.38.1 From nobody Fri May 17 09:01:44 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=1670506331; cv=none; d=zohomail.com; s=zohoarc; b=ai/oylMzX+YOdm5vo8YgH9sIg0XNYLbpUoa0eD0okHOiFzkB+5yunZZMSi/eEoTqlo/jgZevBo11NNJgSc98Y02/JyrAsFPHuZzDngQsKpAh8hkRT3x3VzU4zit3uzFYZHCmwJgFG3cH7TYrvxFVh0h+OEU+De2DtbEt5/OC8jI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506331; 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=JQ/luTt0thkQ0muAGYfRi0hBZIJe+dGXCZLHBjTjP9Q=; b=lo9y/d5OaBxfgpQO/HvEHo9b8C44NyTxeyb00dyydfo+VNoC3wva/4QTNwQum8Y+KMcCTVPh8MRt0m4iBDkBdcCLPwlXISSgttPEtdCh7rHTW9Djp8cMP+ldpTMyxszZ+dEVluOMILS4jYB8ox9wIMb9ziURUnSEy3ZE34m9YPg= 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 1670506331876870.545394528815; Thu, 8 Dec 2022 05:32: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-251-C6X1h3NyOP2aaQuNVKyJ-A-1; Thu, 08 Dec 2022 08:31:39 -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 82E8C82DFA6; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D76D40C6EC3; Thu, 8 Dec 2022 13:31: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 02BAE194704C; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2E9181947048 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 73DBA40C6F9F; Thu, 8 Dec 2022 13:31:23 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D00840C6DC7 for ; Thu, 8 Dec 2022 13:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506330; 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=JQ/luTt0thkQ0muAGYfRi0hBZIJe+dGXCZLHBjTjP9Q=; b=VC05LGjnKNSWyfMAD33x9HDpsruwGTDpzQIaSEcPQnRNac0hyEQTEn1qnz7oMzjX597Dua D5lsAQDo2dw7/lSHHxtHtIHPczbxU4JtHMVDcwki6CNikOOJ4FVZ+jE0CljRD/sw7pblPM o2v/YTX2rS2D1DWR+ooWTC8ecRF824w= X-MC-Unique: C6X1h3NyOP2aaQuNVKyJ-A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 12/30] qemu_snapshot: refactor qemuSnapshotDelete Date: Thu, 8 Dec 2022 14:30:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506332440100003 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 d7983c134f..e9bb5abee2 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.38.1 From nobody Fri May 17 09:01:44 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=1670506301; cv=none; d=zohomail.com; s=zohoarc; b=G1H7wg2OFptoBaQIMKzrfaOc1DoUizu80oPA71V+kMKiCmto3VwDWrQYWQTyCS80kQ/lXQrTEIsH6zv6H+Yaai3iS6LSGm5lr6uUbwIYzL+yDkjh/MPQAyfFh7aATBu7+HC5qUVtTDcDOqB31X9fMgU3JAZHfQdx4cu+7QnPLHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506301; 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=oRtsMmbE+2zJ/d5/7RTg3aEP+i0lQlvmkp/68/K7zAs=; b=f465R/QsDgVFgmp5lwy036q0eZLmFmht8povL9AUohFE1FdS5SvoV3Xvy/2SjjwP7EJCf5EuFkqsAT1tlmW0ExN//xMNszj+jVP6k7rUtSsDJmAGjrQEcWBaZLumknlTNhwQ+gHKK11U5gDVLzvTRf8jkzmouxjLKgDFOrCYKtI= 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 167050630099225.301268655508693; Thu, 8 Dec 2022 05:31:40 -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-377-7f8PEOT0OmWR8qk3hh7t1Q-1; Thu, 08 Dec 2022 08:31:37 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A2988811731; Thu, 8 Dec 2022 13:31:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A2211401C37; Thu, 8 Dec 2022 13:31: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 9FAD81947051; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2A3651946A68 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2555C40C6FA1; Thu, 8 Dec 2022 13:31:24 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id B338540C6FA0 for ; Thu, 8 Dec 2022 13:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506300; 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=oRtsMmbE+2zJ/d5/7RTg3aEP+i0lQlvmkp/68/K7zAs=; b=UQpxkfy8z7y3SlVTcN4IO7g00e9hnbX9TmQXIdOKTevveYUGEIiQrdwNxG1p9p5fqa1fSx fxZ54+lGYDyS/x08EAfcSiAbB5slDihF6Mxvx1QXApja/pFW2xysEhc46uQRPoQSKUsF6V LQDhdOIuZx5iogrvSbZSWLzgLlDp7fc= X-MC-Unique: 7f8PEOT0OmWR8qk3hh7t1Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 13/30] qemu_snapshot: introduce qemuSnapshotDeleteSingle Date: Thu, 8 Dec 2022 14:30:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.7 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: 1670506302277100001 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 e9bb5abee2..47239e9e9c 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.38.1 From nobody Fri May 17 09:01:44 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=1670506441; cv=none; d=zohomail.com; s=zohoarc; b=oJT/PzQjP6uGItZYVjivplrjm0mqifyH1Phu9aQNKO991Amy5iyalzggZM+KHzYcWYuuf3nA1hddazrCS/qY+AFs0sMWFgPQxr+4Zex9qjda78J69sYtXyuhqskgRNI8v9MJHYhjPkfxYm7A4R8QzG5rTMjWQ6F9Y5woydcwNVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506441; 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=7EZAdV4mV7xOSG7M7zK9qlyZetOIJXMoIPkEMQW8zKQ=; b=KsewkXqJxCJCaNNaceJ2m7NqcAudH5OF5AsJK4YxAuaLWzFkLsyWtAG+Hjv/+Fd/uVqsWwPCVkvK71r40vqKSMG5KOzIHFOuqLgJi+U5jlOSzcoVuQuhniSDU8wxTbhhoiRFZE841DPFDQAKbT0ku50DR7QtYHKbx/l2PttA/WU= 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 1670506441509250.7993306473635; Thu, 8 Dec 2022 05:34:01 -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-9F48C6jVNYiqy_CQlSkkfQ-1; Thu, 08 Dec 2022 08:32:20 -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 AE683857AB9; Thu, 8 Dec 2022 13:32:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90901492B0B; Thu, 8 Dec 2022 13:32:04 +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 B127E1946A7E; Thu, 8 Dec 2022 13:32:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 25C961947047 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CB04C40C6FA2; Thu, 8 Dec 2022 13:31:24 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6510540C6FA0 for ; Thu, 8 Dec 2022 13:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506438; 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=7EZAdV4mV7xOSG7M7zK9qlyZetOIJXMoIPkEMQW8zKQ=; b=Pt6cs4qGzUId993y8g40l/JwYx6amOp4cEPrZPUWimiNBK9glG+pNxAXlipBhoMfNB5V17 ZO8DFQ4w7YHW4RhAnErqWCquTWEpoju3VoMU7O05RhXOBJ9CiWEZ0ULN0luPF7g9a6DoQ6 DB4Jfl0mokEmSx40P2cb5vXxU3vAUWY= X-MC-Unique: 9F48C6jVNYiqy_CQlSkkfQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 14/30] qemu_snapshot: introduce qemuSnapshotDeleteChildren Date: Thu, 8 Dec 2022 14:30:50 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506443145100001 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 | 108 ++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 47239e9e9c..3d5467457b 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: boolean + * @flags: bitwise-OR of virDomainSnapshotDeleteFlags + * + * Delete children snapshots of snapshot proved by @snap. Based on what @f= lags + * are provided it will delete children snapshots including @snap or only + * children snapshots. If @metadata_only is true only libvirt metadata fil= es + * are deleted but the actual snapshots are left intact. + * + * Returns 0 on success, -1 on error. + */ +static int +qemuSnapshotDeleteChildren(virDomainObj *vm, + virDomainMomentObj *snap, + bool metadata_only, + unsigned int flags) { - 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 (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 current"), + snap->def->name); + virDomainSnapshotSetCurrent(vm->snapshots, NULL); + return -1; + } + } + } + + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_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,7 @@ 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); - } + ret =3D qemuSnapshotDeleteChildren(vm, snap, metadata_only, flags); } else { ret =3D qemuSnapshotDeleteSingle(vm, snap, metadata_only); } --=20 2.38.1 From nobody Fri May 17 09:01:44 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=1670506315; cv=none; d=zohomail.com; s=zohoarc; b=CK49z1eDbionZtyNIEtFyek9cDFk8pggonxsBELryi8G1OiBX2+pK54NjpobOgjjgiCT6hx+7u6hOCwJdThyty2z4olzlZz/YMPRKLFVT2Ga2Kjgi5HQCJdWmcQxbjV/3HtozHvQjE30LezNp8Qweh3m2FPCMnh8zYrxBubobG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506315; 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=eV8cthKNxCIwh8+2LzPLW8vEOgztsXwezBAGpiDELYU=; b=NJyImhVUVCXAiPYpwtSIQeoHWoJuu4Ih1JYaX3ESfJFx3kHuT62uS1P7yj60ud9+Qy2nzuYhRPmx/RmnPoi9rjeCFZwD+ySRfaUdbMJr+9Ji4aM8wbUKN6q75RJJmMU0fc5mqmUOthvQzWkPCQxIdNPQXkB/9GSqZxtP7ioirT8= 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 1670506315485961.0653866971523; Thu, 8 Dec 2022 05:31:55 -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-423-hKe_8GSWPGybf3JtZZB76g-1; Thu, 08 Dec 2022 08:31:39 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8CE0686C044; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B149477F64; Thu, 8 Dec 2022 13:31: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 004511946A7E; Thu, 8 Dec 2022 13:31:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 212111946A4B for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7F3A840C6F73; Thu, 8 Dec 2022 13:31:25 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 162E440C6DC7 for ; Thu, 8 Dec 2022 13:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506314; 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=eV8cthKNxCIwh8+2LzPLW8vEOgztsXwezBAGpiDELYU=; b=W8DvBRb1PR1k3OSy5z3u7XdEeAxlbiFFJO6XeM4AQmuAnK9JIXcDNbKFFYkNN7+PKGhJSX FcpxK5uuwtgEq6KtygbXIo+fRrwypl7oln1miEhxbDWVbvHAp/MCnTtjrULzezyA4sGS7Q xrGlGTC+Bxr+X6pP2ZxMR2sBpdSASns= X-MC-Unique: hKe_8GSWPGybf3JtZZB76g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 15/30] qemu_snapshot: rework snapshot children deletion Date: Thu, 8 Dec 2022 14:30:51 +0100 Message-Id: <6534c24cbf4dd932edf8c1923ca9bafe28f656d9.1670505851.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.9 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: 1670506316356100001 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 3d5467457b..846f6e9e53 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 +qemuSnapshotDeleteAll(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, unsigned int flags) { - 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, qemuSnapshotDeleteAll, &data); =20 - 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 current"), - snap->def->name); - virDomainSnapshotSetCurrent(vm->snapshots, NULL); - return -1; - } - } - } + if (data.error < 0) + return -1; =20 - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { - virDomainMomentDropChildren(snap); - return 0; + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN && + qemuSnapshotDeleteSingle(vm, snap, metadata_only) < 0) { + return -1; } =20 - return qemuDomainSnapshotDiscard(driver, vm, snap, true, metadata_only= ); + return 0; } =20 =20 --=20 2.38.1 From nobody Fri May 17 09:01:44 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=1670506387; cv=none; d=zohomail.com; s=zohoarc; b=Irklt9KDrOKpERiWit1X6QcumjE7cfjF398rGfDUBb3wrRpkaI7iCOLcXZxzkp3NVm9RRJnIOjNWK9WPtypcKXKh46/I+foQ2bVRVVKvq3Ru6aw4XwC7cT8l5J1az50e5hmTHEQuvA3tZ2tWvqpx7xD17DasD0WXLMPKrEYFr+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506387; 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=4M8pvcxpp+xDEZC+fqjx6Tp3pLcligARca90NcToaj4=; b=L3yLQNPT5zNr7/1NgTBd8FSMxM/qfJI7MytKvfrZxHJrsBgbxTLKqmdmRXlmC6YV/uy1ECbCVXDq60MB751Q8AOku6C9y24XSsnlGnnuOe0p57dU8R/sl6cVO5QTVxBKZqV5LIYplfmhzSURhVutA/wKp4t8aDIDP083haROfl4= 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 1670506387573888.717608059857; Thu, 8 Dec 2022 05:33:07 -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-191-lbNN9iHSMCaNdIUo6M-olQ-1; Thu, 08 Dec 2022 08:31:40 -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 614D81010441; Thu, 8 Dec 2022 13:31:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D7DFC15BA5; Thu, 8 Dec 2022 13:31: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 E594C1946A68; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 369E21947049 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3078A40C6EC2; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDC2B40C6DC7 for ; Thu, 8 Dec 2022 13:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506386; 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=4M8pvcxpp+xDEZC+fqjx6Tp3pLcligARca90NcToaj4=; b=VSLX1YzZQmLtKyuma0LwHuCYTjp50BjmWQ9eKW+Fij65EPQsNsYiSJO2tiM6ybhUF4TyqY Lyoo53eAp8JFRk5b3mXupZPpzBorUgJW4S6ZYKnb1plSxanpolI195v8jWBn3YWry1sORB 3GSPu6Y/vkHCuqLQ27nBE6fs/lzPgiM= X-MC-Unique: lbNN9iHSMCaNdIUo6M-olQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 16/30] qemu_snapshot: move snapshot discard out of qemu_domain.c Date: Thu, 8 Dec 2022 14:30:52 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506388721100006 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 8892f28fce..a6bb4a01df 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" @@ -7139,81 +7140,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, @@ -7232,23 +7158,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, @@ -7261,7 +7170,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 53533062e1..4bd052c4da 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6526,7 +6526,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 846f6e9e53..8754022aa4 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.38.1 From nobody Fri May 17 09:01:44 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=1670506319; cv=none; d=zohomail.com; s=zohoarc; b=WfVIB58QWmSQ+YDnOXmHBTmyx/f+nvmmLO8KNfxqrlnQohQpV1szHpCYTSrRu57fu/tCYrqm/BntvJFw4kzrliV6JQjPuZMhkhGTc41YNOcmxFAJPvEXM7G+FTB9/fWCtqInfZhANCIZZRPt84IoW00gqwKtZ32PfBtQaAcJtTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506319; 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=PooU+pmu5+KXz3Xy7dYyiCdRCJE4s5DccKgWUEKUe5A=; b=XdLw/+emNsuieLftLurzsPVUqw8IrifnYmkViS8YFQ+3r0OiHiFpkwVWgTO8SxvhYGGsVQuBZ9Mo0Oslo7yPMHuiRnUneXghFpRvajKqKa4Jyq8MHaS+i8iT4CLLeiwO3SsPBlyi2wgbjRj/e5mneV/0sc24lV4CgXtPiF7m9ns= 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 1670506319368129.99125270062245; Thu, 8 Dec 2022 05:31:59 -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-50-7U3VIZzBO8WbqntVh4m0vg-1; Thu, 08 Dec 2022 08:31:53 -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 9182D3813F32; Thu, 8 Dec 2022 13:31:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CA31C15BB5; Thu, 8 Dec 2022 13:31: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 1E8BE1946A68; Thu, 8 Dec 2022 13:31:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 00C611946A41 for ; Thu, 8 Dec 2022 13:31:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D588140C6EC3; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F95E40C6EC2 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506318; 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=PooU+pmu5+KXz3Xy7dYyiCdRCJE4s5DccKgWUEKUe5A=; b=I2M6Jd5UCqyY0BtwqsqzP0oHkYztox2jCIB11IGryxyzNllUV8v3ctsePYXCTQP0x2CYHr yiWydMdPHR8dWTHe/efQOaKvWmbV8UoijREVVgm3NEkNjrphdWFQE6nMgt276eFxvNjzt2 BIQqezzPhddZnFb+Aozjo3XUnd/R2IY= X-MC-Unique: 7U3VIZzBO8WbqntVh4m0vg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 17/30] qemu_snapshot: move snapshot metadata reparent code Date: Thu, 8 Dec 2022 14:30:53 +0100 Message-Id: <605bd766f4161bf1541a1387c17552a8e4ee9d80.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506320413100001 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. 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 8754022aa4..5418496c1e 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.38.1 From nobody Fri May 17 09:01:44 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=1670506323; cv=none; d=zohomail.com; s=zohoarc; b=dHqGPK2TjLYCRLkthYGHDgLk57xpdCQ1naPLTdcXy2Oby7f8fFj9qDZm6FacPNjCDXF0zDfgQE3/e+iVzH8pXa+/45UmDK8sH8nJF5DDNbszpCvk1U00yk8cGslK9FY+Tbxs0wzHqRQ5vCpy4L/K9h7G318YCmCu7tHI0OqJew8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506323; 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=jcmXE2Kfmd14v4O83v7FRsodonEhJBN64bNV1qEGhds=; b=fxVrKCBHfRaEcoVfKK8HeOXDYdbbqy+XU5RRFen9vMBYD1kslW5h7DBXcPw/aS9O5yS7zwOZx9A6Lswyjt83Vtom1LKFrVq83cXJLjSgwsYDO/DX4oGF5xjl8UpdADEbZ6c7eiyk1QHsrSMypdddxbKQFUBRwGoNcKV6kmhHmdE= 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 1670506323838419.9218351848667; Thu, 8 Dec 2022 05:32:03 -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-356-WHmZrh33MHujAJ3aIAG0CA-1; Thu, 08 Dec 2022 08:31:57 -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 4284C857FAB; Thu, 8 Dec 2022 13:31:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BFE4111F3BB; Thu, 8 Dec 2022 13:31:52 +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 475131947050; Thu, 8 Dec 2022 13:31:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 35944194706F for ; Thu, 8 Dec 2022 13:31:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 21E9140C6EC2; Thu, 8 Dec 2022 13:31:28 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id B02AB40C6EC3 for ; Thu, 8 Dec 2022 13:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506322; 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=jcmXE2Kfmd14v4O83v7FRsodonEhJBN64bNV1qEGhds=; b=BS/s22WK0t/HhnlM5AERGogQz5w1kl0ZpmXMcUQF0VDx0SvTJwWqEUnfyVthQa0IY+PhA6 W1vxu1+Y/qUdfvBIzgr/7vaZhBGNaj6Re5GfqDs/PQDEotkrAvuyzx4wmhUKYFwSHJP3Yb uMKJfIC10opNFimd2weXO85mgcNv4qM= X-MC-Unique: WHmZrh33MHujAJ3aIAG0CA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 18/30] qemu_snapshot: introduce qemuSnapshotDiscardMetadata Date: Thu, 8 Dec 2022 14:30:54 +0100 Message-Id: <1cb74d2bb546374f3fcc5cc25dee155a8d4b9f21.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506324404100008 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 | 91 +++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5418496c1e..4ea3f578e9 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,52 @@ 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) +{ + qemuDomainObjPrivate *priv; + + 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); + } + } + + if (qemuSnapshotDiscardMetadata(vm, snap, update_parent) < 0) + return -1; + + return 0; +} + + int qemuSnapshotDiscardAllMetadata(virQEMUDriver *driver, virDomainObj *vm) --=20 2.38.1 From nobody Fri May 17 09:01:44 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=1670506325; cv=none; d=zohomail.com; s=zohoarc; b=c1wf8flJhL9jZhVDDddcPwopGcy/KVvuhMUeeTlBUJW5wp+CDRzcJTCKJSqRQk5SHAjQT6TKaUCDCpCFnzoFT50CMZOi0XdhK1zqmlBmDIjHT9hYB/bDAdwkRPqov6dhoAy1TZfo2h1+AdJJZ8/LIUhGKLj5IJDaCqQ6g/mAYYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506325; 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=umyTUWuvVXu7tmFmxs+Ial5O0qfY+MFGmxPDJNOeG7c=; b=UVx2F4RmLqbK0m+qjn9nuGICmqFLFYYOh+KBGMNeymqHNpp4z+/QebbG83V9VVu81ii7mpd5gArvksuhcelIVeJXQFMfWBWbP3rJ2bG4y+lHQAnacThY2Kb1Zkow/M48qYQt+RGVFhoOdmHGUcoTz2RWbVvpbTp7t0bW/gEqW10= 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 1670506325388880.1546770964808; Thu, 8 Dec 2022 05:32:05 -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-414-sBkKecJqOj6dto3GxY1UDg-1; Thu, 08 Dec 2022 08:32:01 -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 12442806001; Thu, 8 Dec 2022 13:31:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F13E717582; Thu, 8 Dec 2022 13:31:57 +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 E1D951947058; Thu, 8 Dec 2022 13:31:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1A0D71947055 for ; Thu, 8 Dec 2022 13:31:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C7E4540C6EC4; Thu, 8 Dec 2022 13:31:28 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 624DE40C6EC2 for ; Thu, 8 Dec 2022 13:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506324; 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=umyTUWuvVXu7tmFmxs+Ial5O0qfY+MFGmxPDJNOeG7c=; b=HzZd4TateVt9Wn/zCJrVG2435TdAbP7jfo9KqJG8JGecJzxHi5srTxjwXGlfPPg20xLii8 DkOXn2A2unlSc4Lxyef88X/n1kU90J8x/jcNFEbCco5NsZyv+J/wgQZBrfRPraP7a3o/hZ RSmu1GF29vx1GWefVlfcPIIzDg5f1eY= X-MC-Unique: sBkKecJqOj6dto3GxY1UDg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 19/30] qemu_snapshot: introduce qemuSnapshotDeleteValidate function Date: Thu, 8 Dec 2022 14:30:55 +0100 Message-Id: <05d5f826a098428eb28501a2a037d29f3e8883d7.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506326463100001 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 4ea3f578e9..11427716e4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2485,6 +2485,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, @@ -2493,7 +2520,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 | @@ -2506,20 +2532,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.38.1 From nobody Fri May 17 09:01:44 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=1670506320; cv=none; d=zohomail.com; s=zohoarc; b=UEV3hk4661S4FCEkquCyrvPSaP2QTLN9GZlS/igMBamwHPR3f9Czij6lXs1qpTMFnbMsBSKHsNTz6qLRhMillywulgD5WPKvzOMsbmM5HJCVe2kMhAEAW/HHWXzBawtp6CBfrPYmVZgj/+Z9E7CFGYP5PaZdDudUHp7ynEUH2hc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506320; 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=SG1+nO9ZYgtylbOa57je7jjBuZ+Q7wY04iE9Xics7po=; b=n5BOq+oVA88ud7pHPa9GNB+owg0/X55hn2TxEsUoIm9CSSDKPKCBOOgs+FufTeVAK/h7PtWkaMGZTKJtFMoAFUqeVb6KrjHOVImFxsAFRycCtU9kTiw9sfC+v7hJ+46YVtqovlSlaxKiDHQ0NFegGLQfy5xoUNh0Tdph2qUidqk= 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 1670506320562419.6521137326205; Thu, 8 Dec 2022 05:32:00 -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-136-hNL9IF6JPeeSOyX0fA3Liw-1; Thu, 08 Dec 2022 08:31:54 -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 D658C857051; Thu, 8 Dec 2022 13:31:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEB412166B29; Thu, 8 Dec 2022 13:31:45 +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 17A011947048; Thu, 8 Dec 2022 13:31:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 989B51946A4B for ; Thu, 8 Dec 2022 13:31:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7E6B240C6EC3; Thu, 8 Dec 2022 13:31:29 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1747040C6EC5 for ; Thu, 8 Dec 2022 13:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506319; 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=SG1+nO9ZYgtylbOa57je7jjBuZ+Q7wY04iE9Xics7po=; b=M3uP2WgmteCHSIZL6DjhSq8Sgxjf2flUXLTb//VwQSg63uKqghSM/YW4I358gAQ9FoXS5S OQGXpX/RmP64HpzXr799eDRbVMu5JwJloLldm3qwPBXwJCifzQ+ZbwOhIQEg5vlPAovuw/ MXxbWVrKai7BbNZdSF1gdeEI90rMUqM= X-MC-Unique: hNL9IF6JPeeSOyX0fA3Liw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 20/30] qemu_snapshot: refactor validation of snapshot delete Date: Thu, 8 Dec 2022 14:30:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506322357100005 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 11427716e4..a4b45d3ba3 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, @@ -2485,26 +2470,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.38.1 From nobody Fri May 17 09:01:44 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=1670506406; cv=none; d=zohomail.com; s=zohoarc; b=X0w1IulEZNUjw6pgAcxOIzlaFXifjhrX430YmISsXzJotCjGpzWy9jotiINRm8Gggi2RBJAshG0ijx2oKW2V8/WbIrJsWlBfxg2Quj4ulWcNgHSd2T6aWrgNHTcmsOlj5JNSl645Xqx7rhGI6Vt1nYpaNDvOiAMOG4sE+JoZBew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506406; 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=oL7z9gSi/Cq4sLhiD0OFB5lbOZsDN+7x0TpdoXeO+DM=; b=GqR0PUGTOsqR5yJOnAMxuwgNcsDTbbqz8iYhMxjI2bpBpiRM5JqsH4ACQGYfqgRvJMrByIVpkwyEnJKdkTl+iL+zCJ3NWWSjSskV6CtmVR0DHfMheIzXhMDDJhLBGLXLuAfqnt8Ab6Jy4SqLf2jlgt2nnfY0JicIR4Na5W4Hoi8= 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 1670506406991193.86517347334188; Thu, 8 Dec 2022 05:33:26 -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-175-Ew-o0_vsPPeG3lVJGpnp5g-1; Thu, 08 Dec 2022 08:32:21 -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 165D92833B21; Thu, 8 Dec 2022 13:32:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB85F40C845B; Thu, 8 Dec 2022 13:32:04 +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 8181719452D8; Thu, 8 Dec 2022 13:32:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6CEFA194704E for ; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 319BC40C6EC2; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDD7640C6EC3 for ; Thu, 8 Dec 2022 13:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506406; 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=oL7z9gSi/Cq4sLhiD0OFB5lbOZsDN+7x0TpdoXeO+DM=; b=bRaAm1zw4BmFjbhEFmNWPXzh9zrDi7B2Hu/hinpNRAaoCF5LLhgg4SOKx9Ir43A59qiM0C /rO3QAZpNYeoEu4CarP81GQ4ynXZmvv6K7Z5hBh7cEpC1uIQ5hxI/aWLLGMeqgjwsf/x+R At1IqTrsBYLcXV4LpAsTYO4WTo8ekE4= X-MC-Unique: Ew-o0_vsPPeG3lVJGpnp5g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 21/30] qemu_snapshot: error out when deleting internal snapshot on non-active disk Date: Thu, 8 Dec 2022 14:30:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506408838100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Deleting internal snapshot when the currently active disk image is different then 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 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index a4b45d3ba3..adcd4eb73a 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2495,9 +2495,30 @@ 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, "%s", + _("deleting internal snapshot for non-activ= e disk is not supported")); + return -1; + } + } + } =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { @@ -2551,7 +2572,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.38.1 From nobody Fri May 17 09:01:44 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=1670506395; cv=none; d=zohomail.com; s=zohoarc; b=A3yVsRluOn27Lmu2eNv9OOfgHE7fFLtwb1627U56DKybT2WdB/2v1OKvxU6NipR3AiLy0YVSq/CXAucrSHOGf3E4B7DkWwzsJfze8TvbqwhhlLflK1IV0eS+of1OyDmFmWD03JSqIJgLUnTM7ScH3iumorWiLmRlDl0bXdPuSR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506395; 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=vu8lI9AMgC6MyVHWNaST/DK0rcBoCrvon7RvkHOQ31w=; b=UjjmRpQakw8OkIyzdI1rDrF92LzpOzUW5K1vdORxM4V4HJCsL2olEeLaout/EKIYNQtuTjsx24kF5x1hDZuuFS7//1SnoBb77LbKVXbzB5i3KNDLzALSmaHwvxNGsX7wmhfxalC3vI7SjZ5ze5v16LHkxKv9LRau87knHXVSIZU= 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 1670506395816446.125692243771; Thu, 8 Dec 2022 05:33: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-121-AE_IxLPCOGK_4zabbt-iwA-1; Thu, 08 Dec 2022 08:32:21 -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 B77971C0DEA4; Thu, 8 Dec 2022 13:32:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60D444EA57; Thu, 8 Dec 2022 13:32:04 +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 98C0A1947B85; Thu, 8 Dec 2022 13:31:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E53D91946A7C for ; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D7F5140C6EC3; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7219040C6E13 for ; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506394; 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=vu8lI9AMgC6MyVHWNaST/DK0rcBoCrvon7RvkHOQ31w=; b=Hu/1UFz0XXsSglcNAu0ohMB0+tU35lS6KolZIo/BGTixerl5rQyyLZ/J4+WrXG3eSsHX6K skr2rDdj+GAnyY57oHrayoroKyTXrt8GpJaNva+zSkblMQJ9NB3BHcRghlY7z0dlDTTt6N ayQAYnAksre/gISnOhRdxk8WZ5YxMRw= X-MC-Unique: AE_IxLPCOGK_4zabbt-iwA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 22/30] qemu_snapshot: convert snapshot delete to async domain job Date: Thu, 8 Dec 2022 14:30:58 +0100 Message-Id: <737170d31347d148d511d10e90c9ab780e37e004.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506396730100003 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 adcd4eb73a..97df448363 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2361,11 +2361,16 @@ qemuSnapshotDiscard(virQEMUDriver *driver, if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", tr= ue) < 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); priv =3D vm->privateData; - qemuDomainObjEnterMonitor(vm); + if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT)= < 0) + return -1; /* we continue on even in the face of error */ qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); qemuDomainObjExitMonitor(vm); + qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_DEFAULT_MASK); } } =20 @@ -2565,8 +2570,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; @@ -2584,7 +2592,7 @@ qemuSnapshotDelete(virDomainObj *vm, } =20 endjob: - virDomainObjEndJob(vm); + virDomainObjEndAsyncJob(vm); =20 return ret; } --=20 2.38.1 From nobody Fri May 17 09:01:44 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=1670506322; cv=none; d=zohomail.com; s=zohoarc; b=aB/YCyxBZXgRhn4DBRiXsvxVTfMnV+A+iqndS+KCriDGUcuF612Vvzi4iaGg61+n2m1CFAPWZICWHF4GeDmBqitP82JfPWXIMRjHvqxF3Wo0ajuLbq0492VzhfshnIeXYCsSpJQ58NOKA2zUUH9YyLq9enFryFrYOISgHO0PsEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506322; 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=+fj45PePY/mvPHuIBT2CJjYVx0RpFJkUwN5mur5gnHI=; b=GZEWIxVNGuLyYr/a30szIE0kJtdLwIOUhQf2u0+XXT9EZosfZdLeIGZ4Ez+GCyhWuiOpHb5Q9bgkY0Iwg0WyEhJwqQ/fFpJXTSbj5gPnRqkpEX3T95/zNYR5vKYlRbGBSrGOuyUgohl6O3CfO9TRxgM3GLIfrQ+nuqVaYsd5BLI= 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 1670506322684729.2030642041009; Thu, 8 Dec 2022 05:32:02 -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-517-hlqkxYIYOyek89AXkzmOTg-1; Thu, 08 Dec 2022 08:31:57 -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 324C71C0DE9D; Thu, 8 Dec 2022 13:31:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B8E41121331; Thu, 8 Dec 2022 13:31:51 +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 E9DE61946A72; Thu, 8 Dec 2022 13:31:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AEC3E194704F for ; Thu, 8 Dec 2022 13:31:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8CD0A40C6E14; Thu, 8 Dec 2022 13:31:31 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2426540C6EC5 for ; Thu, 8 Dec 2022 13:31:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506321; 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=+fj45PePY/mvPHuIBT2CJjYVx0RpFJkUwN5mur5gnHI=; b=TzaVVdbQ13skThkhLKwMEL8wEDSMrCe/cYosTqyS7K6dooZ8DgOkwzYOC2hAC4Q96PQjzt JWyOQdzroa6VKxs7CR/IQztG8PWz+kLhKd/Qf227ECbFK92rzVck24xMvxGYoua18ssYrt HNuWaQDtNZTp53qGY1wNuk4irlSqxCY= X-MC-Unique: hlqkxYIYOyek89AXkzmOTg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 23/30] qemu_snapshot: prepare data for external snapshot deletion Date: Thu, 8 Dec 2022 14:30:59 +0100 Message-Id: <2d2cddfbde472be875d4d79220f8c324f3a59210.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506324408100009 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 | 163 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 97df448363..882224b0a7 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2232,6 +2232,134 @@ qemuSnapshotRevert(virDomainObj *vm, } =20 =20 +typedef struct _qemuSnapshotDeleteExternalData { + virDomainMomentObj *parentSnap; + virDomainSnapshotDiskDef *snapDisk; + virDomainDiskDef *domDisk; + virDomainDiskDef *parentDomDisk; + virStorageSource *diskSrc; + virStorageSource *parentDiskSrc; + virStorageSource *prevDiskSrc; + qemuBlockJobData *job; +} qemuSnapshotDeleteExternalData; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuSnapshotDeleteExternalData, g_free); + + +/** + * 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 virStorageSourceChainLookup(data->domDisk->src, = NULL, + data->snapDisk->src->p= ath, + NULL, &data->prevDiskS= rc); + 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 (!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_append(ret, g_steal_pointer(&data)); + } + + return g_steal_pointer(&ret); +} + + typedef struct _virQEMUMomentReparent virQEMUMomentReparent; struct _virQEMUMomentReparent { const char *dir; @@ -2565,6 +2693,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 | @@ -2582,6 +2714,32 @@ 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)) { + 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. */ + g_slist_free_full(externalData, g_free); + externalData =3D qemuSnapshotDeleteExternalPrepare(vm, sna= p); + } + + if (!externalData) + goto endjob; + } } =20 if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | @@ -2592,6 +2750,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.38.1 From nobody Fri May 17 09:01:44 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=1670506341; cv=none; d=zohomail.com; s=zohoarc; b=TrSRGye6MBRShKls8IMhCtDUHHth5Ubdpvh55SOAOrG2PJohfwo06vHRXf3yaJmM1lFswJhgZSdJz+Vmix6oeyYepPtbDTHExOLlbCMDioM/pcsDKCeuZCFhXFrQfMwtlQClUjfbLWQvdiAKVMsvye7LmzY6FMF/R8JpKrAdENg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506341; 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=gjHxWlTFU0yqKwoFISsuBF3kwAonndckSrQi5GV6JQs=; b=b2+ptNClVHJKnwhL8YjpC9B4ywX+wurNkLKOtjQeVllIlWSBg1FTSuRQaG5pcpegWma/QqWwE4jYNiwJof0FPG1o2pqjvEa/omUxfXuRQW4WhWziSg2zu+3phLaT6XIxCiCGd0nQSWT6NiPfc3CjMnJ3CKCVLYvzgNcLpPUiOO8= 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 1670506341915289.9643050376757; Thu, 8 Dec 2022 05:32:21 -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-518-b-CSO93jPTuVR2SBFkrfMA-1; Thu, 08 Dec 2022 08:32:17 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 020612A59565; Thu, 8 Dec 2022 13:32:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0181492CA4; Thu, 8 Dec 2022 13:32:00 +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 C66111947B90; Thu, 8 Dec 2022 13:31:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7BDB41946A7C for ; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4A25840C6F73; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFED640C6EC6 for ; Thu, 8 Dec 2022 13:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506340; 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=gjHxWlTFU0yqKwoFISsuBF3kwAonndckSrQi5GV6JQs=; b=Yn7Eat+JrGmRmCQLhgJIr5aHviPY+hRimVg95c1lqWFIDJacfpFyydWuhHFwIbUac4bvNC Xp8lqpXh8tk+SanA53HJWgIihIYvXgqS3loerGCM3Q6Fxz+TIicvnQGYVg0P7SfOkjI0S/ s1UXmpSiblrd+g1MzNlSk1c1JeteR0k= X-MC-Unique: b-CSO93jPTuVR2SBFkrfMA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 24/30] qemu_snapshot: implement deletion of external snapshot Date: Thu, 8 Dec 2022 14:31:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.9 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: 1670506342527100001 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 --- src/qemu/qemu_snapshot.c | 266 +++++++++++++++++++++++++++++++++++---- 1 file changed, 245 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 882224b0a7..c493a3e94f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2394,6 +2394,207 @@ 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 +qemuSnapshotJobIsRunning(qemuBlockjobState state) +{ + switch (state) { + 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: + return 0; + + 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_LAST: + break; + } + + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid block job state")); + return -1; +} + + +/* When finishing or aborting qemu blockjob we only need to know if the + * job is still active or not. */ +static int +qemuSnapshotJobIsActive(qemuBlockjobState state) +{ + switch (state) { + case QEMU_BLOCKJOB_STATE_COMPLETED: + case QEMU_BLOCKJOB_STATE_FAILED: + case QEMU_BLOCKJOB_STATE_CANCELLED: + case QEMU_BLOCKJOB_STATE_CONCLUDED: + return 0; + + 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_LAST: + break; + } + + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid block job state")); + return -1; +} + + +/* 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 +qemuSnapshotJobRunning(virDomainObj *vm, + qemuBlockJobData *job) +{ + int rc; + qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); + + while ((rc =3D qemuSnapshotJobIsRunning(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 +qemuSnapshotJobFinishing(virDomainObj *vm, + qemuBlockJobData *job) +{ + int rc; + qemuBlockJobUpdate(vm, job, VIR_ASYNC_JOB_SNAPSHOT); + + while ((rc =3D qemuSnapshotJobIsActive(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 (qemuSnapshotJobRunning(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 (qemuSnapshotJobFinishing(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 (qemuSnapshotJobIsActive(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, @@ -2460,11 +2661,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) { qemuDomainObjPrivate *priv; =20 @@ -2486,19 +2688,29 @@ 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); - priv =3D vm->privateData; - if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT)= < 0) - return -1; - /* we continue on even in the face of error */ - qemuMonitorDeleteSnapshot(priv->mon, 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); + priv =3D vm->privateData; + if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPS= HOT) < 0) + return -1; + /* we continue on even in the face of error */ + qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); + qemuDomainObjExitMonitor(vm); + qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_DEFAULT_MASK); + } } } =20 @@ -2509,6 +2721,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) @@ -2530,12 +2753,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 @@ -2555,7 +2779,7 @@ qemuSnapshotDeleteAll(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; @@ -2595,7 +2819,7 @@ qemuSnapshotDeleteChildren(virDomainObj *vm, return -1; =20 if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN && - qemuSnapshotDeleteSingle(vm, snap, metadata_only) < 0) { + qemuSnapshotDeleteSingle(vm, snap, NULL, metadata_only) < 0) { return -1; } =20 @@ -2746,7 +2970,7 @@ qemuSnapshotDelete(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { ret =3D qemuSnapshotDeleteChildren(vm, snap, metadata_only, flags); } else { - ret =3D qemuSnapshotDeleteSingle(vm, snap, metadata_only); + ret =3D qemuSnapshotDeleteSingle(vm, snap, externalData, metadata_= only); } =20 endjob: --=20 2.38.1 From nobody Fri May 17 09:01:44 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=1670506342; cv=none; d=zohomail.com; s=zohoarc; b=VkkhaEHkdBdq0PMjJ3uQ87UuoGu/pt4JYhxfFrJUbHJVm34ntw2RdWyqMzFKHAwUdy9VNlX6Gj6di4vRTIBMKsZW+/yhZFu6Rllh0dS4H8Nynd3PTm2GK4eUYPQ6eCDUvT8Pq+AxKyIGmG8EtSLRfvWoMol3b9cbv5CD6N3M8t0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506342; 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=LjvepvToDZ0uwboOiaxPUCrrlzCTaHnuK28C7h/vpBo=; b=nL5QNsOutVhX2FX4VL/JLsAjCHzye6qyjQI5RM+OqqqNPd4fImJCpYp4I5qFMXJYlj2HA3OhzLvOmgrvmrAlth44VicQqpoX7X23ra+K4oNM4X/+LhcPfrz9x++XbvkNnJdm36xUTdg8CLOve7n6tZoEiOrFLwk22W+AxmvB8Qo= 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 1670506342851708.372585413208; Thu, 8 Dec 2022 05:32:22 -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-114-GHHa2yF8M-STKmo6gLO-mQ-1; Thu, 08 Dec 2022 08:32:18 -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 D1DD13C0F68B; Thu, 8 Dec 2022 13:32:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC3A240C2065; Thu, 8 Dec 2022 13:32:03 +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 264CA1947049; Thu, 8 Dec 2022 13:32:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 06E991946A41 for ; Thu, 8 Dec 2022 13:31:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E723C40C6EC3; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80DE940C6EC2 for ; Thu, 8 Dec 2022 13:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506341; 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=LjvepvToDZ0uwboOiaxPUCrrlzCTaHnuK28C7h/vpBo=; b=h8QhAWWqCN0Vpj3i1b60onLsTeVFaw6qSKjDSLxnwHi+qJBPfN1FJteJR0m9I+n61fuQXJ mYd9AUT3fHLrQ1BYjNe9uG2bwGW4di/WkCl+1t5jl2bQnxFAn9TarZAFBgqGz34jLH+rD0 b6c4tZwo5TmZ6pOLJU4q+dVOHnb+dw8= X-MC-Unique: GHHa2yF8M-STKmo6gLO-mQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 25/30] qemu_snapshot: update metadata when deleting snapshots Date: Thu, 8 Dec 2022 14:31:01 +0100 Message-Id: <1549842bd6d0796d30f6a5c00957ab96245e3190.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506344509100004 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 c493a3e94f..3fbc3ce65f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2394,6 +2394,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. */ @@ -2604,24 +2725,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, @@ -2655,7 +2786,7 @@ qemuSnapshotDiscardMetadata(virDomainObj *vm, virDomainMomentDropParent(snap); virDomainSnapshotObjListRemove(vm->snapshots, snap); =20 - return 0; + return ret; } =20 =20 --=20 2.38.1 From nobody Fri May 17 09:01:44 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=1670506384; cv=none; d=zohomail.com; s=zohoarc; b=g+k9d7kXx2q+seoMWzEpGuLGs8b5/RJ6m7dM1F2WtAP4MNoHWyoP4054HbsWTB8KVtA+89MaydYkvB5yAsEkxmV05n3hJlVkaZL9hVoC3bOU9xkdCBFFOm+DDTzrcqwQcXjFaC82InK1Dhtiaem/0IOWbLP2lurMk0gxNAOg5NA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506384; 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=Uo2LlOdIuYxHnAkVdeN4Y8DhnLP9SnACdOiuBvdqQx4=; b=mTEBwlj5/+72RIrT/BZbWIxlE/pOWAcFWv85bHyzjhnDXq3GCQgEp1jrkc6ToUbLOoVP617OTrhaF6j18+WsdrjrXr+jSfXwtLPw12qq23BDMy4xQFAfxvezZ+7Wjs53h7zxoIjHqSa51J3Or01iaBcoQkZmCZu3lUaNheM92+g= 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 1670506384709519.8314126197564; Thu, 8 Dec 2022 05:33:04 -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-14-isdM2aR_P7GJDa0fjBBzBw-1; Thu, 08 Dec 2022 08:31:59 -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 32D4A2A59562; Thu, 8 Dec 2022 13:31:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D5D4C15BA8; Thu, 8 Dec 2022 13:31:55 +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 DF17D1946A7C; Thu, 8 Dec 2022 13:31:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id ACD401947047 for ; Thu, 8 Dec 2022 13:31:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 99A6A40C6EC3; Thu, 8 Dec 2022 13:31:33 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3339540C6EC2 for ; Thu, 8 Dec 2022 13:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506383; 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=Uo2LlOdIuYxHnAkVdeN4Y8DhnLP9SnACdOiuBvdqQx4=; b=crDWW5JEuSb5ZV88bQZMLkoFh4nH5s5J8VDfMWhfvyD/oM1FPqi2v5QbLpTNn+kWiodZFk uYo5ZO6q3D2y9XYnso6lReBHpkhICEdkG4gznRP8tcIjNtIhCta2yjywER/Nn8jtNua53z ++DKvL1ejKdSMv/+gf1N1bmldSQlfOw= X-MC-Unique: isdM2aR_P7GJDa0fjBBzBw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 26/30] qemu_snapshot: when deleting snapshot invalidate parent snapshot Date: Thu, 8 Dec 2022 14:31:02 +0100 Message-Id: <70101823f7fc25c116faf1faca66a1fdd5c802c5.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506386675100002 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 --- src/conf/snapshot_conf.c | 6 ++++ src/conf/snapshot_conf.h | 1 + src/qemu/qemu_snapshot.c | 59 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 4b5b908d66..7517208d79 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -158,6 +158,9 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node, return -1; } =20 + if (flags & VIR_DOMAIN_DEF_PARSE_STATUS) + def->invalid =3D !!virXPathNode("./invalid", ctxt); + if ((cur =3D virXPathNode("./source", ctxt)) && virDomainStorageSourceParse(cur, ctxt, src, flags, xmlopt) < 0) return -1; @@ -744,6 +747,9 @@ virDomainSnapshotDiskDefFormat(virBuffer *buf, virBufferAsprintf(&attrBuf, " snapshot=3D'%s'", virDomainSnapshotLocationTypeToString(disk->snap= shot)); =20 + if (disk->invalid) + 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..dfab38e7d2 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->invalid) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("snapshot is in invalid state")); + return NULL; + } + data =3D g_new0(qemuSnapshotDeleteExternalData, 1); data->snapDisk =3D snapDisk; =20 @@ -2620,6 +2626,53 @@ qemuSnapshotJobFinishing(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->invalid =3D invalid; + } + + return qemuDomainSnapshotWriteMetadata(vm, snap, driver->xmlopt, cfg->= snapshotDir); +} + + static int qemuSnapshotDiscardExternal(virDomainObj *vm, GSList *externalData) @@ -2636,6 +2689,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, @@ -2686,6 +2742,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.38.1 From nobody Fri May 17 09:01:44 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=1670506384; cv=none; d=zohomail.com; s=zohoarc; b=NJ3rWFnaZ8c77w+gqUZmkBV9iR9E1qfz4LZOjx5u4a3CsC4AESUrNxaE6LP5la+4xnZCHTKOo4XtGFMKGBoYCI/QDmjZsaCbc2uaMoIhQDK8YavKYfv6/sR96TwG02jakpF+ZtuGdCi7NE4dwCHaOgDmtwTgG2p1UTak8zum3cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506384; 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=iTU7vQbIYlt7/oLvEurcnSb23J+gWgteSyc58c7/X4k=; b=LNxzccr37ftOLNThKQlA8tsIPm+97J7bs+O2NRMUtAYiiP3OMcboean+7PMbUHXQ6dJueGLv/bKsMgkllamd8L3dyAtzCrqStRiKPwBFmtqfINdOashJS0ltR/AOescdCarSBUIDOJZC6Lju3FXC9CFIIWk0uh+IUJGN8YrPyK4= 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 167050638485336.28826023442559; Thu, 8 Dec 2022 05:33:04 -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-563-Q0qvKM2cNtqIh1Ddj23kZw-1; Thu, 08 Dec 2022 08:32:12 -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 3ADBF1C0DEA6; Thu, 8 Dec 2022 13:31:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E253C23DD7; Thu, 8 Dec 2022 13:31:59 +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 7ABDB1946A44; Thu, 8 Dec 2022 13:31:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6E2AF194704D for ; Thu, 8 Dec 2022 13:31:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4B6AF40C6EC2; Thu, 8 Dec 2022 13:31:34 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id D917640C6EC3 for ; Thu, 8 Dec 2022 13:31:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506383; 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=iTU7vQbIYlt7/oLvEurcnSb23J+gWgteSyc58c7/X4k=; b=evUm8BVrFsDfHCwxroT53RK9GEfuDSbJRgUlMUYl/RrekGW36cT/sGIKbwQhAbAUlkOBvP xroMSRpwb2yzodWleIDJqnPonfpmaxRBs6JcAr8RPFF2viFdkeJeffrm36gbCdrjZpO0i4 EfwYoKAroGZT/WXv0ekKln68wRFE+Ck= X-MC-Unique: Q0qvKM2cNtqIh1Ddj23kZw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 27/30] qemu_process: abort snapshot delete when daemon starts Date: Thu, 8 Dec 2022 14:31:03 +0100 Message-Id: <43f724df78ba85e26ac3839de5fc382308f94909.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506386653100001 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. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_process.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 5de55435d2..cc23b4a799 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3677,6 +3677,37 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, } =20 =20 +static void +qemuProcessAbortSnapshotDelete(virDomainObj *vm) +{ + size_t i; + qemuDomainObjPrivate *priv =3D vm->privateData; + + 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, @@ -3726,6 +3757,7 @@ qemuProcessRecoverJob(virQEMUDriver *driver, vm->def->name); } } + qemuProcessAbortSnapshotDelete(vm); break; =20 case VIR_ASYNC_JOB_START: --=20 2.38.1 From nobody Fri May 17 09:01:44 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=1670506445; cv=none; d=zohomail.com; s=zohoarc; b=NLV/+qUHV291x243WaZN87+fp7Rx0rZeRM77qyLzvWWtHqobLUUdhuSHoz6Doe9kp61EbtseVlth01RGwFi86VCZAhrgpsSzUwQQj7s9cvDMmkTegAtIm0O/1r8S4yvtB2y/x09fyK3Dm3Ne/oRJi5KY63a08SZu3epVSOpfNv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506445; 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=YvCZMSMh72lV23bevRwGsOfvVSSU4+q+Jey8jNLggm0=; b=Vyghz3YUjItTqg2HzXNyDH/fUcCDNzNIqz5PuWum4h35fsdHBWZfPo25J6jHjdxXk+JXZYMLuC2Y+dlObhRCDELS6ACoZcCz6xUBXX00KkXHKHRW0Q5HcEGAUdJ568wjuazitNuICdFuiY2WCYpg5LB0km/j6blubBG/FRyQi3M= 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 1670506445369557.6919636731583; Thu, 8 Dec 2022 05:34:05 -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-346-5_5ArMo1NrSeKjRjobUXeQ-1; Thu, 08 Dec 2022 08:32:20 -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 38B6485A5A6; Thu, 8 Dec 2022 13:32:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20A83492B0A; Thu, 8 Dec 2022 13:32:06 +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 0960F194705D; Thu, 8 Dec 2022 13:32:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1E0261947042 for ; Thu, 8 Dec 2022 13:31:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F30F040C6EC3; Thu, 8 Dec 2022 13:31:34 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E3DD40C6EC2 for ; Thu, 8 Dec 2022 13:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506444; 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=YvCZMSMh72lV23bevRwGsOfvVSSU4+q+Jey8jNLggm0=; b=Enc+slQaBrscL5zLRtAUOY2vhLVzxjXA54Yc/NmLkgkxzHYkJGyL4dAdBufX2WPtqgtLpe lXDIOI+qb5UszFIPXOV/3+QXD0ZtjZl5dGwFN/XyUULQrIBjT+3SR+yvlw+Q2ibb7cSND0 +Q4I97KwPCx+O410GSWPw9mXZ6o9x20= X-MC-Unique: 5_5ArMo1NrSeKjRjobUXeQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 28/30] qemu_snapshot: enable deletion of external snapshots Date: Thu, 8 Dec 2022 14:31:04 +0100 Message-Id: <79f93415c2e1f89ce0831ea32835a35ac1b5cebe.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506447167100001 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 253de1196b..68acf54917 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3089,9 +3089,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.38.1 From nobody Fri May 17 09:01:44 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=1670506343; cv=none; d=zohomail.com; s=zohoarc; b=khqd4EaIN9WwzKp6uJdXQVKDuAnJG5m4v532IMzsCjUN/YpPBGRodLixB4xUOIGK5O7l0oj3uCNdptJ1OOb/Pj2d9e1GDlqiwdybOXKDWTlhKb8D5byJz3q9ZE5ZO5HlEVPya87lRX4oOKLdp57ry9kaYeGne8qhRH5PagQCj2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506343; 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=U6XczcvHn5CBtJdGABqVZPr0kagAB3NNb7tEK70rwCk=; b=Q/wfHc3lrGk6wa4u7G+64Q4oZnrnpFYbTGgg+t3ZwqYxrBHrKLsO7iPXrZBoEijLamjgAJZlOETgp0rASV5+IpIJLtbcUEESKaslIVyD+QgmWuLots50G5D7bI+YolgdSbHnXO5fbLV/C5Feze3IGvo+JouwbX9yhenJiV7QiZE= 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 1670506343139721.2546656747808; Thu, 8 Dec 2022 05:32:23 -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-624-jXhy0_8MMymRfb4vMs6QVw-1; Thu, 08 Dec 2022 08:32:17 -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 A7D8F823F6E; Thu, 8 Dec 2022 13:32:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9301E40C2064; Thu, 8 Dec 2022 13:32:00 +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 DB30E194707B; Thu, 8 Dec 2022 13:31:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B736C1947048 for ; Thu, 8 Dec 2022 13:31:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A4C8040C6EC3; Thu, 8 Dec 2022 13:31:35 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3ED8540C6EC2 for ; Thu, 8 Dec 2022 13:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506342; 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=U6XczcvHn5CBtJdGABqVZPr0kagAB3NNb7tEK70rwCk=; b=Qq411dvDY19d6qpxWkBmWMbpgrRCdCfUPifYaOAF8XpRwYkKYB2dR2XPIL4xvoRVbnDxWx 5orpQs/bux/VWV44chKdtwemyz5s4DTQZ99p2fj5PSIljPoJdziInEOx32fs5vHVRlYb/m /hecIaKkWyWDNuE+azK/t3DGQ8NRjHc= X-MC-Unique: jXhy0_8MMymRfb4vMs6QVw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 29/30] api: document support for external snapshot deletion Date: Thu, 8 Dec 2022 14:31:05 +0100 Message-Id: <7315944794dcb83271eb86983b795000e2169f15.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506344474100003 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.38.1 From nobody Fri May 17 09:01:44 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=1670506394; cv=none; d=zohomail.com; s=zohoarc; b=TymndkvmjMLY3vV/cmVltoBj+oNhC5xG+CMMrLSMwNYBA6o4wswOPFCFKKSS+0FuWMPsE/nk4+EkkMzYmtbUtXQuX+khddUCthh8J4+jWDqs7UR1fxmUEqHdCt167bWKjRWZW0MPsqnJ5/ZTMouk4A3Q8tYLC3YmpK68/FnqNrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670506394; 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=2rBFie5Vjadgpom/hU3KvAENANimsNIioV126H/Dv3g=; b=fjIMf/V38ikQDeJjhkX51G+sCBnzjGX7UhUzJ6q65f8/eefQKgPkcO1Z0leVOk4lIF6OLruN1Sm3Kc1OzIQk1GZySdYQlpOg2vH5KdML/7967cG4EOVJlVSKq3ReUGSIoJHiTt30br0Jk4cSzS8Bojla7HIsSIzQwcrMFXo+HlI= 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 1670506394569747.5313375592702; Thu, 8 Dec 2022 05:33:14 -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-544-ZGtM4GPwN0C7dsdA7-GJCw-1; Thu, 08 Dec 2022 08:32:20 -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 D8F603C38FE7; Thu, 8 Dec 2022 13:32:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3E5E1121331; Thu, 8 Dec 2022 13:32:13 +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 A63B61947B99; Thu, 8 Dec 2022 13:32:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 66FAF1947042 for ; Thu, 8 Dec 2022 13:31:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5642A40C6EC3; Thu, 8 Dec 2022 13:31:36 +0000 (UTC) Received: from localhost.localdomain (ovpn-194-45.brq.redhat.com [10.40.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3E7540C6EC2 for ; Thu, 8 Dec 2022 13:31:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670506393; 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=2rBFie5Vjadgpom/hU3KvAENANimsNIioV126H/Dv3g=; b=KSjrzqMmSR+q326bdEGksKb9nduBlstCxbYv4ViQO61hJ7GE0itzEbQ7rcGbuJmVwfyDAu buKexdAD5jW5fOmH+ptly7qzJOphwCxZMNbb6jqMKys360vVtPUN02bqEOq/Btv7zDlK7r noSxxLqfYKit1dD6avw67LsIa+0Qi0g= X-MC-Unique: ZGtM4GPwN0C7dsdA7-GJCw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 30/30] NEWS: document support for external snapshot deletion Date: Thu, 8 Dec 2022 14:31:06 +0100 Message-Id: <5a6635f245d9ff6543c20785555ee9ebc0e42ff2.1670505852.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1670506396719100002 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.38.1