Skip to contentSkip to conversation

Virtual Machine Generation ID

PATCH Applied Gal Hammer 5 participants 14 messages Sep 17, 2014 – Oct 6, 2014

v5 of 16 Applied Latest is v16 →

lore
Share & tools
lore

Gal Hammer

author
#0 lore raw

v5 cover Virtual Machine Generation ID

Hi,

A two parts patch to add a QEmu support for Microsoft's Virtual Machine Generation ID device.

The first one add a new ACPI directive which allow to use a 16-bytes buffer in an ACPI table. This buffer is for storing the VM's UUID.

The second is the ACPI tables changes and the actual device.

Your comment are welcomed.

Thanks,

Gal.

V5: - include the pre-compiled ASL file
- remove an empty line at end of files.

V4: - Move device's description to SSDT table (dynamic build).

V3: - Fix a typo in error message string.
- Move device's description from DSDT back to SSDT table.

V2: - Remove "-uuid" command line parameter.
- Move device's description from SSDT to DSDT table.
- Add new "vmgenid" sysbus device.

Gal Hammer (2):
i386: Add an ACPI_EXTRACT_NAME_BUFFER16 directive.
i386: Add a Virtual Machine Generation ID device.

 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/i386/Makefile.objs              |   2 +-
 hw/i386/acpi-build.c               |  39 +++++++
 hw/i386/ssdt-vmgenid.dsl           |  63 ++++++++++++
 hw/i386/ssdt-vmgenid.hex.generated | 206 +++++++++++++++++++++++++++++++++++++
 hw/misc/Makefile.objs              |   1 +
 hw/misc/vmgenid.c                  |  84 +++++++++++++++
 include/hw/i386/pc.h               |   3 +
 scripts/acpi_extract.py            |  23 +++--
 10 files changed, 413 insertions(+), 10 deletions(-)
 create mode 100644 hw/i386/ssdt-vmgenid.dsl
 create mode 100644 hw/i386/ssdt-vmgenid.hex.generated
 create mode 100644 hw/misc/vmgenid.c
Signature · 1 line
1.9.3
author
#1 lore raw

PATCH v5 1/2 i386: Add an ACPI_EXTRACT_NAME_BUFFER16 directive.

Add a 16-bytes buffer to allow storing a 128-bit UUID value in an ACPI table.

---
 scripts/acpi_extract.py | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
scripts/acpi_extract.py +14 -9
index 22ea468..10c1ffb 100755
@@ -139,13 +139,16 @@ def aml_name_string(offset):
         offset += 1
     return offset;
 
-# Given data offset, find 8 byte buffer offset
-def aml_data_buffer8(offset):
-    #0x08 NameOp NameString DataRef
-    expect = [0x11, 0x0B, 0x0A, 0x08]
+# Given data offset, find variable length byte buffer offset
+def aml_data_buffer(offset, length):
+    #0x11 PkgLength BufferSize ByteList
+    if (length > 63):
+        die( "Name offset 0x%x: expected a one byte PkgLength (length<=63)" %
+             (offset));
+    expect = [0x11, length+3, 0x0A, length]
     if (aml[offset:offset+4] != expect):
         die( "Name offset 0x%x: expected %s actual %s" %
-             (offset, aml[offset:offset+4], expect))
+             (offset, expect, aml[offset:offset+4]))
     return offset + len(expect)
 
 # Given data offset, find dword const offset
@@ -172,9 +175,9 @@ def aml_data_byte_const(offset):
              (offset, aml[offset]));
     return offset + 1;
 
-# Find name'd buffer8
-def aml_name_buffer8(offset):
-    return aml_data_buffer8(aml_name_string(offset) + 4)
+# Find name'd buffer
+def aml_name_buffer(offset, length):
+    return aml_data_buffer(aml_name_string(offset) + 4, length)
 
 # Given name offset, find dword const offset
 def aml_name_dword_const(offset):
@@ -308,7 +311,9 @@ for i in range(len(asl)):
         output[array] = aml
         continue
     if (directive == "ACPI_EXTRACT_NAME_BUFFER8"):
-        offset = aml_name_buffer8(offset)
+        offset = aml_name_buffer(offset, 8)
+    elif (directive == "ACPI_EXTRACT_NAME_BUFFER16"):
+        offset = aml_name_buffer(offset, 16)
     elif (directive == "ACPI_EXTRACT_NAME_DWORD_CONST"):
         offset = aml_name_dword_const(offset)
     elif (directive == "ACPI_EXTRACT_NAME_WORD_CONST"):
Signature · 1 line
1.9.3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] i386: Add an ACPI_EXTRACT_NAME_BUFFER16 directive.

Quoted 5 lines · Gal Hammer

Add a 16-bytes buffer to allow storing a 128-bit UUID value in an ACPI table.

This one looks good. Applied, thanks!

Quoted 57 lines
---
 scripts/acpi_extract.py | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
scripts/acpi_extract.py +14 -9
index 22ea468..10c1ffb 100755
@@ -139,13 +139,16 @@ def aml_name_string(offset):
         offset += 1
     return offset;
 
-# Given data offset, find 8 byte buffer offset
-def aml_data_buffer8(offset):
-    #0x08 NameOp NameString DataRef
-    expect = [0x11, 0x0B, 0x0A, 0x08]
+# Given data offset, find variable length byte buffer offset
+def aml_data_buffer(offset, length):
+    #0x11 PkgLength BufferSize ByteList
+    if (length > 63):
+        die( "Name offset 0x%x: expected a one byte PkgLength (length<=63)" %
+             (offset));
+    expect = [0x11, length+3, 0x0A, length]
     if (aml[offset:offset+4] != expect):
         die( "Name offset 0x%x: expected %s actual %s" %
-             (offset, aml[offset:offset+4], expect))
+             (offset, expect, aml[offset:offset+4]))
     return offset + len(expect)
 
 # Given data offset, find dword const offset
@@ -172,9 +175,9 @@ def aml_data_byte_const(offset):
              (offset, aml[offset]));
     return offset + 1;
 
-# Find name'd buffer8
-def aml_name_buffer8(offset):
-    return aml_data_buffer8(aml_name_string(offset) + 4)
+# Find name'd buffer
+def aml_name_buffer(offset, length):
+    return aml_data_buffer(aml_name_string(offset) + 4, length)
 
 # Given name offset, find dword const offset
 def aml_name_dword_const(offset):
@@ -308,7 +311,9 @@ for i in range(len(asl)):
         output[array] = aml
         continue
     if (directive == "ACPI_EXTRACT_NAME_BUFFER8"):
-        offset = aml_name_buffer8(offset)
+        offset = aml_name_buffer(offset, 8)
+    elif (directive == "ACPI_EXTRACT_NAME_BUFFER16"):
+        offset = aml_name_buffer(offset, 16)
     elif (directive == "ACPI_EXTRACT_NAME_DWORD_CONST"):
         offset = aml_name_dword_const(offset)
     elif (directive == "ACPI_EXTRACT_NAME_WORD_CONST"):
Signature · 1 line
1.9.3
author
#3 lore raw

PATCH v5 2/2 i386: Add a Virtual Machine Generation ID device.

In reply to Gal Hammer

Based on Microsoft's sepecifications (paper can be dowloaded from
http://go.microsoft.com/fwlink/?LinkId=260709), add a device description to the SSDT ACPI table.

The GUID is set using a new "vmgenid" device.

---
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/i386/Makefile.objs              |   2 +-
 hw/i386/acpi-build.c               |  39 +++++++
 hw/i386/ssdt-vmgenid.dsl           |  63 ++++++++++++
 hw/i386/ssdt-vmgenid.hex.generated | 206 +++++++++++++++++++++++++++++++++++++
 hw/misc/Makefile.objs              |   1 +
 hw/misc/vmgenid.c                  |  84 +++++++++++++++
 include/hw/i386/pc.h               |   3 +
 9 files changed, 399 insertions(+), 1 deletion(-)
 create mode 100644 hw/i386/ssdt-vmgenid.dsl
 create mode 100644 hw/i386/ssdt-vmgenid.hex.generated
 create mode 100644 hw/misc/vmgenid.c
