[libvirt] (no subject)

Guido Günther agx at sigxcpu.org
Wed Mar 9 08:17:56 UTC 2011


>From 4a3765d97c3f5049aa294a4b7b629eabfd9cf04d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx at sigxcpu.org>
Date: Mon, 7 Mar 2011 22:22:36 +0100
Subject: [PATCH 1/2] Move rundir creation into separate function

---
 daemon/libvirtd.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 452566c..610e7fd 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -3150,6 +3150,24 @@ enum {
     OPT_VERSION = 129
 };
 
+
+/* Ensure the rundir exists (on tmpfs on some systems) */
+static int create_rundir (void)
+{
+    const char *rundir = LOCALSTATEDIR "/run/libvirt";
+    int ret = 0;
+
+    if (mkdir (rundir, 0755)) {
+       if (errno != EEXIST) {
+           char ebuf[1024];
+           VIR_ERROR(_("unable to create rundir %s: %s"), rundir,
+                     virStrerror(errno, ebuf, sizeof(ebuf)));
+           ret = VIR_DAEMON_ERR_RUNDIR;
+       }
+    }
+    return ret;
+}
+
 #define MAX_LISTEN 5
 int main(int argc, char **argv) {
     struct qemud_server *server = NULL;
@@ -3276,17 +3294,8 @@ int main(int argc, char **argv) {
 
     /* Ensure the rundir exists (on tmpfs on some systems) */
     if (geteuid() == 0) {
-        const char *rundir = LOCALSTATEDIR "/run/libvirt";
-
-        if (mkdir (rundir, 0755)) {
-            if (errno != EEXIST) {
-                char ebuf[1024];
-                VIR_ERROR(_("unable to create rundir %s: %s"), rundir,
-                          virStrerror(errno, ebuf, sizeof(ebuf)));
-                ret = VIR_DAEMON_ERR_RUNDIR;
-                goto error;
-            }
-        }
+        if (create_rundir ())
+            goto error;
     }
 
     /* Beyond this point, nothing should rely on using
-- 
1.7.4.1




More information about the libvir-list mailing list