[libvirt PATCH v3 03/10] remote: split off enums into separate source file

Daniel P. Berrangé berrange at redhat.com
Thu Aug 6 10:45:38 UTC 2020


The remoteDriverTransport and remoteDriverMode enums are going to be
needed by source files beyond the remote driver client.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 src/remote/meson.build      |  1 +
 src/remote/remote_driver.c  | 41 +-----------------------------
 src/remote/remote_sockets.c | 39 +++++++++++++++++++++++++++++
 src/remote/remote_sockets.h | 50 +++++++++++++++++++++++++++++++++++++
 4 files changed, 91 insertions(+), 40 deletions(-)
 create mode 100644 src/remote/remote_sockets.c
 create mode 100644 src/remote/remote_sockets.h

diff --git a/src/remote/meson.build b/src/remote/meson.build
index 5983238a0a..91dd587cba 100644
--- a/src/remote/meson.build
+++ b/src/remote/meson.build
@@ -1,5 +1,6 @@
 remote_driver_sources = [
   'remote_driver.c',
+  'remote_sockets.c',
 ]
 
 remote_driver_generated = []
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f511a9bc33..b214632bdf 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -38,6 +38,7 @@
 #include "virbuffer.h"
 #include "remote_driver.h"
 #include "remote_protocol.h"
+#include "remote_sockets.h"
 #include "lxc_protocol.h"
 #include "qemu_protocol.h"
 #include "viralloc.h"
@@ -54,46 +55,6 @@
 
 VIR_LOG_INIT("remote.remote_driver");
 
-typedef enum {
-    REMOTE_DRIVER_TRANSPORT_TLS,
-    REMOTE_DRIVER_TRANSPORT_UNIX,
-    REMOTE_DRIVER_TRANSPORT_SSH,
-    REMOTE_DRIVER_TRANSPORT_LIBSSH2,
-    REMOTE_DRIVER_TRANSPORT_EXT,
-    REMOTE_DRIVER_TRANSPORT_TCP,
-    REMOTE_DRIVER_TRANSPORT_LIBSSH,
-
-    REMOTE_DRIVER_TRANSPORT_LAST,
-} remoteDriverTransport;
-
-VIR_ENUM_DECL(remoteDriverTransport);
-VIR_ENUM_IMPL(remoteDriverTransport,
-              REMOTE_DRIVER_TRANSPORT_LAST,
-              "tls",
-              "unix",
-              "ssh",
-              "libssh2",
-              "ext",
-              "tcp",
-              "libssh");
-
-typedef enum {
-    /* Try to figure out the "best" choice magically */
-    REMOTE_DRIVER_MODE_AUTO,
-    /* Always use the legacy libvirtd */
-    REMOTE_DRIVER_MODE_LEGACY,
-    /* Always use the per-driver virt*d daemons */
-    REMOTE_DRIVER_MODE_DIRECT,
-
-    REMOTE_DRIVER_MODE_LAST
-} remoteDriverMode;
-
-VIR_ENUM_DECL(remoteDriverMode);
-VIR_ENUM_IMPL(remoteDriverMode,
-              REMOTE_DRIVER_MODE_LAST,
-              "auto",
-              "legacy",
-              "direct");
 
 #if SIZEOF_LONG < 8
 # define HYPER_TO_TYPE(_type, _to, _from) \
diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c
new file mode 100644
index 0000000000..0662cbad14
--- /dev/null
+++ b/src/remote/remote_sockets.c
@@ -0,0 +1,39 @@
+/*
+ * remote_sockets.c: helpers for getting remote driver socket paths
+ *
+ * Copyright (C) 2007-2019 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/>.
+ */
+
+#include <config.h>
+
+#include "remote_sockets.h"
+
+VIR_ENUM_IMPL(remoteDriverTransport,
+              REMOTE_DRIVER_TRANSPORT_LAST,
+              "tls",
+              "unix",
+              "ssh",
+              "libssh2",
+              "ext",
+              "tcp",
+              "libssh");
+
+VIR_ENUM_IMPL(remoteDriverMode,
+              REMOTE_DRIVER_MODE_LAST,
+              "auto",
+              "legacy",
+              "direct");
diff --git a/src/remote/remote_sockets.h b/src/remote/remote_sockets.h
new file mode 100644
index 0000000000..1d4ae3f9c1
--- /dev/null
+++ b/src/remote/remote_sockets.h
@@ -0,0 +1,50 @@
+/*
+ * remote_sockets.h: helpers for getting remote driver socket paths
+ *
+ * Copyright (C) 2007-2020 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/>.
+ */
+
+#pragma once
+
+#include "virenum.h"
+
+typedef enum {
+    REMOTE_DRIVER_TRANSPORT_TLS,
+    REMOTE_DRIVER_TRANSPORT_UNIX,
+    REMOTE_DRIVER_TRANSPORT_SSH,
+    REMOTE_DRIVER_TRANSPORT_LIBSSH2,
+    REMOTE_DRIVER_TRANSPORT_EXT,
+    REMOTE_DRIVER_TRANSPORT_TCP,
+    REMOTE_DRIVER_TRANSPORT_LIBSSH,
+
+    REMOTE_DRIVER_TRANSPORT_LAST,
+} remoteDriverTransport;
+
+VIR_ENUM_DECL(remoteDriverTransport);
+
+typedef enum {
+    /* Try to figure out the "best" choice magically */
+    REMOTE_DRIVER_MODE_AUTO,
+    /* Always use the legacy libvirtd */
+    REMOTE_DRIVER_MODE_LEGACY,
+    /* Always use the per-driver virt*d daemons */
+    REMOTE_DRIVER_MODE_DIRECT,
+
+    REMOTE_DRIVER_MODE_LAST
+} remoteDriverMode;
+
+VIR_ENUM_DECL(remoteDriverMode);
-- 
2.26.2




More information about the libvir-list mailing list