[PATCH 4/6] admin: Move admin_server.{h, c} to admin.{h, c}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This change is merely because admin_server would contain all the code
from dispatchers and helpers to the actual APIs. Admin should have
similar structure to the daemon-side remote driver - dispatchers and
helpers in a separate module, APIs in a separate module.
---
 daemon/Makefile.am    |   4 +-
 daemon/admin.c        | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++
 daemon/admin.h        |  36 ++++++++++++++++
 daemon/admin_server.c | 117 --------------------------------------------------
 daemon/admin_server.h |  36 ----------------
 daemon/libvirtd.c     |   4 +-
 po/POTFILES.in        |   2 +-
 7 files changed, 158 insertions(+), 158 deletions(-)
 create mode 100644 daemon/admin.c
 create mode 100644 daemon/admin.h
 delete mode 100644 daemon/admin_server.c
 delete mode 100644 daemon/admin_server.h

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 59bc4d4..5637f5a 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -128,7 +128,7 @@ libvirtd_conf_la_LIBADD = $(LIBXML_LIBS)
 
 noinst_LTLIBRARIES += libvirtd_admin.la
 libvirtd_admin_la_SOURCES = \
-		admin_server.c admin_server.h
+		admin.c admin.h
 
 libvirtd_admin_la_CFLAGS = \
 		$(AM_CFLAGS)		\
@@ -319,7 +319,7 @@ endif ! WITH_POLKIT
 
 remote.c: $(DAEMON_GENERATED)
 remote.h: $(DAEMON_GENERATED)
-admin_server.c: $(DAEMON_GENERATED)
+admin.c: $(DAEMON_GENERATED)
 
 LOGROTATE_CONFS = libvirtd.qemu.logrotate libvirtd.lxc.logrotate \
 		  libvirtd.libxl.logrotate libvirtd.uml.logrotate \
