From nobody Sat Feb 7 10:08:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554153539814484.8262512528064; Mon, 1 Apr 2019 14:18:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 576823082E03; Mon, 1 Apr 2019 21:18:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2B441001DC1; Mon, 1 Apr 2019 21:18:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 46A56180338A; Mon, 1 Apr 2019 21:18:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x31LIg6W012340 for ; Mon, 1 Apr 2019 17:18:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id E93241001DC1; Mon, 1 Apr 2019 21:18:42 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C2871001DF1 for ; Mon, 1 Apr 2019 21:18:42 +0000 (UTC) Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0899F88AC0 for ; Mon, 1 Apr 2019 21:18:41 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id x12so12745881qts.7 for ; Mon, 01 Apr 2019 14:18:40 -0700 (PDT) Received: from rekt.ibmmodules.com ([2804:431:f700:6702:8bc5:7364:e3c:ea55]) by smtp.gmail.com with ESMTPSA id l129sm5781689qkb.44.2019.04.01.14.18.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Apr 2019 14:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uVzi3j2jL7GrxXbzxEzHGuxo6i4HsdxgEffWMsmwe9s=; b=Og6mH7hqt25C4k9EFWF32XAgUoVuZx4bEqAIxYs7jjawlfExJ9bszA+gThSUtPDOBX E6djBJqL8OBPv1D2J+qc2hpPXLs5I/QUMgUIJABXGfjd9+rU2kX0i13kMxrh3RoI11c1 wFQzo0V3T8A/irRJuJERZ5bE1mDsI06FvZTAU/XhceJ8l0GM6pGa2DW8Dg86qdxGKLWN QVG1kfYPaMcGNojve62D+WlkfLDdeS60ABC3QiioYsBwdl1XWC8dpSk/fKoxJH9MLbve r+wURoZzJPLb/sIbZryc5DG7zpuf2ohS37pWpEP6kp6DkrWQLdfsAPOtNrpDIBZoGs6Y VbzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uVzi3j2jL7GrxXbzxEzHGuxo6i4HsdxgEffWMsmwe9s=; b=BNKUSGm9xgsoQXnVtbNLZhK7n5deTueW3Mw8Sq4Xu9HiFFmmaBnZNimJ4dKKBODMpz KBoMk/4mlIYxC0hJj4bzwm1N53yCS5bLNGENu/VmmEMNteqNKNeT3NSfTiCuK4/Gc8Lh 5hS4/hljRKmjNq5kCIjImRlUEqWeTWJz5+uvAM7oR2StMPrBxg+iFOMDti3chffhydd1 wL3EDyVUolCJSqIiOCmiHSoo+R8Jtj4JQBgNyw6OsKv7d0srmrL2XqK6M7r20DI/wAHQ ndtvKWZRyz9hfnYjSJX8MmwibYuMeDf7aAPuw8kan1Qe+gTsSI7g+H1RI4TB/Q+aXo/k HrYg== X-Gm-Message-State: APjAAAWsHF640TV9q31Dgh0ltvuJu9roUZSvLem18Ruh5umiGHtEo97n RY+iiPv4PbS6k/AVxLSfMm9z95kZ X-Google-Smtp-Source: APXvYqyoJ38UvKGBwad6uqwxkeJI5rgJJ/xqVf5oCogUiUeSvU7iTQAtqNE9FqavbET3NE2Da+ti7A== X-Received: by 2002:ac8:13c3:: with SMTP id i3mr54106047qtj.211.1554153520101; Mon, 01 Apr 2019 14:18:40 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 1 Apr 2019 18:18:25 -0300 Message-Id: <20190401211826.8598-3-danielhb413@gmail.com> In-Reply-To: <20190401211826.8598-1-danielhb413@gmail.com> References: <20190401211826.8598-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 01 Apr 2019 21:18:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 01 Apr 2019 21:18:41 +0000 (UTC) for IP:'209.85.160.196' DOMAIN:'mail-qt1-f196.google.com' HELO:'mail-qt1-f196.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.12 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.160.196 mail-qt1-f196.google.com 209.85.160.196 mail-qt1-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH 2/3] setting QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT qemu capability X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 01 Apr 2019 21:18:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT is a bool that represents the value of the wakeup-suspend-support flag of the new query-current-machine QMP API, available in QEMU 4.0. The flag is set in qemuProcessLaunch, using a new function called qemuProcessSetupWakeupSuspendSupport. This function checks first if the QEMU process has support for the new API, which is reflected by the QEMU_CAPS_QUERY_CURRENT_MACHINE cap. If positive, query it and set QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT with the current value of wakeup-suspend-support. --- src/qemu/qemu_monitor.c | 8 ++++++++ src/qemu/qemu_monitor.h | 3 +++ src/qemu/qemu_monitor_json.c | 35 +++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ src/qemu/qemu_process.c | 38 ++++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index babcbde878..fc6dc2197a 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4472,3 +4472,11 @@ qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon, virHashFree(info); return ret; } + +int +qemuMonitorGetWakeupSuspendSupport(qemuMonitorPtr mon, bool *enabled) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetWakeupSuspendSupport(mon, enabled); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 086195ff98..62074c1acb 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1220,4 +1220,7 @@ struct _qemuMonitorPRManagerInfo { int qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon, virHashTablePtr *retinfo); =20 +int qemuMonitorGetWakeupSuspendSupport(qemuMonitorPtr mon, + bool *enabled); + #endif /* LIBVIRT_QEMU_MONITOR_H */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 743a88b914..16d34fb217 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8452,3 +8452,38 @@ qemuMonitorJSONGetPRManagerInfo(qemuMonitorPtr mon, return ret; =20 } + +int +qemuMonitorJSONGetWakeupSuspendSupport(qemuMonitorPtr mon, bool *enabled) +{ + int ret =3D -1; + virJSONValuePtr cmd, data; + virJSONValuePtr reply =3D NULL; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-current-machine", + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + goto cleanup; + + data =3D virJSONValueObjectGetObject(reply, "return"); + + if (virJSONValueObjectGetBoolean(data, "wakeup-suspend-support", + enabled)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing wakeup-suspend-support in " + "query-current-machine response")); + goto cleanup; + } + + ret =3D 0; + + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index c10513da15..ede828d622 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -576,4 +576,8 @@ int qemuMonitorJSONGetPRManagerInfo(qemuMonitorPtr mon, virHashTablePtr info) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +int qemuMonitorJSONGetWakeupSuspendSupport(qemuMonitorPtr mon, + bool *enabled) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + #endif /* LIBVIRT_QEMU_MONITOR_JSON_H */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index dc7317b723..71984714de 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6449,6 +6449,41 @@ qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriver= Ptr driver, return ret; } =20 +/** + * qemuProcessSetupWakeupSuspendSupport: + * + * Sets up QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT in case QEMU has support + * for the query-current-machine QMP API. This can be verified by + * checking for the QEMU_CAPS_QUERY_CURRENT_MACHINE cap. + */ +static int +qemuProcessSetupWakeupSuspendSupport(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + bool enabled; + int ret =3D -1; + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CURRENT_MACHINE)) + return 0; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + if (qemuMonitorGetWakeupSuspendSupport(qemuDomainGetMonitor(vm), &enab= led) < 0) + goto cleanup; + + if (enabled) + virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_WAKEUP_SUSPEND_SUPPORT); + + ret =3D 0; + + cleanup: + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret =3D -1; + return ret; +} =20 /** * qemuProcessLaunch: @@ -6777,6 +6812,9 @@ qemuProcessLaunch(virConnectPtr conn, qemuProcessAutoDestroyAdd(driver, vm, conn) < 0) goto cleanup; =20 + if (qemuProcessSetupWakeupSuspendSupport(driver, vm, asyncJob) < 0) + goto cleanup; + ret =3D 0; =20 cleanup: --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list