From nobody Thu May 2 14:02:59 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 1494887131537333.8583026642543;
Mon, 15 May 2017 15:25:31 -0700 (PDT)
Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com
[10.5.11.11])
(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id CCC3C80C05;
Mon, 15 May 2017 22:25:23 +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 7025B19CAA;
Mon, 15 May 2017 22:25:23 +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 9B806180BAF7;
Mon, 15 May 2017 22:25:22 +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 v4FMOBPd020519 for ;
Mon, 15 May 2017 18:24:11 -0400
Received: by smtp.corp.redhat.com (Postfix)
id E17D58F2BE; Mon, 15 May 2017 22:24:10 +0000 (UTC)
Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com
[10.5.110.27])
by smtp.corp.redhat.com (Postfix) with ESMTPS id DC0878A231
for ; Mon, 15 May 2017 22:24:09 +0000 (UTC)
Received: from swiftbird.org (92-255-100-1.customer.comfortel.pro
[92.255.100.1])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by mx1.redhat.com (Postfix) with ESMTPS id 3A9EA80F9F
for ; Mon, 15 May 2017 22:23:56 +0000 (UTC)
Received: from vtolstov by swiftbird.org with local (Exim 4.87)
(envelope-from ) id 1dAOHX-0001I3-S6
for libvir-list@redhat.com; Tue, 16 May 2017 01:15:59 +0300
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CCC3C80C05
Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com;
dmarc=none (p=none dis=none) header.from=selfip.ru
Authentication-Results: ext-mx02.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 CCC3C80C05
DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3A9EA80F9F
Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com;
dmarc=none (p=none dis=none) header.from=selfip.ru
Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com;
spf=none smtp.mailfrom=vtolstov@swiftbird.org
DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3A9EA80F9F
From: Vasiliy Tolstov
To: libvir-list@redhat.com
Date: Tue, 16 May 2017 01:15:59 +0300
Message-Id: <20170515221559.4846-2-v.tolstov@selfip.ru>
In-Reply-To: <20170515221559.4846-1-v.tolstov@selfip.ru>
References: <20170515221559.4846-1-v.tolstov@selfip.ru>
X-Greylist: Delayed for 00:07:53 by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.27]); Mon, 15 May 2017 22:23:57 +0000 (UTC)
X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com
[10.5.110.27]);
Mon, 15 May 2017 22:23:57 +0000 (UTC) for IP:'92.255.100.1'
DOMAIN:'92-255-100-1.customer.comfortel.pro'
HELO:'swiftbird.org' FROM:'vtolstov@swiftbird.org' RCPT:''
X-RedHat-Spam-Score: 4.683 **** (BAYES_99, BAYES_999,
HEADER_FROM_DIFFERENT_DOMAINS,
RDNS_DYNAMIC) 92.255.100.1 92-255-100-1.customer.comfortel.pro
92.255.100.1 92-255-100-1.customer.comfortel.pro
X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14
X-loop: libvir-list@redhat.com
Subject: [libvirt] [PATCH] qemu: allow to control host side link status of
network device
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.11
X-Greylist: Sender IP whitelisted,
not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]);
Mon, 15 May 2017 22:25:30 +0000 (UTC)
X-ZohoMail: RSF_0 Z_629925259 SPT_0
Content-Type: text/plain; charset="utf-8"
Signed-off-by: Vasiliy Tolstov
---
docs/formatdomain.html.in | 21 +++++++++++++++++++++
docs/schemas/domaincommon.rng | 11 +++++++++++
src/conf/domain_conf.c | 28 ++++++++++++++++++++++++++++
src/conf/domain_conf.h | 1 +
src/qemu/qemu_hotplug.c | 17 +++++++++++++++++
src/qemu/qemu_interface.c | 8 ++++----
6 files changed, 82 insertions(+), 4 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8c884f4af9cb..dd8e6a4afa99 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5421,6 +5421,27 @@ qemu-kvm -net nic,model=3D? /dev/null
Since 0.9.5
=20
+
+
+...
+<devices>
+ <interface type=3D'ethernet'>
+ <source>
+ <link state=3D'down'/>
+ <target dev=3D'vnet0'/>
+ </interface>
+</devices>
+...
+
+
+ This element provides means of setting state of the phisical network=
interface.
+ Possible values for attribute state
are up
=
and
+ down
. If down
is specified as the value, t=
he interface
+ put in down state. Default behavior if this element is unspecified i=
s to have the
+ link state up
.
+ Since 3.3.2
+
+
...
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 281309ec09da..89213d63b6e9 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2798,6 +2798,17 @@
All ip-related info for either the host or guest side of an interface
-->
+
+
+
+
+ up
+ down
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0ff216e3a373..b7398276af57 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9606,6 +9606,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
char *devaddr =3D NULL;
char *mode =3D NULL;
char *linkstate =3D NULL;
+ char *hostlinkstate =3D NULL;
char *addrtype =3D NULL;
char *domain_name =3D NULL;
char *vhostuser_mode =3D NULL;
@@ -9654,6 +9655,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainNetIPInfoParseXML(_("interface host IP"),
ctxt, &def->hostIP) < 0)
goto error;
+
+ if (!hostlinkstate)
+ hostlinkstate =3D virXPathString("string(./link/@st=
ate)", ctxt);
+
ctxt->node =3D tmpnode;
}
if (!macaddr && xmlStrEqual(cur->name, BAD_CAST "mac")) {
@@ -10303,6 +10308,16 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo=
pt,
}
}
=20
+ def->hostlinkstate =3D VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT;
+ if (hostlinkstate !=3D NULL) {
+ if ((def->hostlinkstate =3D virDomainNetInterfaceLinkStateTypeFrom=
String(hostlinkstate)) <=3D 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown interface link state '%s'"),
+ hostlinkstate);
+ goto error;
+ }
+ }
+
if (filter !=3D NULL) {
switch (def->type) {
case VIR_DOMAIN_NET_TYPE_ETHERNET:
@@ -10371,6 +10386,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop=
t,
VIR_FREE(devaddr);
VIR_FREE(mode);
VIR_FREE(linkstate);
+ VIR_FREE(hostlinkstate);
VIR_FREE(addrtype);
VIR_FREE(domain_name);
VIR_FREE(trustGuestRxFilters);
@@ -22113,6 +22129,18 @@ virDomainNetDefFormat(virBufferPtr buf,
break;
}
=20
+ if (def->hostlinkstate) {
+ if (sourceLines =3D=3D 0) {
+ virBufferAddLit(buf, "\n");
+ sourceLines +=3D 2;
+ }
+ virBufferAdjustIndent(buf, 2);
+ virBufferAsprintf(buf, " \n",
+ virDomainNetInterfaceLinkStateTypeToString(def->hostli=
nkstate));
+ virBufferAdjustIndent(buf, -2);
+ sourceLines +=3D 2;
+ }
+
/* if sourceLines =3D=3D 0 - no info at all so far
* sourceLines =3D=3D 1 - first line written, no terminating ">"
* sourceLines > 1 - multiple lines, including subelements
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 09fb7aada4b2..71e12a30c2c1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1037,6 +1037,7 @@ struct _virDomainNetDef {
virNetDevVlan vlan;
int trustGuestRxFilters; /* enum virTristateBool */
int linkstate;
+ int hostlinkstate;
unsigned int mtu;
virNetDevCoalescePtr coalesce;
};
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index e8d29186eb32..7fc41b28d9f8 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2978,6 +2978,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
bool needBridgeChange =3D false;
bool needFilterChange =3D false;
bool needLinkStateChange =3D false;
+ bool needHostLinkStateChange =3D false;
bool needReplaceDevDef =3D false;
bool needBandwidthSet =3D false;
int ret =3D -1;
@@ -3264,6 +3265,9 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
if (olddev->linkstate !=3D newdev->linkstate)
needLinkStateChange =3D true;
=20
+ if (olddev->hostlinkstate !=3D newdev->hostlinkstate)
+ needHostLinkStateChange =3D true;
+
if (!virNetDevBandwidthEqual(virDomainNetGetActualBandwidth(olddev),
virDomainNetGetActualBandwidth(newdev)))
needBandwidthSet =3D true;
@@ -3308,6 +3312,19 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
goto cleanup;
}
=20
+ if (needHostLinkStateChange) {
+ if (newdev->hostlinkstate =3D=3D VIR_DOMAIN_NET_INTERFACE_LINK_STA=
TE_DOWN) {
+ if (virNetDevSetOnline(newdev->ifname, false) < 0)
+ goto cleanup;
+ } else {
+ if (virNetDevSetOnline(newdev->ifname, true) < 0)
+ goto cleanup;
+ if (virNetDevIPInfoAddToDev(newdev->ifname, &newdev->hostIP) <=
0)
+ goto cleanup;
+ }
+ needReplaceDevDef =3D true;
+ }
+
if (needReplaceDevDef) {
/* the changes above warrant replacing olddev with newdev in
* the domain's nets list.
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index d8a678b4ab13..f3afbdae4009 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -413,7 +413,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
{
virMacAddr tapmac;
int ret =3D -1;
- unsigned int tap_create_flags =3D VIR_NETDEV_TAP_CREATE_IFUP;
+ unsigned int tap_create_flags =3D 0;
bool template_ifname =3D false;
virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver);
const char *tunpath =3D "/dev/net/tun";
@@ -427,6 +427,9 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
}
}
=20
+ if (net->hostlinkstate !=3D VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN)
+ tap_create_flags |=3D VIR_NETDEV_TAP_CREATE_IFUP;
+
if (!net->ifname ||
STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
strchr(net->ifname, '%')) {
@@ -453,9 +456,6 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
if (virNetDevSetMAC(net->ifname, &tapmac) < 0)
goto cleanup;
=20
- if (virNetDevSetOnline(net->ifname, true) < 0)
- goto cleanup;
-
if (net->script &&
virNetDevRunEthernetScript(net->ifname, net->script) < 0)
goto cleanup;
--=20
2.9.3
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list