qemu-devel.nongnu.org archive mirror
 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] pci: allow devices being tagged as not hotpluggable.
Date: Tue, 30 Nov 2010 14:26:02 +0100	[thread overview]
Message-ID: <1291123564-3249-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1291123564-3249-1-git-send-email-kraxel@redhat.com>

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

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/pci.c |   10 ++++++++++
 hw/pci.h |    3 +++
 qerror.c |    4 ++++
 qerror.h |    3 +++
 4 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 438c0d1..aee8d63 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1546,6 +1546,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                      info->is_bridge);
     if (pci_dev == NULL)
         return -1;
+    if (qdev->hotplugged && info->no_hotplug) {
+        qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
+        do_pci_unregister_device(pci_dev);
+        return -1;
+    }
     rc = info->init(pci_dev);
     if (rc != 0) {
         do_pci_unregister_device(pci_dev);
@@ -1575,7 +1580,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
 static int pci_unplug_device(DeviceState *qdev)
 {
     PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
+    PCIDeviceInfo *info = container_of(qdev->info, PCIDeviceInfo, qdev);
 
+    if (info->no_hotplug) {
+        qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
+        return -1;
+    }
     return dev->bus->hotplug(dev->bus->hotplug_qdev, dev,
                              PCI_HOTPLUG_DISABLED);
 }
diff --git a/hw/pci.h b/hw/pci.h
index 09b3e4c..1d1c515 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -431,6 +431,9 @@ typedef struct {
     /* pcie stuff */
     int is_express;   /* is this device pci express? */
 
+    /* device isn't hot-pluggable */
+    int no_hotplug;
+
     /* rom bar */
     const char *romfile;
 } PCIDeviceInfo;
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-12-01  4:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30 13:26 [Qemu-devel] [PATCH 0/3] add hotplug opt-out option for pci devices Gerd Hoffmann
2010-11-30 13:26 ` Gerd Hoffmann [this message]
2011-01-06 14:53   ` [Qemu-devel] Re: [PATCH 1/3] pci: allow devices being tagged as not hotpluggable Michael S. Tsirkin
2010-11-30 13:26 ` [Qemu-devel] [PATCH 2/3] piix: tag " Gerd Hoffmann
2011-01-05 19:44   ` [Qemu-devel] " Michael S. Tsirkin
2011-01-06  8:40     ` Gerd Hoffmann
2011-01-06  9:29       ` Michael S. Tsirkin
2011-01-06 14:14         ` Gerd Hoffmann
2011-01-06 14:34           ` Michael S. Tsirkin
2011-01-06 18:45             ` Marcelo Tosatti
2011-01-07 11:42               ` Michael S. Tsirkin
2010-11-30 13:26 ` [Qemu-devel] [PATCH 3/3] vga: tag as not hotplugable Gerd Hoffmann
2011-01-05 15:57 ` [Qemu-devel] Re: [PATCH 0/3] add hotplug opt-out option for pci devices Michael S. Tsirkin
2011-01-06 15:17   ` 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=1291123564-3249-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 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).