X-Git-Url: https://git.proxmox.com/?p=mirror_qemu.git;a=blobdiff_plain;f=device-hotplug.c;h=6153259d7127ac106883abb646affcc869efa12b;hp=eecb08e2b1449f3856b03b7960e686f88d3cca8b;hb=c4107e8208d0222f9b328691b519aaee4101db87;hpb=c9541f67df48b2c01c4a3d0d7b719b51c6ac9f38 diff --git a/device-hotplug.c b/device-hotplug.c index eecb08e2b1..6153259d71 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -22,15 +22,22 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "hw/hw.h" #include "hw/boards.h" +#include "sysemu/block-backend.h" #include "sysemu/blockdev.h" +#include "qapi/qmp/qdict.h" +#include "qapi/error.h" #include "qemu/config-file.h" +#include "qemu/option.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) { + Error *err = NULL; DriveInfo *dinfo; QemuOpts *opts; MachineClass *mc; @@ -40,8 +47,9 @@ DriveInfo *add_init_drive(const char *optstr) return NULL; mc = MACHINE_GET_CLASS(current_machine); - dinfo = drive_init(opts, mc->block_default_type); - if (!dinfo) { + dinfo = drive_new(opts, mc->block_default_type, &err); + if (err) { + error_report_err(err); qemu_opts_del(opts); return NULL; } @@ -49,33 +57,36 @@ 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) { goto err; } - if (dinfo->devaddr) { - monitor_printf(mon, "Parameter addr not supported\n"); - goto err; - } switch (dinfo->type) { case IF_NONE: 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); } }