qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [6823] Add internal scsi generic block API (Avi Kivity)
@ 2009-03-12 19:57 Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2009-03-12 19:57 UTC (permalink / raw)
  To: qemu-devel

Revision: 6823
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6823
Author:   aliguori
Date:     2009-03-12 19:57:12 +0000 (Thu, 12 Mar 2009)
Log Message:
-----------
Add internal scsi generic block API (Avi Kivity)

Add an internal API for the generic block layer to send scsi generic commands
to block format driver.  This means block format drivers no longer need
to consider overloaded nb_sectors parameters.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Modified Paths:
--------------
    trunk/block-raw-posix.c
    trunk/block.c
    trunk/block_int.h

Modified: trunk/block-raw-posix.c
===================================================================
--- trunk/block-raw-posix.c	2009-03-12 19:57:08 UTC (rev 6822)
+++ trunk/block-raw-posix.c	2009-03-12 19:57:12 UTC (rev 6823)
@@ -1179,6 +1179,32 @@
 }
 #endif /* !linux */
 
+static int raw_sg_send_command(BlockDriverState *bs, void *buf, int count)
+{
+    return raw_pwrite(bs, -1, buf, count);
+}
+
+static int raw_sg_recv_response(BlockDriverState *bs, void *buf, int count)
+{
+    return raw_pread(bs, -1, buf, count);
+}
+
+static BlockDriverAIOCB *raw_sg_aio_read(BlockDriverState *bs,
+                                         void *buf, int count,
+                                         BlockDriverCompletionFunc *cb,
+                                         void *opaque)
+{
+    return raw_aio_read(bs, 0, buf, -(int64_t)count, cb, opaque);
+}
+
+static BlockDriverAIOCB *raw_sg_aio_write(BlockDriverState *bs,
+                                          void *buf, int count,
+                                          BlockDriverCompletionFunc *cb,
+                                          void *opaque)
+{
+    return raw_aio_write(bs, 0, buf, -(int64_t)count, cb, opaque);
+}
+
 BlockDriver bdrv_host_device = {
     .format_name	= "host_device",
     .instance_size	= sizeof(BDRVRawState),
@@ -1204,4 +1230,8 @@
     .bdrv_set_locked	= raw_set_locked,
     /* generic scsi device */
     .bdrv_ioctl		= raw_ioctl,
+    .bdrv_sg_send_command  = raw_sg_send_command,
+    .bdrv_sg_recv_response = raw_sg_recv_response,
+    .bdrv_sg_aio_read      = raw_sg_aio_read,
+    .bdrv_sg_aio_write     = raw_sg_aio_write,
 };

Modified: trunk/block.c
===================================================================
--- trunk/block.c	2009-03-12 19:57:08 UTC (rev 6822)
+++ trunk/block.c	2009-03-12 19:57:12 UTC (rev 6823)
@@ -1678,22 +1678,22 @@
 
 int bdrv_sg_send_command(BlockDriverState *bs, void *buf, int count)
 {
-    return bdrv_pwrite(bs, -1, buf, count);
+    return bs->drv->bdrv_sg_send_command(bs, buf, count);
 }
 
 int bdrv_sg_recv_response(BlockDriverState *bs, void *buf, int count)
 {
-    return bdrv_pread(bs, -1, buf, count);
+    return bs->drv->bdrv_sg_recv_response(bs, buf, count);
 }
 
 BlockDriverAIOCB *bdrv_sg_aio_read(BlockDriverState *bs, void *buf, int count,
                                    BlockDriverCompletionFunc *cb, void *opaque)
 {
-    return bdrv_aio_read(bs, 0, buf, -(int64_t)count, cb, opaque);
+    return bs->drv->bdrv_sg_aio_read(bs, buf, count, cb, opaque);
 }
 
 BlockDriverAIOCB *bdrv_sg_aio_write(BlockDriverState *bs, void *buf, int count,
                                     BlockDriverCompletionFunc *cb, void *opaque)
 {
-    return bdrv_aio_write(bs, 0, buf, -(int64_t)count, cb, opaque);
+    return bs->drv->bdrv_sg_aio_write(bs, buf, count, cb, opaque);
 }

Modified: trunk/block_int.h
===================================================================
--- trunk/block_int.h	2009-03-12 19:57:08 UTC (rev 6822)
+++ trunk/block_int.h	2009-03-12 19:57:12 UTC (rev 6823)
@@ -84,6 +84,16 @@
 
     /* to control generic scsi devices */
     int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf);
+    int (*bdrv_sg_send_command)(BlockDriverState *bs, void *buf, int count);
+    int (*bdrv_sg_recv_response)(BlockDriverState *bs, void *buf, int count);
+    BlockDriverAIOCB *(*bdrv_sg_aio_read)(BlockDriverState *bs,
+                                          void *buf, int count,
+                                          BlockDriverCompletionFunc *cb,
+                                          void *opaque);
+    BlockDriverAIOCB *(*bdrv_sg_aio_write)(BlockDriverState *bs,
+                                           void *buf, int count,
+                                           BlockDriverCompletionFunc *cb,
+                                           void *opaque);
 
     BlockDriverAIOCB *free_aiocb;
     struct BlockDriver *next;

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

only message in thread, other threads:[~2009-03-12 19:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-12 19:57 [Qemu-devel] [6823] Add internal scsi generic block API (Avi Kivity) Anthony Liguori

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