Author: eelco
Date: Fri Jan 14 16:01:47 2011
New Revision: 25570
URL: https://svn.nixos.org/websvn/nix/?rev=25570&sc=1
Log:
* Don't daemonise vde_switch so that it's cleaned up automatically.
This is useful for interactive use.
Modified:
nixos/trunk/lib/test-driver/test-driver.pl
nixos/trunk/lib/testing.nix
Modified: nixos/trunk/lib/test-driver/test-driver.pl
==============================================================================
--- nixos/trunk/lib/test-driver/test-driver.pl Fri Jan 14 15:49:46 2011
(r25569)
+++ nixos/trunk/lib/test-driver/test-driver.pl Fri Jan 14 16:01:47 2011
(r25570)
@@ -4,8 +4,10 @@
use Machine;
use Term::ReadLine;
use IO::File;
+use IO::Pty;
use Logger;
use Cwd;
+use POSIX qw(_exit dup2);
$SIG{PIPE} = 'IGNORE'; # because Unix domain sockets may die unexpectedly
@@ -18,12 +20,27 @@
my %vlans;
foreach my $vlan (split / /, $ENV{VLANS} || "") {
next if defined $vlans{$vlan};
+ # Start vde_switch as a child process. We don't run it in daemon
+ # mode because we want the child process to be cleaned up when we
+ # die. Since we have to make sure that the control socket is
+ # ready, we send a dummy command to vde_switch (via stdin) and
+ # wait for a reply. Note that vde_switch requires stdin to be a
+ # TTY, so we create one.
$log->log("starting VDE switch for network $vlan");
my $socket = Cwd::abs_path "./vde$vlan.ctl";
- system("vde_switch -d -s $socket") == 0
- or die "cannot start vde_switch";
+ my $pty = new IO::Pty;
+ my ($stdoutR, $stdoutW); pipe $stdoutR, $stdoutW;
+ my $pid = fork(); die "cannot fork" unless defined $pid;
+ if ($pid == 0) {
+ dup2(fileno($pty->slave), 0);
+ dup2(fileno($stdoutW), 1);
+ exec "vde_switch -s $socket" or _exit(1);
+ }
+ close $stdoutW;
+ print $pty "version\n";
+ readline $pty or die "cannot start vde_switch";
$ENV{"QEMU_VDE_SOCKET_$vlan"} = $socket;
- $vlans{$vlan} = 1;
+ $vlans{$vlan} = $pty;
}
Modified: nixos/trunk/lib/testing.nix
==============================================================================
--- nixos/trunk/lib/testing.nix Fri Jan 14 15:49:46 2011 (r25569)
+++ nixos/trunk/lib/testing.nix Fri Jan 14 16:01:47 2011 (r25570)
@@ -28,7 +28,7 @@
wrapProgram $out/bin/nixos-test-driver \
--prefix PATH :
"${pkgs.qemu_kvm}/bin:${pkgs.vde2}/bin:${imagemagick}/bin:${coreutils}/bin" \
- --prefix PERL5LIB : "${lib.makePerlPath [
perlPackages.TermReadLineGnu perlPackages.XMLWriter ]}:$out/lib/perl5/site_perl"
+ --prefix PERL5LIB : "${lib.makePerlPath [
perlPackages.TermReadLineGnu perlPackages.XMLWriter perlPackages.IOTty
]}:$out/lib/perl5/site_perl"
'';
};
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits