]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_monitor: s/size_t/ULL/ in qemuMonitorSave{Virtual,Physical}Memory
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 27 Sep 2019 11:29:53 +0000 (13:29 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 27 Sep 2019 12:46:33 +0000 (14:46 +0200)
As it turns out, on my 32bit ARM machine size_t is not the same
size as ULL. However, @length argument for both functions is type
of size_t but it's treated as ULL - for instance when passed to
qemuMonitorJSONMakeCommand(). The problem is that because of
"U:size" the virJSONValueObjectAddVArgs() expects an ULL argument
but on the stack there are size_t and char * arguments (which
coincidentally add up to size of ULL). So the created command has
only two arguments "val" and incorrect "size" and no "path" which
is required.

I've tried to find other occurrences of this pattern but at the
rest of places where size_t is used it tracks size of an array so
that's safe.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index b6d29368722297c6f061508a8ff3564a2660d6b3..7959933e7c1b5187aed9d0448ecff1e6a0f57e57 100644 (file)
@@ -2348,10 +2348,10 @@ qemuMonitorChangeMedia(qemuMonitorPtr mon,
 int
 qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon,
                              unsigned long long offset,
-                             size_t length,
+                             unsigned long long length,
                              const char *path)
 {
-    VIR_DEBUG("offset=%llu length=%zu path=%s", offset, length, path);
+    VIR_DEBUG("offset=%llu length=%llu path=%s", offset, length, path);
 
     QEMU_CHECK_MONITOR(mon);
 
@@ -2362,10 +2362,10 @@ qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon,
 int
 qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon,
                               unsigned long long offset,
-                              size_t length,
+                              unsigned long long length,
                               const char *path)
 {
-    VIR_DEBUG("offset=%llu length=%zu path=%s", offset, length, path);
+    VIR_DEBUG("offset=%llu length=%llu path=%s", offset, length, path);
 
     QEMU_CHECK_MONITOR(mon);
 
index 8fc11c955e61ab2f63e2e5bf23ca7dae58494883..95de891150970bb69c2d24a0c6a751308ca13f9c 100644 (file)
@@ -726,11 +726,11 @@ int qemuMonitorChangeMedia(qemuMonitorPtr mon,
 
 int qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon,
                                  unsigned long long offset,
-                                 size_t length,
+                                 unsigned long long length,
                                  const char *path);
 int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon,
                                   unsigned long long offset,
-                                  size_t length,
+                                  unsigned long long length,
                                   const char *path);
 
 int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon,
index cdfaf9785a9e5c1763590e45596babce511b36b5..d99d291d89febc84d4086521acba9fa6082a3ebb 100644 (file)
@@ -3100,7 +3100,7 @@ int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon,
 static int qemuMonitorJSONSaveMemory(qemuMonitorPtr mon,
                                      const char *cmdtype,
                                      unsigned long long offset,
-                                     size_t length,
+                                     unsigned long long length,
                                      const char *path)
 {
     int ret = -1;
@@ -3129,7 +3129,7 @@ static int qemuMonitorJSONSaveMemory(qemuMonitorPtr mon,
 
 int qemuMonitorJSONSaveVirtualMemory(qemuMonitorPtr mon,
                                      unsigned long long offset,
-                                     size_t length,
+                                     unsigned long long length,
                                      const char *path)
 {
     return qemuMonitorJSONSaveMemory(mon, "memsave", offset, length, path);
@@ -3137,7 +3137,7 @@ int qemuMonitorJSONSaveVirtualMemory(qemuMonitorPtr mon,
 
 int qemuMonitorJSONSavePhysicalMemory(qemuMonitorPtr mon,
                                       unsigned long long offset,
-                                      size_t length,
+                                      unsigned long long length,
                                       const char *path)
 {
     return qemuMonitorJSONSaveMemory(mon, "pmemsave", offset, length, path);
index a60841070305e8cf44f15ad92a46c4c75e7ca8c7..63f569716d588b47b2ca6a8c1c20aabe2a761056 100644 (file)
@@ -118,11 +118,11 @@ int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon,
 
 int qemuMonitorJSONSaveVirtualMemory(qemuMonitorPtr mon,
                                      unsigned long long offset,
-                                     size_t length,
+                                     unsigned long long length,
                                      const char *path);
 int qemuMonitorJSONSavePhysicalMemory(qemuMonitorPtr mon,
                                       unsigned long long offset,
-                                      size_t length,
+                                      unsigned long long length,
                                       const char *path);
 
 int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon,