Commit c0b94f66 authored by Sebastien Gougeaud's avatar Sebastien Gougeaud Committed by Thomas Leibovici
Browse files

refactor: unify resource structures of protobuf headers



Following the previous refactoring patches, now uniformizing the
protocol data structures: from PhoDeviceType to PhoResourceFamily
and from PhoMediumInfo to PhoResourceId.

Change-Id: Iba644d8f2d350db773eb67038e49323a1682ca74
Signed-off-by: default avatarSebastien Gougeaud <sebastien.gougeaud@cea.fr>
Reviewed-on: https://cws-fleury.labs.ocre.cea.fr/gerrit/6546


Reviewed-by: Linter
Reviewed-by: default avatarQuentin Bouget <quentin.bouget@cea.fr>
Tested-by: default avatarJenkins s8open_nr <s8open_nr@ccc.ocre.cea.fr>
Reviewed-by: default avatarThomas Leibovici <thomas.leibovici@cea.fr>
parent 342ad2e5
......@@ -156,7 +156,7 @@ static int _admin_notify(struct admin_handle *adm, enum rsc_family family,
req.id = rid;
req.notify->op = op;
req.notify->rsrc_id->type = family;
req.notify->rsrc_id->family = family;
req.notify->rsrc_id->name = strdup(name);
rc = _send_and_receive(adm, &req, &resp);
......@@ -165,7 +165,7 @@ static int _admin_notify(struct admin_handle *adm, enum rsc_family family,
if (pho_response_is_notify(resp)) {
if (resp->req_id == rid &&
(int) family == (int) resp->notify->rsrc_id->type &&
(int) family == (int) resp->notify->rsrc_id->family &&
!strcmp(resp->notify->rsrc_id->name, name)) {
pho_debug("Notify request succeeded");
goto out;
......@@ -221,8 +221,8 @@ int phobos_admin_format(struct admin_handle *adm, const struct pho_id *id,
req.id = rid;
req.format->fs = fs;
req.format->unlock = unlock;
req.format->med_id->type = id->family;
req.format->med_id->id = strdup(id->name);
req.format->med_id->family = id->family;
req.format->med_id->name = strdup(id->name);
rc = _send_and_receive(adm, &req, &resp);
if (rc)
......@@ -230,8 +230,8 @@ int phobos_admin_format(struct admin_handle *adm, const struct pho_id *id,
if (pho_response_is_format(resp)) {
if (resp->req_id == rid &&
(int)resp->format->med_id->type == (int)id->family &&
!strcmp(resp->format->med_id->id, id->name)) {
(int)resp->format->med_id->family == (int)id->family &&
!strcmp(resp->format->med_id->name, id->name)) {
pho_debug("Format request succeeded");
goto out;
}
......
......@@ -2,7 +2,7 @@
* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/*
* All rights reserved (c) 2014-2019 CEA/DAM.
* All rights reserved (c) 2014-2020 CEA/DAM.
*
* This file is part of Phobos.
*
......@@ -34,23 +34,23 @@
/* Typedefs *******************************************************************/
/******************************************************************************/
typedef PhoMediumInfo pho_med_info_t;
typedef PhoResourceId pho_rsc_id_t;
/******************************************************************************/
/* Convenient functions *******************************************************/
/******************************************************************************/
/**
* Copy content of \a model in \a dest medium info
* Copy content of \a model in \a dest resource ID
*
* \param[out] dest Medium info to set conforming to \provided model
* \param[in] model Medium info to copy
* \param[out] dest Resource ID to set conforming to \provided model
* \param[in] model Resource ID to copy
*/
static inline void med_info_cpy(pho_med_info_t *dest,
const pho_med_info_t *model)
static inline void rsc_id_cpy(pho_rsc_id_t *dest,
const pho_rsc_id_t *model)
{
dest->type = model->type;
dest->id = strdup(model->id);
dest->family = model->family;
dest->name = strdup(model->name);
}
#endif /* _PHO_SRL_COMMON_H */
......@@ -289,8 +289,8 @@ static void set_extent_info(struct extent *extent,
{
extent->layout_idx = layout_idx;
extent->size = extent_size;
extent->media.family = medium->med_id->type;
pho_id_name_set(&extent->media, medium->med_id->id);
extent->media.family = medium->med_id->family;
pho_id_name_set(&extent->media, medium->med_id->name);
extent->addr_type = medium->addr_type;
}
......@@ -646,8 +646,7 @@ static int simple_dec_read_chunk(struct pho_encoder *dec,
"layout_idx %d",
extent_index, candidate_extent->layout_idx);
assert(candidate_extent->layout_idx == extent_index);
if (strcmp(medium->med_id->id, candidate_extent->media.name) == 0) {
if (strcmp(medium->med_id->name, candidate_extent->media.name) == 0) {
extent = candidate_extent;
break;
}
......@@ -748,9 +747,9 @@ static int raid1_enc_handle_release_resp(struct pho_encoder *enc,
for (i = 0; i < rel_resp->n_med_ids; i++) {
int rc2;
pho_debug("Marking medium %s as released", rel_resp->med_ids[i]->id);
pho_debug("Marking medium %s as released", rel_resp->med_ids[i]->name);
/* If the media_id is unexpected, -EINVAL will be returned */
rc2 = mark_written_medium_released(raid1, rel_resp->med_ids[i]->id);
rc2 = mark_written_medium_released(raid1, rel_resp->med_ids[i]->name);
if (rc2 && !rc)
rc = rc2;
}
......@@ -833,9 +832,9 @@ static int raid1_dec_next_read_req(struct pho_encoder *dec, pho_req_t *req)
pho_debug("Requesting medium %s to read copy %d of extent %d",
dec->layout->extents[ext_idx].media.name,
i, raid1->cur_extent_idx);
req->ralloc->med_ids[i]->type =
req->ralloc->med_ids[i]->family =
dec->layout->extents[ext_idx].media.family;
req->ralloc->med_ids[i]->id =
req->ralloc->med_ids[i]->name =
strdup(dec->layout->extents[ext_idx].media.name);
}
......@@ -878,8 +877,8 @@ static int raid1_enc_handle_resp(struct pho_encoder *enc, pho_resp_t *resp,
return rc;
for (i = 0; i < resp->walloc->n_media; ++i)
med_info_cpy((*reqs)[*n_reqs].release->media[i]->med_id,
resp->walloc->media[i]->med_id);
rsc_id_cpy((*reqs)[*n_reqs].release->media[i]->med_id,
resp->walloc->media[i]->med_id);
/* Perform IO and populate release request with the outcome */
if (raid1->repl_count == 1) {
......@@ -907,8 +906,8 @@ static int raid1_enc_handle_resp(struct pho_encoder *enc, pho_resp_t *resp,
return rc;
/* copy medium id from allocation response to release request */
med_info_cpy((*reqs)[*n_reqs].release->media[0]->med_id,
resp->ralloc->media[0]->med_id);
rsc_id_cpy((*reqs)[*n_reqs].release->media[0]->med_id,
resp->ralloc->media[0]->med_id);
/* Perform IO and populate release request with the outcome */
rc = simple_dec_read_chunk(enc, resp->ralloc->media[0]);
......
......@@ -34,6 +34,7 @@
#include "pho_common.h"
#include "pho_io.h"
#include "pho_layout.h"
#include "pho_srl_common.h"
#include "pho_type_utils.h"
#define PLUGIN_NAME "simple"
......@@ -168,8 +169,8 @@ static int simple_enc_write_chunk(struct pho_encoder *enc,
* returned by ioa_put as of yet)
*/
extent->size = min(simple->to_write, medium->avail_size);
extent->media.family = medium->med_id->type;
pho_id_name_set(&extent->media, medium->med_id->id);
extent->media.family = medium->med_id->family;
pho_id_name_set(&extent->media, medium->med_id->name);
extent->addr_type = medium->addr_type;
/* and extent.address will be filled by ioa_put */
......@@ -329,9 +330,9 @@ static int simple_enc_handle_release_resp(struct pho_encoder *enc,
for (i = 0; i < rel_resp->n_med_ids; i++) {
int rc2;
pho_debug("Marking medium %s as released", rel_resp->med_ids[i]->id);
pho_debug("Marking medium %s as released", rel_resp->med_ids[i]->name);
/* If the media_id is unexpected, -EINVAL will be returned */
rc2 = mark_written_media_released(simple, rel_resp->med_ids[i]->id);
rc2 = mark_written_media_released(simple, rel_resp->med_ids[i]->name);
if (rc2 && !rc)
rc = rc2;
}
......@@ -395,9 +396,9 @@ static int simple_dec_next_read_req(struct pho_encoder *dec, pho_req_t *req)
req->ralloc->n_required = 1;
req->ralloc->med_ids[0]->type =
req->ralloc->med_ids[0]->family =
dec->layout->extents[cur_ext_idx].media.family;
req->ralloc->med_ids[0]->id =
req->ralloc->med_ids[0]->name =
strdup(dec->layout->extents[cur_ext_idx].media.name);
return 0;
......@@ -435,12 +436,9 @@ static int simple_enc_handle_resp(struct pho_encoder *enc, pho_resp_t *resp,
if (rc)
return rc;
for (i = 0; i < resp->walloc->n_media; ++i) {
(*reqs)[*n_reqs].release->media[i]->med_id->type =
resp->walloc->media[i]->med_id->type;
(*reqs)[*n_reqs].release->media[i]->med_id->id =
strdup(resp->walloc->media[i]->med_id->id);
}
for (i = 0; i < resp->walloc->n_media; ++i)
rsc_id_cpy((*reqs)[*n_reqs].release->media[i]->med_id,
resp->walloc->media[i]->med_id);
/* Perform IO and populate release request with the outcome */
rc = simple_enc_write_all_chunks(
......@@ -458,12 +456,9 @@ static int simple_enc_handle_resp(struct pho_encoder *enc, pho_resp_t *resp,
if (rc)
return rc;
for (i = 0; i < resp->ralloc->n_media; ++i) {
(*reqs)[*n_reqs].release->media[i]->med_id->type =
resp->ralloc->media[i]->med_id->type;
(*reqs)[*n_reqs].release->media[i]->med_id->id =
strdup(resp->ralloc->media[i]->med_id->id);
}
for (i = 0; i < resp->ralloc->n_media; ++i)
rsc_id_cpy((*reqs)[*n_reqs].release->media[i]->med_id,
resp->ralloc->media[i]->med_id);
/* Perform IO and populate release request with the outcome */
rc = simple_dec_read_chunk(enc, resp->ralloc->media[0]);
......
......@@ -2344,11 +2344,11 @@ static int sched_handle_medium_release(struct lrs_sched *sched,
struct dev_descr *dev;
/* Find the where the media is loaded */
dev = search_loaded_media(sched, medium->med_id->id);
dev = search_loaded_media(sched, medium->med_id->name);
if (dev == NULL) {
LOG_RETURN(-ENOENT,
"Could not find '%s' mount point, the media is not loaded",
medium->med_id->id);
medium->med_id->name);
}
/* Flush media and update media info in dss */
......@@ -2435,13 +2435,13 @@ static int sched_handle_write_alloc(struct lrs_sched *sched, pho_req_t *req,
/* build response */
wresp->avail_size = devs[i]->dss_media_info->stats.phys_spc_free;
wresp->med_id->type = devs[i]->dss_media_info->rsc.id.family;
wresp->med_id->id = strdup(devs[i]->dss_media_info->rsc.id.name);
wresp->med_id->family = devs[i]->dss_media_info->rsc.id.family;
wresp->med_id->name = strdup(devs[i]->dss_media_info->rsc.id.name);
wresp->root_path = strdup(devs[i]->mnt_path);
wresp->fs_type = devs[i]->dss_media_info->fs.type;
wresp->addr_type = devs[i]->dss_media_info->addr_type;
pho_debug("Allocated media %s for write request", wresp->med_id->id);
pho_debug("Allocated media %s for write request", wresp->med_id->name);
if (wresp->root_path == NULL) {
/*
......@@ -2464,7 +2464,7 @@ out:
struct dev_descr *dev;
pho_resp_write_elt_t *wresp = resp->walloc->media[i];
dev = search_loaded_media(sched, wresp->med_id->id);
dev = search_loaded_media(sched, wresp->med_id->name);
sched_dev_release(sched, dev);
sched_media_release(sched, dev->dss_media_info);
}
......@@ -2515,8 +2515,8 @@ static int sched_handle_read_alloc(struct lrs_sched *sched, pho_req_t *req,
pho_resp_read_elt_t *rresp = resp->ralloc->media[n_selected];
struct pho_id m;
m.family = rreq->med_ids[i]->type;
pho_id_name_set(&m, rreq->med_ids[i]->id);
m.family = rreq->med_ids[i]->family;
pho_id_name_set(&m, rreq->med_ids[i]->name);
rc = sched_read_prepare(sched, &m, &dev);
if (rc)
......@@ -2527,8 +2527,8 @@ static int sched_handle_read_alloc(struct lrs_sched *sched, pho_req_t *req,
rresp->fs_type = dev->dss_media_info->fs.type;
rresp->addr_type = dev->dss_media_info->addr_type;
rresp->root_path = strdup(dev->mnt_path);
rresp->med_id->type = rreq->med_ids[i]->type;
rresp->med_id->id = strdup(rreq->med_ids[i]->id);
rresp->med_id->family = rreq->med_ids[i]->family;
rresp->med_id->name = strdup(rreq->med_ids[i]->name);
if (n_selected == rreq->n_required)
break;
......@@ -2539,7 +2539,7 @@ static int sched_handle_read_alloc(struct lrs_sched *sched, pho_req_t *req,
for (i = 0; i < n_selected; i++) {
pho_resp_read_elt_t *rresp = resp->ralloc->media[i];
dev = search_loaded_media(sched, rresp->med_id->id);
dev = search_loaded_media(sched, rresp->med_id->name);
sched_dev_release(sched, dev);
sched_media_release(sched, dev->dss_media_info);
}
......@@ -2629,8 +2629,8 @@ static int sched_handle_release_reqs(struct lrs_sched *sched,
respl = respc->resp->release;
for (i = 0; i < n_media; ++i) {
respl->med_ids[i]->type = rel->media[i]->med_id->type;
respl->med_ids[i]->id = strdup(rel->media[i]->med_id->id);
respl->med_ids[i]->family = rel->media[i]->med_id->family;
respl->med_ids[i]->name = strdup(rel->media[i]->med_id->name);
}
/* Free incoming request */
......@@ -2653,8 +2653,8 @@ static int sched_handle_format(struct lrs_sched *sched, pho_req_t *req,
if (rc)
return rc;
m.family = freq->med_id->type;
pho_id_name_set(&m, freq->med_id->id);
m.family = freq->med_id->family;
pho_id_name_set(&m, freq->med_id->name);
rc = sched_format(sched, &m, freq->fs, freq->unlock);
if (rc) {
......@@ -2674,8 +2674,8 @@ static int sched_handle_format(struct lrs_sched *sched, pho_req_t *req,
}
} else {
resp->req_id = req->id;
resp->format->med_id->type = freq->med_id->type;
resp->format->med_id->id = strdup(freq->med_id->id);
resp->format->med_id->family = freq->med_id->family;
resp->format->med_id->name = strdup(freq->med_id->name);
}
return rc;
......@@ -2693,7 +2693,8 @@ static int sched_handle_notify(struct lrs_sched *sched, pho_req_t *req,
switch (nreq->op) {
case PHO_NTFY_OP_ADD_DEVICE:
rc = sched_device_add(sched, nreq->rsrc_id->type, nreq->rsrc_id->name);
rc = sched_device_add(sched, nreq->rsrc_id->family,
nreq->rsrc_id->name);
break;
default:
LOG_GOTO(err, rc = -EINVAL, "The requested operation is not "
......@@ -2704,7 +2705,7 @@ static int sched_handle_notify(struct lrs_sched *sched, pho_req_t *req,
goto err;
resp->req_id = req->id;
resp->notify->rsrc_id->type = nreq->rsrc_id->type;
resp->notify->rsrc_id->family = nreq->rsrc_id->family;
resp->notify->rsrc_id->name = strdup(nreq->rsrc_id->name);
return rc;
......
......@@ -2,7 +2,7 @@
* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/*
* All rights reserved (c) 2014-2019 CEA/DAM.
* All rights reserved (c) 2014-2020 CEA/DAM.
*
* This file is part of Phobos.
*
......@@ -23,24 +23,17 @@
* \brief Protobuf file for common structures.
*/
/** Device family. */
enum PhoDeviceType {
DV_DISK = 0; // Disk.
DV_TAPE_DRV = 1; // Tape drive.
DV_DIR = 2; // Directory.
}
/** Medium info. */
message PhoMediumInfo {
required PhoDeviceType type = 1; // Device family type.
required string id = 2; // Medium identifier.
/** Resource family. */
enum PhoResourceFamily {
FM_DISK = 0; // Disk.
FM_TAPE = 1; // Tape.
FM_DIR = 2; // Directory.
}
/** Resource identifier. */
// To replace PhoMediumInfo?
message PhoResourceId {
required PhoDeviceType type = 1; // Family type.
required string name = 2; // Resource name.
required PhoResourceFamily family = 1; // Family type.
required string name = 2; // Resource name.
}
/** Notify operation. */
......
......@@ -2,7 +2,7 @@
* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/*
* All rights reserved (c) 2014-2019 CEA/DAM.
* All rights reserved (c) 2014-2020 CEA/DAM.
*
* This file is part of Phobos.
*
......@@ -46,17 +46,17 @@ message PhoRequest {
* the provided med_ids (n_required <= n_med_ids).
*/
message Read {
required uint32 n_required = 1; // Number of media to actually
required uint32 n_required = 1; // Number of media to actually
// allocate among the ones
// specified in med_ids.
repeated PhoMediumInfo med_ids = 2; // IDs of the requested media.
repeated PhoResourceId med_ids = 2; // IDs of the requested media.
}
/** Body of the release request. */
message Release {
/** Release request for one medium. */
message Elt {
required PhoMediumInfo med_id = 1; // ID of the medium to release.
required PhoResourceId med_id = 1; // ID of the medium to release.
required int32 rc = 2; // Outcome of the performed IO
// (0 or -errno).
required uint64 size_written = 3; // Amount of bytes written
......@@ -70,7 +70,7 @@ message PhoRequest {
/** Body of the format request. */
message Format {
required PhoMediumInfo med_id = 1; // ID of the medium to format.
required PhoResourceId med_id = 1; // ID of the medium to format.
required PhoFsType fs = 2; // Medium file system.
required bool unlock = 3; // True if the medium needs to be
// unlocked after format.
......@@ -98,7 +98,7 @@ message PhoResponse {
message Write {
/** Write allocation response for one medium. */
message Elt {
required PhoMediumInfo med_id = 1; // ID of the allocated
required PhoResourceId med_id = 1; // ID of the allocated
// medium.
required uint64 avail_size = 2; // Size available on this
// medium (potentially less
......@@ -115,7 +115,7 @@ message PhoResponse {
message Read {
/** Read allocation response for one medium. */
message Elt {
required PhoMediumInfo med_id = 1; // ID of the allocated
required PhoResourceId med_id = 1; // ID of the allocated
// medium.
required string root_path = 2; // Mount point.
required PhoFsType fs_type = 3; // Filesystem type.
......@@ -127,12 +127,12 @@ message PhoResponse {
/** Body of the release response. */
message Release {
repeated PhoMediumInfo med_ids = 1; // IDs of released media.
repeated PhoResourceId med_ids = 1; // IDs of released media.
}
/** Body of the format response. */
message Format {
required PhoMediumInfo med_id = 1; // ID of formatted medium.
required PhoResourceId med_id = 1; // ID of formatted medium.
}
/** Body of the notify response. */
......
......@@ -168,7 +168,7 @@ int pho_srl_request_read_alloc(pho_req_t *req, size_t n_media)
req->ralloc->med_ids[i] = malloc(sizeof(*req->ralloc->med_ids[i]));
if (!req->ralloc->med_ids[i])
goto err_media_i;
pho_medium_info__init(req->ralloc->med_ids[i]);
pho_resource_id__init(req->ralloc->med_ids[i]);
}
return 0;
......@@ -212,7 +212,7 @@ int pho_srl_request_release_alloc(pho_req_t *req, size_t n_media)
malloc(sizeof(*req->release->media[i]->med_id));
if (!req->release->media[i]->med_id)
goto err_id;
pho_medium_info__init(req->release->media[i]->med_id);
pho_resource_id__init(req->release->media[i]->med_id);
}
return 0;
......@@ -247,7 +247,7 @@ int pho_srl_request_format_alloc(pho_req_t *req)
req->format->med_id = malloc(sizeof(*req->format->med_id));
if (!req->format->med_id)
goto err_media;
pho_medium_info__init(req->format->med_id);
pho_resource_id__init(req->format->med_id);
return 0;
......@@ -307,7 +307,7 @@ void pho_srl_request_free(pho_req_t *req, bool unpack)
if (req->ralloc) {
for (i = 0; i < req->ralloc->n_med_ids; ++i) {
free(req->ralloc->med_ids[i]->id);
free(req->ralloc->med_ids[i]->name);
free(req->ralloc->med_ids[i]);
}
free(req->ralloc->med_ids);
......@@ -317,7 +317,7 @@ void pho_srl_request_free(pho_req_t *req, bool unpack)
if (req->release) {
for (i = 0; i < req->release->n_media; ++i) {
free(req->release->media[i]->med_id->id);
free(req->release->media[i]->med_id->name);
free(req->release->media[i]->med_id);
free(req->release->media[i]);
}
......@@ -327,7 +327,7 @@ void pho_srl_request_free(pho_req_t *req, bool unpack)
}
if (req->format) {
free(req->format->med_id->id);
free(req->format->med_id->name);
free(req->format->med_id);
free(req->format);
req->format = NULL;
......@@ -367,7 +367,7 @@ int pho_srl_response_write_alloc(pho_resp_t *resp, size_t n_media)
malloc(sizeof(*resp->walloc->media[i]->med_id));
if (!resp->walloc->media[i]->med_id)
goto err_id;
pho_medium_info__init(resp->walloc->media[i]->med_id);
pho_resource_id__init(resp->walloc->media[i]->med_id);
}
return 0;
......@@ -416,7 +416,7 @@ int pho_srl_response_read_alloc(pho_resp_t *resp, size_t n_media)
malloc(sizeof(*resp->ralloc->media[i]->med_id));
if (!resp->ralloc->media[i]->med_id)
goto err_id;
pho_medium_info__init(resp->ralloc->media[i]->med_id);
pho_resource_id__init(resp->ralloc->media[i]->med_id);
}
return 0;
......@@ -459,7 +459,7 @@ int pho_srl_response_release_alloc(pho_resp_t *resp, size_t n_media)
resp->release->med_ids[i] = malloc(sizeof(*resp->release->med_ids[i]));
if (!resp->release->med_ids[i])
goto err_media_i;
pho_medium_info__init(resp->release->med_ids[i]);
pho_resource_id__init(resp->release->med_ids[i]);
}
return 0;
......@@ -490,7 +490,7 @@ int pho_srl_response_format_alloc(pho_resp_t *resp)
resp->format->med_id = malloc(sizeof(*resp->format->med_id));
if (!resp->format->med_id)
goto err_media;
pho_medium_info__init(resp->format->med_id);
pho_resource_id__init(resp->format->med_id);
return 0;
......@@ -549,7 +549,7 @@ void pho_srl_response_free(pho_resp_t *resp, bool unpack)
if (resp->walloc) {
for (i = 0; i < resp->walloc->n_media; ++i) {
free(resp->walloc->media[i]->med_id->id);
free(resp->walloc->media[i]->med_id->name);
free(resp->walloc->media[i]->med_id);
free(resp->walloc->media[i]->root_path);
free(resp->walloc->media[i]);
......@@ -561,7 +561,7 @@ void pho_srl_response_free(pho_resp_t *resp, bool unpack)
if (resp->ralloc) {
for (i = 0; i < resp->ralloc->n_media; ++i) {
free(resp->ralloc->media[i]->med_id->id);
free(resp->ralloc->media[i]->med_id->name);
free(resp->ralloc->media[i]->med_id);
free(resp->ralloc->media[i]->root_path);
free(resp->ralloc->media[i]);
......@@ -573,7 +573,7 @@ void pho_srl_response_free(pho_resp_t *resp, bool unpack)
if (resp->release) {
for (i = 0; i < resp->release->n_med_ids; ++i) {
free(resp->release->med_ids[i]->id);
free(resp->release->med_ids[i]->name);
free(resp->release->med_ids[i]);
}
free(resp->release->med_ids);
......@@ -582,7 +582,7 @@ void pho_srl_response_free(pho_resp_t *resp, bool unpack)
}
if (resp->format) {
free(resp->format->med_id->id);
free(resp->format->med_id->name);
free(resp->format->med_id);
free(resp->format);
resp->format = NULL;
......
......@@ -112,8 +112,8 @@ static int test_bad_get(void *arg)
assert(!pho_srl_request_read_alloc(&req, 1));
req.id = 0;
req.ralloc->n_required = 1;
req.ralloc->med_ids[0]->type = PHO_RSC_INVAL;
req.ralloc->med_ids[0]->id = strdup("/tmp/test.pho.1");
req.ralloc->med_ids[0]->family = PHO_RSC_INVAL;
req.ralloc->med_ids[0]->name = strdup("/tmp/test.pho.1");
assert(!_send_and_receive(ci, &req, &resp));
rc = _check_error(resp, "Get -- bad resource family", -EINVAL);
if (rc)
......@@ -122,9 +122,9 @@ static int test_bad_get(void *arg)
// Bad resource name
pho_srl_response_free(resp, true);
++req.id;
req.ralloc->med_ids[0]->type = PHO_RSC_DIR;
free(req.ralloc->med_ids[0]->id);
req.ralloc->med_ids[0]->id = strdup("/tmp/not/a/med");
req.ralloc->med_ids[0]->family = PHO_RSC_DIR;
free(req.ralloc->med_ids[0]->name);
req.ralloc->med_ids[0]->name = strdup("/tmp/not/a/med");
assert(!_send_and_receive(ci, &req, &resp));
rc = _check_error(resp, "Get -- bad resource name", -ENXIO);
......@@ -145,8 +145,8 @@ static int test_bad_release(void *arg)
// Bad resource name
assert(!pho_srl_request_release_alloc(&req, 1));
req.id = 0;
req.release->media[0]->med_id->type = PHO_RSC_DIR;