qemuBuildNicDevProps: Don't pass 'vhostfdSize'

All callers effectively pass 'net->driver.virtio.queues'. In case of the
code in 'qemu_hotplug.c' this value was set to '1' if it was 0 before.

Since 'qemuBuildNicDevProps' only uses it if it's greater than 1 we can
remove all the extra complexity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-05-09 17:12:12 +02:00
parent 29458f0491
commit 7c43765513
3 changed files with 4 additions and 16 deletions

View File

@ -4096,7 +4096,6 @@ qemuBuildLegacyNicStr(virDomainNetDef *net)
virJSONValue *
qemuBuildNicDevProps(virDomainDef *def,
virDomainNetDef *net,
size_t vhostfdSize,
virQEMUCaps *qemuCaps)
{
g_autoptr(virJSONValue) props = NULL;
@ -4133,7 +4132,7 @@ qemuBuildNicDevProps(virDomainDef *def,
}
}
if (vhostfdSize > 1) {
if (net->driver.virtio.queues > 1) {
if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
/* ccw provides a one to one relation of fds to queues and
* does not support the vectors option
@ -4144,7 +4143,7 @@ qemuBuildNicDevProps(virDomainDef *def,
* we should add vectors=2*N+2 where N is the vhostfdSize
*/
mq = VIR_TRISTATE_SWITCH_ON;
vectors = 2 * vhostfdSize + 2;
vectors = 2 * net->driver.virtio.queues + 2;
}
}
@ -9009,7 +9008,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
if (qemuCommandAddExtDevice(cmd, &net->info, def, qemuCaps) < 0)
goto cleanup;
if (!(nicprops = qemuBuildNicDevProps(def, net, net->driver.virtio.queues, qemuCaps)))
if (!(nicprops = qemuBuildNicDevProps(def, net, qemuCaps)))
goto cleanup;
if (qemuBuildDeviceCommandlineFromJSON(cmd, nicprops, def, qemuCaps) < 0)
goto cleanup;

View File

@ -102,7 +102,6 @@ qemuBuildInterfaceConnect(virDomainObj *vm,
virJSONValue *
qemuBuildNicDevProps(virDomainDef *def,
virDomainNetDef *net,
size_t vhostfdSize,
virQEMUCaps *qemuCaps);
char *qemuDeviceDriveHostAlias(virDomainDiskDef *disk);

View File

@ -1191,7 +1191,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
char **vhostfdName = NULL;
int *vhostfd = NULL;
size_t vhostfdSize = 0;
size_t queueSize = 0;
g_autoptr(virJSONValue) nicprops = NULL;
g_autoptr(virJSONValue) netprops = NULL;
int ret = -1;
@ -1287,7 +1286,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
tapfdSize = vhostfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
queueSize = tapfdSize;
tapfd = g_new0(int, tapfdSize);
memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
vhostfd = g_new0(int, vhostfdSize);
@ -1304,7 +1302,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
tapfdSize = vhostfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
queueSize = tapfdSize;
tapfd = g_new0(int, tapfdSize);
memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
vhostfd = g_new0(int, vhostfdSize);
@ -1322,7 +1319,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
tapfdSize = vhostfdSize = net->driver.virtio.queues;
if (!tapfdSize)
tapfdSize = vhostfdSize = 1;
queueSize = tapfdSize;
tapfd = g_new0(int, tapfdSize);
memset(tapfd, -1, sizeof(*tapfd) * tapfdSize);
vhostfd = g_new0(int, vhostfdSize);
@ -1336,9 +1332,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
break;
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
queueSize = net->driver.virtio.queues;
if (!queueSize)
queueSize = 1;
if (!qemuDomainSupportsNicdev(vm->def, net)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Nicdev support unavailable"));
@ -1388,9 +1381,6 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
break;
case VIR_DOMAIN_NET_TYPE_VDPA:
queueSize = net->driver.virtio.queues;
if (!queueSize)
queueSize = 1;
if (qemuDomainAdjustMaxMemLock(vm, false) < 0)
goto cleanup;
adjustmemlock = true;
@ -1506,7 +1496,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
for (i = 0; i < vhostfdSize; i++)
VIR_FORCE_CLOSE(vhostfd[i]);
if (!(nicprops = qemuBuildNicDevProps(vm->def, net, queueSize, priv->qemuCaps)))
if (!(nicprops = qemuBuildNicDevProps(vm->def, net, priv->qemuCaps)))
goto try_remove;
qemuDomainObjEnterMonitor(driver, vm);