From nobody Sun Feb 8 08:22:30 2026 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=1644346507; cv=none; d=zohomail.com; s=zohoarc; b=bOKiaRiauaEtk8eF/3PIBGsvX1ZqnIiTRXxF/xVUIhSrPOepjpz4UOb4jJ1Y43naaonodmHqN6e1N1A7NZrZ5RF02vR1pqHJutWCQjqrLXrNtNTxojL8reABsMcfn4vqyaIwYapObSxJNc31lb7jiOap4c2h41WNzLZsYfXeHQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644346507; 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=tGOXgrn3Z9BdlAoG66dmR0gSuFEEnmt949hCXFcPXUk=; b=Yle9Lllnr/5DEPOyE6YEyjHwO7s204iqAWeSLvEX8VUJIbTbVGOrimC5QmvFZrzG+a9QAJmjsKZQULZ3H3Jzgq0VsSP2ALIiYgBoKttmFqsNlYzhdqGwK+TwMxVhHPdJzMWtrADw9MNM0VaOR5Fy+UrRthsIxWVdw7e1YeP7Dwg= 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 1644346507560305.2384173738709; Tue, 8 Feb 2022 10:55:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-531-006RwDXJMTmXXrpxOI6HNQ-1; Tue, 08 Feb 2022 13:53:30 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 01EF88519E5; Tue, 8 Feb 2022 18:53:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D77387A48F; Tue, 8 Feb 2022 18:53:24 +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 8F0011826D2C; Tue, 8 Feb 2022 18:53:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 217CbHGU003378 for ; Mon, 7 Feb 2022 07:37:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 96BCB6FB8B; Mon, 7 Feb 2022 12:37:17 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id E46CD6F95B; Mon, 7 Feb 2022 12:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644346506; 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=tGOXgrn3Z9BdlAoG66dmR0gSuFEEnmt949hCXFcPXUk=; b=cxbfsQzMvdFqZAUWxTXhBiPiqn2f6bJ+8ss6Uzw9L2jAopgSBfuuzupNDtWgTO8co2G2P/ BfCkUQ4Gy+pv2Tyz9zXXLRW1WIcDUaIe++GSbb647W3BrWn77UIeeQhzQmf2rnCiWSaV1b YgTsy1x5CCX5ZQZ36EWwuRbBWd46guE= X-MC-Unique: 006RwDXJMTmXXrpxOI6HNQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] tools: add --reset-nvram arg to several virsh commands Date: Mon, 7 Feb 2022 12:37:10 +0000 Message-Id: <20220207123711.1042287-5-berrange@redhat.com> In-Reply-To: <20220207123711.1042287-1-berrange@redhat.com> References: <20220207123711.1042287-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.14 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1644346508127100001 This wires up support for resetting NVRAM for all APIs that allow this feature. Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/manpages/virsh.rst | 21 +++++++++++++++++---- tools/virsh-domain.c | 18 ++++++++++++++++++ tools/virsh-snapshot.c | 6 ++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e28927ed6c..429879d2dd 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1455,7 +1455,7 @@ create :: =20 create FILE [--console] [--paused] [--autodestroy] - [--pass-fds N,M,...] [--validate] + [--pass-fds N,M,...] [--validate] [--reset-nvram] =20 Create a domain from an XML . Optionally, *--validate* option can be passed to validate the format of the input XML file against an internal RNG @@ -1478,6 +1478,9 @@ of open file descriptors which should be pass on into= the guest. The file descriptors will be re-numbered in the guest, starting from 3. This is only supported with container based virtualization. =20 +If *--reset-nvram* is specified, any existing NVRAM file will be deleted +and re-initialized from its pristine template. + **Example:** =20 #. prepare a template from an existing domain (skip directly to 3a if writ= ing @@ -3736,7 +3739,7 @@ restore :: =20 restore state-file [--bypass-cache] [--xml file] - [{--running | --paused}] + [{--running | --paused}] [--reset-nvram] =20 Restores a domain from a ``virsh save`` state file. See *save* for more in= fo. =20 @@ -3754,6 +3757,9 @@ save image to decide between running or paused; passi= ng either the *--running* or *--paused* flag will allow overriding which state the domain should be started in. =20 +If *--reset-nvram* is specified, any existing NVRAM file will be deleted +and re-initialized from its pristine template. + ``Note``: To avoid corrupting file system contents within the domain, you should not reuse the saved state file for a second ``restore`` unless you have also reverted all storage volumes back to the same contents as when @@ -4350,7 +4356,7 @@ start =20 start domain-name-or-uuid [--console] [--paused] [--autodestroy] [--bypass-cache] [--force-boot] - [--pass-fds N,M,...] + [--pass-fds N,M,...] [--reset-nvram] =20 Start a (previously defined) inactive domain, either from the last ``managedsave`` state, or via a fresh boot if no managedsave state is @@ -4369,6 +4375,9 @@ of open file descriptors which should be pass on into= the guest. The file descriptors will be re-numbered in the guest, starting from 3. This is only supported with container based virtualization. =20 +If *--reset-nvram* is specified, any existing NVRAM file will be deleted +and re-initialized from its pristine template. + =20 suspend ------- @@ -7352,7 +7361,8 @@ snapshot-revert =20 :: =20 - snapshot-revert domain {snapshot | --current} [{--running | --paused}] = [--force] + snapshot-revert domain {snapshot | --current} [{--running | --paused}] + [--force] [--reset-nvram] =20 Revert the given domain to the snapshot specified by *snapshot*, or to the current snapshot with *--current*. Be aware @@ -7398,6 +7408,9 @@ requires the use of *--force* to proceed: likely cause extensive filesystem corruption or crashes due to swap co= ntent mismatches when run. =20 +If *--reset-nvram* is specified, any existing NVRAM file will be deleted +and re-initialized from its pristine template. + =20 snapshot-delete --------------- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 43d310f2af..97986788d7 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4010,6 +4010,10 @@ static const vshCmdOptDef opts_start[] =3D { .completer =3D virshCompleteEmpty, .help =3D N_("pass file descriptors N,M,... to the guest") }, + {.name =3D "reset-nvram", + .type =3D VSH_OT_BOOL, + .help =3D N_("re-initialize NVRAM from its pristine template") + }, {.name =3D NULL} }; =20 @@ -4087,6 +4091,8 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_START_BYPASS_CACHE; if (vshCommandOptBool(cmd, "force-boot")) flags |=3D VIR_DOMAIN_START_FORCE_BOOT; + if (vshCommandOptBool(cmd, "reset-nvram")) + flags |=3D VIR_DOMAIN_START_RESET_NVRAM; =20 /* We can emulate force boot, even for older servers that reject it. = */ if (flags & VIR_DOMAIN_START_FORCE_BOOT) { @@ -5268,6 +5274,10 @@ static const vshCmdOptDef opts_restore[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("restore domain into paused state") }, + {.name =3D "reset-nvram", + .type =3D VSH_OT_BOOL, + .help =3D N_("re-initialize NVRAM from its pristine template") + }, {.name =3D NULL} }; =20 @@ -5289,6 +5299,8 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_SAVE_RUNNING; if (vshCommandOptBool(cmd, "paused")) flags |=3D VIR_DOMAIN_SAVE_PAUSED; + if (vshCommandOptBool(cmd, "reset-nvram")) + flags |=3D VIR_DOMAIN_SAVE_RESET_NVRAM; =20 if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) return false; @@ -8093,6 +8105,10 @@ static const vshCmdOptDef opts_create[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("validate the XML against the schema") }, + {.name =3D "reset-nvram", + .type =3D VSH_OT_BOOL, + .help =3D N_("re-initialize NVRAM from its pristine template") + }, {.name =3D NULL} }; =20 @@ -8125,6 +8141,8 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_START_AUTODESTROY; if (vshCommandOptBool(cmd, "validate")) flags |=3D VIR_DOMAIN_START_VALIDATE; + if (vshCommandOptBool(cmd, "reset-nvram")) + flags |=3D VIR_DOMAIN_START_RESET_NVRAM; =20 if (nfds) dom =3D virDomainCreateXMLWithFiles(priv->conn, buffer, nfds, fds,= flags); diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 154e82b48b..b86fa73ac2 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -1725,6 +1725,10 @@ static const vshCmdOptDef opts_snapshot_revert[] =3D= { .type =3D VSH_OT_BOOL, .help =3D N_("try harder on risky reverts") }, + {.name =3D "reset-nvram", + .type =3D VSH_OT_BOOL, + .help =3D N_("re-initialize NVRAM from its pristine template") + }, {.name =3D NULL} }; =20 @@ -1742,6 +1746,8 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd= *cmd) flags |=3D VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING; if (vshCommandOptBool(cmd, "paused")) flags |=3D VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED; + if (vshCommandOptBool(cmd, "reset-nvram")) + flags |=3D VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM; /* We want virsh snapshot-revert --force to work even when talking * to older servers that did the unsafe revert by default but * reject the flag, so we probe without the flag, and only use it --=20 2.34.1