From nobody Sun May 5 15:35:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 161341010199583.62328931550473; Mon, 15 Feb 2021 09:28:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-EP-DFBt8Nz6j1x8NXAPZSg-1; Mon, 15 Feb 2021 12:28:19 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 186A71936B69; Mon, 15 Feb 2021 17:28:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF7DF19719; Mon, 15 Feb 2021 17:28:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B59EC57DFF; Mon, 15 Feb 2021 17:28:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11FHRwNV001344 for ; Mon, 15 Feb 2021 12:27:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 10A105C241; Mon, 15 Feb 2021 17:27:58 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63B5F5C541 for ; Mon, 15 Feb 2021 17:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613410100; 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=KZf536Dso21oF0pkwyVDkYGY8PFLPfg3nloXIkbGwlk=; b=h4U+BMgSp5uAsQXgCaK6YDNH5pISxgbbuxbFQ/z4oGXIEPYotgxAbnV2/egmHuauIgfBGU MBuQCOTrTDOyJv0RFBdhzmHsQoNw9gGBewplIXCHH24p0ZwDEKRvO7wAOV2o3wRPWVpjp9 KqcbNBmU7JiW/iC25TXtLpbcoUFEGsU= X-MC-Unique: EP-DFBt8Nz6j1x8NXAPZSg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/3] api: Discourage use of VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE Date: Mon, 15 Feb 2021 18:27:49 +0100 Message-Id: <04c49464662d1fd49cbd1fc0cd9d080abbe9acc5.1613409998.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The flag creates additional points of failure which are hard to recover from, such as when thawing of the filesystems fails after an otherwise successful snapshot. Encougage use of explicit virDomainFSFreeze/virDomainFSThaw. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/libvirt-domain-snapshot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libvirt-domain-snapshot.c b/src/libvirt-domain-snapshot.c index f856e5b9b8..15bf4d8634 100644 --- a/src/libvirt-domain-snapshot.c +++ b/src/libvirt-domain-snapshot.c @@ -174,6 +174,9 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr snapsh= ot) * file systems in use within domain OS. However, if the guest agent * is not present, an error is thrown. Moreover, this flag requires * VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY to be passed as well. + * For better control and error recovery users should invoke virDomainFSFr= eeze + * manually before taking the snapshot and then virDomainFSThaw to restore= the + * VM rather than using VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE. * * By default, if the snapshot involves external files, and any of the * destination files already exist as a non-empty regular file, the --=20 2.29.2 From nobody Sun May 5 15:35:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613410091766359.5337912882734; Mon, 15 Feb 2021 09:28:11 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-S0iRORdKNHGFDthkaR-1nw-1; Mon, 15 Feb 2021 12:28:08 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33A6E1020C20; Mon, 15 Feb 2021 17:28:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 094D65C241; Mon, 15 Feb 2021 17:28:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BBD3B50033; Mon, 15 Feb 2021 17:28:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11FHRx8B001353 for ; Mon, 15 Feb 2021 12:27:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3E7BB5C541; Mon, 15 Feb 2021 17:27:59 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 872515C241 for ; Mon, 15 Feb 2021 17:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613410090; 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=AEhQiKXwSZ8cmOUjAt+9FISclDeutzKdTMVv5rHDiro=; b=Ul7Esu/C/oZAiHFgydgthqlI/id4JVOKnYZr+SSvt+JcJRe4ZsvEa4dYRG9j+Ll4FPF/+2 QR7g/lFvxWeNNjfW+MJkHCzqMNOfsyfwdCZTML5cmtQXaWGnSWmKQ9gmREt0i2Ezixdn3G QWqWfjF5wilU7qXQw65cIiyksbPFLvE= X-MC-Unique: S0iRORdKNHGFDthkaR-1nw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/3] qemuSnapshotCreateActiveExternal: Don't thaw filesystems when freeze fails Date: Mon, 15 Feb 2021 18:27:50 +0100 Message-Id: <4f9561de3d57523485542f204ef90743fbcccd21.1613409998.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If we didn't freeze any filesystems we should not even attempt thawing them. Additionally 'guest-fsfreeze-freeze' fails if the filesystems are already frozen, where thawing them may break users data integrity if they used VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE accidentally after an explicit virDomainFSFreeze and the next snapshot without that flag would be taken with already thawed filesystems. This effectively reverts 7c736bab06479ccec59df69fb79a5c06d112d8fb . Libvirt nowadays checks whether the guest agent is connected and pings it before issuing an command so it's very unlikely that we'd end up in a situation where qemuSnapshotCreateActiveExternal froze filesystems and didn't thaw them. Additionally we now discourage the use of VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE since users have better control if they freeze the FS themselves. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 115c2fc91b..eacc8c6400 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1403,7 +1403,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriverPtr dri= ver, virDomainSnapshotDefPtr snapdef =3D virDomainSnapshotObjGetDef(snap); bool memory =3D snapdef->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EX= TERNAL; bool memory_unlink =3D false; - int thaw =3D 0; /* 1 if freeze succeeded, -1 if freeze failed */ + bool thaw =3D false; bool pmsuspended =3D false; int compressed; g_autoptr(virCommand) compressor =3D NULL; @@ -1415,7 +1415,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriverPtr dri= ver, * The command will fail if the guest is paused or the guest agent * is not running, or is already quiesced. */ if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE) { - int freeze; + int frozen; if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_MODIFY) = < 0) goto cleanup; @@ -1425,16 +1425,14 @@ qemuSnapshotCreateActiveExternal(virQEMUDriverPtr d= river, goto cleanup; } - freeze =3D qemuSnapshotFSFreeze(vm, NULL, 0); + frozen =3D qemuSnapshotFSFreeze(vm, NULL, 0); qemuDomainObjEndAgentJob(vm); - if (freeze < 0) { - /* the helper reported the error */ - if (freeze =3D=3D -2) - thaw =3D -1; /* the command is sent but agent failed */ + if (frozen < 0) goto cleanup; - } - thaw =3D 1; + + if (frozen > 0) + thaw =3D true; } /* We need to track what state the guest is in, since taking the @@ -1527,7 +1525,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriverPtr dri= ver, QEMU_ASYNC_JOB_SNAPSHOT, 0); virDomainAuditStop(vm, "from-snapshot"); resume =3D false; - thaw =3D 0; + thaw =3D false; virObjectEventStateQueue(driver->domainEventState, event); } else if (memory && pmsuspended) { /* qemu 1.3 is unable to save a domain in pm-suspended (S3) @@ -1559,14 +1557,12 @@ qemuSnapshotCreateActiveExternal(virQEMUDriverPtr d= river, ret =3D -1; } - if (thaw !=3D 0 && + if (thaw && qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_MODIFY) >=3D= 0 && virDomainObjIsActive(vm)) { - if (qemuSnapshotFSThaw(vm, ret =3D=3D 0 && thaw > 0) < 0) { - /* helper reported the error, if it was needed */ - if (thaw > 0) - ret =3D -1; - } + /* report error only on an otherwise successful snapshot */ + if (qemuSnapshotFSThaw(vm, ret =3D=3D 0) < 0) + ret =3D -1; qemuDomainObjEndAgentJob(vm); } --=20 2.29.2 From nobody Sun May 5 15:35:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1613410092; cv=none; d=zohomail.com; s=zohoarc; b=DfeasF3x8NVHoqFIYQ+WLwRttAJz4XB20DAOK0GQGpOKsmPnQXNGXszAEJLrCJjH1JnEOEwbQDjtcvqjVf2q3DhyhKuSTg4qWnfufD0nbIxsYjmjAk6dWbfhRTqQwAAtGOxUEraWm3OxCIKyOEtQ0P5OW5B7ewNJwC/0nVX0FaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613410092; 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=tDZqKka5TMXEd94uxx8Llys9N8O+SECDDLEpUUcrenM=; b=gg44WWL5FaCZ+fnkGEixnwFpV1UmhKqKiAqNBGNE5kDnfIuep5F40h87BDpfKiGeGKuit1cT0hdK0ok/6BKEXAtFVJ9mUtUWPLZOFsGiTdaQeWgtBZ1KKqyIBEQRlzPdu2I6z+rGZYM4sqMnnJNwY0a/JZDz66zJmDdJ/ss604c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613410092582998.247006538737; Mon, 15 Feb 2021 09:28:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-ZYf48WUVPu2pK2ASpxDz6A-1; Mon, 15 Feb 2021 12:28:09 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC6EBEC1A0; Mon, 15 Feb 2021 17:28:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C49CF62463; Mon, 15 Feb 2021 17:28:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 851399991; Mon, 15 Feb 2021 17:28:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11FHS0ZZ001373 for ; Mon, 15 Feb 2021 12:28:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C36F1B534; Mon, 15 Feb 2021 17:28:00 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id B45D55C241 for ; Mon, 15 Feb 2021 17:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613410091; 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=tDZqKka5TMXEd94uxx8Llys9N8O+SECDDLEpUUcrenM=; b=GIBYLB+FBDNh6x0YjuoCqiniR8hopPOM38rsq2AoVi/xN3nGzjIFIOrGq6VBi95e3kB72f 6VM7rOsazMefZ38DjhKWTLhR5TsT1J4uF4+eu1E26gvNbjylp7WCe6hKob+wXh0qv6Rhft KWmHGflB/bloql/uRNFpgqLmxtAU48c= X-MC-Unique: ZYf48WUVPu2pK2ASpxDz6A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/3] qemuSnapshotFSFreeze: Don't return -2 Date: Mon, 15 Feb 2021 18:27:51 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The -2 value is misleading because if 'qemuAgentFSFreeze' fails it doesn't necessarily mean that the command was sent to the agent. Since callers don't care about the -2 value specifically, remove it. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_snapshot.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index eacc8c6400..93b74b035a 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -119,9 +119,6 @@ qemuSnapshotCountExternal(void *payload, } -/* Return -1 if request is not sent to agent due to misconfig, -2 if reque= st - * is sent but failed, and number of frozen filesystems on success. If -2 = is - * returned, FSThaw should be called revert the quiesced status. */ int qemuSnapshotFSFreeze(virDomainObjPtr vm, const char **mountpoints, @@ -136,7 +133,7 @@ qemuSnapshotFSFreeze(virDomainObjPtr vm, agent =3D qemuDomainObjEnterAgent(vm); frozen =3D qemuAgentFSFreeze(agent, mountpoints, nmountpoints); qemuDomainObjExitAgent(vm, agent); - return frozen < 0 ? -2 : frozen; + return frozen; } --=20 2.29.2