File 040-virtinst-add-pstore-backend-support.patch of Package virt-manager

Subject: virtinst: add --pstore backend=acpi-erst,path=XX,size=YY support
From: Lin Ma lma@suse.de Tue Feb 11 10:54:53 2025 +0800
Date: Mon Mar 3 12:01:09 2025 -0500:
Git: b5f6569bc0e24a4557ac43f7b9a7eeae0399c337

Libvirt since v10.6.0 introduces pstore pci device for storing oops/panic
logs in nvram storage.

Let's add it into virt-install, It has 3 suboptions:
* backend: The desired backend, by far only 'acpi-erst' is accepted.
* path:    Represents a path in the host that backs the pstore device in
           the guest. It is optional, If not specified the libvirt will
           auto generates one.
* size:    Configures the size of the persistent storage available to the
           guest. It is mandatory, unit is kilobytes.

Eg:
virt-install --pstore backend=acpi-erst,path=/tmp/guest_acpi_esrt,size=8

Signed-off-by: Lin Ma <lma@suse.de>

--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -826,6 +826,16 @@ def add_device_options(devg, sound_back_
     devg.add_argument("--iommu", action="append",
                     help=_("Configure an IOMMU device. Ex:\n"
                            "--iommu model=intel,driver.aw_bits=48"))
+    ParserPstore.register()
+    devg.add_argument(
+        "--pstore",
+        action="append",
+        help=_(
+            "Configure a nvram storage device.\n"
+            "It's for guest kernel to record oops/panic logs. Ex:\n"
+            "--pstore backend=acpi-erst,size=8"
+        ),
+    )
 
 
 def add_guest_xml_options(geng):
@@ -4859,6 +4869,19 @@ class ParserAudio(VirtCLIParser):
         cls.add_arg("id", "id")
 
 
+class ParserPstore(VirtCLIParser):
+    cli_arg_name = "pstore"
+    guest_propname = "devices.pstore"
+
+    @classmethod
+    def _virtcli_class_init(cls):
+        VirtCLIParser._virtcli_class_init_common(cls)
+
+        cls.add_arg("backend", "backend")
+        cls.add_arg("path", "path")
+        cls.add_arg("size", "size")
+
+
 #####################
 # --hostdev parsing #
 #####################
--- a/virtinst/devices/__init__.py
+++ b/virtinst/devices/__init__.py
@@ -27,6 +27,7 @@ from .tpm import DeviceTpm
 from .video import DeviceVideo
 from .vsock import DeviceVsock
 from .watchdog import DeviceWatchdog
+from .pstore import DevicePstore
 
 
 __all__ = [l for l in locals() if l.startswith("Device")]
--- a/virtinst/devices/meson.build
+++ b/virtinst/devices/meson.build
@@ -23,6 +23,7 @@ virtinst_devices_sources = files(
   'video.py',
   'vsock.py',
   'watchdog.py',
+  'pstore.py',
 )
 
 install_data(
--- /dev/null
+++ b/virtinst/devices/pstore.py
@@ -0,0 +1,13 @@
+# This work is licensed under the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+from .device import Device
+from ..xmlbuilder import XMLProperty
+
+
+class DevicePstore(Device):
+    XML_NAME = "pstore"
+
+    backend = XMLProperty("./@backend")
+    path = XMLProperty("./path")
+    size = XMLProperty("./size", is_int=True)
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -27,7 +27,7 @@ class _DomainDevices(XMLBuilder):
             'smartcard', 'serial', 'parallel', 'console', 'channel',
             'input', 'tpm', 'graphics', 'sound', 'audio', 'video', 'hostdev',
             'redirdev', 'watchdog', 'memballoon', 'rng', 'panic',
-            'shmem', 'memory', 'vsock', 'iommu']
+            'shmem', 'memory', 'vsock', 'iommu', 'pstore']
 
 
     disk = XMLChildProperty(DeviceDisk)
@@ -55,6 +55,7 @@ class _DomainDevices(XMLBuilder):
     memory = XMLChildProperty(DeviceMemory)
     vsock = XMLChildProperty(DeviceVsock)
     iommu = XMLChildProperty(DeviceIommu)
+    pstore = XMLChildProperty(DevicePstore)
 
     def get_all(self):
         retlist = []
openSUSE Build Service is sponsored by