All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] do not chdir(/) in qemu-nbd
Date: Fri, 13 Jan 2012 13:01:01 +0000	[thread overview]
Message-ID: <20120113130101.GD32411@redhat.com> (raw)
In-Reply-To: <4F1027E7.3080808@msgid.tls.msk.ru>

On Fri, Jan 13, 2012 at 04:47:35PM +0400, Michael Tokarev wrote:
> On 13.01.2012 15:57, Stefan Hajnoczi wrote:
> > On Fri, Jan 13, 2012 at 9:04 AM, Michael Tokarev <mjt@tls.msk.ru> wrote:
> >> When qemu-nbd becomes a daemon it calls daemon(3) with
> >> nochdir=0, so daemon(3) changes current directory to /.
> >> But at this time, qemu-nbd did not open any user-specified
> >> files yet, so by changing current directory, all non-absolute
> >> paths becomes wrong.  The solution is to pass nochdir=1 to
> >> daemon(3) function.
> > 
> > It's polite to chdir("/") so that file systems can be unmounted (even
> > more important when chroot was involved, but I think qemu-nbd doesn't
> > do that).  Is it possible to manually do a chdir("/") later on after
> > we've opened necessary files?
> 
> Yes that was something I wasn't happy about too -- lack of chdir(/) in
> daemons is annoying.
> 
> But instead of adding a chdir later, I'll try to rearrange code a bit
> to do all init in the parent instead.

Or just canonicalize all relative paths before daemonizing.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2012-01-13 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-13  9:04 [Qemu-devel] [PATCH] do not chdir(/) in qemu-nbd Michael Tokarev
2012-01-13 11:57 ` Stefan Hajnoczi
2012-01-13 12:47   ` Michael Tokarev
2012-01-13 13:01     ` Daniel P. Berrange [this message]
2012-01-13 13:41     ` Paolo Bonzini

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=20120113130101.GD32411@redhat.com \
    --to=berrange@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.