+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
*/
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));
}
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));
}
/**
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));
}
/**
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);
+}
+
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);