[virt-tools-list] [virt-manager] [PATCH 2/5] create: Auto-generate fs path if not provided

Radostin Stoyanov rstoyanov1 at gmail.com
Mon Jul 24 08:26:45 UTC 2017


Use default place to store file systems of bootstraped containers.

If the current user has effective UID 0 use:
    /var/lib/libvirt/filesystems/<container-name>

otherwise use:
    ~/.local/share/libvirt/filesystems/<container-name>
---
 virtManager/create.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/virtManager/create.py b/virtManager/create.py
index b3f02b7..cec44a6 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -1653,6 +1653,17 @@ class vmmCreate(vmmGObjectUI):
         enable_src = self.widget("install-oscontainer-bootstrap").get_active()
         self.widget("install-oscontainer-source").set_sensitive(enable_src)
 
+        # Auto-generate a path if not specified
+        if enable_src and not self.widget("install-oscontainer-fs").get_text():
+            if os.geteuid() == 0:
+                fs_dir = ['/var/lib/libvirt/filesystems/']
+            else:
+                fs_dir = [os.environ['HOME'],
+                          '.local/share/libvirt/filesystems/']
+
+            fs = fs_dir + [self._generate_default_name(None, None)]
+            self.widget("install-oscontainer-fs").set_text(os.path.join(*fs))
+
 
     ########################
     # Misc helper routines #
-- 
2.9.4




More information about the virt-tools-list mailing list