Our discussion will cover various implementations of
virtual machines including qemu
, virtualbox
, and vmware
running on a real
machine running some version of Ubuntu.
If you want to startup a Vmware virtual host from the command you can do
vmware-cmd /virtual_machines/vmware/cscfprint1/cscfprint1.vmx startwhere the host in question is on trainer.cscf. Basically look for the file that ends with .vmx, it is a executable =#!/usr/bin/vmware# shell script.
qemu
, kqemu=common
and kqemu-source
where the latter two packages
allow for kernal module that permits greatly improved performance of any virtual
machines installed in qemu
. Alas the required device file /dev/kqemu
is not
generated automatically. To do this we do the following /etc/udev/rules.d/60-kqemu.rules
with the contents KERNEL=="kqemu", NAME="kqemu", OWNER="root", GROUP="kqemu", MODE="0660"Then reload udev configuration by running
/etc/init.d/udev reload
. (NOTE. This does not cause the /dev/kqemu
file file, see below for what will.)
GROUP
specification dictates we should create a UNIX group with that name, and any users who wish to launch any virtual machines into that group addgroup --system kqemu adduser cscf-adm kqemu
/etc/modprobe.d/kqemu
(part of the =kqemu-common) package so that the contents look like options kqemu major=0(Aside: Not sure why this is necessary)
kqemu
by running modprobe -r kqemuThis will cause the
/dev/kqemu
device to be created (udev
responds to event requests, so we probably shouldn't be surprised this step was necessary for the creation of /dev/kqemu
. Ideally the package qemu-common
should have done this for us, I have reported this as a bug in https://bugs.launchpad.net/ubuntu/+source/kqemu/+bug/159340qemu-img
, say =gutsy-i386.img. Then
install from iso image, namely run (because we are on an AMD64 machine)
qemu-system-x86_64 -cdrom ubuntu-7.10-server-i386.iso -hda ./gutsy-i386.img -m 512 -boot dThen boot the newly installed machine via
qemu-system-x86_64 -hda ./gutsy-i386.img -m 512 -boot cBy default any virtual machine can access the network that the host machine is attached to. In particular if you installed ssh on the host, you can ssh to any host on the network and it will look like you are connecting from the host computer.
It is possible to assign a network configuration to the virtual machine. For example
qemu-system-x86_64 -hda /vmdata/qemu/gutsy-i386.img -m 512 -boot c -net nic -net tap(Aside: To run this as a non-root you need to be in the group
vde-net
as the device
permits users in this group rw
access t /dev/net/tun
)
By default the network configuration in qemu will read the script /etc/qemu-ifup
unless a different script is specified on the command line.
br0
with the IP configuration of eth0 and we disable any configuration on =eth0.
Next we join eth0 to the bridge and restart networking.
To connect the guestOS to the network of the hostOS start it up with the command
line above which will result in the execution of /etc/qemu-ifup
which consists of
#!/bin/sh echo "Executing /etc/qemu-ifup" echo "Bringing up $1 for bridged mode" sudo -p "Password for $0:" /sbin/ifconfig $1 0.0.0.0 promisc up echo "Adding $1 to br0..." sudo -p "Password for $0:" /usr/sbin/brctl addif br0 $1 sleep 2We probably could just setup a tap0 interface in
/etc/network/interfaces
?
Note the above script adds the qemu generated tap interface to the bridge
when the virtual machine starts up.
Finally configure the guestOS by editing /etc/network/interfaces
in the manner
you would a real host with an IP address that is on the same network that the
bridge br0
has been configured with.
help
is gives a list of commands. As an example stop
will suspend
any machines and cont
resumes them.