From patchwork Mon Oct 9 15:57:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9993781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93B0460216 for ; Mon, 9 Oct 2017 15:59:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86219285E8 for ; Mon, 9 Oct 2017 15:59:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AC202879A; Mon, 9 Oct 2017 15:59:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1FA09285E8 for ; Mon, 9 Oct 2017 15:59:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1aR9-0003YQ-Mv; Mon, 09 Oct 2017 15:57:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1aR8-0003Xy-2F for xen-devel@lists.xensource.com; Mon, 09 Oct 2017 15:57:46 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 03/2E-02225-97C9BD95; Mon, 09 Oct 2017 15:57:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsXitHRDpG7FnNu RBk9+G1jcm/Ke3YHRY3vfLvYAxijWzLyk/IoE1ox97w8zFTwQr9jz7AJ7A+MqkS5GTg4JAX+J e0cXMEHYHhLXz54As9kEdCWatvxlA7FFBJQljjd9Ye1i5OJgFjjHKNE6ZQMzSEJYIEBi/7LHL F2MHBwsAioSMx74gYR5gebsuv4RaqacxPnjP8HKOQU8JRbMWAIWFwKqOdtxixGkVUhATWLu+n iIVkGJkzOfsIDYzAISEgdfvGCGGGMp8W39U+YJjPyzkJTNQlK2gJFpFaNGcWpRWWqRrpGpXlJ RZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGYKjVMzAw7mBsPeF3iFGSg0lJlHfejNuR QnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4y2YD5QSLUtNTK9Iyc4BBD5OW4OBREuFNBEnzFhck5 hZnpkOkTjHqcnTcvPuHSYglLz8vVUqc99QsoCIBkKKM0jy4EbAIvMQoKyXMy8jAwCDEU5BalJ tZgir/ilGcg1FJmDcdZBVPZl4J3KZXQEcwAR3BWHwD5IiSRISUVAMj34JrzB6XVu7f+HiGA+t y/a2JAbYZHJt8zzz+m9wcoO2ycOPF7QtUa+/PjfvXofB6p9yde1XOWSetzXmWH7G9t1X+jKfC yvrNE1LT5+3iS5PQnvjqwbOAv8pTHtTO4wswXfzq8as3j/d6O+ezxitcFAlq/L1KX23PrYSX5 fUe3QH/W1Z7fp89UYmlOCPRUIu5qDgRALPJAFC7AgAA X-Env-Sender: prvs=4484f2008=Ian.Jackson@citrix.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1507564658!108752994!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43551 invoked from network); 9 Oct 2017 15:57:44 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 9 Oct 2017 15:57:44 -0000 X-IronPort-AV: E=Sophos;i="5.42,500,1500940800"; d="scan'208";a="443012882" X-CrossPremisesHeadersFilteredBySendConnector: FTLPEX02AMS01.citrite.net From: Ian Jackson To: Date: Mon, 9 Oct 2017 16:57:05 +0100 Message-ID: <1507564648-7580-4-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1507564648-7580-1-git-send-email-ian.jackson@eu.citrix.com> References: <1507564648-7580-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: FTLPEX02AMS01.citrite.net Cc: Ross Lagerwall , Stefano Stabellini , Wei Liu , Ian Jackson Subject: [Xen-devel] [PATCH 03/26] tools: libxendevicemodel: Provide xendevicemodel_shutdown X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ian Jackson Acked-by: Wei Liu --- v2: Bump library minor version, as this is a new function --- tools/libs/devicemodel/Makefile | 2 +- tools/libs/devicemodel/core.c | 16 ++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 9 +++++++++ tools/libs/devicemodel/libxendevicemodel.map | 3 ++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile index f0e1e6c..1d4e584 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 0f2c1a7..0094e93 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 13216db..dda0bc7 100644 --- a/tools/libs/devicemodel/include/xendevicemodel.h +++ b/tools/libs/devicemodel/include/xendevicemodel.h @@ -317,6 +317,15 @@ int xendevicemodel_inject_event( 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 130222c..b0765fa 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 */