Skip to contentSkip to conversation

hmp: fix crash in 'info block -n -v'

PATCH Applied Alberto Garcia 3 participants 3 messages Apr 17, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hmp: fix crash in 'info block -n -v'

The image field in BlockDeviceInfo should never be null, however bdrv_block_device_info() is not filling it in.

This makes the 'info block -n -v' command crash QEMU.

The proper solution is probably to move the relevant code from bdrv_query_info() to bdrv_block_device_info(), but since we're too close to the release for that this simpler workaround solves the crash.

---
 hmp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hmp.c +2 -1
index f31ae27..f142d36 100644
@@ -391,7 +391,8 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
                         inserted->iops_size);
     }
 
-    if (verbose) {
+    /* TODO: inserted->image should never be null */
+    if (verbose && inserted->image) {
         monitor_printf(mon, "\nImages:\n");
         image_info = inserted->image;
         while (1) {
Signature · 1 line
2.1.4
#1 lore raw
Quoted 11 lines · Alberto Garcia

The image field in BlockDeviceInfo should never be null, however bdrv_block_device_info() is not filling it in.

This makes the 'info block -n -v' command crash QEMU.

The proper solution is probably to move the relevant code from bdrv_query_info() to bdrv_block_device_info(), but since we're too close to the release for that this simpler workaround solves the crash.

Applied, thanks.

-- PMM

Reviewed-by on v1 1/1
#2 lore raw
In reply to Alberto Garcia
Quoted 10 lines · Alberto Garcia

The image field in BlockDeviceInfo should never be null, however bdrv_block_device_info() is not filling it in.

This makes the 'info block -n -v' command crash QEMU.

The proper solution is probably to move the relevant code from bdrv_query_info() to bdrv_block_device_info(), but since we're too close to the release for that this simpler workaround solves the crash.

Quoted 4 lines
---
 hmp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 16 lines
hmp.c +2 -1
index f31ae27..f142d36 100644
@@ -391,7 +391,8 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
                         inserted->iops_size);
     }
 
-    if (verbose) {
+    /* TODO: inserted->image should never be null */
+    if (verbose && inserted->image) {
         monitor_printf(mon, "\nImages:\n");
         image_info = inserted->image;
         while (1) {
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org