On 08/24/2016 12:09 PM, Vasiliy Tolstov wrote:
IP and routes assigenment incorrectly placed on device stop.
This is fixing it, also change device state according to xml.
Note that as i know in linux routes can't be created on device that does
not up.
Signed-off-by: Vasiliy Tolstov <v.tolstov@xxxxxxxxx>
---
src/qemu/qemu_interface.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index e637d21fb77a..f80feff2d545 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -108,8 +108,25 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
break;
}
- case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ switch (dev->linkstate) {
+ case VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP:
+ case VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT:
+ if ((ret = virNetDevSetOnline(dev->ifname, true)) < 0)
+ goto cleanup;
+ break;
+
+ case VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN:
+ if ((ret = virNetDevSetOnline(dev->ifname, false)) < 0)
+ goto cleanup;
+ break;
+ }
The Online/Offline handling of the tap device for ethernet devices
should be identical to that used for network/bridge network devices. If
something is necessary (and it may be), it should be in a separate patch.
(Note that macvtap devices are set online in this function because
they're artificially kept offline when the macvtap device is created -->
this is necessary because the macvtap and guest interface use the same
MAC address, and setting it online early could cause unwanted traffic
with that MAC address, thus prematurely directing traffic for the MAC
address to this host. See this BZ for more details:
https://bugzilla.redhat.com/show_bug.cgi?id=1113474
+ if (virNetDevIPInfoAddToDev(net->ifname, &net->hostIP) < 0)
+ goto cleanup;
ACK to moving this.
+
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
@@ -197,10 +214,6 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
}
case VIR_DOMAIN_NET_TYPE_ETHERNET:
- if (virNetDevIPInfoAddToDev(net->ifname, &net->hostIP) < 0)
- goto cleanup;
- break;
-
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
case VIR_DOMAIN_NET_TYPE_SERVER:
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list