aboutsummaryrefslogtreecommitdiff
path: root/hw/pci-hotplug.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-05 23:01:23 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-05 23:01:23 +0000
commit376253ece484b7dc86f215641dca47c3c88f38d1 (patch)
treecbbcd578628422d88cc6326012f59e7081d3c77e /hw/pci-hotplug.c
parentbb5fc20f7c1c65e95030da3629dd0d7a0cce38cd (diff)
monitor: Rework API (Jan Kiszka)
Refactor the monitor API and prepare it for decoupled terminals: term_print functions are renamed to monitor_* and all monitor services gain a new parameter (mon) that will once refer to the monitor instance the output is supposed to appear on. However, the argument remains unused for now. All monitor command callbacks are also extended by a mon parameter so that command handlers are able to pass an appropriate reference to monitor output services. For the case that monitor outputs so far happen without clearly identifiable context, the global variable cur_mon is introduced that shall once provide a pointer either to the current active monitor (while processing commands) or to the default one. On the mid or long term, those use case will be obsoleted so that this variable can be removed again. Due to the broad usage of the monitor interface, this patch mostly deals with converting users of the monitor API. A few of them are already extended to pass 'mon' from the command handler further down to internal functions that invoke monitor_printf. At this chance, monitor-related prototypes are moved from console.h to a new monitor.h. The same is done for the readline API. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6711 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/pci-hotplug.c')
-rw-r--r--hw/pci-hotplug.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index 628676444e..a01efe0963 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -28,7 +28,7 @@
#include "net.h"
#include "sysemu.h"
#include "pc.h"
-#include "console.h"
+#include "monitor.h"
#include "block_int.h"
#include "virtio-blk.h"
@@ -43,7 +43,7 @@ static PCIDevice *qemu_pci_hot_add_nic(PCIBus *pci_bus, const char *opts)
return pci_nic_init (pci_bus, &nd_table[ret], -1, "rtl8139");
}
-void drive_hot_add(const char *pci_addr, const char *opts)
+void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
{
int dom, pci_bus;
unsigned slot;
@@ -52,13 +52,13 @@ void drive_hot_add(const char *pci_addr, const char *opts)
PCIDevice *dev;
if (pci_read_devaddr(pci_addr, &dom, &pci_bus, &slot)) {
- term_printf("Invalid pci address\n");
+ monitor_printf(mon, "Invalid pci address\n");
return;
}
dev = pci_find_device(pci_bus, slot, 0);
if (!dev) {
- term_printf("no pci device with address %s\n", pci_addr);
+ monitor_printf(mon, "no pci device with address %s\n", pci_addr);
return;
}
@@ -75,16 +75,18 @@ void drive_hot_add(const char *pci_addr, const char *opts)
drives_table[drive_idx].unit);
break;
default:
- term_printf("Can't hot-add drive to type %d\n", type);
+ monitor_printf(mon, "Can't hot-add drive to type %d\n", type);
}
if (success)
- term_printf("OK bus %d, unit %d\n", drives_table[drive_idx].bus,
- drives_table[drive_idx].unit);
+ monitor_printf(mon, "OK bus %d, unit %d\n",
+ drives_table[drive_idx].bus,
+ drives_table[drive_idx].unit);
return;
}
-static PCIDevice *qemu_pci_hot_add_storage(PCIBus *pci_bus, const char *opts)
+static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus,
+ const char *opts)
{
void *opaque = NULL;
int type = -1, drive_idx = -1;
@@ -97,7 +99,7 @@ static PCIDevice *qemu_pci_hot_add_storage(PCIBus *pci_bus, const char *opts)
type = IF_VIRTIO;
}
} else {
- term_printf("no if= specified\n");
+ monitor_printf(mon, "no if= specified\n");
return NULL;
}
@@ -106,7 +108,7 @@ static PCIDevice *qemu_pci_hot_add_storage(PCIBus *pci_bus, const char *opts)
if (drive_idx < 0)
return NULL;
} else if (type == IF_VIRTIO) {
- term_printf("virtio requires a backing file/device.\n");
+ monitor_printf(mon, "virtio requires a backing file/device.\n");
return NULL;
}
@@ -121,13 +123,14 @@ static PCIDevice *qemu_pci_hot_add_storage(PCIBus *pci_bus, const char *opts)
opaque = virtio_blk_init (pci_bus, drives_table[drive_idx].bdrv);
break;
default:
- term_printf ("type %s not a hotpluggable PCI device.\n", buf);
+ monitor_printf(mon, "type %s not a hotpluggable PCI device.\n", buf);
}
return opaque;
}
-void pci_device_hot_add(const char *pci_addr, const char *type, const char *opts)
+void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type,
+ const char *opts)
{
PCIDevice *dev = NULL;
PCIBus *pci_bus;
@@ -135,47 +138,47 @@ void pci_device_hot_add(const char *pci_addr, const char *type, const char *opts
unsigned slot;
if (pci_assign_devaddr(pci_addr, &dom, &bus, &slot)) {
- term_printf("Invalid pci address\n");
+ monitor_printf(mon, "Invalid pci address\n");
return;
}
pci_bus = pci_find_bus(bus);
if (!pci_bus) {
- term_printf("Can't find pci_bus %d\n", bus);
+ monitor_printf(mon, "Can't find pci_bus %d\n", bus);
return;
}
if (strcmp(type, "nic") == 0)
dev = qemu_pci_hot_add_nic(pci_bus, opts);
else if (strcmp(type, "storage") == 0)
- dev = qemu_pci_hot_add_storage(pci_bus, opts);
+ dev = qemu_pci_hot_add_storage(mon, pci_bus, opts);
else
- term_printf("invalid type: %s\n", type);
+ monitor_printf(mon, "invalid type: %s\n", type);
if (dev) {
qemu_system_device_hot_add(bus, PCI_SLOT(dev->devfn), 1);
- term_printf("OK domain %d, bus %d, slot %d, function %d\n",
- 0, pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
- PCI_FUNC(dev->devfn));
+ monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
+ 0, pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
+ PCI_FUNC(dev->devfn));
} else
- term_printf("failed to add %s\n", opts);
+ monitor_printf(mon, "failed to add %s\n", opts);
}
#endif
-void pci_device_hot_remove(const char *pci_addr)
+void pci_device_hot_remove(Monitor *mon, const char *pci_addr)
{
PCIDevice *d;
int dom, bus;
unsigned slot;
if (pci_read_devaddr(pci_addr, &dom, &bus, &slot)) {
- term_printf("Invalid pci address\n");
+ monitor_printf(mon, "Invalid pci address\n");
return;
}
d = pci_find_device(bus, slot, 0);
if (!d) {
- term_printf("slot %d empty\n", slot);
+ monitor_printf(mon, "slot %d empty\n", slot);
return;
}
@@ -199,7 +202,7 @@ void pci_device_hot_remove_success(int pcibus, int slot)
int class_code;
if (!d) {
- term_printf("invalid slot %d\n", slot);
+ monitor_printf(cur_mon, "invalid slot %d\n", slot);
return;
}