default-configs/i386-softmmu.mak +1 -0
index 8e08841..bd33c75 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
 CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
default-configs/x86_64-softmmu.mak +1 -0
index 66557ac..006fc7c 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
 CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
hw/i386/Makefile.objs +1 -1
index 9d419ad..cd1beb3 100644
@@ -12,7 +12,7 @@ hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \
 	hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \
 	hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \
 	hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \
-	hw/i386/ssdt-tpm.hex
+	hw/i386/ssdt-tpm.hex hw/i386/ssdt-vmgenid.hex
 
 iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
     ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/acpi-build.c +39 -0
index a313321..72d5a88 100644
@@ -96,6 +96,8 @@ typedef struct AcpiMiscInfo {
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
     uint16_t pvpanic_port;
+    bool vm_generation_id_set;
+    uint8_t vm_generation_id[16];
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -216,6 +218,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
     info->has_hpet = hpet_find();
     info->has_tpm = tpm_find();
     info->pvpanic_port = pvpanic_port();
+    info->vm_generation_id_set = vm_generation_id(info->vm_generation_id);
 }
 
 static void acpi_get_pci_info(PcPciInfo *info)
@@ -710,6 +713,7 @@ static inline char acpi_get_hex(uint32_t val)
 #include "hw/i386/ssdt-misc.hex"
 #include "hw/i386/ssdt-pcihp.hex"
 #include "hw/i386/ssdt-tpm.hex"
+#include "hw/i386/ssdt-vmgenid.hex"
 
 static void
 build_append_notify_method(GArray *device, const char *name,
@@ -1246,6 +1250,37 @@ build_tpm_ssdt(GArray *table_data, GArray *linker)
     memcpy(tpm_ptr, ssdt_tpm_aml, sizeof(ssdt_tpm_aml));
 }
 
+static void
+build_vmgenid_ssdt(GArray *table_data, GArray *linker, AcpiMiscInfo *info)
+{
+    int vgid_start = table_data->len;
+    void *vgid_ptr;
+    uint8_t *vm_gid_ptr;
+    uint32_t vm_gid_physical_address;
+
+    vgid_ptr = acpi_data_push(table_data, sizeof(ssdt_vmgenid_aml));
+    memcpy(vgid_ptr, ssdt_vmgenid_aml, sizeof(ssdt_vmgenid_aml));
+
+    vm_gid_ptr = acpi_data_get_ptr(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                                   *ssdt_acpi_vm_gid,
+                                   sizeof(info->vm_generation_id));
+    memcpy(vm_gid_ptr, info->vm_generation_id,
+           sizeof(info->vm_generation_id));
+
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
+                                   ACPI_BUILD_TABLE_FILE,
+                                   table_data,
+                                   vgid_ptr + *ssdt_acpi_vm_gid_addr,
+                                   sizeof(uint32_t));
+
+    vm_gid_physical_address = vgid_start + *ssdt_acpi_vm_gid;
+    ACPI_BUILD_SET_LE(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                      *ssdt_acpi_vm_gid_addr, 32, vm_gid_physical_address);
+
+    build_header(linker, table_data, vgid_ptr, "SSDT",
+                 sizeof(ssdt_vmgenid_aml), 1);
+}
+
 typedef enum {
     MEM_AFFINITY_NOFLAGS      = 0,
     MEM_AFFINITY_ENABLED      = (1 << 0),
@@ -1617,6 +1652,10 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
         acpi_add_table(table_offsets, tables->table_data);
         build_tpm_ssdt(tables->table_data, tables->linker);
     }
+    if (misc.vm_generation_id_set) {
+        acpi_add_table(table_offsets, tables->table_data);
+        build_vmgenid_ssdt(tables->table_data, tables->linker, &misc);
+    }
     if (guest_info->numa_nodes) {
         acpi_add_table(table_offsets, tables->table_data);
         build_srat(tables->table_data, tables->linker, &cpu, guest_info);
hw/i386/ssdt-vmgenid.dsl new file +63 -0

63 lines not on this page · raw message

hw/i386/ssdt-vmgenid.hex.generated new file +206 -0

206 lines not on this page · raw message

hw/misc/Makefile.objs +1 -0
index 979e532..c18b800 100644
@@ -41,3 +41,4 @@ obj-$(CONFIG_SLAVIO) += slavio_misc.o
 obj-$(CONFIG_ZYNQ) += zynq_slcr.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_VMGENID) += vmgenid.o
hw/misc/vmgenid.c new file +84 -0

84 lines not on this page · raw message

include/hw/i386/pc.h +3 -0
index 77316d5..40ecccb 100644
@@ -290,6 +290,9 @@ void pc_system_firmware_init(MemoryRegion *rom_memory,
 /* pvpanic.c */
 uint16_t pvpanic_port(void);
 
+/* vmgenid.c */
+bool vm_generation_id(uint8_t id[16]);
+
 /* e820 types */
 #define E820_RAM        1
 #define E820_RESERVED   2
Signature · 1 line
1.9.3
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] i386: Add a Virtual Machine Generation ID device.

Quoted 8 lines · Gal Hammer

Based on Microsoft's sepecifications (paper can be dowloaded from
http://go.microsoft.com/fwlink/?LinkId=260709), add a device description to the SSDT ACPI table.

The GUID is set using a new "vmgenid" device.

Quoted 10 lines
---
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/i386/Makefile.objs              |   2 +-
 hw/i386/acpi-build.c               |  39 +++++++
 hw/i386/ssdt-vmgenid.dsl           |  63 ++++++++++++
 hw/i386/ssdt-vmgenid.hex.generated | 206 +++++++++++++++++++++++++++++++++++++
 hw/misc/Makefile.objs              |   1 +
 hw/misc/vmgenid.c                  |  84 +++++++++++++++
 include/hw/i386/pc.h               |   3 +

Patch scripts/update-acpi.sh as well please.

Quoted 154 lines
 9 files changed, 399 insertions(+), 1 deletion(-)
 create mode 100644 hw/i386/ssdt-vmgenid.dsl
 create mode 100644 hw/i386/ssdt-vmgenid.hex.generated
 create mode 100644 hw/misc/vmgenid.c
default-configs/i386-softmmu.mak +1 -0
index 8e08841..bd33c75 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
 CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
default-configs/x86_64-softmmu.mak +1 -0
index 66557ac..006fc7c 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
 CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
hw/i386/Makefile.objs +1 -1
index 9d419ad..cd1beb3 100644
@@ -12,7 +12,7 @@ hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \
 	hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \
 	hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \
 	hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \
-	hw/i386/ssdt-tpm.hex
+	hw/i386/ssdt-tpm.hex hw/i386/ssdt-vmgenid.hex
 
 iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
     ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/acpi-build.c +39 -0
index a313321..72d5a88 100644
@@ -96,6 +96,8 @@ typedef struct AcpiMiscInfo {
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
     uint16_t pvpanic_port;
+    bool vm_generation_id_set;
+    uint8_t vm_generation_id[16];
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -216,6 +218,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
     info->has_hpet = hpet_find();
     info->has_tpm = tpm_find();
     info->pvpanic_port = pvpanic_port();
+    info->vm_generation_id_set = vm_generation_id(info->vm_generation_id);
 }
 
 static void acpi_get_pci_info(PcPciInfo *info)
@@ -710,6 +713,7 @@ static inline char acpi_get_hex(uint32_t val)
 #include "hw/i386/ssdt-misc.hex"
 #include "hw/i386/ssdt-pcihp.hex"
 #include "hw/i386/ssdt-tpm.hex"
+#include "hw/i386/ssdt-vmgenid.hex"
 
 static void
 build_append_notify_method(GArray *device, const char *name,
@@ -1246,6 +1250,37 @@ build_tpm_ssdt(GArray *table_data, GArray *linker)
     memcpy(tpm_ptr, ssdt_tpm_aml, sizeof(ssdt_tpm_aml));
 }
 
+static void
+build_vmgenid_ssdt(GArray *table_data, GArray *linker, AcpiMiscInfo *info)
+{
+    int vgid_start = table_data->len;
+    void *vgid_ptr;
+    uint8_t *vm_gid_ptr;
+    uint32_t vm_gid_physical_address;
+
+    vgid_ptr = acpi_data_push(table_data, sizeof(ssdt_vmgenid_aml));
+    memcpy(vgid_ptr, ssdt_vmgenid_aml, sizeof(ssdt_vmgenid_aml));
+
+    vm_gid_ptr = acpi_data_get_ptr(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                                   *ssdt_acpi_vm_gid,
+                                   sizeof(info->vm_generation_id));
+    memcpy(vm_gid_ptr, info->vm_generation_id,
+           sizeof(info->vm_generation_id));
+
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
+                                   ACPI_BUILD_TABLE_FILE,
+                                   table_data,
+                                   vgid_ptr + *ssdt_acpi_vm_gid_addr,
+                                   sizeof(uint32_t));
+
+    vm_gid_physical_address = vgid_start + *ssdt_acpi_vm_gid;
+    ACPI_BUILD_SET_LE(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                      *ssdt_acpi_vm_gid_addr, 32, vm_gid_physical_address);
+
+    build_header(linker, table_data, vgid_ptr, "SSDT",
+                 sizeof(ssdt_vmgenid_aml), 1);
+}
+
 typedef enum {
     MEM_AFFINITY_NOFLAGS      = 0,
     MEM_AFFINITY_ENABLED      = (1 << 0),
@@ -1617,6 +1652,10 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
         acpi_add_table(table_offsets, tables->table_data);
         build_tpm_ssdt(tables->table_data, tables->linker);
     }
+    if (misc.vm_generation_id_set) {
+        acpi_add_table(table_offsets, tables->table_data);
+        build_vmgenid_ssdt(tables->table_data, tables->linker, &misc);
+    }
     if (guest_info->numa_nodes) {
         acpi_add_table(table_offsets, tables->table_data);
         build_srat(tables->table_data, tables->linker, &cpu, guest_info);
hw/i386/ssdt-vmgenid.dsl new file +34 -0
new file mode 100644
index 0000000..fee376f
@@ -0,0 +1,63 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/****************************************************************
+ * Virtual Machine Generation ID Device
+ ****************************************************************/
+
+ACPI_EXTRACT_ALL_CODE ssdt_vmgenid_aml
+
+DefinitionBlock (
+    "ssdt-vmgenid.aml", // Output Filename
+    "SSDT",             // Signature
+    0x01,               // SSDT Compliance Revision
+    "BXPC",             // OEMID
+    "BXSSDTSUSP",       // TABLE ID
+    0x1                 // OEM Revision
+    )
+{
+    Scope(\_SB) {
+
+        Device(VMGI) {
+            Name(_HID, "QEMU0002")

hw/i386/ssdt-vmgenid.dsl line 44

Quoted 10 lines
hw/i386/ssdt-vmgenid.dsl new file +10 -0
+            Name(_CID, "VM_Gen_Counter")
+            Name(_DDN, "VM_Gen_Counter")
+
+            ACPI_EXTRACT_NAME_DWORD_CONST ssdt_acpi_vm_gid_addr
+            Name(VGIA, 0x12345678)
+
+            ACPI_EXTRACT_NAME_BUFFER16 ssdt_acpi_vm_gid
+            Name(VGID, Buffer(16) {
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })

IMHO, statically allocating the ID in ACPI like this is a mistake.

For example, your guest might be in hybernation, in this case it will not re-read ACPI tables on boot.

Also - what guarantees that this buffer is 8 byte aligned?

Quoted 347 lines
hw/i386/ssdt-vmgenid.dsl new file +19 -0
+
+            Method(_STA, 0, NotSerialized) {
+                Store(VGIA, Local0)
+                If (LEqual(Local0, Zero)) {
+                    Return (0x00)
+                } Else {
+                    Return (0x0F)
+                }
+            }
+
+            Method(ADDR, 0, Serialized) {
+                Store(Package(2) { }, Local0)
+                Store(VGIA, Index(Local0, 0))
+                Store(0x0000, Index(Local0, 1))
+                return (Local0)
+            }
+        }
+    }
+}
hw/i386/ssdt-vmgenid.hex.generated new file +206 -0
new file mode 100644
index 0000000..e96cb36
@@ -0,0 +1,206 @@
+static unsigned char ssdt_vmgenid_aml[] = {
+0x53,
+0x53,
+0x44,
+0x54,
+0xc6,
+0x0,
+0x0,
+0x0,
+0x1,
+0xeb,
+0x42,
+0x58,
+0x50,
+0x43,
+0x0,
+0x0,
+0x42,
+0x58,
+0x53,
+0x53,
+0x44,
+0x54,
+0x53,
+0x55,
+0x1,
+0x0,
+0x0,
+0x0,
+0x49,
+0x4e,
+0x54,
+0x4c,
+0x24,
+0x4,
+0x14,
+0x20,
+0x10,
+0x41,
+0xa,
+0x5c,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x5b,
+0x82,
+0x48,
+0x9,
+0x56,
+0x4d,
+0x47,
+0x49,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xd,
+0x51,
+0x45,
+0x4d,
+0x55,
+0x30,
+0x30,
+0x30,
+0x32,
+0x0,
+0x8,
+0x5f,
+0x43,
+0x49,
+0x44,
+0xd,
+0x56,
+0x4d,
+0x5f,
+0x47,
+0x65,
+0x6e,
+0x5f,
+0x43,
+0x6f,
+0x75,
+0x6e,
+0x74,
+0x65,
+0x72,
+0x0,
+0x8,
+0x5f,
+0x44,
+0x44,
+0x4e,
+0xd,
+0x56,
+0x4d,
+0x5f,
+0x47,
+0x65,
+0x6e,
+0x5f,
+0x43,
+0x6f,
+0x75,
+0x6e,
+0x74,
+0x65,
+0x72,
+0x0,
+0x8,
+0x56,
+0x47,
+0x49,
+0x41,
+0xc,
+0x78,
+0x56,
+0x34,
+0x12,
+0x8,
+0x56,
+0x47,
+0x49,
+0x44,
+0x11,
+0x13,
+0xa,
+0x10,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x14,
+0x18,
+0x5f,
+0x53,
+0x54,
+0x41,
+0x0,
+0x70,
+0x56,
+0x47,
+0x49,
+0x41,
+0x60,
+0xa0,
+0x6,
+0x93,
+0x60,
+0x0,
+0xa4,
+0x0,
+0xa1,
+0x4,
+0xa4,
+0xa,
+0xf,
+0x14,
+0x1c,
+0x41,
+0x44,
+0x44,
+0x52,
+0x8,
+0x70,
+0x12,
+0x2,
+0x2,
+0x60,
+0x70,
+0x56,
+0x47,
+0x49,
+0x41,
+0x88,
+0x60,
+0x0,
+0x0,
+0x70,
+0x0,
+0x88,
+0x60,
+0x1,
+0x0,
+0xa4,
+0x60
+};
+static unsigned char ssdt_acpi_vm_gid_addr[] = {
+0x73
+};
+static unsigned char ssdt_acpi_vm_gid[] = {
+0x80
+};
hw/misc/Makefile.objs +1 -0
index 979e532..c18b800 100644
@@ -41,3 +41,4 @@ obj-$(CONFIG_SLAVIO) += slavio_misc.o
 obj-$(CONFIG_ZYNQ) += zynq_slcr.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_VMGENID) += vmgenid.o
