This patch adds the common code for outputting drive sizing information, when a user has requested the new API flag from the previous patch. * src/util/virstoragefile.h (_virStorageSource): Add physical, to mirror virDomainBlockInfo. * docs/schemas/domaincommon.rng (storageSourceExtra): New define. * src/conf/domain_conf.c (virDomainDiskDefFormat): Output sizing when flag is set. (DUMPXML_FLAGS): Add new flag. Signed-off-by: Eric Blake <eblake@xxxxxxxxxx> --- docs/schemas/domaincommon.rng | 22 ++++++++++++++++++++++ src/conf/domain_conf.c | 16 +++++++++++++++- src/util/virstoragefile.h | 3 ++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c600f22..dd874fc 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1292,6 +1292,28 @@ </element> </define> + <define name='storageSourceExtra' combine='choice'> + <!-- Override of storagecommon.rng to allow domain disks to list + extras without impacting snapshot disks --> + <interleave> + <optional> + <element name="capacity"> + <ref name="scaledInteger"/> + </element> + </optional> + <optional> + <element name="allocation"> + <ref name="scaledInteger"/> + </element> + </optional> + <optional> + <element name="physical"> + <ref name="scaledInteger"/> + </element> + </optional> + </interleave> + </define> + <define name="diskBackingChain"> <choice> <ref name="diskBackingStore"/> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3ccec1c..3b54619 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -108,7 +108,8 @@ typedef enum { (VIR_DOMAIN_XML_SECURE | \ VIR_DOMAIN_XML_INACTIVE | \ VIR_DOMAIN_XML_UPDATE_CPU | \ - VIR_DOMAIN_XML_MIGRATABLE) + VIR_DOMAIN_XML_MIGRATABLE | \ + VIR_DOMAIN_XML_BLOCK_INFO) verify(((VIR_DOMAIN_XML_INTERNAL_STATUS | VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET | @@ -15887,6 +15888,19 @@ virDomainDiskDefFormat(virBufferPtr buf, flags) < 0) return -1; + if (flags & VIR_DOMAIN_XML_BLOCK_INFO) { + if (def->src->capacity) + virBufferAsprintf(buf, "<capacity unit='bytes'>%llu</capacity>\n", + def->src->capacity); + if (def->src->allocation) + virBufferAsprintf(buf, + "<allocation unit='bytes'>%llu</allocation>\n", + def->src->allocation); + if (def->src->physical) + virBufferAsprintf(buf, "<physical unit='bytes'>%llu</physical>\n", + def->src->physical); + } + /* Don't format backingStore to inactive XMLs until the code for * persistent storage of backing chains is ready. */ if (!(flags & VIR_DOMAIN_XML_INACTIVE) && diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2583e10..681e50a 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -252,8 +252,9 @@ struct _virStorageSource { virStoragePermsPtr perms; virStorageTimestampsPtr timestamps; - unsigned long long allocation; /* in bytes, 0 if unknown */ unsigned long long capacity; /* in bytes, 0 if unknown */ + unsigned long long allocation; /* in bytes, 0 if unknown */ + unsigned long long physical; /* in bytes, 0 if unknown */ size_t nseclabels; virSecurityDeviceLabelDefPtr *seclabels; -- 1.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list