]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_interface: Fix managed='no' case when creating an ethernet interface
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Jan 2023 10:42:18 +0000 (11:42 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Jan 2023 11:29:12 +0000 (12:29 +0100)
In a recent commit of v9.0.0-rc1~192 I've tried to forbid case
where a TAP device already exists, but at the same time it's
managed by Libvirt (<interface type='ethernet'> <target
dev='tap0' managed='yes'/> </interface>). NB, if @managed
attribute is missing then it's assumed to be managed by Libvirt.

Anyway, I've mistakenly put setting of
VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING flag into managed='yes'
branch instead of managed='no' branch in
qemuInterfaceEthernetConnect().

Move the setting of the flag into the correct branch.

Fixes: a2ae3d299cf9c5ada8aa42ec4271748eb479dc27
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_interface.c

index b6895cedde8956d820588f6b92bd6c91f19f02f1..ed2c209167d70a8fa24863d4017889504ccd5bf3 100644 (file)
@@ -443,6 +443,9 @@ qemuInterfaceEthernetConnect(virDomainDef *def,
                            _("target managed='no' but specified dev doesn't exist"));
             goto cleanup;
         }
+
+        tap_create_flags |= VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING;
+
         if (virNetDevMacVLanIsMacvtap(net->ifname)) {
             auditdev = net->ifname;
             if (virNetDevMacVLanTapOpen(net->ifname, tapfd, tapfdSize) < 0)
@@ -461,8 +464,6 @@ qemuInterfaceEthernetConnect(virDomainDef *def,
         if (!net->ifname)
             template_ifname = true;
 
-        tap_create_flags |= VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING;
-
         if (virNetDevTapCreate(&net->ifname, tunpath, tapfd, tapfdSize,
                                tap_create_flags) < 0) {
             goto cleanup;