From: Ian Jackson Date: Fri, 15 Sep 2017 16:21:14 +0000 (+0100) Subject: tools: libxendevicemodel: Provide xendevicemodel_shutdown X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~1160 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1462f9ea8f4219d520a530787b80c986e050aa98;p=xen.git tools: libxendevicemodel: Provide xendevicemodel_shutdown Signed-off-by: Ian Jackson Acked-by: Wei Liu --- diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile index f0e1e6cb48..1d4e584927 100644 --- a/tools/libs/devicemodel/Makefile +++ b/tools/libs/devicemodel/Makefile @@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../.. include $(XEN_ROOT)/tools/Rules.mk MAJOR = 1 -MINOR = 0 +MINOR = 1 SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map CFLAGS += -Werror -Wmissing-prototypes diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c index 0f2c1a791f..0094e93e96 100644 --- a/tools/libs/devicemodel/core.c +++ b/tools/libs/devicemodel/core.c @@ -532,6 +532,22 @@ int xendevicemodel_inject_event( return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op)); } +int xendevicemodel_shutdown( + xendevicemodel_handle *dmod, domid_t domid, unsigned int reason) +{ + struct xen_dm_op op; + struct xen_dm_op_remote_shutdown *data; + + memset(&op, 0, sizeof(op)); + + op.op = XEN_DMOP_remote_shutdown; + data = &op.u.remote_shutdown; + + data->reason = reason; + + return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op)); +} + int xendevicemodel_restrict(xendevicemodel_handle *dmod, domid_t domid) { return osdep_xendevicemodel_restrict(dmod, domid); diff --git a/tools/libs/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h index 13216db04a..dda0bc7695 100644 --- a/tools/libs/devicemodel/include/xendevicemodel.h +++ b/tools/libs/devicemodel/include/xendevicemodel.h @@ -316,6 +316,15 @@ int xendevicemodel_inject_event( xendevicemodel_handle *dmod, domid_t domid, int vcpu, uint8_t vector, uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2); +/** + * Shuts the domain down. + * + * @parm reason usually enum sched_shutdown_reason, see xen/sched.h + * @return 0 on success, -1 on failure. + */ +int xendevicemodel_shutdown( + xendevicemodel_handle *dmod, domid_t domid, unsigned int reason); + /** * This function restricts the use of this handle to the specified * domain. diff --git a/tools/libs/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map index 130222c3e4..b0765fa334 100644 --- a/tools/libs/devicemodel/libxendevicemodel.map +++ b/tools/libs/devicemodel/libxendevicemodel.map @@ -1,4 +1,4 @@ -VERS_1.0 { +VERS_1.1 { global: xendevicemodel_open; xendevicemodel_create_ioreq_server; @@ -18,6 +18,7 @@ VERS_1.0 { xendevicemodel_modified_memory; xendevicemodel_set_mem_type; xendevicemodel_inject_event; + xendevicemodel_shutdown; xendevicemodel_restrict; xendevicemodel_close; local: *; /* Do not expose anything by default */