@@ -5,7 +5,25 @@
static int raw_open(BlockDriverState *bs, int flags)
{
+ int fd, ret;
+
bs->sg = bs->file->sg;
+ /*
+ * scsi-generic and other raw types do not call qemu_open()
+ */
+ if (bs->sg != BDS_BSG)
+ return 0;
+ /*
+ * Obtain a file descriptor for the underlying BSG device for AIO w/ iovecs
+ */
+ fd = qemu_open(bs->filename, flags, 0644);
+ if (fd < 0) {
+ ret = -errno;
+ if (ret == -EROFS)
+ ret = -EACCES;
+ return ret;
+ }
+ bs->fd = fd;
return 0;
}
@@ -37,6 +55,8 @@ static BlockDriverAIOCB *raw_aio_writev(BlockDriverState *bs,
static void raw_close(BlockDriverState *bs)
{
+ if (bs->fd > 0)
+ close(bs->fd);
}
static void raw_flush(BlockDriverState *bs)