From nobody Sun Apr 28 08:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531649452277561.7439571480259; Sun, 15 Jul 2018 03:10:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94DB23082126; Sun, 15 Jul 2018 10:10:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09A3C100190D; Sun, 15 Jul 2018 10:10:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 872E218037F1; Sun, 15 Jul 2018 10:10:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6FAAJQu004531 for ; Sun, 15 Jul 2018 06:10:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id E009E111CD5B; Sun, 15 Jul 2018 10:10:18 +0000 (UTC) Received: from hansolo.redhat.com (ovpn-12-65.pek2.redhat.com [10.72.12.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88276111CD32; Sun, 15 Jul 2018 10:10:17 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Sun, 15 Jul 2018 18:08:16 +0800 Message-Id: <20180715100817.31003-2-hhan@redhat.com> In-Reply-To: <20180715100817.31003-1-hhan@redhat.com> References: <20180715100817.31003-1-hhan@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v2 1/2] virsh: Support alias in attach-disk X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 15 Jul 2018 10:10:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add --alias to support custom disk alias in virsh attach-disk. Report error if custom alias doesn't start with 'ua-'. Signed-off-by: Han Han --- tools/virsh-domain.c | 15 ++++++++++++++- tools/virsh.pod | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8adec1d9b1..467417852e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -290,6 +290,10 @@ static const vshCmdOptDef opts_attach_disk[] =3D { .type =3D VSH_OT_STRING, .help =3D N_("wwn of disk device") }, + {.name =3D "alias", + .type =3D VSH_OT_STRING, + .help =3D N_("custom alias name of disk device") + }, {.name =3D "rawio", .type =3D VSH_OT_BOOL, .help =3D N_("needs rawio capability") @@ -574,7 +578,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) *subdriver =3D NULL, *type =3D NULL, *mode =3D NULL, *iothread =3D NULL, *cache =3D NULL, *io =3D NULL, *serial =3D NULL, *straddr =3D NULL, *wwn =3D NULL, - *targetbus =3D NULL; + *targetbus =3D NULL, *alias =3D NULL; struct DiskAddress diskAddr; bool isFile =3D false, functionReturn =3D false; int ret; @@ -611,6 +615,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "wwn", &wwn) < 0 || vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 || vshCommandOptStringReq(ctl, cmd, "targetbus", &targetbus) < 0 || + vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0) goto cleanup; =20 @@ -680,6 +685,14 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) if (serial) virBufferAsprintf(&buf, "%s\n", serial); =20 + if (alias) { + if (!STRPREFIX(alias, "ua-")) { + vshError(ctl, _("Custom alias name should start with ua-")); + goto cleanup; + } + virBufferAsprintf(&buf, "", alias); + } + if (wwn) virBufferAsprintf(&buf, "%s\n", wwn); =20 diff --git a/tools/virsh.pod b/tools/virsh.pod index 771e99591e..4f0d12225a 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3027,7 +3027,7 @@ expected. =3Ditem B I I I [[[I<--live>] [I<--co= nfig>] | [I<--current>]] | [I<--persistent>]] [I<--targetbus bus>] [I<--driver driver>] [I<--subdriver subdriver>] [I<--iothread iothread>] -[I<--cache cache>] [I<--io io>] [I<--type type>] +[I<--cache cache>] [I<--io io>] [I<--type type>] [I<--alias alias>] [I<--mode mode>] [I<--sourcetype sourcetype>] [I<--serial serial>] [I<--wwn wwn>] [I<--rawio>] [I<--address address>] [I<--multifunction>] [I<--print-= xml>] =20 @@ -3050,6 +3050,7 @@ disk formats. I can indicate I, I = or I as alternative to the disk default, although this use only replaces the media within the existing virtual cdrom or floppy device; consider using B for this usage instead. +I can set user supplied alias. It should start with 'ua-'. I can specify the two specific mode I or I. I can indicate the type of source (block|file) I can be one of "default", "none", "writethrough", "writeback", --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 08:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531649458727840.7532627218271; Sun, 15 Jul 2018 03:10:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39DB330E6840; Sun, 15 Jul 2018 10:10:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECDD8608EF; Sun, 15 Jul 2018 10:10:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A439C4A460; Sun, 15 Jul 2018 10:10:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6FAALbm004544 for ; Sun, 15 Jul 2018 06:10:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF637111CD5B; Sun, 15 Jul 2018 10:10:20 +0000 (UTC) Received: from hansolo.redhat.com (ovpn-12-65.pek2.redhat.com [10.72.12.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93B77111CD32; Sun, 15 Jul 2018 10:10:19 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Sun, 15 Jul 2018 18:08:17 +0800 Message-Id: <20180715100817.31003-3-hhan@redhat.com> In-Reply-To: <20180715100817.31003-1-hhan@redhat.com> References: <20180715100817.31003-1-hhan@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v2 2/2] virsh: Support alias in attach-interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 15 Jul 2018 10:10:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add --alias to support custom alias in virsh attach-interface. Report error if custom alias doesn't start with 'ua-'. Signed-off-by: Han Han --- tools/virsh-domain.c | 15 ++++++++++++++- tools/virsh.pod | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 467417852e..7fb419f6b5 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -842,6 +842,10 @@ static const vshCmdOptDef opts_attach_interface[] =3D { .type =3D VSH_OT_STRING, .help =3D N_("model type") }, + {.name =3D "alias", + .type =3D VSH_OT_STRING, + .help =3D N_("custom alias name of interface device") + }, {.name =3D "inbound", .type =3D VSH_OT_STRING, .help =3D N_("control domain's incoming traffics") @@ -915,7 +919,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom =3D NULL; const char *mac =3D NULL, *target =3D NULL, *script =3D NULL, *type =3D NULL, *source =3D NULL, *model =3D NULL, - *inboundStr =3D NULL, *outboundStr =3D NULL; + *inboundStr =3D NULL, *outboundStr =3D NULL, *alias =3D NUL= L; virNetDevBandwidthRate inbound, outbound; virDomainNetType typ; int ret; @@ -945,6 +949,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0 || vshCommandOptStringReq(ctl, cmd, "script", &script) < 0 || vshCommandOptStringReq(ctl, cmd, "model", &model) < 0 || + vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || vshCommandOptStringReq(ctl, cmd, "inbound", &inboundStr) < 0 || vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0) goto cleanup; @@ -1042,6 +1047,14 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cm= d) if (model !=3D NULL) virBufferAsprintf(&buf, "\n", model); =20 + if (alias !=3D NULL) { + if (!STRPREFIX(alias, "ua-")) { + vshError(ctl, _("Custom alias name should start with ua-")); + goto cleanup; + } + virBufferAsprintf(&buf, "\n", alias); + } + if (inboundStr || outboundStr) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); diff --git a/tools/virsh.pod b/tools/virsh.pod index 4f0d12225a..4af21462e9 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3085,7 +3085,7 @@ Likewise, I<--shareable> is an alias for I<--mode sha= reable>. [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] [I<--target target>] [I<--mac mac>] [I<--script script>] [I<--model model>] [I<--inbound average,peak,burst,floor>] [I<--outbound average,peak,burst>] -[I<--managed>] [I<--print-xml>] +[I<--alias alias>] [I<--managed>] [I<--print-xml>] =20 Attach a new network interface to the domain. =20 @@ -3139,6 +3139,8 @@ I type and only for Xen domains. B<--model> specifies the network device model to be presented to the domain. =20 +B can set user supplied alias. It should start with 'ua-'. + B<--inbound> and B<--outbound> control the bandwidth of the interface. At least one from the I, I pair must be specified. The other two I and I are optional, so --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list