[virt-tools-list] [virt-manager PATCH] virtManager: disable 'Clone' in VMActionMenu if VM can't be cloned

Cole Robinson crobinso at redhat.com
Fri Sep 30 14:03:49 UTC 2016


On 09/20/2016 11:59 PM, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao at gmail.com>
> 
> We can't clone a VM in some scenarios,
> such as a VM is active.
> 
> This patch will disable 'Clone' label in VMActionMenu
> if we can't clone a VM,
> as same as we did for 'Clone' button in clone ui page.
> 
> Signed-off-by: Chen Hanxiao <chenhanxiao at gmail.com>
> ---
>  virtManager/domain.py | 4 ++++
>  virtManager/vmmenu.py | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/virtManager/domain.py b/virtManager/domain.py
> index a707f25..582de64 100644
> --- a/virtManager/domain.py
> +++ b/virtManager/domain.py
> @@ -1655,6 +1655,10 @@ class vmmDomain(vmmLibvirtObject):
>          return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
>      def is_paused(self):
>          return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
> +    def is_clonable(self):
> +        return self.status() in [libvirt.VIR_DOMAIN_SHUTOFF,
> +                                 libvirt.VIR_DOMAIN_PAUSED,
> +                                 libvirt.VIR_DOMAIN_PMSUSPENDED]
>  
>      def run_status(self):
>          return self.pretty_run_status(self.status(), self.has_managed_save())
> diff --git a/virtManager/vmmenu.py b/virtManager/vmmenu.py
> index a1ae375..bb23360 100644
> --- a/virtManager/vmmenu.py
> +++ b/virtManager/vmmenu.py
> @@ -128,7 +128,7 @@ class VMActionMenu(_VMMenu):
>              "suspend": bool(vm and vm.is_stoppable()),
>              "resume": bool(vm and vm.is_paused()),
>              "migrate": bool(vm and vm.is_stoppable()),
> -            "clone": True,
> +            "clone": bool(vm and vm.is_clonable()),
>          }
>          vismap = {
>              "suspend": bool(vm and not vm.is_paused()),
> 

Technically we can clone an active VM, if it doesn't have any disks, but
that's sufficiently rare that I don't think it's worth supporting in the UI.
So ACK

- Cole




More information about the virt-tools-list mailing list