]> xenbits.xensource.com Git - libvirt.git/commit
udevHandleOneDevice: Remove old instance of device on "move"
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 20 Apr 2020 14:12:03 +0000 (16:12 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 22 Apr 2020 10:51:15 +0000 (12:51 +0200)
commit9a13704818e4a018723e0ec5b9e97b176f1c8584
tree6593835c73a0101fee19dbee43bef34a76919a91
parentbfa8cf4b299086719bc644fcb70f24793b5eb49a
udevHandleOneDevice: Remove old instance of device on "move"

When a device is "move"-d (this basically means it was renamed),
we add the new device onto our list but keep the old there too.
Fortunately, udev sets this DEVPATH_OLD property which points to
the old device path. We can use it to remove the old instance.

To test this try renaming an interface, for instance:

  # ip link set tunl0 name tunl1
  # ip link set tunl1 name tunl0

One problem with udev is that it sends old ifname in INTERFACE
property, which creates a problem for us, the property is where
we get the ifname from and use it then to query all kind of info
about the interface. Well, if it is non-existent then we can't
query anything. This happens if ifname rename is suppressed
(net.ifnames=0 on kernel cmd line for instance). Fortunately, we
can use "kernel" source for udev events which has always the
fresh info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/node_device/node_device_udev.c