virtio-iommu-pci: Advertise the device as modern-only
cover virtio-iommu-pci: Advertise the device as modern-only
Since commit 9b3a35ec82 ("virtio: verify that legacy support is not accidentally on"), we are forced to use disable-legacy=on when instantiating the virtio-iommu-pci device. This also revealed that the unrealize() function is likely to call g_tree_destroy() on NULL gtrees, which triggers assertions.
Best Regards
Eric
Eric Auger (2):
virtio-iommu: Check gtrees are non null before destroying them
virtio-iommu-pci: force virtio version 1
hw/virtio/virtio-iommu-pci.c | 2 +- hw/virtio/virtio-iommu.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
Signature · 1 line
2.21.3
PATCH 1/2 virtio-iommu: Check gtrees are non null before destroying them
If realize fails, domains and endpoints trees may be NULL. On unrealize(), this produces asseryions:
"GLib: g_tree_destroy: assertion 'tree != NULL' failed"
Check the tree are non NULL before destroying them.
--- hw/virtio/virtio-iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/virtio/virtio-iommu.c +6 -2
@@ -801,8 +801,12 @@ static void virtio_iommu_device_unrealize(DeviceState *dev)VirtIOIOMMU *s =VIRTIO_IOMMU (dev);g_hash_table_destroy (s->as_by_busptr); -g_tree_destroy (s->domains); -g_tree_destroy (s->endpoints); +if (s->domains) { +g_tree_destroy (s->domains); + } +if (s->endpoints) { +g_tree_destroy (s->endpoints); + }virtio_delete_queue (s->req_vq);virtio_delete_queue (s->event_vq);
Signature · 1 line
2.21.3
Re: [PATCH 1/2] virtio-iommu: Check gtrees are non null before destroying them
Quoted 2 lines · On Wed, 2 Sep 2020 15:11:51 +0200 Eric Auger <[email protected]> wrote:
If realize fails, domains and endpoints trees may be NULL. On
unrealize(), this produces asseryions:
s/asseryions/assertions/
Quoted 3 lines
"GLib:
g_tree_destroy: assertion 'tree != NULL' failed"Check the tree are non NULL before destroying them.
s/the tree/that the trees/
Quoted 6 lines
Signed-off-by Eric Auger <[email protected]>--- hw/virtio/virtio-iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Good to see that the version checking has flushed out a bug :)
PATCH 2/2 virtio-iommu-pci: force virtio version 1
In reply to Eric AugerCommit 9b3a35ec82 ("virtio: verify that legacy support is not accidentally on") added a safety check that requires to set 'disable-legacy=on' on virtio-iommu-pci:
qemu-system-aarch64: -device virtio-iommu-pci: device is modern-only, use disable-legacy=on
virtio-iommu was introduced after the release of VIRTIO 1.0 specifications, so it should be 'modern-only'.
This patch forces virtio version 1 and removes the 'transitional_name' property removing the need to specify 'disable-legacy=on' on virtio-iommu-pci device.
--- hw/virtio/virtio-iommu-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-iommu-pci.c +1 -1
@@ -68,6 +68,7 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)object_property_set_link (OBJECT (dev),"primary-bus" ,OBJECT (pci_get_bus (&vpci_dev->pci_dev)), &error_abort); +virtio_pci_force_virtio_1 (vpci_dev);qdev_realize (vdev,BUS (&vpci_dev->bus), errp); }
@@ -97,7 +98,6 @@ static void virtio_iommu_pci_instance_init(Object *obj)static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = { .base_name =TYPE_VIRTIO_IOMMU_PCI , .generic_name ="virtio-iommu-pci" , - .transitional_name ="virtio-iommu-pci-transitional" , .non_transitional_name ="virtio-iommu-pci-non-transitional" , .instance_size =sizeof (VirtIOIOMMUPCI), .instance_init = virtio_iommu_pci_instance_init,
Signature · 1 line
2.21.3
Re: [PATCH 2/2] virtio-iommu-pci: force virtio version 1
Quoted 14 lines · On Wed, 2 Sep 2020 15:11:52 +0200 Eric Auger <[email protected]> wrote:
Commit
9b3a35ec82("virtio: verify that legacy support is not accidentally on") added a safety check that requires to set 'disable-legacy=on' on virtio-iommu-pci:qemu-system-aarch64: -device virtio-iommu-pci: device is modern-only, use disable-legacy=on
virtio-iommu was introduced after the release of VIRTIO 1.0 specifications, so it should be 'modern-only'.
This patch forces virtio version 1 and removes the '
transitional_name' property removing the need to specify 'disable-legacy=on' on virtio-iommu-pci device.
Quoted 5 lines
Signed-off-by Eric Auger <[email protected]>--- hw/virtio/virtio-iommu-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)