From nobody Thu Nov 21 17:33:19 2024 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 1731939808720620.0137249634874; Mon, 18 Nov 2024 06:23:28 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 80BC51AD1; Mon, 18 Nov 2024 09:23:27 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A19361C2F; Mon, 18 Nov 2024 09:10:57 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 74DF91A29; Mon, 18 Nov 2024 08:55:33 -0500 (EST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 AA14A19F5 for ; Mon, 18 Nov 2024 08:55:32 -0500 (EST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-211a4682fcaso27885635ad.2 for ; Mon, 18 Nov 2024 05:55:32 -0800 (PST) Received: from localhost.localdomain ([2409:40f4:9:7d39:e991:fcfb:15ab:ce58]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-72477135ecbsm6113482b3a.84.2024.11.18.05.55.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Nov 2024 05:55:30 -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.5 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_H2,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=1731938131; x=1732542931; 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=qhqPLSsaQ5HvutYpkOhyWJPUtm9V4erTS+GaMe9Kibk=; b=Y64UgYI/wa2lZyeXVxEWqlVUfMVE/9P7/QfQ0zBTlWXn7DUvcuqqfssbwzIRQj/GD5 c85dxjKYNUlVOFYsRrUYI0hZuE50C1ANMzsNd2/SEekqWif8Ruoo5v0ZAnJ34E81BMWw OLAe7/U+aFlbraonQASUwTpZ7WDroNEZDCIYDL5kq+TB/aFSaySerOIQZCiwVBu5oqUP GYl3yqW/xr/HD/JgjFl6lAQagp2O1dVwk7dXlNv0xo+I96THt8k0r67xuIt+AYv5gY/K ZRkGOQbEC1LAaQAYT2pWTF1wM2DNUC7LxgGduaNGCtxT07398JOQmL/Vg4K0R/4Pq7Uf O/MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731938131; x=1732542931; 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=qhqPLSsaQ5HvutYpkOhyWJPUtm9V4erTS+GaMe9Kibk=; b=UvX6G1GnWYUllAs7A+fDBg6/QRw2iK7MCquzhfkMpi8GVkSK1fkKQO9Ubwynlli5Ru JzHiM1VSZLlzNJTkhX7V9cHwlOTkua1FEhEQVQDhmb1INuAYcf2KnwOGwY5JYYhHN9xP T3kr9hHhc1ZsSvf1VhQMQdwU1+1A4X0OnWTvr3z6imJR2iA61/D1egCmd/KBsf4jdlOk c+kgoL3ziOgjUikHUlcS2oUY/dTFIQliHscRoRoRUHqpBPV2fuOYuD+CJJP0lY37Bx3r 8iLEX+DYcT8AoUBhotx8SfPXLwXKj3i568vMmADxvLxhLR0oM+m1TK6PbFLYaUbry75E gKKw== X-Gm-Message-State: AOJu0YzyTp9iNd3YGSieFTp+VSdayGxxq0fxXzQ1l5yVJgzn3h55Fcux OGLBppuNIuy6PU4U68qgvr0pGgbCfVVX/MWRs8UL/A2s0V5YlojFDzvQwJbh X-Google-Smtp-Source: AGHT+IHgaA+0cUVBIJiBsANM943F4ZmSEIMCzj1QsvOiVRPooCz3vj613SsFvMGlYau+qUWXd3wjJQ== X-Received: by 2002:a05:6a20:72a3:b0:1db:f022:8bac with SMTP id adf61e73a8af0-1dc90be17f9mr18654442637.29.1731938131198; Mon, 18 Nov 2024 05:55:31 -0800 (PST) From: Harikumar R To: devel@lists.libvirt.org Subject: [PATCH v5 17/18] virsh: Add option "throttle-groups" to "attach_disk" Date: Mon, 18 Nov 2024 19:24:25 +0530 Message-Id: <20241118135426.37643-18-harirajkumar230@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20241118135426.37643-1-harirajkumar230@gmail.com> References: <20241118135426.37643-1-harirajkumar230@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MailFrom: harirajkumar230@gmail.com X-Mailman-Rule-Hits: nonmember-moderation 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 Message-ID-Hash: JCANNMSNEYSDBI6MZBRWQPBJML2BTPZD X-Message-ID-Hash: JCANNMSNEYSDBI6MZBRWQPBJML2BTPZD X-Mailman-Approved-At: Mon, 18 Nov 2024 14:10:19 -0500 CC: harikumar.rajkumar@ibm.com, sanjeev.ranjan@ibm.com, earulana@in.ibm.com, Chun Feng Wu 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: 1731939809634116600 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 --- 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 3b78f77384..bc99c69dfb 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5001,7 +5001,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* @@ -5041,6 +5041,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 b7004979c6..7f0cf81501 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_autofree char **throttle_groups =3D NULL; int ret; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; const char *stype =3D NULL; @@ -622,6 +629,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) g_auto(virBuffer) sourceAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) sourceChildBuf =3D VIR_BUFFER_INIT_CHILD(&diskChildB= uf); g_auto(virBuffer) hostAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) throttleChildBuf =3D VIR_BUFFER_INITIALIZER; g_autofree char *xml =3D NULL; struct stat st; bool current =3D vshCommandOptBool(cmd, "current"); @@ -665,9 +673,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 +727,16 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) =20 virXMLFormatElement(&diskChildBuf, "driver", &driverAttrBuf, NULL); =20 + if (throttle_groups) { + 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)