xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: QEMU-devel <qemu-devel@nongnu.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	Xen Devel <xen-devel@lists.xen.org>
Subject: [PATCH 2/4] qdev: Introduce qdev_force_unplug.
Date: Tue, 15 May 2012 16:26:37 +0100	[thread overview]
Message-ID: <1337095599-28836-3-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1337095599-28836-1-git-send-email-anthony.perard@citrix.com>

This function will be use to force a device to be ejected without the guest
cooperation.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 hw/qdev.c |   23 ++++++++++++++++++++---
 hw/qdev.h |    3 +++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 6a8f6bd..c95d4c2 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -184,24 +184,41 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
     dev->alias_required_for_version = required_for_version;
 }
 
-void qdev_unplug(DeviceState *dev, Error **errp)
+static void qdev_unplug_common(DeviceState *dev, Error **errp, bool force)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);
+    qdev_event unplug;
 
     if (!dev->parent_bus->allow_hotplug) {
         error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
         return;
     }
-    assert(dc->unplug != NULL);
+
+    if (force) {
+        unplug = dc->force_unplug;
+    } else {
+        unplug = dc->unplug;
+    }
+    assert(unplug != NULL);
 
     qdev_hot_removed = true;
 
-    if (dc->unplug(dev) < 0) {
+    if (unplug(dev) < 0) {
         error_set(errp, QERR_UNDEFINED_ERROR);
         return;
     }
 }
 
+void qdev_force_unplug(DeviceState *dev, Error **errp)
+{
+    qdev_unplug_common(dev, errp, true);
+}
+
+void qdev_unplug(DeviceState *dev, Error **errp)
+{
+    qdev_unplug_common(dev, errp, false);
+}
+
 static int qdev_reset_one(DeviceState *dev, void *opaque)
 {
     device_reset(dev);
diff --git a/hw/qdev.h b/hw/qdev.h
index 4e90119..404c560 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -54,6 +54,7 @@ typedef struct DeviceClass {
     /* Private to qdev / bus.  */
     qdev_initfn init;
     qdev_event unplug;
+    qdev_event force_unplug;
     qdev_event exit;
     BusInfo *bus_info;
 } DeviceClass;
@@ -150,6 +151,8 @@ void qdev_init_nofail(DeviceState *dev);
 void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
                                  int required_for_version);
 void qdev_unplug(DeviceState *dev, Error **errp);
+/* Unplug a device without the guest cooperation. */
+void qdev_force_unplug(DeviceState *dev, Error **errp);
 void qdev_free(DeviceState *dev);
 int qdev_simple_unplug_cb(DeviceState *dev);
 void qdev_machine_creation_done(void);
-- 
Anthony PERARD

  parent reply	other threads:[~2012-05-15 15:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1337095599-28836-1-git-send-email-anthony.perard@citrix.com>
2012-05-15 15:26 ` [PATCH 1/4] Introduce a new hotplug state: Force eject Anthony PERARD
2012-05-15 18:19   ` Stefano Stabellini
     [not found]   ` <alpine.DEB.2.00.1205151916440.26786@kaball-desktop>
2012-05-15 18:25     ` [Qemu-devel] " Anthony PERARD
2012-05-15 20:52   ` Michael S. Tsirkin
     [not found]   ` <20120515205222.GA12039@redhat.com>
2012-05-16 10:32     ` Stefano Stabellini
     [not found]     ` <alpine.DEB.2.00.1205161124090.26786@kaball-desktop>
2012-05-16 11:15       ` [Qemu-devel] " Anthony PERARD
     [not found]       ` <CAJJyHjKHn5HA6y0B8oHP7o2W=6_wd-0vpLzkeM74-ZYypn+tAA@mail.gmail.com>
2012-05-16 11:23         ` Paolo Bonzini
     [not found]         ` <4FB38E2E.5000508@redhat.com>
2012-05-16 11:37           ` [Qemu-devel] " Anthony PERARD
     [not found]           ` <CAJJyHj+AOgGDUfKKkJa0R=kjokeN5dcz8yEXQPjnXsCrOQ52Dw@mail.gmail.com>
2012-05-16 13:20             ` Michael S. Tsirkin
     [not found]             ` <20120516132017.GB8620@redhat.com>
2012-05-16 15:52               ` Paolo Bonzini
     [not found]               ` <4FB3CD31.8050903@redhat.com>
2012-05-16 16:25                 ` Michael S. Tsirkin
2012-05-16 16:02           ` Anthony Liguori
     [not found]           ` <4FB3CF96.7080402@codemonkey.ws>
2012-05-16 16:24             ` Michael S. Tsirkin
2012-05-15 15:26 ` Anthony PERARD [this message]
2012-05-15 18:15   ` [PATCH 2/4] qdev: Introduce qdev_force_unplug Stefano Stabellini
     [not found]   ` <alpine.DEB.2.00.1205151913460.26786@kaball-desktop>
2012-05-15 18:22     ` [Qemu-devel] " Anthony PERARD
2012-05-15 15:26 ` [PATCH 3/4] pci: Add force_unplug callback Anthony PERARD
2012-05-15 15:26 ` [PATCH 4/4] xen: Fix PV-on-HVM Anthony PERARD
2012-05-15 21:00   ` Michael S. Tsirkin
     [not found]   ` <20120515210053.GB12039@redhat.com>
2012-05-16  8:06     ` Paolo Bonzini
     [not found]     ` <4FB36001.9030008@redhat.com>
2012-05-16  8:13       ` Michael S. Tsirkin
     [not found]       ` <20120516081341.GB3183@redhat.com>
2012-05-16  8:42         ` Paolo Bonzini
     [not found]         ` <4FB36890.3090301@redhat.com>
2012-05-16 10:19           ` Stefano Stabellini
     [not found]           ` <alpine.DEB.2.00.1205161116070.26786@kaball-desktop>
2012-05-16 10:30             ` Michael S. Tsirkin
     [not found]             ` <20120516103057.GA5161@redhat.com>
2012-05-16 10:37               ` Stefano Stabellini
     [not found]               ` <alpine.DEB.2.00.1205161133270.26786@kaball-desktop>
2012-05-16 13:24                 ` Michael S. Tsirkin
2012-05-15 16:26 ` [PATCH 1.1 0/4] Xen: " Anthony Liguori
     [not found] ` <4FB2839B.3000103@codemonkey.ws>
2012-05-15 16:42   ` Stefano Stabellini
2012-05-15 18:20 ` Stefano Stabellini
2012-05-15 21:06 ` 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=1337095599-28836-3-git-send-email-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=anthony@codemonkey.ws \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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).