mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
* proxy/libvirt_proxy.c src/proxy_internal.c src/xen_internal.c
src/xen_internal.h src/xend_internal.c src/xend_internal.h: implemented id based lookup and other cleanups, virsh starts to work, but still some TODOs Daniel
This commit is contained in:
parent
337211e731
commit
ec48593fdc
@ -1,3 +1,10 @@
|
|||||||
|
Thu Jun 29 23:57:35 EDT 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* proxy/libvirt_proxy.c src/proxy_internal.c src/xen_internal.c
|
||||||
|
src/xen_internal.h src/xend_internal.c src/xend_internal.h:
|
||||||
|
implemented id based lookup and other cleanups, virsh starts to
|
||||||
|
work, but still some TODOs
|
||||||
|
|
||||||
Thu Jun 29 22:19:51 EDT 2006 Daniel Veillard <veillard@redhat.com>
|
Thu Jun 29 22:19:51 EDT 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/proxy_internal.c src/proxy_internal.h src/driver.h src/libvirt.c
|
* src/proxy_internal.c src/proxy_internal.h src/driver.h src/libvirt.c
|
||||||
|
@ -403,11 +403,64 @@ retry:
|
|||||||
req->data.larg = xenHypervisorGetDomMaxMemory(conn, req->data.arg);
|
req->data.larg = xenHypervisorGetDomMaxMemory(conn, req->data.arg);
|
||||||
break;
|
break;
|
||||||
case VIR_PROXY_DOMAIN_INFO:
|
case VIR_PROXY_DOMAIN_INFO:
|
||||||
|
if (req->len != sizeof(virProxyPacket))
|
||||||
|
goto comm_error;
|
||||||
|
memset(&request.extra.dinfo, 0, sizeof(virDomainInfo));
|
||||||
|
ret = xenHypervisorGetDomInfo(conn, req->data.arg,
|
||||||
|
&request.extra.dinfo);
|
||||||
|
if (ret < 0) {
|
||||||
|
req->data.arg = -1;
|
||||||
|
} else {
|
||||||
|
req->len += sizeof(virDomainInfo);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case VIR_PROXY_LOOKUP_ID: {
|
||||||
|
char **names;
|
||||||
|
char **tmp;
|
||||||
|
int ident, len;
|
||||||
|
char *name = NULL;
|
||||||
|
unsigned char uuid[16];
|
||||||
|
|
||||||
|
if (req->len != sizeof(virProxyPacket))
|
||||||
|
goto comm_error;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Xend API forces to collect the full domain list by names, and
|
||||||
|
* then query each of them until the id is found
|
||||||
|
*/
|
||||||
|
names = xenDaemonListDomainsOld(conn);
|
||||||
|
tmp = names;
|
||||||
|
|
||||||
|
if (names != NULL) {
|
||||||
|
while (*tmp != NULL) {
|
||||||
|
ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
|
||||||
|
if (ident == req->data.arg) {
|
||||||
|
name = *tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name == NULL) {
|
||||||
|
req->data.arg = -1;
|
||||||
|
} else {
|
||||||
|
len = strlen(name);
|
||||||
|
if (len > 1000) {
|
||||||
|
len = 1000;
|
||||||
|
name[1000] = 0;
|
||||||
|
}
|
||||||
|
req->len += 16 + len + 1;
|
||||||
|
memcpy(&request.extra.str[0], uuid, 16);
|
||||||
|
strcpy(&request.extra.str[16], name);
|
||||||
|
}
|
||||||
|
free(names);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case VIR_PROXY_NODE_INFO:
|
case VIR_PROXY_NODE_INFO:
|
||||||
case VIR_PROXY_LOOKUP_ID:
|
|
||||||
case VIR_PROXY_LOOKUP_UUID:
|
case VIR_PROXY_LOOKUP_UUID:
|
||||||
case VIR_PROXY_LOOKUP_NAME:
|
case VIR_PROXY_LOOKUP_NAME:
|
||||||
TODO;
|
TODO;
|
||||||
|
req->data.arg = -1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto comm_error;
|
goto comm_error;
|
||||||
|
@ -741,8 +741,39 @@ xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
static virDomainPtr
|
static virDomainPtr
|
||||||
xenProxyLookupByID(virConnectPtr conn, int id)
|
xenProxyLookupByID(virConnectPtr conn, int id)
|
||||||
{
|
{
|
||||||
TODO
|
virProxyPacket req;
|
||||||
return(NULL);
|
virProxyFullPacket ans;
|
||||||
|
unsigned char uuid[16];
|
||||||
|
const char *name;
|
||||||
|
int ret;
|
||||||
|
virDomainPtr res;
|
||||||
|
|
||||||
|
if (!VIR_IS_CONNECT(conn)) {
|
||||||
|
virProxyError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
req.command = VIR_PROXY_LOOKUP_ID;
|
||||||
|
req.data.arg = id;
|
||||||
|
req.len = sizeof(req);
|
||||||
|
ret = xenProxyCommand(conn, &req, &ans);
|
||||||
|
if (ret < 0) {
|
||||||
|
xenProxyClose(conn);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
if (req.data.arg == -1) {
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
memcpy(uuid, &ans.extra.str[0], 16);
|
||||||
|
name = &ans.extra.str[16];
|
||||||
|
res = virGetDomain(conn, name, uuid);
|
||||||
|
|
||||||
|
if (res == NULL)
|
||||||
|
virProxyError(conn, VIR_ERR_NO_MEMORY, "Allocating domain");
|
||||||
|
else
|
||||||
|
res->handle = id;
|
||||||
|
|
||||||
|
return(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -579,8 +579,9 @@ xenHypervisorGetMaxMemory(virDomainPtr domain)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenHypervisorGetDomainInfo:
|
* xenHypervisorGetDomInfo:
|
||||||
* @domain: pointer to the domain block
|
* @conn: connection data
|
||||||
|
* @id: the domain ID
|
||||||
* @info: the place where informations should be stored
|
* @info: the place where informations should be stored
|
||||||
*
|
*
|
||||||
* Do an hypervisor call to get the related set of domain informations.
|
* Do an hypervisor call to get the related set of domain informations.
|
||||||
@ -588,14 +589,13 @@ xenHypervisorGetMaxMemory(virDomainPtr domain)
|
|||||||
* Returns 0 in case of success, -1 in case of error.
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
|
||||||
{
|
{
|
||||||
dom0_op_t op;
|
dom0_op_t op;
|
||||||
dom0_getdomaininfo_t dominfo;
|
dom0_getdomaininfo_t dominfo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((domain == NULL) || (domain->conn == NULL) ||
|
if ((conn == NULL) || (conn->handle < 0) || (info == NULL))
|
||||||
(domain->conn->handle < 0) || (info == NULL))
|
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
memset(info, 0, sizeof(virDomainInfo));
|
memset(info, 0, sizeof(virDomainInfo));
|
||||||
@ -608,13 +608,13 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
op.cmd = DOM0_GETDOMAININFOLIST;
|
op.cmd = DOM0_GETDOMAININFOLIST;
|
||||||
op.u.getdomaininfolist.first_domain = (domid_t) domain->handle;
|
op.u.getdomaininfolist.first_domain = (domid_t) id;
|
||||||
op.u.getdomaininfolist.max_domains = 1;
|
op.u.getdomaininfolist.max_domains = 1;
|
||||||
op.u.getdomaininfolist.buffer = &dominfo;
|
op.u.getdomaininfolist.buffer = &dominfo;
|
||||||
op.u.getdomaininfolist.num_domains = 1;
|
op.u.getdomaininfolist.num_domains = 1;
|
||||||
dominfo.domain = domain->handle;
|
dominfo.domain = id;
|
||||||
|
|
||||||
ret = xenHypervisorDoOp(domain->conn->handle, &op);
|
ret = xenHypervisorDoOp(conn->handle, &op);
|
||||||
|
|
||||||
if (munlock(&dominfo, sizeof(dom0_getdomaininfo_t)) < 0) {
|
if (munlock(&dominfo, sizeof(dom0_getdomaininfo_t)) < 0) {
|
||||||
virXenError(VIR_ERR_XEN_CALL, " release",
|
virXenError(VIR_ERR_XEN_CALL, " release",
|
||||||
@ -657,6 +657,30 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenHypervisorGetDomainInfo:
|
||||||
|
* @domain: pointer to the domain block
|
||||||
|
* @info: the place where informations should be stored
|
||||||
|
*
|
||||||
|
* Do an hypervisor call to get the related set of domain informations.
|
||||||
|
*
|
||||||
|
* Returns 0 in case of success, -1 in case of error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
||||||
|
{
|
||||||
|
dom0_op_t op;
|
||||||
|
dom0_getdomaininfo_t dominfo;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if ((domain == NULL) || (domain->conn == NULL) ||
|
||||||
|
(domain->conn->handle < 0) || (info == NULL) ||
|
||||||
|
(domain->handle < 0))
|
||||||
|
return (-1);
|
||||||
|
return(xenHypervisorGetDomInfo(domain->conn, domain->handle, info));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenHypervisorPauseDomain:
|
* xenHypervisorPauseDomain:
|
||||||
* @domain: pointer to the domain block
|
* @domain: pointer to the domain block
|
||||||
|
@ -37,6 +37,9 @@ int xenHypervisorResumeDomain (virDomainPtr domain);
|
|||||||
int xenHypervisorPauseDomain (virDomainPtr domain);
|
int xenHypervisorPauseDomain (virDomainPtr domain);
|
||||||
int xenHypervisorGetDomainInfo (virDomainPtr domain,
|
int xenHypervisorGetDomainInfo (virDomainPtr domain,
|
||||||
virDomainInfoPtr info);
|
virDomainInfoPtr info);
|
||||||
|
int xenHypervisorGetDomInfo (virConnectPtr conn,
|
||||||
|
int id,
|
||||||
|
virDomainInfoPtr info);
|
||||||
int xenHypervisorSetMaxMemory (virDomainPtr domain,
|
int xenHypervisorSetMaxMemory (virDomainPtr domain,
|
||||||
unsigned long memory);
|
unsigned long memory);
|
||||||
int xenHypervisorCheckID (virConnectPtr conn,
|
int xenHypervisorCheckID (virConnectPtr conn,
|
||||||
|
@ -1014,7 +1014,7 @@ xend_sysrq(virConnectPtr xend, const char *name, const char *key)
|
|||||||
*
|
*
|
||||||
* Returns a list of names or NULL in case of error.
|
* Returns a list of names or NULL in case of error.
|
||||||
*/
|
*/
|
||||||
static char **
|
char **
|
||||||
xenDaemonListDomainsOld(virConnectPtr xend)
|
xenDaemonListDomainsOld(virConnectPtr xend)
|
||||||
{
|
{
|
||||||
size_t extra = 0;
|
size_t extra = 0;
|
||||||
|
@ -614,6 +614,7 @@ int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
|||||||
char *xenDaemonDomainDumpXML(virDomainPtr domain);
|
char *xenDaemonDomainDumpXML(virDomainPtr domain);
|
||||||
virDomainPtr xenDaemonDomainLookupByName(virConnectPtr conn, const char *domname);
|
virDomainPtr xenDaemonDomainLookupByName(virConnectPtr conn, const char *domname);
|
||||||
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
|
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
|
||||||
|
char **xenDaemonListDomainsOld(virConnectPtr xend);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user