qemu: don't set/clear NetDef IP addresses in qemuConnectDomainXMLToNative()

This patch removes the expanded and duplicated code that all sprung
out of two well-intentioned-but-useless settings of
net->data.(bridge|ethernet).ipaddr.

qemu has never supported even a single IP address in the interface
config, much less a list of them. All of the instances of "clearing
out the IP addresses" that are now in this function originated with
commit d8dbd6 "Basic domain XML conversions for Xen/QEMU drivers" in
May 2009, but even then the single "ipaddr" in the struct for
type='ethernet' and type='bridge' wasn't used in the qemu driver (only
in xen and openvz). Since then anyone who added a new interface type
also tacked on another unnecessary clearing of ipaddr, and when it was
made into a list of IPs (so far supported only by the LXC driver) this
simple setting was turned into a loop (well, multiple loops) to clear
them all.
This commit is contained in:
Laine Stump 2016-06-07 19:59:10 -04:00
parent 7cfbaad189
commit 9104509289

View File

@ -6938,7 +6938,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
(brname = virDomainNetGetActualBridgeName(net))) { (brname = virDomainNetGetActualBridgeName(net))) {
char *brnamecopy; char *brnamecopy;
size_t j;
if (VIR_STRDUP(brnamecopy, brname) < 0) if (VIR_STRDUP(brnamecopy, brname) < 0)
goto cleanup; goto cleanup;
@ -6950,29 +6949,18 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET; net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
net->script = NULL; net->script = NULL;
net->data.ethernet.dev = brnamecopy; net->data.ethernet.dev = brnamecopy;
for (j = 0; j < net->nips; j++)
VIR_FREE(net->ips[j]);
VIR_FREE(net->ips);
net->nips = 0;
} else { } else {
/* actualType is either NETWORK or DIRECT. In either /* actualType is either NETWORK or DIRECT. In either
* case, the best we can do is NULL everything out. * case, the best we can do is NULL everything out.
*/ */
size_t j;
virDomainActualNetDefFree(net->data.network.actual); virDomainActualNetDefFree(net->data.network.actual);
memset(net, 0, sizeof(*net)); memset(net, 0, sizeof(*net));
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET; net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
net->script = NULL; net->script = NULL;
net->data.ethernet.dev = NULL; net->data.ethernet.dev = NULL;
for (j = 0; j < net->nips; j++)
VIR_FREE(net->ips[j]);
VIR_FREE(net->ips);
net->nips = 0;
} }
} else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) { } else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
size_t j;
VIR_FREE(net->data.direct.linkdev); VIR_FREE(net->data.direct.linkdev);
memset(net, 0, sizeof(*net)); memset(net, 0, sizeof(*net));
@ -6980,23 +6968,15 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET; net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
net->script = NULL; net->script = NULL;
net->data.ethernet.dev = NULL; net->data.ethernet.dev = NULL;
for (j = 0; j < net->nips; j++)
VIR_FREE(net->ips[j]);
VIR_FREE(net->ips);
net->nips = 0;
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) { } else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
char *script = net->script; char *script = net->script;
char *brname = net->data.bridge.brname; char *brname = net->data.bridge.brname;
size_t nips = net->nips;
virDomainNetIPDefPtr *ips = net->ips;
memset(net, 0, sizeof(*net)); memset(net, 0, sizeof(*net));
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET; net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
net->script = script; net->script = script;
net->data.ethernet.dev = brname; net->data.ethernet.dev = brname;
net->nips = nips;
net->ips = ips;
} }
VIR_FREE(net->virtPortProfile); VIR_FREE(net->virtPortProfile);