Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-12-16 Thread Vagrant Cascadian
tags 618743 patch
thanks

there's a patch (included below) from upstream that should resolve the issue. 
it seems to at least apply to both the 0.15 and 1.0 series.

would you be able to test it?

live well,
  vagrant


commit 885660bd48efbe3742892e06de7a8898703e0bdc
Author: Michael Roth mdr...@linux.vnet.ibm.com
Date:   Wed Dec 7 21:48:07 2011 -0600

network scripts: don't block SIGCHLD before forking

This patch fixes a bug where child processes of launch_script() can
misbehave due to SIGCHLD being blocked. In the case of `sudo`, this
causes a permanent hang.

Previously a SIGCHLD handler was added to reap fork_exec()'d zombie
processes by calling waitpid(-1, ...). This required other
fork()/waitpid() callers to temporarilly block SIGCHILD to avoid
having the final wait status being intercepted by the SIGCHLD
handler:

7c3370d4fe3fa6cda8655f109e4659afc8ca4269

Since then, the qemu_add_child_watch() interface was added to allow
registration of such processes and reap only from that specific set
of PIDs:

4d54ec7898bd951007cb6122d5315584bd41d0c4

As a result, we can now avoid blocking SIGCHLD in launch_script(), so
drop that behavior.

Reviewed-by: Jan Kiszka jan.kis...@siemens.com
Reviewed-by: Paolo Bonzini pbonz...@redhat.com
Signed-off-by: Michael Roth mdr...@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori aligu...@us.ibm.com

