diff --git a/virtManager/addstorage.py b/virtManager/addstorage.py index 1dfecc82..525dd74c 100644 --- a/virtManager/addstorage.py +++ b/virtManager/addstorage.py @@ -67,8 +67,9 @@ class vmmAddStorage(vmmGObjectUI): def _get_ideal_path_info(self, name): path = self._get_default_dir() - suffix = ".img" - return (path, name, suffix) + fmt = self.conn.get_default_storage_format() + suffix = virtinst.StorageVolume.get_file_extension_for_format(fmt) + return (path, name, suffix or ".img") def _get_ideal_path(self, name): target, name, suffix = self._get_ideal_path_info(name) diff --git a/virtManager/createvol.py b/virtManager/createvol.py index 97a11095..0677ca57 100644 --- a/virtManager/createvol.py +++ b/virtManager/createvol.py @@ -113,10 +113,10 @@ class vmmCreateVolume(vmmGObjectUI): return ret def default_suffix(self): - suffix = "" - if self.vol.file_type == self.vol.TYPE_FILE: - suffix = ".img" - return suffix + if self.vol.file_type != self.vol.TYPE_FILE: + return "" + return StorageVolume.get_file_extension_for_format( + self.get_config_format()) def _init_state(self): blue = Gdk.color_parse("#0072A8") @@ -255,6 +255,7 @@ class vmmCreateVolume(vmmGObjectUI): ignore = src self._show_alloc() self._show_backing() + self.widget("vol-name").emit("changed") def browse_backing(self, src): ignore = src diff --git a/virtinst/cli.py b/virtinst/cli.py index da13fde7..9c8c22c1 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -1453,8 +1453,9 @@ def _parse_disk_source(guest, path, pool, vol, size, fmt, sparse): disk.get_vol_install().pool.name() == poolobj.name()): collidelist.append(os.path.basename(disk.path)) + ext = virtinst.StorageVolume.get_file_extension_for_format(fmt) vname = virtinst.StorageVolume.find_free_name( - poolobj, guest.name, suffix=".img", collidelist=collidelist) + poolobj, guest.name, suffix=ext, collidelist=collidelist) volinst = virtinst.VirtualDisk.build_vol_install( guest.conn, vname, poolobj, size, sparse) diff --git a/virtinst/storage.py b/virtinst/storage.py index b98b9153..51485d20 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -463,6 +463,14 @@ class StorageVolume(_StorageObject): ALL_FORMATS = ["raw", "bochs", "cloop", "cow", "dmg", "iso", "qcow", "qcow2", "qed", "vmdk", "vpc", "fat", "vhd", "vdi"] + @staticmethod + def get_file_extension_for_format(fmt): + if not fmt: + return "" + if fmt == "raw": + return ".img" + return "." + fmt + @staticmethod def find_free_name(pool_object, basename, **kwargs): """