diff --git a/ChangeLog b/ChangeLog index 05df555485ea3ed4ab6dcab5627c0d24e4e5d7bf..56a9108582a5a5a7fa427e28c3f6052de0be1303 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 30 18:02:00 BST 2007 Richard W.M. Jones + + * src/proxy_internal.c (xenProxyGetCapabilities): Add support + for virConnectGetCapabilities across Xen proxy. + Mon Apr 30 18:00:00 BST 2007 Richard W.M. Jones * src/xen_unified.c: In the non-root case keep track of the diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c index c21c34f945ec6a79756132a5229ebdd3edd963be..21424d05c13ee7fa79f1c25b0a6287cad3ea8055 100644 --- a/proxy/libvirt_proxy.c +++ b/proxy/libvirt_proxy.c @@ -587,6 +587,29 @@ retry2: req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo); } break; + + case VIR_PROXY_GET_CAPABILITIES: + if (req->len != sizeof(virProxyPacket)) + goto comm_error; + + xml = xenHypervisorGetCapabilities (conn); + if (!xml) { + req->data.arg = -1; + req->len = sizeof (virProxyPacket); + } else { + int xmllen = strlen (xml); + if (xmllen > (int) sizeof (request.extra.str)) { + req->data.arg = -2; + req->len = sizeof (virProxyPacket); + } else { + req->data.arg = 0; + memmove (request.extra.str, xml, xmllen); + req->len = sizeof (virProxyPacket) + xmllen; + } + free (xml); + } + break; + case VIR_PROXY_DOMAIN_XML: if (req->len != sizeof(virProxyPacket)) goto comm_error; diff --git a/src/proxy_internal.c b/src/proxy_internal.c index 5767f30fa77e615da77edfc9244c215dc7a3ce94..fdf16f02698b375283d28450acc4b23d3e4c1c1f 100644 --- a/src/proxy_internal.c +++ b/src/proxy_internal.c @@ -31,6 +31,7 @@ static int xenProxyClose(virConnectPtr conn); static int xenProxyOpen(virConnectPtr conn, const char *name, int flags); static int xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer); static int xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); +static char *xenProxyGetCapabilities(virConnectPtr conn); static int xenProxyListDomains(virConnectPtr conn, int *ids, int maxids); static int xenProxyNumOfDomains(virConnectPtr conn); static virDomainPtr xenProxyLookupByID(virConnectPtr conn, int id); @@ -53,7 +54,7 @@ virDriver xenProxyDriver = { xenProxyGetVersion, /* version */ NULL, /* getMaxVcpus */ xenProxyNodeGetInfo, /* nodeGetInfo */ - NULL, /* getCapabilities */ + xenProxyGetCapabilities, /* getCapabilities */ xenProxyListDomains, /* listDomains */ xenProxyNumOfDomains, /* numOfDomains */ NULL, /* domainCreateLinux */ @@ -976,6 +977,55 @@ xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) { return(0); } +/** + * xenProxyGetCapabilities: + * @conn: pointer to the Xen Daemon block + * + * Extract capabilities of the hypervisor. + * + * Returns capabilities in case of success (freed by caller) + * and NULL in case of failure. + */ +static char * +xenProxyGetCapabilities (virConnectPtr conn) +{ + virProxyPacket req; + virProxyFullPacket ans; + int ret, xmllen; + char *xml; + + if (!VIR_IS_CONNECT(conn)) { + virProxyError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__); + return NULL; + } + memset(&req, 0, sizeof(req)); + req.command = VIR_PROXY_GET_CAPABILITIES; + req.data.arg = 0; + req.len = sizeof(req); + ret = xenProxyCommand(conn, &req, &ans, 0); + if (ret < 0) { + xenProxyClose(conn); + return NULL; + } + if (ans.data.arg == -1) + return NULL; + if (ans.len <= sizeof(virProxyPacket)) { + virProxyError(conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__); + return NULL; + } + + xmllen = ans.len - sizeof (virProxyPacket); + xml = malloc (xmllen+1); + if (!xml) { + virProxyError (conn, VIR_ERR_NO_MEMORY, __FUNCTION__); + return NULL; + } + memmove (xml, ans.extra.str, xmllen); + xml[xmllen] = '\0'; + + return xml; +} + /** * xenProxyDomainDumpXML: * @domain: a domain object diff --git a/src/proxy_internal.h b/src/proxy_internal.h index 492414471ab50725fd8f592ca937247a05c52550..f857bd55205f537d079b59f54cb72aaf14f9be23 100644 --- a/src/proxy_internal.h +++ b/src/proxy_internal.h @@ -36,7 +36,8 @@ typedef enum { VIR_PROXY_MAX_MEMORY = 8, VIR_PROXY_DOMAIN_INFO = 9, VIR_PROXY_DOMAIN_XML = 10, - VIR_PROXY_DOMAIN_OSTYPE = 11 + VIR_PROXY_DOMAIN_OSTYPE = 11, + VIR_PROXY_GET_CAPABILITIES = 12 } virProxyCommand; /*