mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 13:05:27 +00:00
Hook up virDomainGetXMLDesc to driver backends. Added implementation of virDomainGetXMLDesc driver for the setuid proxy
This commit is contained in:
parent
0342994a8d
commit
098e0a4bdc
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
|||||||
|
Wed Aug 9 10:17:03 EDT 2006 Daniel Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* src/driver.h, src/libvirt.c: Made the virDomainGetXMLDesc
|
||||||
|
method use the driver backends.
|
||||||
|
* src/xend_internal.c: Surround all functions which are not
|
||||||
|
needed for proxy with #ifndef PROXY. Refactor XML generator
|
||||||
|
functions to allow calling from proxy based on domain id
|
||||||
|
instead of virDomainPtr object
|
||||||
|
* src/xs_internal.c, src/xs_internal.h: Change signature
|
||||||
|
of method for extracting VNC port & console TTY to use domain
|
||||||
|
id instead of virDomainPtr. Surround functions not used by
|
||||||
|
proxy in #ifndef PROXY
|
||||||
|
* src/xml.c:Surround functions not used by proxy in #ifndef PROXY
|
||||||
|
* src/test.c, src/xen_internal.c: Added NULL entry for new
|
||||||
|
driver method for fetching XML
|
||||||
|
* src/proxy_internal.c, src/proxy_internal.h, proxy/libvirt_proxy.c:
|
||||||
|
Added implmentation of virDomainGetXMLDesc driver method which
|
||||||
|
goes via proxy.
|
||||||
|
|
||||||
Tue Aug 8 23:24:51 CEST 2006 Daniel Veillard <veillard@redhat.com>
|
Tue Aug 8 23:24:51 CEST 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* src/driver.h src/libvirt.c src/proxy_internal.c src/test.c
|
* src/driver.h src/libvirt.c src/proxy_internal.c src/test.c
|
||||||
|
@ -6,11 +6,11 @@ INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include \
|
|||||||
|
|
||||||
|
|
||||||
libexec_PROGRAMS = libvirt_proxy
|
libexec_PROGRAMS = libvirt_proxy
|
||||||
LIBS=
|
|
||||||
|
|
||||||
libvirt_proxy_SOURCES = libvirt_proxy.c @top_srcdir@/src/xend_internal.c \
|
libvirt_proxy_SOURCES = libvirt_proxy.c @top_srcdir@/src/xend_internal.c \
|
||||||
@top_srcdir@/src/xen_internal.c @top_srcdir@/src/virterror.c \
|
@top_srcdir@/src/xen_internal.c @top_srcdir@/src/virterror.c \
|
||||||
@top_srcdir@/src/sexpr.c
|
@top_srcdir@/src/sexpr.c @top_srcdir@/src/xml.c \
|
||||||
|
@top_srcdir@/src/xs_internal.c
|
||||||
libvirt_proxy_LDFLAGS =
|
libvirt_proxy_LDFLAGS =
|
||||||
libvirt_proxy_DEPENDENCIES =
|
libvirt_proxy_DEPENDENCIES =
|
||||||
libvirt_proxy_LDADD =
|
libvirt_proxy_LDADD =
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "proxy_internal.h"
|
#include "proxy_internal.h"
|
||||||
#include "xen_internal.h"
|
#include "xen_internal.h"
|
||||||
#include "xend_internal.h"
|
#include "xend_internal.h"
|
||||||
|
#include "xs_internal.h"
|
||||||
|
|
||||||
static int fdServer = -1;
|
static int fdServer = -1;
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
@ -71,6 +72,11 @@ proxyInitXen(void) {
|
|||||||
fprintf(stderr, "Failed to connect to Xen daemon\n");
|
fprintf(stderr, "Failed to connect to Xen daemon\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
ret = xenStoreOpen(conn, NULL, VIR_DRV_OPEN_QUIET | VIR_DRV_OPEN_RO);
|
||||||
|
if (ret < 0) {
|
||||||
|
fprintf(stderr, "Failed to open XenStore connection");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
ret = xenDaemonGetVersion(conn, &xenVersion2);
|
ret = xenDaemonGetVersion(conn, &xenVersion2);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
fprintf(stderr, "Failed to get Xen daemon version\n");
|
fprintf(stderr, "Failed to get Xen daemon version\n");
|
||||||
@ -331,6 +337,7 @@ proxyReadClientSocket(int nr) {
|
|||||||
virProxyFullPacket request;
|
virProxyFullPacket request;
|
||||||
virProxyPacketPtr req = (virProxyPacketPtr) &request;
|
virProxyPacketPtr req = (virProxyPacketPtr) &request;
|
||||||
int ret;
|
int ret;
|
||||||
|
char *xml;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
ret = read(pollInfos[nr].fd, req, sizeof(virProxyPacket));
|
ret = read(pollInfos[nr].fd, req, sizeof(virProxyPacket));
|
||||||
@ -559,6 +566,27 @@ retry2:
|
|||||||
req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo);
|
req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case VIR_PROXY_DOMAIN_XML:
|
||||||
|
if (req->len != sizeof(virProxyPacket))
|
||||||
|
goto comm_error;
|
||||||
|
|
||||||
|
xml = xenDaemonDomainDumpXMLByID(conn, request.data.arg);
|
||||||
|
if (!xml) {
|
||||||
|
req->data.arg = -1;
|
||||||
|
req->len = sizeof(virProxyPacket);
|
||||||
|
} else {
|
||||||
|
int xmllen = strlen(xml);
|
||||||
|
if (xmllen > sizeof(request.extra.str)) {
|
||||||
|
req->data.arg = -2;
|
||||||
|
req->len = sizeof(virProxyPacket);
|
||||||
|
} else {
|
||||||
|
req->data.arg = 0;
|
||||||
|
memmove(&request.extra.str[0], xml, xmllen);
|
||||||
|
req->len = sizeof(virProxyPacket) + xmllen;
|
||||||
|
}
|
||||||
|
free(xml);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
goto comm_error;
|
goto comm_error;
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,9 @@ typedef int
|
|||||||
typedef int
|
typedef int
|
||||||
(*virDrvDomainRestore) (virConnectPtr conn,
|
(*virDrvDomainRestore) (virConnectPtr conn,
|
||||||
const char *from);
|
const char *from);
|
||||||
|
typedef char *
|
||||||
|
(*virDrvDomainDumpXML) (virDomainPtr dom,
|
||||||
|
int flags);
|
||||||
|
|
||||||
typedef int
|
typedef int
|
||||||
(*virDrvDomainSetVcpus) (virDomainPtr domain,
|
(*virDrvDomainSetVcpus) (virDomainPtr domain,
|
||||||
@ -164,6 +167,7 @@ struct _virDriver {
|
|||||||
virDrvDomainSetVcpus domainSetVcpus;
|
virDrvDomainSetVcpus domainSetVcpus;
|
||||||
virDrvDomainPinVcpu domainPinVcpu;
|
virDrvDomainPinVcpu domainPinVcpu;
|
||||||
virDrvDomainGetVcpus domainGetVcpus;
|
virDrvDomainGetVcpus domainGetVcpus;
|
||||||
|
virDrvDomainDumpXML domainDumpXML;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1442,6 +1442,8 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
char *
|
char *
|
||||||
virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
char *ret = NULL;
|
||||||
if (!VIR_IS_DOMAIN(domain)) {
|
if (!VIR_IS_DOMAIN(domain)) {
|
||||||
virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -1451,7 +1453,19 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (xenDaemonDomainDumpXML(domain));
|
for (i = 0;i < domain->conn->nb_drivers;i++) {
|
||||||
|
if ((domain->conn->drivers[i] != NULL) &&
|
||||||
|
(domain->conn->drivers[i]->domainDumpXML != NULL)) {
|
||||||
|
ret = domain->conn->drivers[i]->domainDumpXML(domain, flags);
|
||||||
|
if (ret)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ret) {
|
||||||
|
virLibConnError(domain->conn, VIR_ERR_CALL_FAILED, __FUNCTION__);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +39,7 @@ static virDomainPtr xenProxyDomainLookupByName(virConnectPtr conn,
|
|||||||
const char *domname);
|
const char *domname);
|
||||||
static unsigned long xenProxyDomainGetMaxMemory(virDomainPtr domain);
|
static unsigned long xenProxyDomainGetMaxMemory(virDomainPtr domain);
|
||||||
static int xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
static int xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
||||||
|
static char *xenProxyDomainDumpXML(virDomainPtr domain, int flags);
|
||||||
|
|
||||||
static virDriver xenProxyDriver = {
|
static virDriver xenProxyDriver = {
|
||||||
VIR_DRV_XEN_PROXY,
|
VIR_DRV_XEN_PROXY,
|
||||||
@ -74,7 +75,8 @@ static virDriver xenProxyDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainSetVcpus */
|
NULL, /* domainSetVcpus */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
|
xenProxyDomainDumpXML, /* domainDumpXML */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -927,3 +929,50 @@ xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) {
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xenProxyDomainDumpXML:
|
||||||
|
* @domain: a domain object
|
||||||
|
* @flags: xml generation flags
|
||||||
|
*
|
||||||
|
* This method generates an XML description of a domain.
|
||||||
|
*
|
||||||
|
* Returns the XML document on success, NULL otherwise.
|
||||||
|
*/
|
||||||
|
static char *
|
||||||
|
xenProxyDomainDumpXML(virDomainPtr domain, int flags)
|
||||||
|
{
|
||||||
|
virProxyPacket req;
|
||||||
|
virProxyFullPacket ans;
|
||||||
|
int ret;
|
||||||
|
int xmllen;
|
||||||
|
char *xml;
|
||||||
|
|
||||||
|
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
|
||||||
|
if (domain == NULL)
|
||||||
|
virProxyError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||||
|
else
|
||||||
|
virProxyError(domain->conn, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
req.command = VIR_PROXY_DOMAIN_XML;
|
||||||
|
req.data.arg = domain->handle;
|
||||||
|
req.len = sizeof(req);
|
||||||
|
ret = xenProxyCommand(domain->conn, &req, &ans, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
xenProxyClose(domain->conn);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
if (ans.len <= sizeof(virProxyPacket)) {
|
||||||
|
virProxyError(domain->conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
xmllen = ans.len - sizeof(virProxyPacket);
|
||||||
|
if (!(xml = malloc(xmllen+1))) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
memmove(xml, &ans.extra.dinfo, xmllen);
|
||||||
|
xml[xmllen] = '\0';
|
||||||
|
|
||||||
|
return(xml);
|
||||||
|
}
|
||||||
|
@ -34,7 +34,8 @@ typedef enum {
|
|||||||
VIR_PROXY_LOOKUP_UUID = 6,
|
VIR_PROXY_LOOKUP_UUID = 6,
|
||||||
VIR_PROXY_LOOKUP_NAME = 7,
|
VIR_PROXY_LOOKUP_NAME = 7,
|
||||||
VIR_PROXY_MAX_MEMORY = 8,
|
VIR_PROXY_MAX_MEMORY = 8,
|
||||||
VIR_PROXY_DOMAIN_INFO = 9
|
VIR_PROXY_DOMAIN_INFO = 9,
|
||||||
|
VIR_PROXY_DOMAIN_XML = 10,
|
||||||
} virProxyCommand;
|
} virProxyCommand;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -50,7 +50,8 @@ static virDriver testDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainSetVcpus */
|
NULL, /* domainSetVcpus */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
|
NULL, /* domainDumpXML */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Amount of time it takes to shutdown */
|
/* Amount of time it takes to shutdown */
|
||||||
|
@ -92,7 +92,8 @@ static virDriver xenHypervisorDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
xenHypervisorSetVcpus, /* domainSetVcpus */
|
xenHypervisorSetVcpus, /* domainSetVcpus */
|
||||||
xenHypervisorPinVcpu, /* domainPinVcpu */
|
xenHypervisorPinVcpu, /* domainPinVcpu */
|
||||||
xenHypervisorGetVcpus /* domainGetVcpus */
|
xenHypervisorGetVcpus, /* domainGetVcpus */
|
||||||
|
NULL, /* domainDumpXML */
|
||||||
};
|
};
|
||||||
#endif /* !PROXY */
|
#endif /* !PROXY */
|
||||||
|
|
||||||
@ -686,6 +687,7 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xenHypervisorPauseDomain:
|
* xenHypervisorPauseDomain:
|
||||||
* @domain: pointer to the domain block
|
* @domain: pointer to the domain block
|
||||||
@ -799,6 +801,7 @@ xenHypervisorSetMaxMemory(virDomainPtr domain, unsigned long memory)
|
|||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
#endif /* PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenHypervisorCheckID:
|
* xenHypervisorCheckID:
|
||||||
@ -848,6 +851,7 @@ xenHypervisorCheckID(virConnectPtr conn, int id)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xenHypervisorSetVcpus:
|
* xenHypervisorSetVcpus:
|
||||||
* @domain: pointer to domain object
|
* @domain: pointer to domain object
|
||||||
@ -908,6 +912,7 @@ xenHypervisorPinVcpu(virDomainPtr domain, unsigned int vcpu,
|
|||||||
return (-1);
|
return (-1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virDomainGetVcpus:
|
* virDomainGetVcpus:
|
||||||
|
@ -47,7 +47,7 @@ static virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn,
|
|||||||
static virDomainPtr xenDaemonCreateLinux(virConnectPtr conn,
|
static virDomainPtr xenDaemonCreateLinux(virConnectPtr conn,
|
||||||
const char *xmlDesc,
|
const char *xmlDesc,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
#endif
|
#endif /* PROXY */
|
||||||
|
|
||||||
#ifndef PROXY
|
#ifndef PROXY
|
||||||
static virDriver xenDaemonDriver = {
|
static virDriver xenDaemonDriver = {
|
||||||
@ -86,7 +86,8 @@ static virDriver xenDaemonDriver = {
|
|||||||
xenDaemonDomainRestore, /* domainRestore */
|
xenDaemonDomainRestore, /* domainRestore */
|
||||||
xenDaemonDomainSetVcpus, /* domainSetVcpus */
|
xenDaemonDomainSetVcpus, /* domainSetVcpus */
|
||||||
xenDaemonDomainPinVcpu, /* domainPinVcpu */
|
xenDaemonDomainPinVcpu, /* domainPinVcpu */
|
||||||
xenDaemonDomainGetVcpus /* domainGetVcpus */
|
xenDaemonDomainGetVcpus, /* domainGetVcpus */
|
||||||
|
xenDaemonDomainDumpXML, /* domainDumpXML */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -445,6 +446,7 @@ xend_get(virConnectPtr xend, const char *path,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xend_post:
|
* xend_post:
|
||||||
* @xend: pointer to the Xen Daemon structure
|
* @xend: pointer to the Xen Daemon structure
|
||||||
@ -495,6 +497,8 @@ xend_post(virConnectPtr xend, const char *path, const char *ops,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http2unix:
|
* http2unix:
|
||||||
@ -525,6 +529,7 @@ http2unix(int ret)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xend_op_ext2:
|
* xend_op_ext2:
|
||||||
* @xend: pointer to the Xen Daemon structure
|
* @xend: pointer to the Xen Daemon structure
|
||||||
@ -562,6 +567,7 @@ xend_op_ext2(virConnectPtr xend, const char *path, char *error,
|
|||||||
return http2unix(xend_post(xend, path, ops, error, n_error));
|
return http2unix(xend_post(xend, path, ops, error, n_error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_node_op:
|
* xend_node_op:
|
||||||
* @xend: pointer to the Xen Daemon structure
|
* @xend: pointer to the Xen Daemon structure
|
||||||
@ -587,6 +593,7 @@ xend_node_op(virConnectPtr xend, const char *path, const char *key, ...)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_node_op:
|
* xend_node_op:
|
||||||
* @xend: pointer to the Xen Daemon structure
|
* @xend: pointer to the Xen Daemon structure
|
||||||
@ -620,6 +627,7 @@ xend_op_ext(virConnectPtr xend, const char *name, char *error,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define xend_op(xend, name, key, ...) ({char error[1024]; xend_op_ext(xend, name, error, sizeof(error), key, __VA_ARGS__);})
|
#define xend_op(xend, name, key, ...) ({char error[1024]; xend_op_ext(xend, name, error, sizeof(error), key, __VA_ARGS__);})
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sexpr_get:
|
* sexpr_get:
|
||||||
@ -819,6 +827,7 @@ sexpr_uuid(char **ptr, struct sexpr *node, const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* urlencode:
|
* urlencode:
|
||||||
* @string: the input URL
|
* @string: the input URL
|
||||||
@ -854,6 +863,7 @@ urlencode(const char *string)
|
|||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS */
|
/* PUBLIC FUNCTIONS */
|
||||||
|
|
||||||
@ -890,6 +900,7 @@ xenDaemonOpen_unix(virConnectPtr conn, const char *path)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xenDaemonOpen_tcp:
|
* xenDaemonOpen_tcp:
|
||||||
* @conn: an existing virtual connection block
|
* @conn: an existing virtual connection block
|
||||||
@ -932,6 +943,7 @@ xenDaemonOpen_tcp(virConnectPtr conn, const char *host, int port)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_wait_for_devices:
|
* xend_wait_for_devices:
|
||||||
* @xend: pointer to the Xem Daemon block
|
* @xend: pointer to the Xem Daemon block
|
||||||
@ -948,6 +960,7 @@ xend_wait_for_devices(virConnectPtr xend, const char *name)
|
|||||||
return xend_op(xend, name, "op", "wait_for_devices", NULL);
|
return xend_op(xend, name, "op", "wait_for_devices", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_rename:
|
* xend_rename:
|
||||||
* @xend: pointer to the Xem Daemon block
|
* @xend: pointer to the Xem Daemon block
|
||||||
@ -969,6 +982,7 @@ xend_rename(virConnectPtr xend, const char *old, const char *new)
|
|||||||
return xend_op(xend, old, "op", "rename", "name", new, NULL);
|
return xend_op(xend, old, "op", "rename", "name", new, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_sysrq:
|
* xend_sysrq:
|
||||||
* @xend: pointer to the Xem Daemon block
|
* @xend: pointer to the Xem Daemon block
|
||||||
@ -989,6 +1003,8 @@ xend_sysrq(virConnectPtr xend, const char *name, const char *key)
|
|||||||
}
|
}
|
||||||
return xend_op(xend, name, "op", "sysrq", "key", key, NULL);
|
return xend_op(xend, name, "op", "sysrq", "key", key, NULL);
|
||||||
}
|
}
|
||||||
|
#endif /* PROXY */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonListDomainsOld:
|
* xenDaemonListDomainsOld:
|
||||||
@ -1047,6 +1063,7 @@ xenDaemonListDomainsOld(virConnectPtr xend)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xenDaemonDomainCreateLinux:
|
* xenDaemonDomainCreateLinux:
|
||||||
* @xend: A xend instance
|
* @xend: A xend instance
|
||||||
@ -1083,6 +1100,7 @@ xenDaemonDomainCreateLinux(virConnectPtr xend, const char *sexpr)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonDomainLookupByName_ids:
|
* xenDaemonDomainLookupByName_ids:
|
||||||
@ -1275,6 +1293,7 @@ xend_get_node(virConnectPtr xend)
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xend_node_shutdown:
|
* xend_node_shutdown:
|
||||||
* @xend: A xend instance
|
* @xend: A xend instance
|
||||||
@ -1303,6 +1322,7 @@ xend_node_restart(virConnectPtr xend)
|
|||||||
return xend_node_op(xend, "/xend/node/", "op", "restart", NULL);
|
return xend_node_op(xend, "/xend/node/", "op", "restart", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_dmesg:
|
* xend_dmesg:
|
||||||
* @xend: A xend instance
|
* @xend: A xend instance
|
||||||
@ -1351,6 +1371,7 @@ xend_log(virConnectPtr xend, char *buffer, size_t n_buffer)
|
|||||||
{
|
{
|
||||||
return http2unix(xend_get(xend, "/xend/node/log", buffer, n_buffer));
|
return http2unix(xend_get(xend, "/xend/node/log", buffer, n_buffer));
|
||||||
}
|
}
|
||||||
|
#endif /* PROXY */
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
******
|
******
|
||||||
@ -1363,7 +1384,6 @@ xend_log(virConnectPtr xend, char *buffer, size_t n_buffer)
|
|||||||
******
|
******
|
||||||
******
|
******
|
||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
#ifndef PROXY
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xend_parse_sexp_desc_os:
|
* xend_parse_sexp_desc_os:
|
||||||
@ -1448,7 +1468,7 @@ xend_parse_sexp_desc_os(struct sexpr *node, virBufferPtr buf, int hvm)
|
|||||||
* the caller must free() the returned value.
|
* the caller must free() the returned value.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
xend_parse_sexp_desc(virDomainPtr domain, struct sexpr *root)
|
xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
struct sexpr *cur, *node;
|
struct sexpr *cur, *node;
|
||||||
@ -1456,6 +1476,7 @@ xend_parse_sexp_desc(virDomainPtr domain, struct sexpr *root)
|
|||||||
char *tty;
|
char *tty;
|
||||||
virBuffer buf;
|
virBuffer buf;
|
||||||
int hvm = 0;
|
int hvm = 0;
|
||||||
|
int domid = -1;
|
||||||
|
|
||||||
if (root == NULL) {
|
if (root == NULL) {
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
@ -1468,8 +1489,9 @@ xend_parse_sexp_desc(virDomainPtr domain, struct sexpr *root)
|
|||||||
buf.size = 1000;
|
buf.size = 1000;
|
||||||
buf.use = 0;
|
buf.use = 0;
|
||||||
|
|
||||||
virBufferVSprintf(&buf, "<domain type='xen' id='%d'>\n",
|
domid = sexpr_int(root, "domain/domid");
|
||||||
sexpr_int(root, "domain/domid"));
|
virBufferVSprintf(&buf, "<domain type='xen' id='%d'>\n", domid);
|
||||||
|
|
||||||
tmp = sexpr_node(root, "domain/name");
|
tmp = sexpr_node(root, "domain/name");
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
|
virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -1607,9 +1629,9 @@ xend_parse_sexp_desc(virDomainPtr domain, struct sexpr *root)
|
|||||||
tmp = sexpr_node(root, "domain/image/hvm/vnc");
|
tmp = sexpr_node(root, "domain/image/hvm/vnc");
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
if (tmp[0] == '1') {
|
if (tmp[0] == '1') {
|
||||||
int port = xenStoreDomainGetVNCPort(domain);
|
int port = xenStoreDomainGetVNCPort(conn, domid);
|
||||||
if (port == -1)
|
if (port == -1)
|
||||||
port = 5900 + sexpr_int(root, "domain/domid");
|
port = 5900 + domid;
|
||||||
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n", port);
|
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'/>\n", port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1626,7 +1648,7 @@ xend_parse_sexp_desc(virDomainPtr domain, struct sexpr *root)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
tty = xenStoreDomainGetConsolePath(domain);
|
tty = xenStoreDomainGetConsolePath(conn, domid);
|
||||||
if (tty) {
|
if (tty) {
|
||||||
virBufferVSprintf(&buf, " <console tty='%s'/>\n", tty);
|
virBufferVSprintf(&buf, " <console tty='%s'/>\n", tty);
|
||||||
free(tty);
|
free(tty);
|
||||||
@ -1643,7 +1665,7 @@ xend_parse_sexp_desc(virDomainPtr domain, struct sexpr *root)
|
|||||||
free(ret);
|
free(ret);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
#endif /* !PROXY */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sexpr_to_xend_domain_info:
|
* sexpr_to_xend_domain_info:
|
||||||
@ -1873,7 +1895,7 @@ failed:
|
|||||||
xmlFreeURI(uri);
|
xmlFreeURI(uri);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#endif /* !PROXY */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonClose:
|
* xenDaemonClose:
|
||||||
@ -2044,6 +2066,7 @@ xenDaemonDomainRestore(virConnectPtr conn, const char *filename)
|
|||||||
}
|
}
|
||||||
return xend_op(conn, "", "op", "restore", "file", filename, NULL);
|
return xend_op(conn, "", "op", "restore", "file", filename, NULL);
|
||||||
}
|
}
|
||||||
|
#endif /* !PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonDomainGetMaxMemory:
|
* xenDaemonDomainGetMaxMemory:
|
||||||
@ -2076,6 +2099,7 @@ xenDaemonDomainGetMaxMemory(virDomainPtr domain)
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xenDaemonDomainSetMaxMemory:
|
* xenDaemonDomainSetMaxMemory:
|
||||||
* @domain: pointer to the Domain block
|
* @domain: pointer to the Domain block
|
||||||
@ -2133,6 +2157,25 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
|
|||||||
"target", buf, NULL);
|
"target", buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
|
char *
|
||||||
|
xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid)
|
||||||
|
{
|
||||||
|
char *ret = NULL;
|
||||||
|
struct sexpr *root;
|
||||||
|
|
||||||
|
root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid);
|
||||||
|
if (root == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
ret = xend_parse_sexp_desc(conn, root);
|
||||||
|
sexpr_free(root);
|
||||||
|
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef PROXY
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xenDaemonDomainDumpXML:
|
* xenDaemonDomainDumpXML:
|
||||||
@ -2144,25 +2187,15 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
|
|||||||
* the caller must free() the returned value.
|
* the caller must free() the returned value.
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
xenDaemonDomainDumpXML(virDomainPtr domain)
|
xenDaemonDomainDumpXML(virDomainPtr domain, int flags)
|
||||||
{
|
{
|
||||||
char *ret = NULL;
|
|
||||||
struct sexpr *root;
|
|
||||||
|
|
||||||
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
|
if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
|
||||||
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
|
virXendError((domain ? domain->conn : NULL), VIR_ERR_INVALID_ARG,
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
|
return xenDaemonDomainDumpXMLByID(domain->conn, domain->handle);
|
||||||
if (root == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
ret = xend_parse_sexp_desc(domain, root);
|
|
||||||
sexpr_free(root);
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
}
|
||||||
#endif /* !PROXY */
|
#endif /* !PROXY */
|
||||||
|
|
||||||
@ -2231,7 +2264,7 @@ error:
|
|||||||
sexpr_free(root);
|
sexpr_free(root);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonNodeGetInfo:
|
* xenDaemonNodeGetInfo:
|
||||||
@ -2285,7 +2318,7 @@ xenDaemonGetType(virConnectPtr conn)
|
|||||||
}
|
}
|
||||||
return("XenDaemon");
|
return("XenDaemon");
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenDaemonGetVersion:
|
* xenDaemonGetVersion:
|
||||||
@ -2414,7 +2447,7 @@ error:
|
|||||||
sexpr_free(root);
|
sexpr_free(root);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
#ifndef PROXY
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
@ -2734,6 +2767,5 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
|
|||||||
free(name);
|
free(name);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
#endif
|
|
||||||
|
|
||||||
|
@ -548,6 +548,9 @@ int xenDaemonDomainLookupByID(virConnectPtr xend,
|
|||||||
char **name, unsigned char *uuid);
|
char **name, unsigned char *uuid);
|
||||||
|
|
||||||
|
|
||||||
|
char *xenDaemonDomainDumpXMLByID(virConnectPtr xend,
|
||||||
|
int domid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Lookup information about the host machine
|
* \brief Lookup information about the host machine
|
||||||
* \param xend A xend instance
|
* \param xend A xend instance
|
||||||
@ -626,7 +629,7 @@ int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
|
|||||||
int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
|
||||||
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
|
||||||
int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
|
||||||
char *xenDaemonDomainDumpXML(virDomainPtr domain);
|
char *xenDaemonDomainDumpXML(virDomainPtr domain, int flags);
|
||||||
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);
|
char **xenDaemonListDomainsOld(virConnectPtr xend);
|
||||||
|
@ -562,6 +562,7 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* virDomainParseXMLOSDescHVM:
|
* virDomainParseXMLOSDescHVM:
|
||||||
* @node: node containing HVM OS description
|
* @node: node containing HVM OS description
|
||||||
@ -1140,3 +1141,5 @@ virDomainParseXMLDesc(const char *xmldesc, char **name)
|
|||||||
free(ret);
|
free(ret);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* !PROXY */
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
|
#define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
static virDriver xenStoreDriver = {
|
static virDriver xenStoreDriver = {
|
||||||
VIR_DRV_XEN_STORE,
|
VIR_DRV_XEN_STORE,
|
||||||
"XenStore",
|
"XenStore",
|
||||||
@ -67,7 +68,8 @@ static virDriver xenStoreDriver = {
|
|||||||
NULL, /* domainRestore */
|
NULL, /* domainRestore */
|
||||||
NULL, /* domainSetVcpus */
|
NULL, /* domainSetVcpus */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
|
NULL, /* domainDumpXML */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,6 +81,7 @@ void xenStoreRegister(void)
|
|||||||
{
|
{
|
||||||
virRegisterDriver(&xenStoreDriver);
|
virRegisterDriver(&xenStoreDriver);
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virXenStoreError:
|
* virXenStoreError:
|
||||||
@ -106,6 +109,7 @@ virXenStoreError(virConnectPtr conn, virErrorNumber error, const char *info)
|
|||||||
* Helper internal APIs *
|
* Helper internal APIs *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* virConnectDoStoreList:
|
* virConnectDoStoreList:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
@ -126,10 +130,12 @@ virConnectDoStoreList(virConnectPtr conn, const char *path,
|
|||||||
|
|
||||||
return xs_directory(conn->xshandle, 0, path, nb);
|
return xs_directory(conn->xshandle, 0, path, nb);
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virDomainDoStoreQuery:
|
* virDomainDoStoreQuery:
|
||||||
* @domain: a domain object
|
* @conn: pointer to the hypervisor connection
|
||||||
|
* @domid: id of the domain
|
||||||
* @path: the relative path of the data in the store to retrieve
|
* @path: the relative path of the data in the store to retrieve
|
||||||
*
|
*
|
||||||
* Internal API querying the Xenstore for a string value.
|
* Internal API querying the Xenstore for a string value.
|
||||||
@ -137,23 +143,21 @@ virConnectDoStoreList(virConnectPtr conn, const char *path,
|
|||||||
* Returns a string which must be freed by the caller or NULL in case of error
|
* Returns a string which must be freed by the caller or NULL in case of error
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
virDomainDoStoreQuery(virDomainPtr domain, const char *path)
|
virDomainDoStoreQuery(virConnectPtr conn, int domid, const char *path)
|
||||||
{
|
{
|
||||||
char s[256];
|
char s[256];
|
||||||
unsigned int len = 0;
|
unsigned int len = 0;
|
||||||
|
|
||||||
if (!VIR_IS_CONNECTED_DOMAIN(domain))
|
if (conn->xshandle == NULL)
|
||||||
return (NULL);
|
|
||||||
if (domain->conn->xshandle == NULL)
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
snprintf(s, 255, "/local/domain/%d/%s", domain->handle, path);
|
snprintf(s, 255, "/local/domain/%d/%s", domid, path);
|
||||||
s[255] = 0;
|
s[255] = 0;
|
||||||
|
|
||||||
return xs_read(domain->conn->xshandle, 0, &s[0], &len);
|
return xs_read(conn->xshandle, 0, &s[0], &len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* virDomainDoStoreWrite:
|
* virDomainDoStoreWrite:
|
||||||
* @domain: a domain object
|
* @domain: a domain object
|
||||||
@ -269,6 +273,7 @@ virConnectCheckStoreID(virConnectPtr conn, int id)
|
|||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
@ -291,10 +296,14 @@ xenStoreOpen(virConnectPtr conn, const char *name, int flags)
|
|||||||
if ((name != NULL) && (strcasecmp(name, "xen")))
|
if ((name != NULL) && (strcasecmp(name, "xen")))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
|
#ifdef PROXY
|
||||||
|
conn->xshandle = xs_daemon_open_readonly();
|
||||||
|
#else
|
||||||
if (flags & VIR_DRV_OPEN_RO)
|
if (flags & VIR_DRV_OPEN_RO)
|
||||||
conn->xshandle = xs_daemon_open_readonly();
|
conn->xshandle = xs_daemon_open_readonly();
|
||||||
else
|
else
|
||||||
conn->xshandle = xs_daemon_open();
|
conn->xshandle = xs_daemon_open();
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
if (conn->xshandle == NULL) {
|
if (conn->xshandle == NULL) {
|
||||||
if (!(flags & VIR_DRV_OPEN_QUIET))
|
if (!(flags & VIR_DRV_OPEN_QUIET))
|
||||||
@ -327,6 +336,7 @@ xenStoreClose(virConnectPtr conn)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PROXY
|
||||||
/**
|
/**
|
||||||
* xenStoreGetDomainInfo:
|
* xenStoreGetDomainInfo:
|
||||||
* @domain: pointer to the domain block
|
* @domain: pointer to the domain block
|
||||||
@ -343,6 +353,9 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
unsigned int nb_vcpus;
|
unsigned int nb_vcpus;
|
||||||
char request[200];
|
char request[200];
|
||||||
|
|
||||||
|
if (!VIR_IS_CONNECTED_DOMAIN(domain))
|
||||||
|
return (-1);
|
||||||
|
|
||||||
if ((domain == NULL) || (domain->conn == NULL) || (info == NULL)) {
|
if ((domain == NULL) || (domain->conn == NULL) || (info == NULL)) {
|
||||||
virXenStoreError(domain ? domain->conn : NULL, VIR_ERR_INVALID_ARG,
|
virXenStoreError(domain ? domain->conn : NULL, VIR_ERR_INVALID_ARG,
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
@ -351,7 +364,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
if (domain->conn->xshandle == NULL)
|
if (domain->conn->xshandle == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
tmp = virDomainDoStoreQuery(domain, "running");
|
tmp = virDomainDoStoreQuery(domain->conn, domain->handle, "running");
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
if (tmp[0] == '1')
|
if (tmp[0] == '1')
|
||||||
info->state = VIR_DOMAIN_RUNNING;
|
info->state = VIR_DOMAIN_RUNNING;
|
||||||
@ -359,7 +372,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
} else {
|
} else {
|
||||||
info->state = VIR_DOMAIN_NONE;
|
info->state = VIR_DOMAIN_NONE;
|
||||||
}
|
}
|
||||||
tmp = virDomainDoStoreQuery(domain, "memory/target");
|
tmp = virDomainDoStoreQuery(domain->conn, domain->handle, "memory/target");
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
info->memory = atol(tmp);
|
info->memory = atol(tmp);
|
||||||
info->maxMem = atol(tmp);
|
info->maxMem = atol(tmp);
|
||||||
@ -370,7 +383,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
/* doesn't seems to work */
|
/* doesn't seems to work */
|
||||||
tmp = virDomainDoStoreQuery(domain, "cpu_time");
|
tmp = virDomainDoStoreQuery(domain->conn, domain->handle, "cpu_time");
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
info->cpuTime = atol(tmp);
|
info->cpuTime = atol(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
@ -430,7 +443,10 @@ xenStoreDomainGetMaxMemory(virDomainPtr domain)
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
unsigned long ret = 0;
|
unsigned long ret = 0;
|
||||||
|
|
||||||
tmp = virDomainDoStoreQuery(domain, "memory/target");
|
if (!VIR_IS_CONNECTED_DOMAIN(domain))
|
||||||
|
return (ret);
|
||||||
|
|
||||||
|
tmp = virDomainDoStoreQuery(domain->conn, domain->handle, "memory/target");
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
ret = (unsigned long) atol(tmp);
|
ret = (unsigned long) atol(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
@ -629,21 +645,23 @@ xenStoreDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
|
|||||||
*/
|
*/
|
||||||
return(virDomainDoStoreWrite(domain, "control/shutdown", "reboot"));
|
return(virDomainDoStoreWrite(domain, "control/shutdown", "reboot"));
|
||||||
}
|
}
|
||||||
|
#endif /* ! PROXY */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xenStoreDomainGetVNCPort:
|
* xenStoreDomainGetVNCPort:
|
||||||
* @domain: pointer to the domain block
|
* @conn: the hypervisor connection
|
||||||
|
* @domid: id of the domain
|
||||||
*
|
*
|
||||||
* Return the port number on which the domain is listening for VNC
|
* Return the port number on which the domain is listening for VNC
|
||||||
* connections.
|
* connections.
|
||||||
*
|
*
|
||||||
* Returns the port number, -1 in case of error
|
* Returns the port number, -1 in case of error
|
||||||
*/
|
*/
|
||||||
int xenStoreDomainGetVNCPort(virDomainPtr domain) {
|
int xenStoreDomainGetVNCPort(virConnectPtr conn, int domid) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
tmp = virDomainDoStoreQuery(domain, "console/vnc-port");
|
tmp = virDomainDoStoreQuery(conn, domid, "console/vnc-port");
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
char *end;
|
char *end;
|
||||||
ret = strtol(tmp, &end, 10);
|
ret = strtol(tmp, &end, 10);
|
||||||
@ -656,7 +674,8 @@ int xenStoreDomainGetVNCPort(virDomainPtr domain) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* xenStoreDomainGetConsolePath:
|
* xenStoreDomainGetConsolePath:
|
||||||
* @domain: pointer to the domain block
|
* @conn: the hypervisor connection
|
||||||
|
* @domid: id of the domain
|
||||||
*
|
*
|
||||||
* Return the path to the psuedo TTY on which the guest domain's
|
* Return the path to the psuedo TTY on which the guest domain's
|
||||||
* serial console is attached.
|
* serial console is attached.
|
||||||
@ -665,6 +684,6 @@ int xenStoreDomainGetVNCPort(virDomainPtr domain) {
|
|||||||
* responsibilty to free() the return string. Returns NULL
|
* responsibilty to free() the return string. Returns NULL
|
||||||
* on error
|
* on error
|
||||||
*/
|
*/
|
||||||
char * xenStoreDomainGetConsolePath(virDomainPtr domain) {
|
char * xenStoreDomainGetConsolePath(virConnectPtr conn, int domid) {
|
||||||
return virDomainDoStoreQuery(domain, "console/tty");
|
return virDomainDoStoreQuery(conn, domid, "console/tty");
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,9 @@ unsigned long xenStoreDomainGetMaxMemory(virDomainPtr domain);
|
|||||||
int xenStoreDomainShutdown (virDomainPtr domain);
|
int xenStoreDomainShutdown (virDomainPtr domain);
|
||||||
int xenStoreDomainReboot (virDomainPtr domain,
|
int xenStoreDomainReboot (virDomainPtr domain,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
int xenStoreDomainGetVNCPort(virDomainPtr domain);
|
|
||||||
char * xenStoreDomainGetConsolePath(virDomainPtr domain);
|
int xenStoreDomainGetVNCPort(virConnectPtr conn, int domid);
|
||||||
|
char * xenStoreDomainGetConsolePath(virConnectPtr conn, int domid);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user