aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2011-11-22 17:58:31 -0200
committerLuiz Capitulino <lcapitulino@redhat.com>2011-12-06 11:40:01 -0200
commite42e818bf45f2f70cdd88a3864efcc3964039f37 (patch)
treeedc33f757981f6a1a5005b1ee3229b7e38589e46 /monitor.c
parent6d3962bf848ba06296554976f9fd86af805584bb (diff)
qapi: Convert cont
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c74
1 files changed, 15 insertions, 59 deletions
diff --git a/monitor.c b/monitor.c
index a1b46b3c62..b0d1862de8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1073,65 +1073,6 @@ static void do_singlestep(Monitor *mon, const QDict *qdict)
}
}
-static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs);
-
-struct bdrv_iterate_context {
- Monitor *mon;
- int err;
-};
-
-static void iostatus_bdrv_it(void *opaque, BlockDriverState *bs)
-{
- bdrv_iostatus_reset(bs);
-}
-
-/**
- * do_cont(): Resume emulation.
- */
-static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data)
-{
- struct bdrv_iterate_context context = { mon, 0 };
-
- if (runstate_check(RUN_STATE_INMIGRATE)) {
- qerror_report(QERR_MIGRATION_EXPECTED);
- return -1;
- } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) ||
- runstate_check(RUN_STATE_SHUTDOWN)) {
- qerror_report(QERR_RESET_REQUIRED);
- return -1;
- }
-
- bdrv_iterate(iostatus_bdrv_it, NULL);
- bdrv_iterate(encrypted_bdrv_it, &context);
- /* only resume the vm if all keys are set and valid */
- if (!context.err) {
- vm_start();
- return 0;
- } else {
- return -1;
- }
-}
-
-static void bdrv_key_cb(void *opaque, int err)
-{
- Monitor *mon = opaque;
-
- /* another key was set successfully, retry to continue */
- if (!err)
- do_cont(mon, NULL, NULL);
-}
-
-static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs)
-{
- struct bdrv_iterate_context *context = opaque;
-
- if (!context->err && bdrv_key_required(bs)) {
- context->err = -EBUSY;
- monitor_read_bdrv_key_start(context->mon, bs, bdrv_key_cb,
- context->mon);
- }
-}
-
static void do_gdbserver(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_try_str(qdict, "device");
@@ -4858,3 +4799,18 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
return err;
}
+
+int monitor_read_block_device_key(Monitor *mon, const char *device,
+ BlockDriverCompletionFunc *completion_cb,
+ void *opaque)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_find(device);
+ if (!bs) {
+ monitor_printf(mon, "Device not found %s\n", device);
+ return -1;
+ }
+
+ return monitor_read_bdrv_key_start(mon, bs, completion_cb, opaque);
+}