[virt-tools-list] [ [PATCH 2/3] details: Add disk pr.managed and pr.path options to support SCSI PR

2018-09-25 Thread Lin Ma
It's a common requirement for VMs to send SCSI PR commands in VM cluster
environment. This patch adds the configuration support in details page.

To make the usage simpler, the pr.type and pr.mode are invisible for user.
Currently, the pr.type and the pr.mode are hardcoded in case of user select
unmanaged PR, user only needs to provide the value of pr.path in this case.

Signed-off-by: Lin Ma 
---
 ui/details.ui  | 57 ++
 virtManager/addhardware.py |  7 +
 virtManager/details.py | 47 ++-
 virtManager/domain.py  | 15 +-
 virtinst/devices/disk.py   |  4 +++
 5 files changed, 128 insertions(+), 2 deletions(-)

diff --git a/ui/details.ui b/ui/details.ui
index 48464546..acc4b1c5 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -3676,6 +3676,63 @@
 2
   
 
+
+  
+True
+False
+end
+_Managed SCSI PR:
+True
+disk-pr-entry
+  
+  
+0
+4
+  
+
+
+  
+True
+False
+True
+
+  
+True
+
+  
+
+  
+  
+1
+4
+  
+
+
+  
+False
+False
+end
+PR source path:
+True
+disk-pr-path-entry
+  
+  
+0
+5
+  
+
+
+  
+False
+True
+False
+
+  
+
+  1
+  5
+
+
   
   
 False
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index cb45b194..e1fe699c 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -463,6 +463,13 @@ class vmmAddHardware(vmmGObjectUI):
 values.append([m, m])
 _build_combo(combo, values, sort=False)
 
+@staticmethod
+def build_disk_pr_managed_combo(_vm, combo):
+values = [[None, _("Hypervisor de

[virt-tools-list] [ [PATCH 3/3] addhardware: Add disk pr.managed and pr.path options to support SCSI PR

2018-09-25 Thread Lin Ma
Signed-off-by: Lin Ma 
---
 ui/addhardware.ui  | 56 ++
 virtManager/addhardware.py | 35 
 2 files changed, 91 insertions(+)

diff --git a/ui/addhardware.ui b/ui/addhardware.ui
index dffcf8c6..aa9e0339 100644
--- a/ui/addhardware.ui
+++ b/ui/addhardware.ui
@@ -328,6 +328,62 @@
 3
   
 
+
+  
+True
+False
+end
+_Managed SCSI PR:
+True
+disk-pr-entry
+  
+  
+0
+4
+  
+
+
+  
+True
+False
+True
+
+  
+True
+
+  
+
+  
+  
+1
+4
+  
+
+
+  
+False
+False
+end
+PR source path:
+True
+disk-pr-path-entry
+  
+  
+0
+5
+  
+
+
+  
+False
+True
+False
+  
+  
+1
+5
+  
+
   
 
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index e1fe699c..7d6ae47a 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -111,6 +111,8 @@ class vmmAddHardware(vmmGObjectUI):
 "on_usbredir_type_changed": self._change_usbredir_type,
 
 "on_controller_type_changed": self._change_controller_type,
+
+"on_disk_pr_combo_changed": self._change_disk_pr_combo,
 })
 self.bind_escape_key_close()
 
@@ -197,6 +199,7 @@ class vmmAddHardware(vmmGObjectUI):
 self.build_disk_discard_combo(self.vm, self.widget("storage-discard"))
 self.build_disk_detect_zeroes_combo(self.vm,
 self.widget("storage-detect-zeroes"))
+self.build_disk_pr_managed_combo(self.vm, self.widget("disk-pr"))
 self.build_network_model_combo(self.vm, self.widget("net-model"))
 self._build_input_combo()
 self.build_sound_combo(self.vm, self.widget("sound-model"))
@@ -856,6 +859,15 @@ class vmmAddHardware(vmmGObjectUI):
 self.widget("storage-devtype"))
 self._refresh_disk_bus(devtype)
 
+disk_pr = self.widget("disk-pr")
+uiutil.set_grid_row_visible(disk_pr, False)
+disk_pr_path_entry = self.widget("disk-pr-path-entry")
+uiutil.set_grid_row_visible(disk_pr_path_entry, False)
+is_lun = devtype == "lun"
+uiutil.set_grid_row_visible(disk_pr, is_lun)
+not_managed = (uiutil.get_list_selection(disk_pr) == "no")
+uiutil.set_grid_row_visible(disk_pr_path_entry, is_lun and not_managed)
+
 allow_create = devtype not in ["cdrom", "floppy"]
 self.addstorage.widget("storage-create-box").set_sensitive(
 allow_create)
@@ -978,6 +990,15 @@ class vmmAddHardware(vmmGObjectUI):
 self.populate_controller_model_combo(combo, controller_type)
 uiutil.set_grid_row_visible(combo, len(combo.get_model()) > 1)
 
+def _change_disk_pr_combo(self, src):
+ 

[virt-tools-list] [ [PATCH 1/3] cli: disk: add pr.managed=, pr.type=, pr.path= and pr.mode= support

2018-09-25 Thread Lin Ma
Enable the managed or unmanaged PR configuration to enable SCSI persistent
reservation for LUN Passthrough.

Signed-off-by: Lin Ma 
---
 man/virt-install.pod| 13 +
 .../compare/virt-install-many-devices.xml   |  9 +
 tests/clitest.py|  1 +
 virtinst/cli.py |  5 +
 virtinst/devices/disk.py|  5 +
 5 files changed, 33 insertions(+)

diff --git a/man/virt-install.pod b/man/virt-install.pod
index 657ef8cb..abb9d40d 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -739,6 +739,19 @@ Defines default behavior of the disk during disk 
snapshots.  See possible
 values in L,
 "snapshot" attribute of the  element.
 
+=item B
+
+It enables SCSI persistent reservations for LUN passthrough disks.
+For possible values, Please refer toPlease refer
+L,
+"reservations" attribute of the  element.
+
+e.g.
+
+--disk /dev/sdb,device=lun,bus=scsi,pr.managed=yes
+
+--disk 
/dev/sdc,device=lun,bus=scsi,pr.managed=no,pr.type=unix,pr.path=/tmp/pr-helper0.sock,pr.mode=client
+
 =back
 
 See the examples section for some uses. This option deprecates -f/--file,
diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml 
b/tests/cli-test-xml/compare/virt-install-many-devices.xml
index 25070b1b..20071439 100644
--- a/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -160,6 +160,15 @@
   
   
 
+
+  
+  
+
+  
+
+  
+  
+
 
   
 
diff --git a/tests/clitest.py b/tests/clitest.py
index 04795e05..47e2b6dc 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -438,6 +438,7 @@ c.add_compare(""" \
 --disk 
/var,device=floppy,address.type=ccw,address.cssid=0xfe,address.ssid=0,address.devno=01
 \
 --disk %(NEWIMG2)s,size=1,backing_store=/tmp/foo.img,backing_format=vmdk \
 --disk /tmp/brand-new.img,size=1,backing_store=/dev/default-pool/iso-vol \
+--disk 
path=/dev/sda,device=lun,bus=scsi,pr.managed=no,pr.type=unix,pr.path=/var/run/test/pr-helper0.sock,pr.mode=client
 \
 \
 --network 
user,mac=12:34:56:78:11:22,portgroup=foo,link_state=down,rom_bar=on,rom_file=/tmp/foo
 \
 --network bridge=foobar,model=virtio,driver_name=qemu,driver_queues=3 \
diff --git a/virtinst/cli.py b/virtinst/cli.py
index d7cb3ac3..b2adbcd2 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2130,6 +2130,11 @@ ParserDisk.add_arg("geometry_heads", "geometry.heads")
 ParserDisk.add_arg("geometry_secs", "geometry.secs")
 ParserDisk.add_arg("geometry_trans", "geometry.trans")
 
+ParserDisk.add_arg("pr_managed", "pr.managed")
+ParserDisk.add_arg("pr_type", "pr.type")
+ParserDisk.add_arg("pr_path", "pr.path")
+ParserDisk.add_arg("pr_mode", "pr.mode")
+
 
 #
 # --network parsing #
diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py
index d3ec27f9..8b125e16 100644
--- a/virtinst/devices/disk.py
+++ b/virtinst/devices/disk.py
@@ -836,6 +836,11 @@ class DeviceDisk(Device):
 geometry_secs = XMLProperty("./geometry/@secs", is_int=True)
 geometry_trans = XMLProperty("./geometry/@trans")
 
+pr_managed = XMLProperty("./source/reservations/@managed")
+pr_type = XMLProperty("./source/reservations/source/@type")
+pr_path = XMLProperty("./source/reservations/source/@path")
+pr_mode = XMLProperty("./source/reservations/source/@mode")
+
 
 #
 # Validation assistance methods #
-- 
2.19.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [ [PATCH 0/3] Add SCSI persistent reservation support for LUN Passthrough

2018-09-25 Thread Lin Ma
Lin Ma (3):
  cli: disk: add pr.managed=, pr.type=, pr.path= and pr.mode= support
  details: Add disk pr.managed and pr.path options to support SCSI PR
  addhardware: Add disk pr.managed and pr.path options to support SCSI
PR

 man/virt-install.pod  | 13 +
 .../compare/virt-install-many-devices.xml |  9 +++
 tests/clitest.py  |  1 +
 ui/addhardware.ui | 56 ++
 ui/details.ui | 57 +++
 virtManager/addhardware.py| 42 ++
 virtManager/details.py| 47 ++-
 virtManager/domain.py | 15 -
 virtinst/cli.py   |  5 ++
 virtinst/devices/disk.py  |  9 +++
 10 files changed, 252 insertions(+), 2 deletions(-)

-- 
2.19.0

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list