Re: [Qemu-devel] [PATCH 01/18] block: move AioContext, QEMUTimer, main-loop to libqemuutil

2017-02-14 Thread Daniel P. Berrange
On Tue, Feb 14, 2017 at 03:48:31PM +0800, Fam Zheng wrote:
> On Mon, 02/13 14:52, Paolo Bonzini wrote:
> > --- /dev/null
> > +++ b/util/aiocb.c
> > @@ -0,0 +1,55 @@
> > +/*
> > + * BlockAIOCB allocation
> > + *
> > + * Copyright (c) 2003-2017 Fabrice Bellard and the QEMU team
> 
> Hmm, I'm not lawyer, just wondering if the QEMU team is a legal entity that 
> can
> hold copyright? :)

Reword it to say

  "Copyright (c) 2003-2017 Fabrice Bellard and other QEMU contributors"

so it is referring to individual contributors as distinct copyright
holders, as opposed to a single entity called "QEMU team"

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://entangle-photo.org   -o-http://search.cpan.org/~danberr/ :|



Re: [Qemu-devel] [PATCH 01/18] block: move AioContext, QEMUTimer, main-loop to libqemuutil

2017-02-13 Thread Fam Zheng
On Mon, 02/13 14:52, Paolo Bonzini wrote:
> --- /dev/null
> +++ b/util/aiocb.c
> @@ -0,0 +1,55 @@
> +/*
> + * BlockAIOCB allocation
> + *
> + * Copyright (c) 2003-2017 Fabrice Bellard and the QEMU team

Hmm, I'm not lawyer, just wondering if the QEMU team is a legal entity that can
hold copyright? :)

Fam



[Qemu-devel] [PATCH 01/18] block: move AioContext, QEMUTimer, main-loop to libqemuutil

2017-02-13 Thread Paolo Bonzini
AioContext is fairly self contained, the only dependency is QEMUTimer but
that in turn doesn't need anything else.  So move them out of block-obj-y
to avoid introducing a dependency from io/ to block-obj-y.

main-loop and its dependency iohandler also need to be moved, because
later in this series io/ will call iohandler_get_aio_context.

Signed-off-by: Paolo Bonzini 
---
 Makefile.objs   |  4 ---
 block/io.c  | 29 ---
 stubs/Makefile.objs |  1 +
 stubs/linux-aio.c   | 32 +
 stubs/set-fd-handler.c  | 11 
 tests/Makefile.include  | 11 
 trace-events| 11 
 util/Makefile.objs  |  6 +++-
 aio-posix.c => util/aio-posix.c |  2 +-
 aio-win32.c => util/aio-win32.c |  0
 util/aiocb.c| 55 +
 async.c => util/async.c |  3 +-
 iohandler.c => util/iohandler.c |  0
 main-loop.c => util/main-loop.c |  0
 qemu-timer.c => util/qemu-timer.c   |  0
 thread-pool.c => util/thread-pool.c |  2 +-
 util/trace-events   | 11 
 17 files changed, 114 insertions(+), 64 deletions(-)
 create mode 100644 stubs/linux-aio.c
 rename aio-posix.c => util/aio-posix.c (99%)
 rename aio-win32.c => util/aio-win32.c (100%)
 create mode 100644 util/aiocb.c
 rename async.c => util/async.c (99%)
 rename iohandler.c => util/iohandler.c (100%)
 rename main-loop.c => util/main-loop.c (100%)
 rename qemu-timer.c => util/qemu-timer.c (100%)
 rename thread-pool.c => util/thread-pool.c (99%)

diff --git a/Makefile.objs b/Makefile.objs
index 431fc59..b4b29c2 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -9,12 +9,8 @@ chardev-obj-y = chardev/
 ###
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
-block-obj-y = async.o thread-pool.o
 block-obj-y += nbd/
 block-obj-y += block.o blockjob.o
-block-obj-y += main-loop.o iohandler.o qemu-timer.o
-block-obj-$(CONFIG_POSIX) += aio-posix.o
-block-obj-$(CONFIG_WIN32) += aio-win32.o
 block-obj-y += block/
 block-obj-y += qemu-io-cmds.o
 block-obj-$(CONFIG_REPLICATION) += replication.o
diff --git a/block/io.c b/block/io.c
index c42b34a..76dfaf4 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2239,35 +2239,6 @@ BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
 return >common;
 }
 
-void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
-   BlockCompletionFunc *cb, void *opaque)
-{
-BlockAIOCB *acb;
-
-acb = g_malloc(aiocb_info->aiocb_size);
-acb->aiocb_info = aiocb_info;
-acb->bs = bs;
-acb->cb = cb;
-acb->opaque = opaque;
-acb->refcnt = 1;
-return acb;
-}
-
-void qemu_aio_ref(void *p)
-{
-BlockAIOCB *acb = p;
-acb->refcnt++;
-}
-
-void qemu_aio_unref(void *p)
-{
-BlockAIOCB *acb = p;
-assert(acb->refcnt > 0);
-if (--acb->refcnt == 0) {
-g_free(acb);
-}
-}
-
 /**/
 /* Coroutine block device emulation */
 
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index a187295..aa6050f 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -16,6 +16,7 @@ stub-obj-y += get-vm-name.o
 stub-obj-y += iothread.o
 stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
+stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-y += machine-init-done.o
 stub-obj-y += migr-blocker.o
 stub-obj-y += monitor.o
diff --git a/stubs/linux-aio.c b/stubs/linux-aio.c
new file mode 100644
index 000..ed47bd4
--- /dev/null
+++ b/stubs/linux-aio.c
@@ -0,0 +1,32 @@
+/*
+ * Linux native AIO support.
+ *
+ * Copyright (C) 2009 IBM, Corp.
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "block/aio.h"
+#include "block/raw-aio.h"
+
+void laio_detach_aio_context(LinuxAioState *s, AioContext *old_context)
+{
+abort();
+}
+
+void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context)
+{
+abort();
+}
+
+LinuxAioState *laio_init(void)
+{
+abort();
+}
+
+void laio_cleanup(LinuxAioState *s)
+{
+abort();
+}
diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c
index acbe65c..26965de 100644
--- a/stubs/set-fd-handler.c
+++ b/stubs/set-fd-handler.c
@@ -9,14 +9,3 @@ void qemu_set_fd_handler(int fd,
 {
 abort();
 }
-
-void aio_set_fd_handler(AioContext *ctx,
-int fd,
-bool is_external,
-IOHandler *io_read,
-IOHandler *io_write,
-AioPollFn *io_poll,
-void *opaque)
-{
-abort();
-}
diff --git a/tests/Makefile.include 

[Qemu-devel] [PATCH 01/18] block: move AioContext, QEMUTimer, main-loop to libqemuutil

2017-02-13 Thread Paolo Bonzini
AioContext is fairly self contained, the only dependency is QEMUTimer but
that in turn doesn't need anything else.  So move them out of block-obj-y
to avoid introducing a dependency from io/ to block-obj-y.

main-loop and its dependency iohandler also need to be moved, because
later in this series io/ will call iohandler_get_aio_context.

Reviewed-by: Stefan Hajnoczi 
Signed-off-by: Paolo Bonzini 
---
 Makefile.objs   |  4 ---
 block/io.c  | 29 ---
 stubs/Makefile.objs |  1 +
 stubs/linux-aio.c   | 32 +
 stubs/set-fd-handler.c  | 11 
 tests/Makefile.include  | 11 
 util/Makefile.objs  |  6 +++-
 aio-posix.c => util/aio-posix.c |  0
 aio-win32.c => util/aio-win32.c |  0
 util/aiocb.c| 55 +
 async.c => util/async.c |  3 +-
 iohandler.c => util/iohandler.c |  0
 main-loop.c => util/main-loop.c |  0
 qemu-timer.c => util/qemu-timer.c   |  0
 thread-pool.c => util/thread-pool.c |  0
 15 files changed, 101 insertions(+), 51 deletions(-)
 create mode 100644 stubs/linux-aio.c
 rename aio-posix.c => util/aio-posix.c (100%)
 rename aio-win32.c => util/aio-win32.c (100%)
 create mode 100644 util/aiocb.c
 rename async.c => util/async.c (99%)
 rename iohandler.c => util/iohandler.c (100%)
 rename main-loop.c => util/main-loop.c (100%)
 rename qemu-timer.c => util/qemu-timer.c (100%)
 rename thread-pool.c => util/thread-pool.c (100%)

diff --git a/Makefile.objs b/Makefile.objs
index 431fc59..b4b29c2 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -9,12 +9,8 @@ chardev-obj-y = chardev/
 ###
 # block-obj-y is code used by both qemu system emulation and qemu-img
 
-block-obj-y = async.o thread-pool.o
 block-obj-y += nbd/
 block-obj-y += block.o blockjob.o
-block-obj-y += main-loop.o iohandler.o qemu-timer.o
-block-obj-$(CONFIG_POSIX) += aio-posix.o
-block-obj-$(CONFIG_WIN32) += aio-win32.o
 block-obj-y += block/
 block-obj-y += qemu-io-cmds.o
 block-obj-$(CONFIG_REPLICATION) += replication.o
diff --git a/block/io.c b/block/io.c
index c42b34a..76dfaf4 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2239,35 +2239,6 @@ BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,
 return >common;
 }
 
-void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs,
-   BlockCompletionFunc *cb, void *opaque)
-{
-BlockAIOCB *acb;
-
-acb = g_malloc(aiocb_info->aiocb_size);
-acb->aiocb_info = aiocb_info;
-acb->bs = bs;
-acb->cb = cb;
-acb->opaque = opaque;
-acb->refcnt = 1;
-return acb;
-}
-
-void qemu_aio_ref(void *p)
-{
-BlockAIOCB *acb = p;
-acb->refcnt++;
-}
-
-void qemu_aio_unref(void *p)
-{
-BlockAIOCB *acb = p;
-assert(acb->refcnt > 0);
-if (--acb->refcnt == 0) {
-g_free(acb);
-}
-}
-
 /**/
 /* Coroutine block device emulation */
 
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index a187295..aa6050f 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -16,6 +16,7 @@ stub-obj-y += get-vm-name.o
 stub-obj-y += iothread.o
 stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
+stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-y += machine-init-done.o
 stub-obj-y += migr-blocker.o
 stub-obj-y += monitor.o
diff --git a/stubs/linux-aio.c b/stubs/linux-aio.c
new file mode 100644
index 000..ed47bd4
--- /dev/null
+++ b/stubs/linux-aio.c
@@ -0,0 +1,32 @@
+/*
+ * Linux native AIO support.
+ *
+ * Copyright (C) 2009 IBM, Corp.
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "block/aio.h"
+#include "block/raw-aio.h"
+
+void laio_detach_aio_context(LinuxAioState *s, AioContext *old_context)
+{
+abort();
+}
+
+void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context)
+{
+abort();
+}
+
+LinuxAioState *laio_init(void)
+{
+abort();
+}
+
+void laio_cleanup(LinuxAioState *s)
+{
+abort();
+}
diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c
index acbe65c..26965de 100644
--- a/stubs/set-fd-handler.c
+++ b/stubs/set-fd-handler.c
@@ -9,14 +9,3 @@ void qemu_set_fd_handler(int fd,
 {
 abort();
 }
-
-void aio_set_fd_handler(AioContext *ctx,
-int fd,
-bool is_external,
-IOHandler *io_read,
-IOHandler *io_write,
-AioPollFn *io_poll,
-void *opaque)
-{
-abort();
-}
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 634394a..fed0bb5 100644
---