[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[libvirt] [PATCH] json: Avoid passing large positive 64 bit integers to QMP.
- From: "Richard W.M. Jones" <rjones redhat com>
- To: libvir-list redhat com
- Subject: [libvirt] [PATCH] json: Avoid passing large positive 64 bit integers to QMP.
- Date: Wed, 25 May 2011 17:55:34 +0100
We don't seem to be reaching any sort of sensible conclusion with qemu
about this bug, so it seems easier (albeit uglier) to fix it on the
libvirt side.
I have verified that with this patch virDomainMemoryPeek works on 64
bit guests.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/
>From 9def1fb4a1b59b086493cf5eb78228515933e0b7 Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones redhat com>
Date: Wed, 25 May 2011 17:52:26 +0100
Subject: [PATCH] json: Avoid passing large positive 64 bit integers to QMP.
http://lists.gnu.org/archive/html/qemu-devel/2011-05/threads.html#02162
Currently, qemu silently clips any JSON integer in the range
0x8000000000000000 - 0xffffffffffffffff (all numbers in this range
will be clipped to 0x7fffffffffffffff == LLONG_MAX).
To avoid this, pass these as signed 64 bit integers in the QMP
request.
---
src/qemu/qemu_monitor_json.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 2d8a390..bdd0dcb 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -413,8 +413,13 @@ qemuMonitorJSONMakeCommand(const char *cmdname,
ret = virJSONValueObjectAppendNumberLong(jargs, key, val);
} break;
case 'U': {
- unsigned long long val = va_arg(args, unsigned long long);
- ret = virJSONValueObjectAppendNumberUlong(jargs, key, val);
+ /* qemu silently truncates numbers larger than LLONG_MAX,
+ * so passing the full range of unsigned 64 bit integers
+ * is not safe here. Pass them as signed 64 bit integers
+ * instead.
+ */
+ long long val = va_arg(args, long long);
+ ret = virJSONValueObjectAppendNumberLong(jargs, key, val);
} break;
case 'd': {
double val = va_arg(args, double);
--
1.7.5.1
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]