[PATCH 1/2] virtinst: Implement support for transient disks

Han Han hhan at redhat.com
Wed May 26 01:22:10 UTC 2021


Since libvirt v6.9, the element <transient/> is to configure a disk
which discards its changes while VM was active. Support this element
by cmdline option `--disk ...,transient=on`.

Signed-off-by: Han Han <hhan at redhat.com>
---
 tests/data/cli/compare/virt-install-many-devices.xml | 1 +
 tests/test_cli.py                                    | 2 +-
 virtinst/cli.py                                      | 1 +
 virtinst/devices/disk.py                             | 1 +
 4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml
index 01996d27..7c4b0d54 100644
--- a/tests/data/cli/compare/virt-install-many-devices.xml
+++ b/tests/data/cli/compare/virt-install-many-devices.xml
@@ -231,6 +231,7 @@
       <driver name="qemu" type="qcow2"/>
       <source file="/fooroot.img"/>
       <target dev="vds" bus="virtio"/>
+      <transient/>
     </disk>
     <disk type="dir" device="disk">
       <driver name="qemu"/>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index bf64fc21..0ab64182 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -611,7 +611,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser
 --disk size=.0001,format=raw
 --disk size=.0001,pool=disk-pool
 --disk path=%(EXISTIMG1)s,type=dir
---disk path=/fooroot.img,size=.0001
+--disk path=/fooroot.img,size=.0001,transient=on
 --disk source.dir=/
 --disk type=nvme,source.type=pci,source.managed=no,source.namespace=2,source.address.domain=0x0001,source.address.bus=0x02,source.address.slot=0x00,source.address.function=0x0
 
diff --git a/virtinst/cli.py b/virtinst/cli.py
index e4676bc9..fe08c433 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -3440,6 +3440,7 @@ class ParserDisk(VirtCLIParser):
         cls.add_arg("wwn", "wwn")
         cls.add_arg("readonly", "read_only", is_onoff=True)
         cls.add_arg("shareable", "shareable", is_onoff=True)
+        cls.add_arg("transient", "transient", is_onoff=True)
 
         cls.add_arg("target.bus", "bus")
         cls.add_arg("target.removable", "removable", is_onoff=True)
diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py
index 77f10340..0a0bb564 100644
--- a/virtinst/devices/disk.py
+++ b/virtinst/devices/disk.py
@@ -475,6 +475,7 @@ class DeviceDisk(Device):
 
     read_only = XMLProperty("./readonly", is_bool=True)
     shareable = XMLProperty("./shareable", is_bool=True)
+    transient = XMLProperty("./transient", is_bool=True)
     driver_cache = XMLProperty("./driver/@cache")
     driver_discard = XMLProperty("./driver/@discard")
     driver_detect_zeroes = XMLProperty("./driver/@detect_zeroes")
-- 
2.31.1




More information about the virt-tools-list mailing list