From 15ddeae6cb405bad10bc62164b14117646e9127e Mon Sep 17 00:00:00 2001
From: Cole Robinson <crobinso@redhat.com>
Date: Mon, 17 Oct 2022 11:54:37 -0400
Subject: [PATCH] cli: support --boot loader.stateless=

Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 tests/data/cli/compare/virt-install-singleton-config-2.xml | 4 ++--
 tests/test_cli.py                                          | 2 +-
 virtinst/cli.py                                            | 1 +
 virtinst/domain/os.py                                      | 2 ++
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/data/cli/compare/virt-install-singleton-config-2.xml b/tests/data/cli/compare/virt-install-singleton-config-2.xml
index d567d188..27c69c11 100644
--- a/tests/data/cli/compare/virt-install-singleton-config-2.xml
+++ b/tests/data/cli/compare/virt-install-singleton-config-2.xml
@@ -11,7 +11,7 @@
   <vcpu cpuset="1,3-5">2</vcpu>
   <os>
     <type arch="x86_64" machine="q35">hvm</type>
-    <loader readonly="yes" secure="no" type="rom">/tmp/foo</loader>
+    <loader readonly="yes" secure="no" type="rom" stateless="yes">/tmp/foo</loader>
     <smbios mode="emulate"/>
     <boot dev="network"/>
     <boot dev="hd"/>
@@ -112,7 +112,7 @@
   <vcpu cpuset="1,3-5">2</vcpu>
   <os>
     <type arch="x86_64" machine="q35">hvm</type>
-    <loader readonly="yes" secure="no" type="rom">/tmp/foo</loader>
+    <loader readonly="yes" secure="no" type="rom" stateless="yes">/tmp/foo</loader>
     <boot dev="hd"/>
     <smbios mode="emulate"/>
   </os>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 9d4e5ae3..3d299c12 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -832,7 +832,7 @@ c.add_compare("--pxe "
 "--cpuset 1,3-5 "  # setting compat --cpuset when --vcpus is not present
 # --boot loader settings here, or they will conflict with firmware=efi
 # in other test cases
-"--boot loader_ro=yes,loader.type=rom,loader=/tmp/foo,loader_secure=no "
+"--boot loader_ro=yes,loader.type=rom,loader=/tmp/foo,loader_secure=no,loader.stateless=yes"
 
 # 'default' handling for solo devices
 """
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 5ac8266b..8dbffeb6 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2861,6 +2861,7 @@ class ParserBoot(VirtCLIParser):
         cls.add_arg("loader.readonly", "loader_ro", is_onoff=True)
         cls.add_arg("loader.type", "loader_type")
         cls.add_arg("loader.secure", "loader_secure", is_onoff=True)
+        cls.add_arg("loader.stateless", "loader_stateless", is_onoff=True)
 
         # Guest-Based bootloader options
         cls.add_arg("firmware", "firmware")
diff --git a/virtinst/domain/os.py b/virtinst/domain/os.py
index e2cea755..4310e623 100644
--- a/virtinst/domain/os.py
+++ b/virtinst/domain/os.py
@@ -86,6 +86,7 @@ class DomainOs(XMLBuilder):
     _XML_PROP_ORDER = [
             "firmware", "os_type", "arch", "machine", "firmware_features",
             "loader", "loader_ro", "loader_secure", "loader_type",
+            "loader_stateless",
             "nvram", "nvram_template",
             "init", "initargs", "initenvs", "initdir", "inituser", "initgroup",
             "kernel", "initrd", "kernel_args", "dtb", "acpi_tb", "acpi_tb_type",
@@ -100,6 +101,7 @@ class DomainOs(XMLBuilder):
     loader_ro = XMLProperty("./loader/@readonly", is_yesno=True)
     loader_type = XMLProperty("./loader/@type")
     loader_secure = XMLProperty("./loader/@secure", is_yesno=True)
+    loader_stateless = XMLProperty("./loader/@stateless", is_yesno=True)
 
     # BIOS bootloader options
     def _get_bootorder(self):
-- 
2.37.2.windows.2

