From 3bff82b57564ffc1fe4fff23f9d121fcf410dd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= Date: Wed, 25 Nov 2015 11:43:56 +0100 Subject: [PATCH] Wait for udev events to be handled after removing veth As per http://www.redhat.com/archives/libvir-list/2013-July/msg01279.html, wait for udev events to be handled after removing a virtual NIC. Any udev rule associated to NIC destroy could happen to run with a new device with the same name that is being created. --- src/lxc/lxc_controller.c | 1 + src/lxc/lxc_driver.c | 2 ++ src/lxc/lxc_process.c | 1 + 3 files changed, 4 insertions(+) Index: libvirt-8.0.0/src/lxc/lxc_controller.c =================================================================== --- libvirt-8.0.0.orig/src/lxc/lxc_controller.c +++ libvirt-8.0.0/src/lxc/lxc_controller.c @@ -2006,6 +2006,7 @@ static int virLXCControllerDeleteInterfa if (virNetDevVethDelete(ctrl->veths[i]) < 0) ret = -1; } + virWaitForDevices(); return ret; } Index: libvirt-8.0.0/src/lxc/lxc_driver.c =================================================================== --- libvirt-8.0.0.orig/src/lxc/lxc_driver.c +++ libvirt-8.0.0/src/lxc/lxc_driver.c @@ -67,6 +67,7 @@ #include "virtime.h" #include "virtypedparam.h" #include "viruri.h" +#include "virutil.h" #include "virstring.h" #include "viraccessapicheck.h" #include "viraccessapichecklxc.h" @@ -3508,6 +3509,7 @@ lxcDomainAttachDeviceNetLive(virLXCDrive case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_ETHERNET: ignore_value(virNetDevVethDelete(veth)); + virWaitForDevices(); break; case VIR_DOMAIN_NET_TYPE_DIRECT: @@ -3947,6 +3949,7 @@ lxcDomainDetachDeviceNetLive(virDomainOb virDomainAuditNet(vm, detach, NULL, "detach", false); goto cleanup; } + virWaitForDevices(); break; /* It'd be nice to support this, but with macvlan Index: libvirt-8.0.0/src/lxc/lxc_process.c =================================================================== --- libvirt-8.0.0.orig/src/lxc/lxc_process.c +++ libvirt-8.0.0/src/lxc/lxc_process.c @@ -51,6 +51,7 @@ #include "virstring.h" #include "virprocess.h" #include "virsystemd.h" +#include "virutil.h" #include "netdev_bandwidth_conf.h" #include "virutil.h" @@ -249,6 +250,7 @@ static void virLXCProcessCleanup(virLXCD VIR_WARN("Unable to release network device '%s'", NULLSTR(iface->ifname)); } } + virWaitForDevices(); virDomainConfVMNWFilterTeardown(vm);