[virt-tools-list] [PATCH] virt-manager: Throw appropriate error when fs target string already exists.

Deepak C Shetty deepakcs at linux.vnet.ibm.com
Fri Dec 16 10:08:50 UTC 2011


In case of qemu for default fs type (mount) target is not
actually a directory, it is merely a arbitrary string tag
that is exported to the guest as a hint for where to mount.

This tag is unique and is exported as a virito-9p-pci
device and hence this patch adds check to ensure the target
string/tag is never entered duplicate by the user when
adding 2 or more filesystem devices.

Signed-off-by: Deepak C Shetty <deepakcs at linux.vnet.ibm.com>
---

 src/virtManager/addhardware.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/virtManager/addhardware.py b/src/virtManager/addhardware.py
index 1b0f004..27dfbef 100644
--- a/src/virtManager/addhardware.py
+++ b/src/virtManager/addhardware.py
@@ -1379,6 +1379,10 @@ class vmmAddHardware(vmmGObjectUI):
         if not target:
             return self.err.val_err(_("A filesystem target must be specified"))
 
+        if self.conn.is_qemu() and self.filesystem_target_present(target):
+            return self.err.val_err(_('Invalid target path. A filesystem with'
+                                       ' that target already exists'))
+
         try:
             self._dev = virtinst.VirtualFilesystem(conn=conn)
             self._dev.source = source
@@ -1390,6 +1394,15 @@ class vmmAddHardware(vmmGObjectUI):
         except Exception, e:
             return self.err.val_err(_("Filesystem parameter error"), e)
 
+    def filesystem_target_present(self, target):
+        fsdevs = self.vm.get_filesystem_devices()
+
+        for fs in fsdevs:
+            if (fs.target == target):
+                return True
+
+        return False
+
     def validate_page_smartcard(self):
         conn = self.conn.vmm
         mode = self.get_config_smartcard_mode()




More information about the virt-tools-list mailing list