Commit 4099df586a0f16522383c4e4a9613e7c2dcd2491
Committed by
Anthony Liguori
1 parent
94c6d6d8
raw-posix: fix hdev_create
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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
1 additions
and
10 deletions
block/raw-posix.c
... | ... | @@ -1376,7 +1376,6 @@ static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs, |
1376 | 1376 | } |
1377 | 1377 | #endif /* !linux && !FreeBSD */ |
1378 | 1378 | |
1379 | -#if defined(__linux__) || defined(__FreeBSD__) | |
1380 | 1379 | static int hdev_create(const char *filename, QEMUOptionParameter *options) |
1381 | 1380 | { |
1382 | 1381 | int fd; |
... | ... | @@ -1398,7 +1397,7 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options) |
1398 | 1397 | |
1399 | 1398 | if (fstat(fd, &stat_buf) < 0) |
1400 | 1399 | ret = -EIO; |
1401 | - else if (!S_ISBLK(stat_buf.st_mode)) | |
1400 | + else if (!S_ISBLK(stat_buf.st_mode) && !S_ISCHR(stat_buf.st_mode)) | |
1402 | 1401 | ret = -EIO; |
1403 | 1402 | else if (lseek(fd, 0, SEEK_END) < total_size * 512) |
1404 | 1403 | ret = -ENOSPC; |
... | ... | @@ -1407,14 +1406,6 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options) |
1407 | 1406 | return ret; |
1408 | 1407 | } |
1409 | 1408 | |
1410 | -#else /* !(linux || freebsd) */ | |
1411 | - | |
1412 | -static int hdev_create(const char *filename, QEMUOptionParameter *options) | |
1413 | -{ | |
1414 | - return -ENOTSUP; | |
1415 | -} | |
1416 | -#endif | |
1417 | - | |
1418 | 1409 | static BlockDriver bdrv_host_device = { |
1419 | 1410 | .format_name = "host_device", |
1420 | 1411 | .instance_size = sizeof(BDRVRawState), | ... | ... |