lock_pages(void *addr, size_t len)
{
#ifdef __linux__
- return mlock(addr, len);
+ if (mlock(addr, len) < 0) {
+ virReportSystemError(errno,
+ _("Unable to lock %zu bytes of memory"),
+ len);
+ return -1;
+ }
+ return 0;
#elif defined(__sun)
- return 0;
+ return 0;
#endif
}
unlock_pages(void *addr, size_t len)
{
#ifdef __linux__
- return munlock(addr, len);
+ if (munlock(addr, len) < 0) {
+ virReportSystemError(errno,
+ _("Unable to unlock %zu bytes of memory"),
+ len);
+ return -1;
+ }
+ return 0;
#elif defined(__sun)
- return 0;
+ return 0;
#endif
}
hc.op = __HYPERVISOR_dom0_op;
hc.arg[0] = (unsigned long) op;
- if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " locking");
+ if (lock_pages(op, sizeof(dom0_op_t)) < 0)
return -1;
- }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) {
- virXenError(VIR_ERR_XEN_CALL, " ioctl %d",
- xen_ioctl_hypercall_cmd);
+ virReportSystemError(errno,
+ _("Unable to issue hypervisor ioctl %d"),
+ xen_ioctl_hypercall_cmd);
}
- if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " releasing");
+ if (unlock_pages(op, sizeof(dom0_op_t)) < 0)
ret = -1;
- }
if (ret < 0)
return -1;
hc.op = __HYPERVISOR_dom0_op;
hc.arg[0] = (unsigned long) op;
- if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " locking");
+ if (lock_pages(op, sizeof(dom0_op_t)) < 0)
return -1;
- }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) {
- virXenError(VIR_ERR_XEN_CALL, " ioctl %d",
- xen_ioctl_hypercall_cmd);
+ virReportSystemError(errno,
+ _("Unable to issue hypervisor ioctl %d"),
+ xen_ioctl_hypercall_cmd);
}
- if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " releasing");
+ if (unlock_pages(op, sizeof(dom0_op_t)) < 0)
ret = -1;
- }
if (ret < 0)
return -1;
hc.op = __HYPERVISOR_sysctl;
hc.arg[0] = (unsigned long) op;
- if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " locking");
+ if (lock_pages(op, sizeof(dom0_op_t)) < 0)
return -1;
- }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) {
- virXenError(VIR_ERR_XEN_CALL, " sys ioctl %d",
- xen_ioctl_hypercall_cmd);
+ virReportSystemError(errno,
+ _("Unable to issue hypervisor ioctl %d"),
+ xen_ioctl_hypercall_cmd);
}
- if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " releasing");
+ if (unlock_pages(op, sizeof(dom0_op_t)) < 0)
ret = -1;
- }
if (ret < 0)
return -1;
hc.op = __HYPERVISOR_domctl;
hc.arg[0] = (unsigned long) op;
- if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " locking");
+ if (lock_pages(op, sizeof(dom0_op_t)) < 0)
return -1;
- }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) {
- virXenError(VIR_ERR_XEN_CALL, " ioctl %d",
- xen_ioctl_hypercall_cmd);
+ virReportSystemError(errno,
+ _("Unable to issue hypervisor ioctl %d"),
+ xen_ioctl_hypercall_cmd);
}
- if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " releasing");
+ if (unlock_pages(op, sizeof(dom0_op_t)) < 0)
ret = -1;
- }
if (ret < 0)
return -1;
int ret = -1;
if (lock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos),
- XEN_GETDOMAININFO_SIZE * maxids) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " locking");
+ XEN_GETDOMAININFO_SIZE * maxids) < 0)
return -1;
- }
+
if (hv_versions.hypervisor > 1) {
xen_op_v2_sys op;
ret = op.u.getdomaininfolist.num_domains;
}
if (unlock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos),
- XEN_GETDOMAININFO_SIZE * maxids) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " release");
+ XEN_GETDOMAININFO_SIZE * maxids) < 0)
ret = -1;
- }
+
return ret;
}
if (hv_versions.hypervisor > 1) {
xen_op_v2_dom op;
- if (lock_pages(cpumap, maplen) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " locking");
+ if (lock_pages(cpumap, maplen) < 0)
return -1;
- }
+
memset(&op, 0, sizeof(op));
op.cmd = XEN_V2_OP_SETVCPUMAP;
op.domain = (domid_t) id;
ret = xenHypervisorDoV2Dom(handle, &op);
VIR_FREE(new);
- if (unlock_pages(cpumap, maplen) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " release");
+ if (unlock_pages(cpumap, maplen) < 0)
ret = -1;
- }
} else {
cpumap_t xen_cpumap; /* limited to 64 CPUs in old hypervisors */
uint64_t *pm = &xen_cpumap;
ipt->cpu = op.u.getvcpuinfod5.online ? (int)op.u.getvcpuinfod5.cpu : -1;
}
if ((cpumap != NULL) && (maplen > 0)) {
- if (lock_pages(cpumap, maplen) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " locking");
+ if (lock_pages(cpumap, maplen) < 0)
return -1;
- }
+
memset(cpumap, 0, maplen);
memset(&op, 0, sizeof(op));
op.cmd = XEN_V2_OP_GETVCPUMAP;
op.u.getvcpumapd5.cpumap.nr_cpus = maplen * 8;
}
ret = xenHypervisorDoV2Dom(handle, &op);
- if (unlock_pages(cpumap, maplen) < 0) {
- virXenError(VIR_ERR_XEN_CALL, " release");
+ if (unlock_pages(cpumap, maplen) < 0)
ret = -1;
- }
}
} else {
int mapl = maplen;
*/
hv_versions.hypervisor = -1;
- virXenError(VIR_ERR_XEN_CALL, " ioctl %lu",
- (unsigned long) IOCTL_PRIVCMD_HYPERCALL);
+ virReportSystemError(errno,
+ _("Unable to issue hypervisor ioctl %lu"),
+ (unsigned long)IOCTL_PRIVCMD_HYPERCALL);
VIR_FORCE_CLOSE(fd);
in_init = 0;
return -1;
goto done;
}
+
/*
* we failed to make the getdomaininfolist hypercall
*/
-
- VIR_DEBUG("Failed to find any Xen hypervisor method");
hv_versions.hypervisor = -1;
- virXenError(VIR_ERR_XEN_CALL, " ioctl %lu",
- (unsigned long)IOCTL_PRIVCMD_HYPERCALL);
+ virReportSystemError(errno,
+ _("Unable to issue hypervisor ioctl %lu"),
+ (unsigned long)IOCTL_PRIVCMD_HYPERCALL);
+ VIR_DEBUG("Failed to find any Xen hypervisor method");
VIR_FORCE_CLOSE(fd);
in_init = 0;
VIR_FREE(ipt);