[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 1/2] virtio-mem-pci: Allow setting nvectors, so we can use MSI
From: |
David Hildenbrand |
Subject: |
[PATCH v1 1/2] virtio-mem-pci: Allow setting nvectors, so we can use MSI-X |
Date: |
Mon, 27 Jan 2025 15:28:23 +0100 |
Let's do it similar as virtio-balloon-pci. With this change, we can
use virtio-mem-pci on s390x, although plugging will still fail until
properly wired up in the machine.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/core/machine.c | 3 +++
hw/virtio/virtio-mem-pci.c | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 8f396ef803..5e1d9e12ef 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -41,6 +41,9 @@ GlobalProperty hw_compat_9_2[] = {
{ "virtio-balloon-pci", "vectors", "0" },
{ "virtio-balloon-pci-transitional", "vectors", "0" },
{ "virtio-balloon-pci-non-transitional", "vectors", "0" },
+ { "virtio-mem-pci", "vectors", "0" },
+ { "virtio-mem-pci-transitional", "vectors", "0" },
+ { "virtio-mem-pci-non-transitional", "vectors", "0" },
};
const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
index 1b4e9a3284..6cc5f0fd3b 100644
--- a/hw/virtio/virtio-mem-pci.c
+++ b/hw/virtio/virtio-mem-pci.c
@@ -22,6 +22,10 @@ static void virtio_mem_pci_realize(VirtIOPCIProxy *vpci_dev,
Error **errp)
VirtIOMEMPCI *mem_pci = VIRTIO_MEM_PCI(vpci_dev);
DeviceState *vdev = DEVICE(&mem_pci->vdev);
+ if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
+ vpci_dev->nvectors = 2;
+ }
+
virtio_pci_force_virtio_1(vpci_dev);
qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
}
@@ -152,6 +156,13 @@ static void virtio_mem_pci_set_requested_size(Object *obj,
Visitor *v,
object_property_set(OBJECT(&pci_mem->vdev), name, v, errp);
}
+static const Property virtio_mem_pci_class_properties[] = {
+ DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
+ VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
+ DEV_NVECTORS_UNSPECIFIED),
+};
+
static void virtio_mem_pci_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -164,6 +175,7 @@ static void virtio_mem_pci_class_init(ObjectClass *klass,
void *data)
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
pcidev_k->class_id = PCI_CLASS_OTHERS;
+ device_class_set_props(dc, virtio_mem_pci_class_properties);
mdc->get_addr = virtio_mem_pci_get_addr;
mdc->set_addr = virtio_mem_pci_set_addr;
--
2.48.1