qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] monitor: Add force option support to pci_del command
@ 2010-06-09  5:37 Marcos Oviedo
  2010-06-09  6:39 ` Markus Armbruster
  2010-06-09  7:38 ` Gerd Hoffmann
  0 siblings, 2 replies; 10+ messages in thread
From: Marcos Oviedo @ 2010-06-09  5:37 UTC (permalink / raw)
  To: qemu-devel

This adds a way to force the removal/unplug of previously added pci
devices when ACPI-based hotplug mechanism is not present.

Signed-off-by: Marcos Oviedo <moviedo@gmail.com>
---
 hw/pci-hotplug.c |   16 +++++++++++++---
 qemu-monitor.hx  |    4 ++--
 sysemu.h         |    2 +-
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index a8f3df1..1007e5b 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -260,11 +260,12 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)
 }
 #endif

-int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
+int pci_device_hot_remove(Monitor *mon, const char *pci_addr, const int forced)
 {
     PCIDevice *d;
     int dom, bus;
     unsigned slot;
+    int ret = -1;

     if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
         return -1;
@@ -275,10 +276,19 @@ int pci_device_hot_remove(Monitor *mon, const
char *pci_addr)
         monitor_printf(mon, "slot %d empty\n", slot);
         return -1;
     }
-    return qdev_unplug(&d->qdev);
+
+    if (forced) {
+        qdev_free(&d->qdev);
+        ret = 0;
+    }
+    else {
+        ret = qdev_unplug(&d->qdev);
+    }
+
+    return ret;
 }

 void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict)
 {
-    pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"));
+    pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"),
qdict_get_int(qdict, "force"));
 }
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index f6a94f2..ce8cddd 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1140,8 +1140,8 @@ ETEXI
 #if defined(TARGET_I386)
     {
         .name       = "pci_del",
-        .args_type  = "pci_addr:s",
-        .params     = "[[<domain>:]<bus>:]<slot>",
+        .args_type  = "pci_addr:s,force:-f",
+        .params     = "[[<domain>:]<bus>:]<slot> [-f]",
         .help       = "hot remove PCI device",
         .mhandler.cmd = do_pci_device_hot_remove,
     },
diff --git a/sysemu.h b/sysemu.h
index 879446a..22303b3 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -202,7 +202,7 @@ DriveInfo *add_init_drive(const char *opts);
 /* pci-hotplug */
 void pci_device_hot_add(Monitor *mon, const QDict *qdict);
 void drive_hot_add(Monitor *mon, const QDict *qdict);
-int pci_device_hot_remove(Monitor *mon, const char *pci_addr);
+int pci_device_hot_remove(Monitor *mon, const char *pci_addr, const
int forced);
 void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);

 /* serial ports */
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-06-17 18:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-09  5:37 [Qemu-devel] [PATCH] monitor: Add force option support to pci_del command Marcos Oviedo
2010-06-09  6:39 ` Markus Armbruster
2010-06-09  7:38 ` Gerd Hoffmann
2010-06-09 14:00   ` Marcos Oviedo
2010-06-09 14:27     ` Gerd Hoffmann
2010-06-14 16:59       ` Anthony Liguori
2010-06-15  8:46         ` Gerd Hoffmann
2010-06-15  9:03         ` Markus Armbruster
2010-06-17 18:15           ` Luiz Capitulino
2010-06-17 18:20             ` Anthony Liguori

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