]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirtd: diagnose explicitly requested but missing conf file
authorEric Blake <eblake@redhat.com>
Fri, 8 Jul 2011 17:44:25 +0000 (11:44 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 8 Jul 2011 17:49:16 +0000 (11:49 -0600)
Fixes test regression introduced in commit 8e2e4780.

* daemon/libvirtd.c (daemonConfigLoad): Add argument.
(main): Update caller.

daemon/libvirtd.c

index fe0fa27f2e4d1b36e5cb9e26b40588e51e6348de..a4198d9fe48dd16239ad460c6195793ec5c047ba 100644 (file)
@@ -1024,11 +1024,13 @@ daemonConfigFree(struct daemonConfig *data)
  */
 static int
 daemonConfigLoad(struct daemonConfig *data,
-                 const char *filename)
+                 const char *filename,
+                 bool allow_missing)
 {
     virConfPtr conf;
 
-    if (access(filename, R_OK) == -1 &&
+    if (allow_missing &&
+        access(filename, R_OK) == -1 &&
         errno == ENOENT)
         return 0;
 
@@ -1282,6 +1284,7 @@ int main(int argc, char **argv) {
     int ipsock = 0;
     struct daemonConfig *config;
     bool privileged = geteuid() == 0 ? true : false;
+    bool implicit_conf = false;
 
     struct option opts[] = {
         { "verbose", no_argument, &verbose, 1},
@@ -1367,14 +1370,16 @@ int main(int argc, char **argv) {
         exit(EXIT_FAILURE);
 
     /* No explicit config, so try and find a default one */
-    if (remote_config_file == NULL &&
-        daemonConfigFilePath(privileged,
-                             &remote_config_file) < 0)
-        exit(EXIT_FAILURE);
+    if (remote_config_file == NULL) {
+        implicit_conf = true;
+        if (daemonConfigFilePath(privileged,
+                                 &remote_config_file) < 0)
+            exit(EXIT_FAILURE);
+    }
 
     /* Read the config file if it exists*/
     if (remote_config_file &&
-        daemonConfigLoad(config, remote_config_file) < 0)
+        daemonConfigLoad(config, remote_config_file, implicit_conf) < 0)
         exit(EXIT_FAILURE);
 
     if (config->host_uuid &&