From: Wido den Hollander Date: Thu, 24 Dec 2015 12:34:58 +0000 (+0100) Subject: rbd: Return VIR_STORAGE_FILE_RAW as format for RBD volumes X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=688623b5b035cc0ce736a2e39329b47b36855636;p=libvirt.git rbd: Return VIR_STORAGE_FILE_RAW as format for RBD volumes This used to return 'unkown' and that was not correct. A vol-dumpxml now returns: image3 libvirt/image3 10737418240 10737418240 libvirt/image3 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 --- diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 9b8abea795..7c81babd04 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 cdbfdee985..80684eb55a 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;