DaDesktop

Creating VMs within DaDesktop using Virt Manager

Introduction

While preparing a course, it is often useful to virtualise a server within DaDesktop, and perhaps one or two client machines as well, either using the same OS or a mix of Windows and Linux.

Running 'Nested VMs' can be done using Virt Manager, or VirtualBox (with Vagrant optionally) on Linux; if using Windows 10 as the DaDesktop machine, VirtualBox is the only option.

DD Machines Nested Virt

After extensive testing, we recommend using Virt Manager, because there are some bugs with VirtualBox; hence, at present, we advise against using VirtualBox in this fashion.

The VirtManager application leverages the libvirt library to offer virtual machine management capabilities. It has a desktop interface that helps in creating, deleting, and managing multiple virtual machines. While primarily meant for KVM VMs, it also supports other hypervisors like Xen and LXC.

Virt Manager works seamlessly with Vagrant. Simply run:-

apt install vagrant-libvirt

Note that there are fewer Vagrant boxes available for libvirt/kvm than for VirtualBox, but they can easily be converted to work with libvirt, as detailed here:-

https://medium.com/@gamunu/use-vagrant-with-libvirt-unsupported-boxes-12e719d71e8e
 

The user interface shows a summary of all VMs, their status, CPU usage, a live performance graph for running VMs, and resource utilisation statistics.

If you are new to Virt Manager, it is quite similar to VirtualBox, but with a few key differences explained below.

This is a good guide on using virt-manager on Ubuntu Linux - https://www.debugpoint.com/virt-manager/

 

Why should I use Virt Manager instead of Virtualbox?

Advantages
  1. Performance is significantly better. Virt Manager uses VirtIO drivers for storage, networking, and graphics, which offer superior performance. virtio drivers are KVM's paravirtualized device drivers, available for Linux and Windows guest virtual machines running on KVM hosts. The virtio package supports block (storage) devices, network interface controllers, and graphics. VirtIO drivers are open source, so they are easily installed if not already pre-installed on your Linux distribution.
  2. More configuration options are available.
  3. Works well with Vagrant.
  4. Parts of VirtualBox are not fully open source.
  5. Virt Manager does not require module recompilation upon kernel upgrades, unlike VirtualBox.
  6. VirtualBox sometimes breaks after a kernel upgrade.
Disadvantages
  1. VirtualBox arguably has a slightly shorter learning curve.
  2. Setting up host networking (instead of NAT) is easier on VirtualBox, though NAT works well for most networking scenarios on both systems.
  3. VirtualBox is available on many platforms, whereas Virt Manager is Linux-only.


Overall, for running servers inside a DaDesktop machine, we find Virt Manager to be the preferred choice.

 

Installation

Since libvirt is constantly being improved, always use the latest non-LTS Ubuntu or Debian release.

Installation of KVM and virt-manager: these notes are brief, so please follow an up-to-date guide for your chosen DaDesktop OS. One such guide is https://www.debugpoint.com/virt-manager/

sudo apt install virt-manager
sudo adduser student libvirt
sudo systemctl restart libvirtd

Reboot the DaDesktop machine, then run Virt Manager from the Applications menu.

 

Configuration

  1. How can I import or convert virtual machines? While it is straightforward to create VMs tailored to your OS and specs, for complex setups you might prefer to import an existing VM setup of a specific server or appliance. These are often supplied as VMDK images, which can be added directly to Virt Manager, though it is not obvious that this works with the current version. VirtualBox server images cannot be imported directly into Virt Manager, but they can be exported to formats like Open Virtualisation Format (OVF), which Virt Manager can import easily. Alternatively, you can use VmWare Convertor if you have it, or the virt-v2v tool (https://www.redhat.com/en/blog/importing-vms-kvm-virt-v2v). Qemu-convert is also a great open source tool that allows easy conversion between different virtual machine formats.
    To Convert from VirtualBox to Virt Manager KVM format follow these instructions https://ostechnix.com/how-to-migrate-virtualbox-vms-into-kvm-vms-in-linux/
  2. Best method to import large files within a standalone environment. Recently, a way to easily upload files from your machine to your DaDesktop machine has been introduced.

    Alternatively, consider using cloud storage tools like Google Drive or Microsoft 365; you can then access them by logging in from within the DaDesktop machine.

  3. When importing virtual machines from other formats, you often need to change the graphics and/or disk types.  One of Virt Manager's strengths is its excellent support for VirtIO drivers. These are open source, fully virtualized drivers that deliver much better performance than original disk, network, or graphics drivers, and are available for nearly all operating systems, including great support for Windows 10 guests. If your guest OS supports them, these are usually the preferred option for both compatibility and performance with Virt Manager (KVM). https://wiki.archlinux.org/title/Libvirt
  4. Optimal settings for virtual machines in Virt Manager VirtIO drivers are included in nearly all open source server OSes today, and can be easily installed on Windows. Usually, the best drivers are virtio, though sometimes you might need to use other types. NAT is generally sufficient for most networking needs, unless you require a more complex setup where bridged host networking is needed, though that can be trickier to get working smoothly.
    https://wiki.manjaro.org/index.php?title=Virt-manager is a good starter guide.
    Running Windows requires extra steps, including slipstreaming the VirtIO drivers to allow the Windows 10 ISO to boot.
    When choosing a hard disk format, raw files (.raw) offer the best speed unless snapshots are needed; in that case, use qcow2, though it is a bit slower.
  5. While Wayland works well as a display manager in most cases, we advise sticking with X11 for the time being. However, it might be worth testing Wayland in your own setup, as distros are continually improving Wayland support.
  6. There's no need to use KSM; even though it works in nested environments and in Virt Manager, it makes little practical difference.
  7. Tech Support is available if required when converting disk images to work with Virt Manager, and also for configuring Virt Manager for DaDesktop courses in India.
  8. Where are the disk image files stored on the filesystem? Virt Manager uses the following location to store image files, though this is configurable, and you can use other paths if you prefer.

    /var/lib/libvirt/images