/* The mutex is special because we can't idempotently destroy it */
if (libxl__init_recursive_mutex(ctx, &ctx->lock) < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Failed to initialize mutex");
+ LOG(ERROR, "Failed to initialize mutex");
free(ctx);
ctx = 0;
rc = ERROR_FAIL;
if (!trans) {
trans = our_trans = xs_transaction_start(ctx->xsh);
if (!our_trans) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno,
- "create xs transaction for domain (re)name");
+ LOGEV(ERROR, errno, "create xs transaction for domain (re)name");
goto x_fail;
}
}
if (!new_name) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "new domain name not specified");
+ LOG(ERROR, "new domain name not specified");
rc = ERROR_INVAL;
goto x_rc;
}
if (rc == ERROR_INVAL) {
/* no such domain, good */
} else if (rc != 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unexpected error"
- "checking for existing domain");
+ LOG(ERROR, "unexpected error""checking for existing domain");
goto x_rc;
} else if (domid_e == domid) {
/* domain already has this name, ok (but we do still
* need the rest of the code as we may need to check
* old_name, for example). */
} else {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "domain with name \"%s\""
- " already exists.", new_name);
+ LOG(ERROR, "domain with name \"%s\""" already exists.", new_name);
rc = ERROR_INVAL;
goto x_rc;
}
if (old_name) {
got_old_name = xs_read(ctx->xsh, trans, name_path, &got_old_len);
if (!got_old_name) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno, "check old name"
- " for domain %"PRIu32" allegedly named `%s'",
- domid, old_name);
+ LOGEV(ERROR, errno,
+ "check old name"" for domain %"PRIu32" allegedly named `%s'",
+ domid,
+ old_name);
goto x_fail;
}
if (strcmp(old_name, got_old_name)) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "domain %"PRIu32" allegedly named "
- "`%s' is actually named `%s' - racing ?",
- domid, old_name, got_old_name);
+ LOG(ERROR,
+ "domain %"PRIu32" allegedly named ""`%s' is actually named `%s' - racing ?",
+ domid,
+ old_name,
+ got_old_name);
free(got_old_name);
goto x_fail;
}
}
if (!xs_write(ctx->xsh, trans, name_path,
new_name, strlen(new_name))) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to write new name `%s'"
- " for domain %"PRIu32" previously named `%s'",
- new_name, domid, old_name);
+ LOG(ERROR,
+ "failed to write new name `%s'"" for domain %"PRIu32" previously named `%s'",
+ new_name,
+ domid,
+ old_name);
goto x_fail;
}
if (!xs_transaction_end(ctx->xsh, our_trans, 0)) {
trans = our_trans = 0;
if (errno != EAGAIN) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to commit new name `%s'"
- " for domain %"PRIu32" previously named `%s'",
- new_name, domid, old_name);
+ LOG(ERROR,
+ "failed to commit new name `%s'"" for domain %"PRIu32" previously named `%s'",
+ new_name,
+ domid,
+ old_name);
goto x_fail;
}
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "need to retry rename transaction"
- " for domain %"PRIu32" (name_path=\"%s\", new_name=\"%s\")",
- domid, name_path, new_name);
+ LOG(DEBUG,
+ "need to retry rename transaction"" for domain %"PRIu32" (name_path=\"%s\", new_name=\"%s\")",
+ domid,
+ name_path,
+ new_name);
goto retry_transaction;
}
our_trans = 0;
int i, ret;
xc_domaininfo_t info[1024];
int size = 1024;
+ GC_INIT(ctx);
ptr = calloc(size, sizeof(libxl_dominfo));
if (!ptr) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "allocating domain info");
+ LOGE(ERROR, "allocating domain info");
+ GC_FREE;
return NULL;
}
ret = xc_domain_getinfolist(ctx->xch, 0, 1024, info);
if (ret<0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+ LOGE(ERROR, "getting domain info list");
free(ptr);
+ GC_FREE;
return NULL;
}
xcinfo2xlinfo(ctx, &info[i], &ptr[i]);
}
*nb_domain_out = ret;
+ GC_FREE;
return ptr;
}
uint32_t domid) {
xc_domaininfo_t xcinfo;
int ret;
+ GC_INIT(ctx);
ret = xc_domain_getinfolist(ctx->xch, domid, 1, &xcinfo);
if (ret<0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+ LOGE(ERROR, "getting domain info list");
+ GC_FREE;
return ERROR_FAIL;
}
- if (ret==0 || xcinfo.domain != domid) return ERROR_DOMAIN_NOTFOUND;
+ if (ret==0 || xcinfo.domain != domid) {
+ GC_FREE;
+ return ERROR_DOMAIN_NOTFOUND;
+ }
if (info_r)
xcinfo2xlinfo(ctx, &xcinfo, info_r);
+ GC_FREE;
return 0;
}
ret = xc_domain_getinfolist(ctx->xch, 1, ARRAY_SIZE(info), info);
if (ret < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+ LOGE(ERROR, "getting domain info list");
goto out;
}
int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid)
{
int ret;
+ GC_INIT(ctx);
ret = xc_domain_pause(ctx->xch, domid);
if (ret<0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "pausing domain %d", domid);
+ LOGE(ERROR, "pausing domain %d", domid);
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return 0;
}
ret = xc_domain_dumpcore(ctx->xch, domid, filename);
if (ret<0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "core dumping domain %d to %s",
- domid, filename);
+ LOGE(ERROR, "core dumping domain %d to %s", domid, filename);
rc = ERROR_FAIL;
goto out;
}
}
ret = xc_domain_unpause(ctx->xch, domid);
if (ret<0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain %d", domid);
+ LOGE(ERROR, "unpausing domain %d", domid);
rc = ERROR_FAIL;
}
out:
ret = xc_hvm_param_get(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver);
if (ret<0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting HVM callback IRQ");
+ LOGE(ERROR, "getting HVM callback IRQ");
return ERROR_FAIL;
}
return !!pvdriver;
EGC_GC;
libxl_evgen_domain_death *const evg = *evg_upd;
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "%s", why);
+ LOG(DEBUG, "%s", why);
libxl_evgen_domain_death *evg_next = LIBXL_TAILQ_NEXT(evg, entry);
*evg_upd = evg_next;
for (;;) {
if (!evg) {
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "[evg=0] all reported");
+ LOG(DEBUG, "[evg=0] all reported");
goto all_reported;
}
}
if (got == gotend) {
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, " got==gotend");
+ LOG(DEBUG, " got==gotend");
break;
}
}
assert(evg->domid == got->domain);
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, " exists shutdown_reported=%d"
- " dominf.flags=%x",
- evg->shutdown_reported, got->flags);
+ LOG(DEBUG, " exists shutdown_reported=%d"" dominf.flags=%x",
+ evg->shutdown_reported, got->flags);
if (got->flags & XEN_DOMINF_dying) {
domain_death_occurred(egc, &evg, "dying");
libxl_event *ev = NEW_EVENT(egc, DOMAIN_SHUTDOWN,
got->domain, evg->user);
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, " shutdown reporting");
+ LOG(DEBUG, " shutdown reporting");
ev->u.domain_shutdown.shutdown_reason =
(got->flags >> XEN_DOMINF_shutdownshift) &
all_reported:
out:
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "domain death search done");
+ LOG(DEBUG, "domain death search done");
CTX_UNLOCK;
}
case 0:
break;
case ERROR_DOMAIN_NOTFOUND:
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "non-existant domain %d", domid);
+ LOG(ERROR, "non-existant domain %d", domid);
default:
goto out;
}
}
if (libxl__device_pci_destroy_all(gc, domid) < 0)
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "pci shutdown failed for domid %d", domid);
+ LOG(ERROR, "pci shutdown failed for domid %d", domid);
rc = xc_domain_pause(ctx->xch, domid);
if (rc < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "xc_domain_pause failed for %d", domid);
+ LOGEV(ERROR, rc, "xc_domain_pause failed for %d", domid);
}
if (dm_present) {
if (libxl__destroy_device_model(gc, domid) < 0)
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "libxl__destroy_device_model failed for %d", domid);
+ LOG(ERROR, "libxl__destroy_device_model failed for %d", domid);
libxl__qmp_cleanup(gc, domid);
}
}
if (rc < 0)
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "libxl__devices_destroy failed for %d", domid);
+ LOG(ERROR, "libxl__devices_destroy failed for %d", domid);
vm_path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/vm", dom_path));
if (vm_path)
if (!xs_rm(ctx->xsh, XBT_NULL, vm_path))
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs_rm failed for %s", vm_path);
+ LOGE(ERROR, "xs_rm failed for %s", vm_path);
if (!xs_rm(ctx->xsh, XBT_NULL, dom_path))
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xs_rm failed for %s", dom_path);
+ LOGE(ERROR, "xs_rm failed for %s", dom_path);
xs_rm(ctx->xsh, XBT_NULL, libxl__xs_libxl_path(gc, domid));
xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc,
char tmpname[] = "/tmp/vncautopass.XXXXXX";
autopass_fd = mkstemp(tmpname);
if ( autopass_fd < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "mkstemp %s failed", tmpname);
+ LOGE(ERROR, "mkstemp %s failed", tmpname);
goto x_fail;
}
if ( unlink(tmpname) ) {
/* should never happen */
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "unlink %s failed", tmpname);
+ LOGE(ERROR, "unlink %s failed", tmpname);
goto x_fail;
}
goto x_fail;
if ( lseek(autopass_fd, SEEK_SET, 0) ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "rewind %s (autopass) failed", tmpname);
+ LOGE(ERROR, "rewind %s (autopass) failed", tmpname);
goto x_fail;
}
libxl_device_disk *disk,
libxl__device *device)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
int devid;
devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
if (devid==-1) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
- " virtual disk identifier %s", disk->vdev);
+ LOG(ERROR, "Invalid or unsupported"" virtual disk identifier %s",
+ disk->vdev);
return ERROR_INVAL;
}
device->backend_kind = LIBXL__DEVICE_KIND_QDISK;
break;
default:
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "unrecognized disk backend type: %d", disk->backend);
+ LOG(ERROR, "unrecognized disk backend type: %d", disk->backend);
return ERROR_INVAL;
}
GCNEW(device);
rc = libxl__device_from_disk(gc, domid, disk, device);
if (rc != 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Invalid or unsupported"
- " virtual disk identifier %s", disk->vdev);
+ LOG(ERROR, "Invalid or unsupported"" virtual disk identifier %s",
+ disk->vdev);
goto out;
}
assert(device->backend_kind == LIBXL__DEVICE_KIND_QDISK);
break;
default:
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "unrecognized disk backend type: %d",
- disk->backend);
+ LOG(ERROR, "unrecognized disk backend type: %d",
+ disk->backend);
rc = ERROR_INVAL;
goto out;
}
return disks;
out_err:
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to list disks");
+ LOG(ERROR, "Unable to list disks");
while (disks && *num) {
(*num)--;
libxl_device_disk_dispose(&disks[*num]);
}
}
if (i == num) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual device not found");
+ LOG(ERROR, "Virtual device not found");
rc = ERROR_FAIL;
goto out;
}
tmp = libxl__xs_read(gc, t, libxl__sprintf(gc, "%s/frontend", path));
if (!tmp)
{
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Internal error: %s does not exist",
- libxl__sprintf(gc, "%s/frontend", path));
+ LOG(ERROR, "Internal error: %s does not exist",
+ libxl__sprintf(gc, "%s/frontend", path));
rc = ERROR_FAIL;
goto out;
}
tmp = libxl__xs_read(gc, t, libxl__sprintf(gc, "%s/frontend", path));
if (!tmp)
{
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Internal error: %s does not exist",
- libxl__sprintf(gc, "%s/frontend", path));
+ LOG(ERROR, "Internal error: %s does not exist",
+ libxl__sprintf(gc, "%s/frontend", path));
rc = ERROR_FAIL;
goto out;
}
return nics;
out_err:
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to list nics");
+ LOG(ERROR, "Unable to list nics");
while (*num) {
(*num)--;
libxl_device_nic_dispose(&nics[*num]);
mem = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/memory/target", dompath));
if (!mem) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "cannot get memory info from %s/memory/target",
- dompath);
+ LOGE(ERROR, "cannot get memory info from %s/memory/target", dompath);
goto out;
}
memorykb = strtoul(mem, &endptr, 10);
if (*endptr != '\0') {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "invalid memory %s from %s/memory/target\n", mem, dompath);
+ LOGE(ERROR, "invalid memory %s from %s/memory/target\n", mem, dompath);
goto out;
}
if (max_memkb < memorykb) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "memory_static_max must be greater than or or equal to memory_dynamic_max");
+ LOGE(ERROR,
+ "memory_static_max must be greater than or or equal to memory_dynamic_max");
goto out;
}
rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + LIBXL_MAXMEM_CONSTANT);
if (rc != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "xc_domain_setmaxmem domid=%d memkb=%d failed "
- "rc=%d\n", domid, max_memkb + LIBXL_MAXMEM_CONSTANT, rc);
+ LOGE(ERROR, "xc_domain_setmaxmem domid=%d memkb=%d failed ""rc=%d\n",
+ domid, max_memkb + LIBXL_MAXMEM_CONSTANT, rc);
goto out;
}
if (target) {
*target_memkb = strtoul(target, &endptr, 10);
if (*endptr != '\0') {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "invalid memory target %s from %s\n", target, target_path);
+ LOGE(ERROR, "invalid memory target %s from %s\n", target,
+ target_path);
rc = ERROR_FAIL;
goto out;
}
if (staticmax) {
*max_memkb = strtoul(staticmax, &endptr, 10);
if (*endptr != '\0') {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "invalid memory static-max %s from %s\n",
- staticmax, max_path);
+ LOGE(ERROR, "invalid memory static-max %s from %s\n", staticmax,
+ max_path);
rc = ERROR_FAIL;
goto out;
}
goto out_no_transaction;
goto retry_transaction;
} else if (!target) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "cannot get target memory info from %s/memory/target",
- dompath);
+ LOGE(ERROR, "cannot get target memory info from %s/memory/target",
+ dompath);
abort_transaction = 1;
goto out;
} else {
current_target_memkb = strtoul(target, &endptr, 10);
if (*endptr != '\0') {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "invalid memory target %s from %s/memory/target\n",
- target, dompath);
+ LOGE(ERROR, "invalid memory target %s from %s/memory/target\n",
+ target, dompath);
abort_transaction = 1;
goto out;
}
memmax = libxl__xs_read(gc, t, libxl__sprintf(gc,
"%s/memory/static-max", dompath));
if (!memmax) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "cannot get memory info from %s/memory/static-max",
- dompath);
+ LOGE(ERROR, "cannot get memory info from %s/memory/static-max",
+ dompath);
abort_transaction = 1;
goto out;
}
memorykb = strtoul(memmax, &endptr, 10);
if (*endptr != '\0') {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "invalid max memory %s from %s/memory/static-max\n",
- memmax, dompath);
+ LOGE(ERROR, "invalid max memory %s from %s/memory/static-max\n",
+ memmax, dompath);
abort_transaction = 1;
goto out;
}
} else
new_target_memkb = target_memkb - videoram;
if (new_target_memkb > memorykb) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "memory_dynamic_max must be less than or equal to"
- " memory_static_max\n");
+ LOG(ERROR,
+ "memory_dynamic_max must be less than or equal to"" memory_static_max\n");
abort_transaction = 1;
goto out;
}
if (!domid && new_target_memkb < LIBXL_MIN_DOM0_MEM) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "new target %d for dom0 is below the minimum threshold",
- new_target_memkb);
+ LOG(ERROR, "new target %d for dom0 is below the minimum threshold",
+ new_target_memkb);
abort_transaction = 1;
goto out;
}
rc = xc_domain_setmaxmem(ctx->xch, domid, memorykb +
LIBXL_MAXMEM_CONSTANT);
if (rc != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "xc_domain_setmaxmem domid=%u memkb=%"PRIu64" failed "
- "rc=%d\n", domid, memorykb + LIBXL_MAXMEM_CONSTANT, rc);
+ LOGE(ERROR,
+ "xc_domain_setmaxmem domid=%u memkb=%"PRIu64" failed ""rc=%d\n",
+ domid,
+ memorykb + LIBXL_MAXMEM_CONSTANT,
+ rc);
abort_transaction = 1;
goto out;
}
rc = xc_domain_set_pod_target(ctx->xch, domid,
new_target_memkb / 4, NULL, NULL, NULL);
if (rc != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "xc_domain_set_pod_target domid=%d, memkb=%d "
- "failed rc=%d\n", domid, new_target_memkb / 4,
- rc);
+ LOGE(ERROR,
+ "xc_domain_set_pod_target domid=%d, memkb=%d ""failed rc=%d\n",
+ domid,
+ new_target_memkb / 4,
+ rc);
abort_transaction = 1;
goto out;
}
if (rc < 0)
goto out;
} else if (!target) {
- LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR,
- "cannot get target memory info from %s/memory/target",
- dompath);
+ LOGE(ERROR, "cannot get target memory info from %s/memory/target",
+ dompath);
goto out;
} else if (!static_max) {
- LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR,
- "cannot get target memory info from %s/memory/static-max",
- dompath);
+ LOGE(ERROR,
+ "cannot get target memory info from %s/memory/static-max",
+ dompath);
goto out;
} else {
target_memkb = strtoul(target, &endptr, 10);
if (*endptr != '\0') {
- LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR,
- "invalid memory target %s from %s/memory/target\n",
- target, dompath);
+ LOGE(ERROR, "invalid memory target %s from %s/memory/target\n",
+ target, dompath);
goto out;
}
max_memkb = strtoul(static_max, &endptr, 10);
if (*endptr != '\0') {
- LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR,
- "invalid memory target %s from %s/memory/static-max\n",
- static_max, dompath);
+ LOGE(ERROR,
+ "invalid memory target %s from %s/memory/static-max\n",
+ static_max,
+ dompath);
goto out;
}
xc_physinfo_t xcphysinfo = { 0 };
int rc;
long l;
+ GC_INIT(ctx);
rc = xc_physinfo(ctx->xch, &xcphysinfo);
if (rc != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting physinfo");
+ LOGE(ERROR, "getting physinfo");
+ GC_FREE;
return ERROR_FAIL;
}
physinfo->threads_per_core = xcphysinfo.threads_per_core;
if (l < 0 && errno == ENOSYS) {
l = 0;
} else if (l < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
- "getting sharing freed pages");
+ LOGEV(ERROR, l, "getting sharing freed pages");
+ GC_FREE;
return ERROR_FAIL;
}
physinfo->sharing_freed_pages = l;
if (l < 0 && errno == ENOSYS) {
l = 0;
} else if (l < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
- "getting sharing used frames");
+ LOGEV(ERROR, l, "getting sharing used frames");
+ GC_FREE;
return ERROR_FAIL;
}
physinfo->sharing_used_frames = l;
physinfo->cap_hvm_directio =
!!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hvm_directio);
+ GC_FREE;
return 0;
}
int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
libxl_bitmap *nodemap)
{
+ GC_INIT(ctx);
if (xc_domain_node_setaffinity(ctx->xch, domid, nodemap->map)) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting node affinity");
+ LOGE(ERROR, "setting node affinity");
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return 0;
}
int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
libxl_bitmap *nodemap)
{
+ GC_INIT(ctx);
if (xc_domain_node_getaffinity(ctx->xch, domid, nodemap->map)) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting node affinity");
+ LOGE(ERROR, "getting node affinity");
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return 0;
}
libxl_scheduler libxl_get_scheduler(libxl_ctx *ctx)
{
libxl_scheduler sched, ret;
-
+ GC_INIT(ctx);
if ((ret = xc_sched_id(ctx->xch, (int *)&sched)) != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting domain info list");
+ LOGE(ERROR, "getting domain info list");
return ERROR_FAIL;
+ GC_FREE;
}
+ GC_FREE;
return sched;
}
{
struct xen_sysctl_credit_schedule sparam;
int rc;
+ GC_INIT(ctx);
rc = xc_sched_credit_params_get(ctx->xch, poolid, &sparam);
if (rc != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting sched credit param");
+ LOGE(ERROR, "getting sched credit param");
+ GC_FREE;
return ERROR_FAIL;
}
scinfo->tslice_ms = sparam.tslice_ms;
scinfo->ratelimit_us = sparam.ratelimit_us;
+ GC_FREE;
return 0;
}
{
struct xen_sysctl_credit_schedule sparam;
int rc=0;
+ GC_INIT(ctx);
if (scinfo->tslice_ms < XEN_SYSCTL_CSCHED_TSLICE_MIN
|| scinfo->tslice_ms > XEN_SYSCTL_CSCHED_TSLICE_MAX) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "Time slice out of range, valid range is from %d to %d",
- XEN_SYSCTL_CSCHED_TSLICE_MIN,
- XEN_SYSCTL_CSCHED_TSLICE_MAX);
+ LOG(ERROR, "Time slice out of range, valid range is from %d to %d",
+ XEN_SYSCTL_CSCHED_TSLICE_MIN, XEN_SYSCTL_CSCHED_TSLICE_MAX);
+ GC_FREE;
return ERROR_INVAL;
}
if (scinfo->ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN
|| scinfo->ratelimit_us > XEN_SYSCTL_SCHED_RATELIMIT_MAX) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "Ratelimit out of range, valid range is from %d to %d",
- XEN_SYSCTL_SCHED_RATELIMIT_MIN,
- XEN_SYSCTL_SCHED_RATELIMIT_MAX);
+ LOG(ERROR, "Ratelimit out of range, valid range is from %d to %d",
+ XEN_SYSCTL_SCHED_RATELIMIT_MIN, XEN_SYSCTL_SCHED_RATELIMIT_MAX);
+ GC_FREE;
return ERROR_INVAL;
}
if (scinfo->ratelimit_us > scinfo->tslice_ms*1000) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "Ratelimit cannot be greater than timeslice");
+ LOG(ERROR, "Ratelimit cannot be greater than timeslice");
+ GC_FREE;
return ERROR_INVAL;
}
rc = xc_sched_credit_params_set(ctx->xch, poolid, &sparam);
if ( rc < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "setting sched credit param");
+ LOGE(ERROR, "setting sched credit param");
+ GC_FREE;
return ERROR_FAIL;
}
scinfo->tslice_ms = sparam.tslice_ms;
scinfo->ratelimit_us = sparam.ratelimit_us;
+ GC_FREE;
return 0;
}
}
if (rc != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Send trigger '%s' failed",
- libxl_trigger_to_string(trigger));
+ LOGE(ERROR, "Send trigger '%s' failed",
+ libxl_trigger_to_string(trigger));
rc = ERROR_FAIL;
}
int libxl_send_debug_keys(libxl_ctx *ctx, char *keys)
{
int ret;
+ GC_INIT(ctx);
ret = xc_send_debug_keys(ctx->xch, keys);
if ( ret < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "sending debug keys");
+ LOGE(ERROR, "sending debug keys");
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return 0;
}
char **line_r)
{
int ret;
+ GC_INIT(ctx);
memset(cr->buffer, 0, cr->size);
ret = xc_readconsolering(ctx->xch, cr->buffer, &cr->count,
cr->clear, cr->incremental, &cr->index);
if (ret < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "reading console ring buffer");
+ LOGE(ERROR, "reading console ring buffer");
+ GC_FREE;
return ERROR_FAIL;
}
if (!ret) {
}
}
+ GC_FREE;
return ret;
}
start_time = libxl__xs_read(
gc, XBT_NULL, libxl__sprintf(gc, "%s/start_time", vm_path));
if (start_time == NULL) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, -1,
- "Can't get start time of domain '%d'", domid);
+ LOGEV(ERROR, -1, "Can't get start time of domain '%d'", domid);
ret = -1;
}else{
ret = strtoul(start_time, NULL, 10);
{
int rc;
char _buf[32768];
+ GC_INIT(ctx);
rc = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_LIST, domid, 32768, use_long,
_buf);
if (rc < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Can not get tmem list");
+ LOGEV(ERROR, rc, "Can not get tmem list");
+ GC_FREE;
return NULL;
}
+ GC_FREE;
return strdup(_buf);
}
int libxl_tmem_freeze(libxl_ctx *ctx, uint32_t domid)
{
int rc;
+ GC_INIT(ctx);
rc = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_FREEZE, domid, 0, 0,
NULL);
if (rc < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Can not freeze tmem pools");
+ LOGEV(ERROR, rc, "Can not freeze tmem pools");
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return rc;
}
int libxl_tmem_thaw(libxl_ctx *ctx, uint32_t domid)
{
int rc;
+ GC_INIT(ctx);
rc = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_THAW, domid, 0, 0,
NULL);
if (rc < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Can not thaw tmem pools");
+ LOGEV(ERROR, rc, "Can not thaw tmem pools");
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return rc;
}
{
int rc;
int32_t subop = tmem_setop_from_string(name);
+ GC_INIT(ctx);
if (subop == -1) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, -1,
- "Invalid set, valid sets are <weight|cap|compress>");
+ LOGEV(ERROR, -1, "Invalid set, valid sets are <weight|cap|compress>");
+ GC_FREE;
return ERROR_INVAL;
}
rc = xc_tmem_control(ctx->xch, -1, subop, domid, set, 0, NULL);
if (rc < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Can not set tmem %s", name);
+ LOGEV(ERROR, rc, "Can not set tmem %s", name);
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return rc;
}
char* uuid, int auth)
{
int rc;
+ GC_INIT(ctx);
rc = xc_tmem_auth(ctx->xch, domid, uuid, auth);
if (rc < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Can not set tmem shared auth");
+ LOGEV(ERROR, rc, "Can not set tmem shared auth");
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return rc;
}
int libxl_tmem_freeable(libxl_ctx *ctx)
{
int rc;
+ GC_INIT(ctx);
rc = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_QUERY_FREEABLE_MB, -1, 0, 0, 0);
if (rc < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Can not get tmem freeable memory");
+ LOGEV(ERROR, rc, "Can not get tmem freeable memory");
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return rc;
}
rc = xc_cpupool_create(ctx->xch, poolid, sched);
if (rc) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Could not create cpupool");
+ LOGEV(ERROR, rc, "Could not create cpupool");
GC_FREE;
return ERROR_FAIL;
}
if (libxl_bitmap_test(&cpumap, i)) {
rc = xc_cpupool_addcpu(ctx->xch, *poolid, i);
if (rc) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Error moving cpu to cpupool");
+ LOGEV(ERROR, rc, "Error moving cpu to cpupool");
libxl_cpupool_destroy(ctx, *poolid);
GC_FREE;
return ERROR_FAIL;
if (libxl_bitmap_test(&cpumap, i)) {
rc = xc_cpupool_removecpu(ctx->xch, poolid, i);
if (rc) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Error removing cpu from cpupool");
+ LOGEV(ERROR, rc, "Error removing cpu from cpupool");
rc = ERROR_FAIL;
goto out1;
}
rc = xc_cpupool_destroy(ctx->xch, poolid);
if (rc) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, "Could not destroy cpupool");
+ LOGEV(ERROR, rc, "Could not destroy cpupool");
rc = ERROR_FAIL;
goto out1;
}
rc = xc_cpupool_movedomain(ctx->xch, poolid, domid);
if (rc) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
- "Error moving domain to cpupool");
+ LOGEV(ERROR, rc, "Error moving domain to cpupool");
GC_FREE;
return ERROR_FAIL;
}
int flagmask, int set_p)
{
int flags, r;
+ GC_INIT(ctx);
flags = fcntl(fd, fcntlgetop);
if (flags == -1) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "fcntl(,F_GET%s) failed",fl);
+ LOGE(ERROR, "fcntl(,F_GET%s) failed", fl);
+ GC_FREE;
return ERROR_FAIL;
}
r = fcntl(fd, fcntlsetop, flags);
if (r == -1) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "fcntl(,F_SET%s) failed",fl);
+ LOGE(ERROR, "fcntl(,F_SET%s) failed", fl);
+ GC_FREE;
return ERROR_FAIL;
}
+ GC_FREE;
return 0;
}
b_info->device_model_version =
LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
} else {
- LIBXL__LOG_ERRNO(CTX, XTL_ERROR, "qemu-xen access error");
+ LOGE(ERROR, "qemu-xen access error");
return ERROR_FAIL;
}
}
b_info->device_model_version !=
LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
libxl_defbool_val(b_info->device_model_stubdomain)) {
- LIBXL__LOG(CTX, XTL_ERROR,
+ LOG(ERROR,
"device model stubdomains require \"qemu-xen-traditional\"");
return ERROR_INVAL;
}
}
break;
default:
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
- "invalid domain type %s in create info",
- libxl_domain_type_to_string(b_info->type));
+ LOG(ERROR, "invalid domain type %s in create info",
+ libxl_domain_type_to_string(b_info->type));
return ERROR_INVAL;
}
return 0;
ret = libxl__arch_domain_prepare_config(gc, d_config, xc_config);
if (ret < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "fail to get domain config");
+ LOGE(ERROR, "fail to get domain config");
rc = ERROR_FAIL;
goto out;
}
handle, flags, domid,
xc_config);
if (ret < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "domain creation fail");
+ LOGE(ERROR, "domain creation fail");
rc = ERROR_FAIL;
goto out;
}
ret = xc_cpupool_movedomain(ctx->xch, info->poolid, *domid);
if (ret < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "domain move fail");
+ LOGE(ERROR, "domain move fail");
rc = ERROR_FAIL;
goto out;
}
vm_path = libxl__sprintf(gc, "/vm/%s", uuid_string);
if (!vm_path) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot allocate create paths");
+ LOG(ERROR, "cannot allocate create paths");
rc = ERROR_FAIL;
goto out;
}
t = 0;
goto retry_transaction;
}
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "domain creation "
- "xenstore transaction commit failed");
+ LOGE(ERROR, "domain creation ""xenstore transaction commit failed");
rc = ERROR_FAIL;
goto out;
}
ret = libxl__domain_make(gc, d_config, &domid, &state->config);
if (ret) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret);
+ LOG(ERROR, "cannot make domain: %d", ret);
dcs->guest_domid = domid;
ret = ERROR_FAIL;
goto error_out;
/* convenience aliases */
const uint32_t domid = dcs->guest_domid;
libxl_domain_config *const d_config = dcs->guest_config;
- libxl_ctx *const ctx = CTX;
if (ret) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot (re-)build domain: %d", ret);
+ LOG(ERROR, "cannot (re-)build domain: %d", ret);
ret = ERROR_FAIL;
goto error_out;
}
{
libxl__domain_create_state *dcs = CONTAINER_OF(dmss, *dcs, dmss.dm);
STATE_AO_GC(dmss->spawn.ao);
- libxl_ctx *ctx = CTX;
int domid = dcs->guest_domid;
/* convenience aliases */
libxl_domain_config *const d_config = dcs->guest_config;
if (ret) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "device model did not start: %d", ret);
+ LOG(ERROR, "device model did not start: %d", ret);
goto error_out;
}
libxl__domain_create_state *dcs = CONTAINER_OF(multidev, *dcs, multidev);
STATE_AO_GC(dcs->ao);
int i;
- libxl_ctx *ctx = CTX;
int domid = dcs->guest_domid;
/* convenience aliases */
for (i = 0; i < d_config->num_pcidevs; i++) {
ret = libxl__device_pci_add(gc, domid, &d_config->pcidevs[i], 1);
if (ret < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "libxl_device_pci_add failed: %d", ret);
+ LOG(ERROR, "libxl_device_pci_add failed: %d", ret);
goto error_out;
}
}
ret = libxl__create_pci_backend(gc, domid, d_config->pcidevs,
d_config->num_pcidevs);
if (ret < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "libxl_create_pci_backend failed: %d", ret);
+ LOG(ERROR, "libxl_create_pci_backend failed: %d", ret);
goto error_out;
}
}
const char *libxl__domain_device_model(libxl__gc *gc,
const libxl_domain_build_info *info)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
const char *dm;
if (libxl_defbool_val(info->device_model_stubdomain))
dm = qemu_xen_path(gc);
break;
default:
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "invalid device model version %d",
- info->device_model_version);
+ LOG(ERROR, "invalid device model version %d",
+ info->device_model_version);
dm = NULL;
break;
}
char *opt;
if (!spice->port && !spice->tls_port) {
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
- "at least one of the spiceport or tls_port must be provided");
+ LOG(ERROR,
+ "at least one of the spiceport or tls_port must be provided");
return NULL;
}
if (!libxl_defbool_val(spice->disable_ticketing)) {
if (!spice->passwd) {
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
- "spice ticketing is enabled but missing password");
+ LOG(ERROR, "spice ticketing is enabled but missing password");
return NULL;
}
else if (!spice->passwd[0]) {
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
- "spice password can't be empty");
+ LOG(ERROR, "spice password can't be empty");
return NULL;
}
}
const libxl__domain_build_state *state,
int *dm_state_fd)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
const libxl_domain_create_info *c_info = &guest_config->c_info;
const libxl_domain_build_info *b_info = &guest_config->b_info;
const libxl_device_disk *disks = guest_config->disks;
const char *pdev_path;
if (dev_number == -1) {
- LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to determine"
- " disk number for %s", disks[i].vdev);
+ LOG(WARN, "unable to determine"" disk number for %s",
+ disks[i].vdev);
continue;
}
disks[i].pdev_path, disk, disks[i].readwrite ? "off" : "on", format, dev_number);
} else {
if (!disks[i].readwrite) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "qemu-xen doesn't support read-only disk drivers");
+ LOG(ERROR,
+ "qemu-xen doesn't support read-only disk drivers");
return ERROR_INVAL;
}
if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
- LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support"
- " empty disk format for %s", disks[i].vdev);
+ LOG(WARN, "cannot support"" empty disk format for %s",
+ disks[i].vdev);
continue;
}
if (format == NULL) {
- LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to determine"
- " disk image format %s", disks[i].vdev);
+ LOG(WARN,
+ "unable to determine"" disk image format %s",
+ disks[i].vdev);
continue;
}
/* dm_state_fd may be NULL iff caller knows we are using old stubdom
* and therefore will be passing a filename rather than a fd. */
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
-
switch (guest_config->b_info.device_model_version) {
case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
return libxl__build_device_model_args_old(gc, dm,
args, envs,
state, dm_state_fd);
default:
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown device model version %d",
- guest_config->b_info.device_model_version);
+ LOGE(ERROR, "unknown device model version %d",
+ guest_config->b_info.device_model_version);
return ERROR_INVAL;
}
}
"%d", guest_domid);
ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
if (ret<0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "setting target domain %d -> %d",
- dm_domid, guest_domid);
+ LOGE(ERROR, "setting target domain %d -> %d", dm_domid, guest_domid);
ret = ERROR_FAIL;
goto out;
}
goto out;
}
if (access(dm, X_OK) < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "device model %s is not executable", dm);
+ LOGE(ERROR, "device model %s is not executable", dm);
rc = ERROR_FAIL;
goto out;
}
}
}
- LIBXL__LOG(CTX, XTL_DEBUG, "Spawning device-model %s with arguments:", dm);
+ LOG(DEBUG, "Spawning device-model %s with arguments:", dm);
for (arg = args; *arg; arg++)
- LIBXL__LOG(CTX, XTL_DEBUG, " %s", *arg);
+ LOG(DEBUG, " %s", *arg);
if (*envs) {
LOG(DEBUG, "Spawning device-model %s with additional environment:", dm);
for (arg = envs; *arg; arg += 2)
libxl_for_each_set_bit(v, info->u.hvm.viridian_enable) {
if (libxl_bitmap_test(&info->u.hvm.viridian_disable, v)) {
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "%s group both enabled and disabled",
- libxl_viridian_enlightenment_to_string(v));
+ LOG(ERROR, "%s group both enabled and disabled",
+ libxl_viridian_enlightenment_to_string(v));
goto err;
}
if (libxl_viridian_enlightenment_to_string(v)) /* check validity */
/* The base set is a pre-requisite for all others */
if (!libxl_bitmap_is_empty(&enlightenments) &&
!libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_BASE)) {
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "base group not enabled");
+ LOG(ERROR, "base group not enabled");
goto err;
}
domid,
HVM_PARAM_VIRIDIAN,
mask) != 0) {
- LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR,
- "Couldn't set viridian feature mask (0x%"PRIx64")",
- mask);
+ LOGE(ERROR, "Couldn't set viridian feature mask (0x%"PRIx64")", mask);
goto err;
}
if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
LIBXL_MAXMEM_CONSTANT) < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't set max memory");
+ LOGE(ERROR, "Couldn't set max memory");
return ERROR_FAIL;
}
}
if (rc)
- LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "cannot write/rename %s for %s",
- newfilename, filename);
+ LOGE(ERROR, "cannot write/rename %s for %s", newfilename, filename);
out:
return rc;
}
goto out;
}
if (!e && !datalen) {
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "userdata file %s is empty", filename);
+ LOG(ERROR, "userdata file %s is empty", filename);
if (data_r) assert(!*data_r);
rc = ERROR_FAIL;
goto out;
{
int rc = gettimeofday(now_r, 0);
if (rc) {
- LIBXL__LOG_ERRNO(CTX, LIBXL__LOG_ERROR, "gettimeofday failed");
+ LOGE(ERROR, "gettimeofday failed");
return ERROR_FAIL;
}
return 0;
uint32_t counterval;
int rc = sscanf(token, "%d/%"SCNx32, &slotnum, &counterval);
if (rc != 2) {
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR,
- "watch epath=%s token=%s: failed to parse token",
- epath, token);
+ LOG(ERROR, "watch epath=%s token=%s: failed to parse token",
+ epath, token);
/* oh well */
goto ignore;
}
libxl__ev_xswatch *w = libxl__watch_slot_contents(gc, slotnum);
if (!w) {
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG,
- "watch epath=%s token=%s: empty slot",
- epath, token);
+ LOG(DEBUG, "watch epath=%s token=%s: empty slot", epath, token);
goto ignore;
}
w, path, token, slotnum);
if (!xs_watch(CTX->xsh, path, token)) {
- LIBXL__LOG_ERRNOVAL(CTX, LIBXL__LOG_ERROR, errno,
- "create watch for path %s", path);
+ LOGEV(ERROR, errno, "create watch for path %s", path);
rc = ERROR_FAIL;
goto out_rc;
}
if (!xs_unwatch(CTX->xsh, w->path, token))
/* Oh well, we will just get watch events forever more
* and ignore them. But we should complain to the log. */
- LIBXL__LOG_ERRNOVAL(CTX, LIBXL__LOG_ERROR, errno,
- "remove watch for path %s", w->path);
+ LOGEV(ERROR, errno, "remove watch for path %s", w->path);
libxl__ev_watch_slot *slot = &CTX->watch_slots[w->slotnum];
LIBXL_SLIST_INSERT_HEAD(&CTX->watch_freeslots, slot, empty);
if (rc) {
if (rc == ERROR_TIMEDOUT)
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "backend %s wanted state %d "
- " timed out", ds->w.path, ds->wanted);
+ LOG(DEBUG, "backend %s wanted state %d "" timed out", ds->w.path,
+ ds->wanted);
goto out;
}
if (!sstate) {
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "backend %s wanted state %d"
- " but it was removed", ds->w.path, ds->wanted);
+ LOG(DEBUG, "backend %s wanted state %d"" but it was removed",
+ ds->w.path, ds->wanted);
rc = ERROR_INVAL;
goto out;
}
int got = atoi(sstate);
if (got == ds->wanted) {
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "backend %s wanted state %d ok",
- ds->w.path, ds->wanted);
+ LOG(DEBUG, "backend %s wanted state %d ok", ds->w.path, ds->wanted);
rc = 0;
} else {
- LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "backend %s wanted state %d"
- " still waiting state %d", ds->w.path, ds->wanted, got);
+ LOG(DEBUG, "backend %s wanted state %d"" still waiting state %d",
+ ds->w.path, ds->wanted, got);
return;
}
if (errno == EINTR)
return 0; /* will go round again if caller requires */
- LIBXL__LOG_ERRNOVAL(CTX, LIBXL__LOG_ERROR, errno, "poll failed");
+ LOGEV(ERROR, errno, "poll failed");
rc = ERROR_FAIL;
goto out;
}
void libxl__ao_complete_check_progress_reports(libxl__egc *egc, libxl__ao *ao)
{
+ EGC_GC;
libxl_ctx *ctx = libxl__gc_owner(&egc->gc);
assert(ao->progress_reports_outstanding >= 0);
/* don't bother with this if we're not in the event loop */
libxl__poller_wakeup(egc, ao->poller);
} else if (ao->how.callback) {
- LIBXL__LOG(ctx, XTL_DEBUG, "ao %p: complete for callback",ao);
+ LOG(DEBUG, "ao %p: complete for callback", ao);
LIBXL_TAILQ_INSERT_TAIL(&egc->aos_for_callback, ao, entry_for_callback);
} else {
libxl_event *ev;
rc = eventloop_iteration(&egc,ao->poller);
if (rc) {
/* Oh dear, this is quite unfortunate. */
- LIBXL__LOG(CTX, LIBXL__LOG_ERROR, "Error waiting for"
- " event during long-running operation (rc=%d)", rc);
+ LOG(ERROR,
+ "Error waiting for"" event during long-running operation (rc=%d)",
+ rc);
sleep(1);
/* It's either this or return ERROR_I_DONT_KNOW_WHETHER
* _THE_THING_YOU_ASKED_FOR_WILL_BE_DONE_LATER_WHEN
parent->aborting = 1;
if (LIBXL_LIST_EMPTY(&parent->abortables)) {
- LIBXL__LOG(ctx, XTL_DEBUG,
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG,
"ao %p: abort requested and noted, but no-one interested",
parent);
rc = 0;
LIBXL_LIST_REMOVE(abrt, entry);
abrt->registered = 0;
- LIBXL__LOG(ctx, XTL_DEBUG, "ao %p: abrt=%p: aborting",
- parent, abrt->ao);
+ LIBXL__LOG(ctx, LIBXL__LOG_DEBUG,
+ "ao %p: abrt=%p: aborting", parent, abrt->ao);
abrt->callback(&egc, abrt, ERROR_ABORTED);
libxl__ctx_unlock(ctx);
void *userdata),
void *check_callback_userdata)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
char *p;
unsigned int len;
int rc = 0;
xsh = xs_daemon_open();
if (xsh == NULL) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to open xenstore connection");
+ LOG(ERROR, "Unable to open xenstore connection");
goto err;
}
}
}
}
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "%s not ready", what);
+ LOG(ERROR, "%s not ready", what);
xs_unwatch(xsh, path, path);
xs_daemon_close(xsh);
_hidden int libxl__init_recursive_mutex(libxl_ctx *ctx, pthread_mutex_t *lock)
{
+ GC_INIT(ctx);
pthread_mutexattr_t attr;
int rc = 0;
if (pthread_mutexattr_init(&attr) != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Failed to init mutex attributes");
- return ERROR_FAIL;
+ LOGE(ERROR, "Failed to init mutex attributes");
+ rc = ERROR_FAIL;
+ goto out;
}
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Failed to set mutex attributes");
+ LOGE(ERROR, "Failed to set mutex attributes");
rc = ERROR_FAIL;
goto out;
}
if (pthread_mutex_init(lock, &attr) != 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to init mutex");
+ LOGE(ERROR, "Failed to init mutex");
rc = ERROR_FAIL;
goto out;
}
out:
pthread_mutexattr_destroy(&attr);
+ GC_FREE;
return rc;
}
}
if (libxl_device_model_version_from_string(dm_version, &value) < 0) {
- libxl_ctx *ctx = libxl__gc_owner(gc);
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "fatal: %s contain a wrong value (%s)", path, dm_version);
+ LOG(ERROR, "fatal: %s contain a wrong value (%s)", path, dm_version);
return -1;
}
return value;
int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
libxl_device_pci *pcidev, int num)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
flexarray_t *front = NULL;
flexarray_t *back = NULL;
libxl__device device;
ret = 0;
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Creating pci backend");
+ LOG(DEBUG, "Creating pci backend");
/* add pci device */
libxl__device_from_pcidev(gc, domid, pcidev, &device);
static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
flexarray_t *back;
char *num_devs, *be_path;
int num = 0;
back = flexarray_make(gc, 16, 1);
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Adding new pci device to xenstore");
+ LOG(DEBUG, "Adding new pci device to xenstore");
num = atoi(num_devs);
libxl_create_pci_backend_device(gc, back, num, pcidev);
flexarray_append_pair(back, "num_devs", libxl__sprintf(gc, "%d", num + 1));
if (domtype == LIBXL_DOMAIN_TYPE_PV) {
if (libxl__wait_for_backend(gc, be_path, GCSPRINTF("%d", XenbusStateConnected)) < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "pci backend at %s is not ready", be_path);
+ LOG(DEBUG, "pci backend at %s is not ready", be_path);
return ERROR_FAIL;
}
}
}
}
if (i == num) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Couldn't find the device on xenstore");
+ LOG(ERROR, "Couldn't find the device on xenstore");
return ERROR_INVAL;
}
if (domtype == LIBXL_DOMAIN_TYPE_PV) {
if (libxl__wait_for_backend(gc, be_path, GCSPRINTF("%d", XenbusStateConnected)) < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "pci backend at %s is not ready", be_path);
+ LOG(DEBUG, "pci backend at %s is not ready", be_path);
return ERROR_FAIL;
}
}
static int sysfs_write_bdf(libxl__gc *gc, const char * sysfs_path,
libxl_device_pci *pcidev)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
int rc, fd;
char *buf;
fd = open(sysfs_path, O_WRONLY);
if (fd < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s",
- sysfs_path);
+ LOGE(ERROR, "Couldn't open %s", sysfs_path);
return ERROR_FAIL;
}
rc = write(fd, buf, strlen(buf));
/* Annoying to have two if's, but we need the errno */
if (rc < 0)
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "write to %s returned %d", sysfs_path, rc);
+ LOGE(ERROR, "write to %s returned %d", sysfs_path, rc);
close(fd);
if (rc < 0)
dir = opendir(SYSFS_PCIBACK_DRIVER);
if ( NULL == dir ) {
if ( errno == ENOENT ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Looks like pciback driver not loaded");
+ LOG(ERROR, "Looks like pciback driver not loaded");
}else{
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", SYSFS_PCIBACK_DRIVER);
+ LOGE(ERROR, "Couldn't open %s", SYSFS_PCIBACK_DRIVER);
}
goto out_closedir;
}
static int sysfs_dev_unbind(libxl__gc *gc, libxl_device_pci *pcidev,
char **driver_path)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
char * spath, *dp = NULL;
struct stat st;
dp = libxl__zalloc(gc, PATH_MAX);
dp = realpath(spath, dp);
if ( !dp ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "realpath() failed");
+ LOGE(ERROR, "realpath() failed");
return -1;
}
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Driver re-plug path: %s",
- dp);
+ LOG(DEBUG, "Driver re-plug path: %s", dp);
/* Unbind from the old driver */
spath = libxl__sprintf(gc, "%s/unbind", dp);
if ( sysfs_write_bdf(gc, spath, pcidev) < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't unbind device");
+ LOGE(ERROR, "Couldn't unbind device");
return -1;
}
}
/* Scan through /sys/.../pciback/slots looking for pcidev's BDF */
static int pciback_dev_has_slot(libxl__gc *gc, libxl_device_pci *pcidev)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
FILE *f;
int rc = 0;
unsigned dom, bus, dev, func;
f = fopen(SYSFS_PCIBACK_DRIVER"/slots", "r");
if (f == NULL) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s",
- SYSFS_PCIBACK_DRIVER"/slots");
+ LOGE(ERROR, "Couldn't open %s", SYSFS_PCIBACK_DRIVER"/slots");
return ERROR_FAIL;
}
static int pciback_dev_is_assigned(libxl__gc *gc, libxl_device_pci *pcidev)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
char * spath;
int rc;
struct stat st;
if ( access(SYSFS_PCIBACK_DRIVER, F_OK) < 0 ) {
if ( errno == ENOENT ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "Looks like pciback driver is not loaded");
+ LOG(ERROR, "Looks like pciback driver is not loaded");
} else {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Can't access "SYSFS_PCIBACK_DRIVER);
+ LOGE(ERROR, "Can't access "SYSFS_PCIBACK_DRIVER);
}
return -1;
}
return 1;
if ( rc < 0 && errno == ENOENT )
return 0;
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Accessing %s", spath);
+ LOGE(ERROR, "Accessing %s", spath);
return -1;
}
static int pciback_dev_assign(libxl__gc *gc, libxl_device_pci *pcidev)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
int rc;
if ( (rc=pciback_dev_has_slot(gc, pcidev)) < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Error checking for pciback slot");
+ LOGE(ERROR, "Error checking for pciback slot");
return ERROR_FAIL;
} else if (rc == 0) {
if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/new_slot",
pcidev) < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Couldn't bind device to pciback!");
+ LOGE(ERROR, "Couldn't bind device to pciback!");
return ERROR_FAIL;
}
}
if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/bind", pcidev) < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Couldn't bind device to pciback!");
+ LOGE(ERROR, "Couldn't bind device to pciback!");
return ERROR_FAIL;
}
return 0;
static int pciback_dev_unassign(libxl__gc *gc, libxl_device_pci *pcidev)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
-
/* Remove from pciback */
if ( sysfs_dev_unbind(gc, pcidev, NULL) < 0 ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Couldn't unbind device!");
+ LOG(ERROR, "Couldn't unbind device!");
return ERROR_FAIL;
}
if ( pciback_dev_has_slot(gc, pcidev) > 0 ) {
if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/remove_slot",
pcidev) < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Couldn't remove pciback slot");
+ LOGE(ERROR, "Couldn't remove pciback slot");
return ERROR_FAIL;
}
}
libxl_device_pci *pcidev,
char *driver_path)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
char *path;
path = libxl__sprintf(gc, PCIBACK_INFO_PATH"/"PCI_BDF_XSPATH"/driver_path",
pcidev->dev,
pcidev->func);
if ( libxl__xs_write(gc, XBT_NULL, path, "%s", driver_path) < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_WARNING,
- "Write of %s to node %s failed.",
- driver_path, path);
+ LOGE(WARN, "Write of %s to node %s failed.", driver_path, path);
}
}
/* See if the device exists */
spath = libxl__sprintf(gc, SYSFS_PCI_DEV"/"PCI_BDF, dom, bus, dev, func);
if ( lstat(spath, &st) ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't lstat %s", spath);
+ LOGE(ERROR, "Couldn't lstat %s", spath);
return ERROR_FAIL;
}
}
if ( pciback_dev_assign(gc, pcidev) ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Couldn't bind device to pciback!");
+ LOG(ERROR, "Couldn't bind device to pciback!");
return ERROR_FAIL;
}
libxl_device_pci *pcidev,
int rebind)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
int rc;
char *driver_path;
} else if ( rc ) {
pciback_dev_unassign(gc, pcidev);
} else {
- LIBXL__LOG(ctx, LIBXL__LOG_WARNING,
- "Not bound to pciback");
+ LOG(WARN, "Not bound to pciback");
}
/* Rebind if necessary */
if ( driver_path ) {
if ( rebind ) {
- LIBXL__LOG(ctx, LIBXL__LOG_INFO, "Rebinding to driver at %s",
- driver_path);
+ LOG(INFO, "Rebinding to driver at %s", driver_path);
if ( sysfs_write_bdf(gc,
libxl__sprintf(gc, "%s/bind", driver_path),
pcidev) < 0 ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
- "Couldn't bind device to %s", driver_path);
+ LOGE(ERROR, "Couldn't bind device to %s", driver_path);
return -1;
}
}
} else {
if ( rebind ) {
- LIBXL__LOG(ctx, LIBXL__LOG_WARNING,
- "Couldn't find path for original driver; not rebinding");
+ LOG(WARN,
+ "Couldn't find path for original driver; not rebinding");
}
}
dir = opendir(SYSFS_PCI_DEV);
if ( NULL == dir ) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", SYSFS_PCI_DEV);
+ LOGE(ERROR, "Couldn't open %s", SYSFS_PCI_DEV);
return -1;
}
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, PCI_BDF " is not assigned to pciback driver",
dom, bus, dev, func);
else
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't lstat %s", path);
+ LOGE(ERROR, "Couldn't lstat %s", path);
closedir(dir);
return -1;
}
vdevfn = libxl__xs_read(gc, XBT_NULL, path);
path = libxl__device_model_xs_path(gc, dm_domid, domid, "/state");
if ( rc < 0 )
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "qemu refused to add device: %s", vdevfn);
+ LOG(ERROR, "qemu refused to add device: %s", vdevfn);
else if ( sscanf(vdevfn, "0x%x", &pcidev->vdevfn) != 1 ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "wrong format for the vdevfn: '%s'", vdevfn);
+ LOG(ERROR, "wrong format for the vdevfn: '%s'", vdevfn);
rc = -1;
}
xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state));
irq = 0;
if (f == NULL) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LOGE(ERROR, "Couldn't open %s", sysfs_path);
return ERROR_FAIL;
}
for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) {
if (flags & PCI_BAR_IO) {
rc = xc_domain_ioport_permission(ctx->xch, domid, start, size, 1);
if (rc < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Error: xc_domain_ioport_permission error 0x%llx/0x%llx", start, size);
+ LOGE(ERROR,
+ "Error: xc_domain_ioport_permission error 0x%llx/0x%llx",
+ start,
+ size);
fclose(f);
return ERROR_FAIL;
}
rc = xc_domain_iomem_permission(ctx->xch, domid, start>>XC_PAGE_SHIFT,
(size+(XC_PAGE_SIZE-1))>>XC_PAGE_SHIFT, 1);
if (rc < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Error: xc_domain_iomem_permission error 0x%llx/0x%llx", start, size);
+ LOGE(ERROR,
+ "Error: xc_domain_iomem_permission error 0x%llx/0x%llx",
+ start,
+ size);
fclose(f);
return ERROR_FAIL;
}
pcidev->bus, pcidev->dev, pcidev->func);
f = fopen(sysfs_path, "r");
if (f == NULL) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LOGE(ERROR, "Couldn't open %s", sysfs_path);
goto out;
}
if ((fscanf(f, "%u", &irq) == 1) && irq) {
rc = xc_physdev_map_pirq(ctx->xch, domid, irq, &irq);
if (rc < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Error: xc_physdev_map_pirq irq=%d", irq);
+ LOGE(ERROR, "Error: xc_physdev_map_pirq irq=%d", irq);
fclose(f);
return ERROR_FAIL;
}
rc = xc_domain_irq_permission(ctx->xch, domid, irq, 1);
if (rc < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Error: xc_domain_irq_permission irq=%d", irq);
+ LOGE(ERROR, "Error: xc_domain_irq_permission irq=%d", irq);
fclose(f);
return ERROR_FAIL;
}
if (pcidev->permissive) {
if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/permissive",
pcidev) < 0 ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
- "Setting permissive for device");
+ LOG(ERROR, "Setting permissive for device");
return ERROR_FAIL;
}
}
if (pcidev->rdm_policy == LIBXL_RDM_RESERVE_POLICY_STRICT) {
flag &= ~XEN_DOMCTL_DEV_RDM_RELAXED;
} else if (pcidev->rdm_policy != LIBXL_RDM_RESERVE_POLICY_RELAXED) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unknown rdm check flag.");
+ LOGE(ERROR, "unknown rdm check flag.");
return ERROR_FAIL;
}
rc = xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev), flag);
if (rc < 0 && (hvm || errno != ENOSYS)) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_assign_device failed");
+ LOGE(ERROR, "xc_assign_device failed");
return ERROR_FAIL;
}
}
char *buf = libxl__sprintf(gc, PCI_BDF, domain, bus, dev, func);
rc = write(fd, buf, strlen(buf));
if (rc < 0)
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "write to %s returned %d", reset, rc);
+ LOG(ERROR, "write to %s returned %d", reset, rc);
close(fd);
return rc < 0 ? rc : 0;
}
if (errno != ENOENT)
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to access pciback path %s", reset);
+ LOGE(ERROR, "Failed to access pciback path %s", reset);
reset = libxl__sprintf(gc, "%s/"PCI_BDF"/reset", SYSFS_PCI_DEV, domain, bus, dev, func);
fd = open(reset, O_WRONLY);
if (fd >= 0) {
rc = write(fd, "1", 1);
if (rc < 0)
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "write to %s returned %d", reset, rc);
+ LOGE(ERROR, "write to %s returned %d", reset, rc);
close(fd);
return rc < 0 ? rc : 0;
}
if (errno == ENOENT) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "The kernel doesn't support reset from sysfs for PCI device "PCI_BDF, domain, bus, dev, func);
} else {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to access reset path %s", reset);
+ LOGE(ERROR, "Failed to access reset path %s", reset);
}
return -1;
}
rc = get_all_assigned_devices(gc, &assigned, &num_assigned);
if ( rc ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot determine if device is assigned, refusing to continue");
+ LOG(ERROR,
+ "cannot determine if device is assigned, refusing to continue");
goto out;
}
if ( is_pcidev_in_array(assigned, num_assigned, pcidev->domain,
pcidev->bus, pcidev->dev, pcidev->func) ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device already attached to a domain");
+ LOG(ERROR, "PCI device already attached to a domain");
rc = ERROR_FAIL;
goto out;
}
if ( pcidev->vfunc_mask == LIBXL_PCI_FUNC_ALL ) {
if ( !(pcidev->vdevfn >> 3) ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Must specify a v-slot for multi-function devices");
+ LOG(ERROR, "Must specify a v-slot for multi-function devices");
rc = ERROR_INVAL;
goto out;
}
libxl__qemu_traditional_cmd(gc, domid, "pci-rem");
if (libxl__wait_for_device_model_deprecated(gc, domid, "pci-removed",
NULL, NULL, NULL) < 0) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device Model didn't respond in time");
+ LOG(ERROR, "Device Model didn't respond in time");
/* This depends on guest operating system acknowledging the
* SCI, if it doesn't respond in time then we may wish to
* force the removal.
rc = ERROR_INVAL;
if ( !is_pcidev_in_array(assigned, num, pcidev->domain,
pcidev->bus, pcidev->dev, pcidev->func) ) {
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device not attached to this domain");
+ LOG(ERROR, "PCI device not attached to this domain");
goto out_fail;
}
int i;
if (f == NULL) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LOGE(ERROR, "Couldn't open %s", sysfs_path);
goto skip1;
}
for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) {
if (flags & PCI_BAR_IO) {
rc = xc_domain_ioport_permission(ctx->xch, domid, start, size, 0);
if (rc < 0)
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_domain_ioport_permission error 0x%x/0x%x", start, size);
+ LOGE(ERROR,
+ "xc_domain_ioport_permission error 0x%x/0x%x",
+ start,
+ size);
} else {
rc = xc_domain_iomem_permission(ctx->xch, domid, start>>XC_PAGE_SHIFT,
(size+(XC_PAGE_SIZE-1))>>XC_PAGE_SHIFT, 0);
if (rc < 0)
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_domain_iomem_permission error 0x%x/0x%x", start, size);
+ LOGE(ERROR,
+ "xc_domain_iomem_permission error 0x%x/0x%x",
+ start,
+ size);
}
}
}
pcidev->bus, pcidev->dev, pcidev->func);
f = fopen(sysfs_path, "r");
if (f == NULL) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't open %s", sysfs_path);
+ LOGE(ERROR, "Couldn't open %s", sysfs_path);
goto out;
}
if ((fscanf(f, "%u", &irq) == 1) && irq) {
rc = xc_physdev_unmap_pirq(ctx->xch, domid, irq);
if (rc < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_physdev_unmap_pirq irq=%d", irq);
+ LOGE(ERROR, "xc_physdev_unmap_pirq irq=%d", irq);
}
rc = xc_domain_irq_permission(ctx->xch, domid, irq, 0);
if (rc < 0) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_domain_irq_permission irq=%d", irq);
+ LOGE(ERROR, "xc_domain_irq_permission irq=%d", irq);
}
}
fclose(f);
if (!libxl_is_stubdom(ctx, domid, NULL)) {
rc = xc_deassign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
if (rc < 0 && (hvm || errno != ENOSYS))
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "xc_deassign_device failed");
+ LOGE(ERROR, "xc_deassign_device failed");
}
stubdomid = libxl_get_stubdom_id(ctx, domid);
constdata void *data, ssize_t sz, \
const char *source, const char *what) { \
ssize_t got; \
+ GC_INIT(ctx); \
\
while (sz > 0) { \
got = rw(fd, data, sz); \
if (got == -1) { \
if (errno == EINTR) continue; \
- if (!ctx) return errno; \
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to " #rw " %s%s%s", \
- what?what:"", what?" from ":"", source); \
+ if (!ctx) { GC_FREE; return errno; } \
+ LOGE(ERROR, "failed to "#rw" %s%s%s", what ? what : "", what ? " from " : "", source); \
+ GC_FREE; \
return errno; \
} \
if (got == 0) { \
- if (!ctx) return EPROTO; \
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, \
- zero_is_eof \
- ? "file/stream truncated reading %s%s%s" \
- : "file/stream write returned 0! writing %s%s%s", \
- what?what:"", what?" from ":"", source); \
+ if (!ctx) { GC_FREE; return EPROTO; } \
+ LOG(ERROR, zero_is_eof ? "file/stream truncated reading %s%s%s" : "file/stream write returned 0! writing %s%s%s", what ? what : "", what ? " from " : "", source); \
+ GC_FREE; \
return EPROTO; \
} \
sz -= got; \
data = (char*)data + got; \
} \
+ GC_FREE; \
return 0; \
}
return "Unknown";
}
-static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[],
+static int e820_sanitize(libxl__gc *gc, struct e820entry src[],
uint32_t *nr_entries,
unsigned long map_limitkb,
unsigned long balloon_kb)
ram_end = e820[idx].addr + e820[idx].size;
idx ++;
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Memory: %"PRIu64"kB End of RAM: " \
+ LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "Memory: %"PRIu64"kB End of RAM: " \
"0x%"PRIx64" (PFN) Delta: %"PRIu64"kB, PCI start: %"PRIu64"kB " \
"(0x%"PRIx64" PFN), Balloon %"PRIu64"kB\n", (uint64_t)map_limitkb,
ram_end >> 12, delta_kb, start_kb ,start >> 12,
if (src[i].addr + src[i].size != end) {
/* We messed up somewhere */
src[i].type = 0;
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Computed E820 wrongly. Continuing on.");
+ LOGE(ERROR, "Computed E820 wrongly. Continuing on.");
}
}
/* Lastly, convert the RAM to UNSUABLE. Look in the Linux kernel
nr = idx;
for (i = 0; i < nr; i++) {
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, ":\t[%"PRIx64" -> %"PRIx64"] %s",
- e820[i].addr >> 12, (e820[i].addr + e820[i].size) >> 12,
- e820_names(e820[i].type));
+ LOG(DEBUG, ":\t[%"PRIx64" -> %"PRIx64"] %s", e820[i].addr >> 12,
+ (e820[i].addr + e820[i].size) >> 12, e820_names(e820[i].type));
}
/* Done: copy the sanitized version. */
*nr = rc;
- rc = e820_sanitize(CTX, map, nr, b_info->target_memkb,
+ rc = e820_sanitize(gc, map, nr, b_info->target_memkb,
(b_info->max_memkb - b_info->target_memkb) +
b_info->u.pv.slack_memkb);
return rc;
libxl_defbool_val(d_config->b_info.u.pv.e820_host)) {
ret = libxl__e820_alloc(gc, domid, d_config);
if (ret) {
- LIBXL__LOG_ERRNO(gc->owner, LIBXL__LOG_ERROR,
- "Failed while collecting E820 with: %d (errno:%d)\n",
- ret, errno);
+ LOGE(ERROR, "Failed while collecting E820 with: %d (errno:%d)\n",
+ ret, errno);
}
}
libxl_ctx *ctx = libxl__gc_owner(gc);
char *s = xs_get_domain_path(ctx->xsh, domid);
if (!s) {
- LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to get dompath for %" PRIu32,
- domid);
+ LOGE(ERROR, "failed to get dompath for %"PRIu32, domid);
return NULL;
}
libxl__ptr_add(gc, s);
char *libxl__xs_libxl_path(libxl__gc *gc, uint32_t domid)
{
- libxl_ctx *ctx = libxl__gc_owner(gc);
char *s = libxl__sprintf(gc, "/libxl/%i", domid);
if (!s)
- LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot allocate create paths");
+ LOG(ERROR, "cannot allocate create paths");
return s;
}