qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] raw-posix: fix hdev_create
@ 2009-05-25  8:29 Christoph Hellwig
  0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2009-05-25  8:29 UTC (permalink / raw)
  To: qemu-devel

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 <hch@lst.de>

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),

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-25  8:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-25  8:29 [Qemu-devel] [PATCH] raw-posix: fix hdev_create Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).