]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: conf: Store 'autoShutdown' config in virDomainDriverAutoShutdownConfig
authorPeter Krempa <pkrempa@redhat.com>
Fri, 27 Jun 2025 13:13:35 +0000 (15:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 8 Jul 2025 12:51:44 +0000 (14:51 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_driver.c

index 9bf12fc17929b710c653237c58dceebdd357ee67..482e19b502001030cc4794eefa05d5fe60fef5d1 100644 (file)
@@ -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;
index 1ce9dbe4a81d9ffed4e27e200905329bcb0f69f7..ff376aed4d3f458a983aa279ec10e41a40657dd9 100644 (file)
@@ -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;
 
index 2c06e50454a53f59414fb9b861314124f5bcaf4f..6982a7a828b34519bbb5d2ae8e71ba58502e0a91 100644 (file)
@@ -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);