From: Paolo Bonzini <pbonzini@redhat.com>
To: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>,
sheepdog@lists.wpkg.org, qemu-devel@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>
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 [thread overview]
Message-ID: <51EE6AA8.10101@redhat.com> (raw)
In-Reply-To: <1374568221-23147-4-git-send-email-morita.kazutaka@lab.ntt.co.jp>
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 <morita.kazutaka@lab.ntt.co.jp>
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 */
>
next prev parent reply other threads:[~2013-07-23 11:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-23 8:30 [Qemu-devel] [PATCH 00/11] sheepdog: reconnect server after connection failure MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 01/11] ignore SIGPIPE in qemu-img and qemu-io MORITA Kazutaka
2013-07-23 9:19 ` [Qemu-devel] [PATCH for-1.6 " Paolo Bonzini
2013-08-03 3:52 ` Doug Goldstein
2013-08-05 11:57 ` Kevin Wolf
2013-07-23 8:30 ` [Qemu-devel] [PATCH 02/11] iov: handle EOF in iov_send_recv MORITA Kazutaka
2013-07-23 11:28 ` Paolo Bonzini
2013-08-03 3:48 ` Doug Goldstein
2013-08-05 12:30 ` Kevin Wolf
2013-07-23 8:30 ` [Qemu-devel] [PATCH 03/11] qemu-sockets: make wait_for_connect be invoked in qemu_aio_wait MORITA Kazutaka
2013-07-23 11:36 ` Paolo Bonzini [this message]
2013-07-24 7:41 ` [Qemu-devel] [sheepdog] " MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 04/11] sheepdog: make connect nonblocking MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 05/11] sheepdog: check return values of qemu_co_recv/send correctly MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 06/11] sheepdog: handle vdi objects in resend_aio_req MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 07/11] sheepdog: reload inode outside of resend_aioreq MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 08/11] coroutine: add co_aio_sleep_ns() to allow sleep in block drivers MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 09/11] sheepdog: try to reconnect to sheepdog after network error MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 10/11] sheepdog: make add_aio_request and send_aioreq void functions MORITA Kazutaka
2013-07-23 8:30 ` [Qemu-devel] [PATCH 11/11] sheepdog: cancel aio requests if possible MORITA Kazutaka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51EE6AA8.10101@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=morita.kazutaka@lab.ntt.co.jp \
--cc=qemu-devel@nongnu.org \
--cc=sheepdog@lists.wpkg.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).