mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuOpenVhostNet: Decrease vhostfdSize on open failure
Currently, if there's an error opening /dev/vhost-net (e.g. because it doesn't exist) but it's not required we proceed with vhostfd array filled with -1 and vhostfdSize unchanged. Later, when constructing the qemu command line only non-negative items within vhostfd array are taken into account. This means, vhostfdSize may be greater than the actual count of non-negative items in vhostfd array. This results in improper command line arguments being generated, e.g.: -netdev tap,fd=21,id=hostnet0,vhost=on,vhostfd=(null)
This commit is contained in:
parent
f6817c70b4
commit
d10cfaec3b
@ -486,6 +486,10 @@ qemuOpenVhostNet(virDomainDefPtr def,
|
|||||||
"but is unavailable"));
|
"but is unavailable"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
VIR_WARN("Unable to open vhost-net. Opened so far %d, requested %d",
|
||||||
|
i, *vhostfdSize);
|
||||||
|
*vhostfdSize = i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virDomainAuditNetDevice(def, net, "/dev/vhost-net", *vhostfdSize);
|
virDomainAuditNetDevice(def, net, "/dev/vhost-net", *vhostfdSize);
|
||||||
@ -6560,12 +6564,10 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < vhostfdSize; i++) {
|
for (i = 0; i < vhostfdSize; i++) {
|
||||||
if (vhostfd[i] >= 0) {
|
virCommandTransferFD(cmd, vhostfd[i]);
|
||||||
virCommandTransferFD(cmd, vhostfd[i]);
|
if (virAsprintf(&vhostfdName[i], "%d", vhostfd[i]) < 0) {
|
||||||
if (virAsprintf(&vhostfdName[i], "%d", vhostfd[i]) < 0) {
|
virReportOOMError();
|
||||||
virReportOOMError();
|
goto cleanup;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user