Fix coredump when using virtio-vga
PATCH 1/1 Fix coredump when using virtio-vga
From: Michael Qiu <[email protected]>
When using command -device virtio-vga,virgl=on the default max_outputs is 0, this will lead coredump,
(con=0x0, hw_ops=0x5555564452e0 <virtio_vga_ops>,
opaque=0x55555754ec60) at ui/console.c:1872
(vpci_dev=0x55555754ec60, errp=0x7fffffffdbb8)
at qemu/hw/display/virtio-vga.c:160
(pci_dev=0x55555754ec60, errp=0x7fffffffdbb8)
at hw/virtio/virtio-pci.c:1786...
This patch force ths max_outputs to 1 when it not greater than 0.
--- hw/display/virtio-gpu-pci.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/display/virtio-gpu-pci.c +5 -0
@@ -46,6 +46,11 @@ static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)int i;Error *local_error =NULL ; +if (g->conf.max_outputs <=0 ) { +qemu_log ("WARNING: virtio gpu max_outputs must greater than 1" ); + g->conf.max_outputs =1 ; + } +qdev_set_parent_bus (vdev,BUS (&vpci_dev->bus));virtio_pci_force_virtio_1 (vpci_dev);object_property_set_bool (OBJECT (vdev), true,"realized" , &local_error);
Signature · 1 line
1.8.3.1
Quoted 4 lines · On Fri, Mar 01, 2019 at 12:13:08PM +0800, [email protected] wrote:
From: Michael Qiu <[email protected]>
When using command -device virtio-vga,virgl=on the default
max_outputsis 0, this will lead coredump,
The default is 1.
hw/display/virtio-gpu-pci.c static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) · line 52
Quoted 8 lines
hw/display/virtio-gpu-pci.c +4
-0@@ -46,6 +46,11 @@ static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)int i;Error *local_error =NULL ; +if (g->conf.max_outputs <=0 ) { +qemu_log ("WARNING: virtio gpu max_outputs must greater than 1" ); + g->conf.max_outputs =1 ; + }
There already is a sanity check in virtio_gpu_device_realize(). You can extend that to also throw an error in case max_outputs is 0. Fixing things up and continuing is a bad idea. Yes there are places in the qemu code base still doing that, for backward compatibility with old versions, but we should not add new instances of this.
cheers,
Gerd