summary refs log tree commit diff stats
path: root/hw/core/trace-events
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2024-11-19 13:03:53 +0100
committerKevin Wolf <kwolf@redhat.com>2024-11-25 11:03:14 +0100
commit5102f9df4a9a7adfbd902f9515c3f8f53dba288e (patch)
tree15f39774c1e83f91019655566a15c5677ff1d790 /hw/core/trace-events
parent05fd7214d8262878ac4d8bf8909fa315f1f589a6 (diff)
downloadfocaccia-qemu-5102f9df4a9a7adfbd902f9515c3f8f53dba288e.tar.gz
focaccia-qemu-5102f9df4a9a7adfbd902f9515c3f8f53dba288e.zip
qdev: Fix set_pci_devfn() to visit option only once
pci_devfn properties accept either a string or an integer as input. To
implement this, set_pci_devfn() first tries to visit the option as a
string, and if that fails, it visits it as an integer instead. While the
QemuOpts visitor happens to accept this, it is invalid according to the
visitor interface. QObject input visitors run into an assertion failure
when this is done.

QObject input visitors are used with the JSON syntax version of -device
on the command line:

$ ./qemu-system-x86_64 -enable-kvm -M q35 -device pcie-pci-bridge,id=pci.1,bus=pcie.0 -blockdev null-co,node-name=disk -device '{ "driver": "virtio-blk-pci", "drive": "disk", "id": "virtio-disk0", "bus": "pci.1", "addr": 1 }'
qemu-system-x86_64: ../qapi/qobject-input-visitor.c:143: QObject *qobject_input_try_get_object(QObjectInputVisitor *, const char *, _Bool): Assertion `removed' failed.

The proper way to accept both strings and integers is using the
alternate mechanism, which tells us the type of the input before it's
visited. With this information, we can directly visit it as the right
type.

This fixes set_pci_devfn() by using the alternate mechanism.

Cc: qemu-stable@nongnu.org
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20241119120353.57812-1-kwolf@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/core/trace-events')
0 files changed, 0 insertions, 0 deletions