mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 07:01:54 +00:00
* Use QEMU/KVM's paravirtualised console device for the backdoor.
This has the advantage that it doesn't depend on networking being up. * Move common QEMU/KVM guest configuration to profiles/qemu-guest.nix. svn path=/nixos/trunk/; revision=26421
This commit is contained in:
parent
c52aeacf1a
commit
be0fca5781
@ -125,8 +125,8 @@ sub start {
|
||||
$ENV{USE_TMPDIR} = 1;
|
||||
$ENV{QEMU_OPTS} =
|
||||
"-no-reboot -monitor unix:./monitor -chardev socket,id=shell,path=./shell " .
|
||||
"-device virtio-serial -device virtconsole,chardev=shell " .
|
||||
($showGraphics ? "-serial stdio" : "-nographic");
|
||||
$ENV{QEMU_NET_OPTS} = "guestfwd=tcp:10.0.2.6:23-chardev:shell";
|
||||
$ENV{QEMU_KERNEL_PARAMS} = "hostTmpDir=$ENV{TMPDIR}";
|
||||
chdir $self->{stateDir} or die;
|
||||
exec $self->{startCommand};
|
||||
|
8
modules/profiles/qemu-guest.nix
Normal file
8
modules/profiles/qemu-guest.nix
Normal file
@ -0,0 +1,8 @@
|
||||
# Common configuration for virtual machines running under QEMU (using
|
||||
# virtio).
|
||||
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
boot.initrd.kernelModules = [ "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "virtio_console" ];
|
||||
}
|
@ -24,10 +24,7 @@ in
|
||||
config = {
|
||||
|
||||
jobs.backdoor =
|
||||
{ # If the firewall is enabled, this job must start *after* the
|
||||
# firewall, otherwise connection tracking won't know about
|
||||
# this connection.
|
||||
startOn = if config.networking.firewall.enable then "started firewall" else "ip-up";
|
||||
{ startOn = "startup";
|
||||
stopOn = "never";
|
||||
|
||||
script =
|
||||
@ -37,8 +34,10 @@ in
|
||||
export DISPLAY=:0.0
|
||||
source /etc/profile
|
||||
cd /tmp
|
||||
echo "connecting to host..." > /dev/ttyS0
|
||||
${pkgs.socat}/bin/socat tcp:10.0.2.6:23 exec:${rootShell} 2> /dev/ttyS0 # || poweroff -f
|
||||
exec < /dev/hvc0 > /dev/hvc0 2> /dev/ttyS0
|
||||
echo "connecting to host..." >&2
|
||||
stty -F /dev/hvc0 raw # prevent nl -> cr/nl conversion
|
||||
${pkgs.socat}/bin/socat stdio exec:${rootShell}
|
||||
'';
|
||||
|
||||
respawn = false;
|
||||
|
@ -228,7 +228,7 @@ let
|
||||
in
|
||||
|
||||
{
|
||||
require = options;
|
||||
require = [ options ../profiles/qemu-guest.nix ];
|
||||
|
||||
boot.loader.grub.device = mkOverride 50 "/dev/vda";
|
||||
|
||||
@ -236,7 +236,7 @@ in
|
||||
# CIFS. Also use paravirtualised network and block devices for
|
||||
# performance.
|
||||
boot.initrd.availableKernelModules =
|
||||
[ "cifs" "virtio_net" "virtio_pci" "virtio_blk" "virtio_balloon" "nls_utf8" ]
|
||||
[ "cifs" "nls_utf8" ]
|
||||
++ optional cfg.writableStore [ "aufs" ];
|
||||
|
||||
boot.extraModulePackages =
|
||||
|
Loading…
Reference in New Issue
Block a user