Commit aa9fab0c authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

keyring: support for writing config



Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I326512277231f57957a6d6992d62edf692650905
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21740


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 48a04a3f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#define SPDK_KEYRING_H

#include "spdk/stdinc.h"
#include "spdk/json.h"

struct spdk_key;

@@ -82,4 +83,11 @@ struct spdk_keyring;
void spdk_keyring_for_each_key(struct spdk_keyring *keyring, void *ctx,
			       void (*fn)(void *ctx, struct spdk_key *key), uint32_t flags);

/**
 * Write keyring configuration to JSON.
 *
 * \param w JSON write context.
 */
void spdk_keyring_write_config(struct spdk_json_write_ctx *w);

#endif /* SPDK_KEYRING_H */
+11 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ struct spdk_keyring_module {
	int (*init)(void);
	/** Clean up resources allocated by a module.  Called during keyring's cleanup  */
	void (*cleanup)(void);
	/** Write module configuration to JSON */
	void (*write_config)(struct spdk_json_write_ctx *w);
	/** Add a key to the keyring */
	int (*add_key)(struct spdk_key *key, void *ctx);
	/** Remove a key from the keyring */
@@ -86,4 +88,13 @@ static void __attribute__((constructor)) _spdk_keyring_register_##name(void) \
 */
void *spdk_key_get_ctx(struct spdk_key *key);

/**
 * Get keyring module owning the key.
 *
 * \param key Key.
 *
 * \return Key owner.
 */
struct spdk_keyring_module *spdk_key_get_module(struct spdk_key *key);

#endif /* SPDK_KEYRING_H */
+19 −0
Original line number Diff line number Diff line
@@ -217,6 +217,25 @@ spdk_key_get_ctx(struct spdk_key *key)
	return key + 1;
}


struct spdk_keyring_module *
spdk_key_get_module(struct spdk_key *key)
{
	return key->module;
}

void
spdk_keyring_write_config(struct spdk_json_write_ctx *w)
{
	struct spdk_keyring_module *module;

	TAILQ_FOREACH(module, &g_keyring.modules, tailq) {
		if (module->write_config != NULL) {
			module->write_config(w);
		}
	}
}

void
spdk_keyring_for_each_key(struct spdk_keyring *keyring,
			  void *ctx, void (*fn)(void *ctx, struct spdk_key *key), uint32_t flags)
+2 −0
Original line number Diff line number Diff line
@@ -8,9 +8,11 @@
	spdk_keyring_get_key;
	spdk_keyring_put_key;
	spdk_keyring_for_each_key;
	spdk_keyring_write_config;
	spdk_key_get_name;
	spdk_key_get_key;
	spdk_key_get_ctx;
	spdk_key_get_module;

	local: *;
};
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ DEPDIRS-event_vhost_scsi := init vhost event_scheduler event_scsi
DEPDIRS-event_sock := init sock
DEPDIRS-event_vfu_tgt := init vfu_tgt
DEPDIRS-event_iobuf := init log thread util $(JSON_LIBS)
DEPDIRS-event_keyring := init keyring
DEPDIRS-event_keyring := init json keyring

# module/vfu_device

Loading