Skip to contentSkip to conversation

PATCH: add missing (dummy) raw_aio_ioctl() for FreeBSD case

Qemu-devel Juergen Lock 4 participants 7 messages May 1, 2009 – May 2, 2009

lore
Share & tools
lore
#0 lore raw

Assuming this never actually gets called (yet?), I just added a dummy:

Index: qemu/block-raw-posix.c
@@ -1323,6 +1323,16 @@

 {
     return -ENOTSUP;

}
+
+#ifdef CONFIG_AIO
+static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
+ unsigned long int req, void *buf,
+ BlockDriverCompletionFunc *cb, void *opaque)
+{
+ return NULL;
+}
+#endif
+
#else /* !linux && !FreeBSD */

static int fd_open(BlockDriverState *bs)

#1 lore raw
Quoted 2 lines · Juergen Lock

Assuming this never actually gets called (yet?), I just added a dummy:

I'd suggest not --disable-aio on FreeBSD.

Certainly, FreeBSD has a working pthread, right?

Regards,

Anthony Liguori

#2 lore raw

In message: <[email protected]>
Anthony Liguori <[email protected]> writes:
: Juergen Lock wrote:
: > Assuming this never actually gets called (yet?), I just added a dummy:
: >
:
: I'd suggest not --disable-aio on FreeBSD.
:
: Certainly, FreeBSD has a working pthread, right?

Yes...

Warner

#3 lore raw
Quoted 11 lines · M. Warner Losh

In message: <[email protected]>
Anthony Liguori <[email protected]> writes:
: Juergen Lock wrote:
: > Assuming this never actually gets called (yet?), I just added a dummy:
: >
:
: I'd suggest not --disable-aio on FreeBSD.
:
: Certainly, FreeBSD has a working pthread, right?

Yes...

Oh, we are using aio afaict, at least configure says

	...
	AIO support       yes
	...

- but isn't this raw_aio_ioctl() only used for SG_IO i.e. scsi passthru? (which isn't implemented for FreeBSD yet because doing direct scsi commands from userland works differently there than on linux.)

Or am I confused? :)

Juergen

#4 lore raw
Quoted 9 lines · Juergen Lock

Oh, we are using aio afaict, at least configure says

	...
	AIO support       yes
	...

- but isn't this raw_aio_ioctl() only used for SG_IO i.e. scsi passthru? (which isn't implemented for FreeBSD yet because doing direct scsi commands from userland works differently there than on linux.)

Or am I confused? :)

You're not. Currently aio_ioctl is only used for SG_IO. But I don't think wiring up for freebsd would hurt. The actual posix-aio-compat.c code for it is compiled on freebsd anyway, so hooking it up is easy, and you're prepared if other users pop up.

#5 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Juergen Lock

Oh, we are using aio afaict, at least configure says

	...
	AIO support       yes
	...

- but isn't this raw_aio_ioctl() only used for SG_IO i.e. scsi passthru? (which isn't implemented for FreeBSD yet because doing direct scsi commands from userland works differently there than on linux.)

Quoted 6 lines
Quoted 1 line

Or am I confused? :)

You're not. Currently aio_ioctl is only used for SG_IO. But I don't think wiring up for freebsd would hurt. The actual posix-aio-compat.c code for it is compiled on freebsd anyway, so hooking it up is easy, and you're prepared if other users pop up.

Alright I can do that too... Tho in that case I'd say raw_ioctl() needs to be hooked up too:

Index: qemu/block-raw-posix.c
@@ -1321,8 +1321,44 @@

static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) {
- return -ENOTSUP;
+ BDRVRawState *s = bs->opaque;
+
+ return ioctl(s->fd, req, buf);
+}
+
+#ifdef CONFIG_AIO
+static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
+ unsigned long int req, void *buf,
+ BlockDriverCompletionFunc *cb, void *opaque)
+{
+ BDRVRawState *s = bs->opaque;
+ RawAIOCB *acb;
+
+ if (fd_open(bs) < 0)
+ return NULL;
+
+ acb = qemu_aio_get(bs, cb, opaque);
+ if (!acb)
+ return NULL;

+    acb->aiocb.aio_fildes = s->fd;
+    acb->aiocb.ev_signo = SIGUSR2;
+    acb->aiocb.aio_offset = 0;
+    acb->aiocb.aio_flags = 0;

+
+ acb->next = posix_aio_state->first_aio;
+ posix_aio_state->first_aio = acb;
+

+    acb->aiocb.aio_ioctl_buf = buf;
+    acb->aiocb.aio_ioctl_cmd = req;
+    if (qemu_paio_ioctl(&acb->aiocb) < 0) {

+ raw_aio_remove(acb);
+ return NULL;
+ }
+
+ return &acb->common;
}
+#endif
+
#else /* !linux && !FreeBSD */

static int fd_open(BlockDriverState *bs)

#6 lore raw
Quoted 31 lines · Juergen Lock

static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) {

(quoted diff) +27 -1
-    return -ENOTSUP;
+    BDRVRawState *s = bs->opaque;
+
+    return ioctl(s->fd, req, buf);
+}
+
+#ifdef CONFIG_AIO
+static BlockDriverAIOCB *raw_aio_ioctl(BlockDriverState *bs,
+        unsigned long int req, void *buf,
+        BlockDriverCompletionFunc *cb, void *opaque)
+{
+    BDRVRawState *s = bs->opaque;
+    RawAIOCB *acb;
+
+    if (fd_open(bs) < 0)
+        return NULL;
+
+    acb = qemu_aio_get(bs, cb, opaque);
+    if (!acb)
+        return NULL;
+    acb->aiocb.aio_fildes = s->fd;
+    acb->aiocb.ev_signo = SIGUSR2;
+    acb->aiocb.aio_offset = 0;
+    acb->aiocb.aio_flags = 0;
+
+    acb->next = posix_aio_state->first_aio;
+    posix_aio_state->first_aio = acb;
+

Review

Quoted 10 lines
(quoted diff) +9 -0
+    acb->aiocb.aio_ioctl_buf = buf;
+    acb->aiocb.aio_ioctl_cmd = req;
+    if (qemu_paio_ioctl(&acb->aiocb) < 0) {
+        raw_aio_remove(acb);
+        return NULL;
+    }
+
+    return &acb->common;
 }
+#endif

Shouldn't we just make these implementations totally unconditional (bdrv_ioctl) or conditional on CONFIG_AIO only (bdrv_aio_ioctl)?

I can't think of any Posix-ish operating system that wouldn't provide the ioctl system call.