[Libvir] RFC: Supporting serial & parallel ports for QEMU (and improving Xen)
by Daniel P. Berrange
One user's feature request for our QEMU driver is to support serial ports.
Easy you might think... you'd be wrong :-)
On Xen we have very simple approach. When creating a guest simply add
<console/>
And it'll cause a serial port to be setup with an autoallocated pty, so
you get back
<console pty='/dev/pts/5'/>
In retrospect calling it 'console' was dumb, but hey we're stuck with that
now and its only a tiny naming issue so I don't mind really.
We can do the same thing with QEMU quite easily. QEMU, however, supports
many many many more ways to hooking up the serial port to Dom0. Indeed
so does Xen fullyvirt, but we don't expose this ability. Parallel ports
have identical config syntax to serial ports so we might as well deal
with both at once.
So, here's a stripped down version of the QEMU docs:
[quote http://fabrice.bellard.free.fr/qemu/qemu-doc.html#SEC10]
`-serial dev'
Redirect the virtual serial port to host character device dev. The
default device is vc in graphical mode and stdio in non graphical
mode. This option can be used several times to simulate up to 4
serials ports. Use -serial none to disable all serial ports.
Available character devices are:
vc
Virtual console
pty
[Linux only] Pseudo TTY (a new PTY is automatically allocated)
none
No device is allocated.
null
void device
/dev/XXX
[Linux only] Use host tty, e.g. `/dev/ttyS0'. The host serial port
parameters are set according to the emulated ones.
/dev/parportN
[Linux only, parallel port only] Use host parallel port N. Currently
only SPP parallel port features can be used.
file:filename
Write output to filename. No character can be read.
stdio
[Unix only] standard input/output
pipe:filename
name pipe filename
COMn
[Windows only] Use host serial port n
udp:[remote_host]:remote_port[@[src_ip]:src_port]
This implements UDP Net Console.
tcp:[host]:port[,server][,nowait][,nodelay]
The TCP Net Console has two modes of operation.
telnet:host:port[,server][,nowait][,nodelay]
The telnet protocol is used instead of raw tcp sockets.
unix:path[,server][,nowait]
A unix domain socket is used instead of a tcp socket.
[/quote]
I don't see any reason to not support all/most of these options. The things
I don't like here is that /dev/XXX, vs /dev/parportN, vs COMn differences
for connecting guest <-> host passthrough of the devices. I figure it could
be simpler if it was just represented as 'n' and we'd translate that to
be /dev/ttyS[n] or /dev/parport[n] or COM[n] as needed.
The question as ever is how to represent this in XML. For serial ports we'll
stick with '<console>', while parallel ports we might as well use a better
named '<parallel>'. Next up, I think should use a 'type' attribute on this
element to determine the main way ot connecting the device, and then more
type specific attributes or sub-elements as needed. If 'type' was not
specified then use a default of 'pty', since that gives compatability with
existing practice.
As an illustrative example
/*
* Parse the XML definition for a character device
*
* Top level node will be <console> or <parallel>, but all attributes
* and sub-elements are identical.
*
* type=vc|pty|null|host|file|pipe|udp|tcp|telnet, default is pty
*
* <console type='vc'/>
*
* <console type='pty' pty='/dev/pts/3'/>
*
* <console type='null'/>
*
* <console type='host' port='3'/>
*
* <console type='file' path='/some/file'/>
*
* <console type='pipe' path='/some/file'/>
*
* <console type='udp'>
* <sendto port='12356'/>
* </console>
*
* <console type='udp'>
* <sendto addr='127.0.0.1' port='12356'/>
* </console>
*
* <console type='udp'>
* <sendto addr='127.0.0.1' port='12356'/>
* <bind port='12356'/>
* </console>
*
* <console type='udp'>
* <sendto addr='127.0.0.1' port='12356'/>
* <bind addr='127.0.0.1' port='12356'/>
* </console>
*
* <console type='tcp'>
* <listen port='12356'/>
* </console>
*
* <console type='tcp'>
* <listen addr='127.0.0.1' port='12356'>
* <nowait/>
* <nodelay/>
* </listen>
* </console>
*
* <console type='tcp'>
* <connect addr='127.0.0.1' port='12356'>
* <nodelay/>
* </connect>
* </console>
*
* <console type='telnet'>
* <listen addr='127.0.0.1' port='12356'/>
* </console>
*
* <console type='telnet'>
* <connect addr='127.0.0.1' port='12356'/>
* </console>
*
*/
BTW, the udp, tcp, telnet options are only available on QEMU >= 0.9.0. We
already have ability to detect / validate that for both Xen & QEMU drivers.
NB, whereever there are IP addresses, hostnames can be used too, hence I
call the attriute 'addr' instead of 'ip'
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
16 years, 9 months
[Libvir] [PATCH] Xen: Support cpu_weight and cpu_cap for Xen.
by Tatsuro Enokura
Hi,
I set the information of cpu_weight/cpu_cap to configuration file or
sxp format, and execute "virsh start".
But the information of weight/cap is lost.
libvirt doesn't support cpu_weight and cpu_cap for XML format.
see also Bz#337591
https://bugzilla.redhat.com/show_bug.cgi?id=337591
I make a patch to add weight/cap attributes as vcpus element
(eg. <vcpus weight='512' cap='280'>4</vcpus>)
c.f. the thread at:
https://www.redhat.com/archives/libvir-list/2007-October/msg00044.html
Signed-off-by: Tatsuro Enokura <fj7716hz(a)aa.jp.fujitsu.com>
Thanks,
Tatsuro Enokura
Index: libvirt/src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.151
diff -u -p -r1.151 xend_internal.c
--- libvirt/src/xend_internal.c 22 Oct 2007 20:28:55 -0000 1.151
+++ libvirt/src/xend_internal.c 24 Oct 2007 06:02:27 -0000
@@ -1438,8 +1438,19 @@ xend_parse_sexp_desc(virConnectPtr conn,
if ((cur_mem >= MIN_XEN_GUEST_SIZE) && (cur_mem != max_mem))
virBufferVSprintf(&buf, " <currentMemory>%d</currentMemory>\n",
cur_mem);
- virBufferVSprintf(&buf, " <vcpu>%d</vcpu>\n",
+ virBufferVSprintf(&buf, " <vcpu");
+ if (sexpr_node(root, "domain/cpu_weight") != NULL) {
+ virBufferVSprintf(&buf, " weight='%d'",
+ sexpr_int(root, "domain/cpu_weight"));
+ }
+ if (sexpr_node(root, "domain/cpu_cap") != NULL) {
+ virBufferVSprintf(&buf, " cap='%d'",
+ sexpr_int(root, "domain/cpu_cap"));
+ }
+ virBufferVSprintf(&buf, ">%d</vcpu>\n",
sexpr_int(root, "domain/vcpus"));
+
+
tmp = sexpr_node(root, "domain/on_poweroff");
if (tmp != NULL)
virBufferVSprintf(&buf, " <on_poweroff>%s</on_poweroff>\n", tmp);
Index: libvirt/src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.41
diff -u -p -r1.41 xm_internal.c
--- libvirt/src/xm_internal.c 10 Oct 2007 17:55:38 -0000 1.41
+++ libvirt/src/xm_internal.c 24 Oct 2007 06:02:28 -0000
@@ -661,9 +661,14 @@ char *xenXMDomainFormatXML(virConnectPtr
virBufferVSprintf(buf, " <memory>%ld</memory>\n", val * 1024);
+ virBufferVSprintf(buf, " <vcpu");
+ if (xenXMConfigGetInt(conf, "cpu_weight", &val) == 0)
+ virBufferVSprintf(buf, " weight='%ld'", val);
+ if (xenXMConfigGetInt(conf, "cpu_cap", &val) == 0)
+ virBufferVSprintf(buf, " cap='%ld'", val);
if (xenXMConfigGetInt(conf, "vcpus", &val) < 0)
val = 1;
- virBufferVSprintf(buf, " <vcpu>%ld</vcpu>\n", val);
+ virBufferVSprintf(buf, ">%ld</vcpu>\n", val);
if (xenXMConfigGetString(conf, "on_poweroff", &str) < 0)
@@ -1820,6 +1825,12 @@ virConfPtr xenXMParseXMLToConfig(virConn
if (xenXMConfigSetIntFromXPath(conn, conf, ctxt, "vcpus", "string(/domain/vcpu)", 0, 1,
"cannot set vcpus config parameter") < 0)
goto error;
+ if (xenXMConfigSetIntFromXPath(conn, conf, ctxt, "cpu_weight", "string(/domain/vcpu/@weight)", 0, 1,
+ "cannot set cpu_weight config paramerter") < 0)
+ goto error;
+ if (xenXMConfigSetIntFromXPath(conn, conf, ctxt, "cpu_cap", "string(/domain/vcpu/@cap)", 0, 1,
+ "cannot set cpu_cap config paramerter") < 0)
+ goto error;
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type)", ctxt);
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
Index: libvirt/src/xml.c
===================================================================
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.94
diff -u -p -r1.94 xml.c
--- libvirt/src/xml.c 23 Oct 2007 15:31:33 -0000 1.94
+++ libvirt/src/xml.c 24 Oct 2007 06:02:28 -0000
@@ -1529,6 +1529,12 @@ virDomainParseXMLDesc(virConnectPtr conn
vcpus = (unsigned int) f;
}
virBufferVSprintf(&buf, "(vcpus %u)", vcpus);
+ if (virXPathNumber("number(/domain/vcpu[1]/@weight)", ctxt, &f) == 0) {
+ virBufferVSprintf(&buf, "(cpu_weight %ld)", (long) f);
+ }
+ if (virXPathNumber("number(/domain/vcpu[1]/@cap)", ctxt, &f) == 0) {
+ virBufferVSprintf(&buf, "(cpu_cap %ld)", (long) f);
+ }
str = virXPathString("string(/domain/vcpu/@cpuset)", ctxt);
if (str != NULL) {
16 years, 10 months
[Libvir] Preliminary packages for libvirt on Debian
by Richard W.M. Jones
These are preliminary packages for libvirt 0.3.3 on Debian. The libvirt
package is derived from the one in Ubuntu, originally packaged by Andrew
Mitchell.
Xen
---
Unfortunately a patch is needed to the base Xen package in Debian, so
that it includes the header files needed by libvirt. Doubly
unfortunately because of the strange way that Xen is packaged in Debian
it isn't possible to modify the changelog (therefore the version or
release number) without some voodoo which I don't understand[1]. So the
version here has the same version/release as the one currently in Debian
testing. As a result you'll have to manually install it using dpkg.
Binary for i386:
http://et.redhat.com/~rjones/debian-libvirt/xen-docs-3.1_3.1.1-1_all.deb
http://et.redhat.com/~rjones/debian-libvirt/xen-hypervisor-3.1-1-i386_3.1...
http://et.redhat.com/~rjones/debian-libvirt/xen-hypervisor-3.1-1-i386-non...
http://et.redhat.com/~rjones/debian-libvirt/xen-utils-3.1-1_3.1.1-1_i386.deb
Patch required to get the right header files:
http://et.redhat.com/~rjones/debian-libvirt/debian-xen-includes.patch
libvirt
-------
Source:
http://et.redhat.com/~rjones/debian-libvirt/libvirt_0.3.3-1.diff.gz
http://et.redhat.com/~rjones/debian-libvirt/libvirt_0.3.3-1.dsc
http://et.redhat.com/~rjones/debian-libvirt/libvirt_0.3.3-1_i386.changes
http://et.redhat.com/~rjones/debian-libvirt/libvirt_0.3.3.orig.tar.gz
Binary for i386:
http://et.redhat.com/~rjones/debian-libvirt/libvirt0_0.3.3-1_i386.deb
http://et.redhat.com/~rjones/debian-libvirt/libvirt-bin_0.3.3-1_i386.deb
http://et.redhat.com/~rjones/debian-libvirt/libvirt-dev_0.3.3-1_i386.deb
http://et.redhat.com/~rjones/debian-libvirt/python-libvirt_0.3.3-1_i386.deb
virt-install & virt-manager
---------------------------
I'm working on these, although I managed to "brick" my Debian install
because of some stupidity in pycentral ...
Rich.
[1] See this thread for the full details:
http://lists.alioth.debian.org/pipermail/pkg-xen-devel/2007-November/0015...
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
16 years, 11 months
[Libvir] [PATCH] Detect heap allocation failure; factor out some duplication.
by Jim Meyering
I spotted a few unchecked heap allocations (strdup, malloc, calloc)
in qemud.c and have fixed it so such failure evokes a proper diagnostic
rather than e.g., a segfault.
I've also arranged to free some of the memory upon failure,
but not all (see comments for why).
In spite of those additions, this patch factors out enough
duplication that the net change is to remove a few lines from the
file. Although in general I prefer to factor things out into
separate functions, in this case, it seemed better to use macros.
Wed Nov 28 14:16:17 CET 2007 Jim Meyering <meyering(a)redhat.com>
Detect heap allocation failure; factor out some duplication.
* qemud/qemud.c (mdns_name, tls_allowed_ip_list, tls_allowed_dn_list):
Remove "const", now that we free these.
(remoteCheckDN, remoteCheckAccess): Adapt to const removal.
(qemudDispatchServer): Check for heap allocation failure.
CHECK_TYPE, GET_CONF_INT, GET_CONF_STR, GET_CONF_STR_LIST):
New and changed macros.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
qemud/qemud.c | 247 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 121 insertions(+), 126 deletions(-)
diff --git a/qemud/qemud.c b/qemud/qemud.c
index 5f76a26..34ab815 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -79,13 +79,13 @@ static int unix_sock_ro_perms = 0777; /* Allow world */
#ifdef HAVE_AVAHI
static int mdns_adv = 1;
-static const char *mdns_name = NULL;
+static char *mdns_name = NULL;
#endif
static int tls_no_verify_certificate = 0;
static int tls_no_verify_address = 0;
-static const char **tls_allowed_ip_list = 0;
-static const char **tls_allowed_dn_list = 0;
+static char **tls_allowed_ip_list = NULL;
+static char **tls_allowed_dn_list = NULL;
static const char *key_file = LIBVIRT_SERVERKEY;
static const char *cert_file = LIBVIRT_SERVERCERT;
@@ -840,7 +840,7 @@ remoteCheckDN (gnutls_x509_crt_t cert)
{
char name[256];
size_t namesize = sizeof name;
- const char **wildcards;
+ char **wildcards;
int err;
err = gnutls_x509_crt_get_dn (cert, name, &namesize);
@@ -959,7 +959,7 @@ static int
remoteCheckAccess (struct qemud_client *client)
{
char addr[NI_MAXHOST];
- const char **wildcards;
+ char **wildcards;
int found, err;
/* Verify client certificate. */
@@ -1044,6 +1044,8 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
}
client = calloc(1, sizeof(struct qemud_client));
+ if (client == NULL)
+ goto cleanup;
client->magic = QEMUD_CLIENT_MAGIC;
client->fd = fd;
client->readonly = sock->readonly;
@@ -1523,31 +1525,38 @@ remoteReadConfigFile (const char *filename)
virConfValuePtr p;
-#define CHECK_TYPE(name,typ) if (p && p->type != (typ)) { \
- qemudLog (QEMUD_ERR, \
- "remoteReadConfigFile: %s: %s: expected type " #typ "\n", \
- filename, (name)); \
- return -1; \
- }
-
- p = virConfGetValue (conf, "listen_tls");
- CHECK_TYPE ("listen_tls", VIR_CONF_LONG);
- listen_tls = p ? p->l : listen_tls;
-
- p = virConfGetValue (conf, "listen_tcp");
- CHECK_TYPE ("listen_tcp", VIR_CONF_LONG);
- listen_tcp = p ? p->l : listen_tcp;
-
- p = virConfGetValue (conf, "tls_port");
- CHECK_TYPE ("tls_port", VIR_CONF_STRING);
- tls_port = p ? strdup (p->str) : tls_port;
-
- p = virConfGetValue (conf, "tcp_port");
- CHECK_TYPE ("tcp_port", VIR_CONF_STRING);
- tcp_port = p ? strdup (p->str) : tcp_port;
-
- p = virConfGetValue (conf, "unix_sock_group");
- CHECK_TYPE ("unix_sock_group", VIR_CONF_STRING);
+#define CHECK_TYPE(p, filename, conf, var_name, Type) \
+ do { \
+ (p) = virConfGetValue ((conf), #Type); \
+ if ((p) && (p)->type != (Type)) { \
+ qemudLog (QEMUD_ERR, \
+ "remoteReadConfigFile: %s: %s:" \
+ " expected type " #Type "\n", \
+ filename, #var_name); \
+ goto free_and_fail; \
+ } \
+ } while (0)
+
+#define GET_CONF_INT(p, filename, conf, var_name) \
+ do { \
+ CHECK_TYPE(p, filename, conf, var_name, VIR_CONF_LONG); \
+ if (p) \
+ (var_name) = p->l; \
+ } while (0)
+
+#define GET_CONF_STR(p, filename, conf, var_name) \
+ do { \
+ CHECK_TYPE(p, filename, conf, var_name, VIR_CONF_STRING); \
+ if (p) { \
+ if (!((var_name) = strdup ((p)->str))) \
+ goto diagnose_alloc_failure_and_fail; \
+ } \
+ } while (0)
+
+ GET_CONF_STR (p, filename, conf, tls_port);
+ GET_CONF_STR (p, filename, conf, tcp_port);
+
+ CHECK_TYPE (p, filename, conf, unix_sock_group, VIR_CONF_STRING);
if (p && p->str) {
if (getuid() != 0) {
qemudLog (QEMUD_WARN, "Cannot set group when not running as root");
@@ -1561,8 +1570,7 @@ remoteReadConfigFile (const char *filename)
}
}
- p = virConfGetValue (conf, "unix_sock_ro_perms");
- CHECK_TYPE ("unix_sock_ro_perms", VIR_CONF_STRING);
+ GET_CONF_INT (p, filename, conf, unix_sock_ro_perms);
if (p && p->str) {
if (xstrtol_i(p->str, NULL, 8, &unix_sock_ro_perms) != 0) {
qemudLog (QEMUD_ERR, "Failed to parse mode '%s'", p->str);
@@ -1570,8 +1578,7 @@ remoteReadConfigFile (const char *filename)
}
}
- p = virConfGetValue (conf, "unix_sock_rw_perms");
- CHECK_TYPE ("unix_sock_rw_perms", VIR_CONF_STRING);
+ GET_CONF_INT (p, filename, conf, unix_sock_rw_perms);
if (p && p->str) {
if (xstrtol_i(p->str, NULL, 8, &unix_sock_rw_perms) != 0) {
qemudLog (QEMUD_ERR, "Failed to parse mode '%s'", p->str);
@@ -1580,107 +1587,95 @@ remoteReadConfigFile (const char *filename)
}
#ifdef HAVE_AVAHI
- p = virConfGetValue (conf, "mdns_adv");
- CHECK_TYPE ("mdns_adv", VIR_CONF_LONG);
- mdns_adv = p ? p->l : mdns_adv;
-
- p = virConfGetValue (conf, "mdns_name");
- CHECK_TYPE ("mdns_name", VIR_CONF_STRING);
- mdns_name = p ? strdup (p->str) : NULL;
+ GET_CONF_INT (p, filename, conf, mdns_adv);
+ GET_CONF_STR (p, filename, conf, mdns_name);
#endif
- p = virConfGetValue (conf, "tls_no_verify_certificate");
- CHECK_TYPE ("tls_no_verify_certificate", VIR_CONF_LONG);
- tls_no_verify_certificate = p ? p->l : tls_no_verify_certificate;
-
- p = virConfGetValue (conf, "tls_no_verify_address");
- CHECK_TYPE ("tls_no_verify_address", VIR_CONF_LONG);
- tls_no_verify_address = p ? p->l : tls_no_verify_address;
-
- p = virConfGetValue (conf, "key_file");
- CHECK_TYPE ("key_file", VIR_CONF_STRING);
- key_file = p ? strdup (p->str) : key_file;
-
- p = virConfGetValue (conf, "cert_file");
- CHECK_TYPE ("cert_file", VIR_CONF_STRING);
- cert_file = p ? strdup (p->str) : cert_file;
-
- p = virConfGetValue (conf, "ca_file");
- CHECK_TYPE ("ca_file", VIR_CONF_STRING);
- ca_file = p ? strdup (p->str) : ca_file;
-
- p = virConfGetValue (conf, "crl_file");
- CHECK_TYPE ("crl_file", VIR_CONF_STRING);
- crl_file = p ? strdup (p->str) : crl_file;
-
- p = virConfGetValue (conf, "tls_allowed_dn_list");
- if (p) {
- switch (p->type) {
- case VIR_CONF_STRING:
- tls_allowed_dn_list = malloc (2 * sizeof (char *));
- tls_allowed_dn_list[0] = strdup (p->str);
- tls_allowed_dn_list[1] = 0;
- break;
+ GET_CONF_INT (p, filename, conf, tls_no_verify_certificate);
+ GET_CONF_INT (p, filename, conf, tls_no_verify_address);
+
+ GET_CONF_STR (p, filename, conf, key_file);
+ GET_CONF_STR (p, filename, conf, cert_file);
+ GET_CONF_STR (p, filename, conf, ca_file);
+ GET_CONF_STR (p, filename, conf, crl_file);
+
+#define GET_CONF_STR_LIST(List_var) \
+ do { \
+ p = virConfGetValue (conf, #List_var); \
+ if (p) { \
+ switch (p->type) { \
+ case VIR_CONF_STRING: \
+ if (!((List_var) = malloc (2 * sizeof (char *)))) \
+ goto free_and_fail; \
+ if (!((List_var)[0] = strdup (p->str))) \
+ goto free_and_fail; \
+ (List_var)[1] = NULL; \
+ break; \
+ \
+ case VIR_CONF_LIST: { \
+ int i, len = 0; \
+ virConfValuePtr pp; \
+ for (pp = p->list; pp; pp = p->next) \
+ len++; \
+ if (!((List_var) = malloc ((1+len) * sizeof (char *)))) \
+ goto free_and_fail; \
+ for (i = 0, pp = p->list; pp; ++i, pp = p->next) { \
+ if (pp->type != VIR_CONF_STRING) { \
+ qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: %s: " \
+ "must be a string or list of strings\n", \
+ filename, #List_var); \
+ goto free_and_fail; \
+ } \
+ if (!((List_var)[i] = strdup (pp->str))) \
+ goto free_and_fail; \
+ } \
+ (List_var)[i] = NULL; \
+ break; \
+ } \
+ \
+ default: \
+ qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: %s: " \
+ "must be a string or list of strings\n", \
+ filename, #List_var); \
+ goto free_and_fail; \
+ } \
+ } \
+ } while (0)
+
+ GET_CONF_STR_LIST (tls_allowed_dn_list);
+ GET_CONF_STR_LIST (tls_allowed_ip_list);
- case VIR_CONF_LIST: {
- int i, len = 0;
- virConfValuePtr pp;
- for (pp = p->list; pp; pp = p->next)
- len++;
- tls_allowed_dn_list =
- malloc ((1+len) * sizeof (char *));
- for (i = 0, pp = p->list; pp; ++i, pp = p->next) {
- if (pp->type != VIR_CONF_STRING) {
- qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: tls_allowed_dn_list: should be a string or list of strings\n", filename);
- return -1;
- }
- tls_allowed_dn_list[i] = strdup (pp->str);
- }
- tls_allowed_dn_list[i] = 0;
- break;
- }
+ virConfFree (conf);
+ return 0;
- default:
- qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: tls_allowed_dn_list: should be a string or list of strings\n", filename);
- return -1;
- }
- }
+ diagnose_alloc_failure_and_fail:
+ qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s\n", strerror (errno));
- p = virConfGetValue (conf, "tls_allowed_ip_list");
- if (p) {
- switch (p->type) {
- case VIR_CONF_STRING:
- tls_allowed_ip_list = malloc (2 * sizeof (char *));
- tls_allowed_ip_list[0] = strdup (p->str);
- tls_allowed_ip_list[1] = 0;
- break;
+ free_and_fail:
+ free (mdns_name);
+ mdns_name = NULL;
- case VIR_CONF_LIST: {
- int i, len = 0;
- virConfValuePtr pp;
- for (pp = p->list; pp; pp = p->next)
- len++;
- tls_allowed_ip_list =
- malloc ((1+len) * sizeof (char *));
- for (i = 0, pp = p->list; pp; ++i, pp = p->next) {
- if (pp->type != VIR_CONF_STRING) {
- qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: tls_allowed_ip_list: should be a string or list of strings\n", filename);
- return -1;
- }
- tls_allowed_ip_list[i] = strdup (pp->str);
- }
- tls_allowed_ip_list[i] = 0;
- break;
- }
+ /* Don't bother trying to free tcp_port, tls_port, key_file, cert_file,
+ ca_file, or crl_file, since they are initialized to non-malloc'd
+ strings. Besides, these are static variables, and callers are
+ unlikely to call this function more than once, so there wouldn't
+ even be a real leak. */
- default:
- qemudLog (QEMUD_ERR, "remoteReadConfigFile: %s: tls_allowed_ip_list: should be a string or list of strings\n", filename);
- return -1;
- }
+ if (tls_allowed_ip_list) {
+ char *t;
+ for (t = *tls_allowed_ip_list; t; t++)
+ free (t);
+ tls_allowed_ip_list = NULL;
}
- virConfFree (conf);
- return 0;
+ if (tls_allowed_dn_list) {
+ char *t;
+ for (t = *tls_allowed_dn_list; t; t++)
+ free (t);
+ tls_allowed_dn_list = NULL;
+ }
+
+ return -1;
}
/* Print command-line usage. */
--
1.5.3.6.961.gecf4
16 years, 11 months
[Libvir] Semantic of xenUnifiedType()
by Daniel Veillard
It does the following:
static const char *
xenUnifiedType (virConnectPtr conn)
{
GET_PRIVATE(conn);
int i;
const char *ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (priv->opened[i] && drivers[i]->type) {
ret = drivers[i]->type (conn);
if (ret) return ret;
}
return NULL;
}
as a result if running as an user virConnectGetType() returns
"XenXM" because the XM file parser backend ended up being registered
first. I think that's bogus and we should change the function to
return "Xen" in any case and drop the virDrvGetType type from
struct xenUnifiedDriver and all associated functions in the various
back-ends.
Opinion ?
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
16 years, 11 months
[Libvir] [PATCH 0/3] More misc patches to improve Windows support
by Richard W.M. Jones
There follows some miscellaneous patches to configure.in and the
Makefile.am's to improve Windows support. I'll explain each in the
follow-ups.
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
16 years, 12 months
[Libvir] Create domU without any disks
by Tim Verhoeven
Hi,
I'm working on RHEL5.1 (libvirt-0.2.3-9.el5). I would like to know if
it is possible, using libvirt, to create a Xen PVM domU that has no
disks? And if this is possible how to code this ( a simple example is
ok).
I can create a configfile for "xm create ..." that works (just use
"disk = [ ]"). But I also need to do this koan (companion to cobbler)
and it uses libvirt.
Thanks,
Tim
--
Tim Verhoeven - tim.verhoeven.be(a)gmail.com - 0479 / 88 11 83
Hoping the problem magically goes away by ignoring it is the
"microsoft approach to programming" and should never be allowed.
(Linus Torvalds)
16 years, 12 months
Re: [Libvir] Building libvirt-0.3.3 on CentOS4
by Carl Jones
Richard W.M. Jones wrote:
> Daniel P. Berrange wrote:
>> On Wed, Nov 28, 2007 at 01:25:41PM +1300, Carl Jones wrote:
>>> Hi,
>>>
>>> I'm trying to build libvirt-0.3.3 on a CentOS4 machine. But I'm
>>> hitting this error while running 'make':
>>>
>>> ./configure --with-init-script=redhat --without-qemu --without-remote
>>> --without-test --with-xen --without-openvz --without-avahi
>>> [...]
>>> make[2]: Entering directory `/usr/src/redhat/SOURCES/libvirt-0.3.3/src'
>>> gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I../include -I../qemud
>>> -I/usr/include/libxml2 -DBINDIR=\""/usr/local/libexec"\"
>>> -DSBINDIR=\""/usr/local/sbin"\" -DSYSCONF_DIR="\"/usr/local/etc\""
>>> -DLOCALEBASEDIR=\""/usr/local/share/locale"\"
>>> -DLOCAL_STATE_DIR=\""/usr/local/var"\" -DGETTEXT_PACKAGE=\"libvirt\"
>>> -Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra
>>> -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return
>>> -Wstrict-prototypes -Winline -Wredundant-decls -Wno-sign-compare
>>> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables
>>> -DWITH_XEN -g -O2 -MT virsh-virsh.o -MD -MP -MF
>>> .deps/virsh-virsh.Tpo -c -o virsh-virsh.o `test -f 'virsh.c' || echo
>>> './'`virsh.c
>>> virsh.c: In function `vshOutputLogFile':
>>> virsh.c:4577: warning: implicit declaration of function `localtime'
>>> virsh.c:4577: warning: nested extern declaration of `localtime'
>>> virsh.c:4577: warning: assignment makes pointer from integer without
>>> a cast
>>
>> Looks like its missing an '#include <time.h>' statement from virsh.c
>
> Carl, can you let us know if adding that include line fixes it for you?
> If so I'll make the change in CVS.
>
> Rich.
After adding that include, it compiles and works nicely. Thanks.
Regards,
Carl
16 years, 12 months