From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1atH-0006ER-2I for qemu-devel@nongnu.org; Tue, 23 Jul 2013 07:36:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1atF-00018I-BJ for qemu-devel@nongnu.org; Tue, 23 Jul 2013 07:36:26 -0400 Received: from mail-gg0-x234.google.com ([2607:f8b0:4002:c02::234]:49609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1atF-00018D-5R for qemu-devel@nongnu.org; Tue, 23 Jul 2013 07:36:25 -0400 Received: by mail-gg0-f180.google.com with SMTP id i6so2249535ggm.25 for ; Tue, 23 Jul 2013 04:36:24 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51EE6AA8.10101@redhat.com> Date: Tue, 23 Jul 2013 13:36:08 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1374568221-23147-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <1374568221-23147-4-git-send-email-morita.kazutaka@lab.ntt.co.jp> In-Reply-To: <1374568221-23147-4-git-send-email-morita.kazutaka@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/11] qemu-sockets: make wait_for_connect be invoked in qemu_aio_wait List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: MORITA Kazutaka Cc: Kevin Wolf , sheepdog@lists.wpkg.org, qemu-devel@nongnu.org, Stefan Hajnoczi 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 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 */ >