32 Xen: converting a paravirtual (PV) guest into a fully virtual (FV/HVM) guest #
This chapter explains how to convert a Xen paravirtual machine into a Xen fully virtualized machine.
To start the guest in FV mode, you need to run the following steps inside the guest.
Before converting the guest, apply all pending patches and reboot the guest.
FV machines use the
-default
kernel. If this kernel is not already installed, install thekernel-default
package (while running in PV mode).PV machines typically use disk names such as
vda*
. These names must be changed to the FVhd*
syntax. This change must be done in the following files:/etc/fstab
/boot/grub/menu.lst
(SLES 11 only)/boot/grub*/device.map
/etc/sysconfig/bootloader
/etc/default/grub
(SLES 12, 15, openSUSE)
Note: Prefer UUIDsYou should use UUIDs or logical volumes within your
/etc/fstab
. Using UUIDs simplifies the use of attached network storage, multipathing and virtualization. To find the UUID of your disk, use the commandblkid
.To avoid any error regenerating the
initrd
with the required modules, you can create a symbolic link from/dev/hda2
to/dev/xvda2
etc. by using theln
:ln -sf /dev/xvda2 /dev/hda2 ln -sf /dev/xvda1 /dev/hda1 .....
PV and FV machines use different disk and network driver modules. These FV modules must be added to the initrd manually. The expected modules are
xen-vbd
(for disk) andxen-vnif
(for network). These are the only PV drivers for a fully virtualized VM Guest. All other modules, such asata_piix
,ata_generic
andlibata
, should be added automatically.Tip: Adding modules to the initrdOn SLES 11, you can add modules to the
INITRD_MODULES
line in the/etc/sysconfig/kernel
file. For example:INITRD_MODULES="xen-vbd xen-vnif"
Run
dracut
to build a new initrd containing the modules.On SLES 12, 15, and openSUSE open or create
/etc/dracut.conf.d/10-virt.conf
and add the modules withforce_drivers
by adding a line as in the example below (mind the leading whitespace):force_drivers+=" xen-vbd xen-vnif"
Run
dracut -f --kver KERNEL_VERSION-default
to build a new initrd (for the default version of the kernel) that contains the required modules.Find your kernel version. Use the
uname -r
command to get the current version used on your system.
Before shutting down the guest, set the default boot parameter to the
-default
kernel usingyast bootloader
.Under SUSE Linux Enterprise Server 11, if you have an X server running on your guest, you need to adjust the
/etc/X11/xorg.conf
file to adjust the X driver. Search forfbdev
and change tocirrus
.Section "Device" Driver "cirrus" ...... EndSection
Note: SUSE Linux Enterprise Server 12/15 and XorgUnder SUSE Linux Enterprise Server 12/15, Xorg automatically adjusts the driver needed to be able to get a working X server.
Shut down the guest.
The following steps explain the action that you need to perform on the host.
To start the guest in FV mode, the configuration of the VM must be modified to match an FV configuration. Editing the configuration of the VM can easily be done using
virsh edit [DOMAIN]
. The following changes are recommended:Make sure the machine, the type, and the
loader
entries in the OS section are changed fromxenpv
toxenfv
. The updated OS section should look similar to:<os> <type arch='x86_64' machine='xenfv'>hvm</type> <loader>/usr/lib/xen/boot/hvmloader</loader> <boot dev='hd'/> </os>
In the OS section, remove anything that is specific to PV guests:
<bootloader>pygrub</bootloader>
<kernel>/usr/lib/grub2/x86_64-xen/grub.xen</kernel>
<cmdline>xen-fbfront.video=4,1024,768</cmdline>
In the devices section, add the qemu emulator as:
<emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
Update the disk configuration so the target device and bus use the FV syntax. This requires replacing the
xen
disk bus withide
, and thevda
target device withhda
. The changes should look similar to:<target dev='hda' bus='ide'/>
Change the bus for the mouse and keyboard from
xen
tops2
. Also add a new USB tablet device:<input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <input type='tablet' bus='usb'/>
Change the console target type from
xen
toserial
:<console type='pty'> <target type='serial' port='0'/> </console>
Change the video configuration from
xen
tocirrus
, with 8 MB of VRAM:<video> <model type='cirrus' vram='8192' heads='1' primary='yes'/> </video>
If desired, add
acpi
andapic
to the features of the VM:<features> <acpi/> <apic/> </features>
Start the guest (using
virsh
orvirt-manager
). If the guest is running kernel-default (as verified throughuname -a
), the machine is running in Fully Virtual mode.
To script this process, or work on disk images directly, you can use the guestfs-tools suite (see Section 20.3, “Guestfs tools” for more information). Several tools exist to help modify disk images.