aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2007-09-30 13:09:07 +0000
committerDaniel Veillard <veillard@redhat.com>2007-09-30 13:09:07 +0000
commit9f211bbf3a7e7eed8eb21fbb27aa0ac7ab6e65a3 (patch)
tree76dda055324378ef6513fd73ed49ebcd88fa5e6e
parentSolaris hypercall compatability fixes (Mark Johnson) (diff)
downloadlibvirt-9f211bbf3a7e7eed8eb21fbb27aa0ac7ab6e65a3.tar.gz
libvirt-9f211bbf3a7e7eed8eb21fbb27aa0ac7ab6e65a3.tar.bz2
libvirt-9f211bbf3a7e7eed8eb21fbb27aa0ac7ab6e65a3.zip
* include/libvirt/libvirt.h include/libvirt/libvirt.h.in
src/driver.h src/libvirt.c src/openvz_driver.c src/qemu_driver.c src/test.c src/xen_unified.c src/xend_internal.c: add new API virNodeGetFreeMemory(), extends the driver. Lacks remote and QEmu support though. * src/libvirt.c: allows to fix virNodeGetCellsFreeMemory() adding parameter check for startCell. * proxy/libvirt_proxy.c src/xend_internal.[ch] include/libvirt/libvirt.h include/libvirt/libvirt.h.in: applied vncpasswd dump patch from Mark Johnson but with the virDomainXMLFlags extension as suggested by Daniel Berrange this changed a couple of internal APIs too * tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml: fix one of the tests affected by bootloader dump change. Daniel
-rw-r--r--ChangeLog17
-rw-r--r--include/libvirt/libvirt.h13
-rw-r--r--include/libvirt/libvirt.h.in13
-rw-r--r--proxy/libvirt_proxy.c2
-rw-r--r--src/driver.h5
-rw-r--r--src/libvirt.c25
-rw-r--r--src/openvz_driver.c1
-rw-r--r--src/qemu_driver.c1
-rw-r--r--src/test.c1
-rw-r--r--src/xen_unified.c20
-rw-r--r--src/xend_internal.c33
-rw-r--r--src/xend_internal.h6
-rw-r--r--tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml1
13 files changed, 125 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 0efee894b..ca5f61e88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Sun Sep 30 14:49:27 CEST 2007 Daniel Veillard <veillard@redhat.com>
+
+ * include/libvirt/libvirt.h include/libvirt/libvirt.h.in
+ src/driver.h src/libvirt.c src/openvz_driver.c src/qemu_driver.c
+ src/test.c src/xen_unified.c src/xend_internal.c: add new API
+ virNodeGetFreeMemory(), extends the driver. Lacks remote and
+ QEmu support though.
+ * src/libvirt.c: allows to fix virNodeGetCellsFreeMemory() adding
+ parameter check for startCell.
+ * proxy/libvirt_proxy.c src/xend_internal.[ch]
+ include/libvirt/libvirt.h include/libvirt/libvirt.h.in: applied
+ vncpasswd dump patch from Mark Johnson but with the
+ virDomainXMLFlags extension as suggested by Daniel Berrange
+ this changed a couple of internal APIs too
+ * tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml: fix one of the
+ tests affected by bootloader dump change.
+
Sat Sep 29 14:30:41 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/xen_internal.c, src/xs_internal.c: Solaris hypercall compat
diff --git a/include/libvirt/libvirt.h b/include/libvirt/libvirt.h
index 9db6d7b6a..b00e34451 100644
--- a/include/libvirt/libvirt.h
+++ b/include/libvirt/libvirt.h
@@ -344,6 +344,8 @@ int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
+unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
+
/*
* Gather list of running domains
*/
@@ -436,6 +438,17 @@ int virDomainGetMaxVcpus (virDomainPtr domain);
/*
* XML domain description
*/
+/**
+ * virDomainXMLFlags:
+ *
+ * Flags available for virDomainGetXMLDesc
+ */
+
+typedef enum {
+ VIR_DOMAIN_XML_SECURE = 1, /* dump security sensitive informations too */
+ VIR_DOMAIN_XML_INACTIVE = 2/* dump inactive domain informations */
+} virDomainXMLFlags;
+
char * virDomainGetXMLDesc (virDomainPtr domain,
int flags);
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index fcfed43fe..e6ebbac44 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -344,6 +344,8 @@ int virNodeGetInfo (virConnectPtr conn,
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
+unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
+
/*
* Gather list of running domains
*/
@@ -436,6 +438,17 @@ int virDomainGetMaxVcpus (virDomainPtr domain);
/*
* XML domain description
*/
+/**
+ * virDomainXMLFlags:
+ *
+ * Flags available for virDomainGetXMLDesc
+ */
+
+typedef enum {
+ VIR_DOMAIN_XML_SECURE = 1, /* dump security sensitive informations too */
+ VIR_DOMAIN_XML_INACTIVE = 2/* dump inactive domain informations */
+} virDomainXMLFlags;
+
char * virDomainGetXMLDesc (virDomainPtr domain,
int flags);
diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c
index 0e074d1ae..a97b3f942 100644
--- a/proxy/libvirt_proxy.c
+++ b/proxy/libvirt_proxy.c
@@ -614,7 +614,7 @@ retry2:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
- xml = xenDaemonDomainDumpXMLByID(conn, request.data.arg);
+ xml = xenDaemonDomainDumpXMLByID(conn, request.data.arg, 0);
if (!xml) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
diff --git a/src/driver.h b/src/driver.h
index 577fa6a8d..3d83b7164 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -262,6 +262,10 @@ typedef int
int startCell,
int maxCells);
+typedef unsigned long long
+ (*virDrvNodeGetFreeMemory)
+ (virConnectPtr conn);
+
/**
* _virDriver:
*
@@ -330,6 +334,7 @@ struct _virDriver {
virDrvDomainBlockStats domainBlockStats;
virDrvDomainInterfaceStats domainInterfaceStats;
virDrvNodeGetCellsFreeMemory nodeGetCellsFreeMemory;
+ virDrvNodeGetFreeMemory getFreeMemory;
};
typedef int
diff --git a/src/libvirt.c b/src/libvirt.c
index 40df5394d..d58bd3521 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1642,7 +1642,7 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
/**
* virDomainGetXMLDesc:
* @domain: a domain object
- * @flags: and OR'ed set of extraction flags, not used yet
+ * @flags: an OR'ed set of virDomainXMLFlags
*
* Provide an XML description of the domain. The description may be reused
* later to relaunch the domain with virDomainCreateLinux().
@@ -1950,6 +1950,29 @@ virConnectGetCapabilities (virConnectPtr conn)
}
/**
+ * virNodeGetFreeMemory:
+ * @conn: pointer to the hypervisor connection
+ *
+ * provides the free memory availble on the Node
+ *
+ * Returns the available free memory in kilobytes or 0 in case of error
+ */
+unsigned long long
+virNodeGetFreeMemory(virConnectPtr conn)
+{
+ if (!VIR_IS_CONNECT (conn)) {
+ virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ return 0;
+ }
+
+ if (conn->driver->getFreeMemory)
+ return conn->driver->getFreeMemory (conn);
+
+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ return 0;
+}
+
+/**
* virDomainGetSchedulerType:
* @domain: pointer to domain object
* @nparams: number of scheduler parameters(return value)
diff --git a/src/openvz_driver.c b/src/openvz_driver.c
index 1f9c8c451..033b19614 100644
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -754,6 +754,7 @@ static virDriver openvzDriver = {
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
NULL, /* nodeGetCellsFreeMemory */
+ NULL, /* nodeGetFreeMemory */
};
static virNetworkDriver openvzNetworkDriver = {
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 9be402392..87b66ad98 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2705,6 +2705,7 @@ static virDriver qemuDriver = {
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
NULL, /* nodeGetCellsFreeMemory */
+ NULL, /* getFreeMemory */
};
static virNetworkDriver qemuNetworkDriver = {
diff --git a/src/test.c b/src/test.c
index 03e49736b..a948530fb 100644
--- a/src/test.c
+++ b/src/test.c
@@ -1970,6 +1970,7 @@ static virDriver testDriver = {
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
NULL, /* nodeGetCellsFreeMemory */
+ NULL, /* getFreeMemory */
};
static virNetworkDriver testNetworkDriver = {
diff --git a/src/xen_unified.c b/src/xen_unified.c
index cddda39bc..684a0a191 100644
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -1067,6 +1067,25 @@ xenUnifiedNodeGetCellsFreeMemory (virConnectPtr conn, unsigned long long *freeMe
return -1;
}
+static unsigned long long
+xenUnifiedNodeGetFreeMemory (virConnectPtr conn)
+{
+ unsigned long long freeMem = 0;
+ int ret;
+ GET_PRIVATE (conn);
+
+ if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
+ ret = xenHypervisorNodeGetCellsFreeMemory (conn, &freeMem,
+ -1, 1);
+ if (ret != 1)
+ return (0);
+ return(freeMem);
+ }
+
+ xenUnifiedError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+ return(0);
+}
+
/*----- Register with libvirt.c, and initialise Xen drivers. -----*/
#define VERSION ((DOM0_INTERFACE_VERSION >> 24) * 1000000 + \
@@ -1128,6 +1147,7 @@ static virDriver xenUnifiedDriver = {
.domainBlockStats = xenUnifiedDomainBlockStats,
.domainInterfaceStats = xenUnifiedDomainInterfaceStats,
.nodeGetCellsFreeMemory = xenUnifiedNodeGetCellsFreeMemory,
+ .getFreeMemory = xenUnifiedNodeGetFreeMemory,
};
/**
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 2a488ccd1..b0e8d0cc9 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -1338,6 +1338,8 @@ xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf
* xend_parse_sexp_desc:
* @conn: the connection associated with the XML
* @root: the root of the parsed S-Expression
+ * @xendConfigVersion: version of xend
+ * @flags: a combination of virDomainXMLFlags
*
* Parse the xend sexp description and turn it into the XML format similar
* to the one unsed for creation.
@@ -1346,7 +1348,8 @@ xend_parse_sexp_desc_os(virConnectPtr xend, struct sexpr *node, virBufferPtr buf
* the caller must free() the returned value.
*/
static char *
-xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersion)
+xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
+ int xendConfigVersion, int flags)
{
struct sexpr *cur, *node;
const char *tmp;
@@ -1661,11 +1664,17 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
} else if (tmp && !strcmp(tmp, "vnc")) {
int port = xenStoreDomainGetVNCPort(conn, domid);
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
+ const char *vncPasswd = NULL;
const char *keymap = sexpr_node(node, "device/vfb/keymap");
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen");
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'", port);
if (listenAddr)
virBufferVSprintf(&buf, " listen='%s'", listenAddr);
+ if (flags & VIR_DOMAIN_XML_SECURE) {
+ vncPasswd = sexpr_node(node, "device/vfb/vncpasswd");
+ if (vncPasswd)
+ virBufferVSprintf(&buf, " passwd='%s'", vncPasswd);
+ }
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAdd(&buf, "/>\n", 3);
@@ -1727,6 +1736,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
if (tmp[0] == '1') {
int port = xenStoreDomainGetVNCPort(conn, domid);
const char *listenAddr = sexpr_fmt_node(root, "domain/image/%s/vnclisten", hvm ? "hvm" : "linux");
+ const char *vncPasswd = NULL;
const char *keymap = sexpr_fmt_node(root, "domain/image/%s/keymap", hvm ? "hvm" : "linux");
/* For Xen >= 3.0.3, don't generate a fixed port mapping
* because it will almost certainly be wrong ! Just leave
@@ -1740,6 +1750,11 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
virBufferVSprintf(&buf, " <graphics type='vnc' port='%d'", port);
if (listenAddr)
virBufferVSprintf(&buf, " listen='%s'", listenAddr);
+ if (flags & VIR_DOMAIN_XML_SECURE) {
+ vncPasswd = sexpr_fmt_node(root, "domain/image/%s/vncpasswd", hvm ? "hvm" : "linux");
+ if (vncPasswd)
+ virBufferVSprintf(&buf, " passwd='%s'", vncPasswd);
+ }
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAdd(&buf, "/>\n", 3);
@@ -1782,7 +1797,7 @@ xend_parse_domain_sexp(virConnectPtr conn, char *sexpr, int xendConfigVersion) {
if (!root)
return NULL;
- data = xend_parse_sexp_desc(conn, root, xendConfigVersion);
+ data = xend_parse_sexp_desc(conn, root, xendConfigVersion, 0);
sexpr_free(root);
@@ -2601,7 +2616,7 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
dumpxml will work over proxy for inactive domains
and this can be removed */
char *
-xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid)
+xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid, int flags)
{
char *ret = NULL;
struct sexpr *root;
@@ -2616,14 +2631,14 @@ xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid)
priv = (xenUnifiedPrivatePtr) conn->privateData;
- ret = xend_parse_sexp_desc(conn, root, priv->xendConfigVersion);
+ ret = xend_parse_sexp_desc(conn, root, priv->xendConfigVersion, flags);
sexpr_free(root);
return (ret);
}
char *
-xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name)
+xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name, int flags)
{
char *ret = NULL;
struct sexpr *root;
@@ -2638,7 +2653,7 @@ xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name)
priv = (xenUnifiedPrivatePtr) conn->privateData;
- ret = xend_parse_sexp_desc(conn, root, priv->xendConfigVersion);
+ ret = xend_parse_sexp_desc(conn, root, priv->xendConfigVersion, flags);
sexpr_free(root);
return (ret);
@@ -2656,7 +2671,7 @@ xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name)
* the caller must free() the returned value.
*/
char *
-xenDaemonDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
+xenDaemonDomainDumpXML(virDomainPtr domain, int flags)
{
xenUnifiedPrivatePtr priv;
@@ -2673,9 +2688,9 @@ xenDaemonDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
}
if (domain->id < 0)
- return xenDaemonDomainDumpXMLByName(domain->conn, domain->name);
+ return xenDaemonDomainDumpXMLByName(domain->conn, domain->name, flags);
else
- return xenDaemonDomainDumpXMLByID(domain->conn, domain->id);
+ return xenDaemonDomainDumpXMLByID(domain->conn, domain->id, flags);
}
#endif /* !PROXY */
diff --git a/src/xend_internal.h b/src/xend_internal.h
index 67c44ec8b..e16d96cc0 100644
--- a/src/xend_internal.h
+++ b/src/xend_internal.h
@@ -109,10 +109,12 @@ int xenDaemonDomainLookupByID(virConnectPtr xend,
char *xenDaemonDomainDumpXMLByID(virConnectPtr xend,
- int domid);
+ int domid,
+ int flags);
char *xenDaemonDomainDumpXMLByName(virConnectPtr xend,
- const char *name);
+ const char *name,
+ int flags);
/**
* \brief Lookup information about the host machine
diff --git a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml
index 429474aff..cfc1949c6 100644
--- a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml
+++ b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml
@@ -1,6 +1,7 @@
<domain type='xen' id='6'>
<name>test</name>
<uuid>cc2315e7-d26a-307a-438c-6d188ec4c09c</uuid>
+ <bootloader/>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>