Skip to contentSkip to conversation

qom: Fix default values in help

PATCH In review Markus Armbruster 3 participants 3 messages Mar 24, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 eab3a4678b07267c39e7290a6e9e7690b1d2a521
---
 qom/object_interfaces.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qom/object_interfaces.c +1 -1
index c3324b0f86..bd8a947a63 100644
@@ -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);
     }
 
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Markus Armbruster

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.

Quoted 8 lines

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 eab3a4678b07267c39e7290a6e9e7690b1d2a521

---

Quoted 21 lines
 qom/object_interfaces.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qom/object_interfaces.c +1 -2
index c3324b0f86..bd8a947a63 100644
@@ -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);
     }
 
--

2.26.3

Reviewed-by on v1 1/1
#2 lore raw
In reply to Markus Armbruster
Quoted 31 lines · Markus Armbruster

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 eab3a4678b07267c39e7290a6e9e7690b1d2a521
---
  qom/object_interfaces.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
qom/object_interfaces.c +0 -0
index c3324b0f86..bd8a947a63 100644

qom/object_interfaces.c char *object_property_help(const char *name, const char *type, · line 165

Quoted 8 lines
qom/object_interfaces.c +1 -1
@@ -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);
      }