[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFi
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets |
Date: |
Wed, 16 Jul 2014 11:50:25 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
Il 16/07/2014 11:37, Dr. David Alan Gilbert ha scritto:
+
+ /* If it's already open, return it */
+ if (qfs->file->return_path) {
+ return qfs->file->return_path;
Wouldn't this leave a dangling file descriptor if you call
socket_dup_return_path twice, and then close the original QEMUFile?
Hmm - how?
The problem is that there is no reference count on QEMUFile, so if you do
f1 = open_return_path(f0);
f2 = open_return_path(f0);
/* now f1 == f2 */
qemu_fclose(f1);
/* now f2 is dangling */
The remark about "closing the original QEMUFile" is also related to this
part:
if (result) {
/* We are the reverse path of our reverse path (although I don't
expect this to be used, it would stop another dup if it was /
result->return_path = qfs->file;
which has a similar bug
f1 = open_return_path(f0);
f2 = open_return_path(f1);
/* now f2 == f0 */
qemu_fclose(f0);
/* now f2 is dangling */
If this is correct, the simplest fix is to drop the optimization.
Source side
Forward path - written by migration thread
: It's OK for this to be blocking, but we end up with it being
non-blocking, and modify the socket code to emulate blocking.
This likely has a performance impact though. The first migration thread
code drop from Juan already improved throughput a lot, even if it kept
the iothread all the time and only converted from nonblocking writes to
blocking.
Return path - opened by main thread, read by fd_handler on main thread
: Must be non-blocking so as not to block the main thread while
waiting for a partially sent command.
Why can't you handle this in the migration thread (or a new postcopy
thread on the source side)? Then it can stay blocking.
Destination side
Forward path - read by main thread
This must be nonblocking so that the monitor keeps responding.
Return path - opened by main thread, written by main thread AND postcopy
thread (protected by rp_mutex)
When does the main thread needs to write?
If it doesn't need that, you can just switch to blocking when you
process the listen command (i.e. when the postcopy thread starts).
Paolo
I think I'm OK with both these being blocking.
- [Qemu-devel] [PATCH 01/46] qemu_ram_foreach_block: pass up error value, and down the ramblock name, (continued)
- [Qemu-devel] [PATCH 01/46] qemu_ram_foreach_block: pass up error value, and down the ramblock name, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 03/46] QEMUSizedBuffer/QEMUFile, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 04/46] improve DPRINTF macros, add to savevm, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 06/46] Create MigrationIncomingState, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 05/46] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2014/07/04
- Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Paolo Bonzini, 2014/07/05
- Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert, 2014/07/16
- Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert, 2014/07/16
- Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Paolo Bonzini, 2014/07/16
- Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert, 2014/07/16
- Re: [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Paolo Bonzini, 2014/07/17
[Qemu-devel] [PATCH 09/46] Migration commands, Dr. David Alan Gilbert (git), 2014/07/04
[Qemu-devel] [PATCH 08/46] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2014/07/04
[Qemu-devel] [PATCH 10/46] Return path: Control commands, Dr. David Alan Gilbert (git), 2014/07/04
[Qemu-devel] [PATCH 12/46] Return path: Source handling of return path, Dr. David Alan Gilbert (git), 2014/07/04
[Qemu-devel] [PATCH 11/46] Return path: Send responses from destination to source, Dr. David Alan Gilbert (git), 2014/07/04