2005-11-02 12:50:21 +00:00
|
|
|
/*
|
|
|
|
* libxen.h: Main interfaces for the libxen library to handle virtualization
|
|
|
|
* domains from a process running in domain 0
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* See COPYING.LIB for the License of this software
|
|
|
|
*
|
|
|
|
* Daniel Veillard <veillard@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libxen.h"
|
|
|
|
|
2005-11-02 13:19:10 +00:00
|
|
|
#include <stdio.h>
|
2005-11-30 13:20:53 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <xenctrl.h>
|
|
|
|
#include <xs.h>
|
2005-11-02 12:50:21 +00:00
|
|
|
#include "internal.h"
|
2005-11-30 13:20:53 +00:00
|
|
|
#include "hash.h"
|
|
|
|
|
2005-11-02 12:50:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO:
|
|
|
|
* - use lock to protect against concurrent accesses ?
|
|
|
|
* - use reference counting to garantee coherent pointer state ?
|
2005-11-10 16:12:31 +00:00
|
|
|
* - error reporting layer
|
|
|
|
* - memory wrappers for malloc/free ?
|
2005-11-02 12:50:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define XEN_CONNECT_MAGIC 0x4F23DEAD
|
2005-11-30 13:20:53 +00:00
|
|
|
|
2005-12-01 16:35:42 +00:00
|
|
|
/*
|
|
|
|
* Flags for Xen connections
|
|
|
|
*/
|
|
|
|
#define XEN_CONNECT_RO 1
|
|
|
|
|
2005-11-02 12:50:21 +00:00
|
|
|
/**
|
|
|
|
* _xenConnect:
|
|
|
|
*
|
|
|
|
* Internal structure associated to a connection
|
|
|
|
*/
|
|
|
|
struct _xenConnect {
|
|
|
|
unsigned int magic; /* specific value to check */
|
|
|
|
int handle; /* internal handle used for hypercall */
|
2005-11-30 13:20:53 +00:00
|
|
|
struct xs_handle *xshandle; /* handle to talk to the xenstore */
|
|
|
|
xenHashTablePtr domains; /* hash table for known domains */
|
2005-12-01 16:35:42 +00:00
|
|
|
int flags; /* a set of connection flags */
|
2005-11-30 13:20:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define XEN_DOMAIN_MAGIC 0xDEAD4321
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _xenDomain:
|
|
|
|
*
|
|
|
|
* Internal structure associated to a domain
|
|
|
|
*/
|
|
|
|
struct _xenDomain {
|
|
|
|
unsigned int magic; /* specific value to check */
|
|
|
|
xenConnectPtr conn; /* pointer back to the connection */
|
|
|
|
char *name; /* the domain external name */
|
2005-12-01 16:35:42 +00:00
|
|
|
char *path; /* the domain internal path */
|
2005-11-30 13:20:53 +00:00
|
|
|
int handle; /* internal handle for the dmonain ID */
|
2005-11-02 13:19:10 +00:00
|
|
|
};
|
2005-11-02 12:50:21 +00:00
|
|
|
|
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenConnectOpen:
|
2005-11-02 12:50:21 +00:00
|
|
|
* @name: optional argument currently unused, pass NULL
|
|
|
|
*
|
|
|
|
* This function should be called first to get a connection to the
|
2005-11-23 07:47:13 +00:00
|
|
|
* Hypervisor and xen store
|
2005-11-02 12:50:21 +00:00
|
|
|
*
|
|
|
|
* Returns a pointer to the hypervisor connection or NULL in case of error
|
|
|
|
*/
|
|
|
|
xenConnectPtr
|
2005-12-01 10:51:34 +00:00
|
|
|
xenConnectOpen(const char *name) {
|
2005-12-01 16:35:42 +00:00
|
|
|
xenConnectPtr ret = NULL;
|
2005-11-23 07:47:13 +00:00
|
|
|
int handle = -1;
|
2005-11-30 13:20:53 +00:00
|
|
|
struct xs_handle *xshandle = NULL;
|
|
|
|
|
|
|
|
/* we can only talk to the local Xen supervisor ATM */
|
|
|
|
if (name != NULL)
|
|
|
|
return(NULL);
|
2005-11-10 16:12:31 +00:00
|
|
|
|
|
|
|
handle = xc_interface_open();
|
2005-11-23 07:47:13 +00:00
|
|
|
if (handle == -1)
|
|
|
|
goto failed;
|
|
|
|
xshandle = xs_daemon_open();
|
2005-11-30 13:20:53 +00:00
|
|
|
if (xshandle == NULL)
|
2005-11-23 07:47:13 +00:00
|
|
|
goto failed;
|
|
|
|
|
2005-11-10 16:12:31 +00:00
|
|
|
ret = (xenConnectPtr) malloc(sizeof(xenConnect));
|
2005-11-23 07:47:13 +00:00
|
|
|
if (ret == NULL)
|
|
|
|
goto failed;
|
2005-11-10 16:12:31 +00:00
|
|
|
ret->magic = XEN_CONNECT_MAGIC;
|
|
|
|
ret->handle = handle;
|
2005-11-23 07:47:13 +00:00
|
|
|
ret->xshandle = xshandle;
|
2005-11-30 13:20:53 +00:00
|
|
|
ret->domains = xenHashCreate(20);
|
2005-12-01 16:35:42 +00:00
|
|
|
ret->flags = 0;
|
2005-11-30 13:20:53 +00:00
|
|
|
if (ret->domains == NULL)
|
|
|
|
goto failed;
|
2005-11-10 16:12:31 +00:00
|
|
|
|
|
|
|
return(ret);
|
2005-11-23 07:47:13 +00:00
|
|
|
failed:
|
|
|
|
if (handle >= 0)
|
|
|
|
xc_interface_close(handle);
|
2005-11-30 13:20:53 +00:00
|
|
|
if (xshandle != NULL)
|
2005-11-23 07:47:13 +00:00
|
|
|
xs_daemon_close(xshandle);
|
2005-12-01 16:35:42 +00:00
|
|
|
if (ret != NULL)
|
|
|
|
free(ret);
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xenConnectOpenReadOnly:
|
|
|
|
* @name: optional argument currently unused, pass NULL
|
|
|
|
*
|
|
|
|
* This function should be called first to get a read-only connection to the
|
|
|
|
* xen store. The set of APIs usable are then restricted.
|
|
|
|
*
|
|
|
|
* Returns a pointer to the hypervisor connection or NULL in case of error
|
|
|
|
*/
|
|
|
|
xenConnectPtr
|
|
|
|
xenConnectOpenReadOnly(const char *name) {
|
|
|
|
xenConnectPtr ret = NULL;
|
|
|
|
struct xs_handle *xshandle = NULL;
|
|
|
|
|
|
|
|
/* we can only talk to the local Xen supervisor ATM */
|
|
|
|
if (name != NULL)
|
|
|
|
return(NULL);
|
|
|
|
|
|
|
|
xshandle = xs_daemon_open_readonly();
|
|
|
|
if (xshandle == NULL)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
ret = (xenConnectPtr) malloc(sizeof(xenConnect));
|
|
|
|
if (ret == NULL)
|
|
|
|
goto failed;
|
|
|
|
ret->magic = XEN_CONNECT_MAGIC;
|
|
|
|
ret->handle = -1;
|
|
|
|
ret->xshandle = xshandle;
|
|
|
|
ret->domains = xenHashCreate(20);
|
|
|
|
ret->flags = XEN_CONNECT_RO;
|
|
|
|
if (ret->domains == NULL)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
return(ret);
|
|
|
|
failed:
|
|
|
|
if (xshandle != NULL)
|
|
|
|
xs_daemon_close(xshandle);
|
|
|
|
if (ret != NULL)
|
|
|
|
free(ret);
|
2005-11-23 07:47:13 +00:00
|
|
|
return(NULL);
|
2005-11-02 12:50:21 +00:00
|
|
|
}
|
|
|
|
|
2005-11-30 13:20:53 +00:00
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainDestroyName:
|
2005-11-30 13:20:53 +00:00
|
|
|
* @domain: a domain object
|
|
|
|
*
|
|
|
|
* Destroy the domain object, this is just used by the domain hash callback.
|
|
|
|
*
|
|
|
|
* Returns 0 in case of success and -1 in case of failure.
|
|
|
|
*/
|
|
|
|
static int
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainDestroyName(xenDomainPtr domain, const char *name ATTRIBUTE_UNUSED) {
|
|
|
|
return(xenDomainDestroy(domain));
|
2005-11-30 13:20:53 +00:00
|
|
|
}
|
|
|
|
|
2005-11-02 12:50:21 +00:00
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenConnectClose:
|
2005-11-02 12:50:21 +00:00
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
*
|
|
|
|
* This function closes the connection to the Hypervisor. This should
|
|
|
|
* not be called if further interaction with the Hypervisor are needed
|
|
|
|
* especially if there is running domain which need further monitoring by
|
|
|
|
* the application.
|
|
|
|
*
|
|
|
|
* Returns 0 in case of success or -1 in case of error.
|
|
|
|
*/
|
|
|
|
int
|
2005-12-01 10:51:34 +00:00
|
|
|
xenConnectClose(xenConnectPtr conn) {
|
2005-11-02 12:50:21 +00:00
|
|
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC))
|
|
|
|
return(-1);
|
2005-11-10 16:12:31 +00:00
|
|
|
|
2005-12-01 10:51:34 +00:00
|
|
|
xenHashFree(conn->domains, (xenHashDeallocator) xenDomainDestroyName);
|
2005-11-02 12:50:21 +00:00
|
|
|
conn->magic = -1;
|
2005-11-23 07:47:13 +00:00
|
|
|
xs_daemon_close(conn->xshandle);
|
2005-11-30 13:20:53 +00:00
|
|
|
conn->xshandle = NULL;
|
2005-12-01 16:35:42 +00:00
|
|
|
if (conn->handle != -1)
|
|
|
|
xc_interface_close(conn->handle);
|
2005-11-10 16:12:31 +00:00
|
|
|
conn->handle = -1;
|
2005-11-02 12:50:21 +00:00
|
|
|
free(conn);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenConnectGetVersion:
|
2005-11-02 12:50:21 +00:00
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
*
|
2005-11-07 17:16:18 +00:00
|
|
|
* Get the version level of the Hypervisor running.
|
|
|
|
*
|
|
|
|
* Returns -1 in case of error or major * 10,000 + minor * 100 + rev otherwise
|
|
|
|
*/
|
|
|
|
unsigned long
|
2005-12-01 10:51:34 +00:00
|
|
|
xenConnectGetVersion(xenConnectPtr conn) {
|
2005-11-07 17:16:18 +00:00
|
|
|
if (conn == NULL)
|
|
|
|
return(-1);
|
2005-12-02 14:16:21 +00:00
|
|
|
TODO
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xenConnectListDomains:
|
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
* @ids: array to collect the list of IDs of active domains
|
|
|
|
* @maxids: size of @ids
|
|
|
|
*
|
|
|
|
* Collect the list of active domains, and store their ID in @maxids
|
|
|
|
*
|
|
|
|
* Returns the number of domain found or -1 in case of error
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
xenConnectListDomains(xenConnectPtr conn, int *ids, int maxids) {
|
|
|
|
struct xs_transaction_handle* t;
|
|
|
|
int ret = -1;
|
|
|
|
unsigned int num, i;
|
|
|
|
long id;
|
|
|
|
char **idlist = NULL, *endptr;
|
|
|
|
|
|
|
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) ||
|
|
|
|
(ids == NULL) || (maxids <= 0))
|
|
|
|
return(-1);
|
|
|
|
|
|
|
|
t = xs_transaction_start(conn->xshandle);
|
|
|
|
if (t == NULL)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
idlist = xs_directory(conn->xshandle, t, "/local/domain", &num);
|
|
|
|
if (idlist == NULL)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
for (ret = 0,i = 0;(i < num) && (ret < maxids);i++) {
|
|
|
|
id = strtol(idlist[i], &endptr, 10);
|
|
|
|
if ((endptr == idlist[i]) || (*endptr != 0)) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ids[ret++] = (int) id;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (t != NULL)
|
|
|
|
xs_transaction_end(conn->xshandle, t, 0);
|
|
|
|
if (idlist != NULL)
|
|
|
|
free(idlist);
|
|
|
|
|
|
|
|
return(ret);
|
2005-11-07 17:16:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainCreateLinux:
|
2005-11-07 17:16:18 +00:00
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
* @kernel_path: the file path to the kernel image
|
|
|
|
* @initrd_path: an optional file path to an initrd
|
|
|
|
* @cmdline: optional command line parameters for the kernel
|
|
|
|
* @memory: the memory size in kilobytes
|
|
|
|
* @flags: an optional set of xenDomainFlags
|
|
|
|
*
|
|
|
|
* Launch a new Linux guest domain
|
|
|
|
*
|
|
|
|
* Returns a new domain object or NULL in case of failure
|
|
|
|
*/
|
|
|
|
xenDomainPtr
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainCreateLinux(xenConnectPtr conn, const char *kernel_path,
|
2005-11-07 17:16:18 +00:00
|
|
|
const char *initrd_path, const char *cmdline,
|
|
|
|
unsigned long memory, unsigned int flags) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) ||
|
|
|
|
(kernel_path == NULL) || (memory < 4096))
|
2005-11-07 17:16:18 +00:00
|
|
|
return(NULL);
|
|
|
|
TODO
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2005-11-23 07:47:13 +00:00
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainLookupByName:
|
2005-11-23 07:47:13 +00:00
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
* @name: name for the domain
|
|
|
|
*
|
|
|
|
* Try to lookup a domain on the given hypervisor
|
|
|
|
*
|
|
|
|
* Returns a new domain object or NULL in case of failure
|
|
|
|
*/
|
|
|
|
xenDomainPtr
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainLookupByName(xenConnectPtr conn, const char *name) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) || (name == NULL))
|
2005-11-23 07:47:13 +00:00
|
|
|
return(NULL);
|
|
|
|
TODO
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2005-12-01 16:35:42 +00:00
|
|
|
/**
|
|
|
|
* xenConnectDoStoreQuery:
|
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
* @path: the absolute path of the data in the store to retrieve
|
|
|
|
*
|
|
|
|
* Internal API querying the Xenstore for a string value.
|
|
|
|
*
|
|
|
|
* Returns a string which must be freed by the caller or NULL in case of error
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
xenConnectDoStoreQuery(xenConnectPtr conn, const char *path) {
|
|
|
|
struct xs_transaction_handle* t;
|
|
|
|
char *ret = NULL;
|
|
|
|
unsigned int len = 0;
|
|
|
|
|
|
|
|
t = xs_transaction_start(conn->xshandle);
|
|
|
|
if (t == NULL)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
ret = xs_read(conn->xshandle, t, path, &len);
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (t != NULL)
|
|
|
|
xs_transaction_end(conn->xshandle, t, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xenDomainDoStoreQuery:
|
|
|
|
* @domain: a domain object
|
|
|
|
* @path: the relative path of the data in the store to retrieve
|
|
|
|
*
|
|
|
|
* Internal API querying the Xenstore for a string value.
|
|
|
|
*
|
|
|
|
* Returns a string which must be freed by the caller or NULL in case of error
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
xenDomainDoStoreQuery(xenDomainPtr domain, const char *path) {
|
|
|
|
struct xs_transaction_handle* t;
|
|
|
|
char s[256];
|
|
|
|
char *ret = NULL;
|
|
|
|
unsigned int len = 0;
|
|
|
|
|
|
|
|
snprintf(s, 255, "/local/domain/%d/%s", domain->handle, path);
|
|
|
|
s[255] = 0;
|
|
|
|
|
|
|
|
t = xs_transaction_start(domain->conn->xshandle);
|
|
|
|
if (t == NULL)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
ret = xs_read(domain->conn->xshandle, t, &s[0], &len);
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (t != NULL)
|
|
|
|
xs_transaction_end(domain->conn->xshandle, t, 0);
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2005-11-30 13:20:53 +00:00
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainLookupByID:
|
2005-11-30 13:20:53 +00:00
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
* @id: the domain ID number
|
|
|
|
*
|
|
|
|
* Try to find a domain based on the hypervisor ID number
|
|
|
|
*
|
|
|
|
* Returns a new domain object or NULL in case of failure
|
|
|
|
*/
|
|
|
|
xenDomainPtr
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainLookupByID(xenConnectPtr conn, int id) {
|
2005-11-30 13:20:53 +00:00
|
|
|
char *path;
|
|
|
|
xenDomainPtr ret;
|
|
|
|
xc_dominfo_t info;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
if ((conn == NULL) || (conn->magic != XEN_CONNECT_MAGIC) || (id < 0))
|
|
|
|
return(NULL);
|
|
|
|
|
2005-12-01 16:35:42 +00:00
|
|
|
if ((conn->flags & XEN_CONNECT_RO) == 0) {
|
|
|
|
res = xc_domain_getinfo(conn->handle, (uint32_t) id, 1, &info);
|
|
|
|
if (res != 1) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
2005-11-30 13:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
path = xs_get_domain_path(conn->xshandle, (unsigned int) id);
|
|
|
|
if (path == NULL) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
ret = (xenDomainPtr) malloc(sizeof(xenDomain));
|
|
|
|
if (ret == NULL) {
|
|
|
|
free(path);
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
ret->magic = XEN_DOMAIN_MAGIC;
|
|
|
|
ret->conn = conn;
|
|
|
|
ret->handle = id;
|
2005-12-01 16:35:42 +00:00
|
|
|
ret->path = path;
|
|
|
|
ret->name = xenDomainDoStoreQuery(ret, "name");
|
2005-11-30 13:20:53 +00:00
|
|
|
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2005-11-07 17:16:18 +00:00
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainDestroy:
|
2005-11-07 17:16:18 +00:00
|
|
|
* @domain: a domain object
|
|
|
|
*
|
|
|
|
* Destroy the domain object. The running instance is shutdown if not down
|
|
|
|
* already and all resources used by it are given back to the hypervisor.
|
|
|
|
*
|
|
|
|
* Returns 0 in case of success and -1 in case of failure.
|
2005-11-02 13:19:10 +00:00
|
|
|
*/
|
2005-11-07 17:16:18 +00:00
|
|
|
int
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainDestroy(xenDomainPtr domain) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
2005-11-07 17:16:18 +00:00
|
|
|
return(-1);
|
|
|
|
TODO
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainSuspend:
|
2005-11-07 17:16:18 +00:00
|
|
|
* @domain: a domain object
|
|
|
|
*
|
|
|
|
* Suspends an active domain, the process is frozen without further access
|
|
|
|
* to CPU resources and I/O but the memory used by the domain at the
|
2005-12-01 17:34:21 +00:00
|
|
|
* hypervisor level will stay allocated. Use xenDomainResume() to reactivate
|
2005-11-07 17:16:18 +00:00
|
|
|
* the domain.
|
|
|
|
*
|
|
|
|
* Returns 0 in case of success and -1 in case of failure.
|
|
|
|
*/
|
|
|
|
int
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainSuspend(xenDomainPtr domain) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
2005-11-07 17:16:18 +00:00
|
|
|
return(-1);
|
|
|
|
TODO
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-12-01 17:34:21 +00:00
|
|
|
* xenDomainResume:
|
2005-11-07 17:16:18 +00:00
|
|
|
* @domain: a domain object
|
|
|
|
*
|
|
|
|
* Resume an suspended domain, the process is restarted from the state where
|
|
|
|
* it was frozen by calling xenSuspendDomain().
|
|
|
|
*
|
|
|
|
* Returns 0 in case of success and -1 in case of failure.
|
|
|
|
*/
|
|
|
|
int
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainResume(xenDomainPtr domain) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
2005-11-07 17:16:18 +00:00
|
|
|
return(-1);
|
|
|
|
TODO
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2005-11-23 07:47:13 +00:00
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainGetName:
|
2005-11-23 07:47:13 +00:00
|
|
|
* @domain: a domain object
|
|
|
|
*
|
|
|
|
* Get the public name for that domain
|
|
|
|
*
|
|
|
|
* Returns a pointer to the name or NULL, the string need not be deallocated
|
|
|
|
* its lifetime will be the same as the domain object.
|
|
|
|
*/
|
|
|
|
const char *
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainGetName(xenDomainPtr domain) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
2005-11-23 07:47:13 +00:00
|
|
|
return(NULL);
|
2005-11-30 13:20:53 +00:00
|
|
|
return(domain->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainGetID:
|
2005-11-30 13:20:53 +00:00
|
|
|
* @domain: a domain object
|
|
|
|
*
|
|
|
|
* Get the hypervisor ID number for the domain
|
|
|
|
*
|
|
|
|
* Returns the domain ID number or (unsigned int) -1 in case of error
|
|
|
|
*/
|
|
|
|
unsigned int
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainGetID(xenDomainPtr domain) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
|
|
|
return((unsigned int) -1);
|
|
|
|
return(domain->handle);
|
2005-11-23 07:47:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainGetMaxMemory:
|
2005-11-23 07:47:13 +00:00
|
|
|
* @domain: a domain object or NULL
|
|
|
|
*
|
|
|
|
* Retrieve the maximum amount of physical memory allocated to a
|
|
|
|
* domain. If domain is NULL, then this get the amount of memory reserved
|
|
|
|
* to Domain0 i.e. the domain where the application runs.
|
|
|
|
*
|
|
|
|
* Returns the memory size in kilobytes or 0 in case of error.
|
|
|
|
*/
|
|
|
|
unsigned long
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainGetMaxMemory(xenDomainPtr domain) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC))
|
2005-11-23 07:47:13 +00:00
|
|
|
return(0);
|
|
|
|
TODO
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2005-11-07 17:16:18 +00:00
|
|
|
/**
|
2005-12-01 10:51:34 +00:00
|
|
|
* xenDomainSetMaxMemory:
|
2005-11-07 17:16:18 +00:00
|
|
|
* @domain: a domain object or NULL
|
|
|
|
* @memory: the memory size in kilobytes
|
|
|
|
*
|
|
|
|
* Dynamically change the maximum amount of physical memory allocated to a
|
|
|
|
* domain. If domain is NULL, then this change the amount of memory reserved
|
|
|
|
* to Domain0 i.e. the domain where the application runs.
|
|
|
|
*
|
|
|
|
* Returns 0 in case of success and -1 in case of failure.
|
|
|
|
*/
|
|
|
|
int
|
2005-12-01 10:51:34 +00:00
|
|
|
xenDomainSetMaxMemory(xenDomainPtr domain, unsigned long memory) {
|
2005-11-30 13:20:53 +00:00
|
|
|
if ((domain == NULL) || (domain->magic != XEN_DOMAIN_MAGIC) ||
|
|
|
|
(memory < 4096))
|
2005-11-07 17:16:18 +00:00
|
|
|
return(-1);
|
|
|
|
TODO
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|