All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/3] qdev: allow devices being tagged as not hotpluggable.
Date: Thu, 18 Nov 2010 11:45:16 +0100	[thread overview]
Message-ID: <1290077118-11577-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1290077118-11577-1-git-send-email-kraxel@redhat.com>

This patch adds a field to DeviceInfo to tag devices as being not
hotpluggable.  Any attempt to plug-in or -out such a device will
throw an error.

This check is done in addition to the check whenever the bus supports
hotplug, i.e. there is no need to tag devices which sit on busses
without hotplug support (ISA for example).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev.c |   16 +++++++++++++---
 hw/qdev.h |    1 +
 qerror.c  |    4 ++++
 qerror.h  |    3 +++
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 35858cb..5ef5346 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -234,9 +234,15 @@ DeviceState *qdev_device_add(QemuOpts *opts)
             return NULL;
         }
     }
-    if (qdev_hotplug && !bus->allow_hotplug) {
-        qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);
-        return NULL;
+    if (qdev_hotplug) {
+        if (!bus->allow_hotplug) {
+            qerror_report(QERR_BUS_NO_HOTPLUG, bus->name);
+            return NULL;
+        }
+        if (info->no_hotplug) {
+            qerror_report(QERR_DEVICE_NO_HOTPLUG, info->name);
+            return NULL;
+        }
     }
 
     /* create device, set properties */
@@ -303,6 +309,10 @@ int qdev_unplug(DeviceState *dev)
         qerror_report(QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
         return -1;
     }
+    if (dev->info->no_hotplug) {
+        qerror_report(QERR_DEVICE_NO_HOTPLUG, dev->info->name);
+        return -1;
+    }
     assert(dev->info->unplug != NULL);
 
     return dev->info->unplug(dev);
diff --git a/hw/qdev.h b/hw/qdev.h
index 579328a..5b57b2b 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -144,6 +144,7 @@ struct DeviceInfo {
     size_t size;
     Property *props;
     int no_user;
+    int no_hotplug;
 
     /* callbacks */
     qdev_resetfn reset;
diff --git a/qerror.c b/qerror.c
index ac2cdaf..9d0cdeb 100644
--- a/qerror.c
+++ b/qerror.c
@@ -101,6 +101,10 @@ static const QErrorStringTable qerror_table[] = {
         .desc      = "Device '%(device)' has no child bus",
     },
     {
+        .error_fmt = QERR_DEVICE_NO_HOTPLUG,
+        .desc      = "Device '%(device)' does not support hotplugging",
+    },
+    {
         .error_fmt = QERR_DUPLICATE_ID,
         .desc      = "Duplicate ID '%(id)' for %(object)",
     },
diff --git a/qerror.h b/qerror.h
index 943a24b..b0f69da 100644
--- a/qerror.h
+++ b/qerror.h
@@ -90,6 +90,9 @@ QError *qobject_to_qerror(const QObject *obj);
 #define QERR_DEVICE_NO_BUS \
     "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
 
+#define QERR_DEVICE_NO_HOTPLUG \
+    "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
+
 #define QERR_DUPLICATE_ID \
     "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
 
-- 
1.7.1

  reply	other threads:[~2010-11-18 10:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18 10:45 [Qemu-devel] [PATCH 0/3] add hotplug opt-out option for devices Gerd Hoffmann
2010-11-18 10:45 ` Gerd Hoffmann [this message]
2010-11-18 10:45 ` [Qemu-devel] [PATCH 2/3] piix: tag as not hotpluggable Gerd Hoffmann
2010-11-18 10:45 ` [Qemu-devel] [PATCH 3/3] vga: tag as not hotplugable Gerd Hoffmann
2010-11-18 11:01 ` [Qemu-devel] [PATCH 0/3] add hotplug opt-out option for devices Gleb Natapov
2010-11-18 11:13   ` Gerd Hoffmann
2010-11-18 11:20     ` Gleb Natapov
2010-11-18 11:29       ` Gerd Hoffmann
2010-11-18 11:42         ` Gleb Natapov
2010-11-18 12:07           ` Michael Tokarev
2010-11-18 12:16             ` Gleb Natapov
2010-11-20  2:30 ` Anthony Liguori
2010-11-20 17:24   ` Gleb Natapov
2010-11-22 10:17   ` Gerd Hoffmann
2010-11-22 13:31     ` Gleb Natapov
2010-12-10 12:34     ` Markus Armbruster
2010-12-10 14:04       ` Gerd Hoffmann

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=1290077118-11577-2-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.