Differences between revisions 17 and 18
Deletions are marked like this. Additions are marked like this.
Line 95: Line 95:
apt-get install libvirt-bin virtinst apt-get install libvirt-bin virtinst qemu-kvm

Making a VM

Both of these methods explain how to make a VM using the libvirt tools with a remote connection authenticated with admin Kerberos tickets (that's how qemu+tcp is set up). But you can also just ssh straight to the host and run the tools, or tunnel your remote connection over ssh (using qemu+ssh instead).

No matter which set of tools you use, you should first make a Netreg entry and Common Maintenance Tasks/Adding and removing DNS records.

TODO make a NetReg walkthrough.

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

First a sanity check.

apt-get install virtinst virt-manager # or equivalent

kinit $USER/admin@CLUB.CC.CMU.EDU
virsh --connect qemu+tcp://kvm02.club.cc.cmu.edu/system list
# does it work? okay, move on

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: TCP, 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 man virt-install.

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

  4. Make sure to set the MAC address to the one in NetReg so DHCP does its thing. (This must be done if you're using a network install).

  5. You may want to check "Customize configuration before install" and add a serial console, or inject "console=ttyS0" into the kernel command line.
  6. You're done.

You may want to clubify that machine.

CLI (virsh/virt-install)

# if you're not ssh'd to the host itself, and are running these
# locally (which is totally okay), then you should either:
# Pass --connect qemu+tcp://kvm02.club.cc.cmu.edu/system as an
# argument to all commands.
# Set LIBVIRT_DEFAULT_URI, like this:
export LIBVIRT_DEFAULT_URI=qemu+tcp://kvm02.club.cc.cmu.edu/system 

virt-install
# this will error and demand a few additional arguments.
# 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/    
# --location url will do a netinst, the other arguments are obvious
# you can instead pass --location dir, --cdrom, --pxe, etc., many things
# try running without arguments, and check the manpage

Some useful other arguments:

  • Network
    • to not be NAT'd, --network bridge=br0,mac=what:you:put:in:net:reg
  • Graphics
    • to force creation of a graphical display, --graphics vnc or --graphics spice
    • to force no creation of graphical display, --graphics none
    • if --graphics something isn't present, it'll choose the appropriate one based on whether DISPLAY is set
  • Console
    • to force the creation of a text console, --extra-args console=ttyS0
    • you can attach to the text console with virsh -c url console namium

# FOR THE LAZY: typical cclub invocation
virt-install --name $VM_HOSTNAME --memory 512 --disk size=10 \
             --graphics none --extra-args console=ttyS0 \
             --network bridge=br0,mac=whatyouputinnetreg \
             --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 log in and make VMs.

# TODO copy my notes about configuring Kerberos ticket auth 

Now you can remotely authenticate with CClub admin tickets and make VMs.

Common Maintenance Tasks/Building KVM Domains (last edited 2016-04-18 20:54:43 by grantwu@CLUB.CC.CMU.EDU)