xref: /spdk/module/event/subsystems/nbd/nbd.c (revision a6dbe3721eb3b5990707fc3e378c95e505dd8ab5)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (C) 2017 Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 #include "spdk/stdinc.h"
7 
8 #include "spdk/nbd.h"
9 
10 #include "spdk_internal/init.h"
11 
12 static void
nbd_subsystem_init(void)13 nbd_subsystem_init(void)
14 {
15 	int rc;
16 
17 	rc = spdk_nbd_init();
18 
19 	spdk_subsystem_init_next(rc);
20 }
21 
22 static void
nbd_subsystem_fini_done(void * arg)23 nbd_subsystem_fini_done(void *arg)
24 {
25 	spdk_subsystem_fini_next();
26 }
27 
28 static void
nbd_subsystem_fini(void)29 nbd_subsystem_fini(void)
30 {
31 	spdk_nbd_fini(nbd_subsystem_fini_done, NULL);
32 }
33 
34 static void
nbd_subsystem_write_config_json(struct spdk_json_write_ctx * w)35 nbd_subsystem_write_config_json(struct spdk_json_write_ctx *w)
36 {
37 	spdk_nbd_write_config_json(w);
38 }
39 
40 static struct spdk_subsystem g_spdk_subsystem_nbd = {
41 	.name = "nbd",
42 	.init = nbd_subsystem_init,
43 	.fini = nbd_subsystem_fini,
44 	.write_config_json = nbd_subsystem_write_config_json,
45 };
46 
47 SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_nbd);
48 SPDK_SUBSYSTEM_DEPEND(nbd, bdev)
49