conf: Don't format actual network definition in migratable XML

https://bugzilla.redhat.com/show_bug.cgi?id=1177194

When migrate a vm, we will generate a xml via qemuDomainDefFormatLive and
pass this xml to target libvirtd. Libvirt will use the current network
state in def->data.network.actual to generate the xml, this will make
migrate failed when we set a network type guest interface use a macvtap
network as a source in a vm then migrate vm to another host(which has the
different macvtap network settings: different interface name, bridge name...)

Add a flag check in virDomainNetDefFormat, if we set a VIR_DOMAIN_XML_MIGRATABLE
flag when call virDomainNetDefFormat, we won't get the current vm interface
state.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Luyao Huang 2014-12-25 11:38:00 +08:00 committed by Laine Stump
parent 0df8394945
commit 8620b7f8df

View File

@ -16737,17 +16737,22 @@ virDomainNetDefFormat(virBufferPtr buf,
virDomainNetDefPtr def, virDomainNetDefPtr def,
unsigned int flags) unsigned int flags)
{ {
unsigned int actualType = virDomainNetGetActualType(def);
bool publicActual = false;
const char *typeStr;
virDomainHostdevDefPtr hostdef = NULL;
char macstr[VIR_MAC_STRING_BUFLEN];
/* publicActual is true if we should report the current state in /* publicActual is true if we should report the current state in
* def->data.network.actual *instead of* the config (*not* in * def->data.network.actual *instead of* the config (*not* in
* addition to) * addition to)
*/ */
unsigned int actualType = virDomainNetGetActualType(def); if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
bool publicActual def->data.network.actual &&
= (def->type == VIR_DOMAIN_NET_TYPE_NETWORK && def->data.network.actual && !(flags & (VIR_DOMAIN_XML_INACTIVE |
!(flags & (VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET))); VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
const char *typeStr; VIR_DOMAIN_XML_MIGRATABLE)))
virDomainHostdevDefPtr hostdef = NULL; publicActual = true;
char macstr[VIR_MAC_STRING_BUFLEN];
if (publicActual) { if (publicActual) {
if (!(typeStr = virDomainNetTypeToString(actualType))) { if (!(typeStr = virDomainNetTypeToString(actualType))) {