[libvirt] [PATCH] qemu: fix ip/route assigning on ethernet device

After investigation, i found that ips and routes incorrectly assigning on device deletion. Also after libvirt create tap device it does not up. Vasiliy Tolstov (1): qemu: fix ethernet network type ip/route assign src/qemu/qemu_interface.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) -- 2.7.4

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@selfip.ru> --- 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..5fc6441cbf99 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; + } + 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: 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: -- 2.7.4

On Wed, Aug 24, 2016 at 06:40:59PM +0300, 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@selfip.ru> --- 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..5fc6441cbf99 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; + } + if (virNetDevIPInfoAddToDev(net->ifname, &net->hostIP) < 0) + goto cleanup; + + break;
The indentation you have here is using tabs and looks totally mangled. Please make sure to always run 'make syntax-check' before submitting patches to catch things like this. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Vasiliy Tolstov