Received: from [140.186.70.92] (port=36686 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PczWE-0006OB-Jo for qemu-devel@nongnu.org; Wed, 12 Jan 2011 07:09:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PczWD-0005Wk-JN for qemu-devel@nongnu.org; Wed, 12 Jan 2011 07:09:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PczWD-0005Wg-BQ for qemu-devel@nongnu.org; Wed, 12 Jan 2011 07:09:37 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0CC9anJ019675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Jan 2011 07:09:36 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [RESEND PATCH 1/2] qdev: Track runtime machine modifications References: <20110104192739.1909.73162.stgit@s20.home> <20110104193743.1909.65407.stgit@s20.home> Date: Wed, 12 Jan 2011 13:09:34 +0100 In-Reply-To: <20110104193743.1909.65407.stgit@s20.home> (Alex Williamson's message of "Tue, 04 Jan 2011 12:37:50 -0700") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: quintela@redhat.com, qemu-devel@nongnu.org, mst@redhat.com Alex Williamson writes: > 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 > Acked-by: Michael S. Tsirkin > Acked-by: Juan Quintela > --- > > 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 6fc9b02..e450c21 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; > @@ -294,6 +297,8 @@ int qdev_unplug(DeviceState *dev) > } > assert(dev->info->unplug != NULL); > > + qdev_hot_removed = true; > + > return dev->info->unplug(dev); > } > > @@ -394,6 +399,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) > { Why do you track add/remove separately, in qdev_hot_added and qdev_hot_removed? I don't mind, just curious. [...]