On Fri, Oct 23, 2009 at 11:41 PM, Ondrej Certik <ond...@certik.cz> wrote:
> On Fri, Oct 23, 2009 at 4:21 PM, Ondrej Certik <ond...@certik.cz> wrote:
>> Interesting. Do you have some notes about your KVM setup? I want to
>> try it as well, as the ubuntu guys seem to prefer it over virtualbox:

I'm using kvm directly (not libvirt / virt-manager). This is kvm 0.72
from debian/lenny.
The command line is long, and includes the following options --- I'll
add a comment on them:

-m 2048        ### 2 GB of memory for this virtual machine
-smp 2          ### 2 virtual cpus
-nographic    ### no virtual vga

-net nic,model=virtio       ### virtio network card in the guest
-net user                          ### user mode network support in the host

-drive file=debian-1.raw,if=virtio,boot=on
### this is the OS image (9.4GB raw file -- using virtio disk drive)

-drive file=swap-1.raw,if=virtio,cache=off
### another one for swap (4 GB)

-monitor unix:/home/vm/debian/debian-1.monitor,server,nowait
### unix socket used for control of the VM

-cpu qemu64,model=15,+ht,+ssse3,+cx16,"model_id=Intel(R) Core(TM)2
Quad  CPU   Q9550  @ 2.83GHz"
### this makes it so the cpuid in the virtual machine reports good
flags -- important when compiling sage

-kernel /boot/vmlinuz-2.6.26-1-amd64
-initrd /boot/initrd.img-2.6.26-1-amd64
-append "root=/dev/vda1  ro quiet console=ttyS0,115200"
### kernel options for booting the VM. I'm using 2.6.26, this is a
kernel from debian
### it's actually booting a kernel in the /boot directory of the host
OS --- but the host itself is running 2.6.29-2.
### The console option for the kernel makes it so that guest console
goes through ttyS0 (because I don't have VGA hardware in the guest)

-redir tcp:11022::22
### I can ssh to the guest through port 11022 in the host

-redir tcp:8000::8000
### I can access to port 8000 in the guest through port 8000 in the
host --- this is where the sage notebook listens

-----

The host system is debian lenny
The guest system is also debian lenny

Both are 64 bit.

The machine is a core 2 quad Q9550 with 8Gb of ram.

I also explored using huge pages for the kvm memory, and it seems to
make a bit of a difference, but I'm not using that in production.

----

This is a shell script I use in /etc/init.d, so the VM runs
automatically at startup, etc:

-----------------------
#! /bin/sh
# Start/stop the Sage notebook server.
#
### BEGIN INIT INFO
# Provides:          kvm-sage1
# Required-Start:    $kvm
# Required-Stop:     $kvm
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: KVM for "sage1".
# Description:       KVM for "sage1".
### END INIT INFO

NAME=kvm-sage1
USER=tornaria
MONFILE=/home/vm/debian/debian-1.monitor
PIDFILE=/home/vm/debian/debian-1.pid
DIR=/home/vm/debian
SCRIPT=run.sh

. /lib/lsb/init-functions

case "$1" in
start) log_daemon_msg "Starting KVM for sage1" "${SCRIPT}"
       start-stop-daemon --start --quiet --pidfile ${PIDFILE} --chuid
${USER} --chdir ${DIR} --startas /usr/bin/screen -- -dmS ${NAME}
${DIR}/${SCRIPT}
       log_end_msg $?
       ;;
stop)  log_daemon_msg "Stopping KVM for sage1" "${SCRIPT}"
       echo "system_powerdown" | socat -t 30 - UNIX-CONNECT:$MONFILE >
/dev/null 2>&1 ||
       start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
       log_end_msg $?
       ;;
*)     log_action_msg "Usage: /etc/init.d/kvm-sage1 {start|stop}"
       exit 2
       ;;
esac
exit 0
-----------------


You can see in the stop part how to use the monitor socket to control
the KVM. In the example, we issue "system_powerdown", that's the
virtual equivalent of pressing the power button; the guest OS should
get an ACPI powerdown event, and it has 30 seconds to cleanly shutdown
(-t 30 option for socat).


Gonzalo

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to