]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Autofill pstore path if missing
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 29 Jul 2024 07:43:35 +0000 (09:43 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 30 Jul 2024 15:22:00 +0000 (17:22 +0200)
Introduced only a couple of commits ago (in
v10.5.0-84-g90e50e67c6) the pstore device acts as a nonvolatile
storage, where guest kernel can store information about crashes.
This device, however, expects a file in the host from which the
crash data is read. So far, we expected users to provide a path,
but we can autogenerate one if missing. Just put it next to
per-domain's NVRAM stores.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
docs/formatdomain.rst
src/conf/schemas/domaincommon.rng
src/qemu/qemu_domain.c

index 860ef17d7b7d75ba91c0a97bd9bbfbf227c59847..c56b739b235f9bbe3c4533724fcb74709438d5b4 100644 (file)
@@ -8683,8 +8683,7 @@ desired backend (only ``acpi-erst`` is accepted for now). Then it has the
 following child elements:
 
 ``path``
-  Represents a path in the host that backs the pstore device in the guest. It
-  is mandatory.
+  Represents a path in the host that backs the pstore device in the guest.
 
 ``size``
   Configures the size of the persistent storage available to the guest. It is
index 6fcee2a70ce279cab9bb8eb33806e1460a349278..7d58dce46544f48d40c2508f7f0ec3837567bedc 100644 (file)
         <value>acpi-erst</value>
       </attribute>
       <interleave>
-        <element name="path">
-          <ref name="absFilePath"/>
-        </element>
+        <optional>
+          <element name="path">
+            <ref name="absFilePath"/>
+          </element>
+        </optional>
         <element name="size">
           <ref name="scaledInteger"/>
         </element>
index 298f4bfb9e6bfb791f2e22582ed248b85de14190..198ab99aefa75b758e6adc76fa5e96d13888fd33 100644 (file)
@@ -6289,6 +6289,28 @@ qemuDomainMemoryDefPostParse(virDomainMemoryDef *mem, virArch arch,
 }
 
 
+static int
+qemuDomainPstoreDefPostParse(virDomainPstoreDef *pstore,
+                             const virDomainDef *def,
+                             virQEMUDriver *driver)
+{
+    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
+
+    switch (pstore->backend) {
+    case VIR_DOMAIN_PSTORE_BACKEND_ACPI_ERST:
+        if (!pstore->path)
+            pstore->path = g_strdup_printf("%s/%s_PSTORE.raw",
+                                           cfg->nvramDir, def->name);
+        break;
+
+    case VIR_DOMAIN_PSTORE_BACKEND_LAST:
+        break;
+    }
+
+    return 0;
+}
+
+
 static int
 qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev,
                              const virDomainDef *def,
@@ -6350,6 +6372,10 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev,
                                            parseFlags);
         break;
 
+    case VIR_DOMAIN_DEVICE_PSTORE:
+        ret = qemuDomainPstoreDefPostParse(dev->data.pstore, def, driver);
+        break;
+
     case VIR_DOMAIN_DEVICE_LEASE:
     case VIR_DOMAIN_DEVICE_FS:
     case VIR_DOMAIN_DEVICE_INPUT:
@@ -6365,7 +6391,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev,
     case VIR_DOMAIN_DEVICE_IOMMU:
     case VIR_DOMAIN_DEVICE_AUDIO:
     case VIR_DOMAIN_DEVICE_CRYPTO:
-    case VIR_DOMAIN_DEVICE_PSTORE:
         ret = 0;
         break;