LCOV - code coverage report
Current view: top level - lib/vfu_tgt - tgt_rpc.c (source / functions) Hit Total Coverage
Test: ut_cov_unit.info Lines: 0 19 0.0 %
Date: 2024-12-13 04:08:15 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*   SPDX-License-Identifier: BSD-3-Clause
       2             :  *   Copyright (C) 2022 Intel Corporation.
       3             :  *   All rights reserved.
       4             :  */
       5             : 
       6             : #include "spdk/bdev.h"
       7             : #include "spdk/log.h"
       8             : #include "spdk/rpc.h"
       9             : #include "spdk/env.h"
      10             : #include "spdk/string.h"
      11             : #include "spdk/util.h"
      12             : #include "spdk/thread.h"
      13             : 
      14             : #include "tgt_internal.h"
      15             : 
      16             : struct rpc_set_vfu_path {
      17             :         char            *path;
      18             : };
      19             : 
      20             : static const struct spdk_json_object_decoder rpc_set_vfu_path_decode[] = {
      21             :         {"path", offsetof(struct rpc_set_vfu_path, path), spdk_json_decode_string }
      22             : };
      23             : 
      24             : static void
      25           0 : free_rpc_set_vfu_path(struct rpc_set_vfu_path *req)
      26             : {
      27           0 :         free(req->path);
      28           0 : }
      29             : 
      30             : static void
      31           0 : rpc_vfu_set_base_path(struct spdk_jsonrpc_request *request,
      32             :                       const struct spdk_json_val *params)
      33             : {
      34           0 :         struct rpc_set_vfu_path req = {0};
      35             :         int rc;
      36             : 
      37           0 :         if (spdk_json_decode_object(params, rpc_set_vfu_path_decode,
      38             :                                     SPDK_COUNTOF(rpc_set_vfu_path_decode),
      39             :                                     &req)) {
      40           0 :                 SPDK_ERRLOG("spdk_json_decode_object failed\n");
      41           0 :                 rc = -EINVAL;
      42           0 :                 goto invalid;
      43             :         }
      44             : 
      45           0 :         rc = spdk_vfu_set_socket_path(req.path);
      46           0 :         if (rc < 0) {
      47           0 :                 goto invalid;
      48             :         }
      49           0 :         free_rpc_set_vfu_path(&req);
      50             : 
      51           0 :         spdk_jsonrpc_send_bool_response(request, true);
      52           0 :         return;
      53             : 
      54           0 : invalid:
      55           0 :         free_rpc_set_vfu_path(&req);
      56           0 :         spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
      57             :                                          spdk_strerror(-rc));
      58             : }
      59           0 : SPDK_RPC_REGISTER("vfu_tgt_set_base_path", rpc_vfu_set_base_path,
      60             :                   SPDK_RPC_RUNTIME)

Generated by: LCOV version 1.15