[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 05/20] qobject: Change qobject_to_json()'s value to GString
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 05/20] qobject: Change qobject_to_json()'s value to GString |
Date: |
Wed, 24 Mar 2021 09:14:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Thomas Huth <thuth@redhat.com> writes:
> On 11/12/2020 18.11, Markus Armbruster wrote:
>> qobject_to_json() and qobject_to_json_pretty() build a GString, then
>> covert it to QString. Just one of the callers actually needs a
>> QString: qemu_rbd_parse_filename(). A few others need a string they
>> can modify: qmp_send_response(), qga's send_response(), to_json_str(),
>> and qmp_fd_vsend_fds(). The remainder just need a string.
>> Change qobject_to_json() and qobject_to_json_pretty() to return the
>> GString.
>> qemu_rbd_parse_filename() now has to convert to QString. All others
>> save a QString temporary. to_json_str() actually becomes a bit
>> simpler, because GString provides more convenient modification
>> functions.
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Hi Markus!
>
> This patch broke the output of default values in the device help. With
> commit eab3a4678b07267c39e72:
>
> $ ./qemu-system-x86_64 -device pvpanic,help
> pvpanic options:
> events=<uint8> - (default: (null))
> ioport=<uint16> - (default: (null))
> pvpanic[0]=<child<qemu:memory-region>>
>
> With the commit right before that one:
>
> $ ./qemu-system-x86_64 -device pvpanic,help
> pvpanic options:
> events=<uint8> - (default: 3)
> ioport=<uint16> - (default: 1285)
> pvpanic[0]=<child<qemu:memory-region>>
>
> Any ideas how to fix that?
Yes:
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index c3324b0f86..bd8a947a63 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -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);
}
I'll post a proper patch. Sorry for the dumb mistake, and thanks for
pinpointing the commit!