+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
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
+unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
+
/*
* Gather list of running domains
*/
/*
* 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);
virNodeInfoPtr info);
char * virConnectGetCapabilities (virConnectPtr conn);
+unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
+
/*
* Gather list of running domains
*/
/*
* 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);
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);
int startCell,
int maxCells);
+typedef unsigned long long
+ (*virDrvNodeGetFreeMemory)
+ (virConnectPtr conn);
+
/**
* _virDriver:
*
virDrvDomainBlockStats domainBlockStats;
virDrvDomainInterfaceStats domainInterfaceStats;
virDrvNodeGetCellsFreeMemory nodeGetCellsFreeMemory;
+ virDrvNodeGetFreeMemory getFreeMemory;
};
typedef int
/**
* 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().
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
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
NULL, /* nodeGetCellsFreeMemory */
+ NULL, /* nodeGetFreeMemory */
};
static virNetworkDriver openvzNetworkDriver = {
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
NULL, /* nodeGetCellsFreeMemory */
+ NULL, /* getFreeMemory */
};
static virNetworkDriver qemuNetworkDriver = {
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
NULL, /* nodeGetCellsFreeMemory */
+ NULL, /* getFreeMemory */
};
static virNetworkDriver testNetworkDriver = {
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 + \
.domainBlockStats = xenUnifiedDomainBlockStats,
.domainInterfaceStats = xenUnifiedDomainInterfaceStats,
.nodeGetCellsFreeMemory = xenUnifiedNodeGetCellsFreeMemory,
+ .getFreeMemory = xenUnifiedNodeGetFreeMemory,
};
/**
* 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.
* 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;
} 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);
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
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);
if (!root)
return NULL;
- data = xend_parse_sexp_desc(conn, root, xendConfigVersion);
+ data = xend_parse_sexp_desc(conn, root, xendConfigVersion, 0);
sexpr_free(root);
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;
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;
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);
* the caller must free() the returned value.
*/
char *
-xenDaemonDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
+xenDaemonDomainDumpXML(virDomainPtr domain, int flags)
{
xenUnifiedPrivatePtr priv;
}
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 */
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
<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>