[Libvir] [PATCH] bug #402249 - include <xen/*.h> header files
by Richard W.M. Jones
When you build Xen from source, the "make install" rule installs extra
header files such as <xen/xen.h> and <xen/dom0_ops.h> which are all
required for building libvirt. However the Debian package doesn't run
the install rule, but instead runs (effectively) "make -C tools install"
and that only installs a partial set of header files. In particular
none of the vital public Xen header files are installed, making it
impossible to build libvirt, and probably other stuff as well.
This patch fixes that by copying the required files by hand:
http://et.redhat.com/~rjones/debian-libvirt/debian-xen-includes.patch
(It is similar to what the Fedora RPM does, faced with the same situation).
There is a bug which is somewhat related to this issue:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=402249
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
17 years
[Libvir] [PATCH] conftest: fix transposed size and count arguments to fwrite.
by Jim Meyering
I noticed conftest fail and tracked it down to this:
conftest: fix transposed size and count arguments to fwrite.
* tests/conftest.c: Include <string.h> and <errno.h>.
Also include strerror in diagnostic.
---
tests/conftest.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/conftest.c b/tests/conftest.c
index 604e410..9c8e3a6 100644
--- a/tests/conftest.c
+++ b/tests/conftest.c
@@ -1,6 +1,8 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
#include "conf.h"
int main(int argc, char **argv) {
@@ -25,8 +27,8 @@ int main(int argc, char **argv) {
exit(3);
}
virConfFree(conf);
- if (fwrite(buffer, len, 1, stdout) != len) {
- fprintf(stderr, "Write failed\n");
+ if (fwrite(buffer, 1, len, stdout) != len) {
+ fprintf(stderr, "Write failed: %s\n", strerror (errno));
exit(1);
}
exit(0);
--
1.5.3.5.643.g40e25
17 years
[Libvir] Question about specifications of virsh start
by Masayuki Sunou
Hi
I have a question about specifications of virsh start.
It is necessary to remove "type=ioemu" from the configuration file of Xen,
when HVM domain installed Para Virtualized Driver use unmodified driver
on Xen 3.0.3.
But,libvirt always adds "type=ioemu" to vif of HVM domain in xm_internal.c.
Therefore virsh start cannot start correctly HVM domain installed
Para Virtualized Driver.
Could you teach why does libvirt disregard setting of configuration
file and set type=ioemu ?
Thanks,
Masayuki Sunou.
17 years
[Libvir] [PATCH] missing printf attributes
by Jim Meyering
I stumbled across two more missing printf attributes:
2007-11-08 Jim Meyering <meyering(a)redhat.com>
* src/virsh.c (vshPrintExtra, vshDebug): Use gcc's printf attribute.
Attaching differently, in an attempt to defy mailman-2.1.5:
17 years
[Libvir] Re: [collectd] collectd libvirtstats plugin
by Florian Forster
Hi Rich,
as promised, I've taken a more in-depth look at the `libvirtstats'
plugin (I've adopted this as a working title for now and will do the
renaming on the weekend or so..) and it looks very good, thanks again :)
The `_virDomainInfo' structure has the members `memory' and `maxMem'.
Can one calculate `unused' or `free' (or whatever the preferred term in
this particular case is) memory using `maxMem - memory'? Would that be
an interesting metric?
I'm not sure what the best way to store the CPU usage is. Is the
`cpuTime' member of the `_virDomainInfo' structure the same as the sum
over all `(struct _virVcpuInfo).cpuTime'? Does collecting the total make
sense in this case? I'd much rather use the same `type' for ``normal''
CPU statistics and this case which would be much simpler if we didn't
collect the total..
I've done some minor things while looking through the code. It basically
a mix of coding style and personal convention. Since there's no Debian
package yet I didn't install try to compile it yet. I'll install the
library and fix the errors I've made as soon as I have some more spare
time. The things I've changed are basically:
- Rather use `sizeof (array);' than the `DATA_MAX_NAME_LEN' define.
- NULL-terminate the strings unconditionally after `strncpy' or
`snprintf' was used.
- Rather use
-- 8< --
if (status != 0) { handle_error (); }
-- >8 --
than
-- 8< --
if (status == -1) { handle_error (); }
-- >8 --
On Mon, Nov 05, 2007 at 02:00:12PM +0000, Richard W.M. Jones wrote:
> In the types.db, I have set the max for virt_cpu_total to be
> 256,000,000,000. [...] Therefore I have assumed here that
> max CPUs = 256.
That's basically the reason why I'd rather collect each virtual CPU in a
separate file and ``simply'' combine the graphs. This will work for n+1
CPUs ;)
> I'm using CSV output, which works, but it seems to report the
> aggregate counter values instead of the differences. Is that to be
> expected?
Yes, that is expected. The changes I've made for the next feature
release (4.3) include an easy way to get the rates for a counter value.
So I will certainly add an option to store rates instead.
Regards,
-octo
--
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
17 years
Re: [Libvir] [PATCH] * src/virsh.c (vshCommandOptInt): Correct indentation
by Jim Meyering
Well, mailman-2.1.5 mangled yet another of my messages.
[ I know why, and have reported the bug. Maybe we'll get
a fixed/newer version of mailman. ]
But at least the patch got through.
Here's the part that it removed:
Here's a tiny patch to fix indentation,
since I'm about to change the code in that area,
I'm submitting this first, so we don't mix syntax-only
changes with ones that change semantics.
The last two times I tried to send an attachment,
mailman removed them. I'll try one more time, with this one:
Jim Meyering <meyering(a)redhat.com> wrote:
> Signed-off-by: Jim Meyering <meyering(a)redhat.com>
> ---
> ChangeLog | 4 ++++
> src/virsh.c | 10 +++++-----
> 2 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index ce68401..a6de485 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,7 @@
> +2007-11-08 Jim Meyering <meyering(a)redhat.com>
> +
> + * src/virsh.c (vshCommandOptInt): Correct indentation
> +
> Wed Nov 7 14:38:43 CET 2007 Daniel Veillard <veillard(a)redhat.com>
>
> * docs/libvir.html docs/site.xsl: small updates with references
> diff --git a/src/virsh.c b/src/virsh.c
> index 0615a7d..852dea2 100644
> --- a/src/virsh.c
> +++ b/src/virsh.c
> @@ -1,7 +1,7 @@
> /*
> * virsh.c: a Xen shell used to exercise the libvirt API
> *
> - * Copyright (C) 2005 Red Hat, Inc.
> + * Copyright (C) 2005, 2007 Red Hat, Inc.
> *
> * See COPYING.LIB for the License of this software
> *
> @@ -3956,10 +3956,10 @@ vshCommandOptInt(vshCmd * cmd, const char *name, int *found)
>
> if ((arg != NULL) && (arg->data != NULL)) {
> res = strtol(arg->data, &end_p, 10);
> - if ((arg->data == end_p) || (*end_p!= 0))
> - num_found = FALSE;
> - else
> - num_found = TRUE;
> + if ((arg->data == end_p) || (*end_p!= 0))
> + num_found = FALSE;
> + else
> + num_found = TRUE;
> }
> if (found)
> *found = num_found;
17 years
[Libvir] fix misleading indentation
by Jim Meyering
Here's a tiny patch to fix indentation,
since I'm about to change the code in that area,
I'm submitting this first, so we don't mix syntax-only
changes with ones that change semantics.
The last two times I tried to send an attachment,
mailman removed them. I'll try one more time, with this one:
17 years
[Libvir] Strange warnings with gcc 4.1.2
by Richard W.M. Jones
This is with libvirt from CVS. They don't look like errors to me though...
------------
In function ‘open’,
inlined from ‘readFile’ at virsh.c:850:
/usr/include/bits/fcntl2.h:45: error: call to ‘__open_too_many_args’
declared with attribute error: open can be called either with 2 or 3
arguments, not more
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’
declared with attribute error: open with O_CREAT in second argument
needs 3 arguments
The code in question is:
if ((fd = open(filename, O_RDONLY)) == -1) {
Not a newly created file, so mode isn't needed AFAICS.
------------
In function ‘read’,
inlined from ‘readFile’ at virsh.c:864:
/usr/include/bits/unistd.h:43: warning: call to ‘__read_chk_warn’
declared with attribute warning: read called with bigger length than
size of the destination buffer
The code in question is:
char buffer[1024];
char *new;
int ret;
if ((ret = read(fd, buffer, sizeof(buffer))) == 0)
break;
Also seems correct to me.
------------
Other warnings:
virsh.c: In function ‘cmdSchedinfo’:
virsh.c:1138: warning: ‘weight’ may be used uninitialized in this function
virsh.c:1140: warning: ‘cap’ may be used uninitialized in this function
For some reason gcc appears to have lots its ability to do the data flow
analysis to find out that these warnings are bogus. In any case the fix
is trivial:
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.105
diff -u -r1.105 virsh.c
--- src/virsh.c 6 Nov 2007 09:41:18 -0000 1.105
+++ src/virsh.c 7 Nov 2007 12:37:07 -0000
@@ -1135,9 +1135,9 @@
int nr_inputparams = 0;
int inputparams = 0;
int weightfound = 0;
- int weight;
+ int weight = 0;
int capfound = 0;
- int cap;
+ int cap = 0;
char str_weight[] = "weight";
char str_cap[] = "cap";
int ret_val = FALSE;
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
17 years
[Libvir] PATCH: Avoid format string abuse (also avoids gcc warnings).
by Jim Meyering
This patch was prompted by warnings like this:
util.c:56: warning: format not a string literal and no format arguments
and they're legitimate.
Imagine a format string contains "%%..." goes through the vnsprintf
call, which reduces it to "%...". If the result string is then passed
to __virRaiseError as the format string, then *boom*.
Instead, use "%s" as the format, with the non-literal as
the matching argument. Patch below.
I searched the sources for %% and *did* find one potential problem:
$ git-grep -B1 %% > k
po/ms.po-msgid "too many drivers registered in %s"
po/ms.po:msgstr "terlalu banyak spesifikasi penukaran %% pada suffiks"
--
src/xend_internal.c- case '\n':
src/xend_internal.c: snprintf(ptr, 4, "%%%02x", string[i]);
since "% p" does happen to be a valid format string!
So if someone using Malaysian messages provoked that particular
diagnostic in a code path that takes it through __virRaiseError,
bad things might happen. Big "if", of course :-) I didn't try.
2007-11-06 Jim Meyering <meyering(a)redhat.com>
Avoid risk of format string abuse (also avoids gcc warnings).
* src/util.c (ReportError): Use a literal "%s" format string.
* src/remote_internal.c (server_error): Likewise.
* src/qemu_conf.c (qemudReportError): Likewise.
17 years
[Libvir] PATCH: Avoid format string abuse (also avoids gcc warnings).
by Jim Meyering
[resending with the patch in-line, not as an attachment --
mailman removed my attached patch the first time! Bad mailman. Bad. ]
This patch was prompted by warnings like this:
util.c:56: warning: format not a string literal and no format arguments
and they're legitimate.
Imagine a format string contains "%%..." goes through the vnsprintf
call, which reduces it to "%...". If the result string is then passed
to __virRaiseError as the format string, then *boom*.
Instead, use "%s" as the format, with the non-literal as
the matching argument. Patch below.
I searched the sources for %% and *did* find one potential problem:
$ git-grep -B1 %% > k
po/ms.po-msgid "too many drivers registered in %s"
po/ms.po:msgstr "terlalu banyak spesifikasi penukaran %% pada suffiks"
--
src/xend_internal.c- case '\n':
src/xend_internal.c: snprintf(ptr, 4, "%%%02x", string[i]);
since "% p" does happen to be a valid format string!
So if someone using Malaysian messages provoked that particular
diagnostic in a code path that takes it through __virRaiseError,
bad things might happen. Big "if", of course :-) I didn't try.
2007-11-06 Jim Meyering <meyering(a)redhat.com>
Avoid risk of format string abuse (also avoids gcc warnings).
* src/util.c (ReportError): Use a literal "%s" format string.
* src/remote_internal.c (server_error): Likewise.
* src/qemu_conf.c (qemudReportError): Likewise.
-----------------------------
>From 8e0cafec021ba3cbec55a4d691f19c14ed9e587f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 6 Nov 2007 20:14:21 +0100
Subject: [PATCH] Avoid risk of format string abuse (also avoids gcc warnings).
* src/util.c (ReportError): Use a literal "%s" format string.
* src/remote_internal.c (server_error): Likewise.
* src/qemu_conf.c (qemudReportError): Likewise.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
ChangeLog | 7 +++++++
src/qemu_conf.c | 2 +-
src/remote_internal.c | 2 +-
src/util.c | 2 +-
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 511ed6a..535173d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-06 Jim Meyering <meyering(a)redhat.com>
+
+ Avoid risk of format string abuse (also avoids gcc warnings).
+ * src/util.c (ReportError): Use a literal "%s" format string.
+ * src/remote_internal.c (server_error): Likewise.
+ * src/qemu_conf.c (qemudReportError): Likewise.
+
Tue Nov 6 17:24:16 CET 2007 Daniel Veillard <veillard(a)redhat.com>
* src/xs_internals.c: patch from Chris Lalancette, forgot to
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 78f4699..3556a9a 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -64,7 +64,7 @@ void qemudReportError(virConnectPtr conn,
errorMessage[0] = '\0';
}
__virRaiseError(conn, dom, net, VIR_FROM_QEMU, code, VIR_ERR_ERROR,
- NULL, NULL, NULL, -1, -1, errorMessage);
+ NULL, NULL, NULL, -1, -1, "%s", errorMessage);
}
int qemudLoadDriverConfig(struct qemud_driver *driver,
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 3af326f..1420a88 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -3073,7 +3073,7 @@ server_error (virConnectPtr conn, remote_error *err)
err->domain, err->code, err->level,
str1, str2, str3,
err->int1, err->int2,
- message);
+ "%s", message);
}
/* get_nonnull_domain and get_nonnull_network turn an on-wire
diff --git a/src/util.c b/src/util.c
index eb57859..c964a63 100644
--- a/src/util.c
+++ b/src/util.c
@@ -53,7 +53,7 @@ ReportError(virConnectPtr conn,
errorMessage[0] = '\0';
}
__virRaiseError(conn, dom, net, VIR_FROM_NONE, code, VIR_ERR_ERROR,
- NULL, NULL, NULL, -1, -1, errorMessage);
+ NULL, NULL, NULL, -1, -1, "%s", errorMessage);
}
static int virSetCloseExec(int fd) {
--
1.5.3.5.561.g140d
17 years