]> git.proxmox.com Git - mirror_qemu.git/commit
string-output-visitor: Fix (pseudo) struct handling
authorKevin Wolf <kwolf@redhat.com>
Tue, 9 Jan 2024 18:17:17 +0000 (19:17 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 26 Jan 2024 10:16:58 +0000 (11:16 +0100)
commit014b99a8e41c8cd1e895137654b44dec5430122c
tree78d3ee3cbf97a114a72a4f17774c0421f71eb7e6
parenta9c8ea95470c27a8a02062b67f9fa6940e828ab6
string-output-visitor: Fix (pseudo) struct handling

Commit ff32bb53 tried to get minimal struct support into the string
output visitor by just making it return "<omitted>". Unfortunately, it
forgot that the caller will still make more visitor calls for the
content of the struct.

If the struct is contained in a list, such as IOThreadVirtQueueMapping,
in the better case its fields show up as separate list entries. In the
worse case, it contains another list, and the string output visitor
doesn't support nested lists and asserts that this doesn't happen. So as
soon as the optional "vqs" field in IOThreadVirtQueueMapping is
specified, we get a crash.

This can be reproduced with the following command line:

  echo "info qtree" | ./qemu-system-x86_64 \
    -object iothread,id=t0 \
    -blockdev null-co,node-name=disk \
    -device '{"driver": "virtio-blk-pci", "drive": "disk",
              "iothread-vq-mapping": [{"iothread": "t0", "vqs": [0]}]}' \
    -monitor stdio

Fix the problem by counting the nesting level of structs and ignoring
any visitor calls for values (apart from start/end_struct) while we're
not on the top level.

Lists nested directly within lists remain unimplemented, as we don't
currently have a use case for them.

Fixes: ff32bb53476539d352653f4ed56372dced73a388
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2069
Reported-by: Aihua Liang <aliang@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20240109181717.42493-1-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qapi/string-output-visitor.c