From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8VYf-0006Dq-EJ for qemu-devel@nongnu.org; Mon, 25 May 2009 04:29:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8VYa-00065z-7U for qemu-devel@nongnu.org; Mon, 25 May 2009 04:29:20 -0400 Received: from [199.232.76.173] (port=42257 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8VYa-00065f-1D for qemu-devel@nongnu.org; Mon, 25 May 2009 04:29:16 -0400 Received: from verein.lst.de ([213.95.11.210]:38723) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1M8VYZ-0002Q8-6j for qemu-devel@nongnu.org; Mon, 25 May 2009 04:29:15 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id n4P8TDIF004523 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 25 May 2009 10:29:13 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id n4P8TDQs004521 for qemu-devel@nongnu.org; Mon, 25 May 2009 10:29:13 +0200 Date: Mon, 25 May 2009 10:29:13 +0200 From: Christoph Hellwig Message-ID: <20090525082913.GA4346@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] raw-posix: fix hdev_create List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org We do need hdev_create unconditionally on all platforms so that qemu-img create support for host device works on all platforms. Also relax the check to allow character devices in addition to block devices. On many Unix platforms block devices have buffered block nodes and unbuffered character device nodes, and on FreeBSD the block nodes don't even exist anymore. Also on Linux we do support the /dev/sgN scsi passthrough devices through the host device driver, and probably the old-style /dev/raw/rawN raw devices although I haven't tested that. Signed-off-by: Christoph Hellwig Index: qemu/block/raw-posix.c =================================================================== --- qemu.orig/block/raw-posix.c 2009-05-25 10:23:09.116939324 +0200 +++ qemu/block/raw-posix.c 2009-05-25 10:24:47.518024024 +0200 @@ -1096,7 +1096,6 @@ static int fd_open(BlockDriverState *bs) #endif /* !linux && !FreeBSD */ -#if defined(__linux__) || defined(__FreeBSD__) static int hdev_create(const char *filename, QEMUOptionParameter *options) { int fd; @@ -1118,7 +1117,7 @@ static int hdev_create(const char *filen if (fstat(fd, &stat_buf) < 0) ret = -EIO; - else if (!S_ISBLK(stat_buf.st_mode)) + else if (!S_ISBLK(stat_buf.st_mode) && !S_ISCHR(stat_buf.st_mode)) ret = -EIO; else if (lseek(fd, 0, SEEK_END) < total_size * 512) ret = -ENOSPC; @@ -1127,14 +1126,6 @@ static int hdev_create(const char *filen return ret; } -#else /* !(linux || freebsd) */ - -static int hdev_create(const char *filename, QEMUOptionParameter *options) -{ - return -ENOTSUP; -} -#endif - static BlockDriver bdrv_host_device = { .format_name = "host_device", .instance_size = sizeof(BDRVRawState),