Skip to content
Snippets Groups Projects
Commit bd74ecd1 authored by Markus Armbruster's avatar Markus Armbruster Committed by Thomas Huth
Browse files

qom: Fix default values in help


Output of default values in device help is broken:

    $ ./qemu-system-x86_64 -S -display none -monitor stdio
    QEMU 5.2.50 monitor - type 'help' for more information
    (qemu) device_add pvpanic,help
    pvpanic options:
      events=<uint8>         -  (default: (null))
      ioport=<uint16>        -  (default: (null))
      pvpanic[0]=<child<qemu:memory-region>>

The "(null)" is glibc printing a null pointer.  Other systems crash
instead.  Having a help request crash a running VM can really spoil
your day.

Root cause is a botched replacement of qstring_free() by
g_string_free(): to get the string back, we need to pass true to the
former, but false to the latter.  Fix the argument.

Fixes: eab3a467
Reported-by: default avatarThomas Huth <thuth@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Message-Id: <20210324084130.3986072-1-armbru@redhat.com>
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
parent 2d53d0c7
No related branches found
No related tags found
No related merge requests found
......@@ -159,7 +159,7 @@ char *object_property_help(const char *name, const char *type,
}
if (defval) {
g_autofree char *def_json = g_string_free(qobject_to_json(defval),
true);
false);
g_string_append_printf(str, " (default: %s)", def_json);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment