Skip to content

Commit

Permalink
hw/acpi/vmgenid: prevent more than one vmgenid device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lersek authored and mstsirkin committed Mar 22, 2017
1 parent f2a1ae4 commit f920630
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hw/acpi/vmgenid.c
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions include/hw/acpi/vmgenid.h
Expand Up @@ -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);
Expand Down

0 comments on commit f920630

Please sign in to comment.