Fix generation of systemtap probes for RPC protocols

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@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-03-13 19:19:22 +00:00
parent ad9ea4a9fd
commit 403594eb8c
7 changed files with 51 additions and 49 deletions

View File

@ -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) > $@

View File

@ -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;
}

View File

@ -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;

View File

@ -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,

View File

@ -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 */
};

View File

@ -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;

View File

@ -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;
}
}