Re: [libvirt] [PATCH 3/3] lxc: Check domain is active/inactive as required by operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 03, 2010 at 02:20:28PM +0200, jdenemar@xxxxxxxxxx wrote:
> From: Jiri Denemark <jdenemar@xxxxxxxxxx>
> 
> Report VIR_ERR_OPERATION_INVALID when operation which requires running
> domain is called on inactive domain and vice versa.
> ---
>  src/lxc/lxc_driver.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 6884fea..fc0df37 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -1378,6 +1378,12 @@ static int lxcDomainStart(virDomainPtr dom)
>          goto cleanup;
>      }
>  
> +    if (virDomainObjIsActive(vm)) {
> +        lxcError(VIR_ERR_OPERATION_INVALID,
> +                 "%s", _("Domain is already running"));
> +        goto cleanup;
> +    }
> +
>      ret = lxcVmStart(dom->conn, driver, vm);
>  
>      if (ret == 0)
> @@ -1483,6 +1489,12 @@ static int lxcDomainShutdown(virDomainPtr dom)
>          goto cleanup;
>      }
>  
> +    if (!virDomainObjIsActive(vm)) {
> +        lxcError(VIR_ERR_OPERATION_INVALID,
> +                 "%s", _("Domain is not running"));
> +        goto cleanup;
> +    }
> +
>      ret = lxcVmTerminate(driver, vm, 0);
>      event = virDomainEventNewFromObj(vm,
>                                       VIR_DOMAIN_EVENT_STOPPED,
> @@ -1662,6 +1674,12 @@ static int lxcDomainDestroy(virDomainPtr dom)
>          goto cleanup;
>      }
>  
> +    if (!virDomainObjIsActive(vm)) {
> +        lxcError(VIR_ERR_OPERATION_INVALID,
> +                 "%s", _("Domain is not running"));
> +        goto cleanup;
> +    }
> +
>      ret = lxcVmTerminate(driver, vm, SIGKILL);
>      event = virDomainEventNewFromObj(vm,
>                                       VIR_DOMAIN_EVENT_STOPPED,

  Ah, sure :-)

ACK

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]