diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-12-30 12:45:41 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-12-30 12:45:41 +0000 |
commit | 718547c77b448b2fa3962c514dcc2295d4db1d18 (patch) | |
tree | e1b79583a6375512162f3053a7fec2d738a173e6 | |
parent | b2da4fcd17fe747ae2ba9002eea83c37c4e72dba (diff) | |
download | xen-718547c77b448b2fa3962c514dcc2295d4db1d18.tar.gz xen-718547c77b448b2fa3962c514dcc2295d4db1d18.tar.bz2 xen-718547c77b448b2fa3962c514dcc2295d4db1d18.zip |
libxl: add a get_shutdown_reason
Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
-rw-r--r-- | tools/libxl/libxl_dom.c | 15 | ||||
-rw-r--r-- | tools/libxl/libxl_internal.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index e876970413..ae93bd11ea 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -42,6 +42,21 @@ int is_hvm(struct libxl_ctx *ctx, uint32_t domid) return !!(info.flags & XEN_DOMINF_hvm_guest); } +int get_shutdown_reason(struct libxl_ctx *ctx, uint32_t domid) +{ + xc_domaininfo_t info; + int ret; + + ret = xc_domain_getinfolist(ctx->xch, domid, 1, &info); + if (ret != 1) + return -1; + if (info.domain != domid) + return -1; + if (!(info.flags & XEN_DOMINF_shutdown)) + return -1; + return dominfo_get_shutdown_reason(&info); +} + int build_pre(struct libxl_ctx *ctx, uint32_t domid, libxl_domain_build_info *info, libxl_domain_build_state *state) { diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 3519eacefd..294d7a7cfc 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -124,6 +124,9 @@ char **libxl_xs_directory(struct libxl_ctx *ctx, xs_transaction_t t, char *path, /* from xl_dom */ int is_hvm(struct libxl_ctx *ctx, uint32_t domid); +int get_shutdown_reason(struct libxl_ctx *ctx, uint32_t domid); +#define dominfo_get_shutdown_reason(info) (((info)->flags >> XEN_DOMINF_shutdownshift) & XEN_DOMINF_shutdownmask) + int build_pre(struct libxl_ctx *ctx, uint32_t domid, libxl_domain_build_info *info, libxl_domain_build_state *state); int build_post(struct libxl_ctx *ctx, uint32_t domid, |