#include <ul_logreg.h>
static UL_LOG_CUST(ulogd);
-static ul_log_domain_t ulogd = {UL_LOGL_MSG, "fcb_contract_log"};
+static ul_log_domain_t ulogd = {UL_LOGL_MSG, "contract_log"};
UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_contract_log, ulogd);
void
char str[1000];
fres_contract_to_string2(str, sizeof(str), c, 4, 0);
ul_logdeb("%s #%d:\n%s", prefix, index, str);
-}
+ }
+ else {
+ char res_name[10] = "";
+ frsh_contract_label_t label = "";
+ fres_block_resource *block_res;
+ fres_block_label *block_label;
+ char *p;
+ block_res = fres_contract_get_resource(c);
+ if (block_res)
+ fres_block_to_string(res_name, sizeof(res_name),
+ FRES_BLOCK_RESOURCE, block_res);
+ block_label = fres_contract_get_label(c);
+ if (block_label)
+ strcpy(label, block_label->label);
+
+ for (p=res_name; *p!='\n' && *p!=0; p++);
+ *p = 0;
+
+ ul_logmsg("%s: %s %s\n", prefix, res_name, label);
+ }
}
#endif
UL_LOG_CUST(ulogd_fcb);
-ul_log_domain_t ulogd_fcb = {UL_LOGL_MSG, "fcb"};
+ul_log_domain_t ulogd_fcb = {UL_LOGL_MSG, "main"};
UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_fcb, ulogd_fcb);
fosa_abs_time_t start_time;
for (i=0; i<num; i++) {
struct fres_contract *c = contracts[i];
- log_contract("Received contract", i, c);
-
if (fres_contract_id_is_empty(&c->id)) {
/* Normal negotiation request */
forb_uuid_generate((forb_uuid_t *)&c->id);
if (!get_res_key(c, &key)) {
return FRSH_ERR_RESOURCE_ID_INVALID;
}
+ log_contract("Negotiation request", i, c);
} else {
fc = fcb_contract_find(fcb, &c->id);
if (!fc) {
if (fres_contract_get_num_blocks(c) == 0) {
/* Cancelation */
get_res_key(fc->user_contract, &key);
+ log_contract("Cancelation request", i, fc->user_contract);
} else {
/* Renegotiation */
if (!get_res_key(c, &key)) {
return FRSH_ERR_RESOURCE_ID_INVALID;
}
+ log_contract("Renegotiation request", i, fc->user_contract);
}
}
}
int fres_block_resource_to_string(char *dest, size_t size, enum fres_block_type type,
const void *block_data)
{
+ static const char *res_names[] = {
+ [FRSH_RT_PROCESSOR] = "CPU",
+ [FRSH_RT_NETWORK] = "NET",
+ [FRSH_RT_MEMORY] = "MEM",
+ [FRSH_RT_DISK] = "DISK"
+ };
+
const fres_block_resource *b = block_data;
- return snprintf(dest, size, "%d.%d\n", b->resource_type, b->resource_id);
+ char res[10];
+ const char *r = NULL;
+ if (b->resource_type >= 0 &&
+ b->resource_type < sizeof(res_names)/sizeof(res_names[0]))
+ r = res_names[b->resource_type];
+ if (!r) {
+ snprintf(res, sizeof(res), "%d", b->resource_type);
+ r = res;
+ }
+ return snprintf(dest, size, "%s.%d\n", r, b->resource_id);
}
int fres_block_basic_to_string(char *dest, size_t size, enum fres_block_type type,
return CORBA_FALSE;
}
+int fres_block_to_string(char *dest, size_t size, enum fres_block_type type,
+ const void *block_data)
+{
+ if (block_registry[type]->to_string)
+ return block_registry[type]->to_string(dest, size, type, block_data);
+ else
+ return 0;
+}
+
int
fres_container_to_string(char *dest, size_t size, const struct fres_container *c)
{
case FRES_BLOCK_EMPTY:
/* nothing to do */
break;
- case FRES_BLOCK_DATA:
+ case FRES_BLOCK_DATA: {
+ char tmp[1000];
ret = snprintf(dest, size, "block %s (%d)\n",
block_registry[type]->name, type);
if (ret < 0) goto err;
size -= ret;
dest += ret;
}
- if (block_registry[type]->to_string) {
- char tmp[1000];
- block_registry[type]->to_string(tmp, sizeof(tmp), type, b->u.data);
+ ret = fres_block_to_string(tmp, sizeof(tmp), type, b->u.data);
+ if (ret > 0) {
ret = fres_indent_str(dest, size, tmp, 2);
written += ret;
size -= ret;
dest += ret;
}
break;
+ }
case FRES_BLOCK_STREAM:
ret = snprintf(dest, size, "unknown block (%d)\n",
type);
fres_container_get_block(const struct fres_container *container,
enum fres_block_type type);
+int fres_block_to_string(char *dest, size_t size, enum fres_block_type type,
+ const void *block_data);
+
/**
* Macro which defines type-safe container "accessor" functions for
* various blocks.