Skip to contentSkip to conversation

Bugfix: Handle error if VM Generation ID device not present

PATCH In review [email protected] 4 participants 4 messages Mar 2, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bugfix: Handle error if VM Generation ID device not present

From: Ben Warren <[email protected]>

This was crashing due to NULL-pointer dereference

QMP Test case:
==============

(QEMU) query-vm-generation-id
{"error": {"class": "GenericError", "desc": "VM Generation ID device not found"}}

HMP Test case:
==============
virsh # qemu-monitor-command --hmp 3 info vm-generation-id VM Generation ID device not found

---
 hmp.c             | 4 +++-
 hw/acpi/vmgenid.c | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
hmp.c +3 -1
index 261843f..edb8970 100644
@@ -2608,9 +2608,11 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
 
 void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
 {
-    GuidInfo *info = qmp_query_vm_generation_id(NULL);
+    Error *err = NULL;
+    GuidInfo *info = qmp_query_vm_generation_id(&err);
     if (info) {
         monitor_printf(mon, "%s\n", info->guid);
     }
+    hmp_handle_error(mon, &err);
     qapi_free_GuidInfo(info);
 }
hw/acpi/vmgenid.c +1 -0
index 744f284..7a3ad17 100644
@@ -248,6 +248,7 @@ GuidInfo *qmp_query_vm_generation_id(Error **errp)
     Object *obj = find_vmgenid_dev();
 
     if (!obj) {
+        error_setg(errp, "VM Generation ID device not found");
         return NULL;
     }
     vms = VMGENID(obj);
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · On 03/02/2017 03:36 PM, [email protected] wrote:

From: Ben Warren <[email protected]>

This was crashing due to NULL-pointer dereference

QMP Test case:
==============

(QEMU) query-vm-generation-id
{"error": {"class": "GenericError", "desc": "VM Generation ID device not found"}}

HMP Test case:
==============
virsh # qemu-monitor-command --hmp 3 info vm-generation-id VM Generation ID device not found

Quoted 5 lines
---
 hmp.c             | 4 +++-
 hw/acpi/vmgenid.c | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

However, hw/acpi/vmgenid.c is not part of the tree yet, so it may be better to just respin the pull request to incorporate this into the problematic patch that introduced the problem, rather than needing a followup patch.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 23 lines · Eric Blake
Quoted 16 lines · On 03/02/2017 03:36 PM, [email protected] wrote:

From: Ben Warren <[email protected]>

This was crashing due to NULL-pointer dereference

QMP Test case:
==============

(QEMU) query-vm-generation-id
{"error": {"class": "GenericError", "desc": "VM Generation ID device not found"}}

HMP Test case:
==============
virsh # qemu-monitor-command --hmp 3 info vm-generation-id VM Generation ID device not found

Quoted 5 lines
---
 hmp.c             | 4 +++-
 hw/acpi/vmgenid.c | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 11 lines

However, hw/acpi/vmgenid.c is not part of the tree yet, so it may be better to just respin the pull request to incorporate this into the problematic patch that introduced the problem, rather than needing a followup patch.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

The issue seems minor enough.
I don't plan to re-spin unless there are more issues.

Signature · 1 line
MST
Reviewed-by on v1 1/1
#3 lore raw
In reply to [email protected]
Quoted 45 lines · On 03/02/17 22:36, [email protected] wrote:

From: Ben Warren <[email protected]>

This was crashing due to NULL-pointer dereference

QMP Test case:
==============

(QEMU) query-vm-generation-id
{"error": {"class": "GenericError", "desc": "VM Generation ID device not found"}}

HMP Test case:
==============
virsh # qemu-monitor-command --hmp 3 info vm-generation-id VM Generation ID device not found

---
 hmp.c             | 4 +++-
 hw/acpi/vmgenid.c | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
hmp.c +3 -1
index 261843f..edb8970 100644
@@ -2608,9 +2608,11 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
 
 void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
 {
-    GuidInfo *info = qmp_query_vm_generation_id(NULL);
+    Error *err = NULL;
+    GuidInfo *info = qmp_query_vm_generation_id(&err);
     if (info) {
         monitor_printf(mon, "%s\n", info->guid);
     }
+    hmp_handle_error(mon, &err);
     qapi_free_GuidInfo(info);
 }
hw/acpi/vmgenid.c +0 -0
index 744f284..7a3ad17 100644

hw/acpi/vmgenid.c GuidInfo *qmp_query_vm_generation_id(Error **errp) · line 254

Quoted 7 lines
hw/acpi/vmgenid.c +1 -0
@@ -248,6 +248,7 @@ GuidInfo *qmp_query_vm_generation_id(Error **errp)
     Object *obj = find_vmgenid_dev();
 
     if (!obj) {
+        error_setg(errp, "VM Generation ID device not found");
         return NULL;
     }
     vms = VMGENID(obj);