qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: owasserm@redhat.com, mtosatti@redhat.com, qemu-devel@nongnu.org,
	pbonzini@redhat.com, avi@redhat.com
Subject: Re: [Qemu-devel] [PATCH 07/18] migration: make writes blocking
Date: Tue, 30 Oct 2012 09:23:56 +0100	[thread overview]
Message-ID: <87d300l65f.fsf@elfo.mitica> (raw)
In-Reply-To: <87y5ioh0no.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Tue, 30 Oct 2012 08:36:11 +0100")

Markus Armbruster <armbru@redhat.com> wrote:
> Juan Quintela <quintela@redhat.com> writes:
>
>> Markus Armbruster <armbru@redhat.com> wrote:
>>> Juan Quintela <quintela@redhat.com> writes:
>>>
>>>> Move all the writes to the migration_thread, and make writings
>>>> blocking.  Notice that are still using the iothread for everything
>>>> that we do.
>>> [...]
>>>> diff --git a/qemu-sockets.c b/qemu-sockets.c
>>>> index cfed9c5..61b6e95 100644
>>>> --- a/qemu-sockets.c
>>>> +++ b/qemu-sockets.c
>>>> @@ -276,9 +276,6 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress,
>>>>          return -1;
>>>>      }
>>>>      qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
>>>> -    if (connect_state != NULL) {
>>>> -        socket_set_nonblock(sock);
>>>> -    }
>>>>      /* connect to peer */
>>>>      do {
>>>>          rc = 0;
>>>> @@ -732,7 +729,6 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
>>>>          connect_state = g_malloc0(sizeof(*connect_state));
>>>>          connect_state->callback = callback;
>>>>          connect_state->opaque = opaque;
>>>> -        socket_set_nonblock(sock);
>>>>      }
>>>>
>>>>      memset(&un, 0, sizeof(un));
>>>
>>> Doesn't this break inet_nonblocking_connect() and
>>> unix_nonblocking_connect()?
>>>
>>> In your cover letter, you wrote:
>>>
>>>     Note: Writes has become blocking, and I have to change the "remove"
>>>     the feature now in qemu-sockets.c.  Checked that migration was the
>>>     only user of that feature.  If new users appear, they just need to add
>>>     the socket_set_nonblock() by hand.
>>>
>>> Yes, migration-{tcp,unix} are their only users, but if they want a
>>> blocking socket now, why not use inet_connect() and unix_connect()?
>>>
>>> New users can't "just add socket_set_nonblock()".  They'd have to add it
>>> right where you deleted it: between qemu_socket() and connect().  Else
>>> the connect() is blocking.
>>
>> Grrr.
>>
>> So, is there any way to make a connection that is non-blocking, but then
>> writes are blocking?
>
> Which operations on the migration socket do you need to block, and which
> ones do you need not to block?

connect: not blocking (done on the iothread)
writes: blocking, done in the migration thread.

I think thet socket_set_block() that paolo says is the right solution.

>
> If connect() should block, use inet_connect() / unix_connect().  The
> returned socket will be blocking.  You can then switch to non-blocking
> mode (and possibly back) at appropriate times.
>
> If connect() should not block, use inet_nonblocking_connect() and so
> forth.

Thanks, Juan.

  reply	other threads:[~2012-10-30  8:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-29 14:11 [Qemu-devel] [PATCH 00/18] Migration thread lite (20121029) Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 01/18] split MRU ram list Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 02/18] add a version number to ram_list Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 03/18] protect the ramlist with a separate mutex Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 04/18] buffered_file: Move from using a timer to use a thread Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 05/18] migration: make qemu_fopen_ops_buffered() return void Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 06/18] migration: stop all cpus correctly Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 07/18] migration: make writes blocking Juan Quintela
2012-10-29 15:51   ` Markus Armbruster
2012-10-29 17:32     ` Juan Quintela
2012-10-29 22:13       ` Paolo Bonzini
2012-10-30  7:36       ` Markus Armbruster
2012-10-30  8:23         ` Juan Quintela [this message]
2012-10-30 10:50           ` Markus Armbruster
2012-10-30 11:08             ` Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 08/18] migration: remove unfreeze logic Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 09/18] migration: take finer locking Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 10/18] buffered_file: Unfold the trick to restart generating migration data Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 11/18] buffered_file: don't flush on put buffer Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 12/18] buffered_file: unfold buffered_append in buffered_put_buffer Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 13/18] savevm: New save live migration method: pending Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 14/18] migration: include qemu-file.h Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 15/18] migration-fd: remove duplicate include Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 16/18] memory: introduce memory_region_test_and_clear_dirty Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 17/18] ram: Use memory_region_test_and_clear_dirty Juan Quintela
2012-10-29 14:11 ` [Qemu-devel] [PATCH 18/18] ram: optimize migration bitmap walking Juan Quintela

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=87d300l65f.fsf@elfo.mitica \
    --to=quintela@redhat.com \
    --cc=armbru@redhat.com \
    --cc=avi@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=owasserm@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).