[PATCH v2] virtinst: Support rotation_rate attrib in target

Han Han hhan at redhat.com
Thu May 20 06:48:27 UTC 2021


Support rotation_rate attrib which is introduced since libvirt v7.3.

Signed-off-by: Han Han <hhan at redhat.com>
---
Diff from v1: Add tests for the new options in virtinst
---
 tests/data/cli/compare/virt-install-many-devices.xml | 4 ++--
 tests/test_cli.py                                    | 4 ++--
 virtinst/cli.py                                      | 2 ++
 virtinst/devices/disk.py                             | 1 +
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml
index d270344d..b23d2796 100644
--- a/tests/data/cli/compare/virt-install-many-devices.xml
+++ b/tests/data/cli/compare/virt-install-many-devices.xml
@@ -148,7 +148,7 @@
       <source protocol="nbd">
         <host transport="unix" socket="/tmp/socket"/>
       </source>
-      <target dev="sdz" bus="scsi"/>
+      <target dev="sdz" bus="scsi" rotation_rate="5000"/>
       <blockio logical_block_size="512" physical_block_size="512"/>
     </disk>
     <disk type="network" device="disk">
@@ -203,7 +203,7 @@
           <source type="unix" path="/var/run/test/pr-helper0.sock" mode="client"/>
         </reservations>
       </source>
-      <target dev="sdae" bus="scsi"/>
+      <target dev="sdae" bus="scsi" rotation_rate="6000"/>
     </disk>
     <disk type="network" device="disk">
       <driver name="qemu"/>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 01d6e8bd..faf353e2 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -597,7 +597,7 @@ vcpus.vcpu1.id=2,vcpus.vcpu1.enabled=yes
 --disk source_protocol=http,source_host_name=example.com,source_host_port=8000,source_name=/path/to/my/file
 --disk source.protocol=http,source.host0.name=exampl2.com,source.host.port=8000,source.name=/path/to/my/file
 --disk source.protocol=nbd,source.host.transport=unix,source.host.socket=/tmp/socket
---disk source.protocol=nbd,source_host_transport=unix,source_host_socket=/tmp/socket,bus=scsi,logical_block_size=512,physical_block_size=512,blockio.logical_block_size=512,blockio.physical_block_size=512,target.dev=sdz
+--disk source.protocol=nbd,source_host_transport=unix,source_host_socket=/tmp/socket,bus=scsi,logical_block_size=512,physical_block_size=512,blockio.logical_block_size=512,blockio.physical_block_size=512,target.dev=sdz,rotation_rate=5000
 --disk gluster://192.168.1.100/test-volume/some/dir/test-gluster.qcow2
 --disk nbd+unix:///var/foo/bar/socket,bus=usb,removable=on,address.type=usb,address.bus=0,address.port=2
 --disk path=http://[1:2:3:4:1:2:3:4]:5522/my/path?query=foo
@@ -606,7 +606,7 @@ vcpus.vcpu1.id=2,vcpus.vcpu1.enabled=yes
 --disk %(NEWIMG2)s,size=1,backing_store=/tmp/foo.img,backing_format=vmdk,bus=usb,target.removable=yes
 --disk /tmp/brand-new.img,size=1,backing_store=/dev/default-pool/iso-vol,boot.order=10,boot.loadparm=5
 --disk path=/dev/disk-pool/diskvol7,device=lun,bus=scsi,reservations.managed=no,reservations.source.type=unix,reservations.source.path=/var/run/test/pr-helper0.sock,reservations.source.mode=client,\
-source.reservations.managed=no,source.reservations.source.type=unix,source.reservations.source.path=/var/run/test/pr-helper0.sock,source.reservations.source.mode=client
+source.reservations.managed=no,source.reservations.source.type=unix,source.reservations.source.path=/var/run/test/pr-helper0.sock,source.reservations.source.mode=client,target.rotation_rate=6000
 --disk vol=iscsi-direct/unit:0:0:1
 --disk size=.0001,format=raw
 --disk size=.0001,pool=disk-pool
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 4ce3abf9..e4676bc9 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -3252,6 +3252,7 @@ class ParserDisk(VirtCLIParser):
         "snapshot": "snapshot_policy",
         "target.dev": "target",
         "target.removable": "removable",
+        "target.rotation_rate": "rotation_rate",
 
         "driver.discard": "discard",
         "driver.detect_zeroes": "detect_zeroes",
@@ -3443,6 +3444,7 @@ class ParserDisk(VirtCLIParser):
         cls.add_arg("target.bus", "bus")
         cls.add_arg("target.removable", "removable", is_onoff=True)
         cls.add_arg("target.dev", "target")
+        cls.add_arg("target.rotation_rate", "rotation_rate")
 
         cls.add_arg("driver.cache", "driver_cache")
         cls.add_arg("driver.discard", "driver_discard")
diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py
index a8971581..77f10340 100644
--- a/virtinst/devices/disk.py
+++ b/virtinst/devices/disk.py
@@ -471,6 +471,7 @@ class DeviceDisk(Device):
     bus = XMLProperty("./target/@bus")
     target = XMLProperty("./target/@dev")
     removable = XMLProperty("./target/@removable", is_onoff=True)
+    rotation_rate = XMLProperty("./target/@rotation_rate", is_int=True)
 
     read_only = XMLProperty("./readonly", is_bool=True)
     shareable = XMLProperty("./shareable", is_bool=True)
-- 
2.31.1




More information about the virt-tools-list mailing list