aboutsummaryrefslogtreecommitdiff
path: root/hw/i386
diff options
context:
space:
mode:
authorLiran Alon <liran.alon@oracle.com>2020-03-12 18:54:24 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-06-10 12:09:47 -0400
commitaaacf1c15a225ffeb1ff066b78e211594b3a5053 (patch)
treef2237701b60861cbad3ee3b96f6d6154604e3d9b /hw/i386
parentdcd938f032d3cca5d33d9faaca591b498d40debe (diff)
downloadqemu-aaacf1c15a225ffeb1ff066b78e211594b3a5053.zip
qemu-aaacf1c15a225ffeb1ff066b78e211594b3a5053.tar.gz
qemu-aaacf1c15a225ffeb1ff066b78e211594b3a5053.tar.bz2
hw/i386/vmport: Add support for CMD_GETBIOSUUID
This is VMware documented functionallity that some guests rely on. Returns the BIOS UUID of the current virtual machine. Note that we also introduce a new compatability flag "x-cmds-v2" to make sure to expose new VMPort commands only to new machine-types. This flag will also be used by the following patches that will introduce additional VMPort commands. Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com> Signed-off-by: Liran Alon <liran.alon@oracle.com> Message-Id: <20200312165431.82118-10-liran.alon@oracle.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/i386')
-rw-r--r--hw/i386/vmport.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c
index 359cdef..8006ff9 100644
--- a/hw/i386/vmport.c
+++ b/hw/i386/vmport.c
@@ -32,6 +32,7 @@
#include "hw/isa/isa.h"
#include "hw/i386/vmport.h"
#include "hw/qdev-properties.h"
+#include "sysemu/sysemu.h"
#include "sysemu/hw_accel.h"
#include "qemu/log.h"
#include "cpu.h"
@@ -43,12 +44,15 @@
#define VMPORT_COMPAT_READ_SET_EAX_BIT 0
#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT 1
#define VMPORT_COMPAT_REPORT_VMX_TYPE_BIT 2
+#define VMPORT_COMPAT_CMDS_V2_BIT 3
#define VMPORT_COMPAT_READ_SET_EAX \
(1 << VMPORT_COMPAT_READ_SET_EAX_BIT)
#define VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD \
(1 << VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT)
#define VMPORT_COMPAT_REPORT_VMX_TYPE \
(1 << VMPORT_COMPAT_REPORT_VMX_TYPE_BIT)
+#define VMPORT_COMPAT_CMDS_V2 \
+ (1 << VMPORT_COMPAT_CMDS_V2_BIT)
#define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT)
@@ -143,6 +147,18 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)
return port_state->vmware_vmx_version;
}
+static uint32_t vmport_cmd_get_bios_uuid(void *opaque, uint32_t addr)
+{
+ X86CPU *cpu = X86_CPU(current_cpu);
+ uint32_t *uuid_parts = (uint32_t *)(qemu_uuid.data);
+
+ cpu->env.regs[R_EAX] = le32_to_cpu(uuid_parts[0]);
+ cpu->env.regs[R_EBX] = le32_to_cpu(uuid_parts[1]);
+ cpu->env.regs[R_ECX] = le32_to_cpu(uuid_parts[2]);
+ cpu->env.regs[R_EDX] = le32_to_cpu(uuid_parts[3]);
+ return cpu->env.regs[R_EAX];
+}
+
static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
{
X86CPU *cpu = X86_CPU(current_cpu);
@@ -170,9 +186,13 @@ static void vmport_realizefn(DeviceState *dev, Error **errp)
isa_register_ioport(isadev, &s->io, 0x5658);
port_state = s;
+
/* Register some generic port commands */
vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL);
vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL);
+ if (s->compat_flags & VMPORT_COMPAT_CMDS_V2) {
+ vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL);
+ }
}
static Property vmport_properties[] = {
@@ -183,6 +203,8 @@ static Property vmport_properties[] = {
VMPORT_COMPAT_SIGNAL_UNSUPPORTED_CMD_BIT, true),
DEFINE_PROP_BIT("x-report-vmx-type", VMPortState, compat_flags,
VMPORT_COMPAT_REPORT_VMX_TYPE_BIT, true),
+ DEFINE_PROP_BIT("x-cmds-v2", VMPortState, compat_flags,
+ VMPORT_COMPAT_CMDS_V2_BIT, true),
/* Default value taken from open-vm-tools code VERSION_MAGIC definition */
DEFINE_PROP_UINT32("vmware-vmx-version", VMPortState,