]> xenbits.xensource.com Git - libvirt.git/commitdiff
diagnose "libvirtd --config=no-such-file"
authorJim Meyering <meyering@redhat.com>
Mon, 12 Jan 2009 18:22:32 +0000 (18:22 +0000)
committerJim Meyering <meyering@redhat.com>
Mon, 12 Jan 2009 18:22:32 +0000 (18:22 +0000)
* 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.

ChangeLog
qemud/qemud.c
src/conf.c

index ff96feba87b1611381a0e18f94229bcc2eb6e01a..b52037474ad3807632050587a8930f81f0530691 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Jan 12 18:55:16 +0100 2009 Jim Meyering <meyering@redhat.com>
+
+       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 <meyering@redhat.com>
 
        fix non-srcdir build failure
index c3d3c02452f580442b1f90aa606e3c71c4990109..336f0a98f632ef1cdb9c56848ef54877eb61516c 100644 (file)
@@ -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));
index 9f0fc347acd6f427b63f305800d8d9a7288ae5d8..339a150a3554fbd1c78c37131a47dfa301fb1647 100644 (file)
@@ -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;
     }