diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2010-06-14 10:33:36 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-06-14 10:33:36 -0500 |
commit | a4673e276248ada38f40d39191a197e7e35d3f8b (patch) | |
tree | 4ecdac95fb7bb86eefc08ee38ca229c4d89e02e0 /monitor.c | |
parent | a2da0395c12bd2b26e2180d735c83988ff66a559 (diff) | |
parent | 653dbec7c97cb51d19636423902719e5850da265 (diff) |
Merge remote branch 'kwolf/for-anthony' into staging
Conflicts:
hw/pc.c
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 104 |
1 files changed, 1 insertions, 103 deletions
@@ -38,7 +38,7 @@ #include "monitor.h" #include "readline.h" #include "console.h" -#include "block.h" +#include "blockdev.h" #include "audio/audio.h" #include "disas.h" #include "balloon.h" @@ -530,21 +530,6 @@ static void do_help_cmd(Monitor *mon, const QDict *qdict) help_cmd(mon, qdict_get_try_str(qdict, "name")); } -static void do_commit(Monitor *mon, const QDict *qdict) -{ - int all_devices; - DriveInfo *dinfo; - const char *device = qdict_get_str(qdict, "device"); - - all_devices = !strcmp(device, "all"); - QTAILQ_FOREACH(dinfo, &drives, next) { - if (!all_devices) - if (strcmp(bdrv_get_device_name(dinfo->bdrv), device)) - continue; - bdrv_commit(dinfo->bdrv); - } -} - static void user_monitor_complete(void *opaque, QObject *ret_data) { MonitorCompletionData *data = (MonitorCompletionData *)opaque; @@ -935,93 +920,6 @@ static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data) return 0; } -static int eject_device(Monitor *mon, BlockDriverState *bs, int force) -{ - if (bdrv_is_inserted(bs)) { - if (!force) { - if (!bdrv_is_removable(bs)) { - qerror_report(QERR_DEVICE_NOT_REMOVABLE, - bdrv_get_device_name(bs)); - return -1; - } - if (bdrv_is_locked(bs)) { - qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); - return -1; - } - } - bdrv_close(bs); - } - return 0; -} - -static int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data) -{ - BlockDriverState *bs; - int force = qdict_get_int(qdict, "force"); - const char *filename = qdict_get_str(qdict, "device"); - - bs = bdrv_find(filename); - if (!bs) { - qerror_report(QERR_DEVICE_NOT_FOUND, filename); - return -1; - } - return eject_device(mon, bs, force); -} - -static int do_block_set_passwd(Monitor *mon, const QDict *qdict, - QObject **ret_data) -{ - BlockDriverState *bs; - int err; - - bs = bdrv_find(qdict_get_str(qdict, "device")); - if (!bs) { - qerror_report(QERR_DEVICE_NOT_FOUND, qdict_get_str(qdict, "device")); - return -1; - } - - err = bdrv_set_key(bs, qdict_get_str(qdict, "password")); - if (err == -EINVAL) { - qerror_report(QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs)); - return -1; - } else if (err < 0) { - qerror_report(QERR_INVALID_PASSWORD); - return -1; - } - - return 0; -} - -static int do_change_block(Monitor *mon, const char *device, - const char *filename, const char *fmt) -{ - BlockDriverState *bs; - BlockDriver *drv = NULL; - int bdrv_flags; - - bs = bdrv_find(device); - if (!bs) { - qerror_report(QERR_DEVICE_NOT_FOUND, device); - return -1; - } - if (fmt) { - drv = bdrv_find_whitelisted_format(fmt); - if (!drv) { - qerror_report(QERR_INVALID_BLOCK_FORMAT, fmt); - return -1; - } - } - if (eject_device(mon, bs, 0) < 0) { - return -1; - } - bdrv_flags = bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM ? 0 : BDRV_O_RDWR; - if (bdrv_open(bs, filename, bdrv_flags, drv) < 0) { - qerror_report(QERR_OPEN_FILE_FAILED, filename); - return -1; - } - return monitor_read_bdrv_key_start(mon, bs, NULL, NULL); -} - static int change_vnc_password(const char *password) { if (vnc_display_password(NULL, password) < 0) { |