diff --git a/daemon/admin.c b/daemon/admin.c
new file mode 100644
index 0000000..ef404a9
--- /dev/null
+++ b/daemon/admin.c
@@ -0,0 +1,117 @@
+/*
+ * admin.c: handlers for RPC method calls
+ *
+ * Copyright (C) 2014-2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Martin Kletzander <mkletzan@xxxxxxxxxx>
+ */
+
+#include <config.h>
+
+#include "internal.h"
+#include "libvirtd.h"
+#include "libvirt_internal.h"
+
+#include "admin_protocol.h"
+#include "admin.h"
+#include "datatypes.h"
+#include "viralloc.h"
+#include "virerror.h"
+#include "virlog.h"
+#include "virnetdaemon.h"
+#include "virnetserver.h"
+#include "virstring.h"
+#include "virthreadjob.h"
+
+#define VIR_FROM_THIS VIR_FROM_ADMIN
+
+VIR_LOG_INIT("daemon.admin");
+
+
+void
+remoteAdmClientFreeFunc(void *data)
+{
+    struct daemonAdmClientPrivate *priv = data;
+
+    virMutexDestroy(&priv->lock);
+    virObjectUnref(priv->dmn);
+    VIR_FREE(priv);
+}
+
+void *
+remoteAdmClientInitHook(virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                        void *opaque)
+{
+    struct daemonAdmClientPrivate *priv;
+
+    if (VIR_ALLOC(priv) < 0)
+        return NULL;
+
+    if (virMutexInit(&priv->lock) < 0) {
+        VIR_FREE(priv);
+        virReportSystemError(errno, "%s", _("unable to init mutex"));
+        return NULL;
+    }
+
+    /*
+     * We don't necessarily need to ref this object right now as there
+     * must be one ref being held throughout the life of the daemon,
+     * but let's just be safe for future.
+     */
+    priv->dmn = virObjectRef(opaque);
+
+    return priv;
+}
+
+/* Functions */
+static int
+adminDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
+                         virNetServerClientPtr client,
+                         virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                         virNetMessageErrorPtr rerr,
+                         struct admin_connect_open_args *args)
+{
+    unsigned int flags;
+    struct daemonAdmClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+    int ret = -1;
+
+    VIR_DEBUG("priv=%p dmn=%p", priv, priv->dmn);
+    virMutexLock(&priv->lock);
+
+    flags = args->flags;
+    virCheckFlagsGoto(0, cleanup);
+
+    ret = 0;
+ cleanup:
+    if (ret < 0)
+        virNetMessageSaveError(rerr);
+    virMutexUnlock(&priv->lock);
+    return ret;
+}
+
+static int
+adminDispatchConnectClose(virNetServerPtr server ATTRIBUTE_UNUSED,
+                          virNetServerClientPtr client,
+                          virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                          virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED)
+{
+    virNetServerClientDelayedClose(client);
+    return 0;
+}
+
+#include "admin_dispatch.h"
diff --git a/daemon/admin.h b/daemon/admin.h
new file mode 100644
index 0000000..6262026
--- /dev/null
+++ b/daemon/admin.h
@@ -0,0 +1,36 @@
+/*
+ * admin.h: handlers for RPC method calls
+ *
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Martin Kletzander <mkletzan@xxxxxxxxxx>
+ */
+
+#ifndef __LIBVIRTD_ADMIN_H__
+# define __LIBVIRTD_ADMIN_H__
+
+# include "rpc/virnetserverprogram.h"
+# include "rpc/virnetserverclient.h"
+
+
+extern virNetServerProgramProc adminProcs[];
+extern size_t adminNProcs;
+
+void remoteAdmClientFreeFunc(void *data);
+void *remoteAdmClientInitHook(virNetServerClientPtr client, void *opaque);
+
+#endif /* __LIBVIRTD_ADMIN_H__ */
diff --git a/daemon/admin_server.c b/daemon/admin_server.c
deleted file mode 100644
index 712a44b..0000000
--- a/daemon/admin_server.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * admin_server.c:
- *
- * Copyright (C) 2014-2015 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * Author: Martin Kletzander <mkletzan@xxxxxxxxxx>
- */
-
-#include <config.h>
-
-#include "internal.h"
-#include "libvirtd.h"
-#include "libvirt_internal.h"
-
-#include "admin_protocol.h"
-#include "admin_server.h"
-#include "datatypes.h"
-#include "viralloc.h"
-#include "virerror.h"
-#include "virlog.h"
-#include "virnetdaemon.h"
-#include "virnetserver.h"
-#include "virstring.h"
-#include "virthreadjob.h"
-
-#define VIR_FROM_THIS VIR_FROM_ADMIN
-
-VIR_LOG_INIT("daemon.admin");
-
-
-void
-remoteAdmClientFreeFunc(void *data)
-{
-    struct daemonAdmClientPrivate *priv = data;
-
-    virMutexDestroy(&priv->lock);
-    virObjectUnref(priv->dmn);
-    VIR_FREE(priv);
-}
-
-void *
-remoteAdmClientInitHook(virNetServerClientPtr client ATTRIBUTE_UNUSED,
-                        void *opaque)
-{
-    struct daemonAdmClientPrivate *priv;
-
-    if (VIR_ALLOC(priv) < 0)
-        return NULL;
-
-    if (virMutexInit(&priv->lock) < 0) {
-        VIR_FREE(priv);
-        virReportSystemError(errno, "%s", _("unable to init mutex"));
-        return NULL;
-    }
-
-    /*
-     * We don't necessarily need to ref this object right now as there
-     * must be one ref being held throughout the life of the daemon,
-     * but let's just be safe for future.
-     */
-    priv->dmn = virObjectRef(opaque);
-
-    return priv;
-}
-
-/* Functions */
-static int
-adminDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
-                         virNetServerClientPtr client,
-                         virNetMessagePtr msg ATTRIBUTE_UNUSED,
-                         virNetMessageErrorPtr rerr,
-                         struct admin_connect_open_args *args)
-{
-    unsigned int flags;
-    struct daemonAdmClientPrivate *priv =
-        virNetServerClientGetPrivateData(client);
-    int ret = -1;
-
-    VIR_DEBUG("priv=%p dmn=%p", priv, priv->dmn);
-    virMutexLock(&priv->lock);
-
-    flags = args->flags;
-    virCheckFlagsGoto(0, cleanup);
-
-    ret = 0;
- cleanup:
-    if (ret < 0)
-        virNetMessageSaveError(rerr);
-    virMutexUnlock(&priv->lock);
-    return ret;
-}
-
-static int
-adminDispatchConnectClose(virNetServerPtr server ATTRIBUTE_UNUSED,
-                          virNetServerClientPtr client,
-                          virNetMessagePtr msg ATTRIBUTE_UNUSED,
-                          virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED)
-{
-    virNetServerClientDelayedClose(client);
-    return 0;
-}
-
-#include "admin_dispatch.h"
diff --git a/daemon/admin_server.h b/daemon/admin_server.h
deleted file mode 100644
index 26721a6..0000000
--- a/daemon/admin_server.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * admin_server.h
- *
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * Author: Martin Kletzander <mkletzan@xxxxxxxxxx>
- */
-
-#ifndef __LIBVIRTD_ADMIN_H__
-# define __LIBVIRTD_ADMIN_H__
-
-# include "rpc/virnetserverprogram.h"
-# include "rpc/virnetserverclient.h"
-
-
-extern virNetServerProgramProc adminProcs[];
-extern size_t adminNProcs;
-
-void remoteAdmClientFreeFunc(void *data);
-void *remoteAdmClientInitHook(virNetServerClientPtr client, void *opaque);
-
-#endif /* __ADMIN_REMOTE_H__ */
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 88ad753..109c619 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -44,7 +44,7 @@
 #include "libvirtd.h"
 #include "libvirtd-config.h"
 
-#include "admin_server.h"
+#include "admin.h"
 #include "viruuid.h"
 #include "remote_driver.h"
 #include "viralloc.h"
@@ -523,7 +523,7 @@ daemonSetupNetworking(virNetServerPtr srv,
         goto cleanup;
 
     /* Temporarily disabled */
-    if (sock_path_adm && false) {
+    if (sock_path_adm) {
         VIR_DEBUG("Registering unix socket %s", sock_path_adm);
         if (!(svcAdm = virNetServerServiceNewUNIX(sock_path_adm,
                                                   unix_sock_adm_mask,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c58a7c1..16f0ad4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,4 +1,4 @@
-daemon/admin_server.c
+daemon/admin.c
 daemon/libvirtd-config.c
 daemon/libvirtd.c
 daemon/qemu_dispatch.h
-- 
2.4.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]