hw/misc/vmgenid.c new file +84 -0
new file mode 100644
index 0000000..81cc49e
@@ -0,0 +1,84 @@
+/*
+ *  Virtual Machine Generation ID Device
+ *
+ *  Copyright (C) 2014 Red Hat Inc.
+ *
+ *  Authors: Gal Hammer <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "hw/i386/pc.h"
+#include "hw/sysbus.h"
+
+#define VMGENID_DEVICE "vmgenid"
+
+#define PROPERTY_UUID "uuid"
+
+#define VMGENID(obj) OBJECT_CHECK(VmGenIdState, (obj), VMGENID_DEVICE)
+
+typedef struct VmGenIdState {
+    SysBusDevice parent_obj;
+    char *guid_arg;
+} VmGenIdState;
+
+bool vm_generation_id(uint8_t id[16])
+{
+    Object *o = object_resolve_path_type("", VMGENID_DEVICE, NULL);
+    char *guid;
+
+    if (!o) {
+        return false;
+    }
+    guid = object_property_get_str(o, PROPERTY_UUID, NULL);
+    /* actual uuid validation was checked during realize. */
+    (void)qemu_uuid_parse(guid, id);
+    return true;
+}
+
+static void vmgenid_realize(DeviceState *dev, Error **errp)
+{
+    VmGenIdState *s = VMGENID(dev);
+    uint8_t id[16];
+
+    if (!s->guid_arg) {
+        error_setg(errp, "missing uuid.");
+        return;
+    }
+
+    if (qemu_uuid_parse(s->guid_arg, id) < 0) {
+        error_setg(errp, "Fail to parse UUID string.");
+        return;
+    }
+}
+
+static Property vmgenid_device_properties[] = {
+    DEFINE_PROP_STRING(PROPERTY_UUID, VmGenIdState, guid_arg),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vmgenid_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = vmgenid_realize;
+    dc->props = vmgenid_device_properties;
+    dc->cannot_instantiate_with_device_add_yet = false;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
+static const TypeInfo vmgenid_device_info = {
+    .name          = VMGENID_DEVICE,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(VmGenIdState),
+    .class_init    = vmgenid_class_init,
+};
+
+static void vmgenid_register_types(void)
+{
+    type_register_static(&vmgenid_device_info);
+}
+
+type_init(vmgenid_register_types)
include/hw/i386/pc.h +3 -0
index 77316d5..40ecccb 100644
@@ -290,6 +290,9 @@ void pc_system_firmware_init(MemoryRegion *rom_memory,
 /* pvpanic.c */
 uint16_t pvpanic_port(void);
 
+/* vmgenid.c */
+bool vm_generation_id(uint8_t id[16]);
+
 /* e820 types */
 #define E820_RAM        1
 #define E820_RESERVED   2
Signature · 1 line
1.9.3
author
#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] i386: Add a Virtual Machine Generation ID device.

Quoted 20 lines · Michael S. Tsirkin
Quoted 8 lines · Gal Hammer

Based on Microsoft's sepecifications (paper can be dowloaded from
http://go.microsoft.com/fwlink/?LinkId=260709), add a device description to the SSDT ACPI table.

The GUID is set using a new "vmgenid" device.

Quoted 10 lines
---
  default-configs/i386-softmmu.mak   |   1 +
  default-configs/x86_64-softmmu.mak |   1 +
  hw/i386/Makefile.objs              |   2 +-
  hw/i386/acpi-build.c               |  39 +++++++
  hw/i386/ssdt-vmgenid.dsl           |  63 ++++++++++++
  hw/i386/ssdt-vmgenid.hex.generated | 206 +++++++++++++++++++++++++++++++++++++
  hw/misc/Makefile.objs              |   1 +
  hw/misc/vmgenid.c                  |  84 +++++++++++++++
  include/hw/i386/pc.h               |   3 +
Quoted 1 line

Patch scripts/update-acpi.sh as well please.

I understand what should be changed there. The script just copy all the *.hex files to *.hex.generated.

Quoted 158 lines
Quoted 158 lines
  9 files changed, 399 insertions(+), 1 deletion(-)

create mode 100644 hw/i386/ssdt-vmgenid.dsl create mode 100644 hw/i386/ssdt-vmgenid.hex.generated create mode 100644 hw/misc/vmgenid.c

default-configs/i386-softmmu.mak +1 -0
index 8e08841..bd33c75 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
  CONFIG_ICC_BUS=y
  CONFIG_PVPANIC=y
  CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
default-configs/x86_64-softmmu.mak +1 -0
index 66557ac..006fc7c 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
  CONFIG_ICC_BUS=y
  CONFIG_PVPANIC=y
  CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
hw/i386/Makefile.objs +1 -1
index 9d419ad..cd1beb3 100644
@@ -12,7 +12,7 @@ hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \
  	hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \
  	hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \
  	hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \
-	hw/i386/ssdt-tpm.hex
+	hw/i386/ssdt-tpm.hex hw/i386/ssdt-vmgenid.hex
 
  iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
      ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/acpi-build.c +39 -0
index a313321..72d5a88 100644
@@ -96,6 +96,8 @@ typedef struct AcpiMiscInfo {
      const unsigned char *dsdt_code;
      unsigned dsdt_size;
      uint16_t pvpanic_port;
+    bool vm_generation_id_set;
+    uint8_t vm_generation_id[16];
  } AcpiMiscInfo;
 
  typedef struct AcpiBuildPciBusHotplugState {
@@ -216,6 +218,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
      info->has_hpet = hpet_find();
      info->has_tpm = tpm_find();
      info->pvpanic_port = pvpanic_port();
+    info->vm_generation_id_set = vm_generation_id(info->vm_generation_id);
  }
 
  static void acpi_get_pci_info(PcPciInfo *info)
@@ -710,6 +713,7 @@ static inline char acpi_get_hex(uint32_t val)
  #include "hw/i386/ssdt-misc.hex"
  #include "hw/i386/ssdt-pcihp.hex"
  #include "hw/i386/ssdt-tpm.hex"
+#include "hw/i386/ssdt-vmgenid.hex"
 
  static void
  build_append_notify_method(GArray *device, const char *name,
@@ -1246,6 +1250,37 @@ build_tpm_ssdt(GArray *table_data, GArray *linker)
      memcpy(tpm_ptr, ssdt_tpm_aml, sizeof(ssdt_tpm_aml));
  }
 
+static void
+build_vmgenid_ssdt(GArray *table_data, GArray *linker, AcpiMiscInfo *info)
+{
+    int vgid_start = table_data->len;
+    void *vgid_ptr;
+    uint8_t *vm_gid_ptr;
+    uint32_t vm_gid_physical_address;
+
+    vgid_ptr = acpi_data_push(table_data, sizeof(ssdt_vmgenid_aml));
+    memcpy(vgid_ptr, ssdt_vmgenid_aml, sizeof(ssdt_vmgenid_aml));
+
+    vm_gid_ptr = acpi_data_get_ptr(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                                   *ssdt_acpi_vm_gid,
+                                   sizeof(info->vm_generation_id));
+    memcpy(vm_gid_ptr, info->vm_generation_id,
+           sizeof(info->vm_generation_id));
+
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
+                                   ACPI_BUILD_TABLE_FILE,
+                                   table_data,
+                                   vgid_ptr + *ssdt_acpi_vm_gid_addr,
+                                   sizeof(uint32_t));
+
+    vm_gid_physical_address = vgid_start + *ssdt_acpi_vm_gid;
+    ACPI_BUILD_SET_LE(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                      *ssdt_acpi_vm_gid_addr, 32, vm_gid_physical_address);
+
+    build_header(linker, table_data, vgid_ptr, "SSDT",
+                 sizeof(ssdt_vmgenid_aml), 1);
+}
+
  typedef enum {
      MEM_AFFINITY_NOFLAGS      = 0,
      MEM_AFFINITY_ENABLED      = (1 << 0),
@@ -1617,6 +1652,10 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
          acpi_add_table(table_offsets, tables->table_data);
          build_tpm_ssdt(tables->table_data, tables->linker);
      }
+    if (misc.vm_generation_id_set) {
+        acpi_add_table(table_offsets, tables->table_data);
+        build_vmgenid_ssdt(tables->table_data, tables->linker, &misc);
+    }
      if (guest_info->numa_nodes) {
          acpi_add_table(table_offsets, tables->table_data);
          build_srat(tables->table_data, tables->linker, &cpu, guest_info);
hw/i386/ssdt-vmgenid.dsl new file +38 -0
new file mode 100644
index 0000000..fee376f
@@ -0,0 +1,63 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/****************************************************************
+ * Virtual Machine Generation ID Device
+ ****************************************************************/
+
+ACPI_EXTRACT_ALL_CODE ssdt_vmgenid_aml
+
+DefinitionBlock (
+    "ssdt-vmgenid.aml", // Output Filename
+    "SSDT",             // Signature
+    0x01,               // SSDT Compliance Revision
+    "BXPC",             // OEMID
+    "BXSSDTSUSP",       // TABLE ID
+    0x1                 // OEM Revision
+    )
+{
+    Scope(\_SB) {
+
+        Device(VMGI) {
+            Name(_HID, "QEMU0002")
+            Name(_CID, "VM_Gen_Counter")
+            Name(_DDN, "VM_Gen_Counter")
+
+            ACPI_EXTRACT_NAME_DWORD_CONST ssdt_acpi_vm_gid_addr
Quoted 8 lines

hw/i386/ssdt-vmgenid.dsl line 44

Quoted 6 lines
hw/i386/ssdt-vmgenid.dsl new file +6 -0
+            Name(VGIA, 0x12345678)
+
+            ACPI_EXTRACT_NAME_BUFFER16 ssdt_acpi_vm_gid
+            Name(VGID, Buffer(16) {
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })

IMHO, statically allocating the ID in ACPI like this is a mistake.

Do you have an idea where else it can be allocated? Since it is just an ACPI declared device without resources. A PCI device with a memory region looks over-kill just to have a known physical address.

Quoted 2 lines

For example, your guest might be in hybernation, in this case it will not re-read ACPI tables on boot.

In this case the VGID physical address should stay the same and only the value is updated. So I don't think should be a problem.

Quoted 1 line

Also - what guarantees that this buffer is 8 byte aligned?

The spec say nothing about the memory-alignment of the VGID's physical address. If the driver can't read an unaligned address I guess it can do a simple pointers calculation and read from the closest aligned address and beyond the VGID buffer, no?

Quoted 347 lines
Quoted 347 lines
hw/i386/ssdt-vmgenid.dsl new file +19 -0
+
+            Method(_STA, 0, NotSerialized) {
+                Store(VGIA, Local0)
+                If (LEqual(Local0, Zero)) {
+                    Return (0x00)
+                } Else {
+                    Return (0x0F)
+                }
+            }
+
+            Method(ADDR, 0, Serialized) {
+                Store(Package(2) { }, Local0)
+                Store(VGIA, Index(Local0, 0))
+                Store(0x0000, Index(Local0, 1))
+                return (Local0)
+            }
+        }
+    }
+}
hw/i386/ssdt-vmgenid.hex.generated new file +206 -0
new file mode 100644
index 0000000..e96cb36
@@ -0,0 +1,206 @@
+static unsigned char ssdt_vmgenid_aml[] = {
+0x53,
+0x53,
+0x44,
+0x54,
+0xc6,
+0x0,
+0x0,
+0x0,
+0x1,
+0xeb,
+0x42,
+0x58,
+0x50,
+0x43,
+0x0,
+0x0,
+0x42,
+0x58,
+0x53,
+0x53,
+0x44,
+0x54,
+0x53,
+0x55,
+0x1,
+0x0,
+0x0,
+0x0,
+0x49,
+0x4e,
+0x54,
+0x4c,
+0x24,
+0x4,
+0x14,
+0x20,
+0x10,
+0x41,
+0xa,
+0x5c,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x5b,
+0x82,
+0x48,
+0x9,
+0x56,
+0x4d,
+0x47,
+0x49,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xd,
+0x51,
+0x45,
+0x4d,
+0x55,
+0x30,
+0x30,
+0x30,
+0x32,
+0x0,
+0x8,
+0x5f,
+0x43,
+0x49,
+0x44,
+0xd,
+0x56,
+0x4d,
+0x5f,
+0x47,
+0x65,
+0x6e,
+0x5f,
+0x43,
+0x6f,
+0x75,
+0x6e,
+0x74,
+0x65,
+0x72,
+0x0,
+0x8,
+0x5f,
+0x44,
+0x44,
+0x4e,
+0xd,
+0x56,
+0x4d,
+0x5f,
+0x47,
+0x65,
+0x6e,
+0x5f,
+0x43,
+0x6f,
+0x75,
+0x6e,
+0x74,
+0x65,
+0x72,
+0x0,
+0x8,
+0x56,
+0x47,
+0x49,
+0x41,
+0xc,
+0x78,
+0x56,
+0x34,
+0x12,
+0x8,
+0x56,
+0x47,
+0x49,
+0x44,
+0x11,
+0x13,
+0xa,
+0x10,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x14,
+0x18,
+0x5f,
+0x53,
+0x54,
+0x41,
+0x0,
+0x70,
+0x56,
+0x47,
+0x49,
+0x41,
+0x60,
+0xa0,
+0x6,
+0x93,
+0x60,
+0x0,
+0xa4,
+0x0,
+0xa1,
+0x4,
+0xa4,
+0xa,
+0xf,
+0x14,
+0x1c,
+0x41,
+0x44,
+0x44,
+0x52,
+0x8,
+0x70,
+0x12,
+0x2,
+0x2,
+0x60,
+0x70,
+0x56,
+0x47,
+0x49,
+0x41,
+0x88,
+0x60,
+0x0,
+0x0,
+0x70,
+0x0,
+0x88,
+0x60,
+0x1,
+0x0,
+0xa4,
+0x60
+};
+static unsigned char ssdt_acpi_vm_gid_addr[] = {
+0x73
+};
+static unsigned char ssdt_acpi_vm_gid[] = {
+0x80
+};
hw/misc/Makefile.objs +1 -0
index 979e532..c18b800 100644
@@ -41,3 +41,4 @@ obj-$(CONFIG_SLAVIO) += slavio_misc.o
  obj-$(CONFIG_ZYNQ) += zynq_slcr.o
 
  obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_VMGENID) += vmgenid.o
hw/misc/vmgenid.c new file +84 -0
new file mode 100644
index 0000000..81cc49e
@@ -0,0 +1,84 @@
+/*
+ *  Virtual Machine Generation ID Device
+ *
+ *  Copyright (C) 2014 Red Hat Inc.
+ *
+ *  Authors: Gal Hammer <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "hw/i386/pc.h"
+#include "hw/sysbus.h"
+
+#define VMGENID_DEVICE "vmgenid"
+
+#define PROPERTY_UUID "uuid"
+
+#define VMGENID(obj) OBJECT_CHECK(VmGenIdState, (obj), VMGENID_DEVICE)
+
+typedef struct VmGenIdState {
+    SysBusDevice parent_obj;
+    char *guid_arg;
+} VmGenIdState;
+
+bool vm_generation_id(uint8_t id[16])
+{
+    Object *o = object_resolve_path_type("", VMGENID_DEVICE, NULL);
+    char *guid;
+
+    if (!o) {
+        return false;
+    }
+    guid = object_property_get_str(o, PROPERTY_UUID, NULL);
+    /* actual uuid validation was checked during realize. */
+    (void)qemu_uuid_parse(guid, id);
+    return true;
+}
+
+static void vmgenid_realize(DeviceState *dev, Error **errp)
+{
+    VmGenIdState *s = VMGENID(dev);
+    uint8_t id[16];
+
+    if (!s->guid_arg) {
+        error_setg(errp, "missing uuid.");
+        return;
+    }
+
+    if (qemu_uuid_parse(s->guid_arg, id) < 0) {
+        error_setg(errp, "Fail to parse UUID string.");
+        return;
+    }
+}
+
+static Property vmgenid_device_properties[] = {
+    DEFINE_PROP_STRING(PROPERTY_UUID, VmGenIdState, guid_arg),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vmgenid_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = vmgenid_realize;
+    dc->props = vmgenid_device_properties;
+    dc->cannot_instantiate_with_device_add_yet = false;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
+static const TypeInfo vmgenid_device_info = {
+    .name          = VMGENID_DEVICE,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(VmGenIdState),
+    .class_init    = vmgenid_class_init,
+};
+
+static void vmgenid_register_types(void)
+{
+    type_register_static(&vmgenid_device_info);
+}
+
+type_init(vmgenid_register_types)
include/hw/i386/pc.h +3 -1
index 77316d5..40ecccb 100644
@@ -290,6 +290,9 @@ void pc_system_firmware_init(MemoryRegion *rom_memory,
  /* pvpanic.c */
  uint16_t pvpanic_port(void);
 
+/* vmgenid.c */
+bool vm_generation_id(uint8_t id[16]);
+
  /* e820 types */
  #define E820_RAM        1
  #define E820_RESERVED   2
--

1.9.3

#6 lore raw

Re: [Qemu-devel] [PATCH 2/2] i386: Add a Virtual Machine Generation ID device.

Quoted 193 lines · Gal Hammer
Quoted 20 lines · Michael S. Tsirkin
Quoted 8 lines · Gal Hammer

Based on Microsoft's sepecifications (paper can be dowloaded from
http://go.microsoft.com/fwlink/?LinkId=260709), add a device description to the SSDT ACPI table.

The GUID is set using a new "vmgenid" device.

Quoted 10 lines
---
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/i386/Makefile.objs              |   2 +-
 hw/i386/acpi-build.c               |  39 +++++++
 hw/i386/ssdt-vmgenid.dsl           |  63 ++++++++++++
 hw/i386/ssdt-vmgenid.hex.generated | 206 +++++++++++++++++++++++++++++++++++++
 hw/misc/Makefile.objs              |   1 +
 hw/misc/vmgenid.c                  |  84 +++++++++++++++
 include/hw/i386/pc.h               |   3 +
Quoted 1 line

Patch scripts/update-acpi.sh as well please.

I understand what should be changed there. The script just copy all the *.hex files to *.hex.generated.

Quoted 158 lines
Quoted 158 lines
 9 files changed, 399 insertions(+), 1 deletion(-)
 create mode 100644 hw/i386/ssdt-vmgenid.dsl
 create mode 100644 hw/i386/ssdt-vmgenid.hex.generated
 create mode 100644 hw/misc/vmgenid.c
default-configs/i386-softmmu.mak +1 -0
index 8e08841..bd33c75 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
 CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
default-configs/x86_64-softmmu.mak +1 -0
index 66557ac..006fc7c 100644
@@ -45,3 +45,4 @@ CONFIG_IOAPIC=y
 CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
+CONFIG_VMGENID=y
hw/i386/Makefile.objs +1 -1
index 9d419ad..cd1beb3 100644
@@ -12,7 +12,7 @@ hw/i386/acpi-build.o: hw/i386/acpi-build.c hw/i386/acpi-dsdt.hex \
 	hw/i386/ssdt-proc.hex hw/i386/ssdt-pcihp.hex hw/i386/ssdt-misc.hex \
 	hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \
 	hw/i386/q35-acpi-dsdt.hex hw/i386/ssdt-mem.hex \
-	hw/i386/ssdt-tpm.hex
+	hw/i386/ssdt-tpm.hex hw/i386/ssdt-vmgenid.hex
 
 iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
     ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/acpi-build.c +39 -0
index a313321..72d5a88 100644
@@ -96,6 +96,8 @@ typedef struct AcpiMiscInfo {
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
     uint16_t pvpanic_port;
+    bool vm_generation_id_set;
+    uint8_t vm_generation_id[16];
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -216,6 +218,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
     info->has_hpet = hpet_find();
     info->has_tpm = tpm_find();
     info->pvpanic_port = pvpanic_port();
+    info->vm_generation_id_set = vm_generation_id(info->vm_generation_id);
 }
 
 static void acpi_get_pci_info(PcPciInfo *info)
@@ -710,6 +713,7 @@ static inline char acpi_get_hex(uint32_t val)
 #include "hw/i386/ssdt-misc.hex"
 #include "hw/i386/ssdt-pcihp.hex"
 #include "hw/i386/ssdt-tpm.hex"
+#include "hw/i386/ssdt-vmgenid.hex"
 
 static void
 build_append_notify_method(GArray *device, const char *name,
@@ -1246,6 +1250,37 @@ build_tpm_ssdt(GArray *table_data, GArray *linker)
     memcpy(tpm_ptr, ssdt_tpm_aml, sizeof(ssdt_tpm_aml));
 }
 
+static void
+build_vmgenid_ssdt(GArray *table_data, GArray *linker, AcpiMiscInfo *info)
+{
+    int vgid_start = table_data->len;
+    void *vgid_ptr;
+    uint8_t *vm_gid_ptr;
+    uint32_t vm_gid_physical_address;
+
+    vgid_ptr = acpi_data_push(table_data, sizeof(ssdt_vmgenid_aml));
+    memcpy(vgid_ptr, ssdt_vmgenid_aml, sizeof(ssdt_vmgenid_aml));
+
+    vm_gid_ptr = acpi_data_get_ptr(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                                   *ssdt_acpi_vm_gid,
+                                   sizeof(info->vm_generation_id));
+    memcpy(vm_gid_ptr, info->vm_generation_id,
+           sizeof(info->vm_generation_id));
+
+    bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE,
+                                   ACPI_BUILD_TABLE_FILE,
+                                   table_data,
+                                   vgid_ptr + *ssdt_acpi_vm_gid_addr,
+                                   sizeof(uint32_t));
+
+    vm_gid_physical_address = vgid_start + *ssdt_acpi_vm_gid;
+    ACPI_BUILD_SET_LE(vgid_ptr, sizeof(ssdt_vmgenid_aml),
+                      *ssdt_acpi_vm_gid_addr, 32, vm_gid_physical_address);
+
+    build_header(linker, table_data, vgid_ptr, "SSDT",
+                 sizeof(ssdt_vmgenid_aml), 1);
+}
+
 typedef enum {
     MEM_AFFINITY_NOFLAGS      = 0,
     MEM_AFFINITY_ENABLED      = (1 << 0),
@@ -1617,6 +1652,10 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
         acpi_add_table(table_offsets, tables->table_data);
         build_tpm_ssdt(tables->table_data, tables->linker);
     }
+    if (misc.vm_generation_id_set) {
+        acpi_add_table(table_offsets, tables->table_data);
+        build_vmgenid_ssdt(tables->table_data, tables->linker, &misc);
+    }
     if (guest_info->numa_nodes) {
         acpi_add_table(table_offsets, tables->table_data);
         build_srat(tables->table_data, tables->linker, &cpu, guest_info);
hw/i386/ssdt-vmgenid.dsl new file +38 -0
new file mode 100644
index 0000000..fee376f
@@ -0,0 +1,63 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/****************************************************************
+ * Virtual Machine Generation ID Device
+ ****************************************************************/
+
+ACPI_EXTRACT_ALL_CODE ssdt_vmgenid_aml
+
+DefinitionBlock (
+    "ssdt-vmgenid.aml", // Output Filename
+    "SSDT",             // Signature
+    0x01,               // SSDT Compliance Revision
+    "BXPC",             // OEMID
+    "BXSSDTSUSP",       // TABLE ID
+    0x1                 // OEM Revision
+    )
+{
+    Scope(\_SB) {
+
+        Device(VMGI) {
+            Name(_HID, "QEMU0002")
+            Name(_CID, "VM_Gen_Counter")
+            Name(_DDN, "VM_Gen_Counter")
+
+            ACPI_EXTRACT_NAME_DWORD_CONST ssdt_acpi_vm_gid_addr
Quoted 8 lines

hw/i386/ssdt-vmgenid.dsl line 44

Quoted 6 lines
hw/i386/ssdt-vmgenid.dsl new file +6 -0
+            Name(VGIA, 0x12345678)
+
+            ACPI_EXTRACT_NAME_BUFFER16 ssdt_acpi_vm_gid
+            Name(VGID, Buffer(16) {
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })

IMHO, statically allocating the ID in ACPI like this is a mistake.

Quoted 3 lines

Do you have an idea where else it can be allocated? Since it is just an ACPI declared device without resources. A PCI device with a memory region looks over-kill just to have a known physical address.

I guess you can reserve some memory in E820, but that's pretty involved.

It might be a better idea to allocate buffer e.g. like TPM does, but fill the data in from hypervisor, by passing the physical address back to host. _INI might work for this.

Quoted 5 lines
Quoted 2 lines

For example, your guest might be in hybernation, in this case it will not re-read ACPI tables on boot.

In this case the VGID physical address should stay the same and only the value is updated. So I don't think should be a problem.

What will update the value? ACPI tables in qemu are ignored.

Quoted 354 lines
Quoted 1 line

Also - what guarantees that this buffer is 8 byte aligned?

The spec say nothing about the memory-alignment of the VGID's physical address.
If the driver can't read an unaligned address I guess it can do a simple pointers calculation and read from the closest aligned address and beyond the VGID buffer, no?

Quoted 347 lines
Quoted 347 lines
hw/i386/ssdt-vmgenid.dsl new file +19 -0
+
+            Method(_STA, 0, NotSerialized) {
+                Store(VGIA, Local0)
+                If (LEqual(Local0, Zero)) {
+                    Return (0x00)
+                } Else {
+                    Return (0x0F)
+                }
+            }
+
+            Method(ADDR, 0, Serialized) {
+                Store(Package(2) { }, Local0)
+                Store(VGIA, Index(Local0, 0))
+                Store(0x0000, Index(Local0, 1))
+                return (Local0)
+            }
+        }
+    }
+}
hw/i386/ssdt-vmgenid.hex.generated new file +206 -0
new file mode 100644
index 0000000..e96cb36
@@ -0,0 +1,206 @@
+static unsigned char ssdt_vmgenid_aml[] = {
+0x53,
+0x53,
+0x44,
+0x54,
+0xc6,
+0x0,
+0x0,
+0x0,
+0x1,
+0xeb,
+0x42,
+0x58,
+0x50,
+0x43,
+0x0,
+0x0,
+0x42,
+0x58,
+0x53,
+0x53,
+0x44,
+0x54,
+0x53,
+0x55,
+0x1,
+0x0,
+0x0,
+0x0,
+0x49,
+0x4e,
+0x54,
+0x4c,
+0x24,
+0x4,
+0x14,
+0x20,
+0x10,
+0x41,
+0xa,
+0x5c,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x5b,
+0x82,
+0x48,
+0x9,
+0x56,
+0x4d,
+0x47,
+0x49,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xd,
+0x51,
+0x45,
+0x4d,
+0x55,
+0x30,
+0x30,
+0x30,
+0x32,
+0x0,
+0x8,
+0x5f,
+0x43,
+0x49,
+0x44,
+0xd,
+0x56,
+0x4d,
+0x5f,
+0x47,
+0x65,
+0x6e,
+0x5f,
+0x43,
+0x6f,
+0x75,
+0x6e,
+0x74,
+0x65,
+0x72,
+0x0,
+0x8,
+0x5f,
+0x44,
+0x44,
+0x4e,
+0xd,
+0x56,
+0x4d,
+0x5f,
+0x47,
+0x65,
+0x6e,
+0x5f,
+0x43,
+0x6f,
+0x75,
+0x6e,
+0x74,
+0x65,
+0x72,
+0x0,
+0x8,
+0x56,
+0x47,
+0x49,
+0x41,
+0xc,
+0x78,
+0x56,
+0x34,
+0x12,
+0x8,
+0x56,
+0x47,
+0x49,
+0x44,
+0x11,
+0x13,
+0xa,
+0x10,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x0,
+0x14,
+0x18,
+0x5f,
+0x53,
+0x54,
+0x41,
+0x0,
+0x70,
+0x56,
+0x47,
+0x49,
+0x41,
+0x60,
+0xa0,
+0x6,
+0x93,
+0x60,
+0x0,
+0xa4,
+0x0,
+0xa1,
+0x4,
+0xa4,
+0xa,
+0xf,
+0x14,
+0x1c,
+0x41,
+0x44,
+0x44,
+0x52,
+0x8,
+0x70,
+0x12,
+0x2,
+0x2,
+0x60,
+0x70,
+0x56,
+0x47,
+0x49,
+0x41,
+0x88,
+0x60,
+0x0,
+0x0,
+0x70,
+0x0,
+0x88,
+0x60,
+0x1,
+0x0,
+0xa4,
+0x60
+};
+static unsigned char ssdt_acpi_vm_gid_addr[] = {
+0x73
+};
+static unsigned char ssdt_acpi_vm_gid[] = {
+0x80
+};
hw/misc/Makefile.objs +1 -0
index 979e532..c18b800 100644
@@ -41,3 +41,4 @@ obj-$(CONFIG_SLAVIO) += slavio_misc.o
 obj-$(CONFIG_ZYNQ) += zynq_slcr.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
+obj-$(CONFIG_VMGENID) += vmgenid.o
hw/misc/vmgenid.c new file +84 -0
new file mode 100644
index 0000000..81cc49e
@@ -0,0 +1,84 @@
+/*
+ *  Virtual Machine Generation ID Device
+ *
+ *  Copyright (C) 2014 Red Hat Inc.
+ *
+ *  Authors: Gal Hammer <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "hw/i386/pc.h"
+#include "hw/sysbus.h"
+
+#define VMGENID_DEVICE "vmgenid"
+
+#define PROPERTY_UUID "uuid"
+
+#define VMGENID(obj) OBJECT_CHECK(VmGenIdState, (obj), VMGENID_DEVICE)
+
+typedef struct VmGenIdState {
+    SysBusDevice parent_obj;
+    char *guid_arg;
+} VmGenIdState;
+
+bool vm_generation_id(uint8_t id[16])
+{
+    Object *o = object_resolve_path_type("", VMGENID_DEVICE, NULL);
+    char *guid;
+
+    if (!o) {
+        return false;
+    }
+    guid = object_property_get_str(o, PROPERTY_UUID, NULL);
+    /* actual uuid validation was checked during realize. */
+    (void)qemu_uuid_parse(guid, id);
+    return true;
+}
+
+static void vmgenid_realize(DeviceState *dev, Error **errp)
+{
+    VmGenIdState *s = VMGENID(dev);
+    uint8_t id[16];
+
+    if (!s->guid_arg) {
+        error_setg(errp, "missing uuid.");
+        return;
+    }
+
+    if (qemu_uuid_parse(s->guid_arg, id) < 0) {
+        error_setg(errp, "Fail to parse UUID string.");
+        return;
+    }
+}
+
+static Property vmgenid_device_properties[] = {
+    DEFINE_PROP_STRING(PROPERTY_UUID, VmGenIdState, guid_arg),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void vmgenid_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = vmgenid_realize;
+    dc->props = vmgenid_device_properties;
+    dc->cannot_instantiate_with_device_add_yet = false;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
+static const TypeInfo vmgenid_device_info = {
+    .name          = VMGENID_DEVICE,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(VmGenIdState),
+    .class_init    = vmgenid_class_init,
+};
+
+static void vmgenid_register_types(void)
+{
+    type_register_static(&vmgenid_device_info);
+}
+
+type_init(vmgenid_register_types)
include/hw/i386/pc.h +3 -1
index 77316d5..40ecccb 100644
@@ -290,6 +290,9 @@ void pc_system_firmware_init(MemoryRegion *rom_memory,
 /* pvpanic.c */
 uint16_t pvpanic_port(void);
 
+/* vmgenid.c */
+bool vm_generation_id(uint8_t id[16]);
+
 /* e820 types */
 #define E820_RAM        1
 #define E820_RESERVED   2
--

1.9.3

#7 lore raw
In reply to Gal Hammer

Did this get stuck?

Quoted 27 lines · Gal Hammer

Hi,

A two parts patch to add a QEmu support for Microsoft's Virtual Machine Generation ID device.

The first one add a new ACPI directive which allow to use a 16-bytes buffer in an ACPI table. This buffer is for storing the VM's UUID.

The second is the ACPI tables changes and the actual device.

Your comment are welcomed.

Thanks,

Gal.

V5: - include the pre-compiled ASL file
- remove an empty line at end of files.

V4: - Move device's description to SSDT table (dynamic build).

V3: - Fix a typo in error message string.
- Move device's description from DSDT back to SSDT table.

V2: - Remove "-uuid" command line parameter.
- Move device's description from SSDT to DSDT table.
- Add new "vmgenid" sysbus device.

author
#8 lore raw
Quoted 1 line · Markus Armbruster

Did this get stuck?

I think so. Did I miss a comment which was not handled in the last version of the patch?

Gal.

Quoted 29 lines
Quoted 27 lines · Gal Hammer

Hi,

A two parts patch to add a QEmu support for Microsoft's Virtual Machine Generation ID device.

The first one add a new ACPI directive which allow to use a 16-bytes buffer in an ACPI table. This buffer is for storing the VM's UUID.

The second is the ACPI tables changes and the actual device.

Your comment are welcomed.

Thanks,

Gal.

V5: - include the pre-compiled ASL file
- remove an empty line at end of files.

V4: - Move device's description to SSDT table (dynamic build).

V3: - Fix a typo in error message string.
- Move device's description from DSDT back to SSDT table.

V2: - Remove "-uuid" command line parameter.
- Move device's description from SSDT to DSDT table.
- Add new "vmgenid" sysbus device.

#9 lore raw
Quoted 7 lines · Gal Hammer
Quoted 1 line · Markus Armbruster

Did this get stuck?

I think so. Did I miss a comment which was not handled in the last version of the patch?

Gal.

I don't think you did but you have to Cc maintainers if you want your patches to be applied :) I'll queue this for review, thanks!

Quoted 30 lines
Quoted 29 lines
Quoted 27 lines · Gal Hammer

Hi,

A two parts patch to add a QEmu support for Microsoft's Virtual Machine Generation ID device.

The first one add a new ACPI directive which allow to use a 16-bytes buffer in an ACPI table. This buffer is for storing the VM's UUID.

The second is the ACPI tables changes and the actual device.

Your comment are welcomed.

Thanks,

Gal.

V5: - include the pre-compiled ASL file
- remove an empty line at end of files.

V4: - Move device's description to SSDT table (dynamic build).

V3: - Fix a typo in error message string.
- Move device's description from DSDT back to SSDT table.

V2: - Remove "-uuid" command line parameter.
- Move device's description from SSDT to DSDT table.
- Add new "vmgenid" sysbus device.

#10 lore raw
In reply to Gal Hammer
Quoted 8 lines · Gal Hammer

Hi,

A two parts patch to add a QEmu support for Microsoft's Virtual Machine Generation ID device.

The first one add a new ACPI directive which allow to use a 16-bytes buffer in an ACPI table. This buffer is for storing the VM's UUID.

Quoted 7 lines

The second is the ACPI tables changes and the actual device.

Your comment are welcomed.

Thanks,

Gal.

I applied this, thanks!

Quoted 34 lines

V5: - include the pre-compiled ASL file
- remove an empty line at end of files.

V4: - Move device's description to SSDT table (dynamic build).

V3: - Fix a typo in error message string.
- Move device's description from DSDT back to SSDT table.

V2: - Remove "-uuid" command line parameter.
- Move device's description from SSDT to DSDT table.
- Add new "vmgenid" sysbus device.

Gal Hammer (2):
i386: Add an ACPI_EXTRACT_NAME_BUFFER16 directive.
i386: Add a Virtual Machine Generation ID device.

 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/i386/Makefile.objs              |   2 +-
 hw/i386/acpi-build.c               |  39 +++++++
 hw/i386/ssdt-vmgenid.dsl           |  63 ++++++++++++
 hw/i386/ssdt-vmgenid.hex.generated | 206 +++++++++++++++++++++++++++++++++++++
 hw/misc/Makefile.objs              |   1 +
 hw/misc/vmgenid.c                  |  84 +++++++++++++++
 include/hw/i386/pc.h               |   3 +
 scripts/acpi_extract.py            |  23 +++--
 10 files changed, 413 insertions(+), 10 deletions(-)
 create mode 100644 hw/i386/ssdt-vmgenid.dsl
 create mode 100644 hw/i386/ssdt-vmgenid.hex.generated
 create mode 100644 hw/misc/vmgenid.c
Signature · 1 line
1.9.3
#11 lore raw
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Gal Hammer

Hi,

A two parts patch to add a QEmu support for Microsoft's Virtual Machine Generation ID device.

The first one add a new ACPI directive which allow to use a 16-bytes buffer in an ACPI table. This buffer is for storing the VM's UUID.

The second is the ACPI tables changes and the actual device.

Quoted 7 lines
Quoted 5 lines

Your comment are welcomed.

Thanks,

Gal.

I applied this, thanks!

Ooops wrong thread :(

I will review this now though.

Quoted 34 lines
Quoted 34 lines

V5: - include the pre-compiled ASL file
- remove an empty line at end of files.

V4: - Move device's description to SSDT table (dynamic build).

V3: - Fix a typo in error message string.
- Move device's description from DSDT back to SSDT table.

V2: - Remove "-uuid" command line parameter.
- Move device's description from SSDT to DSDT table.
- Add new "vmgenid" sysbus device.

Gal Hammer (2):
i386: Add an ACPI_EXTRACT_NAME_BUFFER16 directive.
i386: Add a Virtual Machine Generation ID device.

 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/i386/Makefile.objs              |   2 +-
 hw/i386/acpi-build.c               |  39 +++++++
 hw/i386/ssdt-vmgenid.dsl           |  63 ++++++++++++
 hw/i386/ssdt-vmgenid.hex.generated | 206 +++++++++++++++++++++++++++++++++++++
 hw/misc/Makefile.objs              |   1 +
 hw/misc/vmgenid.c                  |  84 +++++++++++++++
 include/hw/i386/pc.h               |   3 +
 scripts/acpi_extract.py            |  23 +++--
 10 files changed, 413 insertions(+), 10 deletions(-)
 create mode 100644 hw/i386/ssdt-vmgenid.dsl
 create mode 100644 hw/i386/ssdt-vmgenid.hex.generated
 create mode 100644 hw/misc/vmgenid.c
Signature · 1 line
1.9.3
#12 lore raw
In reply to Gal Hammer
Quoted 11 lines · Gal Hammer

Hi,

A two parts patch to add a QEmu support for Microsoft's Virtual Machine Generation ID device.

The first one add a new ACPI directive which allow to use a 16-bytes buffer in an ACPI table. This buffer is for storing the VM's UUID.

The second is the ACPI tables changes and the actual device.

Your comment are welcomed.

There are some rules on when the VM generation ID *must* change

Virtual machine is paused or resumed: No
Virtual machine reboots: No
Virtual machine host reboots: No
Virtual machine starts executing a snapshot (every time): Yes Virtual machine is recovered from backup: Yes
Virtual machine is failed over in a disaster recovery environment: Yes Virtual machine is live migrated: No
Virtual machine is imported, copied, or cloned: Yes
Virtual machine is failed over in a clustered environment: No Virtual machine's configuration changes: Unspecified

Now this can largely be accomplished by libvirt by simply changing the value of the -vmgenid command line parameter, because most of these scenarios involve the spawning of a new QEMU process. The exception I think is when a running guest is reverted to a previous snapshot, because that is done via a monitor command and not restarting QEMU. So for this VM Generation ID work to be considered complete we need to have a way to dynamically change the VM generation ID on the fly, atomatically with reverting snapshots from the POV of the guest. eg we must load the snapshot state, change the generation ID, and only then start CPUs again.

IOW I think this patch series is incomplete wrt the Microsoft spec on generation ID semantics.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#13 lore raw

Il 06/10/2014 11:06, Daniel P. Berrange ha scritto:

Quoted 11 lines

Now this can largely be accomplished by libvirt by simply changing the value of the -vmgenid command line parameter, because most of these scenarios involve the spawning of a new QEMU process. The exception I think is when a running guest is reverted to a previous snapshot, because that is done via a monitor command and not restarting QEMU. So for this VM Generation ID work to be considered complete we need to have a way to dynamically change the VM generation ID on the fly, atomatically with reverting snapshots from the POV of the guest. eg we must load the snapshot state, change the generation ID, and only then start CPUs again.

Quoted 2 lines

IOW I think this patch series is incomplete wrt the Microsoft spec on generation ID semantics.

I think this should not be a problem, as long as there is an idea of how to implement on-the-fly changes to the vmgenid.

Gal, do you know how to find back the address of the VM generation ID? Can we put the offset into the DSDT in the migration stream, and then find the ACPI tables in the f-segment at post_load time?

Paolo