Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting our team. We will be in touch shortly.Close

  1. Blog
  2. Article

Bill Wear
on 25 February 2020


When designing or testing with MAAS, it’s often handy to start with virtual machines. If you’re just on your laptop, and you want to check out a new MAAS version, or mock up some datacentre idea you’ve been considering, KVMs are often very useful. You could create pods, of course, but it’s also very simple just to create a few individual KVM machines and enlist them in MAAS. This article will show you how.

You’ll need to first install libvirt (aka, Virtual Machine Manager) — on the machine where you plan to install and test MAAS — since libvirt is the tool that provides KVMs. Once you’ve done this, you can open the Virtual Machine Manager application. You’ll see a screen that looks something like the one below, though it may not be populated with any KVMs yet:

The Virtual Machine Manager’s KVM list, which is the default landing page

To begin creating a new KVM, choose File –> New Virtual Machine from the menubar at the top, which brings you to a corresponding dialog:

Select the “Network Boot (PXE)” option and click the “Forward” button:

Choose the “Generic…” operating system by typing a few letters of “Generic” in the text box and selecting the relevant choice when it becomes available, then go Forward:

For CPU and memory, you can usually accept the defaults:

On the other hand, the storage values have a noticeable effect on local disk usage, so note that, generally, only about 5.0 GiB are needed for a simple, test KVM:

In the next screen, you’ll have the chance to set a name; here, we’ve used a pseudo-MAC address, although you can name the machine whatever you want (and then return later to set the name to match the MAC address assigned by libvirt, if desired):

Selecting “Finish” will create the virtual machine and attempt to boot it – which will fail, since no device currently knows about this KVM (and hence can’t boot it). Not to worry; you’re not done yet:

Select the “information” button (blue circle, white lowercase “i”) to switch to the KVM configuration screens, then select the “Boot Options” choice from the left-hand menu:

Turn off the “IDE” item under “Boot device order:”

When you select “Apply,” a dialog will pop up to remind you that you need to restart this KVM for changes to take effect (don’t worry about restarting yet):

Switch to the “NIC…” option and set the “Network source” and “Device model” as shown, then select “Apply” and respond to the dialog:

You’ll next select the dropdown arrow next to the “on/off” menu bar option and select “Force reset,” then answer the prompt in the affirmative:

You now have a KVM that can be added to MAAS.

If you want more than one, you can simply right-click on the one you’ve just created and select “Clone.” Cloned KVMs tend to use considerably less host disk space than newly-created ones, and the cloning process saves you considerable time. Here’s what cloning looks like:

Another KVM will instantiate, using the name of the cloned KVM with an added “-clone” suffix:

Note that the “-clone” suffix will automatically increment as you keep cloning the same machine (e.g., “-clone1,” “-clone2”, ….).

Disabling DHCP for Virtual Machine Manager

Before attempting to enlist your new KVMs into MAAS, you must modify the KVM networking arrangements so that MAAS can manage DHCP requests. The command-line utility “virsh” is the easiest way to do this:

Presumably, you’ll be using the “default” network, but if you’ve created a different network connection, substitute its name in the following instructions.

Before modifying the default network, you need to disable it. This is accomplished via the “net-destroy” command:

Once you’ve disabled the network, you can edit it with “net-edit:”

In the editor window, you’ll want to select the <dhcp>…</dhcp> section and delete it, then save and quit the file:

Finally, you want to restart the default network with the “net-start” command:

This sequence of steps prevents the Virtual Machine Manager from attempting to provide DHCP, which would prevent MAAS from properly accessing and enlisting the machines.

Adding KVMs to MAAS manually

Manually creating a machine from a KVM requires just a few pieces of information, most of which you can gather from the KVM itself:

In the left column, you’re only required to enter a machine name and the machine’s MAC address:

Here, we’ve assigned a variant of the MAC address as the machine name. Note that the machine name cannot include colons (“:”), so dashes are substituted. In the right column, it’s necessary to choose the power type. When enlisting KVMs, the correct power type is “Virsh,” as shown below:

For default configurations, the Virsh Address is “qemu+ssh://[your-login-id]@192.168.122.1/system,” where “[your-login-id]” is replaced by your username or login ID on the machine where you’re hosting MAAS and the Virtual Machine Manager. Likewise, the password is your normal login password for the same host. Finally, the Virsh VM ID is retrieved from the “Overview” screen of the KVM itself:

As you add machines, they automatically commission:

When you’ve finished, all commissioned machines will be at the “Ready” state.

A couple of tips

Here are a couple of tips for adding individual KVMs as MAAS machines:

  1. Cloned machines tend to take up less disk space on your host laptop. It’s not a perfect rule, but it does tend to hold most of the time.
  2. Watch your laptop processor limit when creating machines; specifically, don’t commission too many at once — you may cause your laptop to run out of resources and freeze up or reboot. The same goes for deploying machines, and for accidentally leaving too many on when you’re playing around.

That’s it! That’s all there is to adding a few KVMs to check out MAAS or play around with ideas.

Related posts


Anton Smith
1 February 2022

Bare metal Kubernetes as a Service: Canonical MAAS and SpectroCloud Webinar

Ubuntu Article

Developers want Kubernetes infrastructure that is fast, consistent, and without limits! Platform engineering, IT, and DevOps teams are adopting Kubernetes as a Service (KaaS) now more than ever before to streamline efficiency for dev teams and operations. But what happens when the requirement involves deploying clusters directly on top of ...


Anton Smith
27 January 2022

Understanding bare metal Kubernetes

Kubernetes Article

Bare metal Kubernetes is a powerful set of technologies that builds on the best ideas behind the public and private cloud, yet abstracts away some toilsome aspects related to virtualisation management and networking. For operators and users, it provides significant benefits, making it easier and faster to ship and maintain complex, distri ...


Anton Smith
14 December 2021

Bare metal Kubernetes: The 6 things you wish you knew before 2022

Cloud and server Article

2022 is right around the corner, and it’s not just time to prepare for Christmas, play video games, buy presents, or share anti-Christmas memes. It’s time to start making some predictions for bare metal Kubernetes! Take a minute and let’s think about it. Developers have advent of code so they’re busy right now. Sysadmins and ...