]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: virDomainDiskDefIotuneParse: Report malformed number errors
authorPeter Krempa <pkrempa@redhat.com>
Tue, 12 Apr 2016 13:03:19 +0000 (15:03 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Apr 2016 06:21:38 +0000 (08:21 +0200)
Rest of the fields of the iotune data structure did not check for
malformed integers. Use the previously defined macro to extract them
which will simplify the code and add error reporting.

src/conf/domain_conf.c

index 5ada00f839e4b91cbeea08521f0f1979babdb4c8..510be735a9a4a2368af39598b42fa336fe23847e 100644 (file)
@@ -6699,48 +6699,14 @@ virDomainDiskDefIotuneParse(virDomainDiskDefPtr def,
     PARSE_IOTUNE(read_iops_sec);
     PARSE_IOTUNE(write_iops_sec);
 
-    if (virXPathULongLong("string(./iotune/total_bytes_sec_max)",
-                          ctxt,
-                          &def->blkdeviotune.total_bytes_sec_max) < 0) {
-        def->blkdeviotune.total_bytes_sec_max = 0;
-    }
-
-    if (virXPathULongLong("string(./iotune/read_bytes_sec_max)",
-                          ctxt,
-                          &def->blkdeviotune.read_bytes_sec_max) < 0) {
-        def->blkdeviotune.read_bytes_sec_max = 0;
-    }
-
-    if (virXPathULongLong("string(./iotune/write_bytes_sec_max)",
-                          ctxt,
-                          &def->blkdeviotune.write_bytes_sec_max) < 0) {
-        def->blkdeviotune.write_bytes_sec_max = 0;
-    }
-
-    if (virXPathULongLong("string(./iotune/total_iops_sec_max)",
-                          ctxt,
-                          &def->blkdeviotune.total_iops_sec_max) < 0) {
-        def->blkdeviotune.total_iops_sec_max = 0;
-    }
-
-    if (virXPathULongLong("string(./iotune/read_iops_sec_max)",
-                          ctxt,
-                          &def->blkdeviotune.read_iops_sec_max) < 0) {
-        def->blkdeviotune.read_iops_sec_max = 0;
-    }
-
-    if (virXPathULongLong("string(./iotune/write_iops_sec_max)",
-                          ctxt,
-                          &def->blkdeviotune.write_iops_sec_max) < 0) {
-        def->blkdeviotune.write_iops_sec_max = 0;
-    }
-
-    if (virXPathULongLong("string(./iotune/size_iops_sec)",
-                          ctxt,
-                          &def->blkdeviotune.size_iops_sec) < 0) {
-        def->blkdeviotune.size_iops_sec = 0;
-    }
-
+    PARSE_IOTUNE(total_bytes_sec_max);
+    PARSE_IOTUNE(read_bytes_sec_max);
+    PARSE_IOTUNE(write_bytes_sec_max);
+    PARSE_IOTUNE(total_iops_sec_max);
+    PARSE_IOTUNE(read_iops_sec_max);
+    PARSE_IOTUNE(write_iops_sec_max);
+
+    PARSE_IOTUNE(size_iops_sec);
 
     if ((def->blkdeviotune.total_bytes_sec &&
          def->blkdeviotune.read_bytes_sec) ||