From patchwork Fri Aug 2 15:36:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11073825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C73617E0 for ; Fri, 2 Aug 2019 15:59:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CA4D28613 for ; Fri, 2 Aug 2019 15:59:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80CE128876; Fri, 2 Aug 2019 15:59:47 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B78228613 for ; Fri, 2 Aug 2019 15:59:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZwx-0006dV-T8; Fri, 02 Aug 2019 15:58:35 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1htZww-0006aH-1j for xen-devel@lists.xenproject.org; Fri, 02 Aug 2019 15:58:34 +0000 X-Inumbo-ID: 60d1086e-b53e-11e9-8f4b-ffbcaae814cf Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 60d1086e-b53e-11e9-8f4b-ffbcaae814cf; Fri, 02 Aug 2019 15:58:32 +0000 (UTC) Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: xzcBt1ITsz0PlRLz7RLYxHuXGRC7tFnIqz5VT++3xWRx/laF06sl4wlnkVR2a1L9wah8J8Zy3s XPEa8+UdRDBM9zjQkHLUnJcpzz0gOyxywm75YmjopgzCN3H8o8CbVraZc9rh5kJvYPOjtgIV4B j+BAJXxY88PQg16bKELSa3Um0MCyRzE12PXYlTX/UFwZUf0Xp/+Rft3vsg5Wp/rP++bd8hBb51 NIf+ohhMZUwzEqJUqHL6TfNPug5ESrv+7EdbsluXB4i5A6s3bpl44k3ipLscmr2W2AzqDG1IdT 9jg= X-SBRS: 2.7 X-MesageID: 3787857 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,338,1559534400"; d="scan'208";a="3787857" From: Anthony PERARD To: Date: Fri, 2 Aug 2019 16:36:02 +0100 Message-ID: <20190802153606.32061-32-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802153606.32061-1-anthony.perard@citrix.com> References: <20190802153606.32061-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 31/35] libxl: Use ev_qmp for libxl_send_trigger X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_domain.c | 49 ++++++++++++++++++++++++++++++------ tools/libxl/libxl_internal.h | 2 -- tools/libxl/libxl_qmp.c | 5 ---- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index cd71900350..08d3fc9fbc 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1556,19 +1556,39 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, return AO_INPROGRESS; } -static int libxl__domain_s3_resume(libxl__gc *gc, int domid) +static void domain_s3_resume_done(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc); + +static void domain_s3_resume(libxl__ao *ao, libxl__egc *egc, int domid) { + AO_GC; + libxl__ev_qmp *qmp; int rc = 0; + int r; + + GCNEW(qmp); + libxl__ev_qmp_init(qmp); + qmp->ao = ao; + qmp->domid = domid; + qmp->payload_fd = -1; + qmp->callback = domain_s3_resume_done; switch (libxl__domain_type(gc, domid)) { case LIBXL_DOMAIN_TYPE_HVM: switch (libxl__device_model_version_running(gc, domid)) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: - rc = xc_hvm_param_set(CTX->xch, domid, HVM_PARAM_ACPI_S_STATE, 0); + r = xc_hvm_param_set(CTX->xch, domid, HVM_PARAM_ACPI_S_STATE, 0); + if (r) { + LOGED(ERROR, domid, "Send trigger '%s' failed", + libxl_trigger_to_string(LIBXL_TRIGGER_S3RESUME)); + rc = ERROR_FAIL; + } break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - rc = libxl__qmp_system_wakeup(gc, domid); - break; + rc = libxl__ev_qmp_send(gc, qmp, "system_wakeup", NULL); + if (rc) goto out; + return; default: rc = ERROR_INVAL; break; @@ -1579,7 +1599,22 @@ static int libxl__domain_s3_resume(libxl__gc *gc, int domid) break; } - return rc; +out: + domain_s3_resume_done(egc, qmp, NULL, rc); +} + +static void domain_s3_resume_done(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + EGC_GC; + + if (rc) + LOGD(ERROR, qmp->domid, "Send trigger '%s' failed, rc=%d", + libxl_trigger_to_string(LIBXL_TRIGGER_S3RESUME), rc); + + libxl__ev_qmp_dispose(gc, qmp); + libxl__ao_complete(egc, qmp->ao, rc); } int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, @@ -1611,8 +1646,8 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid, XEN_DOMCTL_SENDTRIGGER_RESET, vcpuid); break; case LIBXL_TRIGGER_S3RESUME: - rc = libxl__domain_s3_resume(gc, domid); - break; + domain_s3_resume(ao, egc, domid); /* must be last */ + return AO_INPROGRESS; default: rc = -1; errno = EINVAL; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 3e7cb4005d..c6b9655af2 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1983,8 +1983,6 @@ typedef struct libxl__qmp_handler libxl__qmp_handler; */ _hidden libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid); -/* Resume hvm domain */ -_hidden int libxl__qmp_system_wakeup(libxl__gc *gc, int domid); /* Resume QEMU. */ _hidden int libxl__qmp_resume(libxl__gc *gc, int domid); /* Load current QEMU state from file. */ diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 8fac737fad..40043a0a45 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -752,11 +752,6 @@ static int qmp_run_command(libxl__gc *gc, int domid, return rc; } -int libxl__qmp_system_wakeup(libxl__gc *gc, int domid) -{ - return qmp_run_command(gc, domid, "system_wakeup", NULL, NULL, NULL); -} - int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file) { libxl__json_object *args = NULL;