]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/acpi/vmgenid: prevent more than one vmgenid device
authorLaszlo Ersek <lersek@redhat.com>
Mon, 20 Mar 2017 17:05:57 +0000 (18:05 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 22 Mar 2017 16:29:27 +0000 (18:29 +0200)
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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
hw/acpi/vmgenid.c
include/hw/acpi/vmgenid.h

index c3ddcc8e7cb0b971923ddb3644ef06ad92da6148..a32b847fe0dfb41b498ae721736f3ccb42fadfdd 100644 (file)
@@ -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);
 }
 
index 8578476baebebe13fb21eba79e16dbfe7a7fc984..7beb9592fb01b0a766bbe2be5b8bd9978f5850c9 100644 (file)
@@ -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);