}
ret->xshandle = xshandle;
- if (xend_setup(ret) < 0)
+ if (xenDaemonOpen(ret, name, 0) < 0)
goto failed;
ret->domains = virHashCreate(20);
ret->flags = 0;
method++;
ret->xshandle = xshandle;
- if (xend_setup(ret) == 0)
+ if (xenDaemonOpen(ret, name, VIR_DRV_OPEN_QUIET | VIR_DRV_OPEN_RO) == 0)
method++;
ret->domains = virHashCreate(20);
if (ret->domains == NULL)
int
virConnectClose(virConnectPtr conn)
{
- xend_cleanup(conn);
+ xenDaemonClose(conn);
if (!VIR_IS_CONNECT(conn))
return (-1);
virHashFree(conn->domains, (virHashDeallocator) virDomainFreeName);
return (-1);
}
- idlist = xend_get_domains(conn);
+ idlist = xenDaemonListDomains(conn);
if (idlist != NULL) {
for (ret = 0, i = 0; (idlist[i] != NULL) && (ret < maxids); i++) {
- id = xend_get_domain_ids(conn, idlist[i], NULL);
+ id = xenDaemonDomainLookupByName_ids(conn, idlist[i], NULL);
if (id >= 0)
ids[ret++] = (int) id;
}
/*
* try first with Xend interface
*/
- idlist = xend_get_domains(conn);
+ idlist = xenDaemonListDomains(conn);
if (idlist != NULL) {
char **tmp = idlist;
return (NULL);
}
- ret = xend_create_sexpr(conn, sexpr);
+ ret = xenDaemonDomainCreateLinux(conn, sexpr);
free(sexpr);
if (ret != 0) {
fprintf(stderr, "Failed to create domain %s\n", name);
ret = xend_wait_for_devices(conn, name);
if (ret != 0) {
fprintf(stderr, "Failed to get devices for domain %s\n", name);
- xend_destroy(conn, name);
goto error;
}
- ret = xend_unpause(conn, name);
+ dom = virDomainLookupByName(conn, name);
+ if (dom == NULL) {
+ goto error;
+ }
+
+ ret = xenDaemonDomainResume(dom);
if (ret != 0) {
fprintf(stderr, "Failed to resume new domain %s\n", name);
- xend_destroy(conn, name);
+ xenDaemonDomainDestroy(dom);
goto error;
}
}
/* fallback to xend API then */
if (path == NULL) {
- char **names = xend_get_domains(conn);
+ char **names = xenDaemonListDomains(conn);
char **tmp = names;
int ident;
if (names != NULL) {
while (*tmp != NULL) {
- ident = xend_get_domain_ids(conn, *tmp, &uuid[0]);
+ ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
if (ident == id) {
name = strdup(*tmp);
break;
virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (NULL);
}
- names = xend_get_domains(conn);
+ names = xenDaemonListDomains(conn);
tmp = names;
if (names == NULL) {
return (NULL);
}
while (*tmp != NULL) {
- id = xend_get_domain_ids(conn, *tmp, &ident[0]);
+ id = xenDaemonDomainLookupByName_ids(conn, *tmp, &ident[0]);
if (id >= 0) {
if (!memcmp(uuid, ident, 16)) {
name = strdup(*tmp);
}
/* try first though Xend */
- xenddomain = xend_get_domain(conn, name);
+ xenddomain = xenDaemonDomainLookupByName(conn, name);
if (xenddomain != NULL) {
id = xenddomain->live->id;
uuid = xenddomain->uuid;
/*
* try first with the xend method
*/
- ret = xend_destroy(domain->conn, domain->name);
+ ret = xenDaemonDomainDestroy(domain);
if (ret == 0) {
virDomainFree(domain);
return (0);
}
/* first try though the Xen daemon */
- ret = xend_pause(domain->conn, domain->name);
+ ret = xenDaemonDomainSuspend(domain);
if (ret == 0)
return (0);
}
/* first try though the Xen daemon */
- ret = xend_unpause(domain->conn, domain->name);
+ ret = xenDaemonDomainResume(domain);
if (ret == 0)
return (0);
}
- ret = xend_save(domain->conn, domain->name, to);
+ ret = xenDaemonDomainSave(domain, to);
return (ret);
}
from = &filepath[0];
}
- ret = xend_restore(conn, from);
+ ret = xenDaemonDomainRestore(conn, from);
return (ret);
}
/*
* try first with the xend daemon
*/
- ret = xend_shutdown(domain->conn, domain->name);
+ ret = xenDaemonDomainShutdown(domain);
if (ret == 0)
return (0);
(domain->uuid[10] == 0) && (domain->uuid[11] == 0) &&
(domain->uuid[12] == 0) && (domain->uuid[13] == 0) &&
(domain->uuid[14] == 0) && (domain->uuid[15] == 0))
- xend_get_domain_ids(domain->conn, domain->name,
+ xenDaemonDomainLookupByName_ids(domain->conn, domain->name,
&domain->uuid[0]);
memcpy(uuid, &domain->uuid[0], 16);
}
int ret;
char s[256], v[30];
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
if (memory < 4096) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1);
}
- if (domain->conn->flags & VIR_CONNECT_RO)
+ if (domain == NULL) {
+ TODO
+ return (-1);
+ }
+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+ virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
return (-1);
- if (domain->conn->xshandle == NULL)
+ }
+ if (domain->conn->flags & VIR_CONNECT_RO)
return (-1);
+
+ ret = xenDaemonDomainSetMaxMemory(domain, memory);
+ if (ret == 0)
+ return(0);
+
ret = xenHypervisorSetMaxMemory(domain, memory);
if (ret < 0)
return (-1);
- /*
- * try to update at the Xenstore level too
- * Failing to do so should not be considered fatal though as long
- * as the hypervisor call succeeded
- */
- snprintf(s, 255, "/local/domain/%d/memory/target", domain->handle);
- s[255] = 0;
- snprintf(v, 29, "%lu", memory);
- v[30] = 0;
+ if (domain->conn->xshandle != NULL) {
+ /*
+ * try to update at the Xenstore level too
+ * Failing to do so should not be considered fatal though as long
+ * as the hypervisor call succeeded
+ */
+ snprintf(s, 255, "/local/domain/%d/memory/target", domain->handle);
+ s[255] = 0;
+ snprintf(v, 29, "%lu", memory);
+ v[30] = 0;
- if (!xs_write(domain->conn->xshandle, 0, &s[0], &v[0], strlen(v)))
- ret = -1;
+ if (!xs_write(domain->conn->xshandle, 0, &s[0], &v[0], strlen(v)))
+ ret = -1;
+ }
return (ret);
}
*/
if (domain->conn->handle >= 0) {
ret = xenHypervisorGetDomainInfo(domain, info);
- if (ret < 0)
- goto xend_info;
- return (0);
- /*
- dom0_getdomaininfo_t dominfo;
-
- dominfo.domain = domain->handle;
- ret = xenHypervisorGetDomainInfo(domain, &dominfo);
- if (ret < 0)
- goto xend_info;
-
- switch (dominfo.flags & 0xFF) {
- case DOMFLAGS_DYING:
- info->state = VIR_DOMAIN_SHUTDOWN;
- break;
- case DOMFLAGS_SHUTDOWN:
- info->state = VIR_DOMAIN_SHUTOFF;
- break;
- case DOMFLAGS_PAUSED:
- info->state = VIR_DOMAIN_PAUSED;
- break;
- case DOMFLAGS_BLOCKED:
- info->state = VIR_DOMAIN_BLOCKED;
- break;
- case DOMFLAGS_RUNNING:
- info->state = VIR_DOMAIN_RUNNING;
- break;
- default:
- info->state = VIR_DOMAIN_NONE;
- }
-
- * the API brings back the cpu time in nanoseconds,
- * convert to microseconds, same thing convert to
- * kilobytes from page counts
- info->cpuTime = dominfo.cpu_time;
- info->memory = dominfo.tot_pages * 4;
- info->maxMem = dominfo.max_pages * 4;
- info->nrVirtCpu = dominfo.nr_online_vcpus;
- return (0);
- */
+ if (ret == 0)
+ return (0);
}
- xend_info:
/*
* try to extract the informations though access to the Xen Daemon
*/
- if (xend_get_domain_info(domain, info) == 0)
+ if (xenDaemonDomainGetInfo(domain, info) == 0)
return (0);
/*
return (NULL);
}
- return (xend_get_domain_xml(domain));
+ return (xenDaemonDomainDumpXML(domain));
}
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <libxml/uri.h>
#include "libvirt.h"
+#include "driver.h"
#include "internal.h"
#include "sexpr.h"
#include "xml.h"
#include "xend_internal.h"
+static virDriver xenDaemonDriver = {
+ "Xen",
+ NULL, /* init */
+ xenDaemonOpen, /* open */
+ xenDaemonClose, /* close */
+ NULL, /* type */
+ NULL, /* version */
+ NULL, /* listDomains */
+ NULL, /* numOfDomains */
+ NULL, /* domainCreateLinux */
+ NULL, /* domainLookupByID */
+ NULL, /* domainLookupByUUID */
+ NULL, /* domainLookupByName */
+ xenDaemonDomainSuspend, /* domainSuspend */
+ xenDaemonDomainResume, /* domainResume */
+ xenDaemonDomainShutdown, /* domainShutdown */
+ xenDaemonDomainDestroy, /* domainDestroy */
+ NULL, /* domainFree */
+ NULL, /* domainGetName */
+ NULL, /* domainGetID */
+ NULL, /* domainGetUUID */
+ NULL, /* domainGetOSType */
+ NULL, /* domainGetMaxMemory */
+ xenDaemonDomainSetMaxMemory, /* domainSetMaxMemory */
+ xenDaemonDomainGetInfo, /* domainGetInfo */
+ xenDaemonDomainSave, /* domainSave */
+ xenDaemonDomainRestore /* domainRestore */
+};
+
/**
* xend_connection_type:
*
return string2sexpr(buffer);
}
-/**
- * sexpr_append_str:
- * @sexpr: an S-Expression
- * @name: the name of the property
- * @value: the string value
- *
- * convenience function appending a (name value) property to the S-Expression
- *
- * Returns the augmented S-Expression
- */
-static struct sexpr *
-sexpr_append_str(struct sexpr *sexpr, const char *name, const char *value)
-{
- struct sexpr *lst;
-
- if (!value)
- return sexpr;
-
- lst = sexpr_append(sexpr_nil(), sexpr_string(name, -1));
- lst = sexpr_append(lst, sexpr_string(value, -1));
- return sexpr_append(sexpr, lst);
-}
-
-/**
- * sexpr_append_u64:
- * @sexpr: an S-Expression
- * @name: the name of the property
- * @value: a 64 bits unsigned int value
- *
- * convenience function appending a (name value) property to the S-Expression
- *
- * Returns the augmented S-Expression
- */
-static struct sexpr *
-sexpr_append_u64(struct sexpr *sexpr, const char *name, uint64_t value)
-{
- char buffer[1024];
-
- snprintf(buffer, sizeof(buffer), "%llu", value);
- return sexpr_append_str(sexpr, name, buffer);
-}
-
-/**
- * sexpr_append_int:
- * @sexpr: an S-Expression
- * @name: the name of the property
- * @value: an int value
- *
- * convenience function appending a (name value) property to the S-Expression
- *
- * Returns the augmented S-Expression
- */
-static struct sexpr *
-sexpr_append_int(struct sexpr *sexpr, const char *name, int value)
-{
- char buffer[1024];
-
- snprintf(buffer, sizeof(buffer), "%d", value);
- return sexpr_append_str(sexpr, name, buffer);
-}
-
-/**
- * sexpr_append_uuid:
- * @sexpr: an S-Expression
- * @name: the name of the property
- * @uuid: an unique identifier for a domain
- *
- * convenience function appending a (name uuid) property to the S-Expression
- *
- * Returns the augmented S-Expression
- */
-static struct sexpr *
-sexpr_append_uuid(struct sexpr *sexpr,
- const char *name, unsigned char *uuid)
-{
- char buffer[1024];
-
- if (uuid == NULL)
- return sexpr;
-
- snprintf(buffer, sizeof(buffer),
- "%02x%02x%02x%02x-"
- "%02x%02x%02x%02x-"
- "%02x%02x%02x%02x-"
- "%02x%02x%02x%02x",
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15]);
-
- return sexpr_append_str(sexpr, name, buffer);
-}
-
/**
* sexpr_int:
* @sexpr: an S-Expression
return buffer;
}
-/**
- * xend_device_vbd_to_sexpr:
- * @vbd: a virtual block device pointer
- *
- * Encode a virtual block device as an S-Expression understood by the
- * Xen Daemon
- *
- * Returns the result S-Expression pointer
- */
-static struct sexpr *
-xend_device_vbd_to_sexpr(const struct xend_device_vbd *vbd)
-{
- struct sexpr *device = sexpr_nil();
- const char *mode[] = { NULL, "r", "w", "w!" };
-
- sexpr_append(device, sexpr_string("vbd", -1));
- sexpr_append_str(device, "dev", vbd->dev);
- sexpr_append_str(device, "uname", vbd->uname);
- sexpr_append_int(device, "backend", vbd->backend);
- sexpr_append_str(device, "mode", mode[vbd->mode]);
-
- return device;
-}
-
-/**
- * xend_device_vif_to_sexpr:
- * @vif: a virtual network interface pointer
- *
- * Encode a virtual network interface as an S-Expression understood by the
- * Xen Daemon
- *
- * Returns the result S-Expression pointer
- */
-static struct sexpr *
-xend_device_vif_to_sexpr(const struct xend_device_vif *vif)
-{
- struct sexpr *device;
- char buffer[1024];
-
- device = sexpr_append(sexpr_nil(), sexpr_string("vif", -1));
-
- snprintf(buffer, sizeof(buffer),
- "%02x:%02x:%02x:%02x:%02x:%02x",
- vif->mac[0], vif->mac[1], vif->mac[2],
- vif->mac[3], vif->mac[4], vif->mac[5]);
- device = sexpr_append_str(device, "mac", buffer);
- device = sexpr_append_int(device, "backend", vif->backend);
- device = sexpr_append_str(device, "bridge", vif->bridge);
- device = sexpr_append_str(device, "ip", vif->ip);
- device = sexpr_append_str(device, "script", vif->script);
- device = sexpr_append_str(device, "vifname", vif->vifname);
-
- return device;
-}
-
/* PUBLIC FUNCTIONS */
/**
- * xend_setup_unix:
+ * xenDaemonOpen_unix:
* @conn: an existing virtual connection block
* @path: the path for the Xen Daemon socket
*
* Returns 0 in case of success, -1 in case of error.
*/
int
-xend_setup_unix(virConnectPtr xend, const char *path)
+xenDaemonOpen_unix(virConnectPtr xend, const char *path)
{
struct sockaddr_un *addr;
}
/**
- * xend_setup_tcp:
+ * xenDaemonOpen_tcp:
* @conn: an existing virtual connection block
* @host: the host name for the Xen Daemon
* @port: the port
* Returns 0 in case of success, -1 in case of error.
*/
int
-xend_setup_tcp(virConnectPtr xend, const char *host, int port)
+xenDaemonOpen_tcp(virConnectPtr xend, const char *host, int port)
{
struct in_addr ip;
struct hostent *pent;
return (0);
}
-/**
- * xend_setup:
- * @conn: an existing virtual connection block
- *
- * Creates a localhost Xen Daemon connection
- * Note: this doesn't try to check if the connection actually works
- *
- * Returns 0 in case of success, -1 in case of error.
- */
-int
-xend_setup(virConnectPtr conn)
-{
- return (xend_setup_tcp(conn, "localhost", 8000));
-
-/* return(xend_setup_unix(conn, "/var/lib/xend/xend-socket")); */
-}
-
-/**
- * xend_cleanup:
- *
- * Cleanup a xend connection
- */
-void
-xend_cleanup(virConnectPtr xend ATTRIBUTE_UNUSED)
-{
-}
-
/**
* xend_wait_for_devices:
* @xend: pointer to the Xem Daemon block
return xend_op(xend, name, "op", "wait_for_devices", NULL);
}
-/**
- * xend_pause:
- * @xend: pointer to the Xem Daemon block
- * @name: name for the domain
- *
- * Pause the domain, the domain is not scheduled anymore though its resources
- * are preserved. Use xend_unpause() to resume execution.
- *
- * Returns 0 in case of success, -1 (with errno) in case of error.
- */
-int
-xend_pause(virConnectPtr xend, const char *name)
-{
- return xend_op(xend, name, "op", "pause", NULL);
-}
-
-/**
- * xend_unpause:
- * @xend: pointer to the Xem Daemon block
- * @name: name for the domain
- *
- * Resume the domain after xend_pause() has been called
- *
- * Returns 0 in case of success, -1 (with errno) in case of error.
- */
-int
-xend_unpause(virConnectPtr xend, const char *name)
-{
- return xend_op(xend, name, "op", "unpause", NULL);
-}
-
/**
* xend_rename:
* @xend: pointer to the Xem Daemon block
return xend_op(xend, name, "op", "shutdown", "reason", "reboot", NULL);
}
-/**
- * xend_shutdown:
- * @xend: pointer to the Xem Daemon block
- * @name: name for the domain
- *
- * Shutdown the domain, the OS is properly shutdown and the resources allocated
- * for the domain are freed.
- *
- * Returns 0 in case of success, -1 (with errno) in case of error.
- */
-int
-xend_shutdown(virConnectPtr xend, const char *name)
-{
- if ((xend == NULL) || (name == NULL)) {
- /* this should be caught at the interface but ... */
- virXendError(xend, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- return xend_op(xend, name, "op", "shutdown", "reason", "halt", NULL);
-}
-
/**
* xend_sysrq:
* @xend: pointer to the Xem Daemon block
}
/**
- * xend_destroy:
- * @xend: pointer to the Xem Daemon block
- * @name: name for the domain
- *
- * Abruptly halt the domain, the OS is not properly shutdown and the
- * resources allocated for the domain are immediately freed, mounted
- * filesystems will be marked as uncleanly shutdown.
- *
- * Returns 0 in case of success, -1 (with errno) in case of error.
- */
-int
-xend_destroy(virConnectPtr xend, const char *name)
-{
- if ((xend == NULL) || (name == NULL)) {
- /* this should be caught at the interface but ... */
- virXendError(xend, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- return xend_op(xend, name, "op", "destroy", NULL);
-}
-
-/**
- * xend_save:
- * @xend: pointer to the Xem Daemon block
- * @name: name for the domain
- * @filename: path for the output file
- *
- * This method will suspend a domain and save its memory contents to
- * a file on disk. Use xend_restore() to restore a domain after
- * saving.
- * Note that for remote Xen Daemon the file path will be interpreted in
- * the remote host.
- *
- * Returns 0 in case of success, -1 (with errno) in case of error.
- */
-int
-xend_save(virConnectPtr xend, const char *name, const char *filename)
-{
- if ((xend == NULL) || (filename == NULL)) {
- /* this should be caught at the interface but ... */
- virXendError(xend, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- return xend_op(xend, name, "op", "save", "file", filename, NULL);
-}
-
-/**
- * xend_restore:
- * @xend: pointer to the Xem Daemon block
- * @filename: path for the output file
- *
- * This method will restore a domain saved to disk by xend_save().
- * Note that for remote Xen Daemon the file path will be interpreted in
- * the remote host.
- *
- * Returns 0 in case of success, -1 (with errno) in case of error.
- */
-int
-xend_restore(virConnectPtr xend, const char *filename)
-{
- if ((xend == NULL) || (filename == NULL)) {
- /* this should be caught at the interface but ... */
- virXendError(xend, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- return xend_op(xend, "", "op", "restore", "file", filename, NULL);
-}
-
-/**
- * xend_get_domains:
+ * xenDaemonListDomains:
* @xend: pointer to the Xem Daemon block
*
* This method will return an array of names of currently running
* Returns a list of names or NULL in case of error.
*/
char **
-xend_get_domains(virConnectPtr xend)
+xenDaemonListDomains(virConnectPtr xend)
{
size_t extra = 0;
struct sexpr *root = NULL;
}
/**
- * xend_domain_to_sexpr:
- * @domain: a domain pointer
- *
- * Internal function converting the domain informations into an S-Expression
- * that the Xen Daemon can use to create instances
- *
- * Returns the new S-Expression or NULL in case of error.
- */
-static struct sexpr *
-xend_domain_to_sexpr(const struct xend_domain *domain)
-{
- struct sexpr *lst = sexpr_nil();
- struct sexpr *image = sexpr_nil();
- struct sexpr *builder = sexpr_nil();
- const char *restart[] = { NULL, "restart",
- "preserve", "rename-restart"
- };
- size_t i;
-
- if (domain == NULL)
- return (NULL);
-
- lst = sexpr_append(lst, sexpr_string("vm", -1));
- lst = sexpr_append_str(lst, "name", domain->name);
- lst = sexpr_append_uuid(lst, "uuid", domain->uuid);
- lst = sexpr_append_u64(lst, "memory", domain->memory);
- lst = sexpr_append_int(lst, "ssidref", domain->ssidref);
- lst = sexpr_append_u64(lst, "maxmem", domain->max_memory);
- lst =
- sexpr_append_str(lst, "on_poweroff", restart[domain->on_poweroff]);
- lst = sexpr_append_str(lst, "on_reboot", restart[domain->on_reboot]);
- lst = sexpr_append_str(lst, "on_crash", restart[domain->on_crash]);
- lst = sexpr_append_int(lst, "vcpus", domain->vcpus);
-
- builder = sexpr_append(builder, sexpr_string("linux", -1));
- builder = sexpr_append_str(builder, "kernel", domain->image.kernel);
- builder = sexpr_append_str(builder, "ramdisk", domain->image.ramdisk);
- builder = sexpr_append_str(builder, "root", domain->image.root);
- builder = sexpr_append_str(builder, "args", domain->image.extra);
-
- image = sexpr_append(image, sexpr_string("image", -1));
- image = sexpr_append(image, builder);
-
- lst = sexpr_append(lst, image);
-
- for (i = 0; i < domain->n_vbds; i++) {
- struct sexpr *device = sexpr_nil();
- struct sexpr *vbd = xend_device_vbd_to_sexpr(&domain->vbds[i]);
-
- device = sexpr_append(device, sexpr_string("device", -1));
- device = sexpr_append(device, vbd);
- lst = sexpr_append(lst, device);
- }
-
- for (i = 0; i < domain->n_vifs; i++) {
- struct sexpr *device = sexpr_nil();
- struct sexpr *vif = xend_device_vif_to_sexpr(&domain->vifs[i]);
-
- device = sexpr_append(device, sexpr_string("device", -1));
- device = sexpr_append(device, vif);
- lst = sexpr_append(lst, device);
- }
-
- for (i = 0; i < domain->n_ioports; i++) {
- struct sexpr *device = sexpr_nil();
- struct sexpr *ioport = sexpr_nil();
-
- ioport = sexpr_append(ioport, sexpr_string("ioports", -1));
- ioport = sexpr_append_int(ioport, "from", domain->ioports[i].from);
- ioport = sexpr_append_int(ioport, "to", domain->ioports[i].to);
-
- device = sexpr_append(device, sexpr_string("device", -1));
- device = sexpr_append(device, ioport);
- lst = sexpr_append(lst, device);
- }
-
- return lst;
-}
-
-/**
- * xend_create:
- * @xend: A xend instance
- * @info: A struct xen_domain instance describing the domain
- *
- * This method will create a domain based the passed in description. The
- * domain will be paused after creation and must be unpaused with
- * xend_unpause() to begin execution.
- *
- * Returns 0 for success, -1 (with errno) on error
- */
-
-int
-xend_create(virConnectPtr xend, const struct xend_domain *dom)
-{
- int ret, serrno;
- struct sexpr *sexpr;
- char buffer[4096];
- char *ptr;
-
- sexpr = xend_domain_to_sexpr(dom);
- sexpr2string(sexpr, buffer, sizeof(buffer));
- ptr = urlencode(buffer);
-
- ret = xend_op(xend, "", "op", "create", "config", ptr, NULL);
-
- serrno = errno;
- free(ptr);
- sexpr_free(sexpr);
- errno = serrno;
-
- return ret;
-}
-
-/**
- * xend_create_sexpr:
+ * xenDaemonDomainCreateLinux:
* @xend: A xend instance
* @sexpr: An S-Expr description of the domain.
*
* This method will create a domain based the passed in description. The
* domain will be paused after creation and must be unpaused with
- * xend_unpause() to begin execution.
+ * xenDaemonResumeDomain() to begin execution.
* This method may be deprecated once switching to XML-RPC based communcations
* with xend.
*
*/
int
-xend_create_sexpr(virConnectPtr xend, const char *sexpr)
+xenDaemonDomainCreateLinux(virConnectPtr xend, const char *sexpr)
{
int ret, serrno;
char *ptr;
return ret;
}
-/**
- * xend_set_max_memory:
- * @xend: A xend instance
- * @name: The name of the domain
- * @value: The maximum memory in bytes
- *
- * This method will set the maximum amount of memory that can be allocated to
- * a domain. Please note that a domain is able to allocate up to this amount
- * on its own (although under normal circumstances, memory allocation for a
- * domain is only done through xend_set_memory()).
- *
- * Returns 0 for success; -1 (with errno) on error
- */
-int
-xend_set_max_memory(virConnectPtr xend, const char *name, uint64_t value)
-{
- char buf[1024];
-
- snprintf(buf, sizeof(buf), "%llu", value >> 20);
- return xend_op(xend, name, "op", "maxmem_set", "memory", buf, NULL);
-}
-
/**
* xend_set_memory:
* @xend: A xend instance
NULL);
}
+
/**
- * xend_vbd_create:
- * @xend: A xend instance
- * @name: The name of the domain
- * @vbd: A virtual block device description
- *
- * This method creates and attachs a block device to a domain. A successful
- * return value does not indicate that the device successfully attached,
- * rather, one should use xend_wait_for_devices() to block until the device
- * has been successfully attached.
- *
- * Returns 0 on success; -1 (with errno) on error
- */
-int
-xend_vbd_create(virConnectPtr xend,
- const char *name, const struct xend_device_vbd *vbd)
-{
- char buffer[4096];
- char *ptr;
- int ret;
- struct sexpr *device;
-
- device = xend_device_vbd_to_sexpr(vbd);
-
- sexpr2string(device, buffer, sizeof(buffer));
- ptr = urlencode(buffer);
-
- ret = xend_op(xend, name, "op", "device_create", "config", ptr, NULL);
-
- sexpr_free(device);
-
- return ret;
-}
-
-/**
- * xend_vbd_destroy:
- * @xend: A xend instance
- * @name: The name of the domain
- * @vbd: A virtual block device description
- *
- * This method detachs a block device from a given domain. A successful return
- * value does not indicate that the device successfully detached, rather, one
- * should use xend_wait_for_devices() to block until the device has been
- * successfully detached.
- *
- * Returns 0 on success; -1 (with errno) on error
- */
-int
-xend_vbd_destroy(virConnectPtr xend,
- const char *name, const struct xend_device_vbd *vbd)
-{
- return xend_op(xend, name, "op", "device_destroy", "type", "vbd",
- "dev", vbd->dev, NULL);
-}
-
-/**
- * xend_vif_create:
- * @xend: A xend instance
- * @name: The name of the domain
- * @vif: A virtual network device description
- *
- * This method creates and attachs a network device to a domain. A successful
- * return value does not indicate that the device successfully attached,
- * rather, one should use xend_wait_for_devices() to network until the device
- * has been successfully attached.
- *
- * Returns 0 on success; -1 (with errno) on error
- */
-int
-xend_vif_create(virConnectPtr xend,
- const char *name, const struct xend_device_vif *vif)
-{
- char buffer[4096];
- char *ptr;
- int ret;
- struct sexpr *device;
-
- device = xend_device_vif_to_sexpr(vif);
-
- sexpr2string(device, buffer, sizeof(buffer));
- ptr = urlencode(buffer);
-
- ret = xend_op(xend, name, "op", "device_create", "config", ptr, NULL);
-
- sexpr_free(device);
-
- return ret;
-}
-
-static int
-get_vif_handle(virConnectPtr xend,
- const char *name ATTRIBUTE_UNUSED,
- const struct xend_device_vif *vif,
- char *buffer, size_t n_buffer)
-{
- struct sexpr *root;
- char path[4096];
- int ret = -1;
- struct sexpr *_for_i, *node;
-
- root = sexpr_get(xend, "/xend/domain");
- if (root == NULL)
- goto error;
-
- errno = ESRCH;
-
- for (_for_i = root, node = root->car; _for_i->kind == SEXPR_CONS;
- _for_i = _for_i->cdr, node = _for_i->car) {
- uint8_t mac[6];
-
- if (node->car->kind != SEXPR_VALUE)
- continue;
-
- snprintf(path, sizeof(path), "%s/mac", node->car->value);
- sexpr_mac(mac, node, path);
- if (memcmp(mac, vif->mac, 6) == 0) {
- snprintf(buffer, n_buffer, "%s", node->car->value);
- ret = 0;
- break;
- }
- }
-
- error:
- sexpr_free(root);
- return ret;
-
-}
-
-/**
- * xend_vif_destroy:
- * @xend: A xend instance
- * @name: The name of the domain
- * @vif: A virtual network device description
- *
- * This method detachs a network device from a given domain. A successful
- * return value does not indicate that the device successfully detached,
- * rather, one should use xend_wait_for_devices() to network until the device
- * has been successfully detached.
- *
- * Returns 0 on success; -1 (with errno) on error
- */
-int
-xend_vif_destroy(virConnectPtr xend,
- const char *name, const struct xend_device_vif *vif)
-{
- char handle[1024];
-
- if (get_vif_handle(xend, name, vif, handle, sizeof(handle)) == -1)
- return -1;
-
- return xend_op(xend, name, "op", "device_destroy", "type", "vif",
- "dev", handle, NULL);
-}
-
-/**
- * sexpr_to_xend_domain_size:
- * @sexpr: the S-Expression
- * @n_vbds: the number of virtual block devices used (OUT)
- * @n_vifs: the number of network interface devices used (OUT)
+ * sexpr_to_xend_domain_size:
+ * @sexpr: the S-Expression
+ * @n_vbds: the number of virtual block devices used (OUT)
+ * @n_vifs: the number of network interface devices used (OUT)
*
* Helper function to compute the size in byte needed for the strings
* of a domain.
return size;
}
-/**
- * sexpr_to_xend_domain_info:
- * @root: an S-Expression describing a domain
- * @info: a info data structure to fill=up
- *
- * Internal routine filling up the info structure with the values from
- * the domain root provided.
- *
- * Returns 0 in case of success, -1 in case of error
- */
-static int
-sexpr_to_xend_domain_info(struct sexpr *root, virDomainInfoPtr info)
-{
- const char *flags;
-
-
- if ((root == NULL) || (info == NULL))
- return (-1);
-
- info->memory = sexpr_u64(root, "domain/memory") << 10;
- info->maxMem = sexpr_u64(root, "domain/maxmem") << 10;
- flags = sexpr_node(root, "domain/state");
-
- if (flags) {
- if (strchr(flags, 'c'))
- info->state = VIR_DOMAIN_CRASHED;
- else if (strchr(flags, 's'))
- info->state = VIR_DOMAIN_SHUTDOWN;
- else if (strchr(flags, 'd'))
- info->state = VIR_DOMAIN_SHUTOFF;
- else if (strchr(flags, 'p'))
- info->state = VIR_DOMAIN_PAUSED;
- else if (strchr(flags, 'b'))
- info->state = VIR_DOMAIN_BLOCKED;
- else if (strchr(flags, 'r'))
- info->state = VIR_DOMAIN_RUNNING;
- } else {
- info->state = VIR_DOMAIN_NOSTATE;
- }
- info->cpuTime = sexpr_float(root, "domain/cpu_time") * 1000000000;
- info->nrVirtCpu = sexpr_int(root, "domain/vcpus");
- return (0);
-}
-
/**
* sexpr_to_xend_domain:
* @root: an S-Expression describing a domain
}
/**
- * xend_get_domain_info:
- * @xend: A xend instance
- * @name: The name of the domain
- *
- * This method looks up information about a domain and update the
- * information block provided.
- *
- * Returns 0 in case of success, -1 in case of error
- */
-int
-xend_get_domain_info(virDomainPtr domain, virDomainInfoPtr info)
-{
- struct sexpr *root;
- int ret;
-
- if ((domain == NULL) || (info == NULL))
- return (-1);
-
- root =
- sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
- if (root == NULL)
- return (-1);
-
- ret = sexpr_to_xend_domain_info(root, info);
- sexpr_free(root);
- return (ret);
-}
-
-/**
- * xend_get_domain:
+ * xenDaemonDomainLookupByName:
* @xend: A xend instance
* @name: The name of the domain
*
* Returns domain info on success; NULL (with errno) on error
*/
struct xend_domain *
-xend_get_domain(virConnectPtr xend, const char *domname)
+xenDaemonDomainLookupByName(virConnectPtr xend, const char *domname)
{
struct sexpr *root;
struct xend_domain *dom = NULL;
}
/**
- * xend_get_domain_ids:
+ * xenDaemonDomainLookupByName_ids:
* @xend: A xend instance
* @domname: The name of the domain
* @uuid: return value for the UUID if not NULL
* Returns the id on success; -1 (with errno) on error
*/
int
-xend_get_domain_ids(virConnectPtr xend, const char *domname,
+xenDaemonDomainLookupByName_ids(virConnectPtr xend, const char *domname,
unsigned char *uuid)
{
struct sexpr *root;
return (NULL);
}
+/*****************************************************************
+ ******
+ ******
+ ******
+ ******
+ Needed helper code
+ ******
+ ******
+ ******
+ ******
+ *****************************************************************/
/**
- * xend_get_domain_xml:
+ * sexpr_to_xend_domain_info:
+ * @root: an S-Expression describing a domain
+ * @info: a info data structure to fill=up
+ *
+ * Internal routine filling up the info structure with the values from
+ * the domain root provided.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+static int
+sexpr_to_xend_domain_info(struct sexpr *root, virDomainInfoPtr info)
+{
+ const char *flags;
+
+
+ if ((root == NULL) || (info == NULL))
+ return (-1);
+
+ info->memory = sexpr_u64(root, "domain/memory") << 10;
+ info->maxMem = sexpr_u64(root, "domain/maxmem") << 10;
+ flags = sexpr_node(root, "domain/state");
+
+ if (flags) {
+ if (strchr(flags, 'c'))
+ info->state = VIR_DOMAIN_CRASHED;
+ else if (strchr(flags, 's'))
+ info->state = VIR_DOMAIN_SHUTDOWN;
+ else if (strchr(flags, 'd'))
+ info->state = VIR_DOMAIN_SHUTOFF;
+ else if (strchr(flags, 'p'))
+ info->state = VIR_DOMAIN_PAUSED;
+ else if (strchr(flags, 'b'))
+ info->state = VIR_DOMAIN_BLOCKED;
+ else if (strchr(flags, 'r'))
+ info->state = VIR_DOMAIN_RUNNING;
+ } else {
+ info->state = VIR_DOMAIN_NOSTATE;
+ }
+ info->cpuTime = sexpr_float(root, "domain/cpu_time") * 1000000000;
+ info->nrVirtCpu = sexpr_int(root, "domain/vcpus");
+ return (0);
+}
+
+
+/*****************************************************************
+ ******
+ ******
+ ******
+ ******
+ Refactored
+ ******
+ ******
+ ******
+ ******
+ *****************************************************************/
+/**
+ * xenDaemonOpen:
+ * @conn: an existing virtual connection block
+ * @name: optional argument to select a connection type
+ * @flags: combination of virDrvOpenFlag(s)
+ *
+ * Creates a localhost Xen Daemon connection
+ * Note: this doesn't try to check if the connection actually works
+ *
+ * Returns 0 in case of success, -1 in case of error.
+ */
+int
+xenDaemonOpen(virConnectPtr conn, const char *name, int flags)
+{
+ xmlURIPtr uri;
+ int ret;
+
+ if (name == NULL) {
+ name = "http://localhost:8000/";
+ }
+ uri = xmlParseURI(name);
+ if (uri == NULL) {
+ if (!(flags & VIR_DRV_OPEN_QUIET))
+ virXendError(conn, VIR_ERR_NO_SUPPORT, name);
+ return(-1);
+ }
+
+ xmlFreeURI(uri);
+
+ return (xenDaemonOpen_tcp(conn, "localhost", 8000));
+
+/* return(xenDaemonOpen_unix(conn, "/var/lib/xend/xend-socket")); */
+
+ return(ret);
+}
+
+/**
+ * xenDaemonClose:
+ * @conn: an existing virtual connection block
+ *
+ * This method should be called when a connection to xend instance
+ * initialized with xenDaemonOpen is no longer needed
+ * to free the associated resources.
+ *
+ * Returns 0 in case of succes, -1 in case of error
+ */
+int
+xenDaemonClose(virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return(0);
+}
+
+/**
+ * xenDaemonDomainSuspend:
+ * @domain: pointer to the Domain block
+ *
+ * Pause the domain, the domain is not scheduled anymore though its resources
+ * are preserved. Use xenDaemonDomainResume() to resume execution.
+ *
+ * Returns 0 in case of success, -1 (with errno) in case of error.
+ */
+int
+xenDaemonDomainSuspend(virDomainPtr domain)
+{
+ if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
+ virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+ return(-1);
+ }
+ return xend_op(domain->conn, domain->name, "op", "pause", NULL);
+}
+
+/**
+ * xenDaemonDomainResume:
+ * @xend: pointer to the Xem Daemon block
+ * @name: name for the domain
+ *
+ * Resume the domain after xenDaemonDomainSuspend() has been called
+ *
+ * Returns 0 in case of success, -1 (with errno) in case of error.
+ */
+int
+xenDaemonDomainResume(virDomainPtr domain)
+{
+ if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
+ virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+ return(-1);
+ }
+ return xend_op(domain->conn, domain->name, "op", "unpause", NULL);
+}
+
+/**
+ * xenDaemonDomainShutdown:
+ * @domain: pointer to the Domain block
+ *
+ * Shutdown the domain, the OS is requested to properly shutdown
+ * and the domain may ignore it. It will return immediately
+ * after queuing the request.
+ *
+ * Returns 0 in case of success, -1 (with errno) in case of error.
+ */
+int
+xenDaemonDomainShutdown(virDomainPtr domain)
+{
+ if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
+ virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+ return(-1);
+ }
+ return xend_op(domain->conn, domain->name, "op", "shutdown", "reason", "halt", NULL);
+}
+
+/**
+ * xenDaemonDomainDestroy:
+ * @domain: pointer to the Domain block
+ *
+ * Abruptly halt the domain, the OS is not properly shutdown and the
+ * resources allocated for the domain are immediately freed, mounted
+ * filesystems will be marked as uncleanly shutdown.
+ * After calling this function, the domain's status will change to
+ * dying and will go away completely once all of the resources have been
+ * unmapped (usually from the backend devices).
+ *
+ * Returns 0 in case of success, -1 (with errno) in case of error.
+ */
+int
+xenDaemonDomainDestroy(virDomainPtr domain)
+{
+ if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
+ virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+ return(-1);
+ }
+ return xend_op(domain->conn, domain->name, "op", "destroy", NULL);
+}
+
+/**
+ * xenDaemonDomainSave:
+ * @domain: pointer to the Domain block
+ * @filename: path for the output file
+ *
+ * This method will suspend a domain and save its memory contents to
+ * a file on disk. Use xenDaemonDomainRestore() to restore a domain after
+ * saving.
+ * Note that for remote Xen Daemon the file path will be interpreted in
+ * the remote host.
+ *
+ * Returns 0 in case of success, -1 (with errno) in case of error.
+ */
+int
+xenDaemonDomainSave(virDomainPtr domain, const char *filename)
+{
+ if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL) ||
+ (filename == NULL)) {
+ virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+ return(-1);
+ }
+ return xend_op(domain->conn, domain->name, "op", "save", "file", filename, NULL);
+}
+
+/**
+ * xenDaemonDomainRestore:
+ * @conn: pointer to the Xem Daemon block
+ * @filename: path for the output file
+ *
+ * This method will restore a domain saved to disk by xenDaemonDomainSave().
+ * Note that for remote Xen Daemon the file path will be interpreted in
+ * the remote host.
+ *
+ * Returns 0 in case of success, -1 (with errno) in case of error.
+ */
+int
+xenDaemonDomainRestore(virConnectPtr conn, const char *filename)
+{
+ if ((conn == NULL) || (filename == NULL)) {
+ /* this should be caught at the interface but ... */
+ virXendError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
+ return (-1);
+ }
+ return xend_op(conn, "", "op", "restore", "file", filename, NULL);
+}
+
+/**
+ * xenDaemonDomainSetMaxMemory:
+ * @domain: pointer to the Domain block
+ * @memory: The maximum memory in kilobytes
+ *
+ * This method will set the maximum amount of memory that can be allocated to
+ * a domain. Please note that a domain is able to allocate up to this amount
+ * on its own (although under normal circumstances, memory allocation for a
+ * domain is only done through xend_set_memory()).
+ *
+ * Returns 0 for success; -1 (with errno) on error
+ */
+int
+xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
+{
+ char buf[1024];
+
+ if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
+ virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+ return(-1);
+ }
+ snprintf(buf, sizeof(buf), "%lu", memory >> 10);
+ return xend_op(domain->conn, domain->name, "op", "maxmem_set", "memory",
+ buf, NULL);
+}
+
+/**
+ * xenDaemonDomainDumpXML:
* @domain: a domain object
*
* Provide an XML description of the domain.
* the caller must free() the returned value.
*/
char *
-xend_get_domain_xml(virDomainPtr domain)
+xenDaemonDomainDumpXML(virDomainPtr domain)
{
char *ret = NULL;
struct sexpr *root;
- if (!VIR_IS_DOMAIN(domain)) {
- /* this should be caught at the interface but ... */
- virXendError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
+ if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
+ virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+ return(NULL);
}
- root =
- sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
+ root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
if (root == NULL)
return (NULL);
return (ret);
}
+
+/**
+ * xenDaemonDomainGetInfo:
+ * @domain: a domain object
+ * @info: pointer to a virDomainInfo structure allocated by the user
+ *
+ * This method looks up information about a domain and update the
+ * information block provided.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+int
+xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
+{
+ struct sexpr *root;
+ int ret;
+
+ if ((domain == NULL) || (info == NULL))
+ return (-1);
+
+ root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
+ if (root == NULL)
+ return (-1);
+
+ ret = sexpr_to_xend_domain_info(root, info);
+ sexpr_free(root);
+ return (ret);
+}
+
/*
* libxend/xend.h -- Xend library
*
- * Copyright (C) 2005
+ * Copyright (C) 2005,2006
*
* Anthony Liguori <aliguori@us.ibm.com>
+ * Daniel Veillard <veillard@redhat.com>
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file COPYING in the main directory of this archive
const char *cc_compile_date;
};
-/**
- * \brief Setup the connection to the local Xend instance
- * \return 0 in case of success, -1 in case of error
- *
- * This method creates a new Xend instance preferrably trying
- * to connect with the domain socket but if necessary using
- * TCP (only on localhost though).
- *
- * This function may not fail if Xend is not running.
- *
- * Make sure to call xend_cleanup().
- */
- int xend_setup(virConnectPtr conn);
-
/**
* \brief Setup the connection to a xend instance via TCP
* \param host The host name to connect to
*
* This function may not fail if Xend is not running.
*
- * Make sure to call xend_cleanup().
+ * Make sure to call xenDaemonClose().
*/
- int xend_setup_tcp(virConnectPtr xend, const char *host, int port);
+int xenDaemonOpen_tcp(virConnectPtr xend, const char *host, int port);
/**
* \brief Setup the connection to xend instance via a Unix domain socket
*
* This function may not fail if Xend is not running.
*
- * Make sure to call xend_cleanup().
+ * Make sure to call xenDaemonClose().
*/
- int xend_setup_unix(virConnectPtr xend, const char *path);
+int xenDaemonOpen_unix(virConnectPtr xend, const char *path);
-/**
- * \brief Delete a previously allocated Xend instance
- * \param xend The xend instance
- *
- * This method should be called when a connection to xend instance
- * initialized with xend_setup[_{tcp, unix}] is no longer needed
- * to free the associated resources.
- */
- void xend_cleanup(virConnectPtr xend);
/**
* \brief Blocks until a domain's devices are initialized
int xend_wait_for_devices(virConnectPtr xend, const char *name);
/**
- * \brief Pause a domain
- * \param xend A xend instance
- * \param name The domain's name
- * \return 0 for success; -1 (with errno) on error
- *
- * This method will make sure that Xen does not schedule the domain
- * anymore until after xend_unpause() has been called.
- */
- int xend_pause(virConnectPtr xend, const char *name);
-
-/**
- * \brief Unpause a domain
- * \param xend A xend instance
- * \param name The domain's name
- * \return 0 for success; -1 (with errno) on error
- *
- * This method will allow a paused domain (the result of xen_pause())
- * to be scheduled in the future.
- */
- int xend_unpause(virConnectPtr xend, const char *name);
-
-/**
- * \brief Unpause a domain
+ * \brief Rename a domain
* \param xend A xend instance
* \param oldname The domain's name
* \param name The new name
*/
int xend_reboot(virConnectPtr xend, const char *name);
-/**
- * \brief Request a domain to shutdown
- * \param xend A xend instance
- * \param name The domain's name
- * \return 0 for success; -1 (with errno) on error
- *
- * This method *requests* that a domain shutdown itself. This is only
- * a request and the domain may ignore it. It will return immediately
- * after queuing the request.
- */
- int xend_shutdown(virConnectPtr xend, const char *name);
-
-/**
- * \brief Destroy a domain
- * \param xend A xend instance
- * \param name The domain's name
- * \return 0 for success; -1 (with errno) on error
- *
- * This method will immediately destroy a domain. If you call this
- * function while a domain is running, you risk corrupting its devices.
- * After calling this function, the domain's status will change to
- * dying and will go away completely once all of the resources have been
- * unmapped (usually from the backend devices).
- */
- int xend_destroy(virConnectPtr xend, const char *name);
-
-/**
- * \brief Save a domain to the disk
- * \param xend A xend instance
- * \param name The domain's name
- * \param filename The filename to save to
- * \return 0 for success; -1 (with errno) on error
- *
- * This method will suspend a domain and save its memory contents to
- * a file on disk. Use xend_restore() to restore a domain after
- * saving.
- */
- int xend_save(virConnectPtr xend, const char *name,
- const char *filename);
-
-/**
- * \brief Restore a domain from the disk
- * \param xend A xend instance
- * \param filename The filename to restore from
- * \return 0 for success; -1 (with errno) on error
- *
- * This method will restore a domain saved to disk by xend_save().
- */
- int xend_restore(virConnectPtr xend, const char *filename);
-
/**
* \brief Obtain a list of currently running domains
* \param xend A xend instance
* This method will return an array of names of currently running
* domains. The memory should be released will a call to free().
*/
- char **xend_get_domains(virConnectPtr xend);
-
-/**
- * \brief Create a new domain
- * \param xend A xend instance
- * \param info A struct xen_domain instance describing the domain
- * \return 0 for success; -1 (with errno) on error
- *
- * This method will create a domain based the passed in description. The
- * domain will be paused after creation and must be unpaused with
- * xend_unpause() to begin execution.
- */
- int xend_create(virConnectPtr xend, const struct xend_domain *info);
+ char **xenDaemonListDomains(virConnectPtr xend);
/**
* \brief Create a new domain
*
* This method will create a domain based the passed in description. The
* domain will be paused after creation and must be unpaused with
- * xend_unpause() to begin execution.
+ * xenDaemonResumeDomain() to begin execution.
*/
- int xend_create_sexpr(virConnectPtr xend, const char *sexpr);
-
-/**
- * \brief Set the maximum memory for a domain
- * \param xend A xend instance
- * \param name The name of the domain
- * \param value The maximum memory in bytes
- * \return 0 for success; -1 (with errno) on error
- *
- * This method will set the maximum amount of memory that can be allocated to
- * a domain. Please note that a domain is able to allocate up to this amount
- * on its own (although under normal circumstances, memory allocation for a
- * domain is only done through xend_set_memory()).
- */
- int xend_set_max_memory(virConnectPtr xend, const char *name,
- uint64_t value);
+ int xenDaemonDomainCreateLinux(virConnectPtr xend, const char *sexpr);
/**
* \brief Set the memory allocation for a domain
int xend_set_memory(virConnectPtr xend, const char *name,
uint64_t value);
-/**
- * \brief Create a virtual block device
- * \param xend A xend instance
- * \param name The name of the domain
- * \param vbd A virtual block device description
- * \return 0 on success; -1 (with errno) on error
- *
- * This method creates and attachs a block device to a domain. A successful
- * return value does not indicate that the device successfully attached,
- * rather, one should use xend_wait_for_devices() to block until the device
- * has been successfully attached.
- */
- int xend_vbd_create(virConnectPtr xend,
- const char *name,
- const struct xend_device_vbd *vbd);
-
-/**
- * \brief Destroy a virtual block device
- * \param xend A xend instance
- * \param name The name of the domain
- * \param vbd A virtual block device description
- * \return 0 on success; -1 (with errno) on error
- *
- * This method detachs a block device from a given domain. A successful return
- * value does not indicate that the device successfully detached, rather, one
- * should use xend_wait_for_devices() to block until the device has been
- * successfully detached.
- */
- int xend_vbd_destroy(virConnectPtr xend,
- const char *name,
- const struct xend_device_vbd *vbd);
-
-/**
- * \brief Create a virtual network device
- * \param xend A xend instance
- * \param name The name of the domain
- * \param vif A virtual network device description
- * \return 0 on success; -1 (with errno) on error
- *
- * This method creates and attachs a network device to a domain. A successful
- * return value does not indicate that the device successfully attached,
- * rather, one should use xend_wait_for_devices() to network until the device
- * has been successfully attached.
- */
- int xend_vif_create(virConnectPtr xend,
- const char *name,
- const struct xend_device_vif *vif);
-
-/**
- * \brief Destroy a virtual network device
- * \param xend A xend instance
- * \param name The name of the domain
- * \param vif A virtual network device description
- * \return 0 on success; -1 (with errno) on error
- *
- * This method detachs a network device from a given domain. A successful
- * return value does not indicate that the device successfully detached,
- * rather, one should use xend_wait_for_devices() to network until the device
- * has been successfully detached.
- */
- int xend_vif_destroy(virConnectPtr xend,
- const char *name,
- const struct xend_device_vif *vif);
-
/**
* \brief Lookup information about a domain
* \param xend A xend instance
* it in the form of a struct xend_domain. This should be
* free()'d when no longer needed.
*/
- struct xend_domain *xend_get_domain(virConnectPtr xend,
+ struct xend_domain *xenDaemonDomainLookupByName(virConnectPtr xend,
const char *name);
/**
*
* This method looks up the ids of a domain
*/
- int xend_get_domain_ids(virConnectPtr xend,
+ int xenDaemonDomainLookupByName_ids(virConnectPtr xend,
const char *name, unsigned char *uuid);
-/**
- * \brief Get status informations for a domain
- * \param domain A xend domain
- * \param info An information block provided by the user
- * \return 0 in case of success, -1 in case of error
- *
- * This method looks up information about a domain and update the
- * information block provided.
- */
- int xend_get_domain_info(virDomainPtr domain, virDomainInfoPtr info);
/**
* \brief Lookup information about the host machine
*/
int xend_log(virConnectPtr xend, char *buffer, size_t n_buffer);
-/**
- * \brief Provide an XML description of the domain.
- * \param domain a xend domain object
- * \return a 0 terminated UTF-8 encoded XML instance, or NULL in case of error.
- * the caller must free() the returned value.
- *
- * Provide an XML description of the domain.
- */
- char *xend_get_domain_xml(virDomainPtr domain);
+/* refactored ones */
+int xenDaemonOpen(virConnectPtr conn, const char *name, int flags);
+int xenDaemonClose(virConnectPtr conn);
+int xenDaemonDomainSuspend(virDomainPtr domain);
+int xenDaemonDomainResume(virDomainPtr domain);
+int xenDaemonDomainShutdown(virDomainPtr domain);
+int xenDaemonDomainDestroy(virDomainPtr domain);
+int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
+int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
+int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
+int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
+char *xenDaemonDomainDumpXML(virDomainPtr domain);
+
#ifdef __cplusplus
}
#endif