From nobody Sat Feb 7 09:36:41 2026 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 153163728229151.166208843773006; Sat, 14 Jul 2018 23:48:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E28A13A8F; Sun, 15 Jul 2018 06:48:00 +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 9AC995C25C; Sun, 15 Jul 2018 06:47:59 +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 749194A460; Sun, 15 Jul 2018 06:47:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6F6luvL005381 for ; Sun, 15 Jul 2018 02:47:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E5722026E18; Sun, 15 Jul 2018 06:47:56 +0000 (UTC) Received: from hansolo.redhat.com (ovpn-12-29.pek2.redhat.com [10.72.12.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99FEE2026D66; Sun, 15 Jul 2018 06:47:54 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Sun, 15 Jul 2018 14:47:00 +0800 Message-Id: <20180715064700.2823-3-hhan@redhat.com> In-Reply-To: <20180715064700.2823-1-hhan@redhat.com> References: <20180715064700.2823-1-hhan@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 15 Jul 2018 06:48:00 +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..66b7cea353 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 NULL; 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