]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virnetdevtap.c: Disallow pre-existing TAP devices
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 8 Dec 2022 14:35:36 +0000 (15:35 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 9 Dec 2022 07:46:39 +0000 (08:46 +0100)
commita2ae3d299cf9c5ada8aa42ec4271748eb479dc27
treeefecdfe1e7f97920383d58cf9030d30810604959
parent6cbbc71e0dcf94da616860ef6d76424cc82540e3
virnetdevtap.c: Disallow pre-existing TAP devices

When starting a guest with <interface/> which has the target
device name set (i.e. not generated by us), it may happen that
the TAP device already exists. This then may lead to all sorts of
problems. For instance: for <interface type='network'/> the TAP
device is plugged into the network's bridge, but since the TAP
device is persistent it remains plugged there even after the
guest is shut off. We don't have a code that unplugs TAP devices
from the bridge because TAP devices we create are transient, i.e.
are removed automatically when QEMU closes their FD.

The only exception is <interface type='ethernet'/> with <target
managed='no'/> where we specifically want to let users use
pre-created TAP device and basically not touch it at all.

There's another reason for denying to use a pre-created TAP
devices: if we ever have bug in TAP name generation, we may
re-use a TAP device from another domain.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2144738
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/qemu/qemu_interface.c
src/util/virnetdevtap.c
src/util/virnetdevtap.h