CEPH filesystem development
 help / color / mirror / Atom feed
From: Osier Yang <jyang@redhat.com>
To: Sage Weil <sage@newdream.net>
Cc: libvir-list@redhat.com, ceph-devel@vger.kernel.org
Subject: Re: [libvirt] [PATCH 1/5] secret: add Ceph secret type
Date: Fri, 16 Sep 2011 16:18:14 +0800	[thread overview]
Message-ID: <4E730646.5080906@redhat.com> (raw)
In-Reply-To: <1316119944-25201-2-git-send-email-sage@newdream.net>

于 2011年09月16日 04:52, Sage Weil 写道:
> Add a new secret type to store a Ceph authentication key.  The ceph_id
> field contains the name of the key (e.g. 'admin' for the ceph superuser).
>
> Signed-off-by: Sage Weil<sage@newdream.net>
> ---
>   include/libvirt/libvirt.h.in |    3 ++
>   src/conf/secret_conf.c       |   45 +++++++++++++++++++++++++++++++++++++++++-
>   src/conf/secret_conf.h       |    1 +
>   src/secret/secret_driver.c   |    8 +++++++
>   4 files changed, 56 insertions(+), 1 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index b1bda31..51fd044 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -2257,7 +2257,10 @@ typedef virSecret *virSecretPtr;
>   typedef enum {
>       VIR_SECRET_USAGE_TYPE_NONE = 0,
>       VIR_SECRET_USAGE_TYPE_VOLUME = 1,
> +    VIR_SECRET_USAGE_TYPE_CEPH = 2,
>       /* Expect more owner types later... */
> +
> +    VIR_SECRET_USAGE_TYPE_LAST
>   } virSecretUsageType;
>
>   virConnectPtr           virSecretGetConnect     (virSecretPtr secret);
> diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
> index 105afbe..8f11a51 100644
> --- a/src/conf/secret_conf.c
> +++ b/src/conf/secret_conf.c
> @@ -35,7 +35,8 @@
>
>   #define VIR_FROM_THIS VIR_FROM_SECRET
>
> -VIR_ENUM_IMPL(virSecretUsageType, VIR_SECRET_USAGE_TYPE_VOLUME + 1, "none", "volume")
> +VIR_ENUM_IMPL(virSecretUsageType, VIR_SECRET_USAGE_TYPE_LAST,
> +              "none", "volume", "ceph")
>
>   void
>   virSecretDefFree(virSecretDefPtr def)
> @@ -52,6 +53,10 @@ virSecretDefFree(virSecretDefPtr def)
>           VIR_FREE(def->usage.volume);
>           break;
>
> +    case VIR_SECRET_USAGE_TYPE_CEPH:
> +        VIR_FREE(def->usage.authIdDomain);
> +        break;
> +
>       default:
>           VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type);
>           break;
> @@ -65,6 +70,8 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
>   {
>       char *type_str;
>       int type;
> +    char *authId, *authDomain;
> +    int ret;
>
>       type_str = virXPathString("string(./usage/@type)", ctxt);
>       if (type_str == NULL) {
> @@ -94,6 +101,27 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
>           }
>           break;
>
> +    case VIR_SECRET_USAGE_TYPE_CEPH:
> +        authId = virXPathString("string(./usage/auth/@id)", ctxt);
> +        if (!authId) {
> +            virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                                 _("ceph usage specified, but auth id is missing"));
> +            return -1;
> +        }
> +        authDomain = virXPathString("string(./usage/auth/@domain)", ctxt);
> +        if (!authDomain) {
> +            VIR_FREE(authId);
> +            virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                                 _("ceph usage specified, but auth domain is missing"));
> +            return -1;
> +        }
> +        ret = virAlloc(&def->usage.authIdDomain, strlen(authId) +
> +                       strlen(authDomain) + 2);

Should use VIR_ALLOC/VIR_ALLOC_N here.

