tools: add --reset-nvram arg to several virsh commands

This wires up support for resetting NVRAM for all APIs that allow
this feature.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2022-02-03 16:42:28 +00:00
parent 5413608dc2
commit 7904e521b2
3 changed files with 41 additions and 4 deletions

View File

@ -1455,7 +1455,7 @@ create
::
create FILE [--console] [--paused] [--autodestroy]
[--pass-fds N,M,...] [--validate]
[--pass-fds N,M,...] [--validate] [--reset-nvram]
Create a domain from an XML <file>. 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.
If *--reset-nvram* is specified, any existing NVRAM file will be deleted
and re-initialized from its pristine template.
**Example:**
#. prepare a template from an existing domain (skip directly to 3a if writing
@ -3736,7 +3739,7 @@ restore
::
restore state-file [--bypass-cache] [--xml file]
[{--running | --paused}]
[{--running | --paused}] [--reset-nvram]
Restores a domain from a ``virsh save`` state file. See *save* for more info.
@ -3754,6 +3757,9 @@ save image to decide between running or paused; passing either the
*--running* or *--paused* flag will allow overriding which state the
domain should be started in.
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
start domain-name-or-uuid [--console] [--paused]
[--autodestroy] [--bypass-cache] [--force-boot]
[--pass-fds N,M,...]
[--pass-fds N,M,...] [--reset-nvram]
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.
If *--reset-nvram* is specified, any existing NVRAM file will be deleted
and re-initialized from its pristine template.
suspend
-------
@ -7352,7 +7361,8 @@ snapshot-revert
::
snapshot-revert domain {snapshot | --current} [{--running | --paused}] [--force]
snapshot-revert domain {snapshot | --current} [{--running | --paused}]
[--force] [--reset-nvram]
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 content
mismatches when run.
If *--reset-nvram* is specified, any existing NVRAM file will be deleted
and re-initialized from its pristine template.
snapshot-delete
---------------

View File

@ -4010,6 +4010,10 @@ static const vshCmdOptDef opts_start[] = {
.completer = virshCompleteEmpty,
.help = N_("pass file descriptors N,M,... to the guest")
},
{.name = "reset-nvram",
.type = VSH_OT_BOOL,
.help = N_("re-initialize NVRAM from its pristine template")
},
{.name = NULL}
};
@ -4087,6 +4091,8 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_START_BYPASS_CACHE;
if (vshCommandOptBool(cmd, "force-boot"))
flags |= VIR_DOMAIN_START_FORCE_BOOT;
if (vshCommandOptBool(cmd, "reset-nvram"))
flags |= VIR_DOMAIN_START_RESET_NVRAM;
/* 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[] = {
.type = VSH_OT_BOOL,
.help = N_("restore domain into paused state")
},
{.name = "reset-nvram",
.type = VSH_OT_BOOL,
.help = N_("re-initialize NVRAM from its pristine template")
},
{.name = NULL}
};
@ -5289,6 +5299,8 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_SAVE_RUNNING;
if (vshCommandOptBool(cmd, "paused"))
flags |= VIR_DOMAIN_SAVE_PAUSED;
if (vshCommandOptBool(cmd, "reset-nvram"))
flags |= VIR_DOMAIN_SAVE_RESET_NVRAM;
if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0)
return false;
@ -8093,6 +8105,10 @@ static const vshCmdOptDef opts_create[] = {
.type = VSH_OT_BOOL,
.help = N_("validate the XML against the schema")
},
{.name = "reset-nvram",
.type = VSH_OT_BOOL,
.help = N_("re-initialize NVRAM from its pristine template")
},
{.name = NULL}
};
@ -8125,6 +8141,8 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_START_AUTODESTROY;
if (vshCommandOptBool(cmd, "validate"))
flags |= VIR_DOMAIN_START_VALIDATE;
if (vshCommandOptBool(cmd, "reset-nvram"))
flags |= VIR_DOMAIN_START_RESET_NVRAM;
if (nfds)
dom = virDomainCreateXMLWithFiles(priv->conn, buffer, nfds, fds, flags);

View File

@ -1725,6 +1725,10 @@ static const vshCmdOptDef opts_snapshot_revert[] = {
.type = VSH_OT_BOOL,
.help = N_("try harder on risky reverts")
},
{.name = "reset-nvram",
.type = VSH_OT_BOOL,
.help = N_("re-initialize NVRAM from its pristine template")
},
{.name = NULL}
};
@ -1742,6 +1746,8 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING;
if (vshCommandOptBool(cmd, "paused"))
flags |= VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED;
if (vshCommandOptBool(cmd, "reset-nvram"))
flags |= 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