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 used a few new methods from the libvirt.virDomain class. Let's see what they do in more detail and then add them to the simple kvm.py Python script we started in the Defining KVM instances with Python recipe.

In steps 1 and 2, we get the name of the KVM instance and ensure it's in a running state.

In step 3, we collect the following instance information, returned as a Python list:

  • state: The state of the instance, as defined in the virDomainState enumerated type at https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainState
  • maxMemory: The maximum memory used by the guest
  • memory: The current amount of memory used by the instance
  • nbVirtCPU: The number of allocated virtual CPUs
  • cpuTime: The time used ...

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