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] new commands "xl reboot" & "xl shutdown"

To: Gihan Munasinghe <GMunasinghe@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] new commands "xl reboot" & "xl shutdown"
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Mon, 10 May 2010 16:11:20 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 10 May 2010 08:19:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4BE4A40C.8050604@xxxxxxxxxxxx>
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: <4BE4A40C.8050604@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
On Sat, 8 May 2010, Gihan Munasinghe wrote:
> Guys
> 
> I patched xl to have "reboot" and "shutdown" commands.
> I tested this with hvm domains with and and without pv drivers seems to 
> work, of course the os level reboot and shutdown will only happen if 
> there are pv drivers with the dom U.
> 
> Also the libxl_domain_shutdown was not working for hvm guests without pv 
> drivers, I did a small patch to that as well. (same way xend shutdown 
> works used || instead of a && ). I would appreciate if someone can test 
> this more with hvm and pv domains.
> 
> Let me know what  you think
> 

Thanks for the patch!
It is mostly correct, however libxenlight changed quite a bit since xen
4.0 so could you please port your changes to xen-unstable?


> diff -Naur vanila/xen-4.0.0/tools/libxl/libxl.c 
> xen4patch/xen-4.0.0/tools/libxl/libxl.c
> --- vanila/xen-4.0.0/tools/libxl/libxl.c      2010-04-07 17:12:04.000000000 
> +0100
> +++ xen4patch/xen-4.0.0/tools/libxl/libxl.c   2010-05-07 23:14:26.000000000 
> +0100
> @@ -400,12 +400,12 @@
>      shutdown_path = libxl_sprintf(ctx, "%s/control/shutdown", dom_path);
>  
>      xs_write(ctx->xsh, XBT_NULL, shutdown_path, req_table[req], 
> strlen(req_table[req]));
> -    if (/* hvm */ 0) {
> +    if (/* hvm */ 1) {
>          unsigned long acpi_s_state = 0;
>          unsigned long pvdriver = 0;
>          xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_ACPI_S_STATE, 
> &acpi_s_state);
>          xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver);
> -        if (!pvdriver && acpi_s_state != 0)
> +        if (!pvdriver || acpi_s_state != 0)
>              xc_domain_shutdown(ctx->xch, domid, req);
>      }
>      return 0;

this should be correct

> diff -Naur vanila/xen-4.0.0/tools/libxl/xl.c 
> xen4patch/xen-4.0.0/tools/libxl/xl.c
> --- vanila/xen-4.0.0/tools/libxl/xl.c 2010-04-07 17:12:04.000000000 +0100
> +++ xen4patch/xen-4.0.0/tools/libxl/xl.c      2010-05-08 00:19:51.000000000 
> +0100
> @@ -702,9 +702,6 @@
>      if (debug)
>          printf_info(&info1, &info2, disks, num_disks, vifs, num_vifs, 
> pcidevs, num_pcidevs, vfbs, num_vfbs, vkbs, num_vkbs, &dm_info);
>  
> -start:
> -    domid = 0;
> -
>      if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
>          fprintf(stderr, "cannot init xl context\n");
>          return;
> @@ -712,6 +709,9 @@
>  
>      libxl_ctx_set_log(&ctx, log_callback, NULL);
>  
> +start:
> +    domid = 0;
> +
>      ret = libxl_domain_make(&ctx, &info1, &domid);
>      if (ret) {
>          fprintf(stderr, "cannot make domain: %d\n", ret);

this is probably not needed anymore

> @@ -830,8 +830,9 @@
>                              libxl_free_waiter(w2);
>                              free(w1);
>                              free(w2);
> -                            libxl_ctx_free(&ctx);
>                              LOG("Done. Rebooting now");
> +                            sleep(2);/*Fix Me: The sleep is put here to 
> slowdown the recreation of the domain 
> +                                       If this sleep it not there, 
> hvm_domain creation failes sometimes*/
>                              goto start;
>                          }
>                          LOG("Done. Exiting now");

since we don't free the ctx anymore here, it might be unnecessary.
The other changes look OK but we have a command table now, so they need
to be adapted.




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