]> Git Repo - qemu.git/commitdiff
block: add bdrv_set_read_only() helper function
authorJeff Cody <[email protected]>
Fri, 7 Apr 2017 20:55:25 +0000 (16:55 -0400)
committerJeff Cody <[email protected]>
Mon, 24 Apr 2017 19:09:33 +0000 (15:09 -0400)
We have a helper wrapper for checking for the BDS read_only flag,
add a helper wrapper to set the read_only flag as well.

Reviewed-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Jeff Cody <[email protected]>
Reviewed-by: John Snow <[email protected]>
Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120[email protected]

block.c
block/bochs.c
block/cloop.c
block/dmg.c
block/rbd.c
block/vvfat.c
include/block/block.h

diff --git a/block.c b/block.c
index 7eda9a42b3cfcc10d727b6c8558d78b1ce14517c..6f21145689e02b6a1d6c6e1ee8d0c6319a1e31e4 100644 (file)
--- a/block.c
+++ b/block.c
@@ -192,6 +192,11 @@ void path_combine(char *dest, int dest_size,
     }
 }
 
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
+{
+    bs->read_only = read_only;
+}
+
 void bdrv_get_full_backing_filename_from_filename(const char *backed,
                                                   const char *backing,
                                                   char *dest, size_t sz,
index 516da56c3b1acf50e6cbe073e417a1bff927a008..bdc28316e70d06eb41f0a030ec9a23f087d9b036 100644 (file)
@@ -110,7 +110,7 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
         return -EINVAL;
     }
 
-    bs->read_only = true; /* no write support yet */
+    bdrv_set_read_only(bs, true); /* no write support yet */
 
     ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
     if (ret < 0) {
index a6c7b9dbe642c8d262a8ef5eac9ddad8d0c707de..11f17c8489446f227a00156718f7d624bc06877b 100644 (file)
@@ -72,7 +72,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
         return -EINVAL;
     }
 
-    bs->read_only = true;
+    bdrv_set_read_only(bs, true);
 
     /* read header */
     ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
index a7d25fc47b46fb31dc7edaceaf5f1f81c91da3ed..27ce4a62d14bb0b8bed3330b52a62fd2a8b6d080 100644 (file)
@@ -420,7 +420,7 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
     }
 
     block_module_load_one("dmg-bz2");
-    bs->read_only = true;
+    bdrv_set_read_only(bs, true);
 
     s->n_chunks = 0;
     s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
index 1ceeeb5a601316197b983c1205550b8c3e3ef4f1..6ad2904d78a12298fb16d547cd3996e723803a29 100644 (file)
@@ -641,7 +641,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
         goto failed_open;
     }
 
-    bs->read_only = (s->snap != NULL);
+    bdrv_set_read_only(bs, (s->snap != NULL));
 
     qemu_opts_del(opts);
     return 0;
index af5153d27d9eec1c2a7032216319c95e0d18c99b..d4ce6d709203ea6197a206477cafe71592c6ebfb 100644 (file)
@@ -1157,7 +1157,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
     s->current_cluster=0xffffffff;
 
     /* read only is the default for safety */
-    bs->read_only = true;
+    bdrv_set_read_only(bs, true);
     s->qcow = NULL;
     s->qcow_filename = NULL;
     s->fat2 = NULL;
@@ -1173,7 +1173,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
         if (ret < 0) {
             goto fail;
         }
-        bs->read_only = false;
+        bdrv_set_read_only(bs, false);
     }
 
     bs->total_sectors = cyls * heads * secs;
index 466de49b48893ea932cfa8e850628f52978032d2..99d49f2d66dc0b9e55825981fcaf7db63e146c7a 100644 (file)
@@ -434,6 +434,7 @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
                             int64_t sector_num, int nb_sectors, int *pnum);
 
 bool bdrv_is_read_only(BlockDriverState *bs);
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
 bool bdrv_is_sg(BlockDriverState *bs);
 bool bdrv_is_inserted(BlockDriverState *bs);
 int bdrv_media_changed(BlockDriverState *bs);
This page took 0.045223 seconds and 4 git commands to generate.