]> xenbits.xensource.com Git - libvirt.git/commitdiff
include: define constants for resetting NVRAM state
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 3 Feb 2022 15:58:54 +0000 (15:58 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 8 Feb 2022 13:04:11 +0000 (13:04 +0000)
When starting a guest with pflash based firmware, we will initialize
NVRAM from a template if it does not already exist. In theory if the
firmware code file is updated, the existing NVRAM variables should
continue to work correctly. It is inevitable that this could break
accidentally one day. Or a bug in the firmware might corrupt the
NVRAM storage. Or user might make bad changes to the settings that
prevent booting. Or the user might have re-configured the XML to
point to a different firmware file incompatible with the current
variables.

In all these cases it would be useful to delete the existing NVRAM
and initialize it from the pristine template.

To support this introduce a VIR_DOMAIN_START_RESET_NVRAM constant
for use with virDomainCreate / virDomainCreateXML, along with
VIR_DOMAIN_SAVE_RESET_NVRAM for use with virDomainRestore and
VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM for use with
virDomainSnapshotRevert.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
include/libvirt/libvirt-domain-snapshot.h
include/libvirt/libvirt-domain.h
src/libvirt-domain-snapshot.c
src/libvirt-domain.c

index 90673ed0fb5082e7ae245555d0db6ace45fb0135..d729d1a532cdc634e93ad5dc95feee4918ff2c0d 100644 (file)
@@ -198,6 +198,7 @@ typedef enum {
     VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING = 1 << 0, /* Run after revert */
     VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED  = 1 << 1, /* Pause after revert */
     VIR_DOMAIN_SNAPSHOT_REVERT_FORCE   = 1 << 2, /* Allow risky reverts */
+    VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM = 1 << 3, /* Re-initialize NVRAM from template */
 } virDomainSnapshotRevertFlags;
 
 /* Revert the domain to a point-in-time snapshot.  The
index 374859fdffb7e786392c7dd8704742e514f95b2f..8c16598817901d16473e12c1a572cdfac502f904 100644 (file)
@@ -302,6 +302,7 @@ typedef enum {
     VIR_DOMAIN_START_BYPASS_CACHE = 1 << 2, /* Avoid file system cache pollution */
     VIR_DOMAIN_START_FORCE_BOOT   = 1 << 3, /* Boot, discarding any managed save */
     VIR_DOMAIN_START_VALIDATE     = 1 << 4, /* Validate the XML document against schema */
+    VIR_DOMAIN_START_RESET_NVRAM  = 1 << 5, /* Re-initialize NVRAM from template */
 } virDomainCreateFlags;
 
 
@@ -1268,6 +1269,7 @@ typedef enum {
     VIR_DOMAIN_SAVE_BYPASS_CACHE = 1 << 0, /* Avoid file system cache pollution */
     VIR_DOMAIN_SAVE_RUNNING      = 1 << 1, /* Favor running over paused */
     VIR_DOMAIN_SAVE_PAUSED       = 1 << 2, /* Favor paused over running */
+    VIR_DOMAIN_SAVE_RESET_NVRAM  = 1 << 3, /* Re-initialize NVRAM from template */
 } virDomainSaveRestoreFlags;
 
 int                     virDomainSave           (virDomainPtr domain,
index edbf25b04d764b93683ce8df3863bbdba86c0531..69845918a29851cfcd68c03c2cbd40d31c878a8a 100644 (file)
@@ -979,6 +979,10 @@ virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
  * inactive snapshots with a @flags request to start the domain after
  * the revert.
  *
+ * If @flags includes VIR_DOMAIN_SNAPSHOT_REVERT_RESET_NVRAM, then
+ * libvirt will discard any existing NVRAM file and re-initialize
+ * NVRAM from the pristine template.
+ *
  * Returns 0 if the creation is successful, -1 on error.
  */
 int
index f2d5f834ef0ec35f0391b167ae1685695c1eecae..b8a6f103333e9c2939a0edb3ca195969d9827613 100644 (file)
@@ -154,6 +154,10 @@ virDomainGetConnect(virDomainPtr dom)
  * block attempts at migration. Hypervisors may also block save-to-file,
  * or snapshots.
  *
+ * If @flags includes VIR_DOMAIN_START_RESET_NVRAM, then libvirt will
+ * discard any existing NVRAM file and re-initialize NVRAM from the
+ * pristine template.
+ *
  * virDomainFree should be used to free the resources after the
  * domain object is no longer needed.
  *
@@ -1015,6 +1019,10 @@ virDomainRestore(virConnectPtr conn, const char *from)
  * @flags will override the default read from the file.  These two
  * flags are mutually exclusive.
  *
+ * If @flags includes VIR_DOMAIN_SAVE_RESET_NVRAM, then libvirt will
+ * discard any existing NVRAM file and re-initialize NVRAM from the
+ * pristine template.
+ *
  * Returns 0 in case of success and -1 in case of failure.
  */
 int
@@ -6763,6 +6771,10 @@ virDomainCreate(virDomainPtr domain)
  * If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
  * file for this domain is discarded, and the domain boots from scratch.
  *
+ * If @flags includes VIR_DOMAIN_START_RESET_NVRAM, then libvirt will
+ * discard any existing NVRAM file and re-initialize NVRAM from the
+ * pristine template.
+ *
  * Returns 0 in case of success, -1 in case of error
  */
 int
@@ -6835,6 +6847,10 @@ virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
  * If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
  * file for this domain is discarded, and the domain boots from scratch.
  *
+ * If @flags includes VIR_DOMAIN_START_RESET_NVRAM, then libvirt will
+ * discard any existing NVRAM file and re-initialize NVRAM from the
+ * pristine template.
+ *
  * Returns 0 in case of success, -1 in case of error
  */
 int