From: Laszlo Ersek <lersek@redhat.com>
To: qemu devel list <qemu-devel@nongnu.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Ben Warren <ben@skyportsystems.com>,
Igor Mammedov <imammedo@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH v2 2/2] hw/acpi/vmgenid: prevent more than one vmgenid device
Date: Mon, 20 Mar 2017 18:05:57 +0100 [thread overview]
Message-ID: <20170320170557.15645-3-lersek@redhat.com> (raw)
In-Reply-To: <20170320170557.15645-1-lersek@redhat.com>
A system with multiple VMGENID devices is undefined in the VMGENID spec by
omission.
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Ben Warren <ben@skyportsystems.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
Notes:
v2:
- use find_vmgenid_dev() rather than open-code
object_resolve_path_type() [Michael]
- add comments to both the definition of find_vmgenid_dev() and its call
site in vmgenid_realize() [Michael]
include/hw/acpi/vmgenid.h | 1 +
hw/acpi/vmgenid.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/include/hw/acpi/vmgenid.h b/include/hw/acpi/vmgenid.h
index 8578476baebe..7beb9592fb01 100644
--- a/include/hw/acpi/vmgenid.h
+++ b/include/hw/acpi/vmgenid.h
@@ -24,6 +24,7 @@ typedef struct VmGenIdState {
bool write_pointer_available;
} VmGenIdState;
+/* returns NULL unless there is exactly one device */
static inline Object *find_vmgenid_dev(void)
{
return object_resolve_path_type("", VMGENID_DEVICE, NULL);
diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c
index c3ddcc8e7cb0..a32b847fe0df 100644
--- a/hw/acpi/vmgenid.c
+++ b/hw/acpi/vmgenid.c
@@ -221,6 +221,14 @@ static void vmgenid_realize(DeviceState *dev, Error **errp)
return;
}
+ /* Given that this function is executing, there is at least one VMGENID
+ * device. Check if there are several.
+ */
+ if (!find_vmgenid_dev()) {
+ error_setg(errp, "at most one %s device is permitted", VMGENID_DEVICE);
+ return;
+ }
+
qemu_register_reset(vmgenid_handle_reset, vms);
}
--
2.9.3
next prev parent reply other threads:[~2017-03-20 17:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 17:05 [Qemu-devel] [PATCH v2 0/2] some remaining vmgenid tweaks for 2.9 Laszlo Ersek
2017-03-20 17:05 ` [Qemu-devel] [PATCH v2 1/2] hw/acpi/vmgenid: prevent device realization on pre-2.5 machine types Laszlo Ersek
2017-03-21 12:13 ` Igor Mammedov
2017-03-22 0:53 ` Ben Warren
2017-03-20 17:05 ` Laszlo Ersek [this message]
2017-03-20 23:41 ` [Qemu-devel] [PATCH v2 2/2] hw/acpi/vmgenid: prevent more than one vmgenid device Ben Warren
2017-03-21 12:14 ` Igor Mammedov
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=20170320170557.15645-3-lersek@redhat.com \
--to=lersek@redhat.com \
--cc=ben@skyportsystems.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--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).