> +        sprintf(def->usage.authIdDomain, "%s/%s", authId, authDomain);
> +        VIR_FREE(authId);
> +        VIR_FREE(authDomain);
> +        break;
> +
>       default:
>           virSecretReportError(VIR_ERR_INTERNAL_ERROR,
>                                _("unexpected secret usage type %d"),
> @@ -220,6 +248,9 @@ virSecretDefFormatUsage(virBufferPtr buf,
>                           const virSecretDefPtr def)
>   {
>       const char *type;
> +    char *p;
> +    char idAuth[80];
> +    int len;
>
>       type = virSecretUsageTypeTypeToString(def->usage_type);
>       if (type == NULL) {
> @@ -239,6 +270,18 @@ virSecretDefFormatUsage(virBufferPtr buf,
>                                     def->usage.volume);
>           break;
>
> +    case VIR_SECRET_USAGE_TYPE_CEPH:
> +        if (def->usage.authIdDomain != NULL) {
> +            p = strchr(def->usage.authIdDomain, '/');
> +            len = p - def->usage.authIdDomain;
> +            strncpy(idAuth, def->usage.authIdDomain, len);
> +            idAuth[len] = '\0';
> +            p++;
> +            virBufferEscapeString(buf, "<auth id='%s'", idAuth);
> +            virBufferEscapeString(buf, " domain='%s'/>\n", p);
> +        }
> +        break;
> +
>       default:
>           virSecretReportError(VIR_ERR_INTERNAL_ERROR,
>                                _("unexpected secret usage type %d"),
> diff --git a/src/conf/secret_conf.h b/src/conf/secret_conf.h
> index 4b47c52..294e7ab 100644
> --- a/src/conf/secret_conf.h
> +++ b/src/conf/secret_conf.h
> @@ -42,6 +42,7 @@ struct _virSecretDef {
>       int usage_type;
>       union {
>           char *volume;               /* May be NULL */
> +        char *authIdDomain;
>       } usage;
>   };
>
> diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
> index 59dc687..7ea8a49 100644
> --- a/src/secret/secret_driver.c
> +++ b/src/secret/secret_driver.c
> @@ -144,6 +144,11 @@ secretFindByUsage(virSecretDriverStatePtr driver, int usageType, const char *usa
>               if (STREQ(s->def->usage.volume, usageID))
>                   return s;
>               break;
> +
> +        case VIR_SECRET_USAGE_TYPE_CEPH:
> +            if (STREQ(s->def->usage.authIdDomain, usageID))
> +                return s;
> +            break;
>           }
>       }
>       return NULL;
> @@ -607,6 +612,9 @@ secretUsageIDForDef(virSecretDefPtr def)
>       case VIR_SECRET_USAGE_TYPE_VOLUME:
>           return def->usage.volume;
>
> +    case VIR_SECRET_USAGE_TYPE_CEPH:
> +        return def->usage.authIdDomain;
> +
>       default:
>           return NULL;
>       }

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-09-16  8:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-15 20:52 [PATCH 0/5] Improve Ceph Qemu+RBD support Sage Weil
2011-09-15 20:52 ` [PATCH 1/5] secret: add Ceph secret type Sage Weil
2011-09-16  8:18   ` Osier Yang [this message]
2011-09-15 20:52 ` [PATCH 2/5] storage: add authId, authDomain to virDomainDiskDef Sage Weil
2011-09-15 20:52 ` [PATCH 3/5] qemu: pass virConnectPtr into Domain{Attach,Detach}* Sage Weil
2011-09-15 20:52 ` [PATCH 4/5] buf: implement generic virBufferEscape Sage Weil
2011-09-15 20:52 ` [PATCH 5/5] qemu/rbd: improve rbd device specification Sage Weil
2011-09-16 16:52   ` Tommi Virtanen
2011-09-16 17:01     ` Sage Weil
2011-09-16 17:11       ` Tommi Virtanen
  -- strict thread matches above, loose matches on Subject: below --
2011-09-20  4:13 [PATCH 0/5 v2] Improve Ceph Qemu+RBD support Sage Weil
2011-09-20  4:13 ` [PATCH 1/5] secret: add Ceph secret type Sage Weil
2011-10-12 16:36   ` [libvirt] " Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E730646.5080906@redhat.com \
    --to=jyang@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=libvir-list@redhat.com \
    --cc=sage@newdream.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox