[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 03/11] qemu-sockets: make wait_for_connect be in
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 03/11] qemu-sockets: make wait_for_connect be invoked in qemu_aio_wait |
Date: |
Tue, 23 Jul 2013 13:36:08 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 |
Il 23/07/2013 10:30, MORITA Kazutaka ha scritto:
> This allows us to use inet_nonblocking_connect() and
> unix_nonblocking_connect() in block drivers.
>
> qemu-ga needs to link block-obj to resolve dependencies of
> qemu_aio_set_fd_handler().
>
> Signed-off-by: MORITA Kazutaka <address@hidden>
I'm not sure this is safe. You could have e.g. migration start during
qemu_aio_wait().
Paolo
> ---
> Makefile | 4 ++--
> util/qemu-sockets.c | 15 ++++++++++-----
> 2 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index c06bfab..5fe2e0f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -197,7 +197,7 @@ fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
> qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
> $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN
> $@")
>
> -qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
> +qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) $(LIBS_TOOLS)
> qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
>
> gen-out-type = $(subst .,-,$(suffix $@))
> @@ -227,7 +227,7 @@ $(SRC_PATH)/qapi-schema.json
> $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
> QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h
> qga-qapi-visit.h qga-qmp-commands.h)
> $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
>
> -qemu-ga$(EXESUF): $(qga-obj-y) libqemuutil.a libqemustub.a
> +qemu-ga$(EXESUF): $(qga-obj-y) $(block-obj-y) libqemuutil.a libqemustub.a
> $(call LINK, $^)
>
> clean:
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index 095716e..8b21fd1 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -218,6 +218,11 @@ typedef struct ConnectState {
> static int inet_connect_addr(struct addrinfo *addr, bool *in_progress,
> ConnectState *connect_state, Error **errp);
>
> +static int return_true(void *opaque)
> +{
> + return 1;
> +}
> +
> static void wait_for_connect(void *opaque)
> {
> ConnectState *s = opaque;
> @@ -225,7 +230,7 @@ static void wait_for_connect(void *opaque)
> socklen_t valsize = sizeof(val);
> bool in_progress;
>
> - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
> + qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL);
>
> do {
> rc = qemu_getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &val, &valsize);
> @@ -288,8 +293,8 @@ static int inet_connect_addr(struct addrinfo *addr, bool
> *in_progress,
>
> if (connect_state != NULL && QEMU_SOCKET_RC_INPROGRESS(rc)) {
> connect_state->fd = sock;
> - qemu_set_fd_handler2(sock, NULL, NULL, wait_for_connect,
> - connect_state);
> + qemu_aio_set_fd_handler(sock, NULL, wait_for_connect, return_true,
> + connect_state);
> *in_progress = true;
> } else if (rc < 0) {
> error_set_errno(errp, errno, QERR_SOCKET_CONNECT_FAILED);
> @@ -749,8 +754,8 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
>
> if (connect_state != NULL && QEMU_SOCKET_RC_INPROGRESS(rc)) {
> connect_state->fd = sock;
> - qemu_set_fd_handler2(sock, NULL, NULL, wait_for_connect,
> - connect_state);
> + qemu_aio_set_fd_handler(sock, NULL, wait_for_connect, return_true,
> + connect_state);
> return sock;
> } else if (rc >= 0) {
> /* non blocking socket immediate success, call callback */
>
- [Qemu-devel] [PATCH 00/11] sheepdog: reconnect server after connection failure, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 06/11] sheepdog: handle vdi objects in resend_aio_req, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 04/11] sheepdog: make connect nonblocking, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 03/11] qemu-sockets: make wait_for_connect be invoked in qemu_aio_wait, MORITA Kazutaka, 2013/07/23
- Re: [Qemu-devel] [PATCH 03/11] qemu-sockets: make wait_for_connect be invoked in qemu_aio_wait,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 02/11] iov: handle EOF in iov_send_recv, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 01/11] ignore SIGPIPE in qemu-img and qemu-io, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 09/11] sheepdog: try to reconnect to sheepdog after network error, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 07/11] sheepdog: reload inode outside of resend_aioreq, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 11/11] sheepdog: cancel aio requests if possible, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 08/11] coroutine: add co_aio_sleep_ns() to allow sleep in block drivers, MORITA Kazutaka, 2013/07/23
- [Qemu-devel] [PATCH 05/11] sheepdog: check return values of qemu_co_recv/send correctly, MORITA Kazutaka, 2013/07/23