mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
qemu_command.c: reduce qemuBuildNicDevStr() if clauses
We have a lot of "if (usingVirtio)" checks being done while constructing the NIC command line. Let's put all of them in a single "if". Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
edee4290c9
commit
31ac666454
@ -3306,8 +3306,9 @@ qemuBuildNicDevStr(virDomainDefPtr def,
|
|||||||
virBufferAddStr(&buf, virDomainNetGetModelString(net));
|
virBufferAddStr(&buf, virDomainNetGetModelString(net));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingVirtio && net->driver.virtio.txmode) {
|
if (usingVirtio) {
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TX_ALG)) {
|
if (net->driver.virtio.txmode &&
|
||||||
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TX_ALG)) {
|
||||||
virBufferAddLit(&buf, ",tx=");
|
virBufferAddLit(&buf, ",tx=");
|
||||||
switch (net->driver.virtio.txmode) {
|
switch (net->driver.virtio.txmode) {
|
||||||
case VIR_DOMAIN_NET_VIRTIO_TX_MODE_IOTHREAD:
|
case VIR_DOMAIN_NET_VIRTIO_TX_MODE_IOTHREAD:
|
||||||
@ -3331,8 +3332,6 @@ qemuBuildNicDevStr(virDomainDefPtr def,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (usingVirtio) {
|
|
||||||
qemuBuildIoEventFdStr(&buf, net->driver.virtio.ioeventfd, qemuCaps);
|
qemuBuildIoEventFdStr(&buf, net->driver.virtio.ioeventfd, qemuCaps);
|
||||||
if (net->driver.virtio.event_idx &&
|
if (net->driver.virtio.event_idx &&
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_EVENT_IDX)) {
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_EVENT_IDX)) {
|
||||||
@ -3387,8 +3386,8 @@ qemuBuildNicDevStr(virDomainDefPtr def,
|
|||||||
virBufferAsprintf(&buf, ",guest_ufo=%s",
|
virBufferAsprintf(&buf, ",guest_ufo=%s",
|
||||||
virTristateSwitchTypeToString(net->driver.virtio.guest.ufo));
|
virTristateSwitchTypeToString(net->driver.virtio.guest.ufo));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (usingVirtio && vhostfdSize > 1) {
|
if (vhostfdSize > 1) {
|
||||||
if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
|
if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
|
||||||
/* ccw provides a one to one relation of fds to queues and
|
/* ccw provides a one to one relation of fds to queues and
|
||||||
* does not support the vectors option
|
* does not support the vectors option
|
||||||
@ -3402,17 +3401,18 @@ qemuBuildNicDevStr(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingVirtio && net->driver.virtio.rx_queue_size)
|
if (net->driver.virtio.rx_queue_size)
|
||||||
virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
|
virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
|
||||||
|
|
||||||
if (usingVirtio && net->driver.virtio.tx_queue_size)
|
if (net->driver.virtio.tx_queue_size)
|
||||||
virBufferAsprintf(&buf, ",tx_queue_size=%u", net->driver.virtio.tx_queue_size);
|
virBufferAsprintf(&buf, ",tx_queue_size=%u", net->driver.virtio.tx_queue_size);
|
||||||
|
|
||||||
if (usingVirtio && net->mtu)
|
if (net->mtu)
|
||||||
virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu);
|
virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu);
|
||||||
|
|
||||||
if (usingVirtio && net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT)
|
if (net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT)
|
||||||
virBufferAddLit(&buf, ",failover=on");
|
virBufferAddLit(&buf, ",failover=on");
|
||||||
|
}
|
||||||
|
|
||||||
virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
|
virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
|
||||||
virBufferAsprintf(&buf, ",id=%s", net->info.alias);
|
virBufferAsprintf(&buf, ",id=%s", net->info.alias);
|
||||||
|
Loading…
Reference in New Issue
Block a user