Provide a common share between VMs to allow easy communication

Every VM now mounts a common SMB share on /tmp/shared.
This commit is contained in:
Eelco Dolstra 2012-08-16 10:47:33 -04:00
parent 0e3f03106f
commit a025e7e7e2
2 changed files with 23 additions and 1 deletions

View File

@ -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 " .

View File

@ -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";