mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: Simplify interface handling in qemuConnectDomainXMLToNative()
Firstly, VIR_STRDUP() accepts NULL, so there is no need to check if the string we want to duplicate is not-NULL. Secondly, virDomainNetSetModelString() also accepts NULL. Thirdly, we have VIR_AUTOFREE(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
3c32f9ec42
commit
4bdce1219f
@ -7411,12 +7411,11 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
||||
for (i = 0; i < vm->def->nnets; i++) {
|
||||
virDomainNetDefPtr net = vm->def->nets[i];
|
||||
unsigned int bootIndex = net->info.bootIndex;
|
||||
char *model = NULL;
|
||||
VIR_AUTOFREE(char *) model = NULL;
|
||||
virMacAddr mac = net->mac;
|
||||
char *script = net->script;
|
||||
|
||||
if (virDomainNetGetModelString(net) &&
|
||||
VIR_STRDUP(model, virDomainNetGetModelString(net)) < 0)
|
||||
if (VIR_STRDUP(model, virDomainNetGetModelString(net)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
net->script = NULL;
|
||||
@ -7428,11 +7427,8 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
||||
net->mac = mac;
|
||||
net->script = script;
|
||||
|
||||
if (model && virDomainNetSetModelString(net, model) < 0) {
|
||||
VIR_FREE(model);
|
||||
if (virDomainNetSetModelString(net, model) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
VIR_FREE(model);
|
||||
}
|
||||
|
||||
if (!(cmd = qemuProcessCreatePretendCmd(driver, vm, NULL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user