mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 15:52:55 +00:00
qemu: block: Add support for RBD authentication for blockdev
To allow using -blockdev with RBD we need to support the recently added RBD authentication. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
8b4a31efc0
commit
1cb98a1fb3
@ -906,13 +906,33 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src)
|
|||||||
virJSONValuePtr servers = NULL;
|
virJSONValuePtr servers = NULL;
|
||||||
virJSONValuePtr ret = NULL;
|
virJSONValuePtr ret = NULL;
|
||||||
const char *username = NULL;
|
const char *username = NULL;
|
||||||
|
virJSONValuePtr authmodes = NULL;
|
||||||
|
virJSONValuePtr mode = NULL;
|
||||||
|
const char *keysecret = NULL;
|
||||||
|
|
||||||
if (src->nhosts > 0 &&
|
if (src->nhosts > 0 &&
|
||||||
!(servers = qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(src)))
|
!(servers = qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(src)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (src->auth)
|
if (src->auth) {
|
||||||
username = srcPriv->secinfo->s.aes.username;
|
username = srcPriv->secinfo->s.aes.username;
|
||||||
|
keysecret = srcPriv->secinfo->s.aes.alias;
|
||||||
|
/* the auth modes are modelled after our old command line generator */
|
||||||
|
if (!(authmodes = virJSONValueNewArray()))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!(mode = virJSONValueNewString("cephx")) ||
|
||||||
|
virJSONValueArrayAppend(authmodes, mode) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
mode = NULL;
|
||||||
|
|
||||||
|
if (!(mode = virJSONValueNewString("none")) ||
|
||||||
|
virJSONValueArrayAppend(authmodes, mode) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
mode = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectCreate(&ret,
|
if (virJSONValueObjectCreate(&ret,
|
||||||
"s:driver", "rbd",
|
"s:driver", "rbd",
|
||||||
@ -922,10 +942,14 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src)
|
|||||||
"S:conf", src->configFile,
|
"S:conf", src->configFile,
|
||||||
"A:server", &servers,
|
"A:server", &servers,
|
||||||
"S:user", username,
|
"S:user", username,
|
||||||
|
"A:auth-client-required", &authmodes,
|
||||||
|
"S:key-secret", keysecret,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virJSONValueFree(authmodes);
|
||||||
|
virJSONValueFree(mode);
|
||||||
virJSONValueFree(servers);
|
virJSONValueFree(servers);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"user": "testuser-rbd",
|
"user": "testuser-rbd",
|
||||||
|
"auth-client-required": [
|
||||||
|
"cephx",
|
||||||
|
"none"
|
||||||
|
],
|
||||||
|
"key-secret": "node-a-s-secalias",
|
||||||
"node-name": "node-a-s",
|
"node-name": "node-a-s",
|
||||||
"cache": {
|
"cache": {
|
||||||
"direct": false,
|
"direct": false,
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"user": "testuser-rbd",
|
"user": "testuser-rbd",
|
||||||
|
"auth-client-required": [
|
||||||
|
"cephx",
|
||||||
|
"none"
|
||||||
|
],
|
||||||
|
"key-secret": "node-a-s-secalias",
|
||||||
"node-name": "node-a-s",
|
"node-name": "node-a-s",
|
||||||
"read-only": false,
|
"read-only": false,
|
||||||
"discard": "unmap"
|
"discard": "unmap"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user