* src/libvir.c src/xen_internal.c src/xen_internal.h: implement

Pause, Resume, Destroy, but untested yet.
Daniel
This commit is contained in:
Daniel Veillard 2005-12-08 17:16:24 +00:00
parent 086a0ffe4f
commit 6be439c983
4 changed files with 96 additions and 5 deletions

View File

@ -1,3 +1,8 @@
Thu Dec 8 18:16:20 CET 2005 Daniel Veillard <veillard@redhat.com>
* src/libvir.c src/xen_internal.c src/xen_internal.h: implement
Pause, Resume, Destroy, but untested yet.
Thu Dec 8 17:43:11 CET 2005 Daniel Veillard <veillard@redhat.com>
* include/libvir.h src/libvir.c src/libvir_sym.version: adding

View File

@ -538,9 +538,15 @@ virDomainLookupByID(virConnectPtr conn, int id) {
*/
int
virDomainDestroy(virDomainPtr domain) {
int ret;
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(-1);
TODO
if ((domain->conn == NULL) || (domain->conn->magic != VIR_CONNECT_MAGIC))
return(-1);
ret = xenHypervisorDestroyDomain(domain->conn->handle, domain->handle);
if (ret < 0)
return(-1);
return(virDomainFree(domain));
}
@ -583,8 +589,9 @@ int
virDomainSuspend(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(-1);
TODO
return(-1);
if ((domain->conn == NULL) || (domain->conn->magic != VIR_CONNECT_MAGIC))
return(-1);
return(xenHypervisorPauseDomain(domain->conn->handle, domain->handle));
}
/**
@ -600,8 +607,9 @@ int
virDomainResume(virDomainPtr domain) {
if ((domain == NULL) || (domain->magic != VIR_DOMAIN_MAGIC))
return(-1);
TODO
return(-1);
if ((domain->conn == NULL) || (domain->conn->magic != VIR_CONNECT_MAGIC))
return(-1);
return(xenHypervisorResumeDomain(domain->conn->handle, domain->handle));
}
/**

View File

@ -177,3 +177,75 @@ xenHypervisorGetDomainInfo(int handle, int domain, dom0_getdomaininfo_t *info) {
return(0);
}
/**
* xenHypervisorPauseDomain:
* @handle: the handle to the Xen hypervisor
* @domain: the domain ID
*
* Do an hypervisor call to pause the given domain
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenHypervisorPauseDomain(int handle, int domain) {
dom0_op_t op;
int ret;
op.cmd = DOM0_PAUSEDOMAIN;
op.u.pausedomain.domain = (domid_t) domain;
ret = xenHypervisorDoOp(handle, &op);
if (ret < 0)
return(-1);
return(0);
}
/**
* xenHypervisorResumeDomain:
* @handle: the handle to the Xen hypervisor
* @domain: the domain ID
*
* Do an hypervisor call to resume the given domain
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenHypervisorResumeDomain(int handle, int domain) {
dom0_op_t op;
int ret;
op.cmd = DOM0_UNPAUSEDOMAIN;
op.u.unpausedomain.domain = (domid_t) domain;
ret = xenHypervisorDoOp(handle, &op);
if (ret < 0)
return(-1);
return(0);
}
/**
* xenHypervisorDestroyDomain:
* @handle: the handle to the Xen hypervisor
* @domain: the domain ID
*
* Do an hypervisor call to destroy the given domain
*
* Returns 0 in case of success, -1 in case of error.
*/
int
xenHypervisorDestroyDomain(int handle, int domain) {
dom0_op_t op;
int ret;
op.cmd = DOM0_DESTROYDOMAIN;
op.u.destroydomain.domain = (domid_t) domain;
ret = xenHypervisorDoOp(handle, &op);
if (ret < 0)
return(-1);
return(0);
}

View File

@ -23,6 +23,12 @@ extern "C" {
int xenHypervisorOpen (void);
int xenHypervisorClose (int handle);
unsigned long xenHypervisorGetVersion (int handle);
int xenHypervisorDestroyDomain (int handle,
int domain);
int xenHypervisorResumeDomain (int handle,
int domain);
int xenHypervisorPauseDomain (int handle,
int domain);
int xenHypervisorGetDomainInfo (int handle,
int domain,
dom0_getdomaininfo_t *info);