From nobody Sun Feb 8 21:38:14 2026 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=1687878829; cv=none; d=zohomail.com; s=zohoarc; b=C4VpxvfFwv/+6fopVIKz11HBuKJ6ubvyuyBf0NR30Tfn43ic6BSzgRxko7FA5VSOnwPCXiWipXdjOBZUgQmvFrHCTIqNXKa3ozy62wkLtNfO5Cq+hutrsFujL0udsU0YxopkhsBWNVvdkEbqHYbU6lBEDKGagFtVGOZPI2TQZ6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878829; 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=EJvuCWzlpGFdfSusZRCd7kpiilaA5tnC7GWQZvzqVT0=; b=abFS7njS5+2VCJRZBIls1FGrcpkhR1fMfSDNXstu9MItM2Yt7bQCOyAl5SoHVsPLTGsaXKDvdPfAVnmFa1uaC5hJe/TK3PLmwWkT39teCWZ9KVrLJv73sT1tPR56FHyQ7S7vKAAOLAPioZ5mCsOqe/Jr3IIMhJ56X19D9Oc1ixA= 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 1687878829600483.34752597926126; Tue, 27 Jun 2023 08:13:49 -0700 (PDT) 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-108-R7FQQSVFOc-yOw1hYOCnzA-1; Tue, 27 Jun 2023 11:13:33 -0400 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 B96113802275; Tue, 27 Jun 2023 15:07:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A657340C2063; Tue, 27 Jun 2023 15:07:54 +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 8ED741946A6F; Tue, 27 Jun 2023 15:07:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 50F531949738 for ; Tue, 27 Jun 2023 15:07:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 47F5040140F; Tue, 27 Jun 2023 15:07:37 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFA5A400E88 for ; Tue, 27 Jun 2023 15:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878828; 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=EJvuCWzlpGFdfSusZRCd7kpiilaA5tnC7GWQZvzqVT0=; b=RM1q1bNyA3uQZAxH/3fgeE7Bk1qvfA3B+y9w3nFVRW1sWP7ILXRQo4Ouj0eoUdqsXK4MEB H5y2+C2AsMNFestSbAIyZV8h4NrUlp2phRfP4MRBIhWzQ8GlQTk2JyvJIHHJT5dWptnlhu WqwvgUymC6UsLszhLMse4qhOpqvVEyg= X-MC-Unique: R7FQQSVFOc-yOw1hYOCnzA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 14/24] qemu_snapshot: extract external snapshot delete prepare to function Date: Tue, 27 Jun 2023 17:07:17 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1687878830136100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This part of code is about to grow to make deletion work when user reverts to non-leaf snapshot. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 89 +++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c5de24917b..08cff2a9a2 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2653,6 +2653,58 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *= vm, } =20 =20 +static int +qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, + virDomainMomentObj *snap, + unsigned int flags, + GSList **externalData, + bool *stop_qemu) +{ + virQEMUDriver *driver =3D ((qemuDomainObjPrivate *) vm->privateData)->= driver; + g_autoslist(qemuSnapshotDeleteExternalData) tmpData =3D NULL; + + if (!virDomainSnapshotIsExternal(snap)) + return 0; + + if (flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY)) { + return 0; + } + + /* this also serves as validation whether the snapshot can be deleted = */ + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, &tmpData) < 0) + return -1; + + if (!virDomainObjIsActive(vm)) { + if (qemuProcessStart(NULL, driver, vm, NULL, VIR_ASYNC_JOB_SNAPSHO= T, + NULL, -1, NULL, NULL, + VIR_NETDEV_VPORT_PROFILE_OP_CREATE, + VIR_QEMU_PROCESS_START_PAUSED) < 0) { + return -1; + } + + *stop_qemu =3D true; + + /* Call the prepare again as some data require that the VM is + * running to get everything we need. */ + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, externalData) = < 0) + return -1; + } else { + qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; + + *externalData =3D g_steal_pointer(&tmpData); + + /* If the VM is running we need to indicate that the async snapshot + * job is snapshot delete job. */ + jobPriv->snapshotDelete =3D true; + + qemuDomainSaveStatus(vm); + } + + return 0; +} + + typedef struct _virQEMUMomentReparent virQEMUMomentReparent; struct _virQEMUMomentReparent { const char *dir; @@ -3423,40 +3475,9 @@ qemuSnapshotDelete(virDomainObj *vm, if (qemuSnapshotDeleteValidate(vm, snap, flags) < 0) goto endjob; =20 - if (virDomainSnapshotIsExternal(snap) && - !(flags & (VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | - VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY))) { - g_autoslist(qemuSnapshotDeleteExternalData) tmpData =3D NULL; - - /* this also serves as validation whether the snapshot can be = deleted */ - if (qemuSnapshotDeleteExternalPrepareData(vm, snap, &tmpData) = < 0) - goto endjob; - - 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. */ - if (qemuSnapshotDeleteExternalPrepareData(vm, snap, &exter= nalData) < 0) - goto endjob; - } else { - qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; - - externalData =3D g_steal_pointer(&tmpData); - - /* If the VM is running we need to indicate that the async= snapshot - * job is snapshot delete job. */ - jobPriv->snapshotDelete =3D true; - - qemuDomainSaveStatus(vm); - } + if (qemuSnapshotDeleteExternalPrepare(vm, snap, flags, + &externalData, &stop_qemu) <= 0) { + goto endjob; } } =20 --=20 2.41.0