From patchwork Fri Feb 17 12:50:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 9579735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 893E36049F for ; Fri, 17 Feb 2017 12:51:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A5E9277D9 for ; Fri, 17 Feb 2017 12:51:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ED2B286C8; Fri, 17 Feb 2017 12:51:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B2778277D9 for ; Fri, 17 Feb 2017 12:51:16 +0000 (UTC) Received: from localhost ([::1]:53292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cei0J-0002WQ-BX for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Feb 2017 07:51:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cehzs-0002Uy-LX for qemu-devel@nongnu.org; Fri, 17 Feb 2017 07:50:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cehzo-0002TY-D2 for qemu-devel@nongnu.org; Fri, 17 Feb 2017 07:50:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cehzn-0002Sg-Vl for qemu-devel@nongnu.org; Fri, 17 Feb 2017 07:50:44 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 069C83A7696; Fri, 17 Feb 2017 12:50:44 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-41.phx2.redhat.com [10.3.116.41]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1HCofg0018755; Fri, 17 Feb 2017 07:50:42 -0500 To: Igor Mammedov , ben@skyportsystems.com References: <88232638f9ff3b17b54987624468678ea14a3037.1487286467.git.ben@skyportsystems.com> <20170217114321.6c8577e1@nial.brq.redhat.com> From: Laszlo Ersek Message-ID: <918524f7-26cf-3fce-d9e3-7316ca69285b@redhat.com> Date: Fri, 17 Feb 2017 13:50:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20170217114321.6c8577e1@nial.brq.redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 17 Feb 2017 12:50:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH v8 4/8] ACPI: Add Virtual Machine Generation ID support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, "Dr. David Alan Gilbert \(git\)" , mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 >> >> 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 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 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; }