From patchwork Thu Dec 16 18:02:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 75791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A4507B6EF1 for ; Fri, 17 Dec 2010 05:53:33 +1100 (EST) Received: from localhost ([127.0.0.1]:51197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTIxF-0008Dw-Hh for incoming@patchwork.ozlabs.org; Thu, 16 Dec 2010 13:53:29 -0500 Received: from [140.186.70.92] (port=49084 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTIvJ-0007QF-I3 for qemu-devel@nongnu.org; Thu, 16 Dec 2010 13:51:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTIvI-0008Nn-7G for qemu-devel@nongnu.org; Thu, 16 Dec 2010 13:51:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTIvI-0008NQ-0J for qemu-devel@nongnu.org; Thu, 16 Dec 2010 13:51:28 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBGIpLV3015271 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 Dec 2010 13:51:27 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBGI2AFO030798; Thu, 16 Dec 2010 13:02:10 -0500 From: Alex Williamson To: qemu-devel@nongnu.org, mst@redhat.com, quintela@redhat.com Date: Thu, 16 Dec 2010 11:02:09 -0700 Message-ID: <20101216180156.6420.97160.stgit@s20.home> In-Reply-To: <20101216175516.6420.66081.stgit@s20.home> References: <20101216175516.6420.66081.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: pbonzini@redhat.com, alex.williamson@redhat.com Subject: [Qemu-devel] [PATCH 1/2] qdev: Track runtime machine modifications X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Create a trivial interface to track whether the machine has been modified since boot. Adding or removing devices will trigger this to return true. An example usage scenario for such an interface is the rtl8139 driver which includes a cpu_register_io_memory() value in it's migration stream. For the majority of migrations, where no hotplug has occured in the machine, this works correctly. Once the machine is modified, we can use this interface to detect that and include a subsection for the device to prevent migrations to rtl8139 versions with this bug. Signed-off-by: Alex Williamson --- hw/qdev.c | 10 ++++++++++ hw/qdev.h | 1 + 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 35858cb..e6e7a57 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -32,6 +32,8 @@ #include "blockdev.h" static int qdev_hotplug = 0; +static bool qdev_hot_added = false; +static bool qdev_hot_removed = false; /* This is a nasty hack to allow passing a NULL bus to qdev_create. */ static BusState *main_system_bus; @@ -93,6 +95,7 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) if (qdev_hotplug) { assert(bus->allow_hotplug); dev->hotplugged = 1; + qdev_hot_added = true; } dev->instance_id_alias = -1; dev->state = DEV_STATE_CREATED; @@ -305,6 +308,8 @@ int qdev_unplug(DeviceState *dev) } assert(dev->info->unplug != NULL); + qdev_hot_removed = true; + return dev->info->unplug(dev); } @@ -370,6 +375,11 @@ void qdev_machine_creation_done(void) qdev_hotplug = 1; } +bool qdev_machine_modified(void) +{ + return qdev_hot_added || qdev_hot_removed; +} + /* Get a character (serial) device interface. */ CharDriverState *qdev_init_chardev(DeviceState *dev) { diff --git a/hw/qdev.h b/hw/qdev.h index 579328a..66b8aee 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -123,6 +123,7 @@ int qdev_unplug(DeviceState *dev); void qdev_free(DeviceState *dev); int qdev_simple_unplug_cb(DeviceState *dev); void qdev_machine_creation_done(void); +bool qdev_machine_modified(void); qemu_irq qdev_get_gpio_in(DeviceState *dev, int n); void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);