[libvirt] [PATCH] fix error when parsing ppc64 models on x86 host

Stefan Berger stefanb at linux.vnet.ibm.com
Fri Dec 9 14:27:59 UTC 2011


When parsing ppc64 models on an x86 host an out-of-memory error message 
is displayed due
to it checking for retcpus being NULL. Fix this by removing the check 
whether retcpus is NULL
since we will realloc into this variable.
Also in the X86 model parser display the OOM error at the location where 
it happens.

---
  src/qemu/qemu_capabilities.c |   17 +++++++----------
  1 file changed, 7 insertions(+), 10 deletions(-)

Index: libvirt-iterator/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt-iterator.orig/src/qemu/qemu_capabilities.c
+++ libvirt-iterator/src/qemu/qemu_capabilities.c
@@ -443,8 +443,10 @@ qemuCapsParseX86Models(const char *outpu
          if (retcpus) {
              unsigned int len;

-            if (VIR_REALLOC_N(cpus, count + 1) < 0)
+            if (VIR_REALLOC_N(cpus, count + 1) < 0) {
+                virReportOOMError();
                  goto error;
+            }

              if (next)
                  len = next - p - 1;
@@ -456,8 +458,10 @@ qemuCapsParseX86Models(const char *outpu
                  len -= 2;
              }

-            if (!(cpus[count] = strndup(p, len)))
+            if (!(cpus[count] = strndup(p, len))) {
+                virReportOOMError();
                  goto error;
+            }
          }
          count++;
      } while ((p = next));
@@ -493,11 +497,6 @@ qemuCapsParsePPCModels(const char *outpu
      const char **cpus = NULL;
      int i;

-    if (!retcpus) {
-        VIR_DEBUG("No retcpus specified");
-        return -1;
-    }
-
      do {
          const char *t;

@@ -587,10 +586,8 @@ qemuCapsProbeCPUModels(const char *qemu,
      if (virCommandRun(cmd, NULL) < 0)
          goto cleanup;

-    if (parse(output, count, cpus) < 0) {
-        virReportOOMError();
+    if (parse(output, count, cpus) < 0)
          goto cleanup;
-    }

      ret = 0;




More information about the libvir-list mailing list