From nobody Wed Dec 17 08:52:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1739356785417501.8385587318628; Wed, 12 Feb 2025 02:39:45 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B0AA613A3; Wed, 12 Feb 2025 05:39:44 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 239F114D1; Wed, 12 Feb 2025 05:36:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 0D03319DF; Wed, 12 Feb 2025 05:36:16 -0500 (EST) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 02B451B4F for ; Wed, 12 Feb 2025 05:36:00 -0500 (EST) Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2f9f5caa37cso1100847a91.0 for ; Wed, 12 Feb 2025 02:36:00 -0800 (PST) Received: from localhost.localdomain ([117.251.37.46]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2fbf98b3277sm1147688a91.7.2025.02.12.02.35.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 12 Feb 2025 02:35:58 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739356560; x=1739961360; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8FoBIbJH7e864Ex5HS8yoRaXk8XPpimHlePQ04GnBb0=; b=FQJ7c0SvMq0IdGnJG8Yj/55uWOe9BFTzOwzhi4oaCGZKS8sVYZt5uTAw3GI/88OXmQ Q8uvQ99l3vRbWxnrBFv/ivo7OR5hGZIgZO7DY4TyvdoYLDoTb9BYx6ianZAz3KSQkzlK irlVxcNpOTxmXtJRHmIcSer8MXPUKa4/q530fwoLGlwIapSoQFkjgv4j1U3b8C89wSYl V2NFG1s28RTGTZ757emuO6PIwJrtEfZZlpgphAI8qpZ4I/a5AZyB+LbupKQJQSbNpQpo uGMpqdFwh8aIPD/D2qcH6nXvM0/WZIUoJ9G1eWs7FOu4U4kMnWvCiJQ3BqTCGjGRzkbn IhvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739356560; x=1739961360; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8FoBIbJH7e864Ex5HS8yoRaXk8XPpimHlePQ04GnBb0=; b=ob+NMXIw7SYOXQSZ1MvTOSS+lcp9EfhaVBIwdyyWH3c5hcJTPo121cZ8ponzaVar0r LDnzvEJOMzFFFBvpbmys3pkodXOmqOONS0WcKK7OheC0pcadsCO7vamZbC7nLFJAGceV ciGG4PhHNdpws2xbYyysgzYi44uPYDDIbplwnrdCrEz2S8uuDOWK7nVIw3YM5nyeHkyQ D4u5GQx7CD5pairhEgwo6kdwAlmbVyCTXWsrggFeG2fONacuoXRunVePjubXdCt7dXvK x9g81DyI2kl8Lo6kl6/ZI4QKX9TSouRfHnEVsH1sbdVco4AzB1C0Fzq9J5L+M1Eg3ZND b4QQ== X-Gm-Message-State: AOJu0Yz/2ExYRBZrpwy8/QzvtF5Gs3etgKs47Ns+DU1Hs9UbBrj7gr0H dZQQz3whD6vDpOzC69XC5Mzjj8I4LPT4DVBaJr5cNew7UQHkrZxdGRBQbg== X-Gm-Gg: ASbGncuKM8Q1a2szNb/phjgWDsx7H/46TY78puNG3ui2rjWYiPLcOycFIy97XjmCJ3K Qckpy0hRu9FlJwpgCUzNBSkl6qgLtxU/UmIkNkQb/HUvZt11yjkI9y/aR4CNXuyG1kp3VoTgqj1 Mo7zi8/xNXcabxEDUPBOf4Vs27ug77gAsaanpxDkns4ai1QLhAwP6OOydmDF/KwCpTERgftiiDn G3gLzuj3JoBFN1bcXq6Q5PgyWefRKHvdRHKt5hCuc0oMOO8CHaxxm9I9fHY89uzk/3ZCjdl6bfR emVO6qzGeiRAObUnKLPLtWVnYloVkhu/Q1GyB8Sr0xqhlQ== X-Google-Smtp-Source: AGHT+IEi58TDY6+cgXar4QtosWDnRMF0RXYTO7qtnhAOBmZBBuFyIGp4ESPnqSZynAKrISutVLcKVQ== X-Received: by 2002:a17:90b:2f4b:b0:2f6:e47c:1750 with SMTP id 98e67ed59e1d1-2fbf5c60374mr4285575a91.13.1739356559494; Wed, 12 Feb 2025 02:35:59 -0800 (PST) From: Harikumar Rajkumar To: devel@lists.libvirt.org Subject: [PATCH v7 05/18] qemu: monitor: Add support for ThrottleGroup operations Date: Wed, 12 Feb 2025 16:05:24 +0530 Message-Id: <20250212103537.26352-6-harirajkumar230@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250212103537.26352-1-harirajkumar230@gmail.com> References: <20250212103537.26352-1-harirajkumar230@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: B2HAYGZRC2LMOQXGFYRH2ZN4KNPSRBAC X-Message-ID-Hash: B2HAYGZRC2LMOQXGFYRH2ZN4KNPSRBAC X-MailFrom: harirajkumar230@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: harikumar.rajkumar@ibm.com, sanjeev.ranjan@ibm.com, earulana@in.ibm.com, Harikumar Rajkumar X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1739356792268019000 Content-Type: text/plain; charset="utf-8" This change contains QMP requests for ThrottleGroup * ThrottleGroup is updated through "qemuMonitorJSONUpdateThrottleGroup" * ThrottleGroup is retrieved through "qemuMonitorJSONGetThrottleGroup" * ThrottleGroup is deleted by reusing "qemuMonitorDelObject" * ThrottleGroup is added by reusing "qemuMonitorAddObject" * "qemuMonitorMakeThrottleGroupLimits" will be used by building qemu cmd as well Signed-off-by: Harikumar Rajkumar --- src/qemu/qemu_monitor.c | 34 +++++++++ src/qemu/qemu_monitor.h | 14 ++++ src/qemu/qemu_monitor_json.c | 129 +++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 14 ++++ 4 files changed, 191 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 830ecbad1c..962c517d21 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3037,6 +3037,40 @@ qemuMonitorGetBlockIoThrottle(qemuMonitor *mon, } =20 =20 +int +qemuMonitorThrottleGroupLimits(virJSONValue *limits, + const virDomainThrottleGroupDef *group) +{ + return qemuMonitorMakeThrottleGroupLimits(limits, group); +} + + +int +qemuMonitorUpdateThrottleGroup(qemuMonitor *mon, + const char *qomid, + virDomainBlockIoTuneInfo *info) +{ + VIR_DEBUG("qomid=3D%s, info=3D%p", qomid, info); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONUpdateThrottleGroup(mon, qomid, info); +} + + +int +qemuMonitorGetThrottleGroup(qemuMonitor *mon, + const char *groupname, + virDomainBlockIoTuneInfo *reply) +{ + VIR_DEBUG("throttle-group=3D%s, reply=3D%p", groupname, reply); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetThrottleGroup(mon, groupname, reply); +} + + int qemuMonitorVMStatusToPausedReason(const char *status) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 072f452e79..cea61b2e70 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1074,6 +1074,20 @@ int qemuMonitorGetBlockIoThrottle(qemuMonitor *mon, const char *qdevid, virDomainBlockIoTuneInfo *reply); =20 +int +qemuMonitorThrottleGroupLimits(virJSONValue *limits, + const virDomainThrottleGroupDef *group); + +int +qemuMonitorUpdateThrottleGroup(qemuMonitor *mon, + const char *qomid, + virDomainBlockIoTuneInfo *info); + +int +qemuMonitorGetThrottleGroup(qemuMonitor *mon, + const char *groupname, + virDomainBlockIoTuneInfo *reply); + int qemuMonitorSystemWakeup(qemuMonitor *mon); =20 int qemuMonitorGetVersion(qemuMonitor *mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 890d9b7dfd..802b68fae6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4685,6 +4685,135 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *= mon, return qemuMonitorJSONBlockIoThrottleInfo(devices, qdevid, reply); } =20 + +int +qemuMonitorMakeThrottleGroupLimits(virJSONValue *limits, + const virDomainThrottleGroupDef *group) +{ + if (virJSONValueObjectAdd(&limits, + "U:bps-total", group->total_bytes_sec, + "U:bps-read", group->read_bytes_sec, + "U:bps-write", group->write_bytes_sec, + "U:iops-total", group->total_iops_sec, + "U:iops-read", group->read_iops_sec, + "U:iops-write", group->write_iops_sec, + "U:bps-total-max", group->total_bytes_sec_ma= x, + "U:bps-read-max", group->read_bytes_sec_max, + "U:bps-write-max", group->write_bytes_sec_ma= x, + "U:iops-total-max", group->total_iops_sec_ma= x, + "U:iops-read-max", group->read_iops_sec_max, + "U:iops-write-max", group->write_iops_sec_ma= x, + "U:iops-size", group->size_iops_sec, + "P:bps-total-max-length", group->total_bytes= _sec_max_length, + "P:bps-read-max-length", group->read_bytes_s= ec_max_length, + "P:bps-write-max-length", group->write_bytes= _sec_max_length, + "P:iops-total-max-length", group->total_iops= _sec_max_length, + "P:iops-read-max-length", group->read_iops_s= ec_max_length, + "P:iops-write-max-length", group->write_iops= _sec_max_length, + NULL) < 0) + return -1; + + return 0; +} + + +int +qemuMonitorJSONUpdateThrottleGroup(qemuMonitor *mon, + const char *qomid, + virDomainBlockIoTuneInfo *info) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) result =3D NULL; + g_autoptr(virJSONValue) limits =3D virJSONValueNewObject(); + + if (qemuMonitorMakeThrottleGroupLimits(limits, info) < 0) + return -1; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-set", + "s:property", "limits", + "s:path", qomid, + "a:value", &limits, + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &result) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, result) < 0) + return -1; + + return 0; +} + + +#define GET_THROTTLE_GROUP_VALUE(FIELD, STORE) \ + if (virJSONValueObjectHasKey(ret, FIELD)) { \ + if (virJSONValueObjectGetNumberUlong(ret, FIELD, &reply->STORE) < = 0) { \ + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, \ + _("value of throttle group field '%1$s' is malforme= d"), \ + #STORE); \ + return -1; \ + } \ + } + + +int +qemuMonitorJSONGetThrottleGroup(qemuMonitor *mon, + const char *gname, + virDomainBlockIoTuneInfo *reply) +{ + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) result =3D NULL; + g_autofree char *groupCopy =3D NULL; + virJSONValue *ret; + + /* prefix group name with "throttle-" in QOM */ + g_autofree char *path =3D g_strdup_printf("/objects/throttle-%s", gnam= e); + if (!(cmd =3D qemuMonitorJSONMakeCommand("qom-get", + "s:path", path, + "s:property", "limits", + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &result) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, result) < 0) + return -1; + + if (!(ret =3D qemuMonitorJSONGetReply(cmd, result, VIR_JSON_TYPE_OBJEC= T))) + return -1; + + GET_THROTTLE_GROUP_VALUE("bps-total", total_bytes_sec); + GET_THROTTLE_GROUP_VALUE("bps-read", read_bytes_sec); + GET_THROTTLE_GROUP_VALUE("bps-write", write_bytes_sec); + GET_THROTTLE_GROUP_VALUE("iops-total", total_iops_sec); + GET_THROTTLE_GROUP_VALUE("iops-read", read_iops_sec); + GET_THROTTLE_GROUP_VALUE("iops-write", write_iops_sec); + + GET_THROTTLE_GROUP_VALUE("bps-total-max", total_bytes_sec_max); + GET_THROTTLE_GROUP_VALUE("bps-read-max", read_bytes_sec_max); + GET_THROTTLE_GROUP_VALUE("bps-write-max", write_bytes_sec_max); + GET_THROTTLE_GROUP_VALUE("iops-total-max", total_iops_sec_max); + GET_THROTTLE_GROUP_VALUE("iops-read-max", read_iops_sec_max); + GET_THROTTLE_GROUP_VALUE("iops-write-max", write_iops_sec_max); + GET_THROTTLE_GROUP_VALUE("iops-size", size_iops_sec); + + GET_THROTTLE_GROUP_VALUE("bps-total-max-length", total_bytes_sec_max_l= ength); + GET_THROTTLE_GROUP_VALUE("bps-read-max-length", read_bytes_sec_max_len= gth); + GET_THROTTLE_GROUP_VALUE("bps-write-max-length", write_bytes_sec_max_l= ength); + GET_THROTTLE_GROUP_VALUE("iops-total-max-length", total_iops_sec_max_l= ength); + GET_THROTTLE_GROUP_VALUE("iops-read-max-length", read_iops_sec_max_len= gth); + GET_THROTTLE_GROUP_VALUE("iops-write-max-length", write_iops_sec_max_l= ength); + + groupCopy =3D g_strdup(gname); + reply->group_name =3D g_steal_pointer(&groupCopy); + + return 0; +} +#undef GET_THROTTLE_GROUP_VALUE + + int qemuMonitorJSONSystemWakeup(qemuMonitor *mon) { g_autoptr(virJSONValue) cmd =3D NULL; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 2f5a021f56..d2f9d937e7 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -375,6 +375,20 @@ qemuMonitorJSONSetBlockIoThrottle(qemuMonitor *mon, const char *qomid, virDomainBlockIoTuneInfo *info); =20 +int +qemuMonitorMakeThrottleGroupLimits(virJSONValue *limits, + const virDomainThrottleGroupDef *group); + +int +qemuMonitorJSONUpdateThrottleGroup(qemuMonitor *mon, + const char *qomid, + virDomainBlockIoTuneInfo *info); + +int +qemuMonitorJSONGetThrottleGroup(qemuMonitor *mon, + const char *gname, + virDomainBlockIoTuneInfo *reply); + int qemuMonitorJSONGetBlockIoThrottle(qemuMonitor *mon, const char *qdevid, --=20 2.39.5 (Apple Git-154)