[virt-tools-list] [PATCH virt-manager]: addhardware: reset disk image name extension to format selected

Cole Robinson crobinso at redhat.com
Mon Aug 10 18:50:25 UTC 2015


On 07/22/2015 03:54 PM, Charles Arnold wrote:
> 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.
> 

Thanks for the patch. Actually I think this is a side effect of a UI problem.
The 'storage format' field's primary purpose was to allow telling libvirt
'this existing disk image I'm selecting is format=foo', _not_ to allow
creating default storage with a different format, since the user can already
do that via the storage browser even though it's a bit more work.

So instead I'd suggest side stepping the problem by desensitizing the 'storage
format' field when 'default storage' is selected. It already seems to fill in
the default value of qcow2.

- Cole

> Signed-off-by: Charles Arnold <carnold at 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
> 




More information about the virt-tools-list mailing list