qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/5] virtio: add VirtioDeviceClass->get_num_virtqueues()


From: Stefan Hajnoczi
Subject: [PATCH 2/5] virtio: add VirtioDeviceClass->get_num_virtqueues()
Date: Thu, 16 Jan 2020 10:58:39 +0000

The virtio-pci proxy objects have an "nvectors" qdev property to
allocate MSI vectors.  This property defaults to
DEV_NVECTORS_UNSPECIFIED on multi-queue devices and the final value is
based on the number of virtqueues.

The number of virtqueues is typically calculated like this by the
virtio-pci proxy object:

  num_virtqueues = NUM_FIXED_VIRTQUEUES + conf.num_queues

where conf.num_queues is a qdev property to allocate virtqueues.

Add VirtioDeviceClass->get_num_virtqueues() so that this calculation can
be performed by the device instead of the proxy object.  This removes
knowledge of virtqueue layout from the proxy object and allows the
device to implement other formulas for calculating the number of
virtqueues.

This patch has no use on its own but keeping it separate eases backports
if someone wants the virtio-blk patch but not virtio-scsi, or vice
versa.  The next patch uses this new function to automatically set
conf.num_queues to -smp N for automatic multi-queue configuration.

Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 include/hw/virtio/virtio.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index b69d517496..048c81fcef 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -163,6 +163,13 @@ typedef struct VirtioDeviceClass {
     int (*post_load)(VirtIODevice *vdev);
     const VMStateDescription *vmsd;
     bool (*primary_unplug_pending)(void *opaque);
+
+    /*
+     * Return the number of virtqueues.  Called by transports that need to
+     * allocate per-virtqueue interrupt resources.  This function may be called
+     * before the device is realized.
+     */
+    uint32_t (*get_num_virtqueues)(VirtIODevice *vdev);
 } VirtioDeviceClass;
 
 void virtio_instance_init_common(Object *proxy_obj, void *data,
-- 
2.24.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]