From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH 1/4] block: Correct bs->growable
Date: Sat, 12 Jul 2014 00:23:04 +0200 [thread overview]
Message-ID: <1405117387-25539-2-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1405117387-25539-1-git-send-email-mreitz@redhat.com>
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 <mreitz@redhat.com>
---
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
next prev parent reply other threads:[~2014-07-11 22:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 22:23 [Qemu-devel] [PATCH 0/4] block: Warn about usage of growing formats over non-growable protocols Max Reitz
2014-07-11 22:23 ` Max Reitz [this message]
2014-08-20 11:40 ` [Qemu-devel] [PATCH 1/4] block: Correct bs->growable Kevin Wolf
2014-08-20 19:13 ` Max Reitz
2014-08-21 8:19 ` Kevin Wolf
2014-08-22 13:26 ` Max Reitz
2014-09-04 20:01 ` Max Reitz
2014-09-05 10:01 ` Kevin Wolf
2014-09-05 12:46 ` Max Reitz
2014-09-05 13:13 ` Kevin Wolf
2014-07-11 22:23 ` [Qemu-devel] [PATCH 2/4] block: Introduce requires_growing_file Max Reitz
2014-07-11 22:23 ` [Qemu-devel] [PATCH 3/4] iotests: Make some qemu-io commands read-only Max Reitz
2014-07-11 22:23 ` [Qemu-devel] [PATCH 4/4] iotests: Skip read and write in 040 for length=0 Max Reitz
2014-08-15 15:23 ` [Qemu-devel] [PATCH 0/4] block: Warn about usage of growing formats over non-growable protocols Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405117387-25539-2-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).