X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=device-hotplug.c;h=126f73c676f4a2e63a4a34bbb3ee7aa4e8b92e01;hb=b4053c64833762f1249b2d704d2da30b5b10c8ff;hp=ebfa6b1016d81d44f0292fc43494ea5e7fd64be1;hpb=90c49ef1650698cff1288e0d22aa858d89f820fa;p=mirror_qemu.git diff --git a/device-hotplug.c b/device-hotplug.c index ebfa6b1016..126f73c676 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -22,14 +22,17 @@ * 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; @@ -40,7 +43,7 @@ DriveInfo *add_init_drive(const char *optstr) return NULL; mc = MACHINE_GET_CLASS(current_machine); - dinfo = drive_init(opts, mc->qemu_machine->block_default_type); + dinfo = drive_new(opts, mc->block_default_type); if (!dinfo) { qemu_opts_del(opts); return NULL; @@ -49,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) { @@ -68,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); } }