WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] libxl/xl: correctly report domain state

To: Ian Campbell <ian.campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] libxl/xl: correctly report domain state
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Fri, 23 Jul 2010 13:18:29 +0100
Cc: Ian, Campbell <Ian.Campbell@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 23 Jul 2010 05:19:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <006ec67363ab2651d712.1279881816@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <006ec67363ab2651d712.1279881816@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
On Fri, 23 Jul 2010, Ian Campbell wrote:
> # HG changeset patch
> # User Ian Campbell <ian.campbell@xxxxxxxxxx>
> # Date 1279881736 -3600
> # Node ID 006ec67363ab2651d712f9e3f0f48bf1d408396a
> # Parent  b880a9fc98d14aad8464fb1a5c690f6b4bc14e03
> libxl/xl: correctly report domain state.
> 
> In particular distinguish between domain shutdown and crash and the
> blocked and running states.
> 
> Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
> 
> diff -r b880a9fc98d1 -r 006ec67363ab tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c     Thu Jul 22 17:32:08 2010 +0100
> +++ b/tools/libxl/libxl.c     Fri Jul 23 11:42:16 2010 +0100
> @@ -403,17 +403,26 @@ int libxl_domain_resume(struct libxl_ctx
>  }
>  
>  static void xcinfo2xlinfo(const xc_domaininfo_t *xcinfo,
> -                          struct libxl_dominfo *xlinfo) {
> +                          struct libxl_dominfo *xlinfo)
> +{
> +    unsigned int shutdown_reason;
> +
>      memcpy(&(xlinfo->uuid), xcinfo->handle, sizeof(xen_domain_handle_t));
>      xlinfo->domid = xcinfo->domain;
>  
> -    if (xcinfo->flags & XEN_DOMINF_dying)
> -        xlinfo->dying = 1;
> -    else if (xcinfo->flags & XEN_DOMINF_paused)
> -        xlinfo->paused = 1;
> -    else if (xcinfo->flags & XEN_DOMINF_blocked ||
> -             xcinfo->flags & XEN_DOMINF_running)
> -        xlinfo->running = 1;
> +    xlinfo->dying    = !!(xcinfo->flags&XEN_DOMINF_dying);
> +    xlinfo->shutdown = !!(xcinfo->flags&XEN_DOMINF_shutdown);
> +    xlinfo->paused   = !!(xcinfo->flags&XEN_DOMINF_paused);
> +    xlinfo->blocked  = !!(xcinfo->flags&XEN_DOMINF_blocked);
> +    xlinfo->running  = !!(xcinfo->flags&XEN_DOMINF_running);
> +
> +    shutdown_reason = (xcinfo->flags>>XEN_DOMINF_shutdownshift) & 
> XEN_DOMINF_shutdownmask;
> +
> +    if ( xlinfo->shutdown && (shutdown_reason == SHUTDOWN_crash) ) {
> +        xlinfo->shutdown = 0;
> +        xlinfo->crashed  = 1;
> +    }
> +

xlinfo->crashed should be set to 0 in the other cases.

I also think that it might be worth having an enum in xlinfo to specify
the shutdown reason (that might be other than crash, for example
SHUTDOWN_suspend).
This way we would be able to use an xlinfo in
libxl_event_get_domain_death_info (see xl_cmdimpl.c:1346).


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel