I defined how many RAM i want in a virtual machine in the XML of libvirt, but when i start this machine it say me other amount of RAM different with respect to XML. The line that construct libvirt to launch the kvm has a modifier (-m) that you can put the amount of RAM in megabytes that ou want, if in the XML you specified a 512MB of RAM, in the kvm line appear -m 0, and if you want 1024MB of ram, in the kvm line appear -m 1. I use Libvirt 0.8.2 and qemu 0.12.3 The XML <?xml version="1.0" encoding="UTF-8"?> <domain type="kvm"> <name>uml2</name> <memory>780M</memory> <vcpu>1</vcpu> <os> <type arch="i686">hvm</type> <boot dev="hd"/> <boot dev="cdrom"/> </os> <features> <pae/> <acpi/> <apic/> </features> <clock sync="localtime"/> <devices> <emulator>/usr/bin/kvm</emulator> <disk type="file" device="disk"> <source file="/root/.vnx/simulations/tutorial-r1_xp/vms/uml2/fs/root_cow_fs"/> <target dev="hda"/> </disk> <disk type="file" device="cdrom"> <source file="/root/.vnx/simulations/tutorial-r1_xp/vms/uml2/fs/opt_fs.iso"/> <target dev="hdb"/> </disk> <interface type="bridge" name="eth1" onboot="yes"> <source bridge="Net0"/> <mac address="fe:fd:00:00:01:01"/> </interface> <graphics type="vnc" listen=""/> <serial type="unix"> <source mode="bind" path="/root/.vnx/simulations/tutorial-r1_xp/vms/uml2/uml2_socket"/> <target port="1"/> </serial> </devices> </domain> The kvm line in /var/log/libvirt/qemu/uml2 LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-0.12 -cpu qemu32 -enable-kvm -m 0 -smp 1 -name host1 -uuid 7c6fcf9b-ab6e-274f-8cd3-7a6a4aa17209 -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/host1.monitor,server,nowait -monitor chardev:monitor -boot cd -drive file=/root/.vnx/simulations/simple_w7/vms/host1/fs/root_cow_fs,if=ide,index=0,boot=on -drive file=/root/.vnx/simulations/simple_w7/vms/host1/fs/opt_fs.iso,if=ide,media=cdrom,index=1 -net none -chardev socket,id=serial0,path=/root/.vnx/simulations/simple_w7/vms/host1/host1_socket,server,nowait -serial chardev:serial0 -parallel none -usb -vnc :0 -vga cirrus
(In reply to comment #0) > <domain type="kvm"> > <name>uml2</name> > <memory>780M</memory> You've got two problems here. The first is that the memory parameter is specified in kilobytes, not megabytes. The second is that libvirt doesn't understand the M notation, so it's interpreting this as 780kb, essentially 0 (which is probably what it passes to kvm). The only bug here is that we should reject invalid XML like yours; I'll change the subject and leave the bug open to track the error reporting. Chris Lalancette
Thx!
I added support for libvirt XML to take input in megabytes (as in <memory unit='M'>780</memory>), and make it clear that output is in kibibytes, as of this patch in 0.9.11: commit 2e22f23bde0ad6630a29d06ce164b6db8395f72c Author: Eric Blake <eblake> Date: Mon Mar 5 14:52:07 2012 -0700 xml: allow scaled memory on input Output is still in kibibytes, but input can now be in different scales for ease of typing. However, I just checked that we _still_ don't reject <memory>780M</memory> as invalid, so I'll keep this bug open and add another patch.
Upstream patch posted: https://www.redhat.com/archives/libvir-list/2012-April/msg00954.html
Now committed: commit c09acad352039d896f45374a8241910fb207ae56 Author: Eric Blake <eblake> Date: Wed Apr 18 17:58:44 2012 -0600 conf: tighten up XML integer parsing https://bugzilla.redhat.com/show_bug.cgi?id=617711 reported that even with my recent patched to allow <memory unit='G'>1</memory>, people can still get away with trying <memory>1G</memory> and silently get <memory unit='KiB'>1</memory> instead. While virt-xml-validate catches the error, our C parser did not. Not to mention that it's always fun to fix bugs while reducing lines of code. :) * src/conf/domain_conf.c (virDomainParseMemory): Check for parse error. (virDomainDefParseXML): Avoid strtoll. * src/conf/storage_conf.c (virStorageDefParsePerms): Likewise. * src/util/xml.c (virXPathLongBase, virXPathULongBase) (virXPathULongLong, virXPathLongLong): Likewise.