From patchwork Fri Jul 11 22:23:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 369255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E50C21400DD for ; Sat, 12 Jul 2014 08:23:51 +1000 (EST) Received: from localhost ([::1]:46936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5jEL-00067w-Ij for incoming@patchwork.ozlabs.org; Fri, 11 Jul 2014 18:23:49 -0400 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 Received: from localhost (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6BMN2lS010522 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 11 Jul 2014 18:23:04 -0400 From: Max Reitz To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH 1/4] block: Correct bs->growable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }