From: ben@skyportsystems.com
To: qemu-devel@nongnu.org
Cc: lersek@redhat.com, mst@redhat.com, imammedo@redhat.com,
armbru@redhat.com, peter.maydell@linaro.org, dgilbert@redhat.com,
pbonzini@redhat.com, Ben Warren <ben@skyportsystems.com>
Subject: [Qemu-devel] [PATCH] Bugfix: Handle error if VM Generation ID device not present
Date: Thu, 2 Mar 2017 13:36:50 -0800 [thread overview]
Message-ID: <20170302213650.86211-1-ben@skyportsystems.com> (raw)
From: Ben Warren <ben@skyportsystems.com>
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
Signed-off-by: Ben Warren <ben@skyportsystems.com>
---
hmp.c | 4 +++-
hw/acpi/vmgenid.c | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/hmp.c b/hmp.c
index 261843f..edb8970 100644
--- a/hmp.c
+++ b/hmp.c
@@ -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);
}
diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c
index 744f284..7a3ad17 100644
--- a/hw/acpi/vmgenid.c
+++ b/hw/acpi/vmgenid.c
@@ -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);
--
2.7.4
next reply other threads:[~2017-03-02 21:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 21:36 ben [this message]
2017-03-02 21:41 ` [Qemu-devel] [PATCH] Bugfix: Handle error if VM Generation ID device not present Eric Blake
2017-03-02 21:45 ` Michael S. Tsirkin
2017-03-02 22:41 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170302213650.86211-1-ben@skyportsystems.com \
--to=ben@skyportsystems.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=imammedo@redhat.com \
--cc=lersek@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).