[PATCH 0/2] vm-dump-metrics: Fix segmentation fault and exit code
This two patches fix a segfault that happens in vm-dump-metrics if you run it on a machine that doesn't have a metrics disk (eg. from the host instead of from the guest). Also makes vm-dump-metrics return status code of 1 on failure. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ -- To unsubscribe, e-mail: vhostmd+unsubscribe@opensuse.org For additional commands, e-mail: vhostmd+help@opensuse.org
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Richard W.M. Jones wrote:
libmetrics/libmetrics.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/libmetrics/libmetrics.c b/libmetrics/libmetrics.c index 9b3f9fa..8aaabcb 100644 --- a/libmetrics/libmetrics.c +++ b/libmetrics/libmetrics.c @@ -466,6 +466,10 @@ static int get_dom_id() unsigned int len;
xsh = xs_domain_open(); + if (xsh == NULL) { + libmsg("xs_domain_open: cannot open xenstore\n"); + return -1; + } domid = xs_read(xsh, XBT_NULL, "domid", &len); if (domid) { domID = atoi(domid); -- 1.6.5.rc2
Yep, obvious bug. ACK Jim -- To unsubscribe, e-mail: vhostmd+unsubscribe@opensuse.org For additional commands, e-mail: vhostmd+help@opensuse.org
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
Richard W.M. Jones wrote:
From e9db007b120209635edb2c1942a5059a0d6fc625 Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@redhat.com> Date: Fri, 16 Oct 2009 13:55:02 +0100 Subject: [PATCH 2/2] vm-dump-metrics: On error, exit with status code 1.
Make vm-dump-metrics exit with an error status code of 1 if it fails, so that we can detect this failure from scripts etc. --- vm-dump-metrics/main.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/vm-dump-metrics/main.c b/vm-dump-metrics/main.c index 4929838..f48a615 100644 --- a/vm-dump-metrics/main.c +++ b/vm-dump-metrics/main.c @@ -111,19 +111,23 @@ int main(int argc, char *argv[])
#ifdef WITH_XENSTORE if (xenstore) { - dump_xenstore_metrics(dfile); + if (dump_xenstore_metrics(dfile) == -1) + exit (1); } if (vbd) { - dump_metrics(dfile); + if (dump_metrics(dfile) == -1) + exit (1); } /* Try disk first and if not found try xenstore */ if (vbd == 0 && xenstore == 0) { if (dump_metrics(dfile) == -1) - dump_xenstore_metrics(dfile); + if (dump_xenstore_metrics(dfile) == -1) + exit (1); } #else - dump_metrics(dfile); + if (dump_metrics(dfile) == -1) + exit (1); #endif
- return 0; + exit (0); } -- 1.6.5.rc2
ACK Jim -- To unsubscribe, e-mail: vhostmd+unsubscribe@opensuse.org For additional commands, e-mail: vhostmd+help@opensuse.org
participants (2)
-
Jim Fehlig
-
Richard W.M. Jones