#title KVM FAQ <> ||<>|| = How to fix missing Virtual Machines after upgrading from 10.04 (Lucid) to 12.04 (Precise)? = Are all your KVM virtual machines missing after upgrading between these two LTS releases? If so, check [[https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/931350|Ubuntu Bug #931350]] for more information and how to fix the problem. Specifically, you can fix this issue by downloading and running the simple script provided by [[https://launchpad.net/~petermatulis|Peter Matulis]] in [[https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/931350/comments/9|Comment #9]]. = How to prevent VirtualBox and KVM from conflicting? = Installing KVM loads the module kvm (or kvm-intel in my case) which does not allow other virtualization software such as VirtualBox to run. The good news is that you ''can'' disable KVM and unload its modules: 1. Make sure you've completely shut down and powered off all your KVM virtual machines (using virt-manager or otherwise). 2. Unload all of its modules: {{{ $ sudo invoke-rc.d kvm stop }}} In Karmic use {{{ $ sudo invoke-rc.d qemu-kvm stop }}} instead. In Lucid and later, use {{{ $ sudo service qemu-kvm stop }}} instead. ## This section is really old !!! ##== How to boot Dapper, Edgy, Feisty or Gutsy ISO? == ## ## * Q: I'm on Intel hardware, and I'm trying to boot Dapper, Edgy, Feisty, or Gutsy, but KVM fails immediately. ## * A: Yes, this is rather unfortunate. The issue is a limitation in Intel's virtualisation extensions that don't interact very well with gfxboot. The evil, ##hacky workaround is to modify the ISO to disable gfxboot. The following has worked for me, but it might kill your cat or make your coffee go cold or make ##other unpleasantries happen to you. You've been warned! ##{{{ ##$ sed -e 's/GFXBOOT bootlogo/#FXBOOT bootlogo/g' < ubuntu-7.10-server-amd64.iso > ubuntu-7.10-server-amd64-nogfxboot.iso ##}}} ##/!\ Don't change the above command! The length of the string mustn't change or you will have knackered the filesystem on the CD. ## ##A slightly safer way is to download gfxboot-disable from [[http://hg.codemonkey.ws/gfxboot-disable]] and then run: ##{{{ ##$ gfxboot-disable ubuntu-7.10-server-amd64.iso ##}}} = How to boot a VM into single mode? = A VM has a complete BIOS, and also runs GRUB. Unfortunately, the GRUB menu disappears after a couple of seconds, which often doesn't leave time to connect using virt-viewer. There is a small trick here: shutdown the VM, run virt-viewer with the argument --wait (that way it will wait for the VM to start and pop up directly after that), and then start the VM; this should give you a good 2 seconds time to enter the BIOS or access the GRUB menu. If you are running a VM built with ubuntu-vm-builder, there is a small bug that will prevent you from logging in; in GRUB, select the recovery line and press "e"; select the line beginning with kernel, press "e" again. At the end of the line, add "init=/bin/sh" (without the quotes). Confirm with enter, and press b to boot the kernel with these settings. = How to convert VMware machines to virt-manager? = ## This seems old as well, not sure if it is working. Converting VMware -> KVM has some issues, ## Probably should add some cautions. ## (backup) If you want to convert a Windows (XP) vmdk, you must first do two things while running the VM in VMware: 0. Enable IDE in the registry. Start the machine and execute mergeide.reg. See [[http://pve.proxmox.com/wiki/Migration_of_servers_to_Proxmox_VE#Prepare_the_Windows_operating_system_2|the ProxMox wiki]] for very detailed instructions. 0. Remove VMware tools via the Control Panel. If the converted VM still displays a BSOD on boot, you can resolve the issue as follows by booting the converted VM booting from a Windows XP CD and choosing the 'Install' options ('''not''' 'R = Repair'). After a while, Windows setup should display the existing Windows installation (located in C:\Windows by default) and offer the option to repair that installation. Windows Updates will be reset after this procedure, but all your programs, settings, documents, etc. will be preserved. After this procedure, you will need to reactivate Windows, but the VM will boot. To use the VMware machine from within virt-manager, the .vmx file must be converted to libvirt's .xml. vmware2libvirt was created to help with this. It's available in Intrepid/Jaunty, install package 'virt-goodies'. After installing it can be used like so: {{{ $ vmware2libvirt -f ./file.vmx > file.xml $ virsh -c qemu:///system define file.xml }}} The first command converts the VMware 'file.vmx' file to the libvirt compatible 'file.xml'. See {{{ man vmware2libvirt }}} for details. The second command imports file.xml into libvirt. The imported .xml files are stored in /etc/libvirt/qemu. == Caveats == While vmware2libvirt works well on simple virtual machines, there are limitations because .vmx files don't always contain enough information, and also because vmware2libvirt tries not to make too many assumptions about what it finds. A couple of things to look out for: 0. While vmware2libvirt attempts to detect a 64-bit guest, be sure that your 64-bit guest has in its .xml file: {{{ hvm ... }}} 0. vmware2libvirt only detects and uses the first Ethernet interface found. Additional interfaces can be added from within virt-manager. 0. Currently the first scsi disk is used if found, otherwise the first ide disk. Additional disks can be added from within virt-manager. 0. The converted virtual machine is hard-coded to use 1 CPU. This can be changed with:{{{ 2 }}} 0. vmware2libvirt does not (and cannot) convert anything that was VMware-specific within the guest. See 'Guest Notes' below for more details. == Using and Converting VMware Virtual Disk Files == KVM has the ability to use VMware's .vmdk disk files directly, as long as the disk is wholly contained in a single vmdk file. However, VMware also allows splitting a disk into multiple smaller vmdk files, usually 2 GB each. KVM can't use these. You can convert these files into a single virtual disk file using vmware-vdiskmanager, included in the freely available VMware Server. {{{ $ vmware-vdiskmanager -r -t 0 }}} '''IMPORTANT:''' before converting the disk files into a single disk file, you must first remove all snapshots (through the web interface if you were using VMware Server 2.0). Otherwise your merged disk will not be in the latest known state. Removing these snapshots can take quite some time, after which *-000001.vmdk - type of files may have disappeared from the file system. To create a new virtual machine from an existing file, call `virt-install` with the `--import` argument (see the [[http://manpages.ubuntu.com/manpages/man1/virt-install.1.html|virt-install manpage]] for details). To use a .vmdk disk in an existing virtual machine, modify the VM's XML file in /etc/libvirt/qemu: {{{ ... ... }}} and redefine it: {{{ $ virsh -c qemu:///system define NameOfMachine.xml }}} '''IMPORTANT:''' keep in mind that while the .vmx file is converted to .xml, the disks are used as-is. Please make backups, especially if you want to use the virtual machine in VMware later. KVM is not able to make snapshots when using vmdk disk files, so converting the virtual disk file in qemu's qcow2 format is advisable. The qemu package contains a utility named qemu-img to do this: {{{ qemu-img convert diskname.vmdk -O qcow2 diskname.qcow2 OR for raw qemu-img convert diskname.vmdk -O raw diskname.raw }}} The converted image can be used as part of the definition of a new VM, or incorporated into an existing VM (see above). Adding the disk through virt-manager will always add it as a raw disk, so you will need to edit the xml as follows below to make sure it works with qcow2. The important bit is `type='qcow2'` instead of `type='raw'`! {{{ ... ... }}} == Should VMware Tools be kept after conversion? == If converting from vmware to libvirt, be sure to remove vmware-tools if you have it installed (otherwise it will overwrite xorg.conf on reboot) = How to convert Physical Machines to virt-manager = If you want to convert a Windows (XP) physical machine, you may need to enable IDE in the registry first. Start the machine and execute mergeide.reg. See [[http://pve.proxmox.com/wiki/Migration_of_servers_to_Proxmox_VE#Prepare_the_Windows_operating_system_2|the ProxMox wiki]] for very detailed instructions. == Using VMware Converter == VMware Converter is a free tool to migrate a physical machine to VMware. So the first step is to migrate the physical machine to a VMware image. The second step is to follow the howto "How to convert VMware Machines to virt-manager" (see above). == Using Linux tools == See the german book about qemu [[http://qemu-buch.de/de/index.php/QEMU-KVM-Buch/_Speichermedien/_Physical-to-Virtual|physical to virtual]]. There is a link to translate it in English. = How to convert VirtualBox machines to virt-manager? = First we need to convert the disk image format of all disks. {{{ VBoxManage clonehd disk.vdi disk.raw --format raw qemu-img convert -f raw disk.raw -O qcow2 disk.qcow2 }}} Do this for all disks. Then, unfortunately, you need to create a new KVM VM with the same disks. If it's a linux box, be sure to check first /etc/fstab to see which device names are used to mount the disks (sda, hda, vda). Check (using virsh edit) the VM's xml to make sure the same device names are used in the new KVM VM. Or edit the VM to use the new device names. = Should NTP be used for time synchronisation? = NTP can be used on guest VMs for time synchronisation. In particular, the [[ http://www.linux-kvm.org/page/FAQ#I.27m_experiencing_timer_drift_issues_in_my_VM_guests.2C_what_to_do.3F | KVM wiki ]] recommends specifying the KVM host as the main NTP server within the VM instead of external NTP servers. This helps maintain tight coupling between guests and host. In addition, this [[ http://thread.gmane.org/gmane.comp.emulators.kvm.devel/96835/focus=96981 | thread ]] also recommends using NTP in the guest VM to maintain proper timing. Note, it is not necessary to use NTP in a guest VM, as the VM still has access to the kvm-clock clocksource which will set the guest VMs hardware clock. More information about hardware clocks can be found [[ https://wiki.ubuntu.com/HardwareClock | here ]]. = Which driver should be used for Xorg? = == Video == ## bodhi.zazen 5/22/2010 - I updated this section. I added to and left the previous section (which is somewhat dated) ## as comments (if anyone wishes to revert for some reason ## Otherwise the previous sections can probably be removed (deleted). When you first install a Linux guest, use the "cirrus" video driver. Post installation, if you wish to have a resolution above 800x600, switch to the standard video driver. xorg.conf is "depreciated" and so is by default missing in Linux. To use the "standard" video driver use the following in '''''/etc/X11/xorg.conf''''' {{{ Section "ServerLayout" Identifier "BodhiZazen's KVM xorg.conf" Screen 0 "Screen0" 0 0 InputDevice "Mouse0" "CorePointer" InputDevice "Keyboard0" "CoreKeyboard" EndSection Section "Module" Load "record" Load "dri" Load "extmod" Load "glx" Load "dbe" Load "dri2" EndSection Section "InputDevice" Identifier "Keyboard0" Driver "kbd" EndSection Section "InputDevice" Identifier "Mouse0" Driver "vmmouse" Option "Protocol" "SysMouse" Option "Device" "/dev/sysmouse" Option "ZAxisMapping" "4 5 6 7" EndSection Section "Monitor" Identifier "Monitor0" VendorName "Monitor Vendor" ModelName "Monitor Model" HorizSync 20.0 - 50.0 VertRefresh 40.0 - 80.0 Option "DPMS" EndSection Section "Device" Identifier "Card0" Driver "vesa" VendorName "KVM - std" BoardName "GD 5446" BusID "PCI:0:2:0" EndSection Section "Screen" Identifier "Screen0" Device "Card0" Monitor "Monitor0" SubSection "Display" Viewport 0 0 Modes "1600x1200" EndSubSection EndSection }}} Change the line "Modes "1600x1200" " to your desired resolution (I have been able to achieve resolutions up to 1920x1200 ). Hint - 1400X1050 is nice a well. Notice the mouse driver is vmmouse . vmmouse is included by default in most distros (Debian, Fedora, and Ubuntu all include this driver by default). Setting the standard video driver varies by how you use KVM. '''''Command line''''' - use the option -vgs std {{{ kvm -hda ubuntu.qcow -vga std }}} '''''Virtmanager''''' (graphical front end} With the guest shut down, go to the guest over view page , Select the "Video" tab on the Right, select "vga" (rather then cirrus) from the pull down menu. '''''Libvirt''''' - Edit your guest xml file, set the video to std with : {{{ }}} If the display fails to start with an error in the logs like: "No core pointer", then the follow entry in the xorg.conf file will get around this (CentOS5 does this): {{{ Section "ServerFlags" Option "AllowMouseOpenFail" "1" EndSection }}} ##Linux guests with Xorg should be using the 'cirrus' video driver. To use, adjust /etc/X11/xorg.conf to have: {{{ ##Section "Device" ## Identifier "Configured Video Device" ## Driver "cirrus" ##EndSection ##}}} then be sure that your Screen section uses 'Configured Video Device' for its Device. ##=== Mouse === ##Linux guests with Xorg should be using the 'vmmouse' driver (not available on Ubuntu Dapper). To use, perform within the guest: {{{ ##aptitude install xserver-xorg-input-vmmouse ##}}} then adjust /etc/X11/xorg.conf to have (the Identifier line should not change, and you should have only an Identifier line and Driver line for the mouse): ##{{{ ##Section "InputDevice" ## Identifier "Configured Mouse" ## Driver "vmmouse" ##EndSection ##}}} = How to set up guest resolution in Xorg? = Assuming you are using the xorg.conf from above you can set your resolution either by editing '''''/etc/X11/xorg.conf''''' and setting a new default resolutino (the Modes line as above) or, with the guest running, use the graphical system menu to set a Resolution. In gnome this is System -> Preferences -> Monitors In XFCE this is Applications -> Settings -> Display In LXDE this is Menu -> Prefences -> Monitor Settings <> = What system specific adjustments are recommended? = == Windows ( }}} with: {{{ }}} == Windows Vista == Windows Vista virtual machines should add this to the xml file: {{{ ... }}} == Debian Sarge == Debian Sarge (oldstable) may write /boot/grub/menu.lst incorrectly, resulting in the following on boot: {{{ pivot_root: no such file or directory /sbin/init: 432: cannot open dev/console: no such file Kernel panic: Attempted to kill init! }}} The fix is at the grub menu, press 'e' and adjust {{{root=/dev/hdb1}}} to be {{{root=/dev/hda1}}}. After a successful boot, you will need to update /boot/grub/menu.lst to have: {{{ # kopt=root=/dev/hda1 ro }}} and run: {{{ # update-grub }}} == OpenBSD 4.1 (and others?) == OpenBSD 4.1 (and probably others) when using the rtl8139 network driver may realize poor network performance and see this message on the console:{{{ re0: watchdog timeout }}} The fix is to use another NIC (e1000 appears to work well). See 'Changing the Network Card Model' above. == OpenBSD 4.5 and later == A change in the OpenBSD kernel causes it to hang on boot at "setting tty flags". If this affects you, follow the instructions on http://scie.nti.st/2009/10/4/running-openbsd-4-5-in-kvm-on-ubuntu-linux-9-04 == Nested usage == Nested KVM (running kvm inside a kvm vm) tends to work pretty well for development purposes. However, through the releases it has had many regressions, and upstream does not consider it a supportable use case. Therefore it is not recommended for "real" workloads. When using nested kvm, it is recommended to (a) use hugepages to back the parent VM, and (b) ensure that KSM is disabled in the nested VMs. <> ---- CategoryVirtualization