Thu Nov 15 17:40:15 UTC 2007 Richard W.M. Jones <rjones@redhat.com>

* docs/hvsupport.html, docs/libvir.html: Document HV support
	  for virNodeGetFreeMemory and virNodeGetCellsFreeMemory.
	* src/libvirt.c: Add DEBUG to virNodeGetFreeMemory and
	  virNodeGetCellsFreeMemory.
	* src/xen_internal.c: virXenError* functions now take an
	  additional virConnectPtr argument, and set it where possible.
This commit is contained in:
Richard W.M. Jones 2007-11-15 17:44:06 +00:00
parent 9ae4f3d27e
commit 7a66394fcb
5 changed files with 99 additions and 67 deletions

View File

@ -1,3 +1,12 @@
Thu Nov 15 17:40:15 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* docs/hvsupport.html, docs/libvir.html: Document HV support
for virNodeGetFreeMemory and virNodeGetCellsFreeMemory.
* src/libvirt.c: Add DEBUG to virNodeGetFreeMemory and
virNodeGetCellsFreeMemory.
* src/xen_internal.c: virXenError* functions now take an
additional virConnectPtr argument, and set it where possible.
Thu Nov 15 18:06:15 CET 2007 Daniel Veillard <veillard@redhat.com> Thu Nov 15 18:06:15 CET 2007 Daniel Veillard <veillard@redhat.com>
* docs/libvir.html docs/uri.html: update docs about the libvirt * docs/libvir.html docs/uri.html: update docs about the libvirt

View File

