libvirt/src/conf
Laine Stump 282d135ddb conf: properly clear out autogenerated macvtap names when formatting/parsing
Back when macvtap support was added in commit 315baab944 in Feb. 2010
(libvirt-0.7.7), it was setup to autogenerate a name for the device if
one wasn't supplied, in the pattern "macvtap%d" (or "macvlan%d"),
similar to the way an unspecified standard tap device name will lead
to an autogenerated "vnet%d".

As a matter of fact, in commit ca1b7cc8e4 added in May 2010, the code
was changed to *always* ignore a supplied device name for macvtap
interfaces by deleting *any* name immediately during the <interface>
parsing (this was intended to prevent one domain which had failed to
completely start from deleting the macvtap device of another domain
which had subsequently been provided the same device name (this will
seem mildly ironic later). This was later fixed to only clear the
device name when inactive XML was being parsed. HOWEVER - this was
only done if the xml was <interface type='direct'> - autogenerated
names were not cleared for <interface type='network'> (which could
also result in a macvtap device).

Although the names of "vnetX" tap devices had always been
automatically cleared when parsing <interface> (see commit d1304583d
from July 2008 (!)), at the time macvtap support was added, both vnetX
and macvtapX device names were always included when formatting the
XML.

Then in commit a8be259d0c (July 2011, libvirt-0.9.4), <interface>
formatting was changed to also clear out "vnetX" device names during
XML formatting as well. However the same treatment wasn't given to
"macvtapX".

Now in 2020, there has been a report that a failed migration leads to
the macvtap device of some other unrelated guest on the destination
host losing its network connectivity. It was determined that this was
due to the domain XML in the migration containing a macvtap device
name, e.g. "macvtap0", that was already in use by the other guest on
the destination. Normally this wouldn't be a problem, because libvirt
would see that the device was already in use, and then find a
different unused name. But in this case, other external problems were
causing the migration to fail prior to selecting a macvtap device and
successfully opening it, and during error recovery, qemuProcessStop()
was called, which went through all def->nets objects and (if they were
macvtap) deleted the device specified in net->ifname; since libvirt
hadn't gotten to the point of replacing the incoming "macvtap0" with
the name of a device it actually created for this guest, that meant
that "macvtap0" was deleted, *even though it was currently in use by a
different guest*!

Whew!

So, it turns out that when formatting "migratable" XML, "vnetX"
devices are omitted, just as when formatting "inactive" XML. By making
the code in both interface parsing and formatting consistent for
"vnetX", "macvtapX", and "macvlanX", we can thus make sure that the
autogenerated (and unneeded / completely *not* wanted) macvtap device
name will not be sent with the migration XML. This way when a
migration fails, net->ifname will be NULL, and libvirt won't have any
device to try and (erroneously) delete.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2020-08-24 23:49:16 -04:00
..
backup_conf.c backup: Allow configuring incremental backup per-disk individually 2020-07-08 08:40:30 +02:00
backup_conf.h backup: Allow configuring incremental backup per-disk individually 2020-07-08 08:40:30 +02:00
capabilities.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
capabilities.h Add a space before ending a comment 2020-01-30 12:32:03 +01:00
checkpoint_conf.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
checkpoint_conf.h conf: checkpoint: Add a flag storing whether disk 'size' is valid 2020-07-07 12:58:19 +02:00
cpu_conf.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
cpu_conf.h conf: Introduce migratable attribute for the <cpu> element 2020-06-09 20:32:50 +02:00
device_conf.c conf: use g_autofree for all pointers to virXMLPropString() in device_conf.c 2020-07-08 23:11:21 -04:00
device_conf.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
domain_addr.c conf: use g_auto() for all virBuffers 2020-07-08 16:34:17 -04:00
domain_addr.h qemu/conf: set HOTPLUGGABLE connect flag during PCI address set init 2020-04-12 22:39:51 -04:00
domain_audit.c conf, qemu, security, tests: introducing 'def->tpms' array 2020-06-23 17:27:50 +02:00
domain_audit.h
domain_capabilities.c Use g_strfeev instead of virStringFreeList 2020-08-03 15:37:36 +02:00
domain_capabilities.h conf: Advertise migratable attribute for CPU in domcaps 2020-06-09 20:32:50 +02:00
domain_conf.c conf: properly clear out autogenerated macvtap names when formatting/parsing 2020-08-24 23:49:16 -04:00
domain_conf.h conf: fix detection of available host CPUs for vcpupin 2020-08-08 11:07:02 +02:00
domain_event.c conf: remove NULL check from virDomainQemuMonitorEventNew 2019-11-21 12:44:23 +01:00
domain_event.h conf: remove NULL check from virDomainQemuMonitorEventNew 2019-11-21 12:44:23 +01:00
domain_nwfilter.c conf: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:56 +02:00
domain_nwfilter.h
interface_conf.c conf: use g_auto() for all virBuffers 2020-07-08 16:34:17 -04:00
interface_conf.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
meson.build meson: src: build libvirt.so library 2020-08-03 09:27:04 +02:00
moment_conf.c src: replace clock_gettime()/gettimeofday() with g_get_real_time() 2020-01-03 15:42:13 +00:00
moment_conf.h snapshot: Store both config and live XML in the snapshot domain 2019-09-11 13:09:45 +02:00
netdev_bandwidth_conf.c conf: do not pass vm object to virDomainClearNetBandwidth 2020-02-25 17:50:47 +01:00
netdev_bandwidth_conf.h conf: do not pass vm object to virDomainClearNetBandwidth 2020-02-25 17:50:47 +01:00
netdev_vlan_conf.c Use more of VIR_XPATH_NODE_AUTORESTORE 2020-06-03 21:06:02 +02:00
netdev_vlan_conf.h
netdev_vport_profile_conf.c conf: return a const from virDomainNetGetActualVirtPortProfile 2019-11-25 15:29:56 -05:00
netdev_vport_profile_conf.h conf: return a const from virDomainNetGetActualVirtPortProfile 2019-11-25 15:29:56 -05:00
network_conf.c treat all NULL returns from virXMLNodeContentString() as an error 2020-08-05 00:06:27 -04:00
network_conf.h conf: convert network_conf.c to use g_auto* pointers 2020-06-15 16:02:16 -04:00
network_event.c
network_event.h
networkcommon_conf.c Use more of VIR_XPATH_NODE_AUTORESTORE 2020-06-03 21:06:02 +02:00
networkcommon_conf.h
node_device_conf.c treat all NULL returns from virXMLNodeContentString() as an error 2020-08-05 00:06:27 -04:00
node_device_conf.h nodedev: store mdev UUID in mdev caps 2020-06-19 10:39:55 +02:00
node_device_event.c
node_device_event.h conf: node device: use #pragma once in headers 2019-06-13 17:05:09 +02:00
node_device_util.c virsh: include virutil.h where used 2020-02-24 23:15:50 +01:00
node_device_util.h conf: node device: use #pragma once in headers 2019-06-13 17:05:09 +02:00
numa_conf.c numa_conf: Properly check for caches in virDomainNumaDefValidate() 2020-08-19 10:21:59 +02:00
numa_conf.h numa: expose HMAT APIs 2020-07-08 12:05:24 +02:00
nwfilter_conf.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
nwfilter_conf.h conf: nwfilter: use #pragma once in headers 2019-06-13 17:05:09 +02:00
nwfilter_ipaddrmap.c conf: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:56 +02:00
nwfilter_ipaddrmap.h conf: nwfilter: use #pragma once in headers 2019-06-13 17:05:09 +02:00
nwfilter_params.c conf: Remove superfluous breaks 2020-07-21 15:53:15 +02:00
nwfilter_params.h conf: nwfilter: use #pragma once in headers 2019-06-13 17:05:09 +02:00
object_event_private.h conf: fix alignment in virObjectEvent to be 8 not 4 bytes 2020-06-04 11:17:05 +01:00
object_event.c conf: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:56 +02:00
object_event.h conf: misc: use #pragma once in headers 2019-06-13 17:05:09 +02:00
secret_conf.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
secret_conf.h Remove virutil.h from all header files 2020-02-24 23:15:50 +01:00
secret_event.c
secret_event.h conf: misc: use #pragma once in headers 2019-06-13 17:05:09 +02:00
snapshot_conf_priv.h conf: snapshot: Provide a function to free virDomainSnapshotDiskDefPtr 2019-07-18 17:59:34 +02:00
snapshot_conf.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
snapshot_conf.h src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
storage_adapter_conf.c Use more of VIR_XPATH_NODE_AUTORESTORE 2020-06-03 21:06:02 +02:00
storage_adapter_conf.h conf: storage: use #pragma once in headers 2019-06-13 17:05:09 +02:00
storage_capabilities.c conf: use g_auto() for all virBuffers 2020-07-08 16:34:17 -04:00
storage_capabilities.h conf: storagecaps: Fix broken attempt at being const-correct 2019-11-12 14:37:57 +01:00
storage_conf.c conf: add control over COW for storage pool directories 2020-07-23 16:18:09 +01:00
storage_conf.h conf: add control over COW for storage pool directories 2020-07-23 16:18:09 +01:00
storage_event.c
storage_event.h conf: storage: use #pragma once in headers 2019-06-13 17:05:09 +02:00
virchrdev.c virchrdev: Drop needless 'cleanup' label in virChrdevLockFileCreate() 2020-01-16 14:13:47 +01:00
virchrdev.h conf: misc: use #pragma once in headers 2019-06-13 17:05:09 +02:00
virconftypes.h backup: Parse and output backup XML 2019-12-10 12:41:56 +01:00
virdomaincheckpointobjlist.c src: replace verify(expr) with G_STATIC_ASSERT(expr) 2020-01-17 10:02:01 +00:00
virdomaincheckpointobjlist.h backup: Allow for lists of checkpoint objects 2019-07-26 16:48:58 -05:00
virdomainmomentobjlist.c util: consolidate on one free callback for hash data 2019-11-22 14:21:28 +00:00
virdomainmomentobjlist.h backup: Allow for lists of checkpoint objects 2019-07-26 16:48:58 -05:00
virdomainobjlist.c conf: drop virCapsPtr param from domain obj list APIs 2019-12-09 10:17:27 +00:00
virdomainobjlist.h conf: drop virCapsPtr param from domain obj list APIs 2019-12-09 10:17:27 +00:00
virdomainsnapshotobjlist.c Use G_N_ELEMENTS instead of ARRAY_CARDINALITY 2019-10-15 16:14:19 +02:00
virdomainsnapshotobjlist.h snapshot: Don't leak moment obj list metaroot to callers 2019-07-24 17:03:34 -05:00
virinterfaceobj.c conf: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:56 +02:00
virinterfaceobj.h conf: misc: use #pragma once in headers 2019-06-13 17:05:09 +02:00
virnetworkobj.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
virnetworkobj.h Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK 2019-10-15 11:25:22 +02:00
virnetworkportdef.c conf: use g_auto() for all virBuffers 2020-07-08 16:34:17 -04:00
virnetworkportdef.h conf: reduce includes in virnetworkportdef.h 2020-02-25 17:50:47 +01:00
virnodedeviceobj.c nodedev: add mdev support to virNodeDeviceCreateXML() 2020-06-19 10:39:55 +02:00
virnodedeviceobj.h nodedev: add mdev support to virNodeDeviceCreateXML() 2020-06-19 10:39:55 +02:00
virnwfilterbindingdef.c conf: use g_auto() for all virBuffers 2020-07-08 16:34:17 -04:00
virnwfilterbindingdef.h conf: virnwfilterbindingdef: include virxml.h 2020-02-25 17:46:45 +01:00
virnwfilterbindingobj.c conf: use g_auto() for all virBuffers 2020-07-08 16:34:17 -04:00
virnwfilterbindingobj.h conf: nwfilter: use #pragma once in headers 2019-06-13 17:05:09 +02:00
virnwfilterbindingobjlist.c conf: use G_GNUC_UNUSED 2019-10-15 11:25:22 +02:00
virnwfilterbindingobjlist.h conf: nwfilter: use #pragma once in headers 2019-06-13 17:05:09 +02:00
virnwfilterobj.c conf: use g_strdup instead of VIR_STRDUP 2019-10-21 12:51:56 +02:00
virnwfilterobj.h nwfilter: acquire a pidfile in the driver root directory 2019-07-11 12:46:20 +01:00
virsavecookie.c conf: eliminate unnecessary labels 2020-07-08 16:35:36 -04:00
virsavecookie.h conf: misc: use #pragma once in headers 2019-06-13 17:05:09 +02:00
virsecretobj.c conf: remove unneeded cleanup labels 2019-11-12 17:54:01 +01:00
virsecretobj.h conf: misc: use #pragma once in headers 2019-06-13 17:05:09 +02:00
virstorageobj.c Unlock the storage pool objects after looking it up 2020-05-18 11:31:58 +02:00
virstorageobj.h storage_driver: Protect pool def during startup and build 2019-08-23 09:32:26 +02:00