From a025e7e7e287c2539d883bd40a769ae29f9087ff Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 16 Aug 2012 10:47:33 -0400 Subject: [PATCH] Provide a common share between VMs to allow easy communication Every VM now mounts a common SMB share on /tmp/shared. --- lib/test-driver/Machine.pm | 10 +++++++++- modules/virtualisation/qemu-vm.nix | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/test-driver/Machine.pm b/lib/test-driver/Machine.pm index 9018dc589e40..3e6a1c8d158c 100644 --- a/lib/test-driver/Machine.pm +++ b/lib/test-driver/Machine.pm @@ -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) = @_; @@ -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, @@ -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 " . diff --git a/modules/virtualisation/qemu-vm.nix b/modules/virtualisation/qemu-vm.nix index 1de8d5b82ed7..f71e0ba51126 100644 --- a/modules/virtualisation/qemu-vm.nix +++ b/modules/virtualisation/qemu-vm.nix @@ -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. @@ -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";