Skip to contentSkip to conversation

virtio-mem-pci: force virtio version 1

PATCH In review David Hildenbrand 2 participants 2 messages Jul 27, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio-mem-pci: force virtio version 1

Trying to run simple virtio-mem-pci examples currently fails with
qemu-system-x86_64: -device virtio-mem-pci,id=vm0,memdev=mem0,node=0, requested-size=300M: device is modern-only, use disable-legacy=on
due to the added safety checks in 9b3a35ec8236 ("virtio: verify that legacy support is not accidentally on").

As noted by Conny, we have to force virtio version 1. While at it, use qdev_realize() to set the parent bus and realize - like most other virtio-*-pci implementations.

Fixes 0b9a2443a48b ("virtio-pci: Proxy for virtio-mem")
Cc Cornelia Huck <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
---
 hw/virtio/virtio-mem-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio-mem-pci.c +2 -2
index d375280ee1..590cec041b 100644
@@ -21,8 +21,8 @@ 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);
 
-    qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
-    object_property_set_bool(OBJECT(vdev), "realized", true, errp);
+    virtio_pci_force_virtio_1(vpci_dev);
+    qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
 }
 
 static void virtio_mem_pci_set_addr(MemoryDeviceState *md, uint64_t addr,
Signature · 1 line
2.26.2
#1 lore raw
Quoted 10 lines · David Hildenbrand

Trying to run simple virtio-mem-pci examples currently fails with
qemu-system-x86_64: -device virtio-mem-pci,id=vm0,memdev=mem0,node=0, requested-size=300M: device is modern-only, use disable-legacy=on
due to the added safety checks in 9b3a35ec8236 ("virtio: verify that legacy support is not accidentally on").

As noted by Conny, we have to force virtio version 1. While at it, use qdev_realize() to set the parent bus and realize - like most other virtio-*-pci implementations.

Quoted 6 lines
Fixes 0b9a2443a48b ("virtio-pci: Proxy for virtio-mem")
Cc Cornelia Huck <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>

---

In the future, pls add a changelog here.
E.g.
changes from v1:
- rebased on master
- updated commit log to address mst's comments

Anyway, queued.

Thanks!

Quoted 20 lines
 hw/virtio/virtio-mem-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio-mem-pci.c +2 -2
index d375280ee1..590cec041b 100644
@@ -21,8 +21,8 @@ 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);
 
-    qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
-    object_property_set_bool(OBJECT(vdev), "realized", true, errp);
+    virtio_pci_force_virtio_1(vpci_dev);
+    qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
 }
 
 static void virtio_mem_pci_set_addr(MemoryDeviceState *md, uint64_t addr,
Signature · 1 line
2.26.2