From: Chen Hanxiao <[email protected]>

Currently we could config disk with readonly and
shareable at the same time, which is meaningless.
virsh had already discouraged users doing this.
This patch will disable users to config both
readonly and shareable at the same time by UI.

Signed-off-by: Chen Hanxiao <[email protected]>
---
 virtManager/details.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/virtManager/details.py b/virtManager/details.py
index f5aa099..39a016a 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -2033,10 +2033,22 @@ class vmmDetails(vmmGObjectUI):
 
         if self.edited(EDIT_DISK_RO):
             do_readonly = self.widget("disk-readonly").get_active()
+            state_readonly = self.widget("disk-readonly").get_state()
+            state_shareable = self.widget("disk-shareable").get_state()
+            if ((state_readonly == Gtk.StateType.ACTIVE) and
+                    (state_shareable == Gtk.StateType.ACTIVE)):
+                raise ValueError("Readonly and Shareable should not "
+                        "be selected at the same time")
             add_define(self.vm.define_disk_readonly, dev_id_info, do_readonly)
 
         if self.edited(EDIT_DISK_SHARE):
             do_shareable = self.widget("disk-shareable").get_active()
+            state_readonly = self.widget("disk-readonly").get_state()
+            state_shareable = self.widget("disk-shareable").get_state()
+            if ((state_readonly == Gtk.StateType.ACTIVE) and
+                    (state_shareable == Gtk.StateType.ACTIVE)):
+                raise ValueError("Readonly and Shareable should not "
+                        "be selected at the same time")
             add_define(self.vm.define_disk_shareable,
                        dev_id_info, do_shareable)
 
-- 
1.8.2.1

_______________________________________________
virt-tools-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-tools-list

Reply via email to