qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>, ben@skyportsystems.com
Cc: qemu-devel@nongnu.org, mst@redhat.com,
	"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v8 4/8] ACPI: Add Virtual Machine Generation ID support
Date: Fri, 17 Feb 2017 13:50:40 +0100	[thread overview]
Message-ID: <918524f7-26cf-3fce-d9e3-7316ca69285b@redhat.com> (raw)
In-Reply-To: <20170217114321.6c8577e1@nial.brq.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2225 bytes --]

CC Dave

On 02/17/17 11:43, Igor Mammedov wrote:
> On Thu, 16 Feb 2017 15:15:36 -0800
> ben@skyportsystems.com wrote:
> 
>> From: Ben Warren <ben@skyportsystems.com>
>>
>> This implements the VM Generation ID feature by passing a 128-bit
>> GUID to the guest via a fw_cfg blob.
>> Any time the GUID changes, an ACPI notify event is sent to the guest
>>
>> The user interface is a simple device with one parameter:
>>  - guid (string, must be "auto" or in UUID format
>>    xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
> I've given it some testing with WS2012R2 and v4 patches for Seabios,
> 
> Windows is able to read initial GUID allocation and writeback
> seems to work somehow:
> 
> (qemu) info vm-generation-id 
> c109c09b-0e8b-42d5-9b33-8409c9dcd16c
> 
> vmgenid client in Windows reads it as 2 following 64bit integers:
> 42d50e8bc109c09b:6cd1dcc90984339b
> 
> However update path/restore from snapshot doesn't
> here is as I've tested it:
> 
> qemu-system-x86_64 -device vmgenid,id=testvgid,guid=auto -monitor stdio
> (qemu) info vm-generation-id 
> c109c09b-0e8b-42d5-9b33-8409c9dcd16c
> (qemu) stop
> (qemu) migrate "exec:gzip -c > STATEFILE.gz" 
> (qemu) quit
> 
> qemu-system-x86_64 -device vmgenid,id=testvgid,guid=auto -monitor stdio
> -incoming "exec: gzip -c -d STATEFILE.gz"
> (qemu) info vm-generation-id 
> 28b587fa-991b-4267-80d7-9cf28b746fe9
> 
> guest
>  1. doesn't get GPE notification that it must receive
>  2. vmgenid client in Windows reads the same value
>       42d50e8bc109c09b:6cd1dcc90984339b

Hmmm, I wonder if we need something like this, in vmgenid_post_load():

commit 90c647db8d59e47c9000affc0d81754eb346e939
Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
Date:   Fri Apr 15 12:41:30 2016 +0100

    Fix pflash migration

with the idea being that in a single device's post_load callback, we
shouldn't perform machine-wide actions (post_load is likely for fixing
up the device itself). If machine-wide actions are necessary, we should
temporarily register a "vm change state handler", and do the thing once
that handler is called (when the machine has been loaded fully and is
about to continue execution).

Can you please try the attached patch on top? (Build tested only.)

Thanks!
Laszlo

