From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LmpMu-0007Wa-25 for qemu-devel@nongnu.org; Thu, 26 Mar 2009 09:11:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LmpMp-0007VL-Lk for qemu-devel@nongnu.org; Thu, 26 Mar 2009 09:11:35 -0400 Received: from [199.232.76.173] (port=35914 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LmpMp-0007VI-D9 for qemu-devel@nongnu.org; Thu, 26 Mar 2009 09:11:31 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:42416) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LmpMo-0000bG-SP for qemu-devel@nongnu.org; Thu, 26 Mar 2009 09:11:31 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e36.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n2QDA6kS002404 for ; Thu, 26 Mar 2009 07:10:06 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n2QDBCBZ205352 for ; Thu, 26 Mar 2009 07:11:18 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n2QDBCcI027820 for ; Thu, 26 Mar 2009 07:11:12 -0600 Received: from squirrel.codemonkey.ws (sig-9-65-67-86.mts.ibm.com [9.65.67.86]) by d03av04.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n2QDBAC4027723 for ; Thu, 26 Mar 2009 07:11:11 -0600 Message-ID: <49CB7EED.7070706@us.ibm.com> Date: Thu, 26 Mar 2009 08:11:09 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] add bdrv->create function for host_device References: <1237258665.15350.67.camel@voxel> In-Reply-To: <1237258665.15350.67.camel@voxel> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Nolan wrote: > "qemu-img convert" tries to create the destination image by calling it's > ->create function. host_devices do not currently have one, since host > devices are not created like normal images are. A reasonable analog of > create for host devices is verifying that they have the appropriate > properties. > > This patch adds that verification. > > It also fixes a typo that caused qemu-img to print the wrong device type > in the error message informing the user that the destination device did > not support creation. > > Signed-off-by: Nolan Leake sigbus.net> > > Index: block-raw-posix.c > =================================================================== > --- block-raw-posix.c (revision 6718) > +++ block-raw-posix.c (working copy) > @@ -1132,6 +1132,32 @@ > > return ioctl(s->fd, req, buf); > } > + > +static int hdev_create(const char *filename, int64_t total_size, > + const char *backing_file, int flags) > +{ > + int fd; > + int ret = 0; > + struct stat stat_buf; > + > + if (flags || backing_file) > + return -ENOTSUP; > + > + fd = open(filename, O_WRONLY | O_BINARY); > + if (fd < 0) > + return -EIO; > + > + if (fstat(fd, &stat_buf) < 0) > + ret = -EIO; > + else if (!S_ISBLK(stat_buf.st_mode)) > + ret = -EIO; > + else if (lseek(fd, 0, SEEK_END) < total_size * 512) > + ret = -ENOSPC; > + > + close(fd); > + return ret; > +} > I'm not quite sure how, but I think you need to have BDRV_O_FILE as a special case. I think probably the easiest thing to do is to bail out if BDRV_O_FILE is set since a physical device cannot be growable. Regards, Anthony Liguori > >