Patch for adding virsecretuuid & cephx_key ids to --bsopts
Hello,
Below is a patch that adds two new params to --bsopts for RBD backing stores (virsecretuuid & cephx_key). This was very useful for me, since it is nice to be able to give the required authentication detail in the same place as the id. I have tested and both options work, as well as the error condition if both options are given (made them conflict).
I have verified the patch passes scripts/checkpatch.pl style guidelines. Is there any interest in applying this patch? Im using this internally with success; for us at least this is a desirable thing to have.
From 5359b581c5e7bf434979becaefc53a711ef88432 Mon Sep 17 00:00:00 2001
From: Scott Sullivan <[email protected]>
Date: Tue, 17 Jun 2014 08:16:09 -0400
Subject: [PATCH] bsopts: Add virsecretuuid && cephx_key
Allow passing either a libvirt secret UUID, or a cephx_key to --bsopts. Options are conflicting, so error if both options given. This allows one to do this:
--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;virsecretuuid=$MY_LIBVIRT_SECRET_UUID" -OR-
--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;cephx_key=$MY_KEY"
--- usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
usr/bs_rbd.c +64 -0
@@ -517,6 +517,9 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)struct active_rbd *rbd =RBDP (lu);char *confname =NULL ;char *clientid =NULL ; +char *virsecretuuid =NULL ; +char *given_cephx_key =NULL ; +char disc_cephx_key[256 ];char *clustername =NULL ;char clientid_full[128 ];char *ignore =NULL ;
@@ -532,6 +535,10 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) clientid =slurp_value (&bsopts); else if (is_opt("cluster", bsopts)) clustername =slurp_value (&bsopts); + else if (is_opt("virsecretuuid", bsopts)) + virsecretuuid =slurp_value (&bsopts); + else if (is_opt("cephx_key", bsopts)) + given_cephx_key =slurp_value (&bsopts); else { ignore =slurp_to_semi (&bsopts); eprintf("bs_rbd: ignoring unknown option \"%s\"\n",
@@ -547,6 +554,41 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)eprintf ("bs_rbd_init: confname %s\n" , confname);if (clustername)eprintf ("bs_rbd_init: clustername %s\n" , clustername); +if (virsecretuuid) +eprintf ("bs_rbd_init: virsecretuuid %s\n" , virsecretuuid); +if (given_cephx_key) +eprintf ("bs_rbd_init: given_cephx_key %s\n" , given_cephx_key); + +/* virsecretuuid && given_cephx_key are conflicting options. */ +if (virsecretuuid && given_cephx_key) { +eprintf ("Conflicting options virsecretuuid=[%s] cephx_key=[%s]" , + virsecretuuid, given_cephx_key); + goto fail; + } + +/* Get stored key from secret uuid. */ +if (virsecretuuid) { +char libvir_uuid_file_path_buf[256 ] ="/etc/libvirt/secrets/" ; +strcat (libvir_uuid_file_path_buf, virsecretuuid); +strcat (libvir_uuid_file_path_buf,".base64" ); + +FILE *fp; + fp =fopen (libvir_uuid_file_path_buf ,"r" ); +if (fp ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +if (fgets (disc_cephx_key,256 , fp) ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +fclose (fp); +strtok (disc_cephx_key,"\n" ); + +eprintf ("bs_rbd_init: disc_cephx_key %s\n" , disc_cephx_key); + }eprintf ("bs_rbd_init bsopts=%s\n" , bsopts);/*
@@ -570,6 +612,7 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)eprintf ("bs_rbd_init: rados_create: %d\n" , rados_ret);return ret; } +/* * Read config from environment, then conf file(s) which may * be set by conf=
@@ -584,6 +627,23 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)eprintf ("bs_rbd_init: rados_conf_read_file: %d\n" , rados_ret); goto fail; } + +/* Set given key */ +if (virsecretuuid) { +if (rados_conf_set (rbd->cluster,"key" , disc_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + disc_cephx_key); + goto fail; + } + } +if (given_cephx_key) { +if (rados_conf_set (rbd->cluster,"key" , given_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + given_cephx_key); + goto fail; + } + } + rados_ret =rados_connect (rbd->cluster);if (rados_ret <0 ) {eprintf ("bs_rbd_init: rados_connect: %d\n" , rados_ret);
@@ -595,6 +655,10 @@ fail:free (confname);if (clientid)free (clientid); +if (virsecretuuid) +free (virsecretuuid); +if (given_cephx_key) +free (given_cephx_key);return ret; }
Signature · 1 line
1.7.10.4
Added Dan to To:
Quoted 156 lines · On Tue, 17 Jun 2014 08:49:14 -0400 Scott Sullivan <[email protected]>…
Hello,
Below is a patch that adds two new params to --bsopts for RBD backing stores (virsecretuuid &
cephx_key). This was very useful for me, since it is nice to be able to give the required authentication detail in the same place as the id. I have tested and both options work, as well as the error condition if both options are given (made them conflict).I have verified the patch passes
scripts/checkpatch.plstyle guidelines. Is there any interest in applying this patch? Im using this internally with success; for us at least this is a desirable thing to have.From
5359b581c5e7bf434979becaefc53a711ef88432Mon Sep 17 00:00:00 2001
From: Scott Sullivan <[email protected]>
Date: Tue, 17 Jun 2014 08:16:09 -0400
Subject: [PATCH] bsopts: Add virsecretuuid &&cephx_keyAllow passing either a libvirt secret UUID, or a
cephx_keyto --bsopts. Options are
conflicting, so error if both options given. This allows one to do this:--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;virsecretuuid=$MY_LIBVIRT_SECRET_UUID" -OR-
--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;cephx_key=$MY_KEY"Signed-off-by Scott Sullivan <[email protected]>--- usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)usr/bs_rbd.c +3
-0@@ -517,6 +517,9 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)struct active_rbd *rbd =RBDP (lu);char *confname =NULL ;char *clientid =NULL ; +char *virsecretuuid =NULL ; +char *given_cephx_key =NULL ; +char disc_cephx_key[256 ];char *clustername =NULL ;char clientid_full[128 ];char *ignore = NULL;usr/bs_rbd.c +4
-0@@ -532,6 +535,10 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) clientid =slurp_value (&bsopts); else if (is_opt("cluster", bsopts)) clustername =slurp_value (&bsopts); + else if (is_opt("virsecretuuid", bsopts)) + virsecretuuid =slurp_value (&bsopts); + else if (is_opt("cephx_key", bsopts)) + given_cephx_key =slurp_value (&bsopts); else { ignore =slurp_to_semi (&bsopts);eprintf("bs_rbd: ignoring unknown option \"%s\"\n",
usr/bs_rbd.c +35
-0@@ -547,6 +554,41 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: confname %s\n", confname);if (clustername)eprintf ("bs_rbd_init: clustername %s\n" , clustername); +if (virsecretuuid) +eprintf ("bs_rbd_init: virsecretuuid %s\n" , virsecretuuid); +if (given_cephx_key) +eprintf ("bs_rbd_init: given_cephx_key %s\n" , given_cephx_key); + +/* virsecretuuid && given_cephx_key are conflicting options. */ +if (virsecretuuid && given_cephx_key) { +eprintf ("Conflicting options virsecretuuid=[%s] cephx_key=[%s]" , + virsecretuuid, given_cephx_key); + goto fail; + } + +/* Get stored key from secret uuid. */ +if (virsecretuuid) { +char libvir_uuid_file_path_buf[256 ] ="/etc/libvirt/secrets/" ; +strcat (libvir_uuid_file_path_buf, virsecretuuid); +strcat (libvir_uuid_file_path_buf,".base64" ); + +FILE *fp; + fp =fopen (libvir_uuid_file_path_buf ,"r" ); +if (fp ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +if (fgets (disc_cephx_key,256 , fp) ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +fclose (fp); +strtok (disc_cephx_key,"\n" ); + +eprintf ("bs_rbd_init: disc_cephx_key %s\n" , disc_cephx_key); + }eprintf ("bs_rbd_init bsopts=%s\n" , bsopts);/*usr/bs_rbd.c +1
-0@@ -570,6 +612,7 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_create: %d\n", rados_ret);return ret; } +/* * Read config from environment, then conf file(s) which may * be set by conf=
usr/bs_rbd.c +17
-0@@ -584,6 +627,23 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_conf_read_file: %d\n", rados_ret); goto fail; } + +/* Set given key */ +if (virsecretuuid) { +if (rados_conf_set (rbd->cluster,"key" , disc_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + disc_cephx_key); + goto fail; + } + } +if (given_cephx_key) { +if (rados_conf_set (rbd->cluster,"key" , given_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + given_cephx_key); + goto fail; + } + } + rados_ret =rados_connect (rbd->cluster);if (rados_ret <0 ) {eprintf("bs_rbd_init: rados_connect: %d\n", rados_ret);usr/bs_rbd.c +4
-0@@ -595,6 +655,10 @@ fail:free (confname);if (clientid)free (clientid); +if (virsecretuuid) +free (virsecretuuid); +if (given_cephx_key) +free (given_cephx_key);return ret; }Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
I've seen this; I'm traveling/busy this week so will try to give it some thought, but no promises
Quoted 161 lines · FUJITA Tomonori
Added Dan to To:
Quoted 156 lines · On Tue, 17 Jun 2014 08:49:14 -0400 Scott Sullivan <[email protected]>…
Hello,
Below is a patch that adds two new params to --bsopts for RBD backing stores (virsecretuuid &
cephx_key). This was very useful for me, since it is nice to be able to give the required authentication detail in the same place as the id. I have tested and both options work, as well as the error condition if both options are given (made them conflict).I have verified the patch passes
scripts/checkpatch.plstyle guidelines. Is there any interest in applying this patch? Im using this internally with success; for us at least this is a desirable thing to have.From
5359b581c5e7bf434979becaefc53a711ef88432Mon Sep 17 00:00:00 2001
From: Scott Sullivan <[email protected]>
Date: Tue, 17 Jun 2014 08:16:09 -0400
Subject: [PATCH] bsopts: Add virsecretuuid &&cephx_keyAllow passing either a libvirt secret UUID, or a
cephx_keyto --bsopts. Options are
conflicting, so error if both options given. This allows one to do this:--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;virsecretuuid=$MY_LIBVIRT_SECRET_UUID" -OR-
--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;cephx_key=$MY_KEY"Signed-off-by Scott Sullivan <[email protected]>--- usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)usr/bs_rbd.c +3
-0@@ -517,6 +517,9 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)struct active_rbd *rbd =RBDP (lu);char *confname =NULL ;char *clientid =NULL ; +char *virsecretuuid =NULL ; +char *given_cephx_key =NULL ; +char disc_cephx_key[256 ];char *clustername =NULL ;char clientid_full[128 ];char *ignore = NULL;usr/bs_rbd.c +4
-0@@ -532,6 +535,10 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) clientid =slurp_value (&bsopts); else if (is_opt("cluster", bsopts)) clustername =slurp_value (&bsopts); + else if (is_opt("virsecretuuid", bsopts)) + virsecretuuid =slurp_value (&bsopts); + else if (is_opt("cephx_key", bsopts)) + given_cephx_key =slurp_value (&bsopts); else { ignore =slurp_to_semi (&bsopts);eprintf("bs_rbd: ignoring unknown option \"%s\"\n",
usr/bs_rbd.c +35
-0@@ -547,6 +554,41 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: confname %s\n", confname);if (clustername)eprintf ("bs_rbd_init: clustername %s\n" , clustername); +if (virsecretuuid) +eprintf ("bs_rbd_init: virsecretuuid %s\n" , virsecretuuid); +if (given_cephx_key) +eprintf ("bs_rbd_init: given_cephx_key %s\n" , given_cephx_key); + +/* virsecretuuid && given_cephx_key are conflicting options. */ +if (virsecretuuid && given_cephx_key) { +eprintf ("Conflicting options virsecretuuid=[%s] cephx_key=[%s]" , + virsecretuuid, given_cephx_key); + goto fail; + } + +/* Get stored key from secret uuid. */ +if (virsecretuuid) { +char libvir_uuid_file_path_buf[256 ] ="/etc/libvirt/secrets/" ; +strcat (libvir_uuid_file_path_buf, virsecretuuid); +strcat (libvir_uuid_file_path_buf,".base64" ); + +FILE *fp; + fp =fopen (libvir_uuid_file_path_buf ,"r" ); +if (fp ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +if (fgets (disc_cephx_key,256 , fp) ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +fclose (fp); +strtok (disc_cephx_key,"\n" ); + +eprintf ("bs_rbd_init: disc_cephx_key %s\n" , disc_cephx_key); + }eprintf ("bs_rbd_init bsopts=%s\n" , bsopts);/*usr/bs_rbd.c +1
-0@@ -570,6 +612,7 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_create: %d\n", rados_ret);return ret; } +/* * Read config from environment, then conf file(s) which may * be set by conf=
usr/bs_rbd.c +17
-0@@ -584,6 +627,23 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_conf_read_file: %d\n", rados_ret); goto fail; } + +/* Set given key */ +if (virsecretuuid) { +if (rados_conf_set (rbd->cluster,"key" , disc_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + disc_cephx_key); + goto fail; + } + } +if (given_cephx_key) { +if (rados_conf_set (rbd->cluster,"key" , given_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + given_cephx_key); + goto fail; + } + } + rados_ret =rados_connect (rbd->cluster);if (rados_ret <0 ) {eprintf("bs_rbd_init: rados_connect: %d\n", rados_ret);usr/bs_rbd.c +4
-0@@ -595,6 +655,10 @@ fail:free (confname);if (clientid)free (clientid); +if (virsecretuuid) +free (virsecretuuid); +if (given_cephx_key) +free (given_cephx_key);return ret; }Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Dan Mick
I've seen this; I'm traveling/busy this week so will try to give it some thought, but no promises
ping ?
Quoted 167 lines · FUJITA Tomonori
Quoted 163 lines
Added Dan to To:
Quoted 158 lines · On Tue, 17 Jun 2014 08:49:14 -0400 Scott Sullivan <[email protected]>…
Hello,
Below is a patch that adds two new params to --bsopts for RBD backing stores (virsecretuuid &
cephx_key). This was very useful for me, since it is nice to be able to give the required authentication detail in the same place as the id. I have tested and both options work, as well as the error condition if both options are given (made them conflict).I have verified the patch passes
scripts/checkpatch.plstyle guidelines. Is there any interest in applying this patch? Im using this internally with success; for us at least this is a desirable thing to have.From
5359b581c5e7bf434979becaefc53a711ef88432Mon Sep 17 00:00:00 2001
From: Scott Sullivan <[email protected]>
Date: Tue, 17 Jun 2014 08:16:09 -0400
Subject: [PATCH] bsopts: Add virsecretuuid &&cephx_keyAllow passing either a libvirt secret UUID, or a
cephx_keyto --bsopts. Options are
conflicting, so error if both options given. This allows one to do this:--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;virsecretuuid=$MY_LIBVIRT_SECRET_UUID"
-OR- --bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;cephx_key=$MY_KEY"
Signed-off-by Scott Sullivan <[email protected]>--- usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)usr/bs_rbd.c +3
-0@@ -517,6 +517,9 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)struct active_rbd *rbd =RBDP (lu);char *confname =NULL ;char *clientid =NULL ; +char *virsecretuuid =NULL ; +char *given_cephx_key =NULL ; +char disc_cephx_key[256 ];char *clustername =NULL ;char clientid_full[128 ];char *ignore = NULL;usr/bs_rbd.c +4
-0@@ -532,6 +535,10 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) clientid =slurp_value (&bsopts); else if (is_opt("cluster", bsopts)) clustername =slurp_value (&bsopts); + else if (is_opt("virsecretuuid", bsopts)) + virsecretuuid =slurp_value (&bsopts); + else if (is_opt("cephx_key", bsopts)) + given_cephx_key =slurp_value (&bsopts); else { ignore =slurp_to_semi (&bsopts);eprintf("bs_rbd: ignoring unknown option \"%s\"\n",
usr/bs_rbd.c +35
-0@@ -547,6 +554,41 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: confname %s\n", confname);if (clustername)eprintf ("bs_rbd_init: clustername %s\n" , clustername); +if (virsecretuuid) +eprintf ("bs_rbd_init: virsecretuuid %s\n" , virsecretuuid); +if (given_cephx_key) +eprintf ("bs_rbd_init: given_cephx_key %s\n" , given_cephx_key); + +/* virsecretuuid && given_cephx_key are conflicting options. */ +if (virsecretuuid && given_cephx_key) { +eprintf ("Conflicting options virsecretuuid=[%s] cephx_key=[%s]" , + virsecretuuid, given_cephx_key); + goto fail; + } + +/* Get stored key from secret uuid. */ +if (virsecretuuid) { +char libvir_uuid_file_path_buf[256 ] ="/etc/libvirt/secrets/" ; +strcat (libvir_uuid_file_path_buf, virsecretuuid); +strcat (libvir_uuid_file_path_buf,".base64" ); + +FILE *fp; + fp =fopen (libvir_uuid_file_path_buf ,"r" ); +if (fp ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +if (fgets (disc_cephx_key,256 , fp) ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +fclose (fp); +strtok (disc_cephx_key,"\n" ); + +eprintf ("bs_rbd_init: disc_cephx_key %s\n" , disc_cephx_key); + }eprintf ("bs_rbd_init bsopts=%s\n" , bsopts);/*usr/bs_rbd.c +1
-0@@ -570,6 +612,7 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_create: %d\n", rados_ret);return ret; } +/* * Read config from environment, then conf file(s) which may * be set by conf=
usr/bs_rbd.c +17
-0@@ -584,6 +627,23 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_conf_read_file: %d\n", rados_ret); goto fail; } + +/* Set given key */ +if (virsecretuuid) { +if (rados_conf_set (rbd->cluster,"key" , disc_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + disc_cephx_key); + goto fail; + } + } +if (given_cephx_key) { +if (rados_conf_set (rbd->cluster,"key" , given_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + given_cephx_key); + goto fail; + } + } + rados_ret =rados_connect (rbd->cluster);if (rados_ret < 0) { eprintf("bs_rbd_init: rados_connect: %d\n", rados_ret);usr/bs_rbd.c +4
-0@@ -595,6 +655,10 @@ fail:free (confname);if (clientid)free (clientid); +if (virsecretuuid) +free (virsecretuuid); +if (given_cephx_key) +free (given_cephx_key);return ret; }Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · On Mon, 21 Jul 2014 15:34:46 -0400 Scott Sullivan <[email protected]>…
Quoted 2 lines · Dan Mick
I've seen this; I'm traveling/busy this week so will try to give it some thought, but no promises
ping ?
I tried to apply however I can't cleanly. Looks like the patch is corrupted. Can you resend?
Quoted 9 lines · FUJITA Tomonori
Quoted 4 lines · On Mon, 21 Jul 2014 15:34:46 -0400 Scott Sullivan <[email protected]>…
Quoted 2 lines · Dan Mick
I've seen this; I'm traveling/busy this week so will try to give it some thought, but no promises
ping ?
I tried to apply however I can't cleanly. Looks like the patch is corrupted. Can you resend?
URL: http://paste.debian.net/111595/
Paste:
From 5359b581c5e7bf434979becaefc53a711ef88432 Mon Sep 17 00:00:00 2001
From: Scott Sullivan <[email protected]>
Date: Tue, 17 Jun 2014 08:16:09 -0400
Subject: [PATCH] bsopts: Add virsecretuuid && cephx_key
Allow passing either a libvirt secret UUID, or a cephx_key to --bsopts. Options are conflicting, so error if both options given. This allows one to do this:
--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;virsecretuuid=$MY_LIBVIRT_SECRET_UUID" -OR-
--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;cephx_key=$MY_KEY"
--- usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
usr/bs_rbd.c +64 -0
@@ -517,6 +517,9 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)struct active_rbd *rbd =RBDP (lu);char *confname =NULL ;char *clientid =NULL ; +char *virsecretuuid =NULL ; +char *given_cephx_key =NULL ; +char disc_cephx_key[256 ];char *clustername =NULL ;char clientid_full[128 ];char *ignore =NULL ;
@@ -532,6 +535,10 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) clientid =slurp_value (&bsopts); else if (is_opt("cluster", bsopts)) clustername =slurp_value (&bsopts); + else if (is_opt("virsecretuuid", bsopts)) + virsecretuuid =slurp_value (&bsopts); + else if (is_opt("cephx_key", bsopts)) + given_cephx_key =slurp_value (&bsopts); else { ignore =slurp_to_semi (&bsopts); eprintf("bs_rbd: ignoring unknown option \"%s\"\n",
@@ -547,6 +554,41 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)eprintf ("bs_rbd_init: confname %s\n" , confname);if (clustername)eprintf ("bs_rbd_init: clustername %s\n" , clustername); +if (virsecretuuid) +eprintf ("bs_rbd_init: virsecretuuid %s\n" , virsecretuuid); +if (given_cephx_key) +eprintf ("bs_rbd_init: given_cephx_key %s\n" , given_cephx_key); + +/* virsecretuuid && given_cephx_key are conflicting options. */ +if (virsecretuuid && given_cephx_key) { +eprintf ("Conflicting options virsecretuuid=[%s] cephx_key=[%s]" , + virsecretuuid, given_cephx_key); + goto fail; + } + +/* Get stored key from secret uuid. */ +if (virsecretuuid) { +char libvir_uuid_file_path_buf[256 ] ="/etc/libvirt/secrets/" ; +strcat (libvir_uuid_file_path_buf, virsecretuuid); +strcat (libvir_uuid_file_path_buf,".base64" ); + +FILE *fp; + fp =fopen (libvir_uuid_file_path_buf ,"r" ); +if (fp ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +if (fgets (disc_cephx_key,256 , fp) ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +fclose (fp); +strtok (disc_cephx_key,"\n" ); + +eprintf ("bs_rbd_init: disc_cephx_key %s\n" , disc_cephx_key); + }eprintf ("bs_rbd_init bsopts=%s\n" , bsopts);/*
@@ -570,6 +612,7 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)eprintf ("bs_rbd_init: rados_create: %d\n" , rados_ret);return ret; } +/* * Read config from environment, then conf file(s) which may * be set by conf=
@@ -584,6 +627,23 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)eprintf ("bs_rbd_init: rados_conf_read_file: %d\n" , rados_ret); goto fail; } + +/* Set given key */ +if (virsecretuuid) { +if (rados_conf_set (rbd->cluster,"key" , disc_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + disc_cephx_key); + goto fail; + } + } +if (given_cephx_key) { +if (rados_conf_set (rbd->cluster,"key" , given_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + given_cephx_key); + goto fail; + } + } + rados_ret =rados_connect (rbd->cluster);if (rados_ret <0 ) {eprintf ("bs_rbd_init: rados_connect: %d\n" , rados_ret);
@@ -595,6 +655,10 @@ fail:free (confname);if (clientid)free (clientid); +if (virsecretuuid) +free (virsecretuuid); +if (given_cephx_key) +free (given_cephx_key);return ret; }
Signature · 13 lines
1.7.10.4 I also checked, and I didn't have any problem applying the patch to the current master branch: ssullivan@data ~/syseng/packages/tgt $ git apply --stat ../rpmbuild/SOURCES/tgt-add_virsecretuuid_cephx_key_to_bsopts.patch usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) ssullivan@data ~/syseng/packages/tgt $ git apply --check ../rpmbuild/SOURCES/tgt-add_virsecretuuid_cephx_key_to_bsopts.patch ssullivan@data ~/syseng/packages/tgt $ git am --signoff < ../rpmbuild/SOURCES/tgt-add_virsecretuuid_cephx_key_to_bsopts.patch Applying: bsopts: Add virsecretuuid && cephx_key ssullivan@data ~/syseng/packages/tgt $
Hmm,
Still corrupted. Looks like the tabs are converted to spaces.
I don't know what mailer you use but the following might be useful:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/email-clients.txt
Quoted 173 lines · On Fri, 25 Jul 2014 07:25:21 -0400 Scott Sullivan <[email protected]>…
Quoted 9 lines · FUJITA Tomonori
Quoted 4 lines · On Mon, 21 Jul 2014 15:34:46 -0400 Scott Sullivan <[email protected]>…
Quoted 2 lines · Dan Mick
I've seen this; I'm traveling/busy this week so will try to give it some thought, but no promises
ping ?
I tried to apply however I can't cleanly. Looks like the patch is corrupted. Can you resend?
URL: http://paste.debian.net/111595/
Paste:
From
5359b581c5e7bf434979becaefc53a711ef88432Mon Sep 17 00:00:00 2001
From: Scott Sullivan <[email protected]>
Date: Tue, 17 Jun 2014 08:16:09 -0400
Subject: [PATCH] bsopts: Add virsecretuuid &&cephx_keyAllow passing either a libvirt secret UUID, or a
cephx_keyto --bsopts. Options are
conflicting, so error if both options given. This allows one to do this:--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;virsecretuuid=$MY_LIBVIRT_SECRET_UUID" -OR-
--bsopts="conf=/etc/ceph/ceph.conf;id=cephx_user;cephx_key=$MY_KEY"Signed-off-by Scott Sullivan <[email protected]>--- usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)usr/bs_rbd.c +3
-0@@ -517,6 +517,9 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts)struct active_rbd *rbd =RBDP (lu);char *confname =NULL ;char *clientid =NULL ; +char *virsecretuuid =NULL ; +char *given_cephx_key =NULL ; +char disc_cephx_key[256 ];char *clustername =NULL ;char clientid_full[128 ];char *ignore = NULL;usr/bs_rbd.c +4
-0@@ -532,6 +535,10 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) clientid =slurp_value (&bsopts); else if (is_opt("cluster", bsopts)) clustername =slurp_value (&bsopts); + else if (is_opt("virsecretuuid", bsopts)) + virsecretuuid =slurp_value (&bsopts); + else if (is_opt("cephx_key", bsopts)) + given_cephx_key =slurp_value (&bsopts); else { ignore =slurp_to_semi (&bsopts);eprintf("bs_rbd: ignoring unknown option \"%s\"\n",
usr/bs_rbd.c +35
-0@@ -547,6 +554,41 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: confname %s\n", confname);if (clustername)eprintf ("bs_rbd_init: clustername %s\n" , clustername); +if (virsecretuuid) +eprintf ("bs_rbd_init: virsecretuuid %s\n" , virsecretuuid); +if (given_cephx_key) +eprintf ("bs_rbd_init: given_cephx_key %s\n" , given_cephx_key); + +/* virsecretuuid && given_cephx_key are conflicting options. */ +if (virsecretuuid && given_cephx_key) { +eprintf ("Conflicting options virsecretuuid=[%s] cephx_key=[%s]" , + virsecretuuid, given_cephx_key); + goto fail; + } + +/* Get stored key from secret uuid. */ +if (virsecretuuid) { +char libvir_uuid_file_path_buf[256 ] ="/etc/libvirt/secrets/" ; +strcat (libvir_uuid_file_path_buf, virsecretuuid); +strcat (libvir_uuid_file_path_buf,".base64" ); + +FILE *fp; + fp =fopen (libvir_uuid_file_path_buf ,"r" ); +if (fp ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +if (fgets (disc_cephx_key,256 , fp) ==NULL ) { +eprintf ("bs_rbd_init: Unable to read %s\n" , + libvir_uuid_file_path_buf); + goto fail; + } +fclose (fp); +strtok (disc_cephx_key,"\n" ); + +eprintf ("bs_rbd_init: disc_cephx_key %s\n" , disc_cephx_key); + }eprintf ("bs_rbd_init bsopts=%s\n" , bsopts);/*usr/bs_rbd.c +1
-0@@ -570,6 +612,7 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_create: %d\n", rados_ret);return ret; } +/* * Read config from environment, then conf file(s) which may * be set by conf=
usr/bs_rbd.c +17
-0@@ -584,6 +627,23 @@ static tgtadm_err bs_rbd_init(struct scsi_lu *lu, char *bsopts) eprintf("bs_rbd_init: rados_conf_read_file: %d\n", rados_ret); goto fail; } + +/* Set given key */ +if (virsecretuuid) { +if (rados_conf_set (rbd->cluster,"key" , disc_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + disc_cephx_key); + goto fail; + } + } +if (given_cephx_key) { +if (rados_conf_set (rbd->cluster,"key" , given_cephx_key) <0 ) { +eprintf ("bs_rbd_init: failed to set cephx_key: %s\n" , + given_cephx_key); + goto fail; + } + } + rados_ret =rados_connect (rbd->cluster);if (rados_ret <0 ) {eprintf("bs_rbd_init: rados_connect: %d\n", rados_ret);usr/bs_rbd.c +4
-0@@ -595,6 +655,10 @@ fail:free (confname);if (clientid)free (clientid); +if (virsecretuuid) +free (virsecretuuid); +if (given_cephx_key) +free (given_cephx_key);return ret; }Signature · 21 lines
1.7.10.4 I also checked, and I didn't have any problem applying the patch to the current master branch: ssullivan@data ~/syseng/packages/tgt $ git apply --stat ../rpmbuild/SOURCES/tgt-add_virsecretuuid_cephx_key_to_bsopts.patch usr/bs_rbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) ssullivan@data ~/syseng/packages/tgt $ git apply --check ../rpmbuild/SOURCES/tgt-add_virsecretuuid_cephx_key_to_bsopts.patch ssullivan@data ~/syseng/packages/tgt $ git am --signoff < ../rpmbuild/SOURCES/tgt-add_virsecretuuid_cephx_key_to_bsopts.patch Applying: bsopts: Add virsecretuuid && cephx_key ssullivan@data ~/syseng/packages/tgt $ -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · On Fri, 25 Jul 2014 23:38:30 +0900 (JST) FUJITA Tomonori…
Hmm,
Still corrupted. Looks like the tabs are converted to spaces.
I don't know what mailer you use but the following might be useful:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/email-clients.txt
Strange, I was able to apply a patch at debian.net. Thanks a lot.
Quoted 11 lines · FUJITA Tomonori
Quoted 7 lines · On Fri, 25 Jul 2014 23:38:30 +0900 (JST) FUJITA Tomonori…
Hmm,
Still corrupted. Looks like the tabs are converted to spaces.
I don't know what mailer you use but the following might be useful:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/email-clients.txt
Strange, I was able to apply a patch at debian.net. Thanks a lot.
Yeah, I think thunderbird was mangling it sorry about that.
Quoted 6 lines · Scott Sullivan
Quoted 5 lines · FUJITA Tomonori
Quoted 2 lines · On Fri, 25 Jul 2014 23:38:30 +0900 (JST) FUJITA Tomonori…
Hmm,
Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
Still corrupted. Looks like the tabs are converted to spaces.
I don't know what mailer you use but the following might be useful:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/email-clients.txt
Strange, I was able to apply a patch at debian.net. Thanks a lot.
Yeah, I think thunderbird was mangling it sorry about that.
I'm so sorry about not reviewing this yet; it just fell off my plate. Looking now.