From nobody Sun Dec 7 07:34:22 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 1739985308711793.2026181516247; Wed, 19 Feb 2025 09:15:08 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 1546D1D55; Wed, 19 Feb 2025 12:15:07 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6EB181DB6; Wed, 19 Feb 2025 12:03:06 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2B1691C86; Wed, 19 Feb 2025 12:03:01 -0500 (EST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 BC8DE1C86 for ; Wed, 19 Feb 2025 12:02:25 -0500 (EST) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-220f4dd756eso101368475ad.3 for ; Wed, 19 Feb 2025 09:02:25 -0800 (PST) Received: from localhost.localdomain ([2001:4490:4ea9:8374:8512:e327:fdaf:a56e]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-220d558fe3asm106651545ad.234.2025.02.19.09.02.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 19 Feb 2025 09:02:22 -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=1739984544; x=1740589344; 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=8AcEXrMygcvYh+zqxiZsbv43Lkie1cHdFbn9GQZP/Uk=; b=Ibht/4ctW7QlzEYsVEW3XkSUCoNChqKxrbnI+FSG9g8hyqVoJztaCBkD2n4ymXfdM5 uhqtevYpZ/+sV+R2oMqw7M73Uf/tDywODggWx+aHWhpz3mmeFbkyonmaapTaouwjSz3M fYUMc/tLndup3TFs+kTu4KJL0iBIIWiO4eDecXTTJjC7UbRqX3UCQcPDiSQgZ4glsjfA Kle5PlQuu02Gx0WwJtbCGZaLSNj3ZbBNs7eZjF7awtpPRGGBihHI7LOk3tZnTR5WdEEr 8e0SK/ZEY027EKQOT/fbNJzHdJjR7e9rz9sgJjbt+jQ4HbPBF+ptrpz8y2lArMI3ZeSD iKXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739984544; x=1740589344; 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=8AcEXrMygcvYh+zqxiZsbv43Lkie1cHdFbn9GQZP/Uk=; b=TPxcgth15t85zkERLKlNH0H0D+ni/q/77hLmnPl3lHWj1KVQYXVhlOLwwrUuT0swkq zdoMg5goq5bS0gh9+99g9gllYaunNaz/ULmAouokzYJulJMsGJC50PDxaqu1rAvyly20 USuCiSJnky//IMDW0dpBaEV4UZiQaXamfMYjv/56Bzgo/RZQtRw1nyFeHasHimmNLeOA jJOvWvEyiJ2VQEXvfI8kujmPBAyEHQ+E7dFd8pTUOgwHMyhwnK9E+liOTZYC45F+inkx ehbksxw2IupHf5Ks/FkQAxqdpd2Y4B0aNGRQI6VjhspyM/wk6uYN93FgwcQDKK42aRec ol6g== X-Gm-Message-State: AOJu0YxVanODsKPm/9ly0aPl3bukziys5uEGp6c66ulMKVQXDYbg4v7w hh0yWDoNh0Q63mUhRn3vLt6nggntm3WRWsOzbgfLeBW6RD4+3AYLK/wz4xIU X-Gm-Gg: ASbGncvLwUlUZ+OFesMO6IESSKzSZIOoCpthCDgkKlOYNW/RwLARleav/L3HdQVbxqR aSo/+sYxsJBoUnHLi6JCmVZPLuxm6OoIKbPwksCcx5QPhvSh0juoNqbCSIX67Tb8u8c7TdziN+s w7G3+JSn9Co3h4xLgUNpJHjA8o7hvRrA0XksfvrjWJv+upr7wnhl0rRJETcb2TuEY6R/ntAje6e QXbay9JXW97xHehbDG8s7OuYS6xo85ww/6s1KvV6bYWOF/9y4BaGsM1sn3lq1X6ydL6Iv5sI0L7 3BTAtOtlUFIFTxiA5Giz9yVgzcxlaAwOEaZ+qQxryvQCuQckEWx0cdu8zA== X-Google-Smtp-Source: AGHT+IHplNjDNK4s3tQxjlliuFr7rb9Y+jdfQ9FABpPe32Fya0y2/888FSwGb3WCNLt5sNk4ztoWDA== X-Received: by 2002:a17:902:ec8c:b0:21f:68ae:56e3 with SMTP id d9443c01a7336-221040bf834mr291463645ad.39.1739984542841; Wed, 19 Feb 2025 09:02:22 -0800 (PST) From: Harikumar Rajkumar To: devel@lists.libvirt.org Subject: [PATCH v8 18/18] virsh: Add option "throttle-groups" to "attach_disk" Date: Wed, 19 Feb 2025 22:27:22 +0530 Message-Id: <20250219165722.26348-19-harirajkumar230@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250219165722.26348-1-harirajkumar230@gmail.com> References: <20250219165722.26348-1-harirajkumar230@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FACJ5AWNV3SO6RNKIFEE7QTXKPPWHVKM X-Message-ID-Hash: FACJ5AWNV3SO6RNKIFEE7QTXKPPWHVKM 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: sanjeev.ranjan@ibm.com, harikumar.rajkumar@ibm.com, earulana@in.ibm.com, Chun Feng Wu , 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: 1739985309412019000 Content-Type: text/plain; charset="utf-8" From: Chun Feng Wu Update "attach_disk" to support new option: throttle-groups to form filter chain in QEMU for specific disk Signed-off-by: Chun Feng Wu * apply suggested coding style changes. Signed-off-by: Harikumar Rajkumar --- docs/manpages/virsh.rst | 3 ++- tools/virsh-completer-domain.c | 27 +++++++++++++++++++++++++++ tools/virsh-completer-domain.h | 5 +++++ tools/virsh-domain.c | 25 ++++++++++++++++++++++++- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 8726870cf9..7d5a3ff74a 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5028,7 +5028,7 @@ attach-disk [--source-protocol protocol] [--source-host-name hostname:port] [--source-host-transport transport] [--source-host-socket socket] [--serial serial] [--wwn wwn] [--rawio] [--address address] - [--multifunction] [--print-xml] + [--multifunction] [--print-xml] [--throttle-groups groups] =20 Attach a new disk device to the domain. *source* is path for the files and devices unless *--source-protocol* @@ -5068,6 +5068,7 @@ ide:controller.bus.unit, usb:bus.port, sata:controlle= r.bus.unit or ccw:cssid.ssid.devno. Virtio-ccw devices must have their cssid set to 0xfe. *multifunction* indicates specified pci address is a multifunction pci dev= ice address. +*throttle-groups* is comma separated list of throttle groups to be applied. =20 There is also support for using a network disk. As specified, the user can provide a *--source-protocol* in which case the *source* parameter will diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 3b0df15c13..b96180be9e 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -303,6 +303,33 @@ virshDomainThrottleGroupCompleter(vshControl *ctl, } =20 =20 +static char ** +virshDomainThrottleGroupListCompleter(vshControl *ctl, + const vshCmd *cmd, + const char *argname) +{ + const char *curval =3D NULL; + g_auto(GStrv) groups =3D virshDomainThrottleGroupCompleter(ctl, cmd, 0= ); + + if (vshCommandOptStringQuiet(ctl, cmd, argname, &curval) < 0) + return NULL; + + if (!groups) + return NULL; + + return virshCommaStringListComplete(curval, (const char **) groups); +} + + +char ** +virshDomainThrottleGroupsCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int completeflags G_GNUC_UNUSE= D) +{ + return virshDomainThrottleGroupListCompleter(ctl, cmd, "throttle-group= s"); +} + + char ** virshDomainUndefineStorageDisksCompleter(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 680b3fc018..23b432d05c 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -52,6 +52,11 @@ virshDomainThrottleGroupCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); =20 +char ** +virshDomainThrottleGroupsCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + char ** virshDomainInterfaceStateCompleter(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index b8f61340cc..e156199eb1 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -522,6 +522,11 @@ static const vshCmdOptDef opts_attach_disk[] =3D { .type =3D VSH_OT_STRING, .help =3D N_("host socket for source of disk device") }, + {.name =3D "throttle-groups", + .type =3D VSH_OT_STRING, + .completer =3D virshDomainThrottleGroupsCompleter, + .help =3D N_("comma separated list of throttle groups to be applied") + }, VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, VIRSH_COMMON_OPT_DOMAIN_CONFIG, VIRSH_COMMON_OPT_DOMAIN_LIVE, @@ -611,6 +616,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) const char *host_name =3D NULL; const char *host_transport =3D NULL; const char *host_socket =3D NULL; + const char *throttle_groups_str =3D NULL; + g_auto(GStrv) throttle_groups =3D NULL; int ret; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; const char *stype =3D NULL; @@ -665,9 +672,14 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) vshCommandOptString(ctl, cmd, "source-protocol", &source_protocol)= < 0 || vshCommandOptString(ctl, cmd, "source-host-name", &host_name) < 0 = || vshCommandOptString(ctl, cmd, "source-host-transport", &host_trans= port) < 0 || - vshCommandOptString(ctl, cmd, "source-host-socket", &host_socket) = < 0) + vshCommandOptString(ctl, cmd, "source-host-socket", &host_socket) = < 0 || + vshCommandOptString(ctl, cmd, "throttle-groups", &throttle_groups_= str) < 0) return false; =20 + if (throttle_groups_str) { + throttle_groups =3D g_strsplit(throttle_groups_str, ",", 0); + } + if (stype && (type =3D virshAttachDiskSourceTypeFromString(stype)) < 0) { vshError(ctl, _("Unknown source type: '%1$s'"), stype); @@ -714,6 +726,17 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) =20 virXMLFormatElement(&diskChildBuf, "driver", &driverAttrBuf, NULL); =20 + if (throttle_groups) { + g_auto(virBuffer) throttleChildBuf =3D VIR_BUFFER_INITIALIZER; + char **iter; + for (iter =3D throttle_groups; *iter !=3D NULL; iter++) { + g_auto(virBuffer) throttleAttrBuf =3D VIR_BUFFER_INITIALIZER; + virBufferAsprintf(&throttleAttrBuf, " group=3D'%s'", *iter); + virXMLFormatElement(&throttleChildBuf, "throttlefilter", &thro= ttleAttrBuf, NULL); + } + virXMLFormatElement(&diskChildBuf, "throttlefilters", NULL, &throt= tleChildBuf); + } + switch ((enum virshAttachDiskSourceType) type) { case VIRSH_ATTACH_DISK_SOURCE_TYPE_FILE: virBufferEscapeString(&sourceAttrBuf, " file=3D'%s'", source); --=20 2.39.5 (Apple Git-154)