From: Paolo Bonzini <pbonzini@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd
Date: Mon, 16 Jan 2012 08:41:36 +0100 [thread overview]
Message-ID: <4F13D4B0.7020507@redhat.com> (raw)
In-Reply-To: <4F13D03A.7020303@msgid.tls.msk.ru>
On 01/16/2012 08:22 AM, Michael Tokarev wrote:
> On 15.01.2012 21:31, Paolo Bonzini wrote:
>> On 01/15/2012 05:44 PM, Michael Tokarev wrote:
>>>>>>> + * stdout (temporarily) to the pipe to parent,
>>>>>>
>>>>>> This is a bit of a hack.
>>>>>
>>>>> There's another way -- to keep the writing pipe end in some
>>>>> local variable and use that one instead of STDOUT_FILENO.
>>>>> I can do it that way for sure, just thought it's already
>>>>> using too much local variables.
>>>>
>>>> Yes, that would be better.
>>>
>>> Done in a v2 version I sent you.
>>
>> Please stay on the list.
>
> Sorry? I sent it to you and to the list, here's the command
> line from my .bash_history:
>
> git format-patch --subject-prefix="PATCH v2" --stdout --to 'qemu-devel@nongnu.org' --cc "Paolo Bonzini<pbonzini@redhat.com>" --cc mjt@tls.msk.ru HEAD^ | /usr/sbin/sendmail -t -i
>
> On which list I shoult stay?
Ah, sorry, I don't connect to the VPN usually during the weekend so I
thought it was sent privately.
> I still disagree, -- all the operations done in the client
> thread can be done before forking a new thread, syncronously,
> and _that_ will be the easiest and cleanest solution here.
It's a chicken-and-egg problem. To connect a socket to an NBD device,
you need to have negotiated with the server already, so the socket must
be connected already. Since the other side of the socket is also
handled by qemu-nbd, you need threads.
It's true that in principle you could use the main loop and do the
NBD_DO_IT in a new thread. However, qemu-sockets.c does not support
asynchronous connect(2). You could run that code already inside the
main loop, for example in a coroutine, but then patches pile up quickly.
>>> That's not a bad intention. I'm fixing existing logic without
>>> introducing new logical changes. If you want to fix other
>>> stuff, it is better be done in a separate commit/change.
>>
>> AFAIK the only known bug (besides the devfd/sockfd mixup) is the
>> missing chdir, and that should be fixed first.
>
> It all looked so ugly to me that I didn't even want to think
> about just adding a chdir() instead of getting rid of daemon().
> But ok, I can go that ugly route too.
I'm not saying it's particularly pretty, but it's also not as easy to
improve as you'd think. There are a lot of constraints (fork/daemonize
before initializing the block layer, report errors properly, avoid
races, ...).
Paolo
prev parent reply other threads:[~2012-01-16 7:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-14 12:39 [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd Michael Tokarev
2012-01-15 10:42 ` Paolo Bonzini
2012-01-15 12:50 ` Michael Tokarev
2012-01-15 16:11 ` Paolo Bonzini
2012-01-15 16:44 ` Michael Tokarev
2012-01-15 17:31 ` Paolo Bonzini
2012-01-15 17:46 ` Paolo Bonzini
2012-01-16 7:22 ` Michael Tokarev
2012-01-16 7:41 ` Paolo Bonzini [this message]
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=4F13D4B0.7020507@redhat.com \
--to=pbonzini@redhat.com \
--cc=mjt@tls.msk.ru \
--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).