diff --git a/ChangeLog b/ChangeLog index ff96feba87..b52037474a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon Jan 12 18:55:16 +0100 2009 Jim Meyering + + diagnose "libvirtd --config=no-such-file" + * qemud/qemud.c (remoteReadConfigFile): Don't return 0 (success) + when the config file is unreadable or nonexistent + Return -1, not 0, upon virConfReadFile failure. + (main): If remote_config_file is not specified via --config(-f), + use the default config file only if it exists. Otherwise, + use /dev/null. + * src/conf.c (virConfReadFile): Don't diagnose virFileReadAll + failure, since it already does that. + Mon Jan 12 18:55:15 +0100 2009 Jim Meyering fix non-srcdir build failure diff --git a/qemud/qemud.c b/qemud/qemud.c index c3d3c02452..336f0a98f6 100644 --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -1,7 +1,7 @@ /* * qemud.c: daemon start of day, guest process & i/o management * - * Copyright (C) 2006, 2007, 2008 Red Hat, Inc. + * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -2116,13 +2116,8 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename) auth_unix_ro = REMOTE_AUTH_NONE; #endif - /* Just check the file is readable before opening it, otherwise - * libvirt emits an error. - */ - if (access (filename, R_OK) == -1) return 0; - conf = virConfReadFile (filename); - if (!conf) return 0; + if (!conf) return -1; /* * First get all the logging settings and activate them @@ -2301,7 +2296,7 @@ int main(int argc, char **argv) { struct sigaction sig_action; int sigpipe[2]; const char *pid_file = NULL; - const char *remote_config_file = SYSCONF_DIR "/libvirt/libvirtd.conf"; + const char *remote_config_file = NULL; int ret = 1; struct option opts[] = { @@ -2372,6 +2367,15 @@ int main(int argc, char **argv) { } } + if (remote_config_file == NULL) { + static const char *default_config_file + = SYSCONF_DIR "/libvirt/libvirtd.conf"; + remote_config_file = + (access(default_config_file, X_OK) == 0 + ? default_config_file + : "/dev/null"); + } + if (godaemon) { if (qemudGoDaemon() < 0) { VIR_ERROR(_("Failed to fork as daemon: %s"), strerror(errno)); diff --git a/src/conf.c b/src/conf.c index 9f0fc347ac..339a150a35 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1,7 +1,7 @@ /** * conf.c: parser for a subset of the Python encoded Xen configuration files * - * Copyright (C) 2006, 2007, 2008 Red Hat, Inc. + * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc. * * See COPYING.LIB for the License of this software * @@ -712,7 +712,6 @@ virConfReadFile(const char *filename) } if ((len = virFileReadAll(filename, MAX_CONFIG_FILE_SIZE, &content)) < 0) { - virConfError(NULL, VIR_ERR_OPEN_FAILED, filename); return NULL; }