From nobody Fri Nov 21 10:11:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1763545646; cv=none; d=zohomail.com; s=zohoarc; b=glge8ktEFEc5ttY4bEg0GdZpU7HzrbtsErmzkcEbMCgL9HXszaBt8sVoTq+y4lo63uwLRp8GsqkWaVnlcRI2+qAUhMhKkP87s8KOtojVb3i2Dr0oZivgrQRIlSnK3VTBgprhZVxaSVLnuw+9dtX60o8Xrl6iDt7mKhdrrrI4+ng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763545646; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=ngw5uqpHvBvOyCABI43yY73G3GzGin01XU1l/m1GGHA=; b=QnC+flicA5rHVzsk2kRybsFTnIo1fVtkCg/G71CD/UMOd4T/szuqLdAwFxUVd8j9TPh8pU7miGmhD24g9jC3ZK3D+pE8hfPdlf8axW7ZbKQzFB9/P5wCAk7IDCcsX58VeGaSmW2I8iYO3A73HbBkyskEzeUFOBeQmLOeq2SI98A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 176354564696963.342818098903194; Wed, 19 Nov 2025 01:47:26 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 589B0418A1; Wed, 19 Nov 2025 04:47:24 -0500 (EST) Received: from [172.19.199.50] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 9D53444121; Wed, 19 Nov 2025 04:38:41 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id E90F043F5E; Wed, 19 Nov 2025 04:38:15 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 90D4B43F66 for ; Wed, 19 Nov 2025 04:38:04 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-JV438wdWPZiaGvzX_NgG_Q-1; Wed, 19 Nov 2025 04:38:02 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D1E6F1956050 for ; Wed, 19 Nov 2025 09:38:01 +0000 (UTC) Received: from speedmetal.openshiftapps.com (unknown [10.45.242.12]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1458718004A3 for ; Wed, 19 Nov 2025 09:38:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763545084; h=from:from: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; bh=ngw5uqpHvBvOyCABI43yY73G3GzGin01XU1l/m1GGHA=; b=hlEjcxvD1b7har0ikw/7h7fumMKltzG4w0rlWKTFbobjvjNLcVj1w+gH3JhP3Lm2RBcw1N mmQJiuspqkg6drcQfT/RF6JlpNDharxAEJIgMIHK4n4TEtTVU67XSo/A+b91KkL+91SKDP TVhMPndxUNdk5L80GmU8F9McGt4LtCQ= X-MC-Unique: JV438wdWPZiaGvzX_NgG_Q-1 X-Mimecast-MFC-AGG-ID: JV438wdWPZiaGvzX_NgG_Q_1763545081 To: devel@lists.libvirt.org Subject: [PATCH 6/8] lib: Introduce VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN flag Date: Wed, 19 Nov 2025 10:37:49 +0100 Message-ID: <9b296a23112f45bddc8bb1e4fdda753572c8561a.1763544909.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: f_5tI1A3Se4yicJ4GjrG-s5KLZP6uwJxuWkywh86FPs_1763545081 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PU7OZNJ65PDRKBGOOSIK5MZ23NLIUCOA X-Message-ID-Hash: PU7OZNJ65PDRKBGOOSIK5MZ23NLIUCOA X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1763545648991153000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa This flag will instruct the hypervisor driver to keep the VM around while the backup is running if the guest OS decides to shut down, so that the backup can be finished. Signed-off-by: Peter Krempa --- docs/manpages/virsh.rst | 6 ++++++ include/libvirt/libvirt-domain.h | 6 ++++-- src/libvirt-domain.c | 5 +++++ tools/virsh-backup.c | 7 +++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 73263ffc7f..a9d691824e 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -2186,6 +2186,7 @@ backup-begin :: backup-begin domain [backupxml] [checkpointxml] [--reuse-external] + [--preserve-domain-on-shutdown] Begin a new backup job. If *backupxml* is omitted, this defaults to a full backup using a push model to filenames generated by libvirt; supplying XML @@ -2199,6 +2200,11 @@ libvirt. For more information on backup XML, see: If *--reuse-external* is used it instructs libvirt to reuse temporary and output files provided by the user in *backupxml*. +When the *--preserve-domain-on-shutdown* flag is used libvirt will not +terminate the VM if the guest OS shuts down while the backup is running. T= he VM +will be instead kept in VIR_DOMAIN_PAUSED state until the backup job finis= hes. +The vm can be also resumed in order to boot again. + If *checkpointxml* is specified, a second file with a top-level element of *domaincheckpoint* is used to create a simultaneous checkpoint, for doing a later incremental backup relative to the time diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index a2cf762e1a..ad25ed14e1 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -8518,8 +8518,10 @@ int virDomainAgentSetResponseTimeout(virDomainPtr do= main, * Since: 6.0.0 */ typedef enum { - VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL =3D (1 << 0), /* reuse separate= ly - provided images = (Since: 6.0.0) */ + /* reuse separately provided images (Since: 6.0.0) */ + VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL =3D (1 << 0), + /* preserve the domain if the guest OS shuts down while the backup is = running (Since: 11.10.0) */ + VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN =3D (1 << 1), } virDomainBackupBeginFlags; int virDomainBackupBegin(virDomainPtr domain, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index ca110bdf85..74c70a0a43 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13682,6 +13682,11 @@ virDomainAgentSetResponseTimeout(virDomainPtr doma= in, * temporary files described by the @backupXML document were created by the * caller with correct format and size to hold the backup or temporary dat= a. * + * When the VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN flag is used + * libvirt will not terminate the VM if the guest OS shuts down while the + * backup is running. The VM will be kept in the VIR_DOMAIN_PAUSED state + * until the backup job finishes or until it's resumed via virDomainResume. + * * The creation of a new checkpoint allows for future incremental backups. * Note that some hypervisors may require a particular disk format, such as * qcow2, in order to take advantage of checkpoints, while allowing arbitr= ary diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 39e62f9ba9..1d009a3f2c 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -48,6 +48,10 @@ static const vshCmdOptDef opts_backup_begin[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("reuse files provided by caller"), }, + {.name =3D "preserve-domain-on-shutdown", + .type =3D VSH_OT_BOOL, + .help =3D N_("avoid shutdown of the domain while the backup is runnin= g"), + }, {.name =3D NULL} }; @@ -65,6 +69,9 @@ cmdBackupBegin(vshControl *ctl, if (vshCommandOptBool(cmd, "reuse-external")) flags |=3D VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL; + if (vshCommandOptBool(cmd, "preserve-domain-on-shutdown")) + flags |=3D VIR_DOMAIN_BACKUP_BEGIN_PRESERVE_SHUTDOWN_DOMAIN; + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; --=20 2.51.1