mirror of https://gitee.com/openkylin/qemu.git
Monitor: Convert pci_device_hot_add() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
aeb91c1e13
commit
395560c8d1
|
@ -254,7 +254,7 @@ void pci_device_hot_add_print(Monitor *mon, const QObject *data)
|
|||
*
|
||||
* { "domain": 0, "bus": 0, "slot": 5, "function": 0 }
|
||||
*/
|
||||
void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
{
|
||||
PCIDevice *dev = NULL;
|
||||
const char *pci_addr = qdict_get_str(qdict, "pci_addr");
|
||||
|
@ -273,20 +273,26 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
|||
if (!strcmp(pci_addr, "auto"))
|
||||
pci_addr = NULL;
|
||||
|
||||
if (strcmp(type, "nic") == 0)
|
||||
if (strcmp(type, "nic") == 0) {
|
||||
dev = qemu_pci_hot_add_nic(mon, pci_addr, opts);
|
||||
else if (strcmp(type, "storage") == 0)
|
||||
} else if (strcmp(type, "storage") == 0) {
|
||||
dev = qemu_pci_hot_add_storage(mon, pci_addr, opts);
|
||||
else
|
||||
} else {
|
||||
monitor_printf(mon, "invalid type: %s\n", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dev) {
|
||||
*ret_data =
|
||||
qobject_from_jsonf("{ 'domain': 0, 'bus': %d, 'slot': %d, "
|
||||
"'function': %d }", pci_bus_num(dev->bus),
|
||||
PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
|
||||
} else
|
||||
} else {
|
||||
monitor_printf(mon, "failed to add %s\n", opts);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -857,7 +857,7 @@ ETEXI
|
|||
.params = "auto|[[<domain>:]<bus>:]<slot> nic|storage [[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...",
|
||||
.help = "hot-add PCI device",
|
||||
.user_print = pci_device_hot_add_print,
|
||||
.mhandler.cmd_new = pci_device_hot_add,
|
||||
.cmd_new_ret = pci_device_hot_add,
|
||||
},
|
||||
#endif
|
||||
|
||||
|
|
2
sysemu.h
2
sysemu.h
|
@ -213,7 +213,7 @@ DriveInfo *add_init_drive(const char *opts);
|
|||
|
||||
/* pci-hotplug */
|
||||
void pci_device_hot_add_print(Monitor *mon, const QObject *data);
|
||||
void pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
|
||||
int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
|
||||
void drive_hot_add(Monitor *mon, const QDict *qdict);
|
||||
void pci_device_hot_remove(Monitor *mon, const char *pci_addr);
|
||||
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict,
|
||||
|
|
Loading…
Reference in New Issue