From nobody Wed Dec 17 08:52:27 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 1739357374435671.4715283607076; Wed, 12 Feb 2025 02:49:34 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id CB1D41250; Wed, 12 Feb 2025 05:49:33 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 83ADE1E58; Wed, 12 Feb 2025 05:37:13 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8E6C81E73; Wed, 12 Feb 2025 05:37:07 -0500 (EST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 CE75C1DFE for ; Wed, 12 Feb 2025 05:36:41 -0500 (EST) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2f9bac7699aso9736658a91.1 for ; Wed, 12 Feb 2025 02:36:41 -0800 (PST) Received: from localhost.localdomain ([117.251.37.46]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2fbf98b3277sm1147688a91.7.2025.02.12.02.36.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 12 Feb 2025 02:36:38 -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=1739356600; x=1739961400; 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=l/TCdasPJWJWcnlcxX9+zwjS4oBptWzMFFuXiwGUY3U=; b=IinsuKeulpvOvwPH++mdjC+qhDLqRm+fO+VCBWum1UtcLTzBSr3nADMm2Z4gZgvKMw 4AgA+I6JldVws0iIL27KR2VUWwcrIN+3ON/yscu5KqUjfi/8SlKBq8nb2FLkLkU6EEGU eGwsM3LNUtvHrjuGesMGlaAuDgCuf4TgLc/xzFkGvYctDaZbarBBpaa6B4zBUP6P2YRJ KfZHXdzS8j9K2G29rK2J0kdwlWm2AY6EPOqhy1LaO+uzkxL90HDtKNPTaOg1ZaFokj+/ LGuKr/TGQA5YSkUHzHblMRKnVs+1NTNqsgP8G4cRUUKsi6iDF1doR4Dbc82NeymZZkq2 uvqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739356600; x=1739961400; 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=l/TCdasPJWJWcnlcxX9+zwjS4oBptWzMFFuXiwGUY3U=; b=TT2s37F+R9VWjd44hD7/r8mNOaYWWBt9VZ4OGdtNLyFV7fBZS1N4QEBUVYGhcFV3NO 4Hm67rZoLUd3QEuBrOuRoOhB8DfxVGMMVj/FPvB0q1yRvGO4UN8/Z3fzhBHBLR0mJ9ie JhJi+tSqAqkuj7BF6omhTon+8O8Laxd48KktYJ1EnIDOSEDS+cvJsjQ/Eu27xjNYKPid 2xHd9m50kEdDnXFnCnNq6KH0b7+AbStKDEuTT++hc1GWMNxC/ccjoPu0EFWbO8oZavhE p32SHtikB+Rw1mUn7Gmu1Vz9Zj8EF5oynlDxfG0F7PC3y/Tr/ucn+WDpdGUhrLNGqN5h SX7g== X-Gm-Message-State: AOJu0YxLl0j1E7u/o+XBNwbMMD5MFURhrT4JfT1ZukEZ2SjxlamQueMo J7OVE6bjIkCBT/jsyHm6khXnq0VaNC0XRuz0c5TaEE5y3PQqs5uR8ftpCg== X-Gm-Gg: ASbGnctrl324DhGs/qOnJoqgdTFFWOxkXPrm8FW5R0O0MK/FsVghLlqY1sU123gx/U/ HPePwvYApL9b4feRHMzYKGFy3FGDiXfxu4HZJTZZYhr8Ksprf/O/lFD4Vr/Yt8tp8wqK8pOMJR6 vfPAMqXpMm38w9Tztsj4Ac/vfRO6OcEzEki6He1YYzuHfR+9VlU/uPAFAOWC2OXG4jbJ8m5ZQej FjgPRKKz4BE5G5qoIJ/431FJwo0Jp9PZInD6w8Pb6JnoZlXpZ4JLQJidUY0NBYySmvztcFy2hCH d4Yx49vdicvp0vWTv4EyQRgamVa1qEkgTW1MRpZyJjTYKA== X-Google-Smtp-Source: AGHT+IG1qxyg1NDDWqmTJIu1tWaemRRegyXkNIXwKsrHOSxFO6ye8K8whooo1S6cuguIjy7qlboyGg== X-Received: by 2002:a17:90b:1b45:b0:2fa:228d:5af2 with SMTP id 98e67ed59e1d1-2fbf8f56991mr3305549a91.15.1739356598446; Wed, 12 Feb 2025 02:36:38 -0800 (PST) From: Harikumar Rajkumar To: devel@lists.libvirt.org Subject: [PATCH v7 18/18] virsh: Add option throttle-groups to attach_disk Date: Wed, 12 Feb 2025 16:05:37 +0530 Message-Id: <20250212103537.26352-19-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: O7JOO3ZYF7VNE5OR5HQOBSJB66B7SF7X X-Message-ID-Hash: O7JOO3ZYF7VNE5OR5HQOBSJB66B7SF7X 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: 1739357375365019000 Content-Type: text/plain; charset="utf-8" Update "attach_disk" to support new option: throttle-groups to form filter chain in QEMU for specific disk 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)