From patchwork Fri Oct 6 18:27:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9990223 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 BEE0760247 for ; Fri, 6 Oct 2017 18:30:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5BAF28A3A for ; Fri, 6 Oct 2017 18:30:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA9F828DAC; Fri, 6 Oct 2017 18:30:02 +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 58BF428A3A for ; Fri, 6 Oct 2017 18:30:02 +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 1e0XLk-0000xd-IO; Fri, 06 Oct 2017 18:27:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0XLi-0000vU-Qp for xen-devel@lists.xenproject.org; Fri, 06 Oct 2017 18:27:50 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 67/05-02047-62BC7D95; Fri, 06 Oct 2017 18:27:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsXitHSDva7q6eu RBnuPiVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnHWo4zFazgq7j5roOtgXENdxcjJ4eEgL/E i0fb2EFsNgFdiaYtf9lAbBEBaYn+Oe1AcS4OZoH5TBKH5y1mBUkIC3hKHJt4lhHEZhFQkbh+Y C8LiM0LFP/+6xYzxFA5ifPHf4LZnAJeEl/urwVbIARUs2PtWaA4B5CtJjF3fTxEq6DEyZlPwM YwC0hIHHzxgnkCI+8sJKlZSFILGJlWMaoXpxaVpRbpWuolFWWmZ5TkJmbm6BoaGOvlphYXJ6a n5iQmFesl5+duYgSGTj0DA+MOxtc/nQ4xSnIwKYnyMpy4HinEl5SfUpmRWJwRX1Sak1p8iFGG g0NJgrflJFBOsCg1PbUiLTMHGMQwaQkOHiUR3hqQNG9xQWJucWY6ROoUoy5Hx827f5iEWPLy8 1KlxHmdQYoEQIoySvPgRsAi6hKjrJQwLyMDA4MQT0FqUW5mCar8K0ZxDkYlYd5ukCk8mXklcJ teAR3BBHTEnKYrIEeUJCKkpBoYPUsXLlG76Ba/oW8Py0oWDuWNonvX8zUuUZY89HKO5gvLJ1t yi7paWL1n3t526ElD9ZylV1cvXP90Wdf9S9M57oanvaiu03pwqUH9pfnuLz/35s5mrDL+Ju5s Zf6tzrR+pZiWc9/K+xtycuUrk25GpGoentfy90af78vp3nqzKrNbd5aWajadV2Ipzkg01GIuK k4EAKg7JLyjAgAA X-Env-Sender: prvs=44560dde8=Ian.Jackson@citrix.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1507314461!109131161!4 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19536 invoked from network); 6 Oct 2017 18:27:48 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 6 Oct 2017 18:27:48 -0000 X-IronPort-AV: E=Sophos;i="5.42,484,1500940800"; d="scan'208";a="450777170" From: Ian Jackson To: Date: Fri, 6 Oct 2017 19:27:22 +0100 Message-ID: <1507314444-30835-7-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1507314444-30835-1-git-send-email-ian.jackson@eu.citrix.com> References: <1507314444-30835-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Cc: Juergen Gross , Stefano Stabellini , Ian Jackson , Ross Lagerwall , Anthony PERARD , xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 6/8] xen: destroy_hvm_domain: Try 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 xc_interface_open etc. is not going to work if we have dropped privilege, but xendevicemodel_shutdown will if everything is new enough. xendevicemodel_shutdown is only availabe in Xen 4.10 and later, so provide a stub for earlier versions. Signed-off-by: Ian Jackson --- v2: Add compatibility stub for Xen < 4.10. Fix coding style. Signed-off-by: Ian Jackson --- hw/i386/xen/xen-hvm.c | 10 ++++++++++ include/hw/xen/xen_common.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 83420cd..25b8b14 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -1386,9 +1386,19 @@ void destroy_hvm_domain(bool reboot) { xc_interface *xc_handle; int sts; + int rc; unsigned int reason = reboot ? SHUTDOWN_reboot : SHUTDOWN_poweroff; + if (xen_dmod) { + rc = xendevicemodel_shutdown(xen_dmod, xen_domid, reason); + if (!rc) { + return; + } + perror("xendevicemodel_shutdown failed"); + /* well, try the old thing then */ + } + xc_handle = xc_interface_open(0, 0, 0); if (xc_handle == NULL) { fprintf(stderr, "Cannot acquire xenctrl handle\n"); diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 8efdb8a..1d6fb57 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -108,6 +108,13 @@ static inline int xentoolcore_restrict_all(domid_t domid) return -1; } +static inline int xendevicemodel_shutdown(xendevicemodel_handle *dmod, + domid_t domid, unsigned int reason) +{ + errno = ENOTTY; + return -1; +} + #else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 41000 */ #include