[libvirt] [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/util/virnetdevveth.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 6905168..c8a38fb 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -225,5 +225,8 @@ int virNetDevVethDelete(const char *veth) ret = 0; cleanup: virCommandFree(cmd); + /* Make sure the device is properly down: creating a new one + * with the same name could lead to troubles */ + virFileWaitForDevices(); return ret; } -- 2.1.4

On 26.11.2015 09:15, Cédric Bosdonnat wrote:
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/util/virnetdevveth.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 6905168..c8a38fb 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -225,5 +225,8 @@ int virNetDevVethDelete(const char *veth) ret = 0; cleanup: virCommandFree(cmd); + /* Make sure the device is properly down: creating a new one + * with the same name could lead to troubles */ + virFileWaitForDevices(); return ret; }
I'm not fully convinced this is right approach. I mean, we do create plenty of devices here and there and tear them down. How come this is the only place causing trouble? Then, this function you are patching is called in a loop in couple of places. Wouldn't it be better to wait for udev after the loop and not in it? Michal

On Thu, Nov 26, 2015 at 04:01:31PM +0100, Michal Privoznik wrote:
On 26.11.2015 09:15, Cédric Bosdonnat wrote:
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/util/virnetdevveth.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 6905168..c8a38fb 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -225,5 +225,8 @@ int virNetDevVethDelete(const char *veth) ret = 0; cleanup: virCommandFree(cmd); + /* Make sure the device is properly down: creating a new one + * with the same name could lead to troubles */ + virFileWaitForDevices(); return ret; }
I'm not fully convinced this is right approach. I mean, we do create plenty of devices here and there and tear them down. How come this is the only place causing trouble? Then, this function you are patching is called in a loop in couple of places. Wouldn't it be better to wait for udev after the loop and not in it?
Yeah, calling udev settle in a loop is not going to be very attractive from a performance POV. I'd really rather the udev rules were fixed to skip the veth devices 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 (3)
-
Cédric Bosdonnat
-
Daniel P. Berrange
-
Michal Privoznik