From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jDl-000597-HY for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5jDe-0002LT-AB for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jDe-0002Kl-11 for qemu-devel@nongnu.org; Fri, 11 Jul 2014 18:23:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6BMN50K012893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 11 Jul 2014 18:23:05 -0400 From: Max Reitz Date: Sat, 12 Jul 2014 00:23:04 +0200 Message-Id: <1405117387-25539-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1405117387-25539-1-git-send-email-mreitz@redhat.com> References: <1405117387-25539-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 1/4] block: Correct bs->growable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz 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 --- 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