I didn’t have issues that I can remember with kvm and systemd under 12.1. I don’t seem to have major issues under 12.2 either. But I’m using my own method though, and I have no idea what to do and how to do with YaST hypervisor tools. I use basically the same method under Fedora, Ubuntu and ArchLinux. The libvirtd and virt-install versions might be slightly different (and support more or less os variants for guests) but my script takes care of that.
*If all you want or need is to install Windows guests, you can safely skip this post. I don’t offer Windows support (nor does vm-create). VirtualBox is good enough and probably better than kvm for running Windows guests. *
Here’s the method I use to install Linux and Unix guests. I updated vm-create and I’m still testing it under 12.2 now.
As root,
- add and refresh my repo and install vmscripts:
$ su -l
# zypper ar [noparse] http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_12.2/[/noparse]](http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_12.2/) PTA
# zypper --gpg-auto-import-keys refresh -r PTA
# zypper -n in vmscripts
- install the following packages:
# zypper in virt-manager virt-viewer qemu kvm
- enable the libvirtd service:
# systemctl enable libvirtd.service
When you reboot, libvirtd should be running:
# systemctl status libvirtd.service
libvirtd.service - Virtualization daemon
Loaded: loaded (/lib/systemd/system/libvirtd.service; **enabled**)
Active: **active (running) **since Thu, 20 Sep 2012 22:52:55 -0700; 6min ago
Main PID: 3987 (libvirtd)
CGroup: name=systemd:/system/libvirtd.service
3987 /usr/sbin/libvirtd --listen
Sep 20 22:52:56 gwynn libvirtd[3987]: 2012-09-21 05:52:56.306+0000: 4471: info : libvirt version: 0.9.11.4
Sep 20 22:52:56 gwynn libvirtd[3987]: 2012-09-21 05:52:56.306+0000: 4471: warning : virSecurityManagerNew:129 : Configured security driver "none" disables default policy to create confined guests
and kvm should be loaded. So on an AMD CPU, lsmod will show this:
# lsmod | grep kvm
kvm_amd 59609 0
kvm 447778 1 kvm_amd
and on an Intel CPU (from a 12.1 system) :
# lsmod | grep kvm
kvm_intel 141431 0
kvm 438869 1 kvm_intel
- Next create a directory to store your virtual machines and another one to store the iso images.
I’ll take /misc/vm and /misc/iso, because these are the defaults in vm-create. If you use other
paths, you should set the value of IMGPATH and ISOPATH in /etc/vm-create.cfg accordingly.
# mkdir -p /misc/{vm,iso}
- create a local storage pool for the virtual machines. It’s probably easier with a little script (Modify** vmpath**
if needed):
#! /bin/bash
**vmpath=/misc/vm**
-d $vmpath ] || mkdir -p $vmpath
if -d $vmpath ] ; then
service libvirtd status &>/dev/null || service libvirtd start
cat > /tmp/default.xml << DEFAULTPOOL
<pool type='dir'>
<name>default</name>
<source>
</source>
<target>
<path>$vmpath</path>
</target>
</pool>
DEFAULTPOOL
if -f /etc/libvirt/storage/default.xml ] ; then
virsh -c qemu:///system pool-dumpxml default | grep -q $vmpath || {
virsh -c qemu:///system pool-destroy default 2>/dev/null
virsh -c qemu:///system pool-undefine default 2>/dev/null
virsh -c qemu:///system pool-create /tmp/default.xml
virsh -c qemu:///system pool-dumpxml default > /etc/libvirt/storage/default.xml
}
else
echo "- creating default storage pool in $vmpath"
mkdir -p /etc/libvirt/storage/autostart 2>/dev/null
virsh -c qemu:///system pool-create /tmp/default.xml
virsh -c qemu:///system pool-dumpxml default > /etc/libvirt/storage/default.xml
fi
ln -sfn /etc/libvirt/storage/{default.xml,autostart/default.xml}
fi
If the script succeeds, it should print:
- creating default storage pool in /misc/vm
Pool default created from /tmp/default.xml
- Set the IP of your gateway in the variable GW in /etc/vm-create.cfg:
# your gateway (unless set in the environment variable GATEWAY)
GW=192.168.101.1
Now you can create and run kvm virtual machines on your local hypervisor. Notice that vm-create can also install guests on remote hypervisors (using ssh, not tls - sorry).
# nat2bridge
assuming you want to use bridge. Don’t ask me how to use NAT, as I don’t.
When you’re done using the hypervisor and after you powered off the last virtual machine, you can remove the bridge with:
# bridge2nat
I don’t say it is the best way to do it. It’s just the way I do it.
You can check if the bridge is up with** ifconfig -a**
- Finally a single command like the following one will create a virtual machine (called ‘olaf’) with a 10GiB virtual disk, 1 GiB of memory, sound support and install openSUSE 12.2 from network in it:
# vm-create -s 10 -S -b br0 -u opensuse olaf
If you want to see what this command does without actually doing anything, use the option** -t** ( or** --try**):
# vm-create **-t** -s 10 -S -b br0 -u opensuse olaf
virt-install
--connect=qemu:///system
--ram=1024
--arch=i386
--vcpus=1
--video=vga
--soundhw=default
--description="olaf (opensuse 12.2) - vm guest on host jadzia"
--os-variant=opensuse12
--cdrom=/misc/iso/openSUSE-12.2-NET-i586.iso
--boot=cdrom,hd,network
--disk path=/misc/vm/olaf_hd0.img,size=10
--network bridge=br0
--vnc
--vnclisten=0.0.0.0
--name=olaf
iso URL: http://download.opensuse.org/distribution/12.2/iso/openSUSE-12.2-NET-i586.iso
Use** vm-create -h** to see the different options and read this thread for more info: create kvm virtual machines](http://forums.opensuse.org/english/other-forums/development/programming-scripting/453962-vm-create-create-kvm-virtual-machines.html?highlight=vm-bridge).
- Press escape to exit the splash screen and see what’s happening. Loading the installation may take some time.
http://imageshack.us/a/img37/2121/opensuse122kvmsmall.jpg](http://imageshack.us/a/img856/1421/opensuse122kvm.jpg)
Der Rest ist Arbeit…