]> xenbits.xensource.com Git - libvirt.git/commitdiff
Move dtrace probe macros into separate header file
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 27 Feb 2014 13:41:11 +0000 (13:41 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 18 Mar 2014 14:29:21 +0000 (14:29 +0000)
The dtrace probe macros rely on the logging API. We can't make
the internal.h header include the virlog.h header though since
that'd be a circular include. Instead simply split the dtrace
probes into their own header file, since there's no compelling
reason for them to be in the main internal.h header.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
13 files changed:
daemon/remote.c
src/internal.h
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_text.c
src/rpc/virkeepalive.c
src/rpc/virnetclient.c
src/rpc/virnetserverclient.c
src/rpc/virnetsocket.c
src/rpc/virnettlscontext.c
src/util/vireventpoll.c
src/util/virobject.c
src/util/virprobe.h [new file with mode: 0644]

index 416aa40086654ead021b92bc808c20cc0ae13732..48ca3d0b517c14b5f2addfc12ca1fc2c37d267d6 100644 (file)
@@ -52,6 +52,7 @@
 #include "object_event.h"
 #include "domain_conf.h"
 #include "network_conf.h"
+#include "virprobe.h"
 #include "viraccessapicheck.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
index 5a38448b16d32f2872bd8a761873fb0bae213aa5..0b36de9f4e206a492c04bad61f2afee1b044577c 100644 (file)
 # define VIR_ROUND_UP(value, size) (VIR_DIV_UP(value, size) * (size))
 
 
-# if WITH_DTRACE_PROBES
-#  ifndef LIBVIRT_PROBES_H
-#   define LIBVIRT_PROBES_H
-#   include "libvirt_probes.h"
-#  endif /* LIBVIRT_PROBES_H */
-
-/* Systemtap 1.2 headers have a bug where they cannot handle a
- * variable declared with array type.  Work around this by casting all
- * arguments.  This is some gross use of the preprocessor because
- * PROBE is a var-arg macro, but it is better than the alternative of
- * making all callers to PROBE have to be aware of the issues.  And
- * hopefully, if we ever add a call to PROBE with other than 9
- * end arguments, you can figure out the pattern to extend this hack.
- */
-#  define VIR_COUNT_ARGS(...) VIR_ARG11(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
-#  define VIR_ARG11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) _11
-#  define VIR_ADD_CAST_EXPAND(a, b, ...) VIR_ADD_CAST_PASTE(a, b, __VA_ARGS__)
-#  define VIR_ADD_CAST_PASTE(a, b, ...) a##b(__VA_ARGS__)
-
-/* The double cast is necessary to silence gcc warnings; any pointer
- * can safely go to intptr_t and back to void *, which collapses
- * arrays into pointers; while any integer can be widened to intptr_t
- * then cast to void *.  */
-#  define VIR_ADD_CAST(a) ((void *)(intptr_t)(a))
-#  define VIR_ADD_CAST1(a)                                  \
-    VIR_ADD_CAST(a)
-#  define VIR_ADD_CAST2(a, b)                               \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b)
-#  define VIR_ADD_CAST3(a, b, c)                            \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c)
-#  define VIR_ADD_CAST4(a, b, c, d)                         \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
-    VIR_ADD_CAST(d)
-#  define VIR_ADD_CAST5(a, b, c, d, e)                      \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
-    VIR_ADD_CAST(d), VIR_ADD_CAST(e)
-#  define VIR_ADD_CAST6(a, b, c, d, e, f)                   \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
-    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f)
-#  define VIR_ADD_CAST7(a, b, c, d, e, f, g)                \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
-    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f),      \
-    VIR_ADD_CAST(g)
-#  define VIR_ADD_CAST8(a, b, c, d, e, f, g, h)             \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
-    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f),      \
-    VIR_ADD_CAST(g), VIR_ADD_CAST(h)
-#  define VIR_ADD_CAST9(a, b, c, d, e, f, g, h, i)          \
-    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
-    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f),      \
-    VIR_ADD_CAST(g), VIR_ADD_CAST(h), VIR_ADD_CAST(i)
-
-#  define VIR_ADD_CASTS(...)                                            \
-    VIR_ADD_CAST_EXPAND(VIR_ADD_CAST, VIR_COUNT_ARGS(__VA_ARGS__),      \
-                        __VA_ARGS__)
-
-#  define PROBE_EXPAND(NAME, ARGS) NAME(ARGS)
-#  define PROBE(NAME, FMT, ...)                              \
-    VIR_DEBUG_INT(VIR_LOG_FROM_TRACE,                        \
-                  __FILE__, __LINE__, __func__,              \
-                  #NAME ": " FMT, __VA_ARGS__);              \
-    if (LIBVIRT_ ## NAME ## _ENABLED()) {                    \
-        PROBE_EXPAND(LIBVIRT_ ## NAME,                       \
-                     VIR_ADD_CASTS(__VA_ARGS__));            \
-    }
-# else
-#  define PROBE(NAME, FMT, ...)                              \
-    VIR_DEBUG_INT(VIR_LOG_FROM_TRACE,                        \
-                  __FILE__, __LINE__, __func__,              \
-                  #NAME ": " FMT, __VA_ARGS__);
-# endif
-
 /* Specific error values for use in forwarding programs such as
  * virt-login-shell; these values match what GNU env does.  */
 enum {
index b2af0aeb9c7e78f2b54841b0647fac75ee39983c..4c7e7f63b0689045c43b072bc18280a47a74f296 100644 (file)
@@ -40,6 +40,7 @@
 #include "virfile.h"
 #include "virprocess.h"
 #include "virobject.h"
+#include "virprobe.h"
 #include "virstring.h"
 
 #ifdef WITH_DTRACE_PROBES
index dbc04f68d2eea83cf589ed136d83f3531042a62c..05df42ac938a91270905c46fe6a0f1c573032e2f 100644 (file)
@@ -41,6 +41,7 @@
 #include "datatypes.h"
 #include "virerror.h"
 #include "virjson.h"
+#include "virprobe.h"
 #include "virstring.h"
 #include "cpu/cpu_x86.h"
 
index f4992f15f0d89c132af67b5ac6113268afb31c47..6610ba4ae06e33198c337df94bf764d0c2d70efe 100644 (file)
@@ -40,6 +40,7 @@
 #include "datatypes.h"
 #include "virerror.h"
 #include "virbuffer.h"
+#include "virprobe.h"
 #include "virstring.h"
 
 #ifdef WITH_DTRACE_PROBES
index 8ae5c6c24e07aece1a16d5302f2f9522fb6a202a..fcc43ad4a139d70899527bb80e58e399338766d5 100644 (file)
@@ -30,6 +30,7 @@
 #include "virnetsocket.h"
 #include "virkeepaliveprotocol.h"
 #include "virkeepalive.h"
+#include "virprobe.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
index 923332be8db1b73d0fe5d56158645c2000eea955..9e5ea7af00c9233c7d808d00226b4c4470f8067c 100644 (file)
@@ -36,6 +36,7 @@
 #include "virlog.h"
 #include "virutil.h"
 #include "virerror.h"
+#include "virprobe.h"
 #include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_RPC
index 52b494129458aa626a098936fb6f0c8f24f60f55..7b6d82d52143b32e855359352fcff1735dcb44bf 100644 (file)
@@ -35,6 +35,7 @@
 #include "viralloc.h"
 #include "virthread.h"
 #include "virkeepalive.h"
+#include "virprobe.h"
 #include "virstring.h"
 #include "virutil.h"
 
index 04bf25a06131ee509e7a999821484de320dac883..be1df6cde6acd496daf6b153be031aea1f659ad7 100644 (file)
@@ -51,6 +51,7 @@
 #include "virlog.h"
 #include "virfile.h"
 #include "virthread.h"
+#include "virprobe.h"
 #include "virprocess.h"
 #include "virstring.h"
 #include "passfd.h"
index cd69794a5aa69c8cb67d95332a9082a7a0701599..27a00d06d80113da652ce16456beb77dec1de9bd 100644 (file)
@@ -39,6 +39,7 @@
 #include "virfile.h"
 #include "virutil.h"
 #include "virlog.h"
+#include "virprobe.h"
 #include "virthread.h"
 #include "configmake.h"
 
index 8a4c8bc8d230831b689133bd189030994c819c2f..6f1e184163eec0dbddc586b33746197114d7fe05 100644 (file)
@@ -38,6 +38,7 @@
 #include "virutil.h"
 #include "virfile.h"
 #include "virerror.h"
+#include "virprobe.h"
 #include "virtime.h"
 
 #define EVENT_DEBUG(fmt, ...) VIR_DEBUG(fmt, __VA_ARGS__)
index 4f83bc1cb5aa2efd8b9e92ec08830ff3f7b6fb72..5e3ee719e142813a8377ff7cd5f98c6b92bff769 100644 (file)
@@ -28,6 +28,7 @@
 #include "viratomic.h"
 #include "virerror.h"
 #include "virlog.h"
+#include "virprobe.h"
 #include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/util/virprobe.h b/src/util/virprobe.h
new file mode 100644 (file)
index 0000000..3950e49
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * virprobe.h: dynamic operation tracing
+ *
+ * Copyright (C) 2006-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/>.
+ *
+ */
+
+#ifndef __VIR_PROBE_H__
+# define __VIR_PROBE_H__
+
+# include "internal.h"
+# include "virlog.h"
+
+# if WITH_DTRACE_PROBES
+#  ifndef LIBVIRT_PROBES_H
+#   define LIBVIRT_PROBES_H
+#   include "libvirt_probes.h"
+#  endif /* LIBVIRT_PROBES_H */
+
+/* Systemtap 1.2 headers have a bug where they cannot handle a
+ * variable declared with array type.  Work around this by casting all
+ * arguments.  This is some gross use of the preprocessor because
+ * PROBE is a var-arg macro, but it is better than the alternative of
+ * making all callers to PROBE have to be aware of the issues.  And
+ * hopefully, if we ever add a call to PROBE with other than 9
+ * end arguments, you can figure out the pattern to extend this hack.
+ */
+#  define VIR_COUNT_ARGS(...) VIR_ARG11(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
+#  define VIR_ARG11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) _11
+#  define VIR_ADD_CAST_EXPAND(a, b, ...) VIR_ADD_CAST_PASTE(a, b, __VA_ARGS__)
+#  define VIR_ADD_CAST_PASTE(a, b, ...) a##b(__VA_ARGS__)
+
+/* The double cast is necessary to silence gcc warnings; any pointer
+ * can safely go to intptr_t and back to void *, which collapses
+ * arrays into pointers; while any integer can be widened to intptr_t
+ * then cast to void *.  */
+#  define VIR_ADD_CAST(a) ((void *)(intptr_t)(a))
+#  define VIR_ADD_CAST1(a)                                  \
+    VIR_ADD_CAST(a)
+#  define VIR_ADD_CAST2(a, b)                               \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b)
+#  define VIR_ADD_CAST3(a, b, c)                            \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c)
+#  define VIR_ADD_CAST4(a, b, c, d)                         \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
+    VIR_ADD_CAST(d)
+#  define VIR_ADD_CAST5(a, b, c, d, e)                      \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
+    VIR_ADD_CAST(d), VIR_ADD_CAST(e)
+#  define VIR_ADD_CAST6(a, b, c, d, e, f)                   \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
+    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f)
+#  define VIR_ADD_CAST7(a, b, c, d, e, f, g)                \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
+    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f),      \
+    VIR_ADD_CAST(g)
+#  define VIR_ADD_CAST8(a, b, c, d, e, f, g, h)             \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
+    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f),      \
+    VIR_ADD_CAST(g), VIR_ADD_CAST(h)
+#  define VIR_ADD_CAST9(a, b, c, d, e, f, g, h, i)          \
+    VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c),      \
+    VIR_ADD_CAST(d), VIR_ADD_CAST(e), VIR_ADD_CAST(f),      \
+    VIR_ADD_CAST(g), VIR_ADD_CAST(h), VIR_ADD_CAST(i)
+
+#  define VIR_ADD_CASTS(...)                                            \
+    VIR_ADD_CAST_EXPAND(VIR_ADD_CAST, VIR_COUNT_ARGS(__VA_ARGS__),      \
+                        __VA_ARGS__)
+
+#  define PROBE_EXPAND(NAME, ARGS) NAME(ARGS)
+#  define PROBE(NAME, FMT, ...)                              \
+    VIR_DEBUG_INT(VIR_LOG_FROM_TRACE,                        \
+                  NULL, __LINE__, __func__,                  \
+                  #NAME ": " FMT, __VA_ARGS__);              \
+    if (LIBVIRT_ ## NAME ## _ENABLED()) {                    \
+        PROBE_EXPAND(LIBVIRT_ ## NAME,                       \
+                     VIR_ADD_CASTS(__VA_ARGS__));            \
+    }
+# else
+#  define PROBE(NAME, FMT, ...)                              \
+    VIR_DEBUG_INT(VIR_LOG_FROM_TRACE,                        \
+                  NULL, __LINE__, __func__,                  \
+                  #NAME ": " FMT, __VA_ARGS__);
+# endif
+
+#endif /* __VIR_PROBE_H__ */