diff --git a/net/tap.c b/net/tap.c
index 1f26dc9..6c27a94 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -346,15 +346,10 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
 
 static int launch_script(const char *setup_script, const char *ifname, int fd)
 {
-sigset_t oldmask, mask;
 int pid, status;
 char *args[3];
 char **parg;
 
-sigemptyset(mask);
-sigaddset(mask, SIGCHLD);
-sigprocmask(SIG_BLOCK, mask, oldmask);
-
 /* try to launch network script */
 pid = fork();
 if (pid == 0) {
@@ -378,7 +373,6 @@ static int launch_script(const char *setup_script, const 
char *ifname, int fd)
 while (waitpid(pid, status, 0) != pid) {
 /* loop */
 }
-sigprocmask(SIG_SETMASK, oldmask, NULL);
 
 if (WIFEXITED(status)  WEXITSTATUS(status) == 0) {
 return 0;



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-04-03 Thread Christian Marillat
Aurelien Jarno aurel...@aurel32.net writes:

[...]

 For me it is a bug in dash or sudo. See the attached code for a reduced
 testcase.

As I'm saying this bug doesn't exist in qemu 0.9.1

Christian



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-04-03 Thread Aurelien Jarno
On Sun, Apr 03, 2011 at 10:07:27AM +0200, Christian Marillat wrote:
 Aurelien Jarno aurel...@aurel32.net writes:
 
 [...]
 
  For me it is a bug in dash or sudo. See the attached code for a reduced
  testcase.
 
 As I'm saying this bug doesn't exist in qemu 0.9.1
 

Of course this bug doesn't exist with qemu 0.9.1, given that the code
blocking SIGCHLD has been introduced in 0.11.0. It doesn't mean it's a
bug in qemu.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-04-02 Thread Aurelien Jarno
On Thu, Mar 31, 2011 at 01:17:11PM +0200, Andreas Mohr wrote:
 Turns out that dash 0.5.4-12 is NOT affected. Re-upgrading to
 current 0.5.5.1-7.4 package then makes it lock up again.
 
 Non-sudo-prefixed lines (e.g. tested via echo, ls, find, ...)
 in the script work fine, it's specifically sudo-based commands which are 
 problematic.
 
 
 Note that manually executing a test script such as
 
 #!/bin/sh
 
 /usr/bin/sudo echo Hi
 /usr/bin/sudo whoami
 
 does terminate properly, when executed as the same user that kvm would
 execute the scripts as (and when indeed having dash-as-sh).
 Thus it appears that _something_ about the way that kvm sets up its
 startup shell scripts context makes things break, i.e. within kvm only.
 

The issue here is that QEMU is blocking the SIGCHLD signal before
forking, to make sure it won't get any signal due to the child exiting.

sigprocmask() settings are inherited during a fork and dash or sudo do
use SIGCHLD somewhere in their code, without making sure the signal is
enabled.

For me it is a bug in dash or sudo. See the attached code for a reduced
testcase.

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net
#include stdio.h
#include unistd.h
#include signal.h
#include sys/types.h
#include sys/wait.h

int main(int argc, char *argv[])
{
if (argc  0) {
sigset_t oldmask, mask;
int pid, status;
char *args[3];
char **parg;

sigemptyset(mask);
sigaddset(mask, SIGCHLD);
sigprocmask(SIG_BLOCK, mask, oldmask);

pid = fork();
if (pid == 0) {
int open_max = sysconf(_SC_OPEN_MAX), i;

for (i = 0; i  open_max; i++) {
if (i != STDIN_FILENO 
i != STDOUT_FILENO 
i != STDERR_FILENO) {
close(i);
}
}
	parg = args;
	*parg++ = (char *)argv[1];
	*parg = NULL;
execv(argv[1], args);
_exit(1);
} else if (pid  0) {
while (waitpid(pid, status, 0) != pid) {
/* loop */
}
sigprocmask(SIG_SETMASK, oldmask, NULL);

if (WIFEXITED(status)  WEXITSTATUS(status) == 0) {
return 0;
}
}
fprintf(stderr, %s: could not script\n, argv[1]);
return -1;
}
}



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-03-31 Thread Andreas Mohr
Turns out that dash 0.5.4-12 is NOT affected. Re-upgrading to
current 0.5.5.1-7.4 package then makes it lock up again.

Non-sudo-prefixed lines (e.g. tested via echo, ls, find, ...)
in the script work fine, it's specifically sudo-based commands which are 
problematic.


Note that manually executing a test script such as

#!/bin/sh

/usr/bin/sudo echo Hi
/usr/bin/sudo whoami

does terminate properly, when executed as the same user that kvm would
execute the scripts as (and when indeed having dash-as-sh).
Thus it appears that _something_ about the way that kvm sets up its
startup shell scripts context makes things break, i.e. within kvm only.

Thus I'm keeping this bug filed under qemu-system
instead of reassign dash 0.5.5.1-7.4, for now.

Thanks,

Andreas Mohr



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-03-30 Thread Andreas Mohr
Hello Christian (and tons of Packaging Thanks! :),

same issue here.

Turns out this line

 Shell: /bin/sh linked to /bin/dash

was the most important one in your report.

When using dash, _EVERY_ _SINGLE_ _PROCESS_ as spawned by dash
from within that kvm-launched kvm-ifup script ends up as defunct == zombie.
I finally got that Aha! moment when kill -9'ing the currently stuck
process and fortunately realizing that it proceeded with executing the
subsequent shell line script process and got stuck again.

dpkg-reconfigure dash, reverting to bash (which I normally never do,
since it's all working perfectly fine provided one knows to avoid
bashisms - devscript package's checkbashism script - in custom
scripts) finally makes it work again.

So, I don't know _why_ on dash it gets stuck (possibly due to specific
shell execution environment limitations as imposed by kvm startup??),
but IMHO such a strange issue should be investigated ASAP
(also since dash appears to be the new default).


Myself, I'm executing kvm as non-root user, BTW (not sure at all whether
that actually makes any difference here, though).

Side note: Gaad, I really hate having to experience odd little
thoroughly annoying kvm setup quirks on almost every friggin' single ยง%damn
kvm upgrade I do.

Oh well, at least _this time_ again it's working again ;)

HTH,

Andreas Mohr



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-03-30 Thread Christian Marillat
Andreas Mohr a...@lisas.de writes:

 Hello Christian (and tons of Packaging Thanks! :),

Hi Andreas, you're welcome :)

 same issue here.

 Turns out this line

 Shell: /bin/sh linked to /bin/dash

Great. Many thanks. My script works now as before.

 dpkg-reconfigure dash, reverting to bash (which I normally never do,
 since it's all working perfectly fine provided one knows to avoid
 bashisms - devscript package's checkbashism script - in custom
 scripts) finally makes it work again.

I think the best/more easy is to change the shebang for the
/etc/qemu-ifup script.

 So, I don't know _why_ on dash it gets stuck (possibly due to specific
 shell execution environment limitations as imposed by kvm startup??),
 but IMHO such a strange issue should be investigated ASAP
 (also since dash appears to be the new default).

Would be nice to know why sh still works with qemu 0.9.1 and not with
the latest qemu.

Christian



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-03-30 Thread Andreas Mohr
Hi,

On Wed, Mar 30, 2011 at 05:53:48PM +0200, Christian Marillat wrote:
 Andreas Mohr a...@lisas.de writes:
  dpkg-reconfigure dash, reverting to bash (which I normally never do,
  since it's all working perfectly fine provided one knows to avoid
  bashisms - devscript package's checkbashism script - in custom
  scripts) finally makes it work again.
 
 I think the best/more easy is to change the shebang for the
 /etc/qemu-ifup script.

