qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/4] block: Correct bs->growable


From: Max Reitz
Subject: [Qemu-devel] [PATCH 1/4] block: Correct bs->growable
Date: Sat, 12 Jul 2014 00:23:04 +0200

Currently, the field "growable" in a BDS is set iff the BDS is opened in
protocol mode (with O_BDRV_PROTOCOL). However, not every protocol block
driver allows growing: NBD, for instance, does not. On the other hand,
a non-protocol block driver may allow growing: The raw driver does.

Fix this by correcting the "growable" field in the driver-specific open
function for the BDS, if necessary.

Signed-off-by: Max Reitz <address@hidden>
---
 block/blkdebug.c  | 2 ++
 block/blkverify.c | 2 ++
 block/iscsi.c     | 2 ++
 block/nbd.c       | 2 ++
 block/raw_bsd.c   | 1 +
 5 files changed, 9 insertions(+)

diff --git a/block/blkdebug.c b/block/blkdebug.c
index f51407d..c0e5927 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -418,6 +418,8 @@ static int blkdebug_open(BlockDriverState *bs, QDict 
*options, int flags,
         goto out;
     }
 
+    bs->growable = bs->file->growable;
+
     /* Set request alignment */
     align = qemu_opt_get_size(opts, "align", bs->request_alignment);
     if (align > 0 && align < INT_MAX && !(align & (align - 1))) {
diff --git a/block/blkverify.c b/block/blkverify.c
index 621b785..fe90ada 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -154,6 +154,8 @@ static int blkverify_open(BlockDriverState *bs, QDict 
*options, int flags,
         goto fail;
     }
 
+    bs->growable = bs->file->growable && s->test_file->growable;
+
     ret = 0;
 fail:
     return ret;
diff --git a/block/iscsi.c b/block/iscsi.c
index f3e83e2..91626c7 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1246,6 +1246,8 @@ static int iscsi_open(BlockDriverState *bs, QDict 
*options, int flags,
     const char *filename;
     int i, ret;
 
+    bs->growable = false;
+
     if ((BDRV_SECTOR_SIZE % 512) != 0) {
         error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. "
                    "BDRV_SECTOR_SIZE(%lld) is not a multiple "
diff --git a/block/nbd.c b/block/nbd.c
index 4eda095..bd977f4 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -253,6 +253,8 @@ static int nbd_open(BlockDriverState *bs, QDict *options, 
int flags,
     int result, sock;
     Error *local_err = NULL;
 
+    bs->growable = false;
+
     /* Pop the config into our state object. Exit if invalid. */
     nbd_config(s, options, &export, &local_err);
     if (local_err) {
diff --git a/block/raw_bsd.c b/block/raw_bsd.c
index 492f58d..34c091e 100644
--- a/block/raw_bsd.c
+++ b/block/raw_bsd.c
@@ -159,6 +159,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, 
int flags,
                     Error **errp)
 {
     bs->sg = bs->file->sg;
+    bs->growable = bs->file->growable;
     return 0;
 }
 
-- 
2.0.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]