X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=device-hotplug.c;h=126f73c676f4a2e63a4a34bbb3ee7aa4e8b92e01;hb=24ec2863b147aadd8cbd63f87ad0467210164304;hp=eecb08e2b1449f3856b03b7960e686f88d3cca8b;hpb=43cbeffb19877c62cbe0aaf08b2f235d98d71340;p=mirror_qemu.git diff --git a/device-hotplug.c b/device-hotplug.c index eecb08e2b1..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->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); } }