qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org, mst@redhat.com, quintela@redhat.com
Cc: pbonzini@redhat.com, alex.williamson@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] qdev: Track runtime machine modifications
Date: Thu, 16 Dec 2010 11:02:09 -0700	[thread overview]
Message-ID: <20101216180156.6420.97160.stgit@s20.home> (raw)
In-Reply-To: <20101216175516.6420.66081.stgit@s20.home>

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 <alex.williamson@redhat.com>
---

 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);

  reply	other threads:[~2010-12-16 18:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-16 18:01 [Qemu-devel] [PATCH 0/2] Fix rtl8139 migration with hotplug Alex Williamson
2010-12-16 18:02 ` Alex Williamson [this message]
2010-12-16 18:02 ` [Qemu-devel] [PATCH 2/2] rtl8139: Use subsection to restrict migration after hotplug Alex Williamson
2010-12-16 23:41 ` [Qemu-devel] Re: [PATCH 0/2] Fix rtl8139 migration with hotplug Michael S. Tsirkin
2010-12-17  1:35 ` Juan Quintela
2011-01-04 19:37 ` [Qemu-devel] [RESEND PATCH " Alex Williamson
2011-01-04 19:37   ` [Qemu-devel] [RESEND PATCH 1/2] qdev: Track runtime machine modifications Alex Williamson
2011-01-12 12:09     ` Markus Armbruster
2011-01-12 13:51       ` Alex Williamson
2011-01-04 19:38   ` [Qemu-devel] [RESEND PATCH 2/2] rtl8139: Use subsection to restrict migration after hotplug Alex Williamson
2011-01-05 10:13   ` [Qemu-devel] Re: [RESEND PATCH 0/2] Fix rtl8139 migration with hotplug Michael S. Tsirkin

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=20101216180156.6420.97160.stgit@s20.home \
    --to=alex.williamson@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).