From nobody Tue Oct 22 22:19:17 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=1692005884; cv=none; d=zohomail.com; s=zohoarc; b=NTuIHTMun4J67/pt21C26BmiWpAoq9wKiEUnpeBTBLgEriOcAaENtUJIru7bUM0iBKlrKE9TWn39qIZU5FFNUho4YtRgbi7tf4hKJWhppgDfhbIsC1ZlqTLBg+GSBPL4wWphIpwJJY+8aOInTAVPpDRkgLn4bujqx+ZbQaBX4E0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692005884; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R+z8ew8Ra5EqoVoSPD30/NmGVTN6yGdo/gff49BAd68=; b=OL02fjtbg7TjXBgX5uhvAFtbGpU/Scr6sXYyqwvAUkIMIaHXb73n9UvH9GtuN0v6uIAbrTLkJF/9aMTDDx9mLn5dcR77DX4WcCOFl5gnAz+Hqe4KLfzZDacmF+abHhOMX0wK99IhAhWY6oW5rASed2TtsGsCAJquisIL4xHoouk= 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 1692005884161923.8140004108868; Mon, 14 Aug 2023 02:38:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-AtZ4e16YOu-MejoLWP9J-g-1; Mon, 14 Aug 2023 05:36:54 -0400 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 551D38DC664; Mon, 14 Aug 2023 09:36: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 4276F492C14; Mon, 14 Aug 2023 09:36: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 1C2AF19452D2; Mon, 14 Aug 2023 09:36:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 98B4719465A4 for ; Mon, 14 Aug 2023 09:36:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6EE3E40C207F; Mon, 14 Aug 2023 09:36:28 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.226.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12D2140C207D for ; Mon, 14 Aug 2023 09:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692005883; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=R+z8ew8Ra5EqoVoSPD30/NmGVTN6yGdo/gff49BAd68=; b=Mm4YiJApH5OlwC3D6tbxGJ3UW9wh6yoqxNi7AjiXfLJ0ECHYmNnJne3LGxMkRhhmAbxZkl Jgn9NrOseW7t7Pl2UkeEau7kCjMSz407hOXF0+3Xiw8DdYAoF5LxT36BcEpTUxEiXj3CFI E57daGLhDNc1tM/QlfOXZphaSSe7fzw= X-MC-Unique: AtZ4e16YOu-MejoLWP9J-g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v3 16/25] qemu_snapshot: prepare data for non-active leaf external snapshot deletion Date: Mon, 14 Aug 2023 11:36:08 +0200 Message-ID: <10c3cfcbd1f0440e689d253ab285b82e57336f8a.1692005543.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.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: 1692005885361100001 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 | 55 +++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index d47dc72709..8b005cae8f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2759,34 +2759,43 @@ 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) + /* Leaf non-active snapshot doesn't have overlay files for the disk im= ages + * so there is no need to do any merge and we can just delete the files + * directly. */ + 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.41.0