diff --git a/virtman-allow-other-disk-formats.patch b/virtman-allow-other-disk-formats.patch index a5495a3d..1ba1833f 100644 --- a/virtman-allow-other-disk-formats.patch +++ b/virtman-allow-other-disk-formats.patch @@ -2,6 +2,8 @@ Reference: bsc#938942 Allow something other than qcow2 to be selected as the initial boot disk from the 'Customize configuration before install' screen. This is valid only when the disk has not yet been created. +Changing the format requires changing the domain xml and the volume +xml and renaming the file with an appropriate extension. Index: virt-manager-1.2.1/virtManager/details.py =================================================================== @@ -22,7 +24,7 @@ Index: virt-manager-1.2.1/virtManager/details.py self.enable_apply(EDIT_DISK_FORMAT) # IO Tuning -@@ -2694,10 +2700,22 @@ class vmmDetails(vmmGObjectUI): +@@ -2694,7 +2700,7 @@ class vmmDetails(vmmGObjectUI): iotune_wbs = (disk.iotune_wbs or 0) / 1024 iotune_wis = (disk.iotune_wis or 0) @@ -31,18 +33,61 @@ Index: virt-manager-1.2.1/virtManager/details.py virtinst.VirtualDisk.path_definitely_exists( disk.conn, disk.path)) -+ # If customizing and disk doesn't exist, allow format type to change -+ if show_format and self.is_customize_dialog: -+ fmt = uiutil.get_list_selection(self.widget("disk-format")) -+ guest = self.vm.get_backend() -+ if guest and fmt: -+ for d in guest.get_devices("disk"): -+ if d.path == disk.path: -+ dvol = d.get_vol_install() -+ if fmt in dvol.list_formats(): -+ dvol.format = fmt -+ break +Index: virt-manager-1.2.1/virtManager/domain.py +=================================================================== +--- virt-manager-1.2.1.orig/virtManager/domain.py ++++ virt-manager-1.2.1/virtManager/domain.py +@@ -27,6 +27,7 @@ import threading + + import libvirt + ++import virtinst + from virtinst import DomainCapabilities + from virtinst import DomainSnapshot + from virtinst import Guest +@@ -721,6 +722,37 @@ class vmmDomain(vmmLibvirtObject): + # Device XML editing # + ###################### + ++ # Change the extension on the name. ++ def _reset_file_name_extension(self, guest, disk, fmt): ++ suffix = virtinst.StorageVolume.get_file_extension_for_format(fmt) or ".img" ++ dirpath = os.path.dirname(disk.path) ++ pool = self.conn.get_default_pool() ++ newcollidelist = [] ++ collidelist = [d.path for d in self.get_disk_devices()] ++ # Sanitize collidelist to work with the collision checker ++ for c in collidelist: ++ if c and os.path.dirname(c) == pool.get_target_path(): ++ newcollidelist.append(os.path.basename(c)) ++ newname = virtinst.StorageVolume.find_free_name( ++ pool.get_backend(), guest.name, ++ suffix=suffix, collidelist=newcollidelist) ++ disk.get_vol_install().name = newname ++ return dirpath + '/' + newname + - size = _("Unknown") - if not path: - size = "-" ++ # Change the format of the disk image ++ def _reset_storage_format(self, disk): ++ if disk.driver_type is None: ++ return ++ fmt = disk.driver_type ++ guest = self.get_backend() ++ if guest and fmt: ++ for d in guest.get_devices("disk"): ++ if d.path == disk.path: ++ dvol = d.get_vol_install() ++ if dvol.format != fmt and fmt in dvol.list_formats(): ++ dvol.format = fmt ++ disk._source_file = self._reset_file_name_extension(guest, d, fmt) ++ + def define_disk(self, devobj, do_hotplug, + path=_SENTINEL, readonly=_SENTINEL, serial=_SENTINEL, + shareable=_SENTINEL, removable=_SENTINEL, cache=_SENTINEL, +@@ -777,6 +809,7 @@ class vmmDomain(vmmLibvirtObject): + editdev.driver_io = io or None + if driver_type != _SENTINEL: + editdev.driver_type = driver_type or None ++ self._reset_storage_format(editdev) + if serial != _SENTINEL: + editdev.serial = serial or None +