]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domMemoryStats / qemu: Fix parsing of unknown stats
authorAdam Litke <agl@us.ibm.com>
Thu, 21 Jan 2010 15:26:35 +0000 (16:26 +0100)
committerDaniel Veillard <veillard@redhat.com>
Thu, 21 Jan 2010 15:28:50 +0000 (16:28 +0100)
Fix a small problem with the qemu memory stats parsing algorithm.  If qemu
reports a stat that libvirt does not recognize, skip past it so parsing can
continue.  This corrects a potential infinite loop in the parsing code that can
only be triggered if new statistics are added to qemu.

* src/qemu/qemu_monitor_text.c: qemuMonitorParseExtraBalloonInfo add a
  skip for extra ','

src/qemu/qemu_monitor_text.c

index c3848b52468289ad53b442b0eb20848f9fecf6ab..0909b4da3d20a12c6060a24e1eba1c2956a76cdc 100644 (file)
@@ -507,7 +507,11 @@ static int qemuMonitorParseExtraBalloonInfo(char *text,
                             ",total_mem=", &stats[nr_stats_found]))
             nr_stats_found++;
 
-        /* Skip to the next label */
+        /* Skip to the next label.  When *p is ',' the last match attempt
+         * failed so try to match the next ','.
+         */
+        if (*p == ',')
+            p++;
         p = strchr (p, ',');
         if (!p) break;
     }