Same patch, just rebased to the latest libvirt CVS. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
Index: docs/libvir.html =================================================================== RCS file: /data/cvs/libvirt/docs/libvir.html,v retrieving revision 1.91 diff -u -r1.91 libvir.html --- docs/libvir.html 14 Nov 2007 17:11:19 -0000 1.91 +++ docs/libvir.html 15 Nov 2007 14:11:15 -0000 @@ -3262,12 +3262,20 @@ <td> ≥ 0.3.0 </td> </tr> <tr> + <td> virNodeGetFreeMemory </td> + <td> 0.3.3 </td> + <td> ≥ 0.3.3 </td> + <td> x </td> + <td> x </td> + <td> x </td> +</tr> +<tr> <td> virNodeGetCellsFreeMemory </td> <td> 0.3.3 </td> <td> ≥ 0.3.3 </td> - <td></td> - <td></td> - <td></td> + <td> x </td> + <td> x </td> + <td> x </td> </tr> </table> Index: src/libvirt.c =================================================================== RCS file: /data/cvs/libvirt/src/libvirt.c,v retrieving revision 1.105 diff -u -r1.105 libvirt.c --- src/libvirt.c 14 Nov 2007 11:40:57 -0000 1.105 +++ src/libvirt.c 15 Nov 2007 14:11:17 -0000 @@ -2011,6 +2011,8 @@ unsigned long long virNodeGetFreeMemory(virConnectPtr conn) { + DEBUG("conn=%p", conn); + if (!VIR_IS_CONNECT (conn)) { virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); return 0; @@ -2729,6 +2731,9 @@ virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, int startCell, int maxCells) { + DEBUG("conn=%p, freeMems=%p, startCell=%d, maxCells=%d", + conn, freeMems, startCell, maxCells); + if (!VIR_IS_CONNECT(conn)) { virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__); return (-1); Index: src/xen_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xen_internal.c,v retrieving revision 1.101 diff -u -r1.101 xen_internal.c --- src/xen_internal.c 14 Nov 2007 11:58:36 -0000 1.101 +++ src/xen_internal.c 15 Nov 2007 14:11:19 -0000 @@ -722,6 +722,7 @@ /** * virXenError: + * @conn: connection, if known * @error: the error number * @info: extra information string * @value: extra information number @@ -729,7 +730,8 @@ * Handle an error at the xend daemon interface */ static void -virXenError(virErrorNumber error, const char *info, int value) +virXenError(virConnectPtr conn, + virErrorNumber error, const char *info, int value) { const char *errmsg; @@ -737,7 +739,7 @@ return; 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); } @@ -745,6 +747,7 @@ /** * virXenErrorFunc: + * @conn: connection, if known * @error: the error number * @func: the function failing * @info: extra information string @@ -753,7 +756,8 @@ * Handle an error at the xend daemon interface */ static void -virXenErrorFunc(virErrorNumber error, const char *func, const char *info, +virXenErrorFunc(virConnectPtr conn, + virErrorNumber error, const char *func, const char *info, int value) { char fullinfo[1000]; @@ -767,11 +771,11 @@ if (func != NULL) { snprintf(fullinfo, 999, "%s: %s", func, info); 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, value); } 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, value); } @@ -825,17 +829,17 @@ hc.arg[0] = (unsigned long) op; 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); } ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); 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) { - virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); + virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); ret = -1; } @@ -866,17 +870,17 @@ hc.arg[0] = (unsigned long) op; 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); } ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); 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) { - virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); + virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); ret = -1; } @@ -908,17 +912,17 @@ hc.arg[0] = (unsigned long) op; 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); } ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); 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) { - virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); + virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); ret = -1; } @@ -950,17 +954,17 @@ hc.arg[0] = (unsigned long) op; 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); } ret = ioctl(handle, xen_ioctl_hypercall_cmd, (unsigned long) &hc); 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) { - virXenError(VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); + virXenError(NULL, VIR_ERR_XEN_CALL, " releasing", sizeof(*op)); ret = -1; } @@ -989,7 +993,7 @@ if (lock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos), XEN_GETDOMAININFO_SIZE * maxids) < 0) { - virXenError(VIR_ERR_XEN_CALL, " locking", + virXenError(NULL, VIR_ERR_XEN_CALL, " locking", XEN_GETDOMAININFO_SIZE * maxids); return (-1); } @@ -1045,7 +1049,7 @@ } if (unlock_pages(XEN_GETDOMAININFOLIST_DATA(dominfos), XEN_GETDOMAININFO_SIZE * maxids) < 0) { - virXenError(VIR_ERR_XEN_CALL, " release", + virXenError(NULL, VIR_ERR_XEN_CALL, " release", XEN_GETDOMAININFO_SIZE * maxids); ret = -1; } @@ -1084,14 +1088,14 @@ xenUnifiedPrivatePtr priv; 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); return NULL; } priv = (xenUnifiedPrivatePtr) domain->conn->privateData; 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); return NULL; } @@ -1102,7 +1106,7 @@ * TODO: check on Xen 3.0.3 */ 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); return NULL; } @@ -1159,14 +1163,14 @@ xenUnifiedPrivatePtr priv; 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); return -1; } priv = (xenUnifiedPrivatePtr) domain->conn->privateData; 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); return -1; } @@ -1177,7 +1181,7 @@ * TODO: check on Xen 3.0.3 */ 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); return -1; } @@ -1223,7 +1227,7 @@ *nparams = 2; break; default: - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, + virXenErrorFunc(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, "Unknown scheduler", op_sys.u.getschedulerid.sched_id); return -1; } @@ -1251,20 +1255,20 @@ char buf[256]; 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); return -1; } if ((nparams == 0) || (params == NULL)) { - virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, + virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, "Noparameters given", 0); return(-1); } priv = (xenUnifiedPrivatePtr) domain->conn->privateData; 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); return -1; } @@ -1275,7 +1279,7 @@ * TODO: check on Xen 3.0.3 */ 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); return -1; } @@ -1319,7 +1323,7 @@ val = params[i].value.ui; if ((val < 1) || (val > USHRT_MAX)) { 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); } op_dom.u.getschedinfo.u.credit.weight = val; @@ -1329,14 +1333,14 @@ val = params[i].value.ui; if (val > USHRT_MAX) { 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); } op_dom.u.getschedinfo.u.credit.cap = val; cap_set = 1; } else { - virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, - "Credit scheduler accepts 'cap' and 'weight' integer parameters", + virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, + "Credit scheduler accepts 'cap' and 'weight' integer parameters", 0); return(-1); } @@ -1348,7 +1352,7 @@ break; } default: - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, + virXenErrorFunc(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__, "Unknown scheduler", op_sys.u.getschedulerid.sched_id); return -1; } @@ -1369,7 +1373,7 @@ priv = (xenUnifiedPrivatePtr) dom->conn->privateData; return xenLinuxDomainBlockStats (priv, dom, path, stats); #else - virXenErrorFunc (VIR_ERR_NO_SUPPORT, __FUNCTION__, + virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__, "block statistics not supported on this platform", dom->id); return -1; @@ -1395,19 +1399,19 @@ * domain. */ 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); return -1; } 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); return -1; } return linuxDomainInterfaceStats (dom->conn, path, stats); #else - virXenErrorFunc (VIR_ERR_NO_SUPPORT, __FUNCTION__, + virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__, "/proc/net/dev: Interface not found", 0); return -1; #endif @@ -1641,7 +1645,7 @@ xen_op_v2_dom op; if (lock_pages(cpumap, maplen) < 0) { - virXenError(VIR_ERR_XEN_CALL, " locking", maplen); + virXenError(NULL, VIR_ERR_XEN_CALL, " locking", maplen); return (-1); } memset(&op, 0, sizeof(op)); @@ -1659,7 +1663,7 @@ ret = xenHypervisorDoV2Dom(handle, &op); if (unlock_pages(cpumap, maplen) < 0) { - virXenError(VIR_ERR_XEN_CALL, " release", maplen); + virXenError(NULL, VIR_ERR_XEN_CALL, " release", maplen); ret = -1; } } else { @@ -1756,7 +1760,7 @@ } if ((cpumap != NULL) && (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); } memset(cpumap, 0, maplen); @@ -1774,7 +1778,7 @@ } ret = xenHypervisorDoV2Dom(handle, &op); if (unlock_pages(cpumap, maplen) < 0) { - virXenError(VIR_ERR_XEN_CALL, " release", maplen); + virXenError(NULL, VIR_ERR_XEN_CALL, " release", maplen); ret = -1; } } @@ -1870,7 +1874,7 @@ char error[100]; regerror (errcode, &flags_hvm_rec, error, sizeof error); regfree (&flags_hvm_rec); - virXenError (VIR_ERR_INTERNAL_ERROR, error, 0); + virXenError (NULL, VIR_ERR_INTERNAL_ERROR, error, 0); in_init = 0; return -1; } @@ -1880,7 +1884,7 @@ regerror (errcode, &flags_pae_rec, error, sizeof error); regfree (&flags_pae_rec); regfree (&flags_hvm_rec); - virXenError (VIR_ERR_INTERNAL_ERROR, error, 0); + virXenError (NULL, VIR_ERR_INTERNAL_ERROR, error, 0); in_init = 0; return -1; } @@ -1891,7 +1895,7 @@ regfree (&xen_cap_rec); regfree (&flags_pae_rec); regfree (&flags_hvm_rec); - virXenError (VIR_ERR_INTERNAL_ERROR, error, 0); + virXenError (NULL, VIR_ERR_INTERNAL_ERROR, error, 0); in_init = 0; return -1; } @@ -1949,7 +1953,7 @@ */ hypervisor_version = -1; - virXenError(VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL); + virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL); close(fd); in_init = 0; return(-1); @@ -2028,7 +2032,7 @@ */ hypervisor_version = -1; - virXenError(VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL); + virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL); close(fd); in_init = 0; if (ipt) @@ -2069,7 +2073,7 @@ ret = open(XEN_HYPERVISOR_SOCKET, O_RDWR); if (ret < 0) { - virXenError(VIR_ERR_NO_XEN, XEN_HYPERVISOR_SOCKET, 0); + virXenError(conn, VIR_ERR_NO_XEN, XEN_HYPERVISOR_SOCKET, 0); return (-1); } @@ -2123,7 +2127,7 @@ xenHypervisorGetType(virConnectPtr conn) { if (!VIR_IS_CONNECT(conn)) { - virXenError(VIR_ERR_INVALID_CONN, __FUNCTION__, 0); + virXenError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__, 0); return (NULL); } return("Xen"); @@ -2162,7 +2166,7 @@ * Return the capabilities of this hypervisor. */ char * -xenHypervisorMakeCapabilitiesXML(virConnectPtr conn ATTRIBUTE_UNUSED, +xenHypervisorMakeCapabilitiesXML(virConnectPtr conn, const char *hostmachine, FILE *cpuinfo, FILE *capabilities) { @@ -2308,7 +2312,7 @@ /* Construct the final XML. */ xml = virBufferNew (1024); if (!xml) { - virXenError(VIR_ERR_NO_MEMORY, __FUNCTION__, 0); + virXenError(conn, VIR_ERR_NO_MEMORY, __FUNCTION__, 0); return NULL; } r = virBufferVSprintf (xml, @@ -2425,7 +2429,7 @@ return xml_str; vir_buffer_failed: - virXenError(VIR_ERR_NO_MEMORY, __FUNCTION__, 0); + virXenError(conn, VIR_ERR_NO_MEMORY, __FUNCTION__, 0); topology_failed: virBufferFree (xml); return NULL; @@ -2499,7 +2503,7 @@ retry: 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); return(-1); } @@ -2558,7 +2562,7 @@ return (-1); 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); return(-1); } @@ -2666,7 +2670,7 @@ retry: 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); return(NULL); } @@ -2942,20 +2946,20 @@ int nbNodeCells; if (conn == NULL) { - virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, + virXenErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__, "invalid argument", 0); return -1; } nbNodeCells = xenNbCells(conn); if (nbNodeCells < 0) { - virXenErrorFunc (VIR_ERR_XEN_CALL, __FUNCTION__, + virXenErrorFunc (conn, VIR_ERR_XEN_CALL, __FUNCTION__, "cannot determine actual number of cells",0); return(-1); } if ((maxCells < 1) || (startCell >= nbNodeCells)) { - virXenErrorFunc (VIR_ERR_INVALID_ARG, __FUNCTION__, + virXenErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__, "invalid argument", 0); return -1; } @@ -2964,14 +2968,14 @@ * Support only 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); return -1; } priv = (xenUnifiedPrivatePtr) conn->privateData; if (priv->handle < 0) { - virXenErrorFunc (VIR_ERR_INTERNAL_ERROR, __FUNCTION__, + virXenErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__, "priv->handle invalid", 0); return -1; }
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list