Definitely easier, but... IMHO the problem should be squashed if at all
possible instead of having this workaround (and you can bet some Debian
maintainer would inadvertently switch it back within months ;)).

  So, I don't know _why_ on dash it gets stuck (possibly due to specific
  shell execution environment limitations as imposed by kvm startup??),
  but IMHO such a strange issue should be investigated ASAP
  (also since dash appears to be the new default).
 
 Would be nice to know why sh still works with qemu 0.9.1 and not with
 the latest qemu.

OK, so we have data point:
- worked on 0.9.1

And I can add:
- could be sudo-related (echo or test commands in the script
  don't hang) - but this could instead be a more global shell builtins working
  vs. external commands hanging issue...
  Will nail this data point down soon (once I can test again).

Andreas Mohr



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#618743: qemu-system: Tap interface doesn't work anymore

2011-03-18 Thread Christian Marillat
Package: qemu-system
Version: 0.14.0+dfsg-4
Severity: important

Hi,

I've updated qemu from 0.9.1 to this version and I'm now unable to make any
connection with tap.

qemu freeze in the network link creation (See the /etc/qemu-ifup script at
the botttom) :

Bringing up tap0 for bridged mode...

root 19965  0.0  0.0   1792   500 pts/7S07:21   0:00 /bin/sh -x 
/etc/qemu-ifup tap0
root 19968  0.0  0.0   3652  1096 pts/7S07:21   0:00 sudo /sbin/ip 
link set tap0 up
root 19971  0.0  0.0  0 0 pts/7Z07:21   0:00 [ip] defunct

Same problem if I use ifconfig instead of ip :

sudo /sbin/ifconfig $1 0.0.0.0 promisc up

Same problem if I use the dafault  mac address for the interface.

The command line :

sudo qemu-system-mips -M malta -no-reboot -kernel vmlinux-2.6.32-5-4kc-malta
-hda Mips.qcow2 -append root=/dev/sda1 console=tty0 -m 256 -net
-nic,macaddr=52:54:00:12:34:60 -net tap

I see also the same for qemu-system-arm, qemu-system-mipsel or qemu.

Christian

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.38 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages qemu-system depends on:
ii  etherboot-qemu  5.4.4-9  Bootstrapping for various network 
ii  libaio1 0.3.109-1Linux kernel AIO access library - 
ii  libasound2  1.0.23-2.1   shared library for ALSA applicatio
ii  libattr11:2.4.44-2   Extended attribute shared library
ii  libbluetooth3   4.87-2   Library to use the BlueZ Linux Blu
ii  libbrlapi0.54.2-7braille display access via BRLTTY 
ii  libc6   2.11.2-11Embedded GNU C Library: Shared lib
ii  libcurl3-gnutls 7.21.4-1 Multi-protocol file transfer libra
ii  libesd0 0.2.41-8 Enlightened Sound Daemon - Shared 
ii  libgnutls26 2.10.5-1 the GNU TLS library - runtime libr
ii  libjpeg62   6b1-1The Independent JPEG Group's JPEG 
ii  libncurses5 5.8+20110307-1   shared libraries for terminal hand
ii  libpng12-0  1.2.44-2 PNG library - runtime
ii  libpulse0   0.9.21-4 PulseAudio client libraries
ii  librados1   0.24.3-2 RADOS distributed object store cli
ii  libsasl2-2  2.1.23.dfsg1-8   Cyrus SASL - authentication abstra
ii  libsdl1.2debian 1.2.14-6.1   Simple DirectMedia Layer
ii  libuuid12.17.2-9.1   Universally Unique ID library
ii  libvdeplug2 2.2.3-3  Virtual Distributed Ethernet - Plu
ii  libx11-62:1.4.1-5X11 client-side library
ii  openbios-ppc1.0+svn1018-1PowerPC Open Firmware
ii  openbios-sparc  1.0+svn1018-1SPARC Open Firmware
ii  openhackware0.4.1-4  OpenFirmware emulator for PowerPC
ii  qemu-keymaps0.14.0+dfsg-4QEMU keyboard maps
ii  seabios 0.6.1.2-2Legacy BIOS implementation
ii  vgabios 0.6c-3   VGA BIOS software for the Bochs an
ii  zlib1g  1:1.2.3.4.dfsg-3 compression library - runtime

Versions of packages qemu-system recommends:
ii  qemu-utils 0.14.0+dfsg-4 QEMU utilities
pn  vde2   none(no description available)

Versions of packages qemu-system suggests:
pn  samba none (no description available)

-- Configuration Files:
/etc/qemu-ifup changed:
echo Executing /etc/qemu-ifup
echo Bringing up $1 for bridged mode...
sudo /sbin/ip link set $1 up
echo Adding $1 to br0...
sudo /usr/sbin/brctl addif br0 $1
sleep 2


-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org