Index: vl.c =================================================================== --- vl.c (revision 5300) +++ vl.c (working copy) @@ -5439,12 +5439,13 @@ int max_devs; int index; int cache; + int sync; int bdrv_flags; char *str = arg->opt; static const char * const params[] = { "bus", "unit", "if", "index", "cyls", "heads", "secs", "trans", "media", "snapshot", "file", - "cache", "format", NULL }; + "cache", "format", "sync", NULL }; if (check_params(buf, sizeof(buf), params, str) < 0) { fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n", @@ -5459,6 +5460,7 @@ translation = BIOS_ATA_TRANSLATION_AUTO; index = -1; cache = 1; + sync = 0; if (!strcmp(machine->name, "realview") || !strcmp(machine->name, "SS-5") || @@ -5612,6 +5614,17 @@ } } + if (get_param_value(buf, sizeof(buf), "sync", str)) { + if (!strcmp(buf, "off")) + sync = 0; + else if (!strcmp(buf, "on")) + sync = 1; + else { + fprintf(stderr, "qemu: invalid sync option\n"); + return -1; + } + } + if (get_param_value(buf, sizeof(buf), "format", str)) { if (strcmp(buf, "?") == 0) { fprintf(stderr, "qemu: Supported formats:"); @@ -5728,6 +5741,8 @@ bdrv_flags |= BDRV_O_SNAPSHOT; if (!cache) bdrv_flags |= BDRV_O_DIRECT; + if (sync) + bdrv_flags |= BDRV_O_SYNC; if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0 || qemu_key_check(bdrv, file)) { fprintf(stderr, "qemu: could not open disk image %s\n", file); Index: block-raw-posix.c =================================================================== --- block-raw-posix.c (revision 5304) +++ block-raw-posix.c (working copy) @@ -127,6 +127,8 @@ if (flags & BDRV_O_DIRECT) open_flags |= O_DIRECT; #endif + if (flags & BDRV_O_SYNC) + open_flags |= O_SYNC; s->type = FTYPE_FILE; @@ -937,6 +939,8 @@ if (flags & BDRV_O_DIRECT) open_flags |= O_DIRECT; #endif + if (flags & BDRV_O_SYNC) + open_flags |= O_SYNC; s->type = FTYPE_FILE; #if defined(__linux__) Index: block.h =================================================================== --- block.h (revision 5300) +++ block.h (working copy) @@ -48,6 +48,7 @@ it (default for bdrv_file_open()) */ #define BDRV_O_DIRECT 0x0020 +#define BDRV_O_SYNC 0x0040 void bdrv_info(void); void bdrv_info_stats(void);