virtio-balloon-pci: Allow setting nvectors, so we can use MSI-X
PATCH 1/1 virtio-balloon-pci: Allow setting nvectors, so we can use MSI-X
Most virtio-pci devices allow MSI-X. Add it to virtio-balloon-pci, but only enable it in new machine types, so we don't break migration of existing machine types between different qemu versions.
This copies what was done for virtio-rng-pci in:9ea02e8f1306 ("virtio-rng-pci: Allow setting nvectors, so we can use MSI-X") bad9c5a5166f ("virtio-rng-pci: fix migration compat for vectors") 62bdb8871512 ("virtio-rng-pci: fix transitional migration compat for vectors")
--- hw/core/machine.c | 6 +++++- hw/virtio/virtio-balloon-pci.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
hw/core/machine.c +5 -1
@@ -36,7 +36,11 @@#include "hw/virtio/virtio-iommu.h" #include "audio/audio.h" -GlobalProperty hw_compat_9_2[] = {}; +GlobalProperty hw_compat_9_2[] = { + {"virtio-balloon-pci" ,"vectors" ,"0" }, + {"virtio-balloon-pci-transitional" ,"vectors" ,"0" }, + {"virtio-balloon-pci-non-transitional" ,"vectors" ,"0" }, +};const size_t hw_compat_9_2_len =G_N_ELEMENTS (hw_compat_9_2);GlobalProperty hw_compat_9_1[] = {
hw/virtio/virtio-balloon-pci.c +13 -0
@@ -35,11 +35,23 @@ struct VirtIOBalloonPCI {VirtIOBalloon vdev; }; +static Property virtio_balloon_properties[] = { +DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true), +DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors, +DEV_NVECTORS_UNSPECIFIED ), +DEFINE_PROP_END_OF_LIST (), +}; +static void virtio_balloon_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) {VirtIOBalloonPCI *dev =VIRTIO_BALLOON_PCI (vpci_dev);DeviceState *vdev =DEVICE (&dev->vdev); +if (vpci_dev->nvectors ==DEV_NVECTORS_UNSPECIFIED ) { + vpci_dev->nvectors =2 ; + } + vpci_dev->class_code =PCI_CLASS_OTHERS ;qdev_realize (vdev,BUS (&vpci_dev->bus), errp); }
@@ -55,6 +67,7 @@ static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data) pcidev_k->device_id =PCI_DEVICE_ID_VIRTIO_BALLOON ; pcidev_k->revision =VIRTIO_PCI_ABI_VERSION ; pcidev_k->class_id =PCI_CLASS_OTHERS ; +device_class_set_props (dc, virtio_balloon_properties); }static void virtio_balloon_pci_instance_init (Object *obj)
base-commit: ca80a5d026a280762e0772615f1988db542b3ade
Signature · 1 line
2.47.1
Quoted 69 lines · Reza Arbab
Most virtio-pci devices allow MSI-X. Add it to virtio-balloon-pci, but only enable it in new machine types, so we don't break migration of existing machine types between different qemu versions.
This copies what was done for virtio-rng-pci in:
9ea02e8f1306("virtio-rng-pci: Allow setting nvectors, so we can use MSI-X")bad9c5a5166f("virtio-rng-pci: fix migration compat for vectors")62bdb8871512("virtio-rng-pci: fix transitional migration compat for vectors")Signed-off-by Reza Arbab <[email protected]>--- hw/core/machine.c | 6 +++++- hw/virtio/virtio-balloon-pci.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)hw/core/machine.c +5
-1@@ -36,7 +36,11 @@#include "hw/virtio/virtio-iommu.h" #include "audio/audio.h" -GlobalProperty hw_compat_9_2[] = {}; +GlobalProperty hw_compat_9_2[] = { + {"virtio-balloon-pci" ,"vectors" ,"0" }, + {"virtio-balloon-pci-transitional" ,"vectors" ,"0" }, + {"virtio-balloon-pci-non-transitional" ,"vectors" ,"0" }, +};const size_t hw_compat_9_2_len =G_N_ELEMENTS (hw_compat_9_2);GlobalProperty hw_compat_9_1[] = {hw/virtio/virtio-balloon-pci.c +13
-0@@ -35,11 +35,23 @@ struct VirtIOBalloonPCI {VirtIOBalloon vdev; }; +static Property virtio_balloon_properties[] = { +DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true), +DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors, +DEV_NVECTORS_UNSPECIFIED ), +DEFINE_PROP_END_OF_LIST (), +}; +static void virtio_balloon_pci_realize (VirtIOPCIProxy *vpci_dev,Error **errp) {VirtIOBalloonPCI *dev =VIRTIO_BALLOON_PCI (vpci_dev);DeviceState *vdev =DEVICE (&dev->vdev); +if (vpci_dev->nvectors ==DEV_NVECTORS_UNSPECIFIED ) { + vpci_dev->nvectors =2 ; + } + vpci_dev->class_code =PCI_CLASS_OTHERS ;qdev_realize (vdev,BUS (&vpci_dev->bus), errp); }@@ -55,6 +67,7 @@ static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data) pcidev_k->device_id =PCI_DEVICE_ID_VIRTIO_BALLOON ; pcidev_k->revision =VIRTIO_PCI_ABI_VERSION ; pcidev_k->class_id =PCI_CLASS_OTHERS ; +device_class_set_props (dc, virtio_balloon_properties); }static void virtio_balloon_pci_instance_init (Object *obj)
Quoted 1 line
base-commit:
ca80a5d026a280762e0772615f1988db542b3ade
No expert on any of that MSi-X / PCI magic, but LGTM
Signature · 3 lines
Cheers, David / dhildenb
Quoted 3 lines · David Hildenbrand
No expert on any of that MSi-X / PCI magic, but LGTM
Thanks David!
Did anyone else have any comments? Just want to make sure I have things in order to get this into the next release.
Signature · 1 line
Reza Arbab
Quoted 9 lines · Reza Arbab
Quoted 3 lines · David Hildenbrand
No expert on any of that MSi-X / PCI magic, but LGTM
Thanks David!
Did anyone else have any comments? Just want to make sure I have things in order to get this into the next release.
Causes a CI failure:
https://gitlab.com/mstredhat/qemu/-/jobs/8800804175
In file included from ../hw/virtio/virtio-balloon-pci.c:15:../hw/virtio/virtio-balloon-pci.c: In function ‘virtio_balloon_pci_class_init’:../include/qemu/osdep.h:261:35: error: call to ‘qemu_build_not_reached_always’ declared with attribute error: code path is reachable
261 | #define qemu_build_not_reached() qemu_build_not_reached_always()
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/hw/qdev-core.h:956:13: note: in expansion of macro ‘qemu_build_not_reached’
956 | qemu_build_not_reached(); \
| ^~~~~~~~~~~~~~~~~~~~~~
../hw/virtio/virtio-balloon-pci.c:69:5: note: in expansion of macro ‘device_class_set_props’
69 | device_class_set_props(dc, virtio_balloon_properties);
| ^~~~~~~~~~~~~~~~~~~~~~[2493/4296] Compiling C object libqemu-ppc64-softmmu.a.p/hw_virtio_virtio-scsi-pci.c.o [2494/4296] Compiling C object libqemu-ppc64-softmmu.a.p/hw_virtio_virtio-9p-pci.c.o
Quoted 2 lines
Signature · 1 line
Reza Arbab
Hi Reza,
Quoted 21 lines · Reza Arbab
Most virtio-pci devices allow MSI-X. Add it to virtio-balloon-pci, but only enable it in new machine types, so we don't break migration of existing machine types between different qemu versions.
This copies what was done for virtio-rng-pci in:
9ea02e8f1306("virtio-rng-pci: Allow setting nvectors, so we can use MSI-X")bad9c5a5166f("virtio-rng-pci: fix migration compat for vectors")62bdb8871512("virtio-rng-pci: fix transitional migration compat for vectors")Signed-off-by Reza Arbab <[email protected]>--- hw/core/machine.c | 6 +++++- hw/virtio/virtio-balloon-pci.c | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)hw/virtio/virtio-balloon-pci.c +0
-0
hw/virtio/virtio-balloon-pci.c struct VirtIOBalloonPCI { · line 43
Quoted 9 lines
hw/virtio/virtio-balloon-pci.c +6
-0@@ -35,11 +35,23 @@ struct VirtIOBalloonPCI {VirtIOBalloon vdev; }; +static Property virtio_balloon_properties[] = { +DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true), +DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors, +DEV_NVECTORS_UNSPECIFIED ), +DEFINE_PROP_END_OF_LIST (),
You shouldn't use that anymore since commit 5fcabe628b8 ("include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST").
Also, this array can be declared const.
Quoted 1 line
hw/virtio/virtio-balloon-pci.c +1
-0+};
Quoted 11 lines · Michael S. Tsirkin
In file included from
../hw/virtio/virtio-balloon-pci.c:15:../hw/virtio/virtio-balloon-pci.c: In function ‘virtio_balloon_pci_class_init’:../include/qemu/osdep.h:261:35: error: call to ‘qemu_build_not_reached_always’ declared with attribute error: code path is reachable261 | #define qemu_build_not_reached() qemu_build_not_reached_always() | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/hw/qdev-core.h:956:13: note: in expansion of macro ‘qemu_build_not_reached’ 956 | qemu_build_not_reached(); \ | ^~~~~~~~~~~~~~~~~~~~~~ ../hw/virtio/virtio-balloon-pci.c:69:5: note: in expansion of macro ‘device_class_set_props’ 69 | device_class_set_props(dc, virtio_balloon_properties); | ^~~~~~~~~~~~~~~~~~~~~~
Ah, I need to declare virtio_balloon_properties as const.
Signature · 1 line
Reza Arbab
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 6 lines
hw/virtio/virtio-balloon-pci.c +1
-0@@ -35,11 +35,23 @@ struct VirtIOBalloonPCI {VirtIOBalloon vdev; }; +static Property virtio_balloon_properties[] = {
Quoted 8 lines
hw/virtio/virtio-balloon-pci.c struct VirtIOBalloonPCI { · line 43
Quoted 5 lines
hw/virtio/virtio-balloon-pci.c +5
-0+DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true), +DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors, +DEV_NVECTORS_UNSPECIFIED ), + DEFINE_PROP_END_OF_LIST(),You shouldn't use that anymore since commit
5fcabe628b8("include/hw/qdev-properties: RemoveDEFINE_PROP_END_OF_LIST").
Ah, yes, that happened after I sent this.
Quoted 1 line
Also, this array can be declared const.
Funny, commit 1577a9180f37 ("hw/virtio: Constify all Property") also happened not long after I sent.
Thanks for your review! v2 incoming.
Signature · 1 line
Reza Arbab