Commit 2ecea9b8de5cd74df314541b87f712ae77f862ec
1 parent
94451178
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
Showing
1 changed file
with
14 additions
and
6 deletions
monitor.c
@@ -396,18 +396,26 @@ static void do_eject(int force, const char *filename) | @@ -396,18 +396,26 @@ static void do_eject(int force, const char *filename) | ||
396 | eject_device(bs, force); | 396 | eject_device(bs, force); |
397 | } | 397 | } |
398 | 398 | ||
399 | -static void do_change_block(const char *device, const char *filename) | 399 | +static void do_change_block(const char *device, const char *filename, const char *fmt) |
400 | { | 400 | { |
401 | BlockDriverState *bs; | 401 | BlockDriverState *bs; |
402 | + BlockDriver *drv = NULL; | ||
402 | 403 | ||
403 | bs = bdrv_find(device); | 404 | bs = bdrv_find(device); |
404 | if (!bs) { | 405 | if (!bs) { |
405 | term_printf("device not found\n"); | 406 | term_printf("device not found\n"); |
406 | return; | 407 | return; |
407 | } | 408 | } |
409 | + if (fmt) { | ||
410 | + drv = bdrv_find_format(fmt); | ||
411 | + if (!drv) { | ||
412 | + term_printf("invalid format %s\n", fmt); | ||
413 | + return; | ||
414 | + } | ||
415 | + } | ||
408 | if (eject_device(bs, 0) < 0) | 416 | if (eject_device(bs, 0) < 0) |
409 | return; | 417 | return; |
410 | - bdrv_open(bs, filename, 0); | 418 | + bdrv_open2(bs, filename, 0, drv); |
411 | qemu_key_check(bs, filename); | 419 | qemu_key_check(bs, filename); |
412 | } | 420 | } |
413 | 421 | ||
@@ -426,12 +434,12 @@ static void do_change_vnc(const char *target) | @@ -426,12 +434,12 @@ static void do_change_vnc(const char *target) | ||
426 | } | 434 | } |
427 | } | 435 | } |
428 | 436 | ||
429 | -static void do_change(const char *device, const char *target) | 437 | +static void do_change(const char *device, const char *target, const char *fmt) |
430 | { | 438 | { |
431 | if (strcmp(device, "vnc") == 0) { | 439 | if (strcmp(device, "vnc") == 0) { |
432 | do_change_vnc(target); | 440 | do_change_vnc(target); |
433 | } else { | 441 | } else { |
434 | - do_change_block(device, target); | 442 | + do_change_block(device, target, fmt); |
435 | } | 443 | } |
436 | } | 444 | } |
437 | 445 | ||
@@ -1339,8 +1347,8 @@ static term_cmd_t term_cmds[] = { | @@ -1339,8 +1347,8 @@ static term_cmd_t term_cmds[] = { | ||
1339 | "", "quit the emulator" }, | 1347 | "", "quit the emulator" }, |
1340 | { "eject", "-fB", do_eject, | 1348 | { "eject", "-fB", do_eject, |
1341 | "[-f] device", "eject a removable medium (use -f to force it)" }, | 1349 | "[-f] device", "eject a removable medium (use -f to force it)" }, |
1342 | - { "change", "BF", do_change, | ||
1343 | - "device filename", "change a removable medium" }, | 1350 | + { "change", "BFs?", do_change, |
1351 | + "device filename [format]", "change a removable medium, optional format" }, | ||
1344 | { "screendump", "F", do_screen_dump, | 1352 | { "screendump", "F", do_screen_dump, |
1345 | "filename", "save screen into PPM image 'filename'" }, | 1353 | "filename", "save screen into PPM image 'filename'" }, |
1346 | { "logfile", "F", do_logfile, | 1354 | { "logfile", "F", do_logfile, |