qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [COMMIT 4099df5] raw-posix: fix hdev_create


From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT 4099df5] raw-posix: fix hdev_create
Date: Mon, 08 Jun 2009 13:03:08 -0000

From: Christoph Hellwig <address@hidden>

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 <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 57da1df..93ed675 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1376,7 +1376,6 @@ static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState 
*bs,
 }
 #endif /* !linux && !FreeBSD */
 
-#if defined(__linux__) || defined(__FreeBSD__)
 static int hdev_create(const char *filename, QEMUOptionParameter *options)
 {
     int fd;
@@ -1398,7 +1397,7 @@ static int hdev_create(const char *filename, 
QEMUOptionParameter *options)
 
     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;
@@ -1407,14 +1406,6 @@ static int hdev_create(const char *filename, 
QEMUOptionParameter *options)
     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),




reply via email to

[Prev in Thread] Current Thread [Next in Thread]