When a disk is added to an existing virtual machine and the storage format for
that disk is selected to be something other than qcow2 reset the image name
extension from qcow2 to the format selected. This is for a new disk that needs
to be created.

Signed-off-by: Charles Arnold <carn...@suse.com>

diff --git a/virtManager/addstorage.py b/virtManager/addstorage.py
index a40ceed..41a9215 100644
--- a/virtManager/addstorage.py
+++ b/virtManager/addstorage.py
@@ -58,9 +58,10 @@ class vmmAddStorage(vmmGObjectUI):
     def _get_default_dir(self):
         return virtinst.StoragePool.get_default_dir(self.conn.get_backend())
 
-    def _get_ideal_path_info(self, name):
+    def _get_ideal_path_info(self, name, fmt=None):
         path = self._get_default_dir()
-        fmt = self.conn.get_default_storage_format()
+        if fmt is None:
+            fmt = self.conn.get_default_storage_format()
         suffix = virtinst.StorageVolume.get_file_extension_for_format(fmt)
         return (path, name, suffix or ".img")
 
@@ -208,7 +209,7 @@ class vmmAddStorage(vmmGObjectUI):
             use_storage.set_sensitive(True)
         storage_area.set_tooltip_text(storage_tooltip or "")
 
-    def get_default_path(self, name, collidelist=None):
+    def get_default_path(self, name, fmt=None, collidelist=None):
         collidelist = collidelist or []
         pool = self.conn.get_default_pool()
 
@@ -233,7 +234,7 @@ class vmmAddStorage(vmmGObjectUI):
 
             path = f
         else:
-            target, ignore, suffix = self._get_ideal_path_info(name)
+            target, ignore, suffix = self._get_ideal_path_info(name, fmt)
 
             # Sanitize collidelist to work with the collision checker
             newcollidelist = []
@@ -310,7 +311,7 @@ class vmmAddStorage(vmmGObjectUI):
                     not self.widget("config-storage-nosparse").get_active())
             if path is None:
                 if is_default:
-                    path = self.get_default_path(vmname, collidelist)
+                    path = self.get_default_path(vmname, fmt, collidelist)
                 else:
                     path = 
self.widget("config-storage-entry").get_text().strip()
 


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

Reply via email to