Bug 812295
Summary: | qemu: domxml-from-native: error parsing -m 2G: internal error cannot parse memory level '2G' | ||
---|---|---|---|
Product: | [Community] Virtualization Tools | Reporter: | pitnvrsk |
Component: | libvirt | Assignee: | Libvirt Maintainers <libvirt-maint> |
Status: | CLOSED UPSTREAM | QA Contact: | |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | unspecified | CC: | berrange, clalancette, crobinso, dougsland, itamar, jforbes, laine, libvirt-maint, rbalakri, veillard, virt-maint |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | LibvirtFirstBug | ||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2016-05-20 12:52:18 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
pitnvrsk
2012-04-13 10:25:14 UTC
Have changed -m 2G to -m 2048 - helped. After conversion: --------------------------------------------------------------------------- <domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <name>unnamed</name> <uuid>8eb76e3e-52fc-6469-4725-31653c3f4c60</uuid> <memory>2097152</memory> <currentMemory>2097152</currentMemory> <vcpu>4</vcpu> <os> <type arch='x86_64'>hvm</type> </os> <features> <acpi/> </features> <cpu match='exact'> <model>qemu64</model> </cpu> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>destroy</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/local/bin/qemu-system-x86_64</emulator> <input type='mouse' bus='ps2'/> <graphics type='sdl'/> <video> <model type='cirrus' vram='9216' heads='1'/> </video> <memballoon model='virtio'/> </devices> <qemu:commandline> <qemu:arg value='-enable-kvm'/> <qemu:arg value='\ -net'/> <qemu:arg value='nic,vlan=0,model=virtio'/> <qemu:arg value='\ -net'/> <qemu:arg value='tap,vlan=0,ifname=tap745,script=/etc/qemu-ifup,downscript=no'/> <qemu:arg value='\ -drive'/> <qemu:arg value='file=./rootfs_fedora_cd.img,media=cdrom'/> <qemu:arg value='\ -drive'/> <qemu:arg value='file=./pilvi_step1.img,media=cdrom'/> <qemu:arg value='\ -nographic'/> <qemu:arg value='\ -kernel'/> <qemu:arg value='./bzImage-2.6.38.fc15.r49745'/> <qemu:arg value='\ -append'/> <qemu:arg value='root=/dev/sr0 ro ip=192.168.44.105:192.168.44.101:192.168.44.101:255.255.255.0:pilvi-vm:eth0:off mounts=192.168.44.101:/home/khd734/test/exports/var,/var,nfs,nolock,rw console=ttyS0 earlyprintk=ttyS0 selinux=0'/> <qemu:arg value='\ -name'/> <qemu:arg value='pilvi-vm'/> </qemu:commandline> </domain> ----------------------------------------------------------------------------- Have not found : xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0 Have tried to bring up VM with this xml config and got: libvir: QEMU error : internal error guest CPU is not compatible with host CPU But again original native startup string successfuly bringing up VM. After removing all backslashes "\" from original native string: have got an error during domxml-from-native conversion: error: internal error missing index/unit/bus parameter in drive 'file=./rootfs_fedora_cd.img, media=cdrom' The index/unit/bus stuff is tracked in bug 1205925 We can use this just to track the memory 2G issue A super simple reproducer from libvirt.git: $ cat cmd.sh qemu-kvm -m 2G $ sudo ./tools/virsh domxml-from-native qemu-argv cmd.sh error: internal error: cannot parse memory level '2G' The error comes from src/qemu/qemu_parse_command.c qemuParseCommandLine function. The parsing only expects a straight number, not any characters. However libvirt already has a function to help parse numbers like that: /* Scale an integer VALUE in-place by an optional case-insensitive * SUFFIX, defaulting to SCALE if suffix is NULL or empty (scale is * typically 1 or 1024). Recognized suffixes include 'b' or 'bytes', * as well as power-of-two scaling via binary abbreviations ('KiB', * 'MiB', ...) or their one-letter counterpart ('k', 'M', ...), and * power-of-ten scaling via SI abbreviations ('KB', 'MB', ...). * Ensure that the result does not exceed LIMIT. Return 0 on success, * -1 with error message raised on failure. */ int virScaleInteger(unsigned long long *value, const char *suffix, unsigned long long scale, unsigned long long limit) See tools/vsh.c vshCommandOptScaledInt function for an easy example of how to invoke that function. Then it just needs to be adapted for the qemu code. Also you'll want to add a tests/qemuargv2xmltest.c test case Fixed upstream now: commit 701b0f1867055bce3b29d27d23c6935ce94086af Author: Nishith Shah <nishithshah.2211> Date: Fri May 20 07:09:03 2016 +0000 qemu: parse: Handle suffixes for -m memory According to QEMU docs, the '-m' option for specifying RAM is by default in MiB, and a suffix of "M" or "G" may be passed for values in MiB and GiB respectively. This commit adds support and a test for the same. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=812295 Signed-off-by: Nishith Shah <nishithshah.2211> |