From 536d1f87469fcbb2b9df5b52b2752188cebecf5c Mon Sep 17 00:00:00 2001
From: Sage Weil type
attribute specifies the usage category, currently
- only volume
is defined. Specific usage categories are
- described below.
+ only volume
and ceph
are defined.
+ Specific usage categories are described below.
+ This secret is associated with a Ceph RBD (rados block device).
+ The <usage type='ceph'>
element must contain
+ a single name
element that specifies a usage name
+ for the secret. The Ceph secret can then be used by UUID or by
+ this usage name via the <auth>
element of
+ a disk
+ device. Since 0.9.7.
+
diff --git a/docs/schemas/secret.rng b/docs/schemas/secret.rng index 80270aef87..8e7714b92f 100644 --- a/docs/schemas/secret.rng +++ b/docs/schemas/secret.rng @@ -37,6 +37,7 @@@@ -54,6 +55,15 @@ + + + ++ +ceph ++ ++ diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index c51c7c5a6a..92a14a8492 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -2381,7 +2381,14 @@ typedef virSecret *virSecretPtr; typedef enum { VIR_SECRET_USAGE_TYPE_NONE = 0, VIR_SECRET_USAGE_TYPE_VOLUME = 1, - /* Expect more owner types later... */ + VIR_SECRET_USAGE_TYPE_CEPH = 2, + + /* + * NB: this enum value will increase over time as new events are + * added to the libvirt API. It reflects the last secret owner ID + * supported by this version of the libvirt API. + */ + 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 b33ce98f70..fa808888d0 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,9 @@ virSecretDefFree(virSecretDefPtr def) VIR_FREE(def->usage.volume); break; + case VIR_SECRET_USAGE_TYPE_CEPH: + VIR_FREE(def->usage.ceph); + default: VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type); break; @@ -94,6 +98,15 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt, } break; + case VIR_SECRET_USAGE_TYPE_CEPH: + def->usage.ceph = virXPathString("string(./usage/name)", ctxt); + if (!def->usage.ceph) { + virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Ceph usage specified, but name is missing")); + return -1; + } + break; + default: virSecretReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected secret usage type %d"), @@ -239,6 +252,13 @@ virSecretDefFormatUsage(virBufferPtr buf, def->usage.volume); break; + case VIR_SECRET_USAGE_TYPE_CEPH: + if (def->usage.ceph != NULL) { + virBufferEscapeString(buf, " %s \n", + def->usage.ceph); + } + 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 4b47c527df..b5d72d4d93 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 *ceph; } usage; }; diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 59dc687d2e..088a2431cb 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.ceph, 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.ceph; + default: return NULL; } -- 2.39.5