Rather than copy-paste - use a macro Unfortunately due to how the RNG schema was written keeping the 'value' and 'value'_max next to each other in the XML causes a schema failure, so the FORMAT has to write out singly rather than optimizing to write out both values at once Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/domain_conf.c | 77 +++++++++++++------------------------------------- 1 file changed, 19 insertions(+), 58 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dd34cec..f53d6c5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20061,6 +20061,12 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, } +#define FORMAT_IOTUNE(val) \ + if (def->blkdeviotune.val) { \ + virBufferAsprintf(buf, "<" #val ">%llu</" #val ">\n", \ + def->blkdeviotune.val); \ + } + static int virDomainDiskDefFormat(virBufferPtr buf, virDomainDiskDefPtr def, @@ -20248,66 +20254,20 @@ virDomainDiskDefFormat(virBufferPtr buf, def->blkdeviotune.size_iops_sec) { virBufferAddLit(buf, "<iotune>\n"); virBufferAdjustIndent(buf, 2); - if (def->blkdeviotune.total_bytes_sec) { - virBufferAsprintf(buf, "<total_bytes_sec>%llu</total_bytes_sec>\n", - def->blkdeviotune.total_bytes_sec); - } - - if (def->blkdeviotune.read_bytes_sec) { - virBufferAsprintf(buf, "<read_bytes_sec>%llu</read_bytes_sec>\n", - def->blkdeviotune.read_bytes_sec); - - } - - if (def->blkdeviotune.write_bytes_sec) { - virBufferAsprintf(buf, "<write_bytes_sec>%llu</write_bytes_sec>\n", - def->blkdeviotune.write_bytes_sec); - } - - if (def->blkdeviotune.total_iops_sec) { - virBufferAsprintf(buf, "<total_iops_sec>%llu</total_iops_sec>\n", - def->blkdeviotune.total_iops_sec); - } - - if (def->blkdeviotune.read_iops_sec) { - virBufferAsprintf(buf, "<read_iops_sec>%llu</read_iops_sec>\n", - def->blkdeviotune.read_iops_sec); - } - if (def->blkdeviotune.write_iops_sec) { - virBufferAsprintf(buf, "<write_iops_sec>%llu</write_iops_sec>\n", - def->blkdeviotune.write_iops_sec); - } - - if (def->blkdeviotune.total_bytes_sec_max) { - virBufferAsprintf(buf, "<total_bytes_sec_max>%llu</total_bytes_sec_max>\n", - def->blkdeviotune.total_bytes_sec_max); - } - - if (def->blkdeviotune.read_bytes_sec_max) { - virBufferAsprintf(buf, "<read_bytes_sec_max>%llu</read_bytes_sec_max>\n", - def->blkdeviotune.read_bytes_sec_max); - } - - if (def->blkdeviotune.write_bytes_sec_max) { - virBufferAsprintf(buf, "<write_bytes_sec_max>%llu</write_bytes_sec_max>\n", - def->blkdeviotune.write_bytes_sec_max); - } - - if (def->blkdeviotune.total_iops_sec_max) { - virBufferAsprintf(buf, "<total_iops_sec_max>%llu</total_iops_sec_max>\n", - def->blkdeviotune.total_iops_sec_max); - } + FORMAT_IOTUNE(total_bytes_sec); + FORMAT_IOTUNE(read_bytes_sec); + FORMAT_IOTUNE(write_bytes_sec); + FORMAT_IOTUNE(total_iops_sec); + FORMAT_IOTUNE(read_iops_sec); + FORMAT_IOTUNE(write_iops_sec); - if (def->blkdeviotune.read_iops_sec_max) { - virBufferAsprintf(buf, "<read_iops_sec_max>%llu</read_iops_sec_max>\n", - def->blkdeviotune.read_iops_sec_max); - } - - if (def->blkdeviotune.write_iops_sec_max) { - virBufferAsprintf(buf, "<write_iops_sec_max>%llu</write_iops_sec_max>\n", - def->blkdeviotune.write_iops_sec_max); - } + FORMAT_IOTUNE(total_bytes_sec_max); + FORMAT_IOTUNE(read_bytes_sec_max); + FORMAT_IOTUNE(write_bytes_sec_max); + FORMAT_IOTUNE(total_iops_sec_max); + FORMAT_IOTUNE(read_iops_sec_max); + FORMAT_IOTUNE(write_iops_sec_max); if (def->blkdeviotune.size_iops_sec) { virBufferAsprintf(buf, "<size_iops_sec>%llu</size_iops_sec>\n", @@ -20339,6 +20299,7 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAddLit(buf, "</disk>\n"); return 0; } +#undef FORMAT_IOTUNE static int -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list