>From fe2861c25bad25e3966e601f0d9dc0c6c8648cc9 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 15 Oct 2009 13:09:17 +0100 Subject: [PATCH 3/8] Clean up VM metrics error message. Don't print "Failed to collect vm metrics during update" unless there was an actual error collecting VM metrics. There being no running domains is not an error. --- vhostmd/vhostmd.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c index 741caff..1e3378d 100644 --- a/vhostmd/vhostmd.c +++ b/vhostmd/vhostmd.c @@ -870,12 +870,16 @@ static int metrics_vms_get(vu_buffer *buf, int **ids) *ids = NULL; num_vms = vu_num_vms(); - if (num_vms < 1) + if (num_vms == -1) + return -1; + if (num_vms == 0) return 0; *ids = calloc(num_vms, sizeof(int)); - if (*ids == NULL) - return 0; + if (*ids == NULL) { + vu_log (VHOSTMD_ERR, "calloc: %m"); + return -1; + } num_vms = vu_get_vms(*ids, num_vms); for (i = 0; i < num_vms; i++) { @@ -911,7 +915,7 @@ static int vhostmd_run(int diskfd) vu_log(VHOSTMD_ERR, "Failed to collect host metrics " "during update"); - if ((num_vms = metrics_vms_get(buf, &ids)) == 0) + if ((num_vms = metrics_vms_get(buf, &ids)) == -1) vu_log(VHOSTMD_ERR, "Failed to collect vm metrics " "during update"); -- 1.6.5.rc2