Revision 7a344f7a

b/hw/pci-hotplug.c
33 33
#include "scsi.h"
34 34
#include "virtio-blk.h"
35 35
#include "qemu-config.h"
36
#include "qemu-objects.h"
36 37

  
37 38
#if defined(TARGET_I386)
38 39
static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
......
228 229
    return dev;
229 230
}
230 231

  
231
void pci_device_hot_add(Monitor *mon, const QDict *qdict)
232
void pci_device_hot_add_print(Monitor *mon, const QObject *data)
233
{
234
    QDict *qdict;
235

  
236
    assert(qobject_type(data) == QTYPE_QDICT);
237
    qdict = qobject_to_qdict(data);
238

  
239
    monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
240
                   (int) qdict_get_int(qdict, "domain"),
241
                   (int) qdict_get_int(qdict, "bus"),
242
                   (int) qdict_get_int(qdict, "slot"),
243
                   (int) qdict_get_int(qdict, "function"));
244

  
245
}
246

  
247
/**
248
 * pci_device_hot_add(): Hot add a PCI device
249
 *
250
 * Return a QDict with the following device information:
251
 *
252
 * - "domain": domain number
253
 * - "bus": bus number
254
 * - "slot": slot number
255
 * - "function": function number
256
 *
257
 * Example:
258
 *
259
 * { "domain": 0, "bus": 0, "slot": 5, "function": 0 }
260
 */
261
void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
232 262
{
233 263
    PCIDevice *dev = NULL;
234 264
    const char *pci_addr = qdict_get_str(qdict, "pci_addr");
......
255 285
        monitor_printf(mon, "invalid type: %s\n", type);
256 286

  
257 287
    if (dev) {
258
        monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
259
                       0, pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
260
                       PCI_FUNC(dev->devfn));
288
        *ret_data =
289
        qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, "
290
                           "'function': %d }", pci_bus_num(dev->bus),
291
                           PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
292
        assert(*ret_data != NULL);
261 293
    } else
262 294
        monitor_printf(mon, "failed to add %s\n", opts);
263 295
}
b/qemu-monitor.hx
810 810
        .args_type  = "pci_addr:s,type:s,opts:s?",
811 811
        .params     = "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...",
812 812
        .help       = "hot-add PCI device",
813
        .mhandler.cmd = pci_device_hot_add,
813
        .user_print = pci_device_hot_add_print,
814
        .mhandler.cmd_new = pci_device_hot_add,
814 815
    },
815 816
#endif
816 817

  
b/sysemu.h
212 212
DriveInfo *add_init_drive(const char *opts);
213 213

  
214 214
/* pci-hotplug */
215
void pci_device_hot_add(Monitor *mon, const QDict *qdict);
215
void pci_device_hot_add_print(Monitor *mon, const QObject *data);
216
void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
216 217
void drive_hot_add(Monitor *mon, const QDict *qdict);
217 218
void pci_device_hot_remove(Monitor *mon, const char *pci_addr);
218 219
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict,

Also available in: Unified diff