[-- Attachment #2: vmstate_change.diff --]
[-- Type: text/x-patch, Size: 1605 bytes --]

diff --git a/include/hw/acpi/vmgenid.h b/include/hw/acpi/vmgenid.h
index db7fa0e63303..a2ae450b1f56 100644
--- a/include/hw/acpi/vmgenid.h
+++ b/include/hw/acpi/vmgenid.h
@@ -4,6 +4,7 @@
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/qdev.h"
 #include "qemu/uuid.h"
+#include "sysemu/sysemu.h"
 
 #define VMGENID_DEVICE           "vmgenid"
 #define VMGENID_GUID             "guid"
@@ -21,6 +22,7 @@ typedef struct VmGenIdState {
     DeviceClass parent_obj;
     QemuUUID guid;                /* The 128-bit GUID seen by the guest */
     uint8_t vmgenid_addr_le[8];   /* Address of the GUID (little-endian) */
+    VMChangeStateEntry *vmstate;
 } VmGenIdState;
 
 static inline Object *find_vmgenid_dev(void)
diff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c
index 9f97b722761b..0ae1d56ff297 100644
--- a/hw/acpi/vmgenid.c
+++ b/hw/acpi/vmgenid.c
@@ -177,10 +177,20 @@ static void vmgenid_set_guid(Object *obj, const char *value, Error **errp)
 /* After restoring an image, we need to update the guest memory and notify
  * it of a potential change to VM Generation ID
  */
+static void postload_update_guest_cb(void *opaque, int running, RunState state)
+{
+    VmGenIdState *vms = opaque;
+
+    qemu_del_vm_change_state_handler(vms->vmstate);
+    vms->vmstate = NULL;
+    vmgenid_update_guest(vms);
+}
+
 static int vmgenid_post_load(void *opaque, int version_id)
 {
     VmGenIdState *vms = opaque;
-    vmgenid_update_guest(vms);
+    vms->vmstate = qemu_add_vm_change_state_handler(postload_update_guest_cb,
+                                                    vms);
     return 0;
 }
 

  reply	other threads:[~2017-02-17 12:50 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-16 23:15 [Qemu-devel] [PATCH v8 0/8] Add support for VM Generation ID ben
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 1/8] linker-loader: Add new 'write pointer' command ben
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 2/8] docs: VM Generation ID device description ben
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 3/8] ACPI: Add vmgenid blob storage to the build tables ben
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 4/8] ACPI: Add Virtual Machine Generation ID support ben
2017-02-17 10:43   ` Igor Mammedov
2017-02-17 12:50     ` Laszlo Ersek [this message]
2017-02-17 13:05       ` Igor Mammedov
2017-02-17 13:41         ` Laszlo Ersek
2017-02-20 10:23       ` Dr. David Alan Gilbert
2017-02-20 10:40         ` Laszlo Ersek
2017-02-20 11:00           ` Dr. David Alan Gilbert
2017-02-20 11:38             ` Laszlo Ersek
2017-02-20 12:32               ` Dr. David Alan Gilbert
2017-02-20 15:35                 ` Laszlo Ersek
2017-02-20 13:13               ` Igor Mammedov
2017-02-20 13:28                 ` Laszlo Ersek
2017-02-20 14:40                   ` Igor Mammedov
2017-02-20 20:00         ` Eric Blake
2017-02-20 20:19           ` Dr. David Alan Gilbert
2017-02-20 20:45             ` Eric Blake
2017-02-20 20:55               ` Laszlo Ersek
2017-02-21  1:43                 ` Michael S. Tsirkin
2017-02-21  9:58                   ` Laszlo Ersek
2017-02-21 14:14                     ` Michael S. Tsirkin
2017-02-21 16:08                       ` Laszlo Ersek
2017-02-21 16:17                         ` Michael S. Tsirkin
2017-02-21 16:50                           ` Laszlo Ersek
2017-02-20 20:49             ` Laszlo Ersek
2017-02-17 15:33     ` Ben Warren
2017-02-17 16:03       ` Laszlo Ersek
2017-02-17 18:34         ` Ben Warren
2017-02-17 19:00           ` Michael S. Tsirkin
2017-02-17 20:42           ` Laszlo Ersek
2017-02-17 20:07         ` Laszlo Ersek
2017-02-18  0:15           ` Ben Warren
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 5/8] qmp/hmp: add query-vm-generation-id and 'info vm-generation-id' commands ben
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 6/8] tests: Move reusable ACPI code into a utility file ben
2017-02-20 14:49   ` Igor Mammedov
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 7/8] tests: Add unit tests for the VM Generation ID feature ben
2017-02-20 14:49   ` Igor Mammedov
2017-04-21 10:14     ` Marc-André Lureau
2017-04-21 17:59       ` Ben Warren
2017-04-24 12:28         ` Laszlo Ersek
2017-02-16 23:15 ` [Qemu-devel] [PATCH v8 8/8] MAINTAINERS: Add VM Generation ID entries ben
2017-02-20 14:50   ` Igor Mammedov
2017-02-20 14:57 ` [Qemu-devel] [PATCH v8 0/8] Add support for VM Generation ID Igor Mammedov
2017-02-20 15:41   ` Laszlo Ersek
2017-02-20 15:45     ` Kevin O'Connor
2017-02-20 16:00       ` Laszlo Ersek
2017-02-21  7:10       ` Gerd Hoffmann
2017-02-20 18:10     ` Ben Warren
2017-02-21 12:20   ` Laszlo Ersek

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=918524f7-26cf-3fce-d9e3-7316ca69285b@redhat.com \
    --to=lersek@redhat.com \
    --cc=ben@skyportsystems.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@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).