From nobody Sat Jan 4 23:04:50 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 173375121045869.92024443938215; Mon, 9 Dec 2024 05:33:30 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2E10F13E6; Mon, 9 Dec 2024 08:33:26 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A699513CC; Mon, 9 Dec 2024 08:20:29 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 54FA911C7; Mon, 9 Dec 2024 07:43:02 -0500 (EST) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 913C511C9 for ; Mon, 9 Dec 2024 07:43:01 -0500 (EST) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2164b1f05caso8425765ad.3 for ; Mon, 09 Dec 2024 04:43:01 -0800 (PST) Received: from localhost.localdomain ([120.60.110.156]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2164d103993sm18113195ad.193.2024.12.09.04.42.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Dec 2024 04:42:59 -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.6 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=1733748180; x=1734352980; 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=q79zxuVWsUxyyDg4vlNaynN02mcIxG4tGlmsDt0lOjw=; b=fRCFrpq+3UxSWwhIj6+u6Vd4UEpGFcBvmZRspfyk6HwmMTj6GLeBlAGdySGvBbgyDW RYK2gFGVnAk/ITSdfQiRRjZyJCd8BmIGHARLohl2hU/wN1zRXbDDLQBB4z07lqbVMyTZ 6oWDo8MsTUkDNvpH2OgACTF6RO28TVxR4f6a7QWrSNY0+2/bsSgrjPsVsHI/1v7ZmUD5 LvnYjUxXaaB1j6S4/i7yscIMowllE4CpfONIQAhAdBBzs1EDCHEJNVg8cTmTdXib/aV9 TiZKh/MDBcKAI0HDKuim4Bmj67bmDcymhglUiM61MeWX5qo/dovptfqhSnjaPOLfolK2 96/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733748180; x=1734352980; 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=q79zxuVWsUxyyDg4vlNaynN02mcIxG4tGlmsDt0lOjw=; b=jUPjS5T5rjEoxtGhbGEDPHVYPEFYYC+6lME2SHAsSp0mBKEDGDJtVcpY/fcxVys3gA HyRm4klI7VJgBINtH/ybRRmwXa0tTlk+VknwANrTsKFr7YcPqjRuGWb9ocaRZqiUkchr 9nTFqALzqXx3ozGhM90sCrT0UTuvnmB5Vfwa4WqPKstEBJhqGBqSyfu7qkRrwkRtRpbm TaHfMKAipNIQwWfNR1OKcnRK+ZZzKHyvF730st3QIGglSB+3bIfukXiufyYxdWhqOvqs CDjvsoGSI2pwu8NYCJdMtpK3t8nqUM0b73HL0MTpxoBqZHrcI+no5hmYQM7b4zW89D9B YIIQ== X-Gm-Message-State: AOJu0YxPNCKFoA+heuXzw0DcVQM5IvQogflFxiBzj+a8NVICMbLNAxss zg84HVRdLzo1E3thllYgB1yU2at4gIMnJ/n1qaf9GBfan/v+/V5d6T3neeoq X-Gm-Gg: ASbGnctWj854Vs+XwI8IuJl9Mc4X8ZbJHvI94prUns9cmua9zfxl0/2Fi/lEY+sVxiL TbfH2yNpyTCa79n9Fu1eE8QXaFZ8/iiuyTV1nI+4dSzBW6In5SmEcCwJornE/ZWAcKMmKEGz+J9 RM1uqObyiwAqskpMrdUgca1FZshiUSPvMuBGbV4waZjxZ8KUj0M/CqGegsmwBuxrOdRR20XoE+r eHYx99XWVkOd+JUH+hQuX7MRtIjdjWCdn8ZpvSFx9qklx2PZFVqemhEmxcdYqa8vROh/3okEHSA e88v9Q== X-Google-Smtp-Source: AGHT+IFKBByQNUmvt78nc36G/1ROX4/NcttLboRGkpMGDp+wSjOS81CuXCBO2TtwecIJcT1/mnYwgw== X-Received: by 2002:a17:902:e546:b0:216:393b:23c9 with SMTP id d9443c01a7336-216393b29c5mr98043595ad.29.1733748179688; Mon, 09 Dec 2024 04:42:59 -0800 (PST) From: Harikumar R To: devel@lists.libvirt.org Subject: [PATCH v6 17/18] virsh: Add option "throttle-groups" to "attach_disk" Date: Mon, 9 Dec 2024 18:11:17 +0530 Message-Id: <20241209124118.39471-18-harirajkumar230@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20241209124118.39471-1-harirajkumar230@gmail.com> References: <20241209124118.39471-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: FJSDAT6QWFRRLHXUIVMDYOYFUMLMVFFT X-Message-ID-Hash: FJSDAT6QWFRRLHXUIVMDYOYFUMLMVFFT X-Mailman-Approved-At: Mon, 09 Dec 2024 13:19:48 -0500 CC: earulana@in.ibm.com, sanjeev.ranjan@ibm.com, harikumar.rajkumar@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: 1733751211815116600 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 c1ed028844..bb0dda6cc6 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -5007,7 +5007,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* @@ -5047,6 +5047,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)