提交 e103acba 编写于 作者: P Peter Krempa

storage: RBD: Separate creating of the volume from building

Separate the steps to create libvirt's volume metadata from the actual
volume building process.
上级 67ccf91b
...@@ -435,9 +435,35 @@ cleanup: ...@@ -435,9 +435,35 @@ cleanup:
return ret; return ret;
} }
static int virStorageBackendRBDCreateVol(virConnectPtr conn,
static int
virStorageBackendRBDCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool, virStoragePoolObjPtr pool,
virStorageVolDefPtr vol) virStorageVolDefPtr vol)
{
vol->type = VIR_STORAGE_VOL_NETWORK;
VIR_FREE(vol->target.path);
if (virAsprintf(&vol->target.path, "%s/%s",
pool->def->source.name,
vol->name) == -1)
return -1;
VIR_FREE(vol->key);
if (virAsprintf(&vol->key, "%s/%s",
pool->def->source.name,
vol->name) == -1)
return -1;
return 0;
}
static int
virStorageBackendRBDBuildVol(virConnectPtr conn,
virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int flags)
{ {
virStorageBackendRBDState ptr; virStorageBackendRBDState ptr;
ptr.cluster = NULL; ptr.cluster = NULL;
...@@ -449,9 +475,10 @@ static int virStorageBackendRBDCreateVol(virConnectPtr conn, ...@@ -449,9 +475,10 @@ static int virStorageBackendRBDCreateVol(virConnectPtr conn,
pool->def->source.name, pool->def->source.name,
vol->name, vol->capacity); vol->name, vol->capacity);
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, pool) < 0) { virCheckFlags(0, -1);
if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, pool) < 0)
goto cleanup; goto cleanup;
}
if (rados_ioctx_create(ptr.cluster, if (rados_ioctx_create(ptr.cluster,
pool->def->source.name, &ptr.ioctx) < 0) { pool->def->source.name, &ptr.ioctx) < 0) {
...@@ -475,9 +502,8 @@ static int virStorageBackendRBDCreateVol(virConnectPtr conn, ...@@ -475,9 +502,8 @@ static int virStorageBackendRBDCreateVol(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0) { if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0)
goto cleanup; goto cleanup;
}
ret = 0; ret = 0;
...@@ -572,6 +598,7 @@ virStorageBackend virStorageBackendRBD = { ...@@ -572,6 +598,7 @@ virStorageBackend virStorageBackendRBD = {
.refreshPool = virStorageBackendRBDRefreshPool, .refreshPool = virStorageBackendRBDRefreshPool,
.createVol = virStorageBackendRBDCreateVol, .createVol = virStorageBackendRBDCreateVol,
.buildVol = virStorageBackendRBDBuildVol,
.refreshVol = virStorageBackendRBDRefreshVol, .refreshVol = virStorageBackendRBDRefreshVol,
.deleteVol = virStorageBackendRBDDeleteVol, .deleteVol = virStorageBackendRBDDeleteVol,
.resizeVol = virStorageBackendRBDResizeVol, .resizeVol = virStorageBackendRBDResizeVol,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册