mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
lxc: Introduce lxcNetworkParseDataType
Extract out the network "type" processing into it's own method rather than inline within lxcNetworkParseDataSuffix. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
f7fd10e5f8
commit
087a7c9a88
@ -553,6 +553,39 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
lxcNetworkParseDataType(virConfValuePtr value,
|
||||
lxcNetworkParseData *parseData)
|
||||
{
|
||||
virDomainDefPtr def = parseData->def;
|
||||
size_t networks = parseData->networks;
|
||||
bool privnet = parseData->privnet;
|
||||
int status;
|
||||
|
||||
/* Store the previous NIC */
|
||||
status = lxcAddNetworkDefinition(parseData);
|
||||
|
||||
if (status < 0)
|
||||
return -1;
|
||||
else if (status > 0)
|
||||
networks++;
|
||||
else if (parseData->type != NULL && STREQ(parseData->type, "none"))
|
||||
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;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
lxcNetworkParseDataIPs(const char *name,
|
||||
virConfValuePtr value,
|
||||
@ -597,32 +630,9 @@ lxcNetworkParseDataSuffix(const char *name,
|
||||
virConfValuePtr value,
|
||||
lxcNetworkParseData *parseData)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (STREQ(name, "type")) {
|
||||
virDomainDefPtr def = parseData->def;
|
||||
size_t networks = parseData->networks;
|
||||
bool privnet = parseData->privnet;
|
||||
|
||||
/* Store the previous NIC */
|
||||
status = lxcAddNetworkDefinition(parseData);
|
||||
|
||||
if (status < 0)
|
||||
if (lxcNetworkParseDataType(value, parseData) < 0)
|
||||
return -1;
|
||||
else if (status > 0)
|
||||
networks++;
|
||||
else if (parseData->type != NULL && STREQ(parseData->type, "none"))
|
||||
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;
|
||||
}
|
||||
else if (STREQ(name, "link"))
|
||||
parseData->link = value->str;
|
||||
|
Loading…
x
Reference in New Issue
Block a user