From: Peter Krempa Date: Tue, 12 Apr 2016 13:03:19 +0000 (+0200) Subject: conf: virDomainDiskDefIotuneParse: Report malformed number errors X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=14e4c4e46503267e59a924cf066a43030e5414d7;p=libvirt.git conf: virDomainDiskDefIotuneParse: Report malformed number errors 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. --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ada00f839..510be735a9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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) ||