Message ID | 20250127142824.494644-2-david@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | s390x: support virtio-mem-pci | expand |
On 27/01/2025 15.28, David Hildenbrand wrote: > 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" }, Hi! Do we need the entries fo the -transitional and -non-transitional devices? Since virtio-mem is rather new, I would expect that those should not exist here? E.g. virtio-balloon-pci.c has: .transitional_name = "virtio-balloon-pci-transitional", .non_transitional_name = "virtio-balloon-pci-non-transitional", but there are no such entries in virtio-mem-pci.c ... ? Thomas > }; > 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;
On 27.01.25 16:28, Thomas Huth wrote: > On 27/01/2025 15.28, David Hildenbrand wrote: >> 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" }, > > Hi! > > Do we need the entries fo the -transitional and -non-transitional devices? > Since virtio-mem is rather new, I would expect that those should not exist > here? E.g. virtio-balloon-pci.c has: > > .transitional_name = "virtio-balloon-pci-transitional", > .non_transitional_name = "virtio-balloon-pci-non-transitional", > > but there are no such entries in virtio-mem-pci.c ... ? Oh, very good point. Yes, I think we can just drop this legacy stuff. Thanks!
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;
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(+)