/* Default to cache=writeback as data integrity is not important for qemu-tcg. */ -#define BRDV_O_FLAGS BDRV_O_CACHE_WB +#define BDRV_O_FLAGS BDRV_O_CACHE_WB
static void QEMU_NORETURN error(const char *fmt, ...)
{ @@ -185,7 +185,7 @@ static int read_password(char *buf, int #endif
static BlockDriverState *bdrv_new_open(const char *filename, - const char *fmt) + const char *fmt, int flags)
{ BlockDriverState *bs; BlockDriver *drv; @@ -201,7 +201,7 @@ static BlockDriverState *bdrv_new_open(c } else { drv = NULL; } - if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) {
+ if (bdrv_open2(bs, filename, flags, drv) < 0) { error("Could not open '%s'", filename); } if (bdrv_is_encrypted(bs)) { @@ -253,7 +253,7 @@ static int img_create(int argc, char **a
size = 0; if (base_filename) { BlockDriverState *bs; - bs = bdrv_new_open(base_filename, NULL); + bs = bdrv_new_open(base_filename, NULL, BDRV_O_RDWR); bdrv_get_geometry(bs, &size);
size *= 512; bdrv_delete(bs); @@ -334,7 +334,7 @@ static int img_commit(int argc, char **a } else { drv = NULL; } - if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) {
+ if (bdrv_open2(bs, filename, BDRV_O_FLAGS|BDRV_O_RDWR, drv) < 0) { error("Could not open '%s'", filename); } ret = bdrv_commit(bs); @@ -457,7 +457,8 @@ static int img_convert(int argc, char **