Merge remote-tracking branch 'qmp/queue/qmp' into staging
* qmp/queue/qmp: qapi: convert device_del qdev: qdev_unplug(): use error_set()
This commit is contained in:
commit
6da25bd5e8
@ -622,8 +622,7 @@ ETEXI
|
|||||||
.args_type = "id:s",
|
.args_type = "id:s",
|
||||||
.params = "device",
|
.params = "device",
|
||||||
.help = "remove device",
|
.help = "remove device",
|
||||||
.user_print = monitor_user_noop,
|
.mhandler.cmd = hmp_device_del,
|
||||||
.mhandler.cmd_new = do_device_del,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
|
9
hmp.c
9
hmp.c
@ -934,3 +934,12 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
|
|||||||
qemu_mod_timer(status->timer, qemu_get_clock_ms(rt_clock));
|
qemu_mod_timer(status->timer, qemu_get_clock_ms(rt_clock));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hmp_device_del(Monitor *mon, const QDict *qdict)
|
||||||
|
{
|
||||||
|
const char *id = qdict_get_str(qdict, "id");
|
||||||
|
Error *err = NULL;
|
||||||
|
|
||||||
|
qmp_device_del(id, &err);
|
||||||
|
hmp_handle_error(mon, &err);
|
||||||
|
}
|
||||||
|
1
hmp.h
1
hmp.h
@ -60,5 +60,6 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict);
|
|||||||
void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
|
void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
|
||||||
void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
|
void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
|
||||||
void hmp_migrate(Monitor *mon, const QDict *qdict);
|
void hmp_migrate(Monitor *mon, const QDict *qdict);
|
||||||
|
void hmp_device_del(Monitor *mon, const QDict *qdict);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "virtio-blk.h"
|
#include "virtio-blk.h"
|
||||||
#include "qemu-config.h"
|
#include "qemu-config.h"
|
||||||
#include "blockdev.h"
|
#include "blockdev.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
#if defined(TARGET_I386)
|
#if defined(TARGET_I386)
|
||||||
static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
|
static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
|
||||||
@ -191,7 +192,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
|
|||||||
dev = NULL;
|
dev = NULL;
|
||||||
if (dev && dinfo) {
|
if (dev && dinfo) {
|
||||||
if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) {
|
if (scsi_hot_add(mon, &dev->qdev, dinfo, 0) != 0) {
|
||||||
qdev_unplug(&dev->qdev);
|
qdev_unplug(&dev->qdev, NULL);
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,6 +259,7 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
|
|||||||
PCIDevice *d;
|
PCIDevice *d;
|
||||||
int dom, bus;
|
int dom, bus;
|
||||||
unsigned slot;
|
unsigned slot;
|
||||||
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
|
if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -268,7 +270,15 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
|
|||||||
monitor_printf(mon, "slot %d empty\n", slot);
|
monitor_printf(mon, "slot %d empty\n", slot);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return qdev_unplug(&d->qdev);
|
|
||||||
|
qdev_unplug(&d->qdev, &local_err);
|
||||||
|
if (error_is_set(&local_err)) {
|
||||||
|
monitor_printf(mon, "%s\n", error_get_pretty(local_err));
|
||||||
|
error_free(local_err);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict)
|
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "qdev.h"
|
#include "qdev.h"
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
|
#include "qmp-commands.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Aliases were a bad idea from the start. Let's keep them
|
* Aliases were a bad idea from the start. Let's keep them
|
||||||
@ -570,17 +571,17 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
void qmp_device_del(const char *id, Error **errp)
|
||||||
{
|
{
|
||||||
const char *id = qdict_get_str(qdict, "id");
|
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
|
|
||||||
dev = qdev_find_recursive(sysbus_get_default(), id);
|
dev = qdev_find_recursive(sysbus_get_default(), id);
|
||||||
if (NULL == dev) {
|
if (NULL == dev) {
|
||||||
qerror_report(QERR_DEVICE_NOT_FOUND, id);
|
error_set(errp, QERR_DEVICE_NOT_FOUND, id);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
return qdev_unplug(dev);
|
|
||||||
|
qdev_unplug(dev, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qdev_machine_init(void)
|
void qdev_machine_init(void)
|
||||||
|
12
hw/qdev.c
12
hw/qdev.c
@ -28,6 +28,7 @@
|
|||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "qdev.h"
|
#include "qdev.h"
|
||||||
#include "sysemu.h"
|
#include "sysemu.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
int qdev_hotplug = 0;
|
int qdev_hotplug = 0;
|
||||||
static bool qdev_hot_added = false;
|
static bool qdev_hot_added = false;
|
||||||
@ -182,19 +183,22 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
|
|||||||
dev->alias_required_for_version = required_for_version;
|
dev->alias_required_for_version = required_for_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qdev_unplug(DeviceState *dev)
|
void qdev_unplug(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_GET_CLASS(dev);
|
DeviceClass *dc = DEVICE_GET_CLASS(dev);
|
||||||
|
|
||||||
if (!dev->parent_bus->allow_hotplug) {
|
if (!dev->parent_bus->allow_hotplug) {
|
||||||
qerror_report(QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
|
error_set(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
assert(dc->unplug != NULL);
|
assert(dc->unplug != NULL);
|
||||||
|
|
||||||
qdev_hot_removed = true;
|
qdev_hot_removed = true;
|
||||||
|
|
||||||
return dc->unplug(dev);
|
if (dc->unplug(dev) < 0) {
|
||||||
|
error_set(errp, QERR_UNDEFINED_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qdev_reset_one(DeviceState *dev, void *opaque)
|
static int qdev_reset_one(DeviceState *dev, void *opaque)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "qemu-option.h"
|
#include "qemu-option.h"
|
||||||
#include "qapi/qapi-visit-core.h"
|
#include "qapi/qapi-visit-core.h"
|
||||||
#include "qemu/object.h"
|
#include "qemu/object.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
typedef struct Property Property;
|
typedef struct Property Property;
|
||||||
|
|
||||||
@ -148,7 +149,7 @@ int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
|
|||||||
void qdev_init_nofail(DeviceState *dev);
|
void qdev_init_nofail(DeviceState *dev);
|
||||||
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
|
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
|
||||||
int required_for_version);
|
int required_for_version);
|
||||||
int qdev_unplug(DeviceState *dev);
|
void qdev_unplug(DeviceState *dev, Error **errp);
|
||||||
void qdev_free(DeviceState *dev);
|
void qdev_free(DeviceState *dev);
|
||||||
int qdev_simple_unplug_cb(DeviceState *dev);
|
int qdev_simple_unplug_cb(DeviceState *dev);
|
||||||
void qdev_machine_creation_done(void);
|
void qdev_machine_creation_done(void);
|
||||||
|
@ -499,7 +499,7 @@ static void usb_msd_password_cb(void *opaque, int err)
|
|||||||
err = usb_device_attach(&s->dev);
|
err = usb_device_attach(&s->dev);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
qdev_unplug(&s->dev.qdev);
|
qdev_unplug(&s->dev.qdev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct SCSIBusInfo usb_msd_scsi_info = {
|
static const struct SCSIBusInfo usb_msd_scsi_info = {
|
||||||
|
@ -87,7 +87,7 @@ static void unplug_nic(PCIBus *b, PCIDevice *d)
|
|||||||
{
|
{
|
||||||
if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
|
if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
|
||||||
PCI_CLASS_NETWORK_ETHERNET) {
|
PCI_CLASS_NETWORK_ETHERNET) {
|
||||||
qdev_unplug(&(d->qdev));
|
qdev_unplug(&(d->qdev), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ static void unplug_disks(PCIBus *b, PCIDevice *d)
|
|||||||
{
|
{
|
||||||
if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
|
if (pci_get_word(d->config + PCI_CLASS_DEVICE) ==
|
||||||
PCI_CLASS_STORAGE_IDE) {
|
PCI_CLASS_STORAGE_IDE) {
|
||||||
qdev_unplug(&(d->qdev));
|
qdev_unplug(&(d->qdev), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,3 +1701,23 @@
|
|||||||
# Since: 1.1
|
# Since: 1.1
|
||||||
##
|
##
|
||||||
{ 'command': 'xen-save-devices-state', 'data': {'filename': 'str'} }
|
{ 'command': 'xen-save-devices-state', 'data': {'filename': 'str'} }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @device_del:
|
||||||
|
#
|
||||||
|
# Remove a device from a guest
|
||||||
|
#
|
||||||
|
# @id: the name of the device
|
||||||
|
#
|
||||||
|
# Returns: Nothing on success
|
||||||
|
# If @id is not a valid device, DeviceNotFound
|
||||||
|
# If the device does not support unplug, BusNoHotplug
|
||||||
|
#
|
||||||
|
# Notes: When this command completes, the device may not be removed from the
|
||||||
|
# guest. Hot removal is an operation that requires guest cooperation.
|
||||||
|
# This command merely requests that the guest begin the hot removal
|
||||||
|
# process.
|
||||||
|
#
|
||||||
|
# Since: 0.14.0
|
||||||
|
##
|
||||||
|
{ 'command': 'device_del', 'data': {'id': 'str'} }
|
||||||
|
@ -314,10 +314,7 @@ EQMP
|
|||||||
{
|
{
|
||||||
.name = "device_del",
|
.name = "device_del",
|
||||||
.args_type = "id:s",
|
.args_type = "id:s",
|
||||||
.params = "device",
|
.mhandler.cmd_new = qmp_marshal_input_device_del,
|
||||||
.help = "remove device",
|
|
||||||
.user_print = monitor_user_noop,
|
|
||||||
.mhandler.cmd_new = do_device_del,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
SQMP
|
SQMP
|
||||||
|
Loading…
Reference in New Issue
Block a user