|
42 | 42 |
|
43 | 43 | #include "common.h" |
44 | 44 | #include "nvme.h" |
45 | | -#include "nbft.h" |
46 | 45 | #include "nvme-print.h" |
47 | 46 | #include "fabrics.h" |
48 | 47 | #include "util/cleanup.h" |
@@ -342,6 +341,32 @@ static bool nvmf_decide_retry(struct nvmf_discovery_ctx *dctx, int err, |
342 | 341 | return false; |
343 | 342 | } |
344 | 343 |
|
| 344 | +static void nvmf_connected(struct nvmf_discovery_ctx *dctx, |
| 345 | + struct nvme_ctrl *c, void *user_data) |
| 346 | +{ |
| 347 | + struct cb_discovery_log_data *dld = user_data; |
| 348 | + |
| 349 | + if (dld->flags == NORMAL) { |
| 350 | + printf("device: %s\n", nvme_ctrl_get_name(c)); |
| 351 | + return; |
| 352 | + } |
| 353 | + |
| 354 | +#ifdef CONFIG_JSONC |
| 355 | + if (dld->flags == JSON) { |
| 356 | + struct json_object *root; |
| 357 | + |
| 358 | + root = json_create_object(); |
| 359 | + |
| 360 | + json_object_add_value_string(root, "device", |
| 361 | + nvme_ctrl_get_name(c)); |
| 362 | + |
| 363 | + json_print_object(root, NULL); |
| 364 | + printf("\n"); |
| 365 | + json_free_object(root); |
| 366 | + } |
| 367 | +#endif |
| 368 | +} |
| 369 | + |
345 | 370 | static int create_discovery_log_ctx(struct nvme_global_ctx *ctx, |
346 | 371 | bool persistent, |
347 | 372 | struct nvme_fabrics_config *defcfg, |
@@ -374,6 +399,10 @@ static int create_discovery_log_ctx(struct nvme_global_ctx *ctx, |
374 | 399 | if (err) |
375 | 400 | goto err; |
376 | 401 |
|
| 402 | + err = nvmf_discovery_ctx_connected_set(dctx, nvmf_connected); |
| 403 | + if (err) |
| 404 | + goto err; |
| 405 | + |
377 | 406 | err = nvmf_discovery_ctx_persistent_set(dctx, persistent); |
378 | 407 | if (err) |
379 | 408 | goto err; |
@@ -544,6 +573,8 @@ static int nvme_read_config_checked(struct nvme_global_ctx *ctx, |
544 | 573 | return nvme_read_config(ctx, filename); |
545 | 574 | } |
546 | 575 |
|
| 576 | +#define NBFT_SYSFS_PATH "/sys/firmware/acpi/tables" |
| 577 | + |
547 | 578 | /* returns negative errno values */ |
548 | 579 | int nvmf_discover(const char *desc, int argc, char **argv, bool connect) |
549 | 580 | { |
@@ -654,12 +685,10 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) |
654 | 685 | return ret; |
655 | 686 |
|
656 | 687 | if (!device && !transport && !traddr) { |
657 | | - nvmf_discovery_ctx_persistent_set(dctx, true); |
658 | | - |
659 | 688 | if (!nonbft) |
660 | | - ret = discover_from_nbft(ctx, hostnqn, hostid, |
661 | | - hnqn, hid, desc, connect, |
662 | | - &cfg, nbft_path, flags, verbose); |
| 689 | + ret = nvmf_discovery_nbft(ctx, dctx, hostnqn, hostid, |
| 690 | + hnqn, hid, connect, |
| 691 | + &cfg, nbft_path); |
663 | 692 | if (nbft) |
664 | 693 | goto out_free; |
665 | 694 |
|
|
0 commit comments