aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-06-18 22:10:01 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-06-18 22:10:01 +0000
commit2ecea9b8de5cd74df314541b87f712ae77f862ec (patch)
treecc27bbe3d88fdf08d85e0020f5c72efe76ee5d71 /monitor.c
parent94451178b6b7d6d08c0f16a5a1b0d03bf978f74b (diff)
Add image format option in monitor for removable media
(Chris Wright) CVE-2008-1945 git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4747 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/monitor.c b/monitor.c
index 1eb8be1ed4..9f1013ecfd 100644
--- a/monitor.c
+++ b/monitor.c
@@ -396,18 +396,26 @@ static void do_eject(int force, const char *filename)
eject_device(bs, force);
}
-static void do_change_block(const char *device, const char *filename)
+static void do_change_block(const char *device, const char *filename, const char *fmt)
{
BlockDriverState *bs;
+ BlockDriver *drv = NULL;
bs = bdrv_find(device);
if (!bs) {
term_printf("device not found\n");
return;
}
+ if (fmt) {
+ drv = bdrv_find_format(fmt);
+ if (!drv) {
+ term_printf("invalid format %s\n", fmt);
+ return;
+ }
+ }
if (eject_device(bs, 0) < 0)
return;
- bdrv_open(bs, filename, 0);
+ bdrv_open2(bs, filename, 0, drv);
qemu_key_check(bs, filename);
}
@@ -426,12 +434,12 @@ static void do_change_vnc(const char *target)
}
}
-static void do_change(const char *device, const char *target)
+static void do_change(const char *device, const char *target, const char *fmt)
{
if (strcmp(device, "vnc") == 0) {
do_change_vnc(target);
} else {
- do_change_block(device, target);
+ do_change_block(device, target, fmt);
}
}
@@ -1339,8 +1347,8 @@ static term_cmd_t term_cmds[] = {
"", "quit the emulator" },
{ "eject", "-fB", do_eject,
"[-f] device", "eject a removable medium (use -f to force it)" },
- { "change", "BF", do_change,
- "device filename", "change a removable medium" },
+ { "change", "BFs?", do_change,
+ "device filename [format]", "change a removable medium, optional format" },
{ "screendump", "F", do_screen_dump,
"filename", "save screen into PPM image 'filename'" },
{ "logfile", "F", do_logfile,