From: Peter Krempa <pkre...@redhat.com>

Rather than having a bunch of extra variables save the configuration of
the daemon auto shutdown in virDomainDriverAutoShutdownConfig which is
also used when initiating the shutdown.

Signed-off-by: Peter Krempa <pkre...@redhat.com>
---
 src/qemu/qemu_conf.c   | 30 +++++++++++++++---------------
 src/qemu/qemu_conf.h   |  7 +------
 src/qemu/qemu_driver.c | 12 +++---------
 3 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 9bf12fc179..482e19b502 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -320,15 +320,15 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool 
privileged,
          *
          * XXX, or query if libvirt-guests.service is enabled perhaps ?
          */
-        cfg->autoShutdownTrySave = VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE;
-        cfg->autoShutdownTryShutdown = 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE;
-        cfg->autoShutdownPoweroff = VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE;
+        cfg->autoShutdown.trySave = VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE;
+        cfg->autoShutdown.tryShutdown = 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE;
+        cfg->autoShutdown.poweroff = 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_NONE;
     } else {
-        cfg->autoShutdownTrySave = 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_PERSISTENT;
-        cfg->autoShutdownTryShutdown = 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL;
-        cfg->autoShutdownPoweroff = VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL;
+        cfg->autoShutdown.trySave = 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_PERSISTENT;
+        cfg->autoShutdown.tryShutdown = 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL;
+        cfg->autoShutdown.poweroff = VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL;
     }
-    cfg->autoShutdownRestore = true;
+    cfg->autoShutdown.autoRestore = true;

     return g_steal_pointer(&cfg);
 }
@@ -719,11 +719,11 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg,
                            autoShutdownTrySave);
             return -1;
         }
-        cfg->autoShutdownTrySave = autoShutdownVal;
+        cfg->autoShutdown.trySave = autoShutdownVal;
     }

-    if (cfg->autoShutdownTrySave == VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL 
||
-        cfg->autoShutdownTrySave == 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_TRANSIENT) {
+    if (cfg->autoShutdown.trySave == VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_ALL 
||
+        cfg->autoShutdown.trySave == 
VIR_DOMAIN_DRIVER_AUTO_SHUTDOWN_SCOPE_TRANSIENT) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
                        _("managed save cannot be requested for transient 
domains"));
         return -1;
@@ -740,7 +740,7 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg,
                            autoShutdownTryShutdown);
             return -1;
         }
-        cfg->autoShutdownTryShutdown = autoShutdownVal;
+        cfg->autoShutdown.tryShutdown = autoShutdownVal;
     }

     if (virConfGetValueString(conf, "auto_shutdown_poweroff", 
&autoShutdownPoweroff) < 0)
@@ -754,16 +754,16 @@ virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfig *cfg,
                            autoShutdownPoweroff);
             return -1;
         }
-        cfg->autoShutdownPoweroff = autoShutdownVal;
+        cfg->autoShutdown.poweroff = autoShutdownVal;
     }

     if (virConfGetValueUInt(conf, "auto_shutdown_wait",
-                            &cfg->autoShutdownWait) < 0)
+                            &cfg->autoShutdown.waitShutdownSecs) < 0)
         return -1;
-    if (virConfGetValueBool(conf, "auto_shutdown_restore", 
&cfg->autoShutdownRestore) < 0)
+    if (virConfGetValueBool(conf, "auto_shutdown_restore", 
&cfg->autoShutdown.autoRestore) < 0)
         return -1;
     if (virConfGetValueBool(conf, "auto_save_bypass_cache",
-                            &cfg->autoSaveBypassCache) < 0)
+                            &cfg->autoShutdown.saveBypassCache) < 0)
         return -1;

     return 0;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 1ce9dbe4a8..ff376aed4d 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -208,12 +208,7 @@ struct _virQEMUDriverConfig {
     bool autoDumpBypassCache;
     bool autoStartBypassCache;
     unsigned int autoStartDelayMS;
-    virDomainDriverAutoShutdownScope autoShutdownTrySave;
-    virDomainDriverAutoShutdownScope autoShutdownTryShutdown;
-    virDomainDriverAutoShutdownScope autoShutdownPoweroff;
-    unsigned int autoShutdownWait;
-    bool autoShutdownRestore;
-    bool autoSaveBypassCache;
+    virDomainDriverAutoShutdownConfig autoShutdown;

     char *lockManagerName;

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9b583ad7aa..4dbd5ec2fc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -964,15 +964,9 @@ static int
 qemuStateStop(void)
 {
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(qemu_driver);
-    virDomainDriverAutoShutdownConfig ascfg = {
-        .uri = cfg->uri,
-        .trySave = cfg->autoShutdownTrySave,
-        .tryShutdown = cfg->autoShutdownTryShutdown,
-        .poweroff = cfg->autoShutdownPoweroff,
-        .waitShutdownSecs = cfg->autoShutdownWait,
-        .saveBypassCache = cfg->autoSaveBypassCache,
-        .autoRestore = cfg->autoShutdownRestore,
-    };
+    virDomainDriverAutoShutdownConfig ascfg = cfg->autoShutdown;
+
+    ascfg.uri = cfg->uri;

     virDomainDriverAutoShutdown(&ascfg);

-- 
2.49.0

Reply via email to