Mon Apr 30 18:02:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>

* src/proxy_internal.c (xenProxyGetCapabilities): Add support
	  for virConnectGetCapabilities across Xen proxy.
This commit is contained in:
Richard W.M. Jones 2007-04-30 16:58:26 +00:00
parent ebd8071688
commit 27151b3d10
4 changed files with 81 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Mon Apr 30 18:02:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/proxy_internal.c (xenProxyGetCapabilities): Add support
for virConnectGetCapabilities across Xen proxy.
Mon Apr 30 18:00:00 BST 2007 Richard W.M. Jones <rjones@redhat.com> Mon Apr 30 18:00:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/xen_unified.c: In the non-root case keep track of the * src/xen_unified.c: In the non-root case keep track of the

View File

@ -587,6 +587,29 @@ retry2:
req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo); req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo);
} }
break; 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: case VIR_PROXY_DOMAIN_XML:
if (req->len != sizeof(virProxyPacket)) if (req->len != sizeof(virProxyPacket))
goto comm_error; goto comm_error;

View File

@ -31,6 +31,7 @@ static int xenProxyClose(virConnectPtr conn);
static int xenProxyOpen(virConnectPtr conn, const char *name, int flags); static int xenProxyOpen(virConnectPtr conn, const char *name, int flags);
static int xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer); static int xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer);
static int xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info); static int xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
static char *xenProxyGetCapabilities(virConnectPtr conn);
static int xenProxyListDomains(virConnectPtr conn, int *ids, int maxids); static int xenProxyListDomains(virConnectPtr conn, int *ids, int maxids);
static int xenProxyNumOfDomains(virConnectPtr conn); static int xenProxyNumOfDomains(virConnectPtr conn);
static virDomainPtr xenProxyLookupByID(virConnectPtr conn, int id); static virDomainPtr xenProxyLookupByID(virConnectPtr conn, int id);
@ -53,7 +54,7 @@ virDriver xenProxyDriver = {
xenProxyGetVersion, /* version */ xenProxyGetVersion, /* version */
NULL, /* getMaxVcpus */ NULL, /* getMaxVcpus */
xenProxyNodeGetInfo, /* nodeGetInfo */ xenProxyNodeGetInfo, /* nodeGetInfo */
NULL, /* getCapabilities */ xenProxyGetCapabilities, /* getCapabilities */
xenProxyListDomains, /* listDomains */ xenProxyListDomains, /* listDomains */
xenProxyNumOfDomains, /* numOfDomains */ xenProxyNumOfDomains, /* numOfDomains */
NULL, /* domainCreateLinux */ NULL, /* domainCreateLinux */
@ -976,6 +977,55 @@ xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) {
return(0); 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: * xenProxyDomainDumpXML:
* @domain: a domain object * @domain: a domain object

View File

@ -36,7 +36,8 @@ typedef enum {
VIR_PROXY_MAX_MEMORY = 8, VIR_PROXY_MAX_MEMORY = 8,
VIR_PROXY_DOMAIN_INFO = 9, VIR_PROXY_DOMAIN_INFO = 9,
VIR_PROXY_DOMAIN_XML = 10, VIR_PROXY_DOMAIN_XML = 10,
VIR_PROXY_DOMAIN_OSTYPE = 11 VIR_PROXY_DOMAIN_OSTYPE = 11,
VIR_PROXY_GET_CAPABILITIES = 12
} virProxyCommand; } virProxyCommand;
/* /*