@ -352,12 +352,18 @@ updated on <i>2007-08-20</i>.
<td> &#8805; 0.2.0 </td> <td> &#8805; 0.2.0 </td>
<td> &#8805; 0.2.0 </td> <td> &#8805; 0.2.0 </td>
<td> &#8805; 0.3.0 </td> <td> &#8805; 0.3.0 </td>
</tr><tr><td> virNodeGetFreeMemory </td>
<td> 0.3.3 </td>
<td> &#8805; 0.3.3 </td>
<td> x </td>
<td> x </td>
<td> x </td>
</tr><tr><td> virNodeGetCellsFreeMemory </td> </tr><tr><td> virNodeGetCellsFreeMemory </td>
<td> 0.3.3 </td> <td> 0.3.3 </td>
<td> &#8805; 0.3.3 </td> <td> &#8805; 0.3.3 </td>
<td></td> <td> x </td>
<td></td> <td> x </td>
<td></td> <td> x </td>
</tr></table><h3>Network functions</h3><p> </tr></table><h3>Network functions</h3><p>
Network functions are not hypervisor-specific. For historical Network functions are not hypervisor-specific. For historical
reasons they require the QEMU daemon to be running (this reasons they require the QEMU daemon to be running (this

View File

@ -3257,13 +3257,21 @@ updated on <i>2007-08-20</i>.
<td> &ge; 0.2.0 </td> <td> &ge; 0.2.0 </td>
<td> &ge; 0.3.0 </td> <td> &ge; 0.3.0 </td>
</tr> </tr>
<tr>
<td> virNodeGetFreeMemory </td>
<td> 0.3.3 </td>
<td> &ge; 0.3.3 </td>
<td> x </td>
<td> x </td>
<td> x </td>
</tr>
<tr> <tr>
<td> virNodeGetCellsFreeMemory </td> <td> virNodeGetCellsFreeMemory </td>
<td> 0.3.3 </td> <td> 0.3.3 </td>
<td> &ge; 0.3.3 </td> <td> &ge; 0.3.3 </td>
<td></td> <td> x </td>
<td></td> <td> x </td>
<td></td> <td> x </td>
</tr> </tr>
</table> </table>

View File

@ -2011,6 +2011,8 @@ virConnectGetCapabilities (virConnectPtr conn)
unsigned long long unsigned long long
virNodeGetFreeMemory(virConnectPtr conn) virNodeGetFreeMemory(virConnectPtr conn)
{ {
DEBUG("conn=%p", conn);
if (!VIR_IS_CONNECT (conn)) { if (!VIR_IS_CONNECT (conn)) {
virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
return 0; return 0;
@ -2729,6 +2731,9 @@ int
virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems,
int startCell, int maxCells) int startCell, int maxCells)
{ {
DEBUG("conn=%p, freeMems=%p, startCell=%d, maxCells=%d",
conn, freeMems, startCell, maxCells);
if (!VIR_IS_CONNECT(conn)) { if (!VIR_IS_CONNECT(conn)) {
virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__); virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
return (-1); return (-1);

View File

@ -722,6 +722,7 @@ struct xenUnifiedDriver xenHypervisorDriver = {
/** /**
* virXenError: * virXenError:
* @conn: connection, if known
* @error: the error number * @error: the error number
* @info: extra information string * @info: extra information string
* @value: extra information number * @value: extra information number
@ -729,7 +730,8 @@ struct xenUnifiedDriver xenHypervisorDriver = {
* Handle an error at the xend daemon interface * Handle an error at the xend daemon interface
*/ */
static void static void
virXenError(virErrorNumber error, const char *info, int value) virXenError(virConnectPtr conn,
virErrorNumber error, const char *info, int value)
{ {
const char *errmsg; const char *errmsg;
@ -737,7 +739,7 @@ virXenError(virErrorNumber error, const char *info, int value)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(NULL, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info, value); errmsg, info, NULL, value, 0, errmsg, info, value);
} }
@ -745,6 +747,7 @@ virXenError(virErrorNumber error, const char *info, int value)
/** /**
* virXenErrorFunc: * virXenErrorFunc:
* @conn: connection, if known
* @error: the error number * @error: the error number
* @func: the function failing * @func: the function failing
* @info: extra information string * @info: extra information string
@ -753,7 +756,8 @@ virXenError(virErrorNumber error, const char *info, int value)
* Handle an error at the xend daemon interface * Handle an error at the xend daemon interface
*/ */
static void static void
virXenErrorFunc(virErrorNumber error, const char *func, const char *info, virXenErrorFunc(virConnectPtr conn,
virErrorNumber error, const char *func, const char *info,
int value) int value)
{ {
char fullinfo[1000]; char fullinfo[1000];
@ -767,11 +771,11 @@ virXenErrorFunc(virErrorNumber error, const char *func, const char *info,
if (func != NULL) { if (func != NULL) {
snprintf(fullinfo, 999, "%s: %s", func, info); snprintf(fullinfo, 999, "%s: %s", func, info);
fullinfo[999] = 0; fullinfo[999] = 0;
__virRaiseError(NULL, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, fullinfo, NULL, value, 0, errmsg, fullinfo, errmsg, fullinfo, NULL, value, 0, errmsg, fullinfo,
value); value);
} else { } else {
__virRaiseError(NULL, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info, errmsg, info, NULL, value, 0, errmsg, info,
value); value);
} }
@ -825,17 +829,17 @@ xenHypervisorDoV0Op(int handle, xen_op_v0 * op)
hc.arg[0] = (unsigned long) op; hc.arg[0] = (unsigned long) op;
if (lock_pages(op, sizeof(dom0_op_t)) < 0) { if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " locking", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " locking", sizeof(*op));
return (-1); return (-1);
} }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) { if (ret < 0) {
virXenError(VIR_ERR_XEN_CALL, " ioctl ", xen_ioctl_hypercall_cmd); virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", xen_ioctl_hypercall_cmd);
} }
if (unlock_pages(op, sizeof(dom0_op_t)) < 0) { if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op));
ret = -1; ret = -1;
} }
@ -866,17 +870,17 @@ xenHypervisorDoV1Op(int handle, xen_op_v1* op)
hc.arg[0] = (unsigned long) op; hc.arg[0] = (unsigned long) op;
if (lock_pages(op, sizeof(dom0_op_t)) < 0) { if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " locking", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " locking", sizeof(*op));
return (-1); return (-1);
} }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) { if (ret < 0) {
virXenError(VIR_ERR_XEN_CALL, " ioctl ", xen_ioctl_hypercall_cmd); virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", xen_ioctl_hypercall_cmd);
} }
if (unlock_pages(op, sizeof(dom0_op_t)) < 0) { if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op));
ret = -1; ret = -1;
} }
@ -908,17 +912,17 @@ xenHypervisorDoV2Sys(int handle, xen_op_v2_sys* op)
hc.arg[0] = (unsigned long) op; hc.arg[0] = (unsigned long) op;
if (lock_pages(op, sizeof(dom0_op_t)) < 0) { if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " locking", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " locking", sizeof(*op));
return (-1); return (-1);
} }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) { if (ret < 0) {
virXenError(VIR_ERR_XEN_CALL, " sys ioctl ", xen_ioctl_hypercall_cmd); virXenError(NULL, VIR_ERR_XEN_CALL, " sys ioctl ", xen_ioctl_hypercall_cmd);
} }
if (unlock_pages(op, sizeof(dom0_op_t)) < 0) { if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op));
ret = -1; ret = -1;
} }
@ -950,17 +954,17 @@ xenHypervisorDoV2Dom(int handle, xen_op_v2_dom* op)
hc.arg[0] = (unsigned long) op; hc.arg[0] = (unsigned long) op;
if (lock_pages(op, sizeof(dom0_op_t)) < 0) { if (lock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " locking", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " locking", sizeof(*op));
return (-1); return (-1);
} }
ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc);
if (ret < 0) { if (ret < 0) {
virXenError(VIR_ERR_XEN_CALL, " ioctl ", xen_ioctl_hypercall_cmd); virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", xen_ioctl_hypercall_cmd);
} }
if (unlock_pages(op, sizeof(dom0_op_t)) < 0) { if (unlock_pages(op, sizeof(dom0_op_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op));
ret = -1; ret = -1;
} }
@ -989,7 +993,7 @@ virXen_getdomaininfolist(int handle, int first_domain, int maxids,
if (lock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos), if (lock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos),
XEN_GETDOMAININFO_SIZE * maxids) < 0) { XEN_GETDOMAININFO_SIZE * maxids) < 0) {
virXenError(VIR_ERR_XEN_CALL, " locking", virXenError(NULL, VIR_ERR_XEN_CALL, " locking",
XEN_GETDOMAININFO_SIZE * maxids); XEN_GETDOMAININFO_SIZE * maxids);
return (-1); return (-1);
} }
@ -1045,7 +1049,7 @@ virXen_getdomaininfolist(int handle, int first_domain, int maxids,
} }
if (unlock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos), if (unlock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos),
XEN_GETDOMAININFO_SIZE * maxids) < 0) { XEN_GETDOMAININFO_SIZE * maxids) < 0) {
virXenError(VIR_ERR_XEN_CALL, " release", virXenError(NULL, VIR_ERR_XEN_CALL, " release",
XEN_GETDOMAININFO_SIZE * maxids); XEN_GETDOMAININFO_SIZE * maxids);
ret = -1; ret = -1;
} }
@ -1084,14 +1088,14 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams)
xenUnifiedPrivatePtr priv; xenUnifiedPrivatePtr priv;
if ((domain == NULL) || (domain->conn == NULL)) { if ((domain == NULL) || (domain->conn == NULL)) {
virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, virXenErrorFunc(NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"domain or conn is NULL", 0); "domain or conn is NULL", 0);
return NULL; return NULL;
} }
priv = (xenUnifiedPrivatePtr) domain->conn->privateData; priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->handle < 0 || domain->id < 0) { if (priv->handle < 0 || domain->id < 0) {
virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"priv->handle or domain->id invalid", 0); "priv->handle or domain->id invalid", 0);
return NULL; return NULL;
} }
@ -1102,7 +1106,7 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams)
* TODO: check on Xen 3.0.3 * TODO: check on Xen 3.0.3
*/ */
if (dom_interface_version < 5) { if (dom_interface_version < 5) {
virXenErrorFunc(VIR_ERR_NO_XEN, __FUNCTION__, virXenErrorFunc(domain->conn, VIR_ERR_NO_XEN, __FUNCTION__,
"unsupported in dom interface < 5", 0); "unsupported in dom interface < 5", 0);
return NULL; return NULL;
} }
@ -1159,14 +1163,14 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
xenUnifiedPrivatePtr priv; xenUnifiedPrivatePtr priv;
if ((domain == NULL) || (domain->conn == NULL)) { if ((domain == NULL) || (domain->conn == NULL)) {
virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, virXenErrorFunc(NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"domain or conn is NULL", 0); "domain or conn is NULL", 0);
return -1; return -1;
} }
priv = (xenUnifiedPrivatePtr) domain->conn->privateData; priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->handle < 0 || domain->id < 0) { if (priv->handle < 0 || domain->id < 0) {
virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, virXenErrorFunc(domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"priv->handle or domain->id invalid", 0); "priv->handle or domain->id invalid", 0);
return -1; return -1;
} }
@ -1177,7 +1181,7 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
* TODO: check on Xen 3.0.3 * TODO: check on Xen 3.0.3
*/ */
if (dom_interface_version < 5) { if (dom_interface_version < 5) {
virXenErrorFunc(VIR_ERR_NO_XEN, __FUNCTION__, virXenErrorFunc(domain->conn, VIR_ERR_NO_XEN, __FUNCTION__,
"unsupported in dom interface < 5", 0); "unsupported in dom interface < 5", 0);
return -1; return -1;
} }
@ -1223,7 +1227,7 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain,
*nparams = 2; *nparams = 2;
break; break;
default: default:
virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Unknown scheduler", op_sys.u.getschedulerid.sched_id); "Unknown scheduler", op_sys.u.getschedulerid.sched_id);
return -1; return -1;
} }
@ -1251,20 +1255,20 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
char buf[256]; char buf[256];
if ((domain == NULL) || (domain->conn == NULL)) { if ((domain == NULL) || (domain->conn == NULL)) {
virXenErrorFunc (VIR_ERR_INTERNAL_ERROR, __FUNCTION__, virXenErrorFunc (NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"domain or conn is NULL", 0); "domain or conn is NULL", 0);
return -1; return -1;
} }
if ((nparams == 0) || (params == NULL)) { if ((nparams == 0) || (params == NULL)) {
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Noparameters given", 0); "Noparameters given", 0);
return(-1); return(-1);
} }
priv = (xenUnifiedPrivatePtr) domain->conn->privateData; priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->handle < 0 || domain->id < 0) { if (priv->handle < 0 || domain->id < 0) {
virXenErrorFunc (VIR_ERR_INTERNAL_ERROR, __FUNCTION__, virXenErrorFunc (domain->conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"priv->handle or domain->id invalid", 0); "priv->handle or domain->id invalid", 0);
return -1; return -1;
} }
@ -1275,7 +1279,7 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
* TODO: check on Xen 3.0.3 * TODO: check on Xen 3.0.3
*/ */
if (dom_interface_version < 5) { if (dom_interface_version < 5) {
virXenErrorFunc(VIR_ERR_NO_XEN, __FUNCTION__, virXenErrorFunc(domain->conn, VIR_ERR_NO_XEN, __FUNCTION__,
"unsupported in dom interface < 5", 0); "unsupported in dom interface < 5", 0);
return -1; return -1;
} }
@ -1319,7 +1323,7 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
val = params[i].value.ui; val = params[i].value.ui;
if ((val < 1) || (val > USHRT_MAX)) { if ((val < 1) || (val > USHRT_MAX)) {
snprintf(buf, sizeof(buf), _("Credit scheduler weight parameter (%d) is out of range (1-65535)"), val); snprintf(buf, sizeof(buf), _("Credit scheduler weight parameter (%d) is out of range (1-65535)"), val);
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val); virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val);
return(-1); return(-1);
} }
op_dom.u.getschedinfo.u.credit.weight = val; op_dom.u.getschedinfo.u.credit.weight = val;
@ -1329,13 +1333,13 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
val = params[i].value.ui; val = params[i].value.ui;
if (val > USHRT_MAX) { if (val > USHRT_MAX) {
snprintf(buf, sizeof(buf), _("Credit scheduler cap parameter (%d) is out of range (0-65535)"), val); snprintf(buf, sizeof(buf), _("Credit scheduler cap parameter (%d) is out of range (0-65535)"), val);
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val); virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val);
return(-1); return(-1);
} }
op_dom.u.getschedinfo.u.credit.cap = val; op_dom.u.getschedinfo.u.credit.cap = val;
cap_set = 1; cap_set = 1;
} else { } else {
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Credit scheduler accepts 'cap' and 'weight' integer parameters", "Credit scheduler accepts 'cap' and 'weight' integer parameters",
0); 0);
return(-1); return(-1);
@ -1348,7 +1352,7 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain,
break; break;
} }
default: default:
virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"Unknown scheduler", op_sys.u.getschedulerid.sched_id); "Unknown scheduler", op_sys.u.getschedulerid.sched_id);
return -1; return -1;
} }
@ -1369,7 +1373,7 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
priv = (xenUnifiedPrivatePtr) dom->conn->privateData; priv = (xenUnifiedPrivatePtr) dom->conn->privateData;
return xenLinuxDomainBlockStats (priv, dom, path, stats); return xenLinuxDomainBlockStats (priv, dom, path, stats);
#else #else
virXenErrorFunc (VIR_ERR_NO_SUPPORT, __FUNCTION__, virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__,
"block statistics not supported on this platform", "block statistics not supported on this platform",
dom->id); dom->id);
return -1; return -1;
@ -1395,19 +1399,19 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
* domain. * domain.
*/ */
if (sscanf (path, "vif%d.%d", &rqdomid, &device) != 2) { if (sscanf (path, "vif%d.%d", &rqdomid, &device) != 2) {
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc (dom->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, should be vif<domid>.<n>.", 0); "invalid path, should be vif<domid>.<n>.", 0);
return -1; return -1;
} }
if (rqdomid != dom->id) { if (rqdomid != dom->id) {
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc (dom->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, vif<domid> should match this domain ID", 0); "invalid path, vif<domid> should match this domain ID", 0);
return -1; return -1;
} }
return linuxDomainInterfaceStats (dom->conn, path, stats); return linuxDomainInterfaceStats (dom->conn, path, stats);
#else #else
virXenErrorFunc (VIR_ERR_NO_SUPPORT, __FUNCTION__, virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__,
"/proc/net/dev: Interface not found", 0); "/proc/net/dev: Interface not found", 0);
return -1; return -1;
#endif #endif
@ -1641,7 +1645,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
xen_op_v2_dom op; xen_op_v2_dom op;
if (lock_pages(cpumap, maplen) < 0) { if (lock_pages(cpumap, maplen) < 0) {
virXenError(VIR_ERR_XEN_CALL, " locking", maplen); virXenError(NULL, VIR_ERR_XEN_CALL, " locking", maplen);
return (-1); return (-1);
} }
memset(&op, 0, sizeof(op)); memset(&op, 0, sizeof(op));
@ -1659,7 +1663,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
ret = xenHypervisorDoV2Dom(handle, &op); ret = xenHypervisorDoV2Dom(handle, &op);
if (unlock_pages(cpumap, maplen) < 0) { if (unlock_pages(cpumap, maplen) < 0) {
virXenError(VIR_ERR_XEN_CALL, " release", maplen); virXenError(NULL, VIR_ERR_XEN_CALL, " release", maplen);
ret = -1; ret = -1;
} }
} else { } else {
@ -1756,7 +1760,7 @@ virXen_getvcpusinfo(int handle, int id, unsigned int vcpu, virVcpuInfoPtr ipt,
} }
if ((cpumap != NULL) && (maplen > 0)) { if ((cpumap != NULL) && (maplen > 0)) {
if (lock_pages(cpumap, maplen) < 0) { if (lock_pages(cpumap, maplen) < 0) {
virXenError(VIR_ERR_XEN_CALL, " locking", maplen); virXenError(NULL, VIR_ERR_XEN_CALL, " locking", maplen);
return (-1); return (-1);
} }
memset(cpumap, 0, maplen); memset(cpumap, 0, maplen);
@ -1774,7 +1778,7 @@ virXen_getvcpusinfo(int handle, int id, unsigned int vcpu, virVcpuInfoPtr ipt,
} }
ret = xenHypervisorDoV2Dom(handle, &op); ret = xenHypervisorDoV2Dom(handle, &op);
if (unlock_pages(cpumap, maplen) < 0) { if (unlock_pages(cpumap, maplen) < 0) {
virXenError(VIR_ERR_XEN_CALL, " release", maplen); virXenError(NULL, VIR_ERR_XEN_CALL, " release", maplen);
ret = -1; ret = -1;
} }
} }
@ -1870,7 +1874,7 @@ xenHypervisorInit(void)
char error[100]; char error[100];
regerror (errcode, &flags_hvm_rec, error, sizeof error); regerror (errcode, &flags_hvm_rec, error, sizeof error);
regfree (&flags_hvm_rec); regfree (&flags_hvm_rec);
virXenError (VIR_ERR_INTERNAL_ERROR, error, 0); virXenError (NULL, VIR_ERR_INTERNAL_ERROR, error, 0);
in_init = 0; in_init = 0;
return -1; return -1;
} }
@ -1880,7 +1884,7 @@ xenHypervisorInit(void)
regerror (errcode, &flags_pae_rec, error, sizeof error); regerror (errcode, &flags_pae_rec, error, sizeof error);
regfree (&flags_pae_rec); regfree (&flags_pae_rec);
regfree (&flags_hvm_rec); regfree (&flags_hvm_rec);
virXenError (VIR_ERR_INTERNAL_ERROR, error, 0); virXenError (NULL, VIR_ERR_INTERNAL_ERROR, error, 0);
in_init = 0; in_init = 0;
return -1; return -1;
} }
@ -1891,7 +1895,7 @@ xenHypervisorInit(void)
regfree (&xen_cap_rec); regfree (&xen_cap_rec);
regfree (&flags_pae_rec); regfree (&flags_pae_rec);
regfree (&flags_hvm_rec); regfree (&flags_hvm_rec);
virXenError (VIR_ERR_INTERNAL_ERROR, error, 0); virXenError (NULL, VIR_ERR_INTERNAL_ERROR, error, 0);
in_init = 0; in_init = 0;
return -1; return -1;
} }
@ -1949,7 +1953,7 @@ xenHypervisorInit(void)
*/ */
hypervisor_version = -1; hypervisor_version = -1;
virXenError(VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL); virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL);
close(fd); close(fd);
in_init = 0; in_init = 0;
return(-1); return(-1);
@ -2028,7 +2032,7 @@ xenHypervisorInit(void)
*/ */
hypervisor_version = -1; hypervisor_version = -1;
virXenError(VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL); virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL);
close(fd); close(fd);
in_init = 0; in_init = 0;
if (ipt) if (ipt)
@ -2069,7 +2073,7 @@ xenHypervisorOpen(virConnectPtr conn,
ret = open(XEN_HYPERVISOR_SOCKET, O_RDWR); ret = open(XEN_HYPERVISOR_SOCKET, O_RDWR);
if (ret < 0) { if (ret < 0) {
virXenError(VIR_ERR_NO_XEN, XEN_HYPERVISOR_SOCKET, 0); virXenError(conn, VIR_ERR_NO_XEN, XEN_HYPERVISOR_SOCKET, 0);
return (-1); return (-1);
} }
@ -2123,7 +2127,7 @@ static const char *
xenHypervisorGetType(virConnectPtr conn) xenHypervisorGetType(virConnectPtr conn)
{ {
if (!VIR_IS_CONNECT(conn)) { if (!VIR_IS_CONNECT(conn)) {
virXenError(VIR_ERR_INVALID_CONN, __FUNCTION__, 0); virXenError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__, 0);
return (NULL); return (NULL);
} }
return("Xen"); return("Xen");
@ -2162,7 +2166,7 @@ xenHypervisorGetVersion(virConnectPtr conn, unsigned long *hvVer)
* Return the capabilities of this hypervisor. * Return the capabilities of this hypervisor.
*/ */
char * char *
xenHypervisorMakeCapabilitiesXML(virConnectPtr conn ATTRIBUTE_UNUSED, xenHypervisorMakeCapabilitiesXML(virConnectPtr conn,
const char *hostmachine, const char *hostmachine,
FILE *cpuinfo, FILE *capabilities) FILE *cpuinfo, FILE *capabilities)
{ {
@ -2308,7 +2312,7 @@ xenHypervisorMakeCapabilitiesXML(virConnectPtr conn ATTRIBUTE_UNUSED,
/* Construct the final XML. */ /* Construct the final XML. */
xml = virBufferNew (1024); xml = virBufferNew (1024);
if (!xml) { if (!xml) {
virXenError(VIR_ERR_NO_MEMORY, __FUNCTION__, 0); virXenError(conn, VIR_ERR_NO_MEMORY, __FUNCTION__, 0);
return NULL; return NULL;
} }
r = virBufferVSprintf (xml, r = virBufferVSprintf (xml,
@ -2425,7 +2429,7 @@ xenHypervisorMakeCapabilitiesXML(virConnectPtr conn ATTRIBUTE_UNUSED,
return xml_str; return xml_str;
vir_buffer_failed: vir_buffer_failed:
virXenError(VIR_ERR_NO_MEMORY, __FUNCTION__, 0); virXenError(conn, VIR_ERR_NO_MEMORY, __FUNCTION__, 0);
topology_failed: topology_failed:
virBufferFree (xml); virBufferFree (xml);
return NULL; return NULL;
@ -2499,7 +2503,7 @@ xenHypervisorNumOfDomains(virConnectPtr conn)
retry: retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
virXenError(VIR_ERR_NO_MEMORY, _("allocating %d domain info"), virXenError(conn, VIR_ERR_NO_MEMORY, _("allocating %d domain info"),
maxids); maxids);
return(-1); return(-1);
} }
@ -2558,7 +2562,7 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
return (-1); return (-1);
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
virXenError(VIR_ERR_NO_MEMORY, "allocating %d domain info", virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info",
maxids); maxids);
return(-1); return(-1);
} }
@ -2666,7 +2670,7 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn,
retry: retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
virXenError(VIR_ERR_NO_MEMORY, "allocating %d domain info", virXenError(conn, VIR_ERR_NO_MEMORY, "allocating %d domain info",
maxids); maxids);
return(NULL); return(NULL);
} }
@ -2942,20 +2946,20 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *free
int nbNodeCells; int nbNodeCells;
if (conn == NULL) { if (conn == NULL) {
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid argument", 0); "invalid argument", 0);
return -1; return -1;
} }
nbNodeCells = xenNbCells(conn); nbNodeCells = xenNbCells(conn);
if (nbNodeCells < 0) { if (nbNodeCells < 0) {
virXenErrorFunc (VIR_ERR_XEN_CALL, __FUNCTION__, virXenErrorFunc (conn, VIR_ERR_XEN_CALL, __FUNCTION__,
"cannot determine actual number of cells",0); "cannot determine actual number of cells",0);
return(-1); return(-1);
} }
if ((maxCells < 1) || (startCell >= nbNodeCells)) { if ((maxCells < 1) || (startCell >= nbNodeCells)) {
virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, virXenErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid argument", 0); "invalid argument", 0);
return -1; return -1;
} }
@ -2964,14 +2968,14 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *free
* Support only sys_interface_version >=4 * Support only sys_interface_version >=4
*/ */
if (sys_interface_version < 4) { if (sys_interface_version < 4) {
virXenErrorFunc (VIR_ERR_XEN_CALL, __FUNCTION__, virXenErrorFunc (conn, VIR_ERR_XEN_CALL, __FUNCTION__,
"unsupported in sys interface < 4", 0); "unsupported in sys interface < 4", 0);
return -1; return -1;
} }
priv = (xenUnifiedPrivatePtr) conn->privateData; priv = (xenUnifiedPrivatePtr) conn->privateData;
if (priv->handle < 0) { if (priv->handle < 0) {
virXenErrorFunc (VIR_ERR_INTERNAL_ERROR, __FUNCTION__, virXenErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"priv->handle invalid", 0); "priv->handle invalid", 0);
return -1; return -1;
} }