X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=device-hotplug.c;h=126f73c676f4a2e63a4a34bbb3ee7aa4e8b92e01;hb=f9a8b5530d438f836f9697639814f585aaec554d;hp=103d34ac45ea49039be2d562b23f9995a3b4c905;hpb=6e72a00f909dcd093fbdd1faa2b3c8caa1697a6c;p=mirror_qemu.git diff --git a/device-hotplug.c b/device-hotplug.c index 103d34ac45..126f73c676 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -22,23 +22,28 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "hw/hw.h" #include "hw/boards.h" +#include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "qemu/config-file.h" #include "sysemu/sysemu.h" #include "monitor/monitor.h" +#include "block/block_int.h" -DriveInfo *add_init_drive(const char *optstr) +static DriveInfo *add_init_drive(const char *optstr) { DriveInfo *dinfo; QemuOpts *opts; + MachineClass *mc; opts = drive_def(optstr); if (!opts) return NULL; - dinfo = drive_init(opts, current_machine->block_default_type); + mc = MACHINE_GET_CLASS(current_machine); + dinfo = drive_new(opts, mc->block_default_type); if (!dinfo) { qemu_opts_del(opts); return NULL; @@ -47,10 +52,16 @@ DriveInfo *add_init_drive(const char *optstr) return dinfo; } -void drive_hot_add(Monitor *mon, const QDict *qdict) +void hmp_drive_add(Monitor *mon, const QDict *qdict) { DriveInfo *dinfo = NULL; const char *opts = qdict_get_str(qdict, "opts"); + bool node = qdict_get_try_bool(qdict, "node", false); + + if (node) { + hmp_drive_add_node(mon, opts); + return; + } dinfo = add_init_drive(opts); if (!dinfo) { @@ -66,14 +77,15 @@ void drive_hot_add(Monitor *mon, const QDict *qdict) monitor_printf(mon, "OK\n"); break; default: - if (pci_drive_hot_add(mon, qdict, dinfo)) { - goto err; - } + monitor_printf(mon, "Can't hot-add drive to type %d\n", dinfo->type); + goto err; } return; err: if (dinfo) { - drive_put_ref(dinfo); + BlockBackend *blk = blk_by_legacy_dinfo(dinfo); + monitor_remove_blk(blk); + blk_unref(blk); } }