Making a VM

Both of these methods explain how to make a VM using the libvirt tools with a remote connection tunneled over ssh, which can be authenticated any way you please. But you can also just ssh straight to the host and run the tools.

No matter which set of tools you use, you should first make a Netreg entry and make a DNS entry.

kvm02 is the only host in an acceptable state at the moment. So just use that one.

Install the necessary packages to do this remotely!

apt-get install virtinst virt-manager virt-viewer 
pacman -Ss virt-manager # virt-viewer is in AUR

GUI (virt-manager)

Honestly this is not hard, you can really just follow some random tutorial.

  1. Start virt-manager.
  2. File->Add Connection, Method: SSH, Username: yourusername, Hostname: kvm02.club.cc.cmu.edu

  3. Click new VM and follow the prompts. For maximum ease of use, choose Network Install on the first step, and paste in a url from the --location section of man virt-install.

    Or just paste in http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/

  4. If you don't want to be NAT'd, make sure to change the network interface in "Advanced Options" to Bridge br0,

    and set the MAC address to the one in NetReg so DHCP does its thing.

  5. You're done.

You may want to clubify that machine.

CLI (virsh/virt-install)

# Set LIBVIRT_DEFAULT_URI, like this:
export LIBVIRT_DEFAULT_URI=qemu+ssh://$USER@kvm02.club.cc.cmu.edu/system 
# or add the argument --connect qemu+ssh://$USER@kvm02.club.cc.cmu.edu/system
# or just ssh kvm02.club.cc.cmu.edu and do these things

# this actually presents a useful error message
virt-install
# so, a full invocation might be:
virt-install --name namium --memory 512 --disk size=10 \
             --location http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/    

To find out what, say, --location does, perform the following operation:

  1. open the man page
  2. search for it

Nevertheless, here are some useful arguments:

# FOR THE LAZY: typical cclub invocation
virt-install --name $VM_HOSTNAME --memory 512 --disk size=10 \
             --network bridge=br0,mac=whatyouputinnetreg \
             --extra-args console=ttyS0 \
             --location http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/    

OK, you're done! You may want to clubify that machine.

Making a Host

# Install libvirt, which pulls in QEMU/KVM by default
apt-get install libvirt-bin virtinst qemu-kvm

Now you can make VMs.

# Configure the networking bridge so we can get non-NAT'd IPs
sensible-editor /etc/interfaces/network
# Add something like the following (assumes you're using DHCP for the
# host rather than static networking)

# auto lo br0
# iface lo inet loopback
# 
# iface eth0 inet manual
# 
# iface br0 inet dhcp
#       bridge_ports eth0
#       bridge_stp off

Now you can make VMs that can DHCP to get NetReg'd IPs.

Clubify the machine.

Now you can ssh in.

# change something in /etc/libvirt/libvirtd.conf so the unix socket controlling libvirt is accessible by all users, or users in the "wheel" group, or something

Now you can make VMs as non-root, so you can remotely make VMs over ssh.

libvirtifying an existing Xen host

sensible-editor /etc/xen/xend-config.sxp
# make sure this is present and uncommented:
# (xend-unix-server yes)
service xen restart
apt-get install libvirt-bin netcat-openbsd pm-utils
# libvirt remoting wants a certain version of netcat, what can I say?
# pm-utils is also necessary to prevent a (harmless but annoying) error message