From 78c65074736d111677f6526f193d8df931f43d4f Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Fri, 9 Oct 2020 11:08:49 -0300 Subject: [PATCH] qemu_command.c: move QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE check to qemu_validate.c Reviewed-by: Michal Privoznik Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_command.c | 10 +++------- src/qemu/qemu_validate.c | 8 ++++++++ tests/qemuxml2argvtest.c | 3 ++- tests/qemuxml2xmltest.c | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1629fac659..acbd5b1234 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3401,14 +3401,10 @@ qemuBuildNicDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",mq=on,vectors=%zu", 2 * vhostfdSize + 2); } } - if (usingVirtio && net->driver.virtio.rx_queue_size) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio rx_queue_size option is not supported with this QEMU binary")); - return NULL; - } + + if (usingVirtio && 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 (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index bdfb501e23..9013da7ef7 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1261,6 +1261,14 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net, return -1; } + if (net->driver.virtio.rx_queue_size && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio rx_queue_size option is not supported " + "with this QEMU binary")); + return -1; + } + if (net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("rx_queue_size has to be a power of two")); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index cf1d3c7ded..40ce346a73 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1445,7 +1445,8 @@ mymain(void) DO_TEST("net-virtio-rxtxqueuesize", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE); - DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE); + DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", + QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE); DO_TEST("net-virtio-teaming", QEMU_CAPS_VIRTIO_NET_FAILOVER, QEMU_CAPS_DEVICE_VFIO_PCI); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index c1b70025b1..19beb85f96 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -474,7 +474,8 @@ mymain(void) DO_TEST("net-eth-hostip", NONE); DO_TEST("net-eth-unmanaged-tap", NONE); DO_TEST("net-virtio-network-portgroup", NONE); - DO_TEST("net-virtio-rxtxqueuesize", NONE); + DO_TEST("net-virtio-rxtxqueuesize", + QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE); DO_TEST("net-virtio-teaming", QEMU_CAPS_VIRTIO_NET_FAILOVER, QEMU_CAPS_DEVICE_VFIO_PCI);