On Fri, Apr 10, 2015 at 14:58:56 +0200, Ján Tomko wrote:
For reuse in snapshot_conf.
---
src/conf/storage_conf.c | 23 +----------------------
src/conf/storage_feature_conf.c | 25 +++++++++++++++++++++++++
src/conf/storage_feature_conf.h | 3 +++
3 files changed, 29 insertions(+), 22 deletions(-)
...
diff --git a/src/conf/storage_feature_conf.c
b/src/conf/storage_feature_conf.c
index 77e6406..2a4b3df 100644
--- a/src/conf/storage_feature_conf.c
+++ b/src/conf/storage_feature_conf.c
@@ -60,3 +60,28 @@ int virStorageFeaturesParse(xmlXPathContextPtr ctxt,
VIR_FREE(feat_xpath);
return ret;
}
+
+void virStorageFeaturesFormat(virBufferPtr buf,
+ virBitmapPtr features)
<coding_style_bike_shed>
there's only one line between functions and the return type is not on a
new line.
</coding_style_bike_shed>
+{
+ size_t i;
+
+ if (!features)
+ return;
+
+ if (virBitmapIsAllClear(features)) {
+ virBufferAddLit(buf, "<features/>\n");
+ return;
I like this control flow change.
+ }
+ virBufferAddLit(buf, "<features>\n");
+ virBufferAdjustIndent(buf, 2);
+
+ for (i = 0; i < VIR_STORAGE_FILE_FEATURE_LAST; i++) {
+ if (virBitmapIsBitSet(features, i))
+ virBufferAsprintf(buf, "<%s/>\n",
+ virStorageFileFeatureTypeToString(i));
+ }
+
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</features>\n");
+}
ACK,
Peter