mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xl: adds shutdown and reboot commands
libxl : remote shutdown to work for pure hvm domains Signed-off-by: Gihan Munasinghe <GMunasinghe@flexiant.com>
This commit is contained in:
1 parent
9d1f137d16
commit
c1d7e20205
4 files changed
+86
-2
No files matched your search
+2
-2
@@ -550,12 +550,12 @@ int libxl_domain_shutdown(struct libxl_ctx *ctx, uint32_t domid, int req)
|
||||
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 (is_hvm(ctx,domid)) {
|
||||
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;
|
||||
|
||||
@@ -40,6 +40,8 @@ int main_migrate(int argc, char **argv);
|
||||
int main_pause(int argc, char **argv);
|
||||
int main_unpause(int argc, char **argv);
|
||||
int main_destroy(int argc, char **argv);
|
||||
int main_shutdown(int argc, char **argv);
|
||||
int main_reboot(int argc, char **argv);
|
||||
int main_list(int argc, char **argv);
|
||||
int main_list_vm(int argc, char **argv);
|
||||
int main_create(int argc, char **argv);
|
||||
|
||||
@@ -1160,6 +1160,11 @@ start:
|
||||
free(w1);
|
||||
free(w2);
|
||||
LOG("Done. Rebooting now");
|
||||
/*
|
||||
* XXX FIXME: If this sleep is not there then
|
||||
* domain re-creation fails sometimes.
|
||||
*/
|
||||
sleep(2);
|
||||
goto start;
|
||||
}
|
||||
LOG("Done. Exiting now");
|
||||
@@ -1623,6 +1628,22 @@ void destroy_domain(char *p)
|
||||
if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n.",rc); exit(-1); }
|
||||
}
|
||||
|
||||
void shutdown_domain(char *p)
|
||||
{
|
||||
int rc;
|
||||
find_domain(p);
|
||||
rc=libxl_domain_shutdown(&ctx, domid, 0);
|
||||
if (rc) { fprintf(stderr,"shutdown failed (rc=%d)\n.",rc);exit(-1); }
|
||||
}
|
||||
|
||||
void reboot_domain(char *p)
|
||||
{
|
||||
int rc;
|
||||
find_domain(p);
|
||||
rc=libxl_domain_shutdown(&ctx, domid, 1);
|
||||
if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n.",rc);exit(-1); }
|
||||
}
|
||||
|
||||
void list_domains(int verbose)
|
||||
{
|
||||
struct libxl_dominfo *info;
|
||||
@@ -2375,6 +2396,57 @@ int main_destroy(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main_shutdown(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
char *p;
|
||||
|
||||
while ((opt = getopt(argc, argv, "h")) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
help("shutdown");
|
||||
exit(0);
|
||||
default:
|
||||
fprintf(stderr, "option not supported\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (optind >= argc) {
|
||||
help("shutdown");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
p = argv[optind];
|
||||
|
||||
shutdown_domain(p);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main_reboot(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
char *p;
|
||||
|
||||
while ((opt = getopt(argc, argv, "h")) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
help("reboot");
|
||||
exit(0);
|
||||
default:
|
||||
fprintf(stderr, "option not supported\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (optind >= argc) {
|
||||
help("reboot");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
p = argv[optind];
|
||||
|
||||
reboot_domain(p);
|
||||
exit(0);
|
||||
}
|
||||
int main_list(int argc, char **argv)
|
||||
{
|
||||
int opt, verbose = 0;
|
||||
|
||||
@@ -35,6 +35,16 @@ struct cmd_spec cmd_table[] = {
|
||||
"Terminate a domain immediately",
|
||||
"<Domain>",
|
||||
},
|
||||
{ "shutdown",
|
||||
&main_shutdown,
|
||||
"Issue a shutdown signal to a domain",
|
||||
"<Domain>",
|
||||
},
|
||||
{ "reboot",
|
||||
&main_reboot,
|
||||
"Issue a reboot signal to a domain",
|
||||
"<Domain>",
|
||||
},
|
||||
{ "pci-attach",
|
||||
&main_pciattach,
|
||||
"Insert a new pass-through pci device",
|
||||
|
||||