]> xenbits.xensource.com Git - libvirt.git/commitdiff
* include/libvirt/libvirt.h include/libvirt/libvirt.h.in
authorDaniel Veillard <veillard@redhat.com>
Sun, 30 Sep 2007 13:09:07 +0000 (13:09 +0000)
committerDaniel Veillard <veillard@redhat.com>
Sun, 30 Sep 2007 13:09:07 +0000 (13:09 +0000)
  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

13 files changed:
ChangeLog
include/libvirt/libvirt.h
include/libvirt/libvirt.h.in
proxy/libvirt_proxy.c
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
src/xend_internal.h
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml

index 0efee894b9a6701f3cbbf188c810dfa71874e9db..ca5f61e888e2a60e8792a3c5d0faf1473d2b8cc0 100644 (file)
--- 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
index 9db6d7b6acb2b3399450ba0fa4e394232c8bf86e..b00e3445138c2b3b83d1ead2949c8872c5d5b404 100644 (file)
@@ -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);
 
index fcfed43fe89ca2808d0544a5ef6db1c8d67f6f71..e6ebbac44a9fdb1045e0fcc8a2f214ad2c39d8d1 100644 (file)
@@ -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);
 
index 0e074d1aea477736a37ebbfd302b6f34206f8367..a97b3f9425f060dcc9f77ecf16dafa066747b700 100644 (file)
@@ -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);
index 577fa6a8dcb81e511362019cc580551fed2389de..3d83b7164989475936e25be972b24c984430120a 100644 (file)
@@ -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
index 40df5394d4b17709db0867f0481ffbe44e3f7159..d58bd3521c677708eea023f95c05b4fe1b0c28fe 100644 (file)
@@ -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().
@@ -1949,6 +1949,29 @@ virConnectGetCapabilities (virConnectPtr conn)
     return NULL;
 }
 
+/**
+ * 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
index 1f9c8c4512a69031ecd262084472fa7b9e2238c4..033b19614e30a09b3c016f1a3d82217e6aacf4f9 100644 (file)
@@ -754,6 +754,7 @@ static virDriver openvzDriver = {
     NULL, /* domainBlockStats */
     NULL, /* domainInterfaceStats */
     NULL, /* nodeGetCellsFreeMemory */
+    NULL, /* nodeGetFreeMemory */
 };
 
 static virNetworkDriver openvzNetworkDriver = {
index 9be402392c6f61f8fe1d3f29d590658de83d5f58..87b66ad98d44674821e54a1cbb8de4e476c956fb 100644 (file)
@@ -2705,6 +2705,7 @@ static virDriver qemuDriver = {
     NULL, /* domainBlockStats */
     NULL, /* domainInterfaceStats */
     NULL, /* nodeGetCellsFreeMemory */
+    NULL, /* getFreeMemory */
 };
 
 static virNetworkDriver qemuNetworkDriver = {
index 03e49736baae361218ad6284daf9c9094449b0d4..a948530fb76efbf6bc1627ba0c6ad3f746f67031 100644 (file)
@@ -1970,6 +1970,7 @@ static virDriver testDriver = {
     NULL, /* domainBlockStats */
     NULL, /* domainInterfaceStats */
     NULL, /* nodeGetCellsFreeMemory */
+    NULL, /* getFreeMemory */
 };
 
 static virNetworkDriver testNetworkDriver = {
index cddda39bcb93ff3fbbb22de0ced4d89bf56266ac..684a0a191e1ac9bdaee19189f6978eb1e07eec7e 100644 (file)
@@ -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,
 };
 
 /**
index 2a488ccd1920aba7f40810714f4a2fbd9c819ecb..b0e8d0cc90f24a29ea8b039156279844fa5d063f 100644 (file)
@@ -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 */
 
index 67c44ec8bdf828031d8f6849ca8e39547c7625b7..e16d96cc07f570e21d79ba9da362b6a9be9d7e25 100644 (file)
@@ -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
index 429474aff26103adfc2326b1afc3592fbdf09fbc..cfc1949c69efc5cd1b8d410a10c163490dd65291 100644 (file)
@@ -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>