O'Reilly logo

KVM Virtualization Cookbook by Konstantin Ivanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

In this recipe, we are using the pre-existing raw Debian image we created in Chapter 1, Getting Started with QEMU and KVM, to define the KVM instance.

In step 1, we import the libvirt package and proceed to define the new KVM instance. We assign the XML formatted string to the xmlconfig variable in step 2. Notice that the definition contains the name of the new instance and the location of the image file.

In step 3, we obtain a connection object and assign it to the conn variable. We can now use the available methods to define the KVM guest.

To list all available methods for an object in iPython, type the variable name followed by . and press the Tab key twice: In [7]: conn. Display all 117 possibilities? (y or n) conn.allocPages ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required