On the road again

The article shows examples how to change different VM properties

libvirt stores it’s configuration as xml in ‘/etc/libvirt/qemu’. The xml is easy to understand, and is similar to VMware *.vmx files. While it is possible to edit these files in place and restart libvirt-bin for the changes to take affect, the recommended method for modifying the attributes of a virtual machine is via virsh (or virt-manager, if it supports changing the hardware you want to change). The concept is simple:

  1. export (aka ‘dump’) the xml of the virtual machine you want to edit
  2. edit the xml
  3. import (aka ‘define’) the xml

For example, to edit the machine named ‘foo’ (you can get a list of your machines with ‘virsh list —all’), do:

$ virsh dumpxml foo > /tmp/foo.xml
(edit /tmp/foo.xml as needed)
$ virsh define /tmp/foo.xml

Adding CPUs

KVM allows you to create SMP guests. To allocate two CPUs to a VM, dump the xml as above, then edit your xml to have:

<domain type='kvm'>
  ...
  <vcpu>2</vcpu>
  ...
</domain>

Now define the VM as above.

 

Adding RAM

To change the memory allocation in a VM, dump the xml as above, then edit your xml to have:

<domain type='kvm'>
  ...
  <memory>262144</memory>
  <currentMemory>262144</currentMemory>
  ...
</domain>

Now define the VM as above. Keep in mind that the memory allocation is in kilobytes, so to allocate 512MB of memory, use 512 * 1024, or 524288.

 

Changing NIC model

kvm and qemu currently default to using the rtl8139 NIC. Supported NICs in Ubuntu 8.04 LTS are i82551, i82557b, i82559er, ne2k_pci, pcnet, rtl8139, e1000, and virtio. To use an alternate NIC, dump the xml as above, then edit your xml to have:

<domain type='kvm'>
  ...
    <interface type='network'>
      ...
      <model type='e1000'/>
    </interface>
  ...
</domain>

Now define the VM as above.

Add comment