virt-manager/virtman-reset-image-filename-based-on-format.patch
Charles Arnold 4e26d07e08 - bsc#938942 - Can't create a vmguest with raw format image with
virt-manager at first installation (option disable) 
  virtman-reset-image-filename-based-on-format.patch

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=243
2015-07-29 15:03:15 +00:00

70 lines
2.8 KiB
Diff

Reference: bsc#938942
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.
Index: virt-manager-1.2.1/virtManager/addstorage.py
===================================================================
--- virt-manager-1.2.1.orig/virtManager/addstorage.py
+++ virt-manager-1.2.1/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()
@@ -217,15 +218,16 @@ class vmmAddStorage(vmmGObjectUI):
def path_exists(p):
return os.path.exists(p) or p in collidelist
+ target, ignore, suffix = self._get_ideal_path_info(name, fmt)
if not pool:
# Use old generating method
- origf = os.path.join(default_dir, name + ".img")
+ origf = os.path.join(default_dir, name + suffix)
f = origf
n = 1
while path_exists(f) and n < 100:
f = os.path.join(default_dir, name +
- "-" + str(n) + ".img")
+ "-" + str(n) + suffix)
n += 1
if path_exists(f):
@@ -233,8 +235,6 @@ class vmmAddStorage(vmmGObjectUI):
path = f
else:
- target, ignore, suffix = self._get_ideal_path_info(name)
-
# Sanitize collidelist to work with the collision checker
newcollidelist = []
for c in collidelist:
@@ -310,7 +310,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()