---
generator/actions.ml | 13 +++++++------
src/drives.c | 18 +++++++++++-------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index 0bb04be..daea6b6 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -1352,6 +1352,7 @@ See also: L<guestfs(3)/NETWORK BLOCK DEVICE>.
Connect to the Ceph (librbd/RBD) server.
The C<server> parameter must also be supplied - see below.
+The C<username> parameter may be supplied. See below.
See also: L<guestfs(3)/CEPH>.
@@ -1401,13 +1402,13 @@ for the protocol is used (see C</etc/services>).
=item C<username>
-For the C<ssh> protocol only, this specifies the remote username.
+For the C<ssh> and C<rbd> protocols only, this specifies the remote
username.
-If not given, then the local username is used. But note this sometimes
-may give unexpected results, for example if using the libvirt backend
-and if the libvirt backend is configured to start the qemu appliance
-as a special user such as C<qemu.qemu>. If in doubt, specify the
-remote username you want.
+If not given, then the local username is used for C<ssh>, and 'admin' is
used
+for C<rbd>. But note this sometimes may give unexpected results, for example
+if using the libvirt backend and if the libvirt backend is configured to start
+the qemu appliance as a special user such as C<qemu.qemu>. If in doubt,
+specify the remote username you want.
=back" };
diff --git a/src/drives.c b/src/drives.c
index 0a6d956..a510e1e 100644
--- a/src/drives.c
+++ b/src/drives.c
@@ -221,11 +221,6 @@ create_drive_rbd (guestfs_h *g,
{
size_t i;
- if (username != NULL) {
- error (g, _("rbd: you cannot specify a username with this protocol"));
- return NULL;
- }
-
if (nr_servers == 0) {
error (g, _("rbd: you must specify one or more servers"));
return NULL;
@@ -1088,7 +1083,8 @@ guestfs___drive_source_qemu_param (guestfs_h *g, const struct
drive_source *src)
case drive_protocol_rbd: {
/* build the list of all the mon hosts */
- CLEANUP_FREE char *mon_host = NULL;
+ CLEANUP_FREE char *mon_host = NULL, *username = NULL;
+ char *auth;
size_t n = 0;
for (int i = 0; i < src->nr_servers; i++) {
n += strlen (src->servers[i].u.hostname);
@@ -1115,7 +1111,15 @@ guestfs___drive_source_qemu_param (guestfs_h *g, const struct
drive_source *src)
}
mon_host[n] = '\0';
- return safe_asprintf (g, "rbd:%s:mon_host=%s", src->u.exportname,
mon_host);
+ if (src->username)
+ username = safe_asprintf (g, ":id=%s", src->username);
+ if (username)
+ auth = ":auth_supported=cephx\\;none";
+ else
+ auth = ":auth_supported=none";
+
+ return safe_asprintf (g, "rbd:%s:mon_host=%s%s%s", src->u.exportname,
mon_host,
+ username ? username : "", auth);
}
case drive_protocol_sheepdog:
--
1.7.9.5