From nobody Fri Dec 19 16:00:23 2025 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=1678722185; cv=none; d=zohomail.com; s=zohoarc; b=m494c6wlURAJx2P21NIcUzZNs1BbIqXLI8b0G5Lx2+wauKLeWbCjQ31xcpoR6DrT/O1mydmbgRUoON7yGEFJL0z418HMW7zz120F2ae25E7YxD3ME4oJ/9kq8Qb/k7AnwnYKWqZWo0IoadUnCcpFvTtoKYDWALYmyO7wcILbMFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678722185; 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=0QILdaFr7eqkuOLdNccsdxqiudZTKV8l6Rn3yOM+72E=; b=TszpFStu8sIIY5hxSGCaSh+MLA+uv+bpeByesELtqzeJqS/8fHkQq6egMvlJWPzE286DZME7t86Oab5ALqozjXcVJ6Qwm7PC/1B1pjshQGWeLQAvZwi6y1cvBz8VlB3vHJEkxqzpe2+40G5UixoM/8IvxSJznhbXdkBYHgKSYgI= 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 1678722185712243.24939591060797; Mon, 13 Mar 2023 08:43:05 -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-447-TNf0wEZtNImAQxFMVusYcg-1; Mon, 13 Mar 2023 11:42:54 -0400 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 E0CB73C10142; Mon, 13 Mar 2023 15:42:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4F1D1410F1B; Mon, 13 Mar 2023 15:42: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 8E7141946A46; Mon, 13 Mar 2023 15:42:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 00B22194658F for ; Mon, 13 Mar 2023 15:42:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E8D102166B2B; Mon, 13 Mar 2023 15:42:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.45.226.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BA8C2166B26 for ; Mon, 13 Mar 2023 15:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678722184; 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=0QILdaFr7eqkuOLdNccsdxqiudZTKV8l6Rn3yOM+72E=; b=LBjkA6MSm+nqPHt4CxSWET/8GToMAL6t9bCS7mO0VLydsrLPMVCui/C+M93wsL4E9S0i+U fC4NV2t2wY5cbt5Vn1L9+6KfUwaV+3dskn98WYocsQIA+EInvLI+65uzl+zFtUViVkraUW dwzDfkL45XdOLn/hOQz3GT1NgxUYaDA= X-MC-Unique: TNf0wEZtNImAQxFMVusYcg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 13/20] qemu_snapshot: prepare data for non-active leaf external snapshot deletion Date: Mon, 13 Mar 2023 16:42:14 +0100 Message-Id: <39b49b8714ff9784c30e2b2132184088ebc0ffb3.1678718987.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1678722187090100002 Content-Type: text/plain; charset="utf-8"; x-default="true" In this case there is no need to run block commit and using qemu process at all. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 52 ++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 6ff18d7a9e..be2e5c8cc4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2597,34 +2597,40 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, return 0; } =20 - /* this also serves as validation whether the snapshot can be deleted = */ - if (qemuSnapshotDeleteExternalPrepareData(vm, snap, true, &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, true, external= Data) < 0) + if (snap !=3D virDomainSnapshotGetCurrent(vm->snapshots) && + snap->nchildren =3D=3D 0) { + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, false, externa= lData) < 0) return -1; } else { - qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; + /* this also serves as validation whether the snapshot can be dele= ted */ + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, true, &tmpData= ) < 0) + return -1; =20 - *externalData =3D g_steal_pointer(&tmpData); + if (!virDomainObjIsActive(vm)) { + if (qemuProcessStart(NULL, driver, vm, NULL, VIR_ASYNC_JOB_SNA= PSHOT, + NULL, -1, NULL, NULL, + VIR_NETDEV_VPORT_PROFILE_OP_CREATE, + VIR_QEMU_PROCESS_START_PAUSED) < 0) { + return -1; + } =20 - /* If the VM is running we need to indicate that the async snapshot - * job is snapshot delete job. */ - jobPriv->snapshotDelete =3D true; + *stop_qemu =3D true; =20 - qemuDomainSaveStatus(vm); + /* Call the prepare again as some data require that the VM is + * running to get everything we need. */ + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, true, exte= rnalData) < 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 sna= pshot + * job is snapshot delete job. */ + jobPriv->snapshotDelete =3D true; + + qemuDomainSaveStatus(vm); + } } =20 return 0; --=20 2.39.2