Index: src/proxy_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/proxy_internal.c,v retrieving revision 1.13 diff -c -r1.13 proxy_internal.c *** src/proxy_internal.c 8 Nov 2006 13:53:29 -0000 1.13 --- src/proxy_internal.c 15 Nov 2006 02:34:01 -0000 *************** *** 663,669 **** if (!VIR_IS_CONNECT(conn)) { virProxyError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__); ! return (-1); } memset(&req, 0, sizeof(req)); req.command = VIR_PROXY_MAX_MEMORY; --- 663,669 ---- if (!VIR_IS_CONNECT(conn)) { virProxyError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__); ! return (0); } memset(&req, 0, sizeof(req)); req.command = VIR_PROXY_MAX_MEMORY; *************** *** 672,678 **** ret = xenProxyCommand(conn, &req, NULL, 0); if (ret < 0) { xenProxyClose(conn); ! return(-1); } return(req.data.larg); } --- 672,678 ---- ret = xenProxyCommand(conn, &req, NULL, 0); if (ret < 0) { xenProxyClose(conn); ! return(0); } return(req.data.larg); } *************** *** 695,700 **** --- 695,702 ---- virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); return (0); } + if (domain->handle < 0) + return (0); return(xenProxyDomainGetDomMaxMemory(domain->conn, domain->handle)); } *************** *** 716,730 **** int ret; if (!VIR_IS_CONNECTED_DOMAIN(domain)) { ! if (domain == NULL) ! virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); ! else ! virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); ! return (0); } if (info == NULL) { virProxyError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); ! return (-1); } memset(&req, 0, sizeof(req)); req.command = VIR_PROXY_DOMAIN_INFO; --- 718,734 ---- int ret; if (!VIR_IS_CONNECTED_DOMAIN(domain)) { ! if (domain == NULL) ! virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); ! else ! virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); ! return (-1); } + if (domain->handle < 0) + return (-1); if (info == NULL) { virProxyError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); ! return (-1); } memset(&req, 0, sizeof(req)); req.command = VIR_PROXY_DOMAIN_INFO; *************** *** 733,743 **** ret = xenProxyCommand(domain->conn, &req, &ans, 0); if (ret < 0) { xenProxyClose(domain->conn); ! return(-1); } if (ans.len != sizeof(virProxyPacket) + sizeof(virDomainInfo)) { virProxyError(domain->conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__); ! return (-1); } memmove(info, &ans.extra.dinfo, sizeof(virDomainInfo)); --- 737,747 ---- ret = xenProxyCommand(domain->conn, &req, &ans, 0); if (ret < 0) { xenProxyClose(domain->conn); ! return(-1); } if (ans.len != sizeof(virProxyPacket) + sizeof(virDomainInfo)) { virProxyError(domain->conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__); ! return (-1); } memmove(info, &ans.extra.dinfo, sizeof(virDomainInfo)); *************** *** 960,965 **** --- 964,971 ---- virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); return (NULL); } + if (domain->handle < 0) + return (NULL); memset(&req, 0, sizeof(req)); req.command = VIR_PROXY_DOMAIN_XML; req.data.arg = domain->handle; Index: src/xen_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xen_internal.c,v retrieving revision 1.49 diff -c -r1.49 xen_internal.c *** src/xen_internal.c 16 Oct 2006 16:04:55 -0000 1.49 --- src/xen_internal.c 15 Nov 2006 02:34:03 -0000 *************** *** 1498,1504 **** xenHypervisorGetMaxMemory(virDomainPtr domain) { if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0)) return (0); return(xenHypervisorGetDomMaxMemory(domain->conn, domain->handle)); --- 1498,1504 ---- xenHypervisorGetMaxMemory(virDomainPtr domain) { if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0)) return (0); return(xenHypervisorGetDomMaxMemory(domain->conn, domain->handle)); *************** *** 1597,1602 **** --- 1597,1603 ---- (domain->conn->handle < 0) || (info == NULL) || (domain->handle < 0)) return (-1); + return(xenHypervisorGetDomInfo(domain->conn, domain->handle, info)); } *************** *** 1616,1622 **** int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0)) return (-1); ret = virXen_pausedomain(domain->conn->handle, domain->handle); --- 1617,1623 ---- int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0)) return (-1); ret = virXen_pausedomain(domain->conn->handle, domain->handle); *************** *** 1639,1645 **** int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0)) return (-1); ret = virXen_unpausedomain(domain->conn->handle, domain->handle); --- 1640,1646 ---- int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0)) return (-1); ret = virXen_unpausedomain(domain->conn->handle, domain->handle); *************** *** 1662,1668 **** int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0)) return (-1); ret = virXen_destroydomain(domain->conn->handle, domain->handle); --- 1663,1669 ---- int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0)) return (-1); ret = virXen_destroydomain(domain->conn->handle, domain->handle); *************** *** 1686,1692 **** int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0)) return (-1); ret = virXen_setmaxmem(domain->conn->handle, domain->handle, memory); --- 1687,1693 ---- int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0)) return (-1); ret = virXen_setmaxmem(domain->conn->handle, domain->handle, memory); *************** *** 1713,1719 **** int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (nvcpus < 1)) return (-1); ret = virXen_setmaxvcpus(domain->conn->handle, domain->handle, nvcpus); --- 1714,1721 ---- int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0) || ! (nvcpus < 1)) return (-1); ret = virXen_setmaxvcpus(domain->conn->handle, domain->handle, nvcpus); *************** *** 1741,1747 **** int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (cpumap == NULL) || (maplen < 1)) return (-1); ret = virXen_setvcpumap(domain->conn->handle, domain->handle, vcpu, --- 1743,1750 ---- int ret; if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0) || ! (cpumap == NULL) || (maplen < 1)) return (-1); ret = virXen_setvcpumap(domain->conn->handle, domain->handle, vcpu, *************** *** 1782,1790 **** virVcpuInfoPtr ipt; int nbinfo, i; ! if ((domain == NULL) || (domain->conn == NULL) || (domain->conn->handle < 0) ! || (info == NULL) || (maxinfo < 1) ! || (sizeof(cpumap_t) & 7)) return (-1); if ((cpumaps != NULL) && (maplen < 1)) return -1; --- 1785,1794 ---- virVcpuInfoPtr ipt; int nbinfo, i; ! if ((domain == NULL) || (domain->conn == NULL) || ! (domain->conn->handle < 0) || (domain->handle < 0) || ! (info == NULL) || (maxinfo < 1) || ! (sizeof(cpumap_t) & 7)) return (-1); if ((cpumaps != NULL) && (maplen < 1)) return -1; Index: src/xend_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.c,v retrieving revision 1.74 diff -c -r1.74 xend_internal.c *** src/xend_internal.c 15 Nov 2006 00:38:13 -0000 1.74 --- src/xend_internal.c 15 Nov 2006 02:34:04 -0000 *************** *** 1266,1272 **** return node; } ! static int xend_get_config_version(virConnectPtr conn) { struct sexpr *root; const char *value; --- 1266,1272 ---- return node; } ! int xend_get_config_version(virConnectPtr conn) { struct sexpr *root; const char *value; *************** *** 2075,2080 **** --- 2075,2082 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); return xend_op(domain->conn, domain->name, "op", "pause", NULL); } *************** *** 2095,2100 **** --- 2097,2104 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); return xend_op(domain->conn, domain->name, "op", "unpause", NULL); } *************** *** 2116,2121 **** --- 2120,2127 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "halt", NULL); } *************** *** 2138,2143 **** --- 2144,2151 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "reboot", NULL); } *************** *** 2162,2167 **** --- 2170,2177 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); return xend_op(domain->conn, domain->name, "op", "destroy", NULL); } *************** *** 2187,2192 **** --- 2197,2204 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); return xend_op(domain->conn, domain->name, "op", "save", "file", filename, NULL); } *************** *** 2232,2237 **** --- 2244,2251 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); /* can we ask for a subset ? worth it ? */ root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name); *************** *** 2266,2271 **** --- 2280,2288 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); + snprintf(buf, sizeof(buf), "%lu", memory >> 10); return xend_op(domain->conn, domain->name, "op", "maxmem_set", "memory", buf, NULL); *************** *** 2297,2302 **** --- 2314,2322 ---- __FUNCTION__); return(-1); } + if (domain->handle < 0) + return(-1); + snprintf(buf, sizeof(buf), "%lu", memory >> 10); return xend_op(domain->conn, domain->name, "op", "mem_target_set", "target", buf, NULL); *************** *** 2345,2350 **** --- 2365,2372 ---- __FUNCTION__); return(NULL); } + if (domain->handle < 0) + return(NULL); return xenDaemonDomainDumpXMLByID(domain->conn, domain->handle); } *************** *** 2372,2378 **** __FUNCTION__); return(-1); } ! root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name); if (root == NULL) --- 2394,2401 ---- __FUNCTION__); return(-1); } ! if (domain->handle < 0) ! return(-1); root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name); if (root == NULL) *************** *** 2652,2657 **** --- 2675,2683 ---- __FUNCTION__); return (-1); } + if (domain->handle < 0) + return(-1); + snprintf(buf, sizeof(buf), "%d", vcpus); return(xend_op(domain->conn, domain->name, "op", "set_vcpus", "vcpus", buf, NULL)); *************** *** 2681,2686 **** --- 2707,2714 ---- __FUNCTION__); return (-1); } + if (domain->handle < 0) + return(-1); /* from bit map, build character string of mapped CPU numbers */ for (i = 0; i < maplen; i++) for (j = 0; j < 8; j++) *************** *** 2734,2739 **** --- 2762,2770 ---- __FUNCTION__); return (-1); } + if (domain->handle < 0) + return(-1); + root = sexpr_get(domain->conn, "/xend/domain/%s?op=vcpuinfo", domain->name); if (root == NULL) return (-1); Index: src/xend_internal.h =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.h,v retrieving revision 1.26 diff -c -r1.26 xend_internal.h *** src/xend_internal.h 12 Sep 2006 01:16:22 -0000 1.26 --- src/xend_internal.h 15 Nov 2006 02:34:05 -0000 *************** *** 613,618 **** --- 613,619 ---- */ int xend_log(virConnectPtr xend, char *buffer, size_t n_buffer); + int xend_get_config_version(virConnectPtr conn); char *xend_parse_domain_sexp(virConnectPtr conn, char *root, int xendConfigVersion); /* refactored ones */ Index: src/xs_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xs_internal.c,v retrieving revision 1.21 diff -c -r1.21 xs_internal.c *** src/xs_internal.c 8 Nov 2006 13:53:29 -0000 1.21 --- src/xs_internal.c 15 Nov 2006 02:34:06 -0000 *************** *** 372,377 **** --- 372,379 ---- } if (domain->conn->xshandle == NULL) return(-1); + if (domain->handle == -1) + return(-1); tmp = virDomainDoStoreQuery(domain->conn, domain->handle, "running"); if (tmp != NULL) { *************** *** 430,435 **** --- 432,439 ---- __FUNCTION__); return(-1); } + if (domain->handle == -1) + return(-1); snprintf(value, 19, "%lu", memory); value[19] = 0; ret = virDomainDoStoreWrite(domain, "memory/target", &value[0]); *************** *** 454,459 **** --- 458,465 ---- if (!VIR_IS_CONNECTED_DOMAIN(domain)) return (ret); + if (domain->handle == -1) + return(-1); tmp = virDomainDoStoreQuery(domain->conn, domain->handle, "memory/target"); if (tmp != NULL) { *************** *** 626,631 **** --- 632,639 ---- __FUNCTION__); return(-1); } + if (domain->handle == -1) + return(-1); /* * this is very hackish, the domU kernel probes for a special * node in the xenstore and launch the shutdown command if found. *************** *** 652,657 **** --- 660,667 ---- __FUNCTION__); return(-1); } + if (domain->handle == -1) + return(-1); /* * this is very hackish, the domU kernel probes for a special * node in the xenstore and launch the shutdown command if found.