From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1xUH-0007kX-B2 for qemu-devel@nongnu.org; Fri, 09 Sep 2011 05:35:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1xUE-0007mg-UT for qemu-devel@nongnu.org; Fri, 09 Sep 2011 05:35:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1xUE-0007mN-H0 for qemu-devel@nongnu.org; Fri, 09 Sep 2011 05:35:02 -0400 Message-ID: <4E69DE75.5070507@redhat.com> Date: Fri, 09 Sep 2011 11:37:57 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <20110901132755.GG14462@redhat.com> <20110901140526.GA9388@lst.de> <20110901143034.GJ14462@redhat.com> <20110901155543.GA11219@lst.de> <20110907110245.GA3477@lst.de> In-Reply-To: <20110907110245.GA3477@lst.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block: allow resizing of images residing on host devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org Am 07.09.2011 13:02, schrieb Christoph Hellwig: > Allow to resize images that reside on host devices up to the available > space. This allows to grow images after resizing the device manually or > vice versa. > > Reviewed-by: Christoph Hellwig You mean Signed-off-by, no? > Index: qemu/block/raw-posix.c > =================================================================== > --- qemu.orig/block/raw-posix.c 2011-09-01 17:37:42.579651525 +0200 > +++ qemu/block/raw-posix.c 2011-09-01 17:43:28.882967337 +0200 > @@ -645,10 +645,23 @@ static void raw_close(BlockDriverState * > static int raw_truncate(BlockDriverState *bs, int64_t offset) > { > BDRVRawState *s = bs->opaque; > - if (s->type != FTYPE_FILE) > - return -ENOTSUP; > - if (ftruncate(s->fd, offset) < 0) > + struct stat st; > + > + if (fstat(s->fd, &st)) > return -errno; Coding style requires braces. > + > + if (S_ISREG(st.st_mode)) { > + if (ftruncate(s->fd, offset) < 0) > + return -errno; Here as well. > + } else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { > + if (offset > raw_getlength(bs)) { > + return -EINVAL; > + } > + return 0; This return isn't needed and it's not there in the S_ISREG case. It should be symmetrical at least. Semantically the patch looks okay. Kevin