@@ -409,6 +409,7 @@ static int curl_open(BlockDriverState *bs, const char *filename, int flags)
curl_multi_setopt( s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb );
curl_multi_do(s);
+ bs->open_flags |= BDRV_O_NOCACHE;
return 0;
out:
@@ -578,6 +578,8 @@ static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
return -EINVAL;
}
+ bs->open_flags |= BDRV_O_NOCACHE;
+
iscsi_url = iscsi_parse_full_url(iscsi, filename);
if (iscsi_url == NULL) {
error_report("Failed to parse URL : %s %s", filename,
@@ -317,6 +317,7 @@ static int nbd_open(BlockDriverState *bs, const char* filename, int flags)
*/
result = nbd_establish_connection(bs);
+ bs->open_flags |= BDRV_O_NOCACHE;
return result;
}
@@ -494,6 +494,7 @@ static int qemu_rbd_open(BlockDriverState *bs, const char *filename, int flags)
}
bs->read_only = (s->snap != NULL);
+ bs->open_flags |= BDRV_O_NOCACHE;
s->event_reader_pos = 0;
r = qemu_pipe(s->fds);
@@ -1047,6 +1047,7 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
s->min_dirty_data_idx = UINT32_MAX;
s->max_dirty_data_idx = 0;
+ bs->open_flags |= BDRV_O_NOCACHE;
bs->total_sectors = s->inode.vdi_size / SECTOR_SIZE;
strncpy(s->name, vdi, sizeof(s->name));
qemu_co_mutex_init(&s->lock);
@@ -441,6 +441,7 @@ static int vdi_open(BlockDriverState *bs, int flags)
goto fail;
}
+ bs->open_flags |= BDRV_O_NOCACHE;
bs->total_sectors = header.disk_size / SECTOR_SIZE;
s->block_size = header.block_size;
Non-raw protocols never cache their data. Make this visible by setting BDRV_O_NOCACHE in the open_flags. It will be used to prohibit block sizes smaller than the backend's block size. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- block/curl.c | 1 + block/iscsi.c | 2 ++ block/nbd.c | 1 + block/rbd.c | 1 + block/sheepdog.c | 1 + block/vdi.c | 1 + 6 files changed, 7 insertions(+), 0 deletions(-)