aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2013-05-29 19:35:40 +0800
committerKevin Wolf <kwolf@redhat.com>2013-06-04 12:11:58 +0200
commitb64ec4e4ade581d662753cdeb0d7e0e27aafbf81 (patch)
tree73a06f4c2528be5cf76830bb9679b4a37e87aa7e /hw/block
parent8ddd08c5d1415a71f21157686d43f48ff14992b6 (diff)
block: add block driver read only whitelist
We may want to include a driver in the whitelist for read only tasks such as diagnosing or exporting guest data (with libguestfs as a good example). This patch introduces a readonly whitelist option, and for backward compatibility, the old configure option --block-drv-whitelist is now an alias to rw whitelist. Drivers in readonly list is only permitted to open file readonly, and returns -ENOTSUP for RW opening. E.g. To include vmdk readonly, and others read+write: ./configure --target-list=x86_64-softmmu \ --block-drv-rw-whitelist=qcow2,raw,file,qed \ --block-drv-ro-whitelist=vmdk Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/xen_disk.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 0ac65d4e8f..247f32f4ee 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -780,11 +780,13 @@ static int blk_connect(struct XenDevice *xendev)
{
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
int pers, index, qflags;
+ bool readonly = true;
/* read-only ? */
qflags = BDRV_O_CACHE_WB | BDRV_O_NATIVE_AIO;
if (strcmp(blkdev->mode, "w") == 0) {
qflags |= BDRV_O_RDWR;
+ readonly = false;
}
/* init qemu block driver */
@@ -795,8 +797,10 @@ static int blk_connect(struct XenDevice *xendev)
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
blkdev->bs = bdrv_new(blkdev->dev);
if (blkdev->bs) {
- if (bdrv_open(blkdev->bs, blkdev->filename, NULL, qflags,
- bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) {
+ BlockDriver *drv = bdrv_find_whitelisted_format(blkdev->fileproto,
+ readonly);
+ if (bdrv_open(blkdev->bs,
+ blkdev->filename, NULL, qflags, drv) != 0) {
bdrv_delete(blkdev->bs);
blkdev->bs = NULL;
}