From nobody Sat May 18 06:04:09 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=1687878834; cv=none; d=zohomail.com; s=zohoarc; b=S42DZqZ97+2YMZODGy55+8ZhQ7aiec4pEajsWiuhyz6xQ2qxlfyKldo99OZVIjgb/GADbkXBXcVKQJdf2ygvL1ZUsFZbgJmQ545kp1i8/LyTi+lVKRfZmJrqc2YEWuoQLG+StLPeno7FXSyvQIcdx5tMq55ApmVPP6lLEGVctqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878834; 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=IUP2lRbtCYvI9eRXsf8l37c20wL9SDV2L1yLhWhAnBI=; b=Caozb0qTVdgf0GRCHMPYpq3wDRl1VZAybhjeBGaGYDSGuinfJMsasazMLOFpa24uM4pkGKqZq7iaEZiY3yb33gSVizdCjCVDjp9V6aUiAcNE0cDqmY0Hn4usd/0+DqUKax2Csh+uiKia18sA5dT99mDey+CigPBDMxxrlf9WSCY= 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 1687878834200841.4198273173301; Tue, 27 Jun 2023 08:13:54 -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-361-JIDoPPy2MiiGHYiK1HqfBg-1; Tue, 27 Jun 2023 11:13:23 -0400 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 04B191991C6D; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD18340D1A4; Tue, 27 Jun 2023 15:07: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 A6F1A1946587; Tue, 27 Jun 2023 15:07:30 +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 65DAF1946586 for ; Tue, 27 Jun 2023 15:07:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 59D2C400E88; Tue, 27 Jun 2023 15:07:29 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1C9340140F for ; Tue, 27 Jun 2023 15:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878833; 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=IUP2lRbtCYvI9eRXsf8l37c20wL9SDV2L1yLhWhAnBI=; b=iQg87s5V9Q4gQiEAWIrjH7O3Ntcd67aAOgsFFL+PM73aYieNZ8dnZH6RYpiXooO5PfmFZs L81aWtQzP6S1kZz+5iAqieSUb1mzT0E9wAVFoP0tv54Bym618YDkqYCHtzVMhDZKQ69lOm CoEs3rqfrw924fa/0EgKHfov3JZLQxE= X-MC-Unique: JIDoPPy2MiiGHYiK1HqfBg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/24] libvirt_private: list virDomainMomentDefPostParse Date: Tue, 27 Jun 2023 17:07:04 +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.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: 1687878836162100003 Content-Type: text/plain; charset="utf-8"; x-default="true" We will need to call this function from qemu_snapshot when introducing external snapshot revert support. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fb7ad9c855..eed4c17d49 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -807,6 +807,10 @@ virInterfaceDefParseString; virInterfaceDefParseXML; =20 =20 +# conf/moment_conf.h +virDomainMomentDefPostParse; + + # conf/netdev_bandwidth_conf.h virDomainClearNetBandwidth; virNetDevBandwidthFormat; --=20 2.41.0 From nobody Sat May 18 06:04:09 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=1687878827; cv=none; d=zohomail.com; s=zohoarc; b=K0YEHknVfHBnJD6pAHhP7TfLZPQflcuLt20egneP2fyMNFhr8O1ZZkHQ4OJ6MoBmRuuyupVLGRYSSO+rRXXOs2KbQluXjh5sJTySbU5wcfzxhB7fzK/xbnTobUYkxIKPNs6XrjoNaCD6dXGT7b81WSTAX5Kw7gpU+4taKfMpjWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878827; 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=8puEFb6AbulNfiqhk5NLcyiLabeAMhjHt5lHvfrB4VE=; b=LoCq+tsYwyfZ3tMh/oZJCMfs67B9vPhpt4KmOoROrSYEPlTwnFGNdSSuvy7Fj14PhSpmuucHSd0jXEQgLv/bnzsbQUyR+CzhSWdB+4UTKjwF4VRgefFKBO9AjhGeMs9MJyZRpolVT35M72M/463IvxJFsZnV3dWNITvO6DMpVi8= 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 1687878827427234.16288009260893; Tue, 27 Jun 2023 08:13:47 -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-295-Ylmh_Da0PeWMNFWwQdfrOg-1; Tue, 27 Jun 2023 11:13:06 -0400 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 E36F510665C2; Tue, 27 Jun 2023 15:07:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D11EB111F3B6; Tue, 27 Jun 2023 15:07: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 5494E1946A7C; Tue, 27 Jun 2023 15:07:35 +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 278181946586 for ; Tue, 27 Jun 2023 15:07:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EEE4540140F; Tue, 27 Jun 2023 15:07:29 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9280A48FB01 for ; Tue, 27 Jun 2023 15:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878826; 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=8puEFb6AbulNfiqhk5NLcyiLabeAMhjHt5lHvfrB4VE=; b=XX0psL83IjVTSdmwGqpasb7QM6VX+FVJsiSsmlRIvKJaC8i0xL92gsbsdJ/iRdMXAh74RU 6yl5Xkm+ZNVEERabFOqO+ifBcQgSANTK+rGk8Lzm31EYThfwmh1+y5wlqfYKU+Ghl0Hpn0 XmCc3sMb3ptxZS4/+eRGzJ2V/1LpI8I= X-MC-Unique: Ylmh_Da0PeWMNFWwQdfrOg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/24] snapshot_conf: export virDomainSnapshotDiskDefClear Date: Tue, 27 Jun 2023 17:07:05 +0200 Message-ID: <8956a877501a920e974e7821e453e9f039be66a1.1687877087.git.phrdina@redhat.com> 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.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: 1687878829423100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We will need to call this function from qemu_snapshot when introducing external snapshot revert support. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/snapshot_conf.c | 2 +- src/conf/snapshot_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 0acba95d7f..cc59bddbc8 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -74,7 +74,7 @@ VIR_ENUM_IMPL(virDomainSnapshotState, ); =20 /* Snapshot Def functions */ -static void +void virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDef *disk) { VIR_FREE(disk->name); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 96c77ef42b..ad49990a1e 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -59,6 +59,9 @@ struct _virDomainSnapshotDiskDef { virStorageSource *src; }; =20 +void +virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDef *disk); + void virDomainSnapshotDiskDefFree(virDomainSnapshotDiskDef *disk); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index eed4c17d49..2b1d4e4512 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1037,6 +1037,7 @@ virDomainSnapshotDefFormat; virDomainSnapshotDefIsExternal; virDomainSnapshotDefNew; virDomainSnapshotDefParseString; +virDomainSnapshotDiskDefClear; virDomainSnapshotDiskDefFree; virDomainSnapshotDiskDefParseXML; virDomainSnapshotFormatConvertXMLFlags; --=20 2.41.0 From nobody Sat May 18 06:04:09 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=1687878781; cv=none; d=zohomail.com; s=zohoarc; b=VNmpiEk/S5LeyhlQOyv7rCzn4y+aSqzxwqfgF2xaBSp4G7/goukWsfnaUExbkL53O1IyjvGLy2ZDrkuxtt784AzqDLXHE7rYCPEo4yRsx1pmzYDMyxZFpWTnWz84VXrzhnW9YooHTNRGr0Tt1ASopr8weWodeAmCcCdFVDsyn8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878781; 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=qam5xeFztWJUQbV2Ep9yhW3YXlrPa2qmzvVIUxMwFwo=; b=egsiDCjgaP4gUHn8zNZM8iC4H+lpcL2H62F49DiUuQgF5x0C/Xbdotpcxa3vpfUMt/7K7kqfsUCw6FL+O4XW0kKPBOmhJ2b79l1u9ifg1326CQB6RaRMHzZEX/yddgSKYfJwJAPyGNyMxEkmqCL/61yoe8u0xODMf8yx4HZEg98= 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 1687878781325356.68797562342206; Tue, 27 Jun 2023 08:13:01 -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-534-veC25tJrNFmuhQY1PqfcyA-1; Tue, 27 Jun 2023 11:12:17 -0400 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 03E7E38470AB; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E35D40C6F5A; Tue, 27 Jun 2023 15:07: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 E8B2E1946588; Tue, 27 Jun 2023 15:07:31 +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 B125D194658C for ; Tue, 27 Jun 2023 15:07:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9016C4229B6; Tue, 27 Jun 2023 15:07:30 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32D2840140F for ; Tue, 27 Jun 2023 15:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878780; 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=qam5xeFztWJUQbV2Ep9yhW3YXlrPa2qmzvVIUxMwFwo=; b=LvcN6rYlSoCatsEUQUCco+1IP4Aw7lgMHv1tw0SAT59LN/sDvv9Uv8U1vY1D4Nm4QUr4fC skAebI2y6hYysv0nTqP7/9NEXUc5IAK1xZmqcU7hC0TEPaXzlspuNyfp3fJlImhYXLiRUI P21YAQgRGiAtbSMfxJpSYmIqlhm64h8= X-MC-Unique: veC25tJrNFmuhQY1PqfcyA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/24] snapshot_conf: use alternate domain definition in virDomainSnapshotDefAssignExternalNames Date: Tue, 27 Jun 2023 17:07:06 +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.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: 1687878782082100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Commit introduced new argument for virDomainSnapshotAlignDisks() that allows passing alternate domain definition in case the snapshot parent.dom is NULL. In case of redefining snapshot it will not hit the part of code that unconditionally uses parent.dom as there will not be need to generate default external file names. It should be still fixed to make it safe. Future external snapshot revert code will use this to generate default file names and in this case it would crash. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/snapshot_conf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index cc59bddbc8..ac5aba1753 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -486,12 +486,14 @@ virDomainSnapshotRedefineValidate(virDomainSnapshotDe= f *def, /** * virDomainSnapshotDefAssignExternalNames: * @def: snapshot def object + * @domdef: domain def object * * Generate default external file names for snapshot targets. Returns 0 on * success, -1 on error. */ static int -virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDef *def) +virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDef *def, + virDomainDef *domdef) { const char *origpath; char *tmppath; @@ -514,7 +516,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDef *def) return -1; } =20 - if (!(origpath =3D virDomainDiskGetSource(def->parent.dom->disks[i= ]))) { + if (!(origpath =3D virDomainDiskGetSource(domdef->disks[i]))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("cannot generate external snapshot name for d= isk '%1$s' without source"), disk->name); @@ -702,7 +704,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapd= ef, } =20 /* Generate default external file names for external snapshot location= s */ - if (virDomainSnapshotDefAssignExternalNames(snapdef) < 0) + if (virDomainSnapshotDefAssignExternalNames(snapdef, domdef) < 0) return -1; =20 return 0; --=20 2.41.0 From nobody Sat May 18 06:04:09 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=1687878857; cv=none; d=zohomail.com; s=zohoarc; b=eNIW8H/TgjhiyHD5xIJDdChCfN34WisxpfpH27Fwhj8vU+zdddaZL9drFMV0CbhoQTpRZNaBEOUXLB+Y07sh06dTsc6+QGYYqzW2dheRuBM3soKJwRisaj6Cm7SkIaIcVAEApIK4A9I4iIckG3DhnMBzfGSpDOfdOE4s4KFleiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878857; 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=pcAC6V4VLheJPPyfI3vyGCsvSaw991onFN5Lqi2jdCU=; b=dOLAcJ0AG6MelWKeNR3nmViCnCaa+b168CYrEI6R+IIN4BrObKhjZZOXzFR/lS6d/H3y3V1um6VfqF4BgY7LRlBXlLjD8UTRRPzQMqNwbY7/xQVIw4FPE3P0Xw/A/QW75RE2DHVxD+kx7OBbcSSF3SYy1tYeBKL6ZRhrzzcw0bo= 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 1687878857605131.94799391502704; Tue, 27 Jun 2023 08:14:17 -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-261-xOyCcupqOeGiWmgzintqkA-1; Tue, 27 Jun 2023 11:13: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 5195B1869B70; Tue, 27 Jun 2023 15:07:41 +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 3E4F448FB02; Tue, 27 Jun 2023 15:07: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 8D36319451C4; Tue, 27 Jun 2023 15:07:35 +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 5D8101946586 for ; Tue, 27 Jun 2023 15:07:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3057C400E88; Tue, 27 Jun 2023 15:07:31 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8B3540140F for ; Tue, 27 Jun 2023 15:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878856; 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=pcAC6V4VLheJPPyfI3vyGCsvSaw991onFN5Lqi2jdCU=; b=FUl/AH5+Vvz+1E0R3yOULAfZ3/u0X5WZAalXNJG0RY1KBooWhIyZ4+jvC21a1U1HWPz+Lx 2InAyOimVDuGf7ewzxJoHCMuTlk7wDXTtETeFf9/J+VjZod8FZS5UUFSLKbT2nuz2/miQX KxddQo2LH+wS4u/J/QmMAn67TaRF8nA= X-MC-Unique: xOyCcupqOeGiWmgzintqkA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/24] snapshot_conf: introduce metadata element Date: Tue, 27 Jun 2023 17:07:07 +0200 Message-ID: <89c0f82045e9b7d627becf9247694a7c8c258746.1687877087.git.phrdina@redhat.com> 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.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: 1687878864458100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This new element will hold the new disk overlay created when reverting to non-leaf snapshot in order to remember the files libvirt created. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/schemas/domainsnapshot.rng | 7 +++++++ src/conf/snapshot_conf.c | 27 +++++++++++++++++++++++++++ src/conf/snapshot_conf.h | 5 +++++ 3 files changed, 39 insertions(+) diff --git a/src/conf/schemas/domainsnapshot.rng b/src/conf/schemas/domains= napshot.rng index 45f01b96cd..2549c47b22 100644 --- a/src/conf/schemas/domainsnapshot.rng +++ b/src/conf/schemas/domainsnapshot.rng @@ -60,6 +60,13 @@ + + + + + + + diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index ac5aba1753..f6725c0e7b 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -376,6 +376,22 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, return NULL; } =20 + if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) { + g_autofree xmlNodePtr *revertDiskNodes =3D NULL; + + if ((n =3D virXPathNodeSet("./revertDisks/*", ctxt, &revertDiskNod= es)) < 0) + return NULL; + if (n) + def->revertdisks =3D g_new0(virDomainSnapshotDiskDef, n); + def->nrevertdisks =3D n; + for (i =3D 0; i < def->nrevertdisks; i++) { + if (virDomainSnapshotDiskDefParseXML(revertDiskNodes[i], ctxt, + &def->revertdisks[i], + flags, xmlopt) < 0) + return NULL; + } + } + if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL) { int active; =20 @@ -834,6 +850,17 @@ virDomainSnapshotDefFormatInternal(virBuffer *buf, virBufferAddLit(buf, "\n"); } =20 + if (def->nrevertdisks > 0) { + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + + for (i =3D 0; i < def->nrevertdisks; i++) { + if (virDomainSnapshotDiskDefFormat(&childBuf, &def->revertdisk= s[i], xmlopt) < 0) + return -1; + } + + virXMLFormatElement(buf, "revertDisks", NULL, &childBuf); + } + if (def->parent.dom) { if (virDomainDefFormatInternal(def->parent.dom, xmlopt, buf, domainflags) < 0) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index ad49990a1e..ab76af604a 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -80,6 +80,11 @@ struct _virDomainSnapshotDef { size_t ndisks; /* should not exceed dom->ndisks */ virDomainSnapshotDiskDef *disks; =20 + /* When we revert to non-leaf snapshot we need to + * store the new overlay disks. */ + size_t nrevertdisks; + virDomainSnapshotDiskDef *revertdisks; + virObject *cookie; }; =20 --=20 2.41.0 From nobody Sat May 18 06:04:09 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=1687878860; cv=none; d=zohomail.com; s=zohoarc; b=Qu+r74oquc4Kw7He3/pAQ4+BQAF2cNReWeHAnGW8MqMcDEO525mE+lRq+3Z12cQq3QNmaAekqMZaY5mybWJPDNi9n70u2IMro0SJaici9u1v16p/Bx5FiMssIc6ktlDcreTPodJgjneGChzLTtBwtdG1rdGoVdyj+cfSCFRxx00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878860; 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=MIyX/qYNu8EH3jJ82ecKCECOgNmu8MGCUkCz/9uBd7s=; b=m4WTUZ4MfUkt6ijR3BX5W2Y7jl1xczSLOJ2Y+X8TA4/IyEiin5OtpGRdvNtSf+UjkTCToOblzGqGosEPLWWVZwgtqyvCHOQpu+g4R7m+orsN5xe4Xyo8XOfmugWBtDBSaKnJKXHpRKgtKPW+IKbCQ8B4JFPypFdjRTn2XsIacjc= 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 1687878860287297.08025729955546; Tue, 27 Jun 2023 08:14:20 -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-445-AeWUWBbBMWe1nQCQkdX_MQ-1; Tue, 27 Jun 2023 11:13:24 -0400 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 472B510726D9; Tue, 27 Jun 2023 15:07:42 +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 3098CC00049; Tue, 27 Jun 2023 15:07:42 +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 C62FC19451CC; Tue, 27 Jun 2023 15:07:35 +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 F1A3319465B1 for ; Tue, 27 Jun 2023 15:07:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C4DEE429543; Tue, 27 Jun 2023 15:07:31 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68D804229B6 for ; Tue, 27 Jun 2023 15:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878857; 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=MIyX/qYNu8EH3jJ82ecKCECOgNmu8MGCUkCz/9uBd7s=; b=dFs2IdbmpI/4CXc9PSR/yj3Q3Gu+A0dqyMEZFS273X6pdgz2TnpIhbUaNc308wZtg+bmdf W805ar/VmmPVVPSJfXjanYXg+iAq6Q+aA1fWXEuled2aXLkIKNh2unTp0VEtGVFNa3KTPw q+eP3u+d1jQUKyg3CmRob6aaxogSd8o= X-MC-Unique: AeWUWBbBMWe1nQCQkdX_MQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/24] snapshot_conf: add new argument to virDomainSnapshotAlignDisks Date: Tue, 27 Jun 2023 17:07:08 +0200 Message-ID: <322f30a38fa3a4e7a6ef9b1161a07da4b74f0d6e.1687877087.git.phrdina@redhat.com> 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.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: 1687878862163100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This new option will be used by external snapshot revert code. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/snapshot_conf.c | 15 ++++++++++++--- src/conf/snapshot_conf.h | 3 ++- src/qemu/qemu_snapshot.c | 2 +- src/test/test_driver.c | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f6725c0e7b..d8ebf786cf 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -578,6 +578,8 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDef *def, * @default_snapshot: snapshot location to assign to disks which don't hav= e any * @uniform_internal_snapshot: Require that for an internal snapshot all d= isks * take part in the internal snapshot + * @force_default_location: Always use @default_snapshot even if domain def + * has different default value * * Align snapdef->disks to domain definition, filling in any missing disks= or * snapshot state defaults given by the domain, with a fallback to @@ -595,6 +597,10 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnaps= hotDef *def, * in the internal snapshot. This is for hypervisors where granularity of = an * internal snapshot can't be controlled. * + * When @force_default_location is true we will always use @default_snapsh= ot + * even if domain definition has different default set. This is required to + * create new snapshot definition when reverting external snapshots. + * * Convert paths to disk targets for uniformity. * * On error -1 is returned and a libvirt error is reported. @@ -603,7 +609,8 @@ int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapdef, virDomainDef *existingDomainDef, virDomainSnapshotLocation default_snapshot, - bool uniform_internal_snapshot) + bool uniform_internal_snapshot, + bool force_default_location) { virDomainDef *domdef =3D snapdef->parent.dom; g_autoptr(GHashTable) map =3D virHashNew(NULL); @@ -711,7 +718,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapd= ef, /* Don't snapshot empty drives */ if (virStorageSourceIsEmpty(domdef->disks[i]->src)) snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_NO; - else + else if (!force_default_location) snapdisk->snapshot =3D domdef->disks[i]->snapshot; =20 snapdisk->src->type =3D VIR_STORAGE_TYPE_FILE; @@ -967,8 +974,10 @@ virDomainSnapshotRedefinePrep(virDomainObj *vm, virDomainSnapshotDefIsExternal(snapdef)) align_location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; =20 - if (virDomainSnapshotAlignDisks(snapdef, otherDomDef, align_location, = true) < 0) + if (virDomainSnapshotAlignDisks(snapdef, otherDomDef, align_location, + true, false) < 0) { return -1; + } =20 return 0; } diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index ab76af604a..14254d1c86 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -126,7 +126,8 @@ char *virDomainSnapshotDefFormat(const char *uuidstr, int virDomainSnapshotAlignDisks(virDomainSnapshotDef *snapshot, virDomainDef *existingDomainDef, virDomainSnapshotLocation default_snapshot, - bool uniform_internal_snapshot); + bool uniform_internal_snapshot, + bool force_default_location); =20 bool virDomainSnapshotDefIsExternal(virDomainSnapshotDef *def); bool virDomainSnapshotIsExternal(virDomainMomentObj *snap); diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 91de8b0c31..844b02d427 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1585,7 +1585,7 @@ qemuSnapshotCreateAlignDisks(virDomainObj *vm, else def->memory =3D VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } - if (virDomainSnapshotAlignDisks(def, NULL, align_location, true) < 0) + if (virDomainSnapshotAlignDisks(def, NULL, align_location, true, false= ) < 0) return -1; =20 return 0; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e7fce053b4..83d97e629c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8721,7 +8721,7 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL; } =20 - return virDomainSnapshotAlignDisks(def, NULL, align_location, true); + return virDomainSnapshotAlignDisks(def, NULL, align_location, true, fa= lse); } =20 =20 --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878835; cv=none; d=zohomail.com; s=zohoarc; b=gM6B+QTjVXEArjdjpoz3x5VjboU9CfSd45ZbKIO3RXr+bDeQzy06zmBVTMMNXCfZj4diydhGhb/vJ2+cEk4NU8BC3wTSuPQ5EUde+R9VNnL9pj7xZ6cEOkcVrTJZQagbYv91F3Wu29ge++b2pX/fRtf8ImWKbbRITDrzIrq7sfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878835; 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=xyv7w5pFBOuTwmP/dkcpLwPBcqaR/kuT6E1NlX/d9a4=; b=OyfFiZg7nPb3sS57QQbFOZqjcxkbsj/7sMxRWlS+X/S3DlGlBUew1IG9K6waXHeV1wmVkinHSbkerqLz/1yMpD8E3OShcMzsuslsyIcozK4ytDHnX5SwuKMD4aD8jm2lu2G4AYbXDxl8s6j/A2Rkv8/44+RjXm6GZCoa7UGaPWo= 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 1687878835591483.31414283314075; Tue, 27 Jun 2023 08:13:55 -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-544-_WSLStpAOFSU5YGqp8mxdQ-1; Tue, 27 Jun 2023 11:13:03 -0400 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 714291C09A71; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A291C478C8; Tue, 27 Jun 2023 15:07: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 2AC9A1946587; Tue, 27 Jun 2023 15:07:33 +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 6FE9E1946589 for ; Tue, 27 Jun 2023 15:07:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 64232400E88; Tue, 27 Jun 2023 15:07:32 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 090CC40140F for ; Tue, 27 Jun 2023 15:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878829; 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=xyv7w5pFBOuTwmP/dkcpLwPBcqaR/kuT6E1NlX/d9a4=; b=KDeDh/BkzvOlOir0J8P4Fd1uZsmwciztY1vkjMKviWYA75EuSyqGAR+zZgtkCDB14Me6sx jujnq3zYCTrU0mGK6rd+Gr1crNTUvJrefFNeIcGy27Yg/JhH8jM2n9CxbSbBFKD9KT3jZo KiwY0SFzfx2oPNbjshaDN3hsNH+1ue4= X-MC-Unique: _WSLStpAOFSU5YGqp8mxdQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/24] qemu_snapshot: introduce qemuSnapshotDomainDefUpdateDisk Date: Tue, 27 Jun 2023 17:07:09 +0200 Message-ID: <5f50384d0ea292635bc3a0c4665abd502d8c3144.1687877087.git.phrdina@redhat.com> 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.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: 1687878835861100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Extract the code that updates disks in domain definition while creating external snapshots. We will use it later in the external snapshot revert code. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 63 ++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 844b02d427..72a0f71d4f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -142,6 +142,42 @@ qemuSnapshotFSThaw(virDomainObj *vm, } =20 =20 +static int +qemuSnapshotDomainDefUpdateDisk(virDomainDef *domdef, + virDomainSnapshotDef *snapdef, + bool reuse) +{ + size_t i; + + for (i =3D 0; i < snapdef->ndisks; i++) { + g_autoptr(virStorageSource) newsrc =3D NULL; + virDomainSnapshotDiskDef *snapdisk =3D &(snapdef->disks[i]); + virDomainDiskDef *defdisk =3D domdef->disks[i]; + + if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) + continue; + + if (!(newsrc =3D virStorageSourceCopy(snapdisk->src, false))) + return -1; + + if (virStorageSourceInitChainElement(newsrc, defdisk->src, false) = < 0) + return -1; + + if (!reuse && + virStorageSourceHasBacking(defdisk->src)) { + defdisk->src->readonly =3D true; + newsrc->backingStore =3D g_steal_pointer(&defdisk->src); + } else { + virObjectUnref(defdisk->src); + } + + defdisk->src =3D g_steal_pointer(&newsrc); + } + + return 0; +} + + /* The domain is expected to be locked and inactive. */ static int qemuSnapshotCreateInactiveInternal(virQEMUDriver *driver, @@ -216,31 +252,8 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *driv= er, } =20 /* update disk definitions */ - for (i =3D 0; i < snapdef->ndisks; i++) { - g_autoptr(virStorageSource) newsrc =3D NULL; - - snapdisk =3D &(snapdef->disks[i]); - defdisk =3D vm->def->disks[i]; - - if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) - continue; - - if (!(newsrc =3D virStorageSourceCopy(snapdisk->src, false))) - goto cleanup; - - if (virStorageSourceInitChainElement(newsrc, defdisk->src, false) = < 0) - goto cleanup; - - if (!reuse && - virStorageSourceHasBacking(defdisk->src)) { - defdisk->src->readonly =3D true; - newsrc->backingStore =3D g_steal_pointer(&defdisk->src); - } else { - virObjectUnref(defdisk->src); - } - - defdisk->src =3D g_steal_pointer(&newsrc); - } + if (qemuSnapshotDomainDefUpdateDisk(vm->def, snapdef, reuse) < 0) + goto cleanup; =20 if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0) goto cleanup; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687879598; cv=none; d=zohomail.com; s=zohoarc; b=hkKGic8iTixvGyiBFe0astx51QoEXCPUaowwXqceR0vANVn1yB87TmhDk+JDRowd0a2E5YVRuS9U40occDGCimXGr+wtqTEHM7eGd2moYdbklGO7HoYAVGDe5AEbktcWKFd7M9yIEkwpWAKw2bfJXYYkZMO2cEy7Z+ApvSz3JfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879598; 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=KEH6nhUmhscP/MylJEv+o4MZaO8JpyVv5X7Y8bE6Zdw=; b=g+62yA28B6acDnv9KuYJJkbemQbxtjBNNTIifhoFGuActQ2ubdNBkmTgU8jP81Fy3HJKHXaCcRb4xB75bn3QtC4FTFBoGLvo8KfCsx2vpIP63dORNu4xawScH5i/UKR0cEsvQtkl50tGBsudMK5iH4uSXfJ5f2YmBBMnXSdRlAw= 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 1687879597983864.4235354090177; Tue, 27 Jun 2023 08:26:37 -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-595-WLiHqocuNWWtQsCZJhY_OA-1; Tue, 27 Jun 2023 11:22:43 -0400 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 C30CC8870D5; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE631425368; Tue, 27 Jun 2023 15:07: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 765641946A78; Tue, 27 Jun 2023 15:07:34 +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 163C21946587 for ; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0520F48FB01; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D2D6400E88 for ; Tue, 27 Jun 2023 15:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687879592; 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=KEH6nhUmhscP/MylJEv+o4MZaO8JpyVv5X7Y8bE6Zdw=; b=MQQJB/iYb/jd6ue0x9VGYW6vz/onEpzdplhkku14Gtw7F9xqbj5NpGW3igHJA1MIwM+Qbp tArAp2pwEfxE+OaQO42GdymMAOREVzav1TWobA3PVN3JTqjAfjhaEgP/033eiZlsgrd87j Ar0tNFwaE02X47H3HyQpPcxX3R/VBvs= X-MC-Unique: WLiHqocuNWWtQsCZJhY_OA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/24] qemu_snapshot: use virDomainDiskByName while updating domain def Date: Tue, 27 Jun 2023 17:07:10 +0200 Message-ID: <63f65501fd1fb6c74f91693645bc4564cbe1b123.1687877087.git.phrdina@redhat.com> 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.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: 1687879599161100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When creating external snapshot this function is called only when the VM is not running so there is only one definition to care about. However, it will be used by external snapshot revert code for active and inactive definition and they may be different if a disk was (un)plugged only for the active or inactive definition. The current code would crash so use virDomainDiskByName() to get the correct disk from the domain definition based on the disk name and make sure it exists. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 72a0f71d4f..8e1eb21b5d 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -152,11 +152,14 @@ qemuSnapshotDomainDefUpdateDisk(virDomainDef *domdef, for (i =3D 0; i < snapdef->ndisks; i++) { g_autoptr(virStorageSource) newsrc =3D NULL; virDomainSnapshotDiskDef *snapdisk =3D &(snapdef->disks[i]); - virDomainDiskDef *defdisk =3D domdef->disks[i]; + virDomainDiskDef *defdisk =3D virDomainDiskByName(domdef, snapdisk= ->name, false); =20 if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) continue; =20 + if (!defdisk) + continue; + if (!(newsrc =3D virStorageSourceCopy(snapdisk->src, false))) return -1; =20 --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687879306; cv=none; d=zohomail.com; s=zohoarc; b=WJG6tMkNdBouihgl/9BpnEASFSDV2awmQc+9sksrIrUPaZXxy4VD/P9wIrszXUuvF5SIU0s58eMKwDXlGVFjQLE2+kOA0aEWLz+7MsXmLyHHgRnbzPt4bawGaxxBuq7t0I3ncQgfrTwFjrZV0Qp20jwYVDva4/x/bfaO9OpSvM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879306; 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=TsMkPcSh1jBR1HHHd29sQh9xUOdIq/xTFfCQoPTR1f8=; b=EKRAu7jGEKYM1RDi718VUoWwO3mGMdqSkxqw4eVRYlon6pf4WZzVuwv2ZaHECaTraCaq4h0UGBFxWsTe0TOJZ7Lv2bD0GY5lpdUKTq9/TR4373ooXZ+INi386gwLENyExE/PiEMjig9tsrcdhlDNTVBM6T4JxDtGuc/89msq4WM= 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 1687879306759633.4676328015003; Tue, 27 Jun 2023 08:21:46 -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-16-V8MlMKNqNSmT-OCG-Qs_dQ-1; Tue, 27 Jun 2023 11:18:09 -0400 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 CA0F58E7687; Tue, 27 Jun 2023 15:07:42 +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 AF3E040BB4D; Tue, 27 Jun 2023 15:07:42 +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 084A219451D8; Tue, 27 Jun 2023 15:07:36 +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 AAC711946587 for ; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9A1F4400E88; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DCA840140F for ; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687879305; 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=TsMkPcSh1jBR1HHHd29sQh9xUOdIq/xTFfCQoPTR1f8=; b=O6Z99Be4saHYQOEIBD99HIZGfes6E6lXwl+652Mtn/i8wXS8GS3w7G1w+5XZXKBOim6Gls n20ZBYXmTaLAonFmmwa78qjXJAashlGqiP5qCZ/tQ9PiXOEkFUAo9L//6JIYH7OTgMvRAG WXB/qIA3wfnWOpyHdRCrD9BiIpe+njY= X-MC-Unique: V8MlMKNqNSmT-OCG-Qs_dQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/24] qemu_snapshot: introduce qemuSnapshotCreateQcow2Files Date: Tue, 27 Jun 2023 17:07:11 +0200 Message-ID: <6e1175cabd4be0f6810d0412965ee21cdb083a83.1687877087.git.phrdina@redhat.com> 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.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: 1687879307162100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Extract creation of qcow2 files for external snapshots to separate function as we will need it for external snapshot revert code. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 67 +++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 8e1eb21b5d..227c201195 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -181,35 +181,21 @@ qemuSnapshotDomainDefUpdateDisk(virDomainDef *domdef, } =20 =20 -/* The domain is expected to be locked and inactive. */ static int -qemuSnapshotCreateInactiveInternal(virQEMUDriver *driver, - virDomainObj *vm, - virDomainMomentObj *snap) -{ - return qemuDomainSnapshotForEachQcow2(driver, vm->def, snap, "-c", fal= se); -} - - -/* The domain is expected to be locked and inactive. */ -static int -qemuSnapshotCreateInactiveExternal(virQEMUDriver *driver, - virDomainObj *vm, - virDomainMomentObj *snap, - bool reuse) +qemuSnapshotCreateQcow2Files(virDomainObj *vm, + virDomainSnapshotDef *snapdef, + virBitmap *created, + bool reuse) { size_t i; - virDomainSnapshotDiskDef *snapdisk; - virDomainDiskDef *defdisk; const char *qemuImgPath; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - int ret =3D -1; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); - g_autoptr(virBitmap) created =3D virBitmapNew(snapdef->ndisks); + virQEMUDriver *driver =3D ((qemuDomainObjPrivate *) vm->privateData)->= driver; + virDomainSnapshotDiskDef *snapdisk =3D NULL; + virDomainDiskDef *defdisk =3D NULL; =20 if (!(qemuImgPath =3D qemuFindQemuImgBinary(driver))) - goto cleanup; + return -1; =20 /* If reuse is true, then qemuSnapshotPrepare already * ensured that the new files exist, and it was up to the user to @@ -218,6 +204,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *drive= r, g_autoptr(virCommand) cmd =3D NULL; snapdisk =3D &(snapdef->disks[i]); defdisk =3D vm->def->disks[i]; + if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) continue; =20 @@ -225,7 +212,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *drive= r, snapdisk->src->format =3D VIR_STORAGE_FILE_QCOW2; =20 if (qemuDomainStorageSourceValidateDepth(defdisk->src, 1, defdisk-= >dst) < 0) - goto cleanup; + return -1; =20 /* creates cmd line args: qemu-img create -f qcow2 -o */ if (!(cmd =3D virCommandNewArgList(qemuImgPath, @@ -234,7 +221,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *drive= r, virStorageFileFormatTypeToString(= snapdisk->src->format), "-o", NULL))) - goto cleanup; + return -1; =20 /* adds cmd line arg: backing_fmt=3Dformat,backing_file=3D/path/to= /backing/file */ virBufferAsprintf(&buf, "backing_fmt=3D%s,backing_file=3D", @@ -251,9 +238,39 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *driv= er, ignore_value(virBitmapSetBit(created, i)); =20 if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; } =20 + return 0; +} + + +/* The domain is expected to be locked and inactive. */ +static int +qemuSnapshotCreateInactiveInternal(virQEMUDriver *driver, + virDomainObj *vm, + virDomainMomentObj *snap) +{ + return qemuDomainSnapshotForEachQcow2(driver, vm->def, snap, "-c", fal= se); +} + + +/* The domain is expected to be locked and inactive. */ +static int +qemuSnapshotCreateInactiveExternal(virQEMUDriver *driver, + virDomainObj *vm, + virDomainMomentObj *snap, + bool reuse) +{ + virDomainSnapshotDiskDef *snapdisk; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + int ret =3D -1; + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + g_autoptr(virBitmap) created =3D virBitmapNew(snapdef->ndisks); + + if (qemuSnapshotCreateQcow2Files(vm, snapdef, created, reuse) < 0) + goto cleanup; + /* update disk definitions */ if (qemuSnapshotDomainDefUpdateDisk(vm->def, snapdef, reuse) < 0) goto cleanup; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878940; cv=none; d=zohomail.com; s=zohoarc; b=cERseYYbWz/iGJhMdyhn/U339ljiiGulk685w5+V7SKERe7xJYPiC8I2sbCKHkPor/WHEZ94qS6mnSLT6TGnqEfqdFwlbj/SjTgMHvYExJNv6pc8G993PkmrOtu4V7MVlzuPbpZgL0KUKhto6eKOO3r3bcXcRBKBestvbD1hHXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878940; 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=R3Ea8bTatGjccdzL289eEr7LSIaPuKSKEqN7S8K4YSw=; b=ZiKGXme7WH/RWihm62q/jS4l7Tpke0//Hx0EtjJVUFA5bBZgqUQqdLe9McIJ3ZQuZ/vGwPs8B6njadwZ/TEHDJAQ5FKZvFkksgxj0oPoDA6wwwmXxxKHpZ1UyMdsEgwaULbh3APYFJzzphtewmDc+GRpfdmILcS4Ggl5rlEcBc4= 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 1687878940356160.05702358245276; Tue, 27 Jun 2023 08:15:40 -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-201-I05N283-OM6VOw_D-mRcpA-1; Tue, 27 Jun 2023 11:15:13 -0400 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 DCB0A8E2D41; Tue, 27 Jun 2023 15:07:57 +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 C36082166B25; Tue, 27 Jun 2023 15:07: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 05546194975A; Tue, 27 Jun 2023 15:07:40 +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 4A0961946587 for ; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3A1A54229B6; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D295748FB01 for ; Tue, 27 Jun 2023 15:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878938; 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=R3Ea8bTatGjccdzL289eEr7LSIaPuKSKEqN7S8K4YSw=; b=ZGkKuYUY4uedc+ruN/Bs5RUf11CLbqM6cepFeZm2QaBJOA0h5yNVJSWQ8D4Ksm7liMoUwW 8pQd51VkWVb1VqH3fCeArcuryDDIgl1m7x0pH0GH53/v69BnN/Aa/FJsQ4QfcRM33faf0T xDEVvZPlVlApesdgjNgk8qe1G8Rl1/E= X-MC-Unique: I05N283-OM6VOw_D-mRcpA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 09/24] qemu_snapshot: allow using alternate domain definition when creating qcow2 files Date: Tue, 27 Jun 2023 17:07:12 +0200 Message-ID: <1c00c05e19be1cb32fbcb46e9ac9b3603008ef8a.1687877087.git.phrdina@redhat.com> 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.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: 1687878941080100001 Content-Type: text/plain; charset="utf-8"; x-default="true" To create new overlay files when external snapshot revert support is introduced we will be using different domain definition than what is currently used by the domain. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 227c201195..069c4c8ba7 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -183,6 +183,7 @@ qemuSnapshotDomainDefUpdateDisk(virDomainDef *domdef, =20 static int qemuSnapshotCreateQcow2Files(virDomainObj *vm, + virDomainDef *def, virDomainSnapshotDef *snapdef, virBitmap *created, bool reuse) @@ -194,6 +195,9 @@ qemuSnapshotCreateQcow2Files(virDomainObj *vm, virDomainSnapshotDiskDef *snapdisk =3D NULL; virDomainDiskDef *defdisk =3D NULL; =20 + if (!def) + def =3D vm->def; + if (!(qemuImgPath =3D qemuFindQemuImgBinary(driver))) return -1; =20 @@ -203,7 +207,7 @@ qemuSnapshotCreateQcow2Files(virDomainObj *vm, for (i =3D 0; i < snapdef->ndisks && !reuse; i++) { g_autoptr(virCommand) cmd =3D NULL; snapdisk =3D &(snapdef->disks[i]); - defdisk =3D vm->def->disks[i]; + defdisk =3D def->disks[i]; =20 if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) continue; @@ -268,7 +272,7 @@ qemuSnapshotCreateInactiveExternal(virQEMUDriver *drive= r, virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); g_autoptr(virBitmap) created =3D virBitmapNew(snapdef->ndisks); =20 - if (qemuSnapshotCreateQcow2Files(vm, snapdef, created, reuse) < 0) + if (qemuSnapshotCreateQcow2Files(vm, NULL, snapdef, created, reuse) < = 0) goto cleanup; =20 /* update disk definitions */ --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878844; cv=none; d=zohomail.com; s=zohoarc; b=CwfhjoWh6NIHY2fF/cIaBR1HBMvXv7U1AEXRnu/9QOdChlI+UyV+z8PAf07mSHA90JH5cw2uBsXIveWSE/orh8Z4PTd6Ei79PcnnpJ8CEwpHGX2owfJbzsTB2AzglT2i9Q4g3KesrSHBf7Iq2z/Ms4tjo929gsKLEa6ghfT0gNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878844; 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=b9Ga8OWEhj7aXgC4Hm7MPzz25IQbjb6GJ99jMZ7FKUQ=; b=eCqOgMQDeqh4EWdR/rMvKFIJSsqw8Xjxzs3ZzHurXHf2KsIT+hpwmCZwrHUwbyombbyB4psqx8d3udBlOijQdy/XIxLQnVVbFiamHKemRXlBHH0bami6F3A3XuyA9n3+UKjK7LsC3xA86chmL3BoGHXP+fDdkHLGh8s81OtxzKs= 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 1687878844407471.8079982930162; Tue, 27 Jun 2023 08:14: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-302-nNMbfHmzNdyMTIwd-BzWUA-1; Tue, 27 Jun 2023 11:13:40 -0400 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 DA1A2108BDCD; Tue, 27 Jun 2023 15:07:48 +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 C63E3C478C8; Tue, 27 Jun 2023 15:07:48 +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 41B6019451FC; Tue, 27 Jun 2023 15:07:37 +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 DE8F21946588 for ; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CF1CA400E88; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73D9448FB01 for ; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878843; 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=b9Ga8OWEhj7aXgC4Hm7MPzz25IQbjb6GJ99jMZ7FKUQ=; b=K7mquY7CMlqVaFMoWeYMptwj2L/tmXkv4tlk0YvAe5eHkmQNwq785dCoEZKGHwbZMgThIv MOKrcFqJb39SqNs2oTfd+7BTi3Il5Ccs2x7whVP3SQmbL+qTWWUi1XLA0zq63CrXHCfIZQ JMufa3zQcqSotnLu8jcOUf6o9rehy+s= X-MC-Unique: nNMbfHmzNdyMTIwd-BzWUA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/24] qemu_snapshot: move external disk prepare to single function Date: Tue, 27 Jun 2023 17:07:13 +0200 Message-ID: <5dd584843c3fdff751d1f248d3f61b723786eeeb.1687877087.git.phrdina@redhat.com> 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.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: 1687878845901100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We will need to reuse the functionality when reverting external snapshots. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 069c4c8ba7..5d2ffdeee6 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -520,6 +520,25 @@ qemuSnapshotPrepareDiskExternal(virDomainDiskDef *disk, bool active, bool reuse) { + if (!snapdisk->src->format) { + snapdisk->src->format =3D VIR_STORAGE_FILE_QCOW2; + } else if (snapdisk->src->format !=3D VIR_STORAGE_FILE_QCOW2 && + snapdisk->src->format !=3D VIR_STORAGE_FILE_QED) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("external snapshot format for disk %1$s is unsupp= orted: %2$s"), + snapdisk->name, + virStorageFileFormatTypeToString(snapdisk->src->for= mat)); + return -1; + } + + if (snapdisk->src->metadataCacheMaxSize > 0) { + if (snapdisk->src->format !=3D VIR_STORAGE_FILE_QCOW2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metadata cache max size control is supported= only with qcow2 images")); + return -1; + } + } + if (qemuTranslateSnapshotDiskSourcePool(snapdisk) < 0) return -1; =20 @@ -700,25 +719,6 @@ qemuSnapshotPrepare(virDomainObj *vm, break; =20 case VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL: - if (!disk->src->format) { - disk->src->format =3D VIR_STORAGE_FILE_QCOW2; - } else if (disk->src->format !=3D VIR_STORAGE_FILE_QCOW2 && - disk->src->format !=3D VIR_STORAGE_FILE_QED) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("external snapshot format for disk %1$s i= s unsupported: %2$s"), - disk->name, - virStorageFileFormatTypeToString(disk->src-= >format)); - return -1; - } - - if (disk->src->metadataCacheMaxSize > 0) { - if (disk->src->format !=3D VIR_STORAGE_FILE_QCOW2) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("metadata cache max size control is s= upported only with qcow2 images")); - return -1; - } - } - if (qemuSnapshotPrepareDiskExternal(dom_disk, disk, active, re= use) < 0) return -1; =20 --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878913; cv=none; d=zohomail.com; s=zohoarc; b=R2yjVPMx2P9s73JIXvsG39HXKQAmJalZneQX9y65yaJcR8etvcK1CBBvUYIrfOW36Zk0rdA9uEK36R77c06yIieiYu+JWuCbFHFvazNx4x8dEIgH6ZcETvJxiz25J/UipttuV7OIrdtXctsjM61KEJIIux3a51LWVV6IWNiW3k4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878913; 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=4noD3iblxbODaAOUV+ZkRnUbXhrGfUHpud9O8b6RQ44=; b=RokG9meyuKGxM+Jt1I2OpSXYWtR82sGexJIi2xa5Ntr5/lzddtCF/KpIR6TiEvBHQ3fVAjLRIS1Qsvi6/9bGtgm0l03mHdPiMWELhe3cSbsyvAb7f2q9LTd7+aX2VHT60aSrmZ7+KHPe+AA89V+2g3GRyApVMjGw89w/Yz/jo6o= 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 1687878913669697.9549729766909; Tue, 27 Jun 2023 08:15:13 -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-346-bFLeTRroNau56WCtnoulkQ-1; Tue, 27 Jun 2023 11:14:05 -0400 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 1BB208E7696; Tue, 27 Jun 2023 15:07:43 +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 056CF40C6CDE; Tue, 27 Jun 2023 15:07:43 +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 AB9D4194658F; Tue, 27 Jun 2023 15:07:36 +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 7E64219451C1 for ; Tue, 27 Jun 2023 15:07:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7042D48FB01; Tue, 27 Jun 2023 15:07:35 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13BB448FB02 for ; Tue, 27 Jun 2023 15:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878912; 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=4noD3iblxbODaAOUV+ZkRnUbXhrGfUHpud9O8b6RQ44=; b=GQbMhvPDRcPRboQtI2KhIz6P5McruDL62MAJsPtGQq34pjIziTgrfX5TjTyxGejvM70cCC x8JsfQ8tFmUkfzLErUHRy0xjq2jGA6entcb62Yv3KGguR5G7Pe0FOguihRd9Zp/6jNRnF9 bctFPEQqAIf61cNEfzn+NjVyzOHz87c= X-MC-Unique: bFLeTRroNau56WCtnoulkQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 11/24] qemu_snapshot: use VIR_ASYNC_JOB_SNAPSHOT when reverting snapshot Date: Tue, 27 Jun 2023 17:07:14 +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.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: 1687878914671100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5d2ffdeee6..1cb0ea55de 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2001,7 +2001,7 @@ qemuSnapshotRevertActive(virDomainObj *vm, /* Transitions 5, 6, 8, 9 */ qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, - VIR_ASYNC_JOB_START, 0); + VIR_ASYNC_JOB_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); detail =3D VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; event =3D virDomainEventLifecycleNewFromObj(vm, @@ -2026,7 +2026,7 @@ qemuSnapshotRevertActive(virDomainObj *vm, =20 rc =3D qemuProcessStart(snapshot->domain->conn, driver, vm, cookie ? cookie->cpu : NULL, - VIR_ASYNC_JOB_START, NULL, -1, NULL, snap, + VIR_ASYNC_JOB_SNAPSHOT, NULL, -1, NULL, snap, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags); virDomainAuditStart(vm, "from-snapshot", rc >=3D 0); @@ -2059,7 +2059,7 @@ qemuSnapshotRevertActive(virDomainObj *vm, } rc =3D qemuProcessStartCPUs(driver, vm, VIR_DOMAIN_RUNNING_FROM_SNAPSHOT, - VIR_ASYNC_JOB_START); + VIR_ASYNC_JOB_SNAPSHOT); if (rc < 0) return -1; } @@ -2122,7 +2122,7 @@ qemuSnapshotRevertInactive(virDomainObj *vm, if (virDomainObjIsActive(vm)) { /* Transitions 4, 7 */ qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT, - VIR_ASYNC_JOB_START, 0); + VIR_ASYNC_JOB_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); detail =3D VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT; event =3D virDomainEventLifecycleNewFromObj(vm, @@ -2149,7 +2149,7 @@ qemuSnapshotRevertInactive(virDomainObj *vm, start_flags |=3D paused ? VIR_QEMU_PROCESS_START_PAUSED : 0; =20 rc =3D qemuProcessStart(snapshot->domain->conn, driver, vm, NULL, - VIR_ASYNC_JOB_START, NULL, -1, NULL, NULL, + VIR_ASYNC_JOB_SNAPSHOT, NULL, -1, NULL, NULL, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags); virDomainAuditStart(vm, "from-snapshot", rc >=3D 0); @@ -2216,10 +2216,11 @@ qemuSnapshotRevert(virDomainObj *vm, return -1; } =20 - if (qemuProcessBeginJob(vm, - VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT, - flags) < 0) + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SNAPSHOT, + VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT, + flags) < 0) { return -1; + } =20 if (!(snap =3D qemuSnapObjFromSnapshot(vm, snapshot))) goto endjob; @@ -2269,7 +2270,7 @@ qemuSnapshotRevert(virDomainObj *vm, } =20 endjob: - qemuProcessEndJob(vm); + virDomainObjEndAsyncJob(vm); =20 return ret; } --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878883; cv=none; d=zohomail.com; s=zohoarc; b=QsVD6hmcSVR3KXFtPOjkqkoydrCbAwYhBQefnhuWDfJmktiDitWlVyjPvnLSx4Y8iq2u+S8yobUvW4ZkObO9/b7ryuOVBJjmr5O+qVwk13d12bnd1n8TL8miqLXMwt2ckDYHEpvIS1unj/ul/qeWOM+03aLZCNTEklps0CeQLqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878883; 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=n7vND/ZJDdy5XK4dIJuzgtGAdZaM6D3TXpFb+T7HSMk=; b=UgMIppiz6uiK4/J2nt25ZNYsB2DCN7PtECNcQC4TxlQ20u87fsVaAc7DXunkK1KonxmDy22it/8N+/tv2B+RcOIF4nKqXoy9f96NB4MpPENzzZgBZXbdCdwbYcSuJRetlIW0cixj1wvgcgEp2eZOrIHlU+K05xbG/cTNTxRJPio= 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 1687878883586254.13690173921816; Tue, 27 Jun 2023 08:14:43 -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-155-pwGATlRNP3iNJ3CgW-Fh8Q-1; Tue, 27 Jun 2023 11:14:05 -0400 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 CB5481C315AE; Tue, 27 Jun 2023 15:07:48 +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 7A30CC478C7; Tue, 27 Jun 2023 15:07:48 +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 E092B19451EF; Tue, 27 Jun 2023 15:07:36 +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 3E5C219451E5 for ; Tue, 27 Jun 2023 15:07:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 10D6B48FB01; Tue, 27 Jun 2023 15:07:36 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9A3E400E88 for ; Tue, 27 Jun 2023 15:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878882; 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=n7vND/ZJDdy5XK4dIJuzgtGAdZaM6D3TXpFb+T7HSMk=; b=TwxJAoRCE5qQfb0YCSyExnKu9rzyhTDZ66IRXOO/wg+XcaR9GRE9QByoMsqKFQU2XUKRbv 1P9APZBoOZxXoAuRb6p8hyWMu/NIVQuZX9qIIwlhceGiX+IvHqWDFxjbpD50l4XTXm9DTH LnfqUG7ssM/+2ZCw71EXh6p9X2GuWEU= X-MC-Unique: pwGATlRNP3iNJ3CgW-Fh8Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 12/24] qemu_snapshot: introduce external snapshot revert support Date: Tue, 27 Jun 2023 17:07:15 +0200 Message-ID: <11c92010c2712596168f5d2c765e60c57383231a.1687877087.git.phrdina@redhat.com> 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.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: 1687878884897100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When reverting to external snapshot we need to create new overlay qcow2 files from the disk files the VM had when the snapshot was taken. There are some specifics and limitations when reverting to a snapshot: 1) When reverting to last snapshot we need to first create new overlay files before we can safely delete the old overlay files in case the creation fails so we have still recovery option when we error out. These new files will not have the suffix as when the snapshot was created as renaming the original files in order to use the same file names as when the snapshot was created would add unnecessary complexity to the code. 2) When reverting to any snapshot we will always create overlay files for every disk the VM had when the snapshot was done. Otherwise we would have to figure out if there is any other qcow2 image already using any of the VM disks as backing store and that itself might be extremely complex and in some cases impossible. 3) When reverting from any state the current overlay files will be always removed as that VM state is not meant to be saved. It's the same as with internal snapshots. If user want's to keep the current state before reverting they need to create a new snapshot. For now this will only work if the current snapshot is the last. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 232 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 228 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 1cb0ea55de..dbf2cdd5db 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -18,6 +18,8 @@ =20 #include =20 +#include + #include "qemu_snapshot.h" =20 #include "qemu_monitor.h" @@ -1975,6 +1977,183 @@ qemuSnapshotRevertWriteMetadata(virDomainObj *vm, } =20 =20 +static int +qemuSnapshotRevertExternalPrepare(virDomainObj *vm, + virDomainSnapshotDef *tmpsnapdef, + virDomainMomentObj *snap, + virDomainDef *config, + virDomainDef *inactiveConfig, + int *memsnapFD, + char **memsnapPath) +{ + ssize_t i; + bool active =3D virDomainObjIsActive(vm); + virDomainDef *domdef =3D NULL; + virDomainSnapshotLocation location =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EX= TERNAL; + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + + if (config) { + domdef =3D config; + } else { + domdef =3D inactiveConfig; + } + + /* We need this to generate creation timestamp that is used as default + * snapshot name. */ + if (virDomainMomentDefPostParse(&tmpsnapdef->parent) < 0) + return -1; + + if (virDomainSnapshotAlignDisks(tmpsnapdef, domdef, location, false, t= rue) < 0) + return -1; + + for (i =3D 0; i < tmpsnapdef->ndisks; i++) { + virDomainSnapshotDiskDef *snapdisk =3D &tmpsnapdef->disks[i]; + virDomainDiskDef *domdisk =3D domdef->disks[i]; + + if (qemuSnapshotPrepareDiskExternal(domdisk, snapdisk, active, fal= se) < 0) + return -1; + } + + if (memsnapFD && memsnapPath && snapdef->memorysnapshotfile) { + virQEMUDriver *driver =3D ((qemuDomainObjPrivate *) vm->privateDat= a)->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driv= er); + + *memsnapPath =3D snapdef->memorysnapshotfile; + *memsnapFD =3D qemuDomainOpenFile(cfg, NULL, *memsnapPath, O_RDONL= Y, NULL); + } + + return 0; +} + + +static int +qemuSnapshotRevertExternalActive(virDomainObj *vm, + virDomainSnapshotDef *tmpsnapdef) +{ + ssize_t i; + g_autoptr(GHashTable) blockNamedNodeData =3D NULL; + g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; + + snapctxt =3D qemuSnapshotDiskContextNew(tmpsnapdef->ndisks, vm, VIR_AS= YNC_JOB_SNAPSHOT); + + if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, VIR_ASYNC_J= OB_SNAPSHOT))) + return -1; + + for (i =3D 0; i < tmpsnapdef->ndisks; i++) { + if (qemuSnapshotDiskPrepareOne(snapctxt, + vm->def->disks[i], + tmpsnapdef->disks + i, + blockNamedNodeData, + false, + true) < 0) + return -1; + } + + if (qemuSnapshotDiskCreate(snapctxt) < 0) + return -1; + + return 0; +} + + +static int +qemuSnapshotRevertExternalInactive(virDomainObj *vm, + virDomainSnapshotDef *tmpsnapdef, + virDomainDef *config, + virDomainDef *inactiveConfig) +{ + virDomainDef *domdef =3D NULL; + g_autoptr(virBitmap) created =3D NULL; + + created =3D virBitmapNew(tmpsnapdef->ndisks); + + if (config) { + domdef =3D config; + } else { + domdef =3D inactiveConfig; + } + + if (config) { + if (qemuSnapshotDomainDefUpdateDisk(config, tmpsnapdef, false) < 0) + return -1; + } + + if (qemuSnapshotDomainDefUpdateDisk(inactiveConfig, tmpsnapdef, false)= < 0) + return -1; + + if (qemuSnapshotCreateQcow2Files(vm, domdef, tmpsnapdef, created, fals= e) < 0) { + ssize_t bit =3D -1; + + while ((bit =3D virBitmapNextSetBit(created, bit)) >=3D 0) { + virDomainSnapshotDiskDef *snapdisk =3D &(tmpsnapdef->disks[bit= ]); + + if (virStorageSourceInit(snapdisk->src) < 0 || + virStorageSourceUnlink(snapdisk->src) < 0) { + VIR_WARN("Failed to remove snapshot image '%s'", + snapdisk->src->path); + } + } + + return -1; + } + + return 0; +} + + +static void +qemuSnapshotRevertExternalFinish(virDomainObj *vm, + virDomainSnapshotDef *tmpsnapdef, + virDomainMomentObj *snap) +{ + size_t i; + virDomainMomentObj *curSnap =3D virDomainSnapshotGetCurrent(vm->snapsh= ots); + virDomainSnapshotDef *curdef =3D virDomainSnapshotObjGetDef(curSnap); + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + + if (curdef->revertdisks) { + for (i =3D 0; i < curdef->nrevertdisks; i++) { + virDomainSnapshotDiskDef *snapdisk =3D &(curdef->revertdisks[i= ]); + + if (virStorageSourceInit(snapdisk->src) < 0 || + virStorageSourceUnlink(snapdisk->src) < 0) { + VIR_WARN("Failed to remove snapshot image '%s'", + snapdisk->src->path); + } + + virDomainSnapshotDiskDefClear(snapdisk); + } + + g_clear_pointer(&curdef->revertdisks, g_free); + curdef->nrevertdisks =3D 0; + } else { + for (i =3D 0; i < curdef->ndisks; i++) { + virDomainSnapshotDiskDef *snapdisk =3D &(curdef->disks[i]); + + if (virStorageSourceInit(snapdisk->src) < 0 || + virStorageSourceUnlink(snapdisk->src) < 0) { + VIR_WARN("Failed to remove snapshot image '%s'", + snapdisk->src->path); + } + } + } + + if (snap->nchildren !=3D 0) { + snapdef->revertdisks =3D g_steal_pointer(&tmpsnapdef->disks); + snapdef->nrevertdisks =3D tmpsnapdef->ndisks; + tmpsnapdef->ndisks =3D 0; + } else { + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDefClear(&snapdef->disks[i]); + } + g_free(snapdef->disks); + snapdef->disks =3D g_steal_pointer(&tmpsnapdef->disks); + snapdef->ndisks =3D tmpsnapdef->ndisks; + tmpsnapdef->ndisks =3D 0; + } +} + + static int qemuSnapshotRevertActive(virDomainObj *vm, virDomainSnapshotPtr snapshot, @@ -1989,10 +2168,14 @@ qemuSnapshotRevertActive(virDomainObj *vm, { virObjectEvent *event =3D NULL; virObjectEvent *event2 =3D NULL; + virDomainMomentObj *loadSnap =3D NULL; + VIR_AUTOCLOSE memsnapFD =3D -1; + char *memsnapPath =3D NULL; int detail; bool defined =3D false; qemuDomainSaveCookie *cookie =3D (qemuDomainSaveCookie *) snapdef->coo= kie; int rc; + g_autoptr(virDomainSnapshotDef) tmpsnapdef =3D NULL; =20 start_flags |=3D VIR_QEMU_PROCESS_START_PAUSED; =20 @@ -2010,6 +2193,19 @@ qemuSnapshotRevertActive(virDomainObj *vm, virObjectEventStateQueue(driver->domainEventState, event); } =20 + if (virDomainSnapshotIsExternal(snap)) { + if (!(tmpsnapdef =3D virDomainSnapshotDefNew())) + return -1; + + if (qemuSnapshotRevertExternalPrepare(vm, tmpsnapdef, snap, + *config, *inactiveConfig, + &memsnapFD, &memsnapPath) < = 0) { + return -1; + } + } else { + loadSnap =3D snap; + } + if (*inactiveConfig) { virDomainObjAssignDef(vm, inactiveConfig, false, NULL); defined =3D true; @@ -2026,7 +2222,8 @@ qemuSnapshotRevertActive(virDomainObj *vm, =20 rc =3D qemuProcessStart(snapshot->domain->conn, driver, vm, cookie ? cookie->cpu : NULL, - VIR_ASYNC_JOB_SNAPSHOT, NULL, -1, NULL, snap, + VIR_ASYNC_JOB_SNAPSHOT, NULL, memsnapFD, + memsnapPath, loadSnap, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags); virDomainAuditStart(vm, "from-snapshot", rc >=3D 0); @@ -2038,6 +2235,14 @@ qemuSnapshotRevertActive(virDomainObj *vm, if (rc < 0) return -1; =20 + + if (virDomainSnapshotIsExternal(snap)) { + if (qemuSnapshotRevertExternalActive(vm, tmpsnapdef) < 0) + return -1; + + qemuSnapshotRevertExternalFinish(vm, tmpsnapdef, snap); + } + /* Touch up domain state. */ if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING) && (snapdef->state =3D=3D VIR_DOMAIN_SNAPSHOT_PAUSED || @@ -2112,6 +2317,7 @@ qemuSnapshotRevertInactive(virDomainObj *vm, int detail; bool defined =3D false; int rc; + g_autoptr(virDomainSnapshotDef) tmpsnapdef =3D NULL; =20 /* Transitions 1, 4, 7 */ /* Newer qemu -loadvm refuses to revert to the state of a snapshot @@ -2131,9 +2337,27 @@ qemuSnapshotRevertInactive(virDomainObj *vm, virObjectEventStateQueue(driver->domainEventState, event); } =20 - if (qemuSnapshotInternalRevertInactive(driver, vm, snap) < 0) { - qemuDomainRemoveInactive(driver, vm, 0, false); - return -1; + if (virDomainSnapshotIsExternal(snap)) { + if (!(tmpsnapdef =3D virDomainSnapshotDefNew())) + return -1; + + if (qemuSnapshotRevertExternalPrepare(vm, tmpsnapdef, snap, + NULL, *inactiveConfig, + NULL, NULL) < 0) { + return -1; + } + + if (qemuSnapshotRevertExternalInactive(vm, tmpsnapdef, + NULL, *inactiveConfig) < 0)= { + return -1; + } + + qemuSnapshotRevertExternalFinish(vm, tmpsnapdef, snap); + } else { + if (qemuSnapshotInternalRevertInactive(driver, vm, snap) < 0) { + qemuDomainRemoveInactive(driver, vm, 0, false); + return -1; + } } =20 if (*inactiveConfig) { --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687879177; cv=none; d=zohomail.com; s=zohoarc; b=k67FCov4cC2NziYso00bpTXVic0DKUEtJy5ZDRT6aUr+DnDrUoP9kIQwUQLLb/uNpwmEkOGtViCWkM9NMjPk5DGBbjlh0gmRhonNATiWKQF1BF763yRpViNaMWynJ0f8YWdfF5ztjG4ecYSsPZ6fRxjd6ylYCTOQuPNNU+SAhYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879177; 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=j0SVWzlr3J4PC4o6HNtRK2ElPSApmMM/D8c5mCVqqmQ=; b=kqB0qo4PJ0WxqbrzihXmWk6OB1dlVj657qs5Fvb3wSBhXqt1qFKNHZDp89cYanUjexEx+Jeh2/kXojjdCdcYELRUsLe6i4FVpqy2Nt7MTt1id3zQeB4ww8tZ0dVc2nGTWddyMkzbuLud0l3QdevnS3hl+6YyZKFP3qIIhWf4F2A= 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 1687879177308812.9290997181982; Tue, 27 Jun 2023 08:19:37 -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-59-rQFg-tkvMNarTBwy1khdcg-1; Tue, 27 Jun 2023 11:15:48 -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 06EB48E9C10; Tue, 27 Jun 2023 15:07:59 +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 E612840C2063; Tue, 27 Jun 2023 15:07:58 +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 3A1D3194037E; Tue, 27 Jun 2023 15:07:40 +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 C69AA1946A74 for ; Tue, 27 Jun 2023 15:07:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A706B400E88; Tue, 27 Jun 2023 15:07:36 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49BDB48FB01 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=1687879175; 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=j0SVWzlr3J4PC4o6HNtRK2ElPSApmMM/D8c5mCVqqmQ=; b=jODlW8czrs+wY7uikdjtHdsKpT7MpIKo9bWofHiKxKYRt6ttiYeTVj2xSmi29/FOR3NUId 63+TcF3V+aIfEPpsm/xETYTLG9vsfeXK2ablXNEHf+GJEufAvN8pK9tFxE1l9EjTK1SIVR Z2vh83+EUP8Upoz0+V/rxbDiMP1Pzpc= X-MC-Unique: rQFg-tkvMNarTBwy1khdcg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 13/24] qemu_snapshot: rename qemuSnapshotDeleteExternalPrepare Date: Tue, 27 Jun 2023 17:07:16 +0200 Message-ID: <4987f33df1048346f2b6d3e549a300d198fd4c2f.1687877087.git.phrdina@redhat.com> 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: 1687879178279100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The new name reflects that we prepare data for external snapshot deletion and the old name will be used later for different part of code. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index dbf2cdd5db..c5de24917b 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2570,9 +2570,9 @@ qemuSnapshotFindParentSnapForDisk(virDomainMomentObj = *snap, =20 =20 static int -qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, - virDomainMomentObj *snap, - GSList **externalData) +qemuSnapshotDeleteExternalPrepareData(virDomainObj *vm, + virDomainMomentObj *snap, + GSList **externalData) { ssize_t i; virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); @@ -3429,7 +3429,7 @@ qemuSnapshotDelete(virDomainObj *vm, g_autoslist(qemuSnapshotDeleteExternalData) tmpData =3D NULL; =20 /* this also serves as validation whether the snapshot can be = deleted */ - if (qemuSnapshotDeleteExternalPrepare(vm, snap, &tmpData) < 0) + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, &tmpData) = < 0) goto endjob; =20 if (!virDomainObjIsActive(vm)) { @@ -3444,7 +3444,7 @@ qemuSnapshotDelete(virDomainObj *vm, =20 /* Call the prepare again as some data require that the VM= is * running to get everything we need. */ - if (qemuSnapshotDeleteExternalPrepare(vm, snap, &externalD= ata) < 0) + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, &exter= nalData) < 0) goto endjob; } else { qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=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 From nobody Sat May 18 06:04:10 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=1687878851; cv=none; d=zohomail.com; s=zohoarc; b=nPzWVTaIs6U1jhuMQDsRddl8w7hEE7W4ARJeGYd05JQuLfCm5au/HjdSOYWwUfnUkTFFcPqwGILwriTkca8u+gwmnpWxm2igfGr1uNts2HTHnUkA894OZ3xEur30pQk8nPng/du4zkWX2QlLxy3So8omfQQufueNjoGKx9urMlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878851; 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=GH4/5c8YEcZInajpa+Cjd/iIZdsdvCfz2dcSxOVAAmo=; b=GqSgaUb43AhIqP5U2PThMGsoH7ECAQ922GiDnraITxbukaF/2+8NxWuKL2LvhBl33dbz+B8qK50sSXhJ6RS5gDZx+NJeoRR0jM9oNkdRPDVZTsWIFbrXcsf5uKukjBGL/MuhhQRrbOf13VUrby42rRAu49nqNET5uEiiz+7FZ3w= 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 1687878851607112.55953528209; Tue, 27 Jun 2023 08:14:11 -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-21-6mQxYonON5GueSLfETYg_Q-1; Tue, 27 Jun 2023 11:13:48 -0400 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 574F11066543; Tue, 27 Jun 2023 15:07:56 +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 3D06E2166B25; Tue, 27 Jun 2023 15:07:56 +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 C7921194974C; 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 EA93C1946586 for ; Tue, 27 Jun 2023 15:07:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DCA28400E88; 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 80A0748FB01 for ; Tue, 27 Jun 2023 15:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878850; 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=GH4/5c8YEcZInajpa+Cjd/iIZdsdvCfz2dcSxOVAAmo=; b=h4NaJgKbenu6hehG8DPbOjuCQZIdkGEGEgsHQRX+jDnhCwzFPaqeTGtaNck/CmHZU9E8vO RMjnIdLrhqI7Y+rEUhETyyhQipHYAG9Xc4uoLw6B1+qVFLDww0tL2eWFpMvG3HTtOPVyC/ sWz4LZN9yHSTU5okN9JmCA97C4k1aVQ= X-MC-Unique: 6mQxYonON5GueSLfETYg_Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 15/24] qemu_snapshot: add merge to external snapshot delete prepare data Date: Tue, 27 Jun 2023 17:07:18 +0200 Message-ID: <996a347fa1aac2123b60a17c4fe5ab3f0d38f437.1687877087.git.phrdina@redhat.com> 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.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: 1687878851923100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Before external snapshot revert every delete operation did block commit in order to delete a snapshot. But now when user reverts to non-leaf snapshot deleting leaf snapshot will not have any overlay files so we can just simply delete the snapshot images. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 93 ++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 08cff2a9a2..9c4d26bad5 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2569,9 +2569,26 @@ qemuSnapshotFindParentSnapForDisk(virDomainMomentObj= *snap, } =20 =20 +/** + * qemuSnapshotDeleteExternalPrepareData: + * @vm: domain object + * @snap: snapshot object + * @merge: whether we are just deleting image or not + * @externalData: prepared data to delete external snapshot + * + * Validate if we can delete selected snapshot @snap and prepare all neces= sary + * data that will be used when deleting snapshot as @externalData. + * + * If @merge is set to true we will merge the deleted snapshot into parent= one + * instead of just deleting it. This is necessary when operating on snapsh= ot + * that has existing overlay files. + * + * Returns -1 on error, 0 on success. + */ static int qemuSnapshotDeleteExternalPrepareData(virDomainObj *vm, virDomainMomentObj *snap, + bool merge, GSList **externalData) { ssize_t i; @@ -2579,7 +2596,6 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *v= m, g_autoslist(qemuSnapshotDeleteExternalData) ret =3D NULL; =20 for (i =3D 0; i < snapdef->ndisks; i++) { - g_autofree qemuSnapshotDeleteExternalData *data =3D NULL; virDomainSnapshotDiskDef *snapDisk =3D &(snapdef->disks[i]); =20 if (snapDisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) @@ -2591,14 +2607,18 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj = *vm, snapDisk->name); return -1; } + } + + for (i =3D 0; i < snapdef->ndisks; i++) { + virDomainSnapshotDiskDef *snapDisk =3D &(snapdef->disks[i]); + g_autofree qemuSnapshotDeleteExternalData *data =3D NULL; + + if (snapDisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) + continue; =20 data =3D g_new0(qemuSnapshotDeleteExternalData, 1); data->snapDisk =3D snapDisk; =20 - data->domDisk =3D qemuDomainDiskByName(vm->def, snapDisk->name); - if (!data->domDisk) - return -1; - data->parentDomDisk =3D virDomainDiskByTarget(snapdef->parent.dom, data->snapDisk->name); if (!data->parentDomDisk) { @@ -2608,39 +2628,46 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj = *vm, return -1; } =20 - if (virDomainObjIsActive(vm)) { - data->diskSrc =3D virStorageSourceChainLookupBySource(data->do= mDisk->src, - data->snap= Disk->src, - &data->pre= vDiskSrc); - if (!data->diskSrc) + if (merge) { + data->domDisk =3D qemuDomainDiskByName(vm->def, snapDisk->name= ); + if (!data->domDisk) return -1; =20 - if (!virStorageSourceIsSameLocation(data->diskSrc, data->snapD= isk->src)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("VM disk source and snapshot disk source = are not the same")); - return -1; - } + if (virDomainObjIsActive(vm)) { + data->diskSrc =3D virStorageSourceChainLookupBySource(data= ->domDisk->src, + data->= snapDisk->src, + &data-= >prevDiskSrc); + if (!data->diskSrc) + return -1; =20 - data->parentDiskSrc =3D data->diskSrc->backingStore; - if (!virStorageSourceIsBacking(data->parentDiskSrc)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("failed to find parent disk source in bac= king chain")); - return -1; - } + if (!virStorageSourceIsSameLocation(data->diskSrc, data->s= napDisk->src)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("VM disk source and snapshot disk sou= rce are not the same")); + return -1; + } =20 - 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 -1; + data->parentDiskSrc =3D data->diskSrc->backingStore; + if (!virStorageSourceIsBacking(data->parentDiskSrc)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("failed to find parent disk source in= backing chain")); + return -1; + } + + if (!virStorageSourceIsSameLocation(data->parentDiskSrc, + data->parentDomDisk->s= rc)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("snapshot VM disk source and parent d= isk source are not the same")); + return -1; + } } - } =20 - data->parentSnap =3D qemuSnapshotFindParentSnapForDisk(snap, data-= >snapDisk); + data->parentSnap =3D qemuSnapshotFindParentSnapForDisk(snap, d= ata->snapDisk); =20 - 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 -1; + if (data->parentSnap && !virDomainSnapshotIsExternal(data->par= entSnap)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("deleting external snapshot that has inte= rnal snapshot as parent not supported")); + return -1; + } } =20 ret =3D g_slist_prepend(ret, g_steal_pointer(&data)); @@ -2672,7 +2699,7 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, } =20 /* this also serves as validation whether the snapshot can be deleted = */ - if (qemuSnapshotDeleteExternalPrepareData(vm, snap, &tmpData) < 0) + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, true, &tmpData) < = 0) return -1; =20 if (!virDomainObjIsActive(vm)) { @@ -2687,7 +2714,7 @@ qemuSnapshotDeleteExternalPrepare(virDomainObj *vm, =20 /* Call the prepare again as some data require that the VM is * running to get everything we need. */ - if (qemuSnapshotDeleteExternalPrepareData(vm, snap, externalData) = < 0) + if (qemuSnapshotDeleteExternalPrepareData(vm, snap, true, external= Data) < 0) return -1; } else { qemuDomainJobPrivate *jobPriv =3D vm->job->privateData; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687879065; cv=none; d=zohomail.com; s=zohoarc; b=PiNsBvlhnbd8+gWU+pYBU/GN/8IKTS89vzTIn2gHbgM1520IaSt4mwmgtMEKnv+NJjtOxuJm6UnV62LQbrBUOI6iRMQW/5CqHuePt3+Ah7P+Q33spSsZAQYsiRY0bIdqkjUyyOXbuBzeYQVVj3dJnFqvrwNjW/bBZVoRG1W1L2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879065; 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=aP/9xAI17yC8PQMd89vSF2WuUPFYZYTfCq3fUrh+DK8=; b=ScVgrq6jOiznXr/vKHTkkTinfUx1lHMG5dw25JYHYP2+arwQpJkCCVn7RQ+HEzP3+9TFmEBg04pEuAgdQOXb0dxNrPnMqZxBkDRhr0cRvl80avIOjnyZr3X5TyOECBX5nEUGYw9DHzdsdWs++LLmxu9AtJ37Ntd55ikms4GGOUQ= 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 1687879065092849.5887846699959; Tue, 27 Jun 2023 08:17:45 -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-509-P88OGWtYNVygp1dA9Ahm7g-1; Tue, 27 Jun 2023 11:15:33 -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 C1E578FC07D; Tue, 27 Jun 2023 15:08:03 +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 AD51047AD4B; Tue, 27 Jun 2023 15:08: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 2A64C1946A78; Tue, 27 Jun 2023 15:07:41 +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 AE8321949746 for ; Tue, 27 Jun 2023 15:07:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7FA8640140F; Tue, 27 Jun 2023 15:07:38 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20E1048FB01 for ; Tue, 27 Jun 2023 15:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687879063; 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=aP/9xAI17yC8PQMd89vSF2WuUPFYZYTfCq3fUrh+DK8=; b=Wa1oqwrT5aLnNCObe76mrLd1vPgu4vw1+sQr8L7zP1BS9zH4IBgDPEXaH5r74rUFIEoItb SDOTMneRV1G6geulQCNT3ImNb9CrYLQfvjtkeCx3+yGWVufRAGEgWvFAvDJriMCFyQtxR+ FPXtcKCjwVZdCFNLavG05vR+s525Lx8= X-MC-Unique: P88OGWtYNVygp1dA9Ahm7g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 16/24] qemu_snapshot: prepare data for non-active leaf external snapshot deletion Date: Tue, 27 Jun 2023 17:07:19 +0200 Message-ID: <4b99a8735167092f1a6f6c19be89e5793d8e02e6.1687877087.git.phrdina@redhat.com> 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.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: 1687879065635100001 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 9c4d26bad5..be94e97340 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2698,34 +2698,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 From nobody Sat May 18 06:04:10 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=1687878909; cv=none; d=zohomail.com; s=zohoarc; b=Q4kvxNlAWI9AOQcxcjaFRl9ACMeVq3kIIA0vfr0AFdGliPX4rMZufwUdkoeEGpIhHqwgxraKY6EeT0JUWuypA4PG2YgEZ2hAIU5Az+T9JBvwyJxwVi5k/fb2QibeV8RtTwGYJzmdshYXqK9KJyVPZZCgLA6vHM1gKLFEDKlxb/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878909; 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=9OhE3Xb87FF9v0lD0I+xwQJmjD5GqFF85HSgZBmPY2M=; b=nAfc9dn7w0eJFgXtymGWOfDN0Cp0L237aWTl26GWHZTgZA+ghxi/9Ce9FRmpJuTtBWwz6jafOMLehHYT0KSp5LwNrTD/OGY48kORTxqBhZHPBLQSp6LEQt8/mw6WKugQG80g8PBWEsg3e9KfsZeK/MdXLY7tp3Na770vRPzjShM= 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 1687878909639689.1469022412867; Tue, 27 Jun 2023 08:15:09 -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-288-eodlwq47NJm9bQZLs6H7SA-1; Tue, 27 Jun 2023 11:14:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AB1538E9C34; Tue, 27 Jun 2023 15:08:00 +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 90D6A200A3AD; Tue, 27 Jun 2023 15:08: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 71BCE194E00C; Tue, 27 Jun 2023 15:07:40 +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 2D4731949759 for ; Tue, 27 Jun 2023 15:07:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 218BE40140F; Tue, 27 Jun 2023 15:07:39 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA44448FB01 for ; Tue, 27 Jun 2023 15:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878908; 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=9OhE3Xb87FF9v0lD0I+xwQJmjD5GqFF85HSgZBmPY2M=; b=IBLRoFSLfXJGCrEeYtH53vex6XvXb6knG8rVoU1mjnXJIDEaW2PhLGHVDZOBeirmEi9l8w 2JTLAEnPa+tErZ3H/74rCSvXCCaVqbfhFqaraHdJMsyJ+4MplUiIh+u4wmvtYtTU5erpkk JymzBjJ9eBbEYKaHKNj1CmMNOnW40io= X-MC-Unique: eodlwq47NJm9bQZLs6H7SA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 17/24] qemu_snapshot: add support to delete external snapshot without block commit Date: Tue, 27 Jun 2023 17:07:20 +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.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687878910629100002 Content-Type: text/plain; charset="utf-8"; x-default="true" When block commit is not needed we can just simply unlink the disk files. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 56 ++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index be94e97340..b08e06d312 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2510,6 +2510,7 @@ typedef struct _qemuSnapshotDeleteExternalData { virStorageSource *prevDiskSrc; /* source of disk for which @diskSrc is backing disk */ qemuBlockJobData *job; + bool merge; } qemuSnapshotDeleteExternalData; =20 =20 @@ -2618,6 +2619,7 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *v= m, =20 data =3D g_new0(qemuSnapshotDeleteExternalData, 1); data->snapDisk =3D snapDisk; + data->merge =3D merge; =20 data->parentDomDisk =3D virDomainDiskByTarget(snapdef->parent.dom, data->snapDisk->name); @@ -2628,7 +2630,7 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *v= m, return -1; } =20 - if (merge) { + if (data->merge) { data->domDisk =3D qemuDomainDiskByName(vm->def, snapDisk->name= ); if (!data->domDisk) return -1; @@ -3053,31 +3055,42 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, virTristateBool autofinalize =3D VIR_TRISTATE_BOOL_NO; unsigned int commitFlags =3D VIR_DOMAIN_BLOCK_COMMIT_DELETE; =20 - if (data->domDisk->src =3D=3D data->diskSrc) { - commitFlags |=3D VIR_DOMAIN_BLOCK_COMMIT_ACTIVE; - autofinalize =3D VIR_TRISTATE_BOOL_YES; + if (data->merge) { + if (data->domDisk->src =3D=3D data->diskSrc) { + commitFlags |=3D VIR_DOMAIN_BLOCK_COMMIT_ACTIVE; + autofinalize =3D VIR_TRISTATE_BOOL_YES; + } + + if (qemuSnapshotSetInvalid(vm, data->parentSnap, data->snapDis= k, true) < 0) + goto error; + + 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; + } else { + if (virStorageSourceInit(data->parentDomDisk->src) < 0 || + virStorageSourceUnlink(data->parentDomDisk->src) < 0) { + VIR_WARN("Failed to remove snapshot image '%s'", + data->snapDisk->name); + } } - - if (qemuSnapshotSetInvalid(vm, data->parentSnap, data->snapDisk, t= rue) < 0) - goto error; - - 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; } =20 for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { qemuSnapshotDeleteExternalData *data =3D cur->data; =20 + if (!data->merge) + continue; + if (qemuSnapshotDeleteBlockJobRunning(vm, data->job) < 0) goto error; =20 @@ -3092,6 +3105,9 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, for (cur =3D externalData; cur; cur =3D g_slist_next(cur)) { qemuSnapshotDeleteExternalData *data =3D cur->data; =20 + if (!data->merge) + continue; + if (data->job->state =3D=3D QEMU_BLOCKJOB_STATE_READY) { if (qemuBlockPivot(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT, NULL= ) < 0) goto error; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687879586; cv=none; d=zohomail.com; s=zohoarc; b=kwP/IOgCIPCLuvSIHovOJaKA2OiG7WqVh2QjSRxQCCCzPqjTdOiGjXqcx5SUpzo1ArXZl+MNwiqvjbDvFCq4X9LzDn2Z/mMuB+NZNY2kMLvtihnXzdzphxVi5jbGoVK8C5vW+o/+gNxtCJyXncU1G6udY+jAOVDaqhcLkz3hfpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879586; 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=NR5FFykJB4/UYX4yHrzU+z0YgHc2+DPmd5+JurmXbx4=; b=V3K0QKmz5L7xmCE+HDo6KOS/OAA9pzUoVj5YvgsJ1LScQow2AXRv2w+kOAOO23XWDqdFj2zafcY+dVmG+4MrHNIZvYXLTBXKSTpuetWcSxyCLKWypbBlmxVOnP3Mby0Po6GKFKg84QzpBo4xS9UX8ZXa+vsP+JETXgd+GHdhqN0= 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 1687879585920800.7436891640388; Tue, 27 Jun 2023 08:26:25 -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-371-boLNWZQAP4iex0Ruuee_Sw-1; Tue, 27 Jun 2023 11:24:16 -0400 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 E65DF8F83C2; Tue, 27 Jun 2023 15:08:04 +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 D1989425369; Tue, 27 Jun 2023 15:08: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 B495719465B1; Tue, 27 Jun 2023 15:07:41 +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 C42491949759 for ; Tue, 27 Jun 2023 15:07:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B62E5400E88; Tue, 27 Jun 2023 15:07:39 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59FAE48FB01 for ; Tue, 27 Jun 2023 15:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687879579; 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=NR5FFykJB4/UYX4yHrzU+z0YgHc2+DPmd5+JurmXbx4=; b=VJJ2H5K6RSca6AFhuzo9MaYAjTqdsIqI+g45HuQXRtlOA/QBpeZuTskYXSBnlCCZbDHYV1 nUwElTQpqclWtU6kbHL4qMt4ymI1a9OqeU10UuA2r32UqF6g4kSIZXJ/jkQDNGBDVR1STh pxCAwOyFzRYMqRfZx4S60tQyROMtS1A= X-MC-Unique: boLNWZQAP4iex0Ruuee_Sw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 18/24] qemu_snapshot: delete: properly update parent snapshot with revert data Date: Tue, 27 Jun 2023 17:07:21 +0200 Message-ID: <4eef96f501230a24581376d559486c134c515199.1687877087.git.phrdina@redhat.com> 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.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: 1687879586547100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When deleting external snapshot and parent snapshot is the currently active snapshot as user reverted to it we need to properly update the parent snapshot metadata. After the delete is done the new overlay files will be the currently used files created when snapshot revert was done, replacing the original overlay files. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index b08e06d312..a206f015c4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3168,6 +3168,41 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, } =20 =20 +static int +qemuSnapshotDeleteUpdateParent(virDomainObj *vm, + virDomainMomentObj *parent) +{ + size_t i; + virQEMUDriver *driver =3D QEMU_DOMAIN_PRIVATE(vm)->driver; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + virDomainSnapshotDef *parentDef =3D virDomainSnapshotObjGetDef(parent); + + if (!parentDef) + return 0; + + if (!parentDef->revertdisks) + return 0; + + for (i =3D 0; i < parentDef->ndisks; i++) { + virDomainSnapshotDiskDefClear(&parentDef->disks[i]); + } + g_free(parentDef->disks); + + parentDef->disks =3D g_steal_pointer(&parentDef->revertdisks); + parentDef->ndisks =3D parentDef->nrevertdisks; + parentDef->nrevertdisks =3D 0; + + if (qemuDomainSnapshotWriteMetadata(vm, + parent, + driver->xmlopt, + cfg->snapshotDir) < 0) { + return -1; + } + + return 0; +} + + static int qemuSnapshotDiscardMetadata(virDomainObj *vm, virDomainMomentObj *snap, @@ -3207,6 +3242,11 @@ qemuSnapshotDiscardMetadata(virDomainObj *vm, virDomainMomentMoveChildren(snap, snap->parent); } =20 + if (update_parent && snap->parent) { + if (qemuSnapshotDeleteUpdateParent(vm, snap->parent) < 0) + ret =3D -1; + } + snapFile =3D g_strdup_printf("%s/%s/%s.xml", cfg->snapshotDir, vm->def= ->name, snap->def->name); =20 --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687879485; cv=none; d=zohomail.com; s=zohoarc; b=hx3sBKFKd1mee2v9WeYn6b10qSY96uatmMcaEtodS2eanMrKX+g/ZWQS/7vGENwXjkViwxS1WqvKFrWvS6L5+LiPw2f6P5d55jXVdb/PPa+XZ4wlOwj9euQp5XbWlrhUqQ9ZKsv819J72rwwppxaMw4XYW8YpLzU4m5jxaoi6eI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879485; 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=Pcqmd9YdtoqNAhjdcHZmxwGdcAvMr3K0VBf+GsZup90=; b=QTilnu95RQuV+3cFR22SaL62EiFI7r9iL19R9/a6LhMr9p+jrBi5KXLlOsyVsB6foJaTKWzYtxDC5OhP1/0PBT44UckDR+pxMujlGGIl1WIPPecG76ReZ+5alsiOjiWp/BL+wX5evSkiI+ucDcW5FfM5xjMk0DyUdFs36N108lY= 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 1687879485371802.7456276109076; Tue, 27 Jun 2023 08:24:45 -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-170-xFa7lRSVOGy1uH9Kh29vZg-1; Tue, 27 Jun 2023 11:21:03 -0400 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 69D0A8FF741; Tue, 27 Jun 2023 15:08:05 +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 4F3D3C00049; Tue, 27 Jun 2023 15:08:05 +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 EAF6F194E11C; Tue, 27 Jun 2023 15:07:41 +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 64D08194E009 for ; Tue, 27 Jun 2023 15:07:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5739348FB02; Tue, 27 Jun 2023 15:07:40 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE84348FB01 for ; Tue, 27 Jun 2023 15:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687879472; 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=Pcqmd9YdtoqNAhjdcHZmxwGdcAvMr3K0VBf+GsZup90=; b=NXxkghSXbZLqUcLKOpXN0iEOsF7lG6viZ1N+Xrw10lTxW+ZZzlt6/HTP9MmkroC/iNxxhr PbIbHyWKdIv8NSVfraaWM2yilhkw70VaZBAEYm/IveJLd7F6AcKSv+gRDL6kh7iACztyPf t9AyBoMpMGon+IhxzKfnXuKHhQlfNX0= X-MC-Unique: xFa7lRSVOGy1uH9Kh29vZg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 19/24] qemu_snapshot: remove revertdisks when creating new snapshot Date: Tue, 27 Jun 2023 17:07:22 +0200 Message-ID: <6b822a2cb1aaa85df79781611c70bc37e1668a37.1687877087.git.phrdina@redhat.com> 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.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: 1687879486966100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When user creates a new snapshot after reverting to non-leaf snapshot we no longer need to store the temporary overlays as they will be part of the VM XMLs stored in the newly created snapshot. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index a206f015c4..2950ad7d77 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1652,6 +1652,23 @@ qemuSnapshotCreateWriteMetadata(virDomainObj *vm, } =20 =20 +static void +qemuSnapshotClearRevertdisks(virDomainMomentObj *current) +{ + virDomainSnapshotDef *curdef =3D NULL; + + if (!current) + return; + + curdef =3D virDomainSnapshotObjGetDef(current); + + if (curdef->revertdisks) { + g_clear_pointer(&curdef->revertdisks, g_free); + curdef->nrevertdisks =3D 0; + } +} + + static virDomainSnapshotPtr qemuSnapshotRedefine(virDomainObj *vm, virDomainPtr domain, @@ -1661,6 +1678,7 @@ qemuSnapshotRedefine(virDomainObj *vm, unsigned int flags) { virDomainMomentObj *snap =3D NULL; + virDomainMomentObj *current =3D virDomainSnapshotGetCurrent(vm->snapsh= ots); virDomainSnapshotPtr ret =3D NULL; g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); =20 @@ -1678,8 +1696,10 @@ qemuSnapshotRedefine(virDomainObj *vm, * makes sense, such as checking that qemu-img recognizes the * snapshot name in at least one of the domain's disks? */ =20 - if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT) + if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT) { + qemuSnapshotClearRevertdisks(current); qemuSnapshotSetCurrent(vm, snap); + } =20 if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) goto error; @@ -1758,6 +1778,7 @@ qemuSnapshotCreate(virDomainObj *vm, } =20 if (!tmpsnap) { + qemuSnapshotClearRevertdisks(current); qemuSnapshotSetCurrent(vm, snap); =20 if (qemuSnapshotCreateWriteMetadata(vm, snap, driver, cfg) < 0) --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878933; cv=none; d=zohomail.com; s=zohoarc; b=XfvRDw1Cz26hrTXvG27aQ2NaKoT1HhDA6jowCZYu8pdJV+dInZT8cGeOoX+w/+s8FYazjFaQpljxuKjjfMNEK844WYOlV4sF/v7PPhCR7OhrEgZC6Uee1og/NkDoC8HcfJNkDiCefIhPVge2n+lHdt+3I9Bu3fGchwWqdESGNz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878933; 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=43eQCDjBefYSVPeZsQa4V/9cREPCmjoDeHopOADVfv0=; b=gHIVZatKtLVymZNdEb/t3omXJUDtoNXTK1dm0vjtoqdEQJdJu+LMi+deBySyfUzbXLrWywUtKbag63csObZ4oVE/SNWNugyuikJzkb+OobliB44bvM0MQ9J5lSZNevVLvsDFfslU2u66LUvmKYDvoFZk6PQ20Pi0zkWp4SeO8W4= 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 1687878933795659.372520555976; Tue, 27 Jun 2023 08:15:33 -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-7-hon4N5lDO4iMiy2yU6Zg3w-1; Tue, 27 Jun 2023 11:15:01 -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 CA38929ABA31; Tue, 27 Jun 2023 15:08:05 +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 AB41F48FB01; Tue, 27 Jun 2023 15:08:05 +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 2FB26194658C; Tue, 27 Jun 2023 15:07:43 +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 089A919465B2 for ; Tue, 27 Jun 2023 15:07:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ECD8A48FB01; Tue, 27 Jun 2023 15:07:40 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FE8C40140F for ; Tue, 27 Jun 2023 15:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878932; 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=43eQCDjBefYSVPeZsQa4V/9cREPCmjoDeHopOADVfv0=; b=TWJ3RDcRPtAGstHmP0oMfkpF1YKz2RsyoZMolYa6NJCNI9rzOsV4YZsI6BrKN6NyOLduTG h/4tFxa5T/sZ6DoJex7vZChKJ1JewCrEl4ITMQjjBZxP+O/Wuy063/Hxxx4SXQ2bIHL4Tk X1qPA/PZQ9eZk9gmH9dnny3J5GjSYNQ= X-MC-Unique: hon4N5lDO4iMiy2yU6Zg3w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 20/24] virdomainmomentobjlist: introduce virDomainMomentIsAncestor Date: Tue, 27 Jun 2023 17:07:23 +0200 Message-ID: <3476db3b9f9dd7371d75be7065e01c5fcf5d1314.1687877087.git.phrdina@redhat.com> 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.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: 1687878935239100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This new helper will allow us to check if we are able to delete external snapshot after user did revert to non-leaf snapshot. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/virdomainmomentobjlist.c | 17 +++++++++++++++++ src/conf/virdomainmomentobjlist.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 22 insertions(+) diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index e5cdd9a141..ea9850df8c 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -582,3 +582,20 @@ virDomainMomentFindLeaf(virDomainMomentObjList *list) return moment; return NULL; } + + +/* Check if @moment is descendant of @ancestor. */ +bool +virDomainMomentIsAncestor(virDomainMomentObj *moment, + virDomainMomentObj *ancestor) +{ + if (moment =3D=3D ancestor) + return false; + + for (moment =3D moment->parent; moment; moment =3D moment->parent) { + if (moment =3D=3D ancestor) + return true; + } + + return false; +} diff --git a/src/conf/virdomainmomentobjlist.h b/src/conf/virdomainmomentob= jlist.h index d2ab3b46b1..2ea6b181c0 100644 --- a/src/conf/virdomainmomentobjlist.h +++ b/src/conf/virdomainmomentobjlist.h @@ -157,3 +157,7 @@ virDomainMomentCheckCycles(virDomainMomentObjList *list, =20 virDomainMomentObj * virDomainMomentFindLeaf(virDomainMomentObjList *list); + +bool +virDomainMomentIsAncestor(virDomainMomentObj *moment, + virDomainMomentObj *ancestor); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2b1d4e4512..2f4ab607e5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1221,6 +1221,7 @@ virDomainMomentDropChildren; virDomainMomentDropParent; virDomainMomentForEachChild; virDomainMomentForEachDescendant; +virDomainMomentIsAncestor; virDomainMomentMoveChildren; virDomainMomentObjFree; virDomainMomentObjNew; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878951; cv=none; d=zohomail.com; s=zohoarc; b=Ac1PxG37hI8g6jsWvGbWHWgei6wuW+rFRmHaOF6p9Rc18TCMyfdafid7avtZBKKbxTVIHK68lIYVtLFs3vTzPmjGz/YXTykSKr4wfSPOgoXvP7SGa9vV2EDN0Jpd2V5B+q3G1t5F0+zIzZDRLaiQ9A4uqj77spJrvhtcuP0urbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878951; 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=hDGhQmNDOOhgz74mCQyarA0dFI8iVH4jSJo4hRMynxE=; b=T8y6rg8m4LvvBP1fI3KV8f3D9osgJlC+tf8vME6CwWojR3fW7knpNIWDVgpDZ/MhFNfH0r3ViHGHaMltO8+nRK5bAz+xc2TM/Czix1MHgW1SLRRZ6WUyK8RuYc6WIphHcEV0LGrOyhI9JjPv1+//LSiMskM00JKrdzuKK5OChh8= 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 1687878951173290.2650549011597; Tue, 27 Jun 2023 08:15:51 -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-382-jjBztnrKNMmP0hXGVnncHg-1; Tue, 27 Jun 2023 11:15:28 -0400 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 9DB848C76E6; Tue, 27 Jun 2023 15:08:06 +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 7394DC478C7; Tue, 27 Jun 2023 15:08: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 6BD7119451D7; Tue, 27 Jun 2023 15:07:48 +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 9CE101946589 for ; Tue, 27 Jun 2023 15:07:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8D5CF400E88; Tue, 27 Jun 2023 15:07:41 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3110E48FB01 for ; Tue, 27 Jun 2023 15:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878950; 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=hDGhQmNDOOhgz74mCQyarA0dFI8iVH4jSJo4hRMynxE=; b=glk+bSiRVpAVrUFzyKY6XqRtOudRNALVzANDTycGQmhCQsCD66xlar4e3EyMSdWBI64QM6 Y2JW7KpnuuFMqWIfIphqlFCFF7xzphJbDV6izKiAgbMucFQ3DjcvomWQCycwNZhn5+1vHu TwBvpGwqne+8bdfdGsZyMf9970OXoOU= X-MC-Unique: jjBztnrKNMmP0hXGVnncHg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 21/24] qemu_snapshot: update backing store after deleting external snapshot Date: Tue, 27 Jun 2023 17:07:24 +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.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: 1687878952689100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With introduction of external snapshot revert we will have to update backing store of qcow images not actively used be QEMU manually. The need for this patch comes from the fact that we stop and start QEMU process therefore after revert not all existing snapshots will be known to that QEMU process due to reverting to non-leaf snapshot or having multiple branches. We need to loop over all existing snapshots and check all disks to see if they happen to have the image we are deleting as backing store and update them to point to the new image except for images currently used by the running QEMU process doing the merge operation. Signed-off-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 95 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 2950ad7d77..337c83f151 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2530,6 +2530,8 @@ typedef struct _qemuSnapshotDeleteExternalData { virStorageSource *parentDiskSrc; /* backing disk source of the @diskSr= c */ virStorageSource *prevDiskSrc; /* source of disk for which @diskSrc is backing disk */ + GSList *disksWithBacking; /* list of storage source for which the + deleted storage source is backing store */ qemuBlockJobData *job; bool merge; } qemuSnapshotDeleteExternalData; @@ -2542,6 +2544,7 @@ qemuSnapshotDeleteExternalDataFree(qemuSnapshotDelete= ExternalData *data) return; =20 virObjectUnref(data->job); + g_slist_free(data->disksWithBacking); =20 g_free(data); } @@ -2591,6 +2594,60 @@ qemuSnapshotFindParentSnapForDisk(virDomainMomentObj= *snap, } =20 =20 +struct _qemuSnapshotDisksWithBackingStoreData { + virDomainMomentObj *current; + virStorageSource *diskSrc; + GSList **disksWithBacking; +}; + + +static int +qemuSnapshotDiskHasBackingDisk(void *payload, + const char *name G_GNUC_UNUSED, + void *opaque) +{ + virDomainMomentObj *snap =3D payload; + virDomainSnapshotDef *snapdef =3D virDomainSnapshotObjGetDef(snap); + struct _qemuSnapshotDisksWithBackingStoreData *data =3D opaque; + ssize_t i; + + /* skip snapshots that are within the active snapshot tree as it will = be handled + * by qemu */ + if (virDomainMomentIsAncestor(data->current, snap) || data->current = =3D=3D snap) + return 0; + + for (i =3D 0; i < snapdef->parent.dom->ndisks; i++) { + virDomainDiskDef *disk =3D snapdef->parent.dom->disks[i]; + + if (!virStorageSourceIsLocalStorage(disk->src)) + continue; + + if (!disk->src->backingStore) + ignore_value(virStorageSourceGetMetadata(disk->src, -1, -1, 1,= false)); + + if (virStorageSourceIsSameLocation(disk->src->backingStore, data->= diskSrc)) + *data->disksWithBacking =3D g_slist_prepend(*data->disksWithBa= cking, disk->src); + } + + return 0; +} + + +static void +qemuSnapshotGetDisksWithBackingStore(virDomainObj *vm, + virDomainMomentObj *snap, + qemuSnapshotDeleteExternalData *data) +{ + struct _qemuSnapshotDisksWithBackingStoreData iterData; + + iterData.current =3D virDomainSnapshotGetCurrent(vm->snapshots); + iterData.diskSrc =3D data->diskSrc; + iterData.disksWithBacking =3D &data->disksWithBacking; + + virDomainMomentForEachDescendant(snap, qemuSnapshotDiskHasBackingDisk,= &iterData); +} + + /** * qemuSnapshotDeleteExternalPrepareData: * @vm: domain object @@ -2682,6 +2739,8 @@ qemuSnapshotDeleteExternalPrepareData(virDomainObj *v= m, _("snapshot VM disk source and parent d= isk source are not the same")); return -1; } + + qemuSnapshotGetDisksWithBackingStore(vm, snap, data); } =20 data->parentSnap =3D qemuSnapshotFindParentSnapForDisk(snap, d= ata->snapDisk); @@ -3063,6 +3122,40 @@ qemuSnapshotSetInvalid(virDomainObj *vm, } =20 =20 +static void +qemuSnapshotUpdateBackingStore(virDomainObj *vm, + qemuSnapshotDeleteExternalData *data) +{ + GSList *cur =3D NULL; + const char *qemuImgPath; + virQEMUDriver *driver =3D QEMU_DOMAIN_PRIVATE(vm)->driver; + + if (!(qemuImgPath =3D qemuFindQemuImgBinary(driver))) + return; + + for (cur =3D data->disksWithBacking; cur; cur =3D g_slist_next(cur)) { + virStorageSource *diskSrc =3D cur->data; + g_autoptr(virCommand) cmd =3D NULL; + + /* creates cmd line args: qemu-img create -f qcow2 -o */ + if (!(cmd =3D virCommandNewArgList(qemuImgPath, + "rebase", + "-u", + "-F", + virStorageFileFormatTypeToString(= data->parentDiskSrc->format), + "-f", + virStorageFileFormatTypeToString(= diskSrc->format), + "-b", + data->parentDiskSrc->path, + diskSrc->path, + NULL))) + continue; + + ignore_value(virCommandRun(cmd, NULL)); + } +} + + static int qemuSnapshotDiscardExternal(virDomainObj *vm, virDomainMomentObj *snap, @@ -3149,6 +3242,8 @@ qemuSnapshotDiscardExternal(virDomainObj *vm, =20 qemuBlockJobSyncEnd(vm, data->job, VIR_ASYNC_JOB_SNAPSHOT); =20 + qemuSnapshotUpdateBackingStore(vm, data); + if (qemuSnapshotSetInvalid(vm, data->parentSnap, data->snapDisk, f= alse) < 0) goto error; } --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878909; cv=none; d=zohomail.com; s=zohoarc; b=cvZyB3gs0ojfKaFZqJNVE+WvT7qAZRMFqTnvwJp/e2jUfDZUgM/fPNbB+9uOKDl8JO8ru4cOVpTblL7etHSuHS46ddEjPrcb+YLaa2QLCcLRrP6dtqQftjtKaMstytlx/cpZK1gBGgv3HIVa/ni7jw4NWnMUwO7V6nDz9Le2Lkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878909; 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=/5Ogw3I3hQXe9dAW4+e903Z4r8KDMAUgY+0HQM9Qkh0=; b=DszjLR1/xQvCZ5C4XJ9VjZuTUBew6VnhdenFG6+Hbqu8l2HiFVoTK5PuFPn7cHYsqk1aReRq6aZPMkCWgK8mHmO8nrXI1vQIwd4dcJK4wi8Ijw0oZ6zd+aFeEHlb/WTZYPULSTeALwPo0ZgdKSskeWmiNSaYodMF2d2ZHxZbnCA= 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 1687878909189608.5301368643005; Tue, 27 Jun 2023 08:15:09 -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-260-EPFFBxcsP_aPdQDHOwtiaA-1; Tue, 27 Jun 2023 11:14:58 -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 2B10895F375; Tue, 27 Jun 2023 15:08:06 +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 0B8884229B6; Tue, 27 Jun 2023 15:08: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 6B34219452CB; Tue, 27 Jun 2023 15:07:43 +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 48C0E1946588 for ; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2DB9040140F; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6800400E88 for ; Tue, 27 Jun 2023 15:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878907; 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=/5Ogw3I3hQXe9dAW4+e903Z4r8KDMAUgY+0HQM9Qkh0=; b=BlxsLvObutO+2dVzO0Xt6YSlTuKYwgKMb4DcQ4ntp8M3nVKNFEgCFDqDLEapSWIyv7P+ED ERy/GLLjJGXlA17t5MJZ79xFDV6TF8AgqEB9HXPgU/PVn1mHmky9JdFhVveFlBCHQTxltX wFSn5kJ92XequfWeGlKk1t1hP556z/I= X-MC-Unique: EPFFBxcsP_aPdQDHOwtiaA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 22/24] qemu_snapshot: check only once if snapshot is external Date: Tue, 27 Jun 2023 17:07:25 +0200 Message-ID: <9fd07651be687d395312e27929d3ac249eefd09a.1687877087.git.phrdina@redhat.com> 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.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: 1687878910628100001 Content-Type: text/plain; charset="utf-8"; x-default="true" There will be more external snapshot checks introduced by following patch so group them together. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 337c83f151..9246c02f12 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3635,18 +3635,18 @@ qemuSnapshotDeleteValidate(virDomainObj *vm, } } =20 - if (virDomainSnapshotIsExternal(snap) && - qemuDomainHasBlockjob(vm, false)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot delete external snapshots when there is a= nother active block job")); - return -1; - } + if (virDomainSnapshotIsExternal(snap)) { + if (qemuDomainHasBlockjob(vm, false)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cannot delete external snapshots when there = is another active block job")); + return -1; + } =20 - if (virDomainSnapshotIsExternal(snap) && - (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("deletion of external disk snapshots with childre= n not supported")); - return -1; + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of external disk snapshots with chi= ldren not supported")); + return -1; + } } =20 return 0; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687878999; cv=none; d=zohomail.com; s=zohoarc; b=m/8mVCelhS4VXcir82n5mE5/KwbeNZDR04kOR2B6tSV38P4q0l3Pneq/ZEhrQ/XOyv4QQ1k4iJP9VJZ2jSemtjfukpECcyHrx/YXgAvmN+x21o4Aj+3nIxtkzcgLgUjFiI+ZZZc/ZFgf3dAYc6n1xvOwwJNWthD/V8Q4HaIC+os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687878999; 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=+b6K0ibHqikSXtjdakwAkGnjJ4KGxmI+C9JJPkoGZyY=; b=nHDf9m8Swr0rp/aA+7hDlLx/vndr5/jva2aN01dsa183yJVxtmaN5UL22JYO7uTy8E+4MKDWrEtUTKXj9LFBPwXm0E7zSfFy7ZWkuaQt+zyFnP0X64EgOfoI+3Y0/WoDO+F0ntl5YpFVBw6cDbux/ytLOKpg9kw2g3IDbY/Ao0A= 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 168787899928716.13001974942142; Tue, 27 Jun 2023 08:16:39 -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-465-REkINKBdNdy4JKUJwaehUA-1; Tue, 27 Jun 2023 11:15:26 -0400 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 CCD14299E76D; Tue, 27 Jun 2023 15:08:06 +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 B69C0C478C6; Tue, 27 Jun 2023 15:08: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 A0E1419451E5; Tue, 27 Jun 2023 15:07:48 +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 D20151946588 for ; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C2C7E48FB01; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66ADE48FB02 for ; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687878998; 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=+b6K0ibHqikSXtjdakwAkGnjJ4KGxmI+C9JJPkoGZyY=; b=PFkSqAbfbwLCXLeyRPBxUbb5Z86zydmJYC1VH1km7xkq0B/VVnf75X+eG+uryNa5du18Fl UEbBvTGPa2Thia2tWe2upOfILzAaa+4IxXa78FqYMsUolPZL+jh8QYGVaF2AZ/Ms2OAn38 uqQqWTSYceUlvk0FkiTP4ydb59ylMTQ= X-MC-Unique: REkINKBdNdy4JKUJwaehUA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 23/24] qemu_snapshot: add checks for external snapshot deletion Date: Tue, 27 Jun 2023 17:07:26 +0200 Message-ID: <9d095626099da72faaf0a2337db06497575530d1.1687877087.git.phrdina@redhat.com> 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.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: 1687878999874100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With the introduction of external snapshot revert support we need to error out in some cases when trying to delete some snapshots. If users reverts to non-leaf snapshots and would try to delete it after the revert is done it would not work currently as this operation would require using block-stream which is not implemented for now as in this case the snapshot has two children so the disk files have multiple overlays. Similarly if user reverts to non-leaf snapshot and would try to delete snapshot that is non-leaf but not in currently active snapshot chain we would still need to use block-commit operation. The issue here is that in order to do that we would have to start new qemu process with different domain definition than what is currently used by the domain. If the current domain would be running it would complicate things even more so this operation is not yet supported. If user creates new snapshot after reverting to non-leaf snapshot it creates a new branch. Deleting snapshot with multiple children will require block-stream which is not implemented for now. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 9246c02f12..9e8a7f2f9f 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3636,6 +3636,8 @@ qemuSnapshotDeleteValidate(virDomainObj *vm, } =20 if (virDomainSnapshotIsExternal(snap)) { + virDomainMomentObj *current =3D virDomainSnapshotGetCurrent(vm->sn= apshots); + if (qemuDomainHasBlockjob(vm, false)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot delete external snapshots when there = is another active block job")); @@ -3647,6 +3649,25 @@ qemuSnapshotDeleteValidate(virDomainObj *vm, _("deletion of external disk snapshots with chi= ldren not supported")); return -1; } + + if (snap =3D=3D current && snap->nchildren !=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of active external snapshot that is= not a leaf snapshot is not supported")); + return -1; + } + + if (snap !=3D current && snap->nchildren !=3D 0 && + virDomainMomentIsAncestor(snap, current)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of non-leaf external snapshot that = is not in active chain is not supported")); + return -1; + } + + if (snap->nchildren > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("deletion of external disk snapshot with mult= iple children snapshots not supported")); + return -1; + } } =20 return 0; --=20 2.41.0 From nobody Sat May 18 06:04:10 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=1687879290; cv=none; d=zohomail.com; s=zohoarc; b=hNwNUHMD1x5WZKcoF5Z+QSxpBwYujTjWt+WhWP3kV3dpGi31hvVCT63ZAqpg8fiOsYx8DHgjSf4lILuXMZFm2ZOFLOxXpgXcvQrSr3ghGPkey4Poo7kQFd1XHoJYZQt+9//Y1qWaS1h7AvlHua//DC7KWvhZwdoXAA4/1qVJukk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687879290; 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=BlRTGeS60aMgK+fbq0Uf05p35/NLeXChIOXxTF8/NHA=; b=lk+x587bN3lbtM1NU4Nup3U//H7qGJ7c3crvzKTbSjqP7E9Lrsx71VTzgF+A8YyjHnYP7CyiveKQGI2JOxGGNWZO3VHE580vp4Ff0UakPD0uY0tHnOWg3WvFjYwiTDiqdvHw+vr/azAhpfELg3Sf1kSI8ePbOYVnDBrXGgIA4zU= 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 1687879290736497.51508933718435; Tue, 27 Jun 2023 08:21:30 -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-439-4IWFNXOjMGOv6R6hkHB0RA-1; Tue, 27 Jun 2023 11:17:31 -0400 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 640978B0D74; Tue, 27 Jun 2023 15:08:12 +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 02A66C478CD; Tue, 27 Jun 2023 15:08:12 +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 E5381194F243; Tue, 27 Jun 2023 15:07:48 +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 871D719451CD for ; Tue, 27 Jun 2023 15:07:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 664C048FB01; Tue, 27 Jun 2023 15:07:43 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.45.225.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09ADE40140F for ; Tue, 27 Jun 2023 15:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687879289; 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=BlRTGeS60aMgK+fbq0Uf05p35/NLeXChIOXxTF8/NHA=; b=VE/pw2fmQNTLNle9X/Pt0SOy5qWljRhsCmZKduo/yx0dSBPFnIrGqwsgg2ujczrOFzGT65 Inb7mHUgbS/9QClQrRonlFO9FwqxB3OYRHBrheE8Ldq9JBLb2p2YydhfOvgMg7dnX25Euk cczU6tWLy+hzQ+gQg39wiEQI0w4nICk= X-MC-Unique: 4IWFNXOjMGOv6R6hkHB0RA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 24/24] qemu_snapshot: allow snapshot revert for external snapshots Date: Tue, 27 Jun 2023 17:07:27 +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.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: 1687879291041100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that the support to revert external snapshots is implemented we can drop this check. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 9e8a7f2f9f..5150e8685a 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1880,12 +1880,6 @@ qemuSnapshotRevertValidate(virDomainObj *vm, return -1; } =20 - if (virDomainSnapshotIsExternal(snap)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("revert to external snapshot not supported yet")); - return -1; - } - if (!snap->def->dom) { virReportError(VIR_ERR_SNAPSHOT_REVERT_RISKY, _("snapshot '%1$s' lacks domain '%2$s' rollback inf= o"), --=20 2.41.0