From nobody Sat May 4 23:51: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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1493112726829655.8938403824537; Tue, 25 Apr 2017 02:32:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A3F823E6C7; Tue, 25 Apr 2017 09:32:03 +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 481087E384; Tue, 25 Apr 2017 09:32:02 +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 1C6F518523CD; Tue, 25 Apr 2017 09:31:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3P9Vvdk020122 for ; Tue, 25 Apr 2017 05:31:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id CB9FA80789; Tue, 25 Apr 2017 09:31:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2B2B81067 for ; Tue, 25 Apr 2017 09:31:51 +0000 (UTC) Received: from out1.zte.com.cn (out1.zte.com.cn [202.103.147.172]) by mx1.redhat.com (Postfix) with ESMTP id 18603369C4 for ; Tue, 25 Apr 2017 09:31:47 +0000 (UTC) Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 25 Apr 2017 09:06:23 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v3P9EV5r092361 for ; Tue, 25 Apr 2017 17:14:31 +0800 (GMT-8) (envelope-from lu.zhipeng@zte.com.cn) Received: from ceshi.localdomain ([10.74.120.130]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017042517143423-1252909 ; Tue, 25 Apr 2017 17:14:34 +0800 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0A3F823E6C7 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0A3F823E6C7 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18603369C4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=zte.com.cn Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=lu.zhipeng@zte.com.cn DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 18603369C4 X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170425170623 From: ZhiPeng Lu To: libvir-list@redhat.com Date: Tue, 25 Apr 2017 17:13:59 +0800 Message-Id: <1493111639-3055-1-git-send-email-lu.zhipeng@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-25 17:14:34, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-04-25 17:14:15, Serialize complete at 2017-04-25 17:14:15 X-MAIL: mse01.zte.com.cn v3P9EV5r092361 X-HQIP: 127.0.0.1 X-Greylist: Delayed for 00:13:47 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 25 Apr 2017 09:31:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 25 Apr 2017 09:31:50 +0000 (UTC) for IP:'202.103.147.172' DOMAIN:'out1.zte.com.cn' HELO:'out1.zte.com.cn' FROM:'lu.zhipeng@zte.com.cn' RCPT:'' X-RedHat-Spam-Score: 0.398 (BAYES_50, DCC_REPUT_00_12, RP_MATCHES_RCVD, SPF_PASS) 202.103.147.172 out1.zte.com.cn 202.103.147.172 out1.zte.com.cn X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: ZhiPeng Lu Subject: [libvirt] [PATCH] virsh-domain: update attach-interface to support bridge type 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 25 Apr 2017 09:32:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Adding this feature will allow users to attach a network to linux bridge or openvswitch. The interface can be attached using --brtype=3Dlinux or --brtype=3Dopenvswitch. If --brtype is not set, the network is attached to linux bridge. Signed-off-by: ZhiPeng Lu --- tools/virsh-domain.c | 23 +++++++++++++++++++++-- tools/virsh.pod | 3 +++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index db8accf..2690689 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -766,6 +766,10 @@ static const vshCmdOptDef opts_attach_interface[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("libvirt will automatically detach/attach the device fro= m/to host") }, + {.name =3D "brtype", + .type =3D VSH_OT_STRING, + .help =3D N_("Bridge type: linux / openvswitch") + }, {.name =3D NULL} }; =20 @@ -819,7 +823,8 @@ 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, + *brtype =3D NULL; virNetDevBandwidthRate inbound, outbound; virDomainNetType typ; int ret; @@ -850,7 +855,8 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "script", &script) < 0 || vshCommandOptStringReq(ctl, cmd, "model", &model) < 0 || vshCommandOptStringReq(ctl, cmd, "inbound", &inboundStr) < 0 || - vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0) + vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0 || + vshCommandOptStringReq(ctl, cmd, "brtype", &brtype) < 0) goto cleanup; =20 /* check interface type */ @@ -946,6 +952,19 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) if (model !=3D NULL) virBufferAsprintf(&buf, "\n", model); =20 + if ((brtype !=3D NULL)) { + if (STRNEQ(brtype , "linux") && STRNEQ(brtype , "openvswitch")) { + vshError(ctl, _("bridge type is incorrect, should be linux " + "or openvswitch")); + goto cleanup; + } + if (typ !=3D VIR_DOMAIN_NET_TYPE_BRIDGE) { + vshError(ctl, _("No support for %s with bridge type"), type); + goto cleanup; + } + if (STREQ(brtype , "openvswitch")) + virBufferAsprintf(&buf, " = \n"); + } if (inboundStr || outboundStr) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); diff --git a/tools/virsh.pod b/tools/virsh.pod index e16f62f..3cd0490 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2935,6 +2935,9 @@ B<--managed> is usable only for I type and t= ells libvirt that the interface should be managed, which means detached and reattached from/to the host by libvirt. =20 +B<--brtype> is usable only for I type and tells libvirt +that the interface attached to bridge type (linux bridge or openvswitch). + If B<--print-xml> is specified, then the XML of the interface that would be attached is printed instead. =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list