summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-24 14:33:24 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-24 14:33:24 +0000
commit33f002714be2ed58ed05ae3870d5ea6915df4b47 (patch)
tree6b5f907e0c0b42bc6ca4222f1e14462be5e30c1a /vl.c
parent3e98dc8ec6af89c7f4f1e006b979eb405b431629 (diff)
downloadqemu-33f002714be2ed58ed05ae3870d5ea6915df4b47.tar.gz
Add "cache" parameter to "-drive" (Laurent Vivier).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3848 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/vl.c b/vl.c
index 52e6e66e76..14cf4d15a9 100644
--- a/vl.c
+++ b/vl.c
@@ -4880,8 +4880,11 @@ static int drive_init(const char *str, int snapshot, QEMUMachine *machine)
BlockDriverState *bdrv;
int max_devs;
int index;
+ int cache;
+ int bdrv_flags;
char *params[] = { "bus", "unit", "if", "index", "cyls", "heads",
- "secs", "trans", "media", "snapshot", "file", NULL };
+ "secs", "trans", "media", "snapshot", "file",
+ "cache", NULL };
if (check_params(buf, sizeof(buf), params, str) < 0) {
fprintf(stderr, "qemu: unknowm parameter '%s' in '%s'\n",
@@ -4895,6 +4898,7 @@ static int drive_init(const char *str, int snapshot, QEMUMachine *machine)
unit_id = -1;
translation = BIOS_ATA_TRANSLATION_AUTO;
index = -1;
+ cache = 1;
if (!strcmp(machine->name, "realview") ||
!strcmp(machine->name, "SS-5") ||
@@ -5037,6 +5041,17 @@ static int drive_init(const char *str, int snapshot, QEMUMachine *machine)
}
}
+ if (get_param_value(buf, sizeof(buf), "cache", str)) {
+ if (!strcmp(buf, "off"))
+ cache = 0;
+ else if (!strcmp(buf, "on"))
+ cache = 1;
+ else {
+ fprintf(stderr, "qemu: invalid cache option\n");
+ return -1;
+ }
+ }
+
get_param_value(file, sizeof(file), "file", str);
/* compute bus and unit according index */
@@ -5131,8 +5146,12 @@ static int drive_init(const char *str, int snapshot, QEMUMachine *machine)
}
if (!file[0])
return 0;
- if (bdrv_open(bdrv, file, snapshot ? BDRV_O_SNAPSHOT : 0) < 0 ||
- qemu_key_check(bdrv, file)) {
+ bdrv_flags = 0;
+ if (snapshot)
+ bdrv_flags |= BDRV_O_SNAPSHOT;
+ if (!cache)
+ bdrv_flags |= BDRV_O_DIRECT;
+ if (bdrv_open(bdrv, file, bdrv_flags) < 0 || qemu_key_check(bdrv, file)) {
fprintf(stderr, "qemu: could not open disk image %s\n",
file);
return -1;
@@ -7480,7 +7499,8 @@ static void help(int exitcode)
"-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n"
"-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][index=i]\n"
- " [,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]\n"
+ " [,cyls=c,heads=h,secs=s[,trans=t]][snapshot=on|off]"
+ " [,cache=on|off]\n"
" use 'file' as a drive image\n"
"-mtdblock file use 'file' as on-board Flash memory image\n"
"-sd file use 'file' as SecureDigital card image\n"