diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 9f6d4b3de826ee6afbd83e0e82bcb2150350d8e0..0d21d9fb2ba87343206968d066cd676fe63992d5 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -561,27 +561,26 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data) int status; if (STREQ(name, "lxc.network.type")) { + virDomainDefPtr def = parseData->def; + size_t networks = parseData->networks; + bool privnet = parseData->privnet; + /* Store the previous NIC */ status = lxcAddNetworkDefinition(parseData); if (status < 0) return -1; else if (status > 0) - parseData->networks++; + networks++; else if (parseData->type != NULL && STREQ(parseData->type, "none")) - parseData->privnet = false; - - /* Start a new network interface config */ - parseData->type = NULL; - parseData->link = NULL; - parseData->mac = NULL; - parseData->flag = NULL; - parseData->macvlanmode = NULL; - parseData->vlanid = NULL; - parseData->name = NULL; - - parseData->ips = NULL; - parseData->nips = 0; + privnet = false; + + /* clean NIC to store a new one */ + memset(parseData, 0, sizeof(*parseData)); + + parseData->def = def; + parseData->networks = networks; + parseData->privnet = privnet; /* Keep the new value */ parseData->type = value->str;