[PATCH] Fix generation of systemtap probes for RPC protocols

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The naming used in the RPC protocols for the LXC monitor and
lock daemon confused the script used to generate systemtap
helper functions. Rename the LXC monitor protocol symbols to
reduce confusion. Adapt the gensystemtap.pl script to cope
with the LXC monitor / lock daemon naming conversions.

This has no functional impact on RPC wire protocol, since
names are only used in the C layer

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/Makefile.am                |  8 +++++---
 src/lxc/lxc_controller.c       | 26 +++++++++++++-------------
 src/lxc/lxc_monitor.c          | 26 +++++++++++++-------------
 src/lxc/lxc_monitor.h          |  2 +-
 src/lxc/lxc_monitor_protocol.x | 24 ++++++++++++------------
 src/lxc/lxc_process.c          |  8 ++++----
 src/rpc/gensystemtap.pl        |  6 +++---
 7 files changed, 51 insertions(+), 49 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index a6cc839..0c0dfb3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -460,12 +460,12 @@ LXC_MONITOR_PROTOCOL = $(srcdir)/lxc/lxc_monitor_protocol.x
 $(srcdir)/lxc/lxc_monitor_dispatch.h: $(srcdir)/rpc/gendispatch.pl \
 		$(LXC_MONITOR_PROTOCOL)
 	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \
-	  -k virLXCProtocol VIR_LXC_MONITOR_PROTOCOL $(LXC_MONITOR_PROTOCOL) > $@
+	  -k virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@
 
 $(srcdir)/lxc/lxc_controller_dispatch.h: $(srcdir)/rpc/gendispatch.pl \
 		$(REMOTE_PROTOCOL)
 	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl \
-	  -b virLXCProtocol VIR_LXC_MONITOR_PROTOCOL $(LXC_MONITOR_PROTOCOL) > $@
+	  -b virLXCMonitor VIR_LXC_MONITOR $(LXC_MONITOR_PROTOCOL) > $@
 
 EXTRA_DIST += \
 	$(LXC_MONITOR_PROTOCOL) \
@@ -1591,7 +1591,9 @@ RPC_PROBE_FILES = $(srcdir)/rpc/virnetprotocol.x \
 		  $(srcdir)/rpc/virkeepaliveprotocol.x \
 		  $(srcdir)/remote/remote_protocol.x \
 		  $(srcdir)/remote/lxc_protocol.x \
-		  $(srcdir)/remote/qemu_protocol.x
+		  $(srcdir)/remote/qemu_protocol.x \
+		  $(srcdir)/lxc/lxc_monitor_protocol.x \
+		  $(srcdir)/locking/lock_protocol.x
 
 libvirt_functions.stp: $(RPC_PROBE_FILES) $(srcdir)/rpc/gensystemtap.pl
 	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gensystemtap.pl $(RPC_PROBE_FILES) > $@
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 5e422ad..becf811 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -713,10 +713,10 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
     virObjectUnref(svc);
     svc = NULL;
 
-    if (!(ctrl->prog = virNetServerProgramNew(VIR_LXC_PROTOCOL_PROGRAM,
-                                              VIR_LXC_PROTOCOL_PROGRAM_VERSION,
-                                              virLXCProtocolProcs,
-                                              virLXCProtocolNProcs)))
+    if (!(ctrl->prog = virNetServerProgramNew(VIR_LXC_MONITOR_PROGRAM,
+                                              VIR_LXC_MONITOR_PROGRAM_VERSION,
+                                              virLXCMonitorProcs,
+                                              virLXCMonitorNProcs)))
         goto error;
 
     virNetServerUpdateServices(ctrl->server, true);
@@ -1415,25 +1415,25 @@ static int
 virLXCControllerEventSendExit(virLXCControllerPtr ctrl,
                               int exitstatus)
 {
-    virLXCProtocolExitEventMsg msg;
+    virLXCMonitorExitEventMsg msg;
 
     VIR_DEBUG("Exit status %d (client=%p)", exitstatus, ctrl->client);
     memset(&msg, 0, sizeof(msg));
     switch (exitstatus) {
     case 0:
-        msg.status = VIR_LXC_PROTOCOL_EXIT_STATUS_SHUTDOWN;
+        msg.status = VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN;
         break;
     case 1:
-        msg.status = VIR_LXC_PROTOCOL_EXIT_STATUS_REBOOT;
+        msg.status = VIR_LXC_MONITOR_EXIT_STATUS_REBOOT;
         break;
     default:
-        msg.status = VIR_LXC_PROTOCOL_EXIT_STATUS_ERROR;
+        msg.status = VIR_LXC_MONITOR_EXIT_STATUS_ERROR;
         break;
     }
 
     virLXCControllerEventSend(ctrl,
-                              VIR_LXC_PROTOCOL_PROC_EXIT_EVENT,
-                              (xdrproc_t)xdr_virLXCProtocolExitEventMsg,
+                              VIR_LXC_MONITOR_PROC_EXIT_EVENT,
+                              (xdrproc_t)xdr_virLXCMonitorExitEventMsg,
                               (void*)&msg);
 
     if (ctrl->client) {
@@ -1451,15 +1451,15 @@ static int
 virLXCControllerEventSendInit(virLXCControllerPtr ctrl,
                               pid_t initpid)
 {
-    virLXCProtocolInitEventMsg msg;
+    virLXCMonitorInitEventMsg msg;
 
     VIR_DEBUG("Init pid %llu", (unsigned long long)initpid);
     memset(&msg, 0, sizeof(msg));
     msg.initpid = initpid;
 
     virLXCControllerEventSend(ctrl,
-                              VIR_LXC_PROTOCOL_PROC_INIT_EVENT,
-                              (xdrproc_t)xdr_virLXCProtocolInitEventMsg,
+                              VIR_LXC_MONITOR_PROC_INIT_EVENT,
+                              (xdrproc_t)xdr_virLXCMonitorInitEventMsg,
                               (void*)&msg);
     return 0;
 }
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index e3901f8..6d11eda 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -68,15 +68,15 @@ virLXCMonitorHandleEventInit(virNetClientProgramPtr prog,
                              virNetClientPtr client,
                              void *evdata, void *opaque);
 
-static virNetClientProgramEvent virLXCProtocolEvents[] = {
-    { VIR_LXC_PROTOCOL_PROC_EXIT_EVENT,
+static virNetClientProgramEvent virLXCMonitorEvents[] = {
+    { VIR_LXC_MONITOR_PROC_EXIT_EVENT,
       virLXCMonitorHandleEventExit,
-      sizeof(virLXCProtocolExitEventMsg),
-      (xdrproc_t)xdr_virLXCProtocolExitEventMsg },
-    { VIR_LXC_PROTOCOL_PROC_INIT_EVENT,
+      sizeof(virLXCMonitorExitEventMsg),
+      (xdrproc_t)xdr_virLXCMonitorExitEventMsg },
+    { VIR_LXC_MONITOR_PROC_INIT_EVENT,
       virLXCMonitorHandleEventInit,
-      sizeof(virLXCProtocolInitEventMsg),
-      (xdrproc_t)xdr_virLXCProtocolInitEventMsg },
+      sizeof(virLXCMonitorInitEventMsg),
+      (xdrproc_t)xdr_virLXCMonitorInitEventMsg },
 };
 
 
@@ -86,7 +86,7 @@ virLXCMonitorHandleEventExit(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
                              void *evdata, void *opaque)
 {
     virLXCMonitorPtr mon = opaque;
-    virLXCProtocolExitEventMsg *msg = evdata;
+    virLXCMonitorExitEventMsg *msg = evdata;
 
     VIR_DEBUG("Event exit %d", msg->status);
     if (mon->cb.exitNotify)
@@ -100,7 +100,7 @@ virLXCMonitorHandleEventInit(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
                              void *evdata, void *opaque)
 {
     virLXCMonitorPtr mon = opaque;
-    virLXCProtocolInitEventMsg *msg = evdata;
+    virLXCMonitorInitEventMsg *msg = evdata;
 
     VIR_DEBUG("Event init %llu",
               (unsigned long long)msg->initpid);
@@ -162,10 +162,10 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
     if (virNetClientRegisterAsyncIO(mon->client) < 0)
         goto error;
 
-    if (!(mon->program = virNetClientProgramNew(VIR_LXC_PROTOCOL_PROGRAM,
-                                                VIR_LXC_PROTOCOL_PROGRAM_VERSION,
-                                                virLXCProtocolEvents,
-                                                ARRAY_CARDINALITY(virLXCProtocolEvents),
+    if (!(mon->program = virNetClientProgramNew(VIR_LXC_MONITOR_PROGRAM,
+                                                VIR_LXC_MONITOR_PROGRAM_VERSION,
+                                                virLXCMonitorEvents,
+                                                ARRAY_CARDINALITY(virLXCMonitorEvents),
                                                 mon)))
         goto error;
 
diff --git a/src/lxc/lxc_monitor.h b/src/lxc/lxc_monitor.h
index cc31a9c..a0d6f37 100644
--- a/src/lxc/lxc_monitor.h
+++ b/src/lxc/lxc_monitor.h
@@ -37,7 +37,7 @@ typedef void (*virLXCMonitorCallbackEOFNotify)(virLXCMonitorPtr mon,
                                                virDomainObjPtr vm);
 
 typedef void (*virLXCMonitorCallbackExitNotify)(virLXCMonitorPtr mon,
-                                                virLXCProtocolExitStatus status,
+                                                virLXCMonitorExitStatus status,
                                                 virDomainObjPtr vm);
 
 typedef void (*virLXCMonitorCallbackInitNotify)(virLXCMonitorPtr mon,
diff --git a/src/lxc/lxc_monitor_protocol.x b/src/lxc/lxc_monitor_protocol.x
index 0f041f6..0926e26 100644
--- a/src/lxc/lxc_monitor_protocol.x
+++ b/src/lxc/lxc_monitor_protocol.x
@@ -4,24 +4,24 @@
  * the libvirt_lxc helper program.
  */
 
-enum virLXCProtocolExitStatus {
-    VIR_LXC_PROTOCOL_EXIT_STATUS_ERROR,
-    VIR_LXC_PROTOCOL_EXIT_STATUS_SHUTDOWN,
-    VIR_LXC_PROTOCOL_EXIT_STATUS_REBOOT
+enum virLXCMonitorExitStatus {
+    VIR_LXC_MONITOR_EXIT_STATUS_ERROR,
+    VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN,
+    VIR_LXC_MONITOR_EXIT_STATUS_REBOOT
 };
 
-struct virLXCProtocolExitEventMsg {
-    enum virLXCProtocolExitStatus status;
+struct virLXCMonitorExitEventMsg {
+    enum virLXCMonitorExitStatus status;
 };
 
-struct virLXCProtocolInitEventMsg {
+struct virLXCMonitorInitEventMsg {
     unsigned hyper initpid;
 };
 
-const VIR_LXC_PROTOCOL_PROGRAM = 0x12341234;
-const VIR_LXC_PROTOCOL_PROGRAM_VERSION = 1;
+const VIR_LXC_MONITOR_PROGRAM = 0x12341234;
+const VIR_LXC_MONITOR_PROGRAM_VERSION = 1;
 
-enum virLXCProtocolProcedure {
-    VIR_LXC_PROTOCOL_PROC_EXIT_EVENT = 1, /* skipgen skipgen */
-    VIR_LXC_PROTOCOL_PROC_INIT_EVENT = 2 /* skipgen skipgen */
+enum virLXCMonitorProcedure {
+    VIR_LXC_MONITOR_PROC_EXIT_EVENT = 1, /* skipgen skipgen */
+    VIR_LXC_MONITOR_PROC_INIT_EVENT = 2 /* skipgen skipgen */
 };
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 942d375..670a032 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -607,19 +607,19 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
 }
 
 static void virLXCProcessMonitorExitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED,
-                                           virLXCProtocolExitStatus status,
+                                           virLXCMonitorExitStatus status,
                                            virDomainObjPtr vm)
 {
     virLXCDomainObjPrivatePtr priv = vm->privateData;
 
     switch (status) {
-    case VIR_LXC_PROTOCOL_EXIT_STATUS_SHUTDOWN:
+    case VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN:
         priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
         break;
-    case VIR_LXC_PROTOCOL_EXIT_STATUS_ERROR:
+    case VIR_LXC_MONITOR_EXIT_STATUS_ERROR:
         priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_FAILED;
         break;
-    case VIR_LXC_PROTOCOL_EXIT_STATUS_REBOOT:
+    case VIR_LXC_MONITOR_EXIT_STATUS_REBOOT:
         priv->stopReason = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
         priv->wantReboot = true;
         break;
diff --git a/src/rpc/gensystemtap.pl b/src/rpc/gensystemtap.pl
index a16fa00..2467300 100755
--- a/src/rpc/gensystemtap.pl
+++ b/src/rpc/gensystemtap.pl
@@ -57,11 +57,11 @@ while (<>) {
             $auth{$2} = lc $1;
         }
     } else {
-        if (/(\w+)_PROGRAM\s*=\s*0x([a-fA-F0-9]+)\s*;/) {
+        if (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROGRAM\s*=\s*0x([a-fA-F0-9]+)\s*;/) {
             $funcs{lc $1} = { id => hex($2), version => undef, progs => [] };
-        } elsif (/(\w+)_PROTOCOL_VERSION\s*=\s*(\d+)\s*;/) {
+        } elsif (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_(?:PROGRAM|PROTOCOL)_VERSION\s*=\s*(\d+)\s*;/) {
             $funcs{lc $1}->{version} = $2;
-        } elsif (/(\w+)_PROC_(.*?)\s+=\s+(\d+)/) {
+        } elsif (/(?:VIR_)?(\w+?)(?:_PROTOCOL)?_PROC_(.*?)\s+=\s+(\d+)/) {
             $funcs{lc $1}->{progs}->[$3] = lc $2;
         }
     }
-- 
1.8.1.4

--
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]