This used to return 'unkown' and that was not correct.
A vol-dumpxml now returns:
<volume type='network'>
<name>image3</name>
<key>libvirt/image3</key>
<source>
</source>
<capacity unit='bytes'>10737418240</capacity>
<allocation unit='bytes'>10737418240</allocation>
<target>
<path>libvirt/image3</path>
<format type='raw'/>
</target>
</volume>
The RBD driver will now error out if a different format than RAW
is provided when creating a volume.
Signed-off-by: Wido den Hollander <wido(a)widodh.nl>
---
src/conf/storage_conf.c | 3 ++-
src/storage/storage_backend_rbd.c | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9b8abea..7c81bab 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -220,7 +220,8 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
},
.volOptions = {
.defaultFormat = VIR_STORAGE_FILE_RAW,
- .formatToString = virStoragePoolFormatDiskTypeToString,
+ .formatFromString = virStorageVolumeFormatFromString,
+ .formatToString = virStorageFileFormatTypeToString,
}
},
{.poolType = VIR_STORAGE_POOL_SHEEPDOG,
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index cdbfdee..80684eb 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -306,6 +306,7 @@ static int volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr
vol,
vol->target.capacity = info.size;
vol->target.allocation = info.obj_size * info.num_objs;
vol->type = VIR_STORAGE_VOL_NETWORK;
+ vol->target.format = VIR_STORAGE_FILE_RAW;
VIR_FREE(vol->target.path);
if (virAsprintf(&vol->target.path, "%s/%s",
@@ -557,6 +558,12 @@ virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
{
vol->type = VIR_STORAGE_VOL_NETWORK;
+ if (vol->target.format != VIR_STORAGE_FILE_RAW) {
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ _("only RAW volumes are supported by this storage
pool"));
+ return -VIR_ERR_NO_SUPPORT;
+ }
+
VIR_FREE(vol->target.path);
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->source.name,
@@ -603,6 +610,12 @@ virStorageBackendRBDBuildVol(virConnectPtr conn,
goto cleanup;
}
+ if (vol->target.format != VIR_STORAGE_FILE_RAW) {
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ _("only RAW volumes are supported by this storage
pool"));
+ goto cleanup;
+ }
+
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source)
< 0)
goto cleanup;
--
1.9.1