mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
qemuParseCommandLineNet: Make it more readable
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
f2fb783bb6
commit
b2482c084a
@ -1055,9 +1055,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
if (virStrToLong_i(values[i], NULL, 10, &wantvlan) < 0) {
|
if (virStrToLong_i(values[i], NULL, 10, &wantvlan) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot parse vlan in '%s'"), val);
|
_("cannot parse vlan in '%s'"), val);
|
||||||
virDomainNetDefFree(def);
|
goto error;
|
||||||
def = NULL;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
} else if (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
|
} else if (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
|
||||||
STREQ(keywords[i], "script") && STRNEQ(values[i], "")) {
|
STREQ(keywords[i], "script") && STRNEQ(values[i], "")) {
|
||||||
@ -1076,18 +1074,13 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
nic = qemuFindNICForVLAN(nnics, nics, wantvlan);
|
nic = qemuFindNICForVLAN(nnics, nics, wantvlan);
|
||||||
if (!nic) {
|
if (!nic)
|
||||||
virDomainNetDefFree(def);
|
goto error;
|
||||||
def = NULL;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!STRPREFIX(nic, "nic")) {
|
if (!STRPREFIX(nic, "nic")) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot parse NIC definition '%s'"), nic);
|
_("cannot parse NIC definition '%s'"), nic);
|
||||||
virDomainNetDefFree(def);
|
goto error;
|
||||||
def = NULL;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nkeywords; i++) {
|
for (i = 0; i < nkeywords; i++) {
|
||||||
@ -1103,9 +1096,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
&values,
|
&values,
|
||||||
&nkeywords,
|
&nkeywords,
|
||||||
0) < 0) {
|
0) < 0) {
|
||||||
virDomainNetDefFree(def);
|
goto error;
|
||||||
def = NULL;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nkeywords = 0;
|
nkeywords = 0;
|
||||||
@ -1118,9 +1109,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unable to parse mac address '%s'"),
|
_("unable to parse mac address '%s'"),
|
||||||
values[i]);
|
values[i]);
|
||||||
virDomainNetDefFree(def);
|
goto error;
|
||||||
def = NULL;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
} else if (STREQ(keywords[i], "model")) {
|
} else if (STREQ(keywords[i], "model")) {
|
||||||
def->model = values[i];
|
def->model = values[i];
|
||||||
@ -1135,9 +1124,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
if (virStrToLong_ul(values[i], NULL, 10, &def->tune.sndbuf) < 0) {
|
if (virStrToLong_ul(values[i], NULL, 10, &def->tune.sndbuf) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("cannot parse sndbuf size in '%s'"), val);
|
_("cannot parse sndbuf size in '%s'"), val);
|
||||||
virDomainNetDefFree(def);
|
goto error;
|
||||||
def = NULL;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
def->tune.sndbuf_specified = true;
|
def->tune.sndbuf_specified = true;
|
||||||
}
|
}
|
||||||
@ -1154,6 +1141,11 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
VIR_FREE(keywords);
|
VIR_FREE(keywords);
|
||||||
VIR_FREE(values);
|
VIR_FREE(values);
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virDomainNetDefFree(def);
|
||||||
|
def = NULL;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user