Skip to content

Commit

Permalink
Provide a common share between VMs to allow easy communication
Browse files Browse the repository at this point in the history
Every VM now mounts a common SMB share on /tmp/shared.
  • Loading branch information
edolstra committed Aug 16, 2012
1 parent 0e3f031 commit a025e7e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/test-driver/Machine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ use POSIX qw(dup2);
use FileHandle;
use Cwd;
use File::Basename;
use File::Path qw(make_path);


my $showGraphics = defined $ENV{'DISPLAY'};

my $sharedDir;


sub new {
my ($class, $args) = @_;
Expand Down Expand Up @@ -40,7 +43,11 @@ sub new {
}

my $tmpDir = $ENV{'TMPDIR'} || "/tmp";

unless (defined $sharedDir) {
$sharedDir = $tmpDir . "/xchg-shared";
make_path($sharedDir, { mode => 0700, owner => $< });
}

my $self = {
startCommand => $startCommand,
name => $name,
Expand Down Expand Up @@ -123,6 +130,7 @@ sub start {
dup2(fileno($serialC), fileno(STDOUT));
dup2(fileno($serialC), fileno(STDERR));
$ENV{TMPDIR} = $self->{stateDir};
$ENV{SHARED_DIR} = $sharedDir;
$ENV{USE_TMPDIR} = 1;
$ENV{QEMU_OPTS} =
"-no-reboot -monitor unix:./monitor -chardev socket,id=shell,path=./shell " .
Expand Down
14 changes: 14 additions & 0 deletions modules/virtualisation/qemu-vm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ let
cd $TMPDIR
mkdir -p $TMPDIR/xchg
EXTRA_SAMBA_CONF="
[shared]
force user = $WHO
path = ''${SHARED_DIR:-$TMPDIR/xchg}
read only = no
guest ok = yes
"
${pkgs.vmTools.startSamba}
# Start QEMU.
Expand Down Expand Up @@ -328,6 +336,12 @@ in
options = "guest,sec=none,noperm,noacl";
neededForBoot = true;
}
{ mountPoint = "/tmp/shared";
device = "//10.0.2.4/shared";
fsType = "cifs";
options = "guest,sec=none,noperm,noacl";
neededForBoot = true;
}
] ++ optional cfg.useBootLoader
{ mountPoint = "/boot";
device = "/dev/disk/by-label/boot";
Expand Down

0 comments on commit a025e7e

Please sign in to comment.