From a9f6b8fc8c58c7f2257d991cb04b07cb8d0fb048 Mon Sep 17 00:00:00 2001 From: Lin Ma Date: Wed, 23 May 2018 14:32:45 +0800 Subject: [PATCH] virsh-nodedev: Rename and move vshEventCallback to virshNodedevEventCallback The next patch will use it in virsh-completer.c for returning the name list of nodedev events. Signed-off-by: Lin Ma Signed-off-by: Michal Privoznik --- tools/virsh-nodedev.c | 18 ++++++------------ tools/virsh-nodedev.h | 8 ++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index d25fe0e09b..b26cd5cec9 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -773,18 +773,12 @@ virshNodeDeviceEventToString(int event) return str ? _(str) : _("unknown"); } -struct vshEventCallback { - const char *name; - virConnectNodeDeviceEventGenericCallback cb; -}; -typedef struct vshEventCallback vshEventCallback; - struct virshNodeDeviceEventData { vshControl *ctl; bool loop; bool timestamp; int count; - vshEventCallback *cb; + virshNodedevEventCallback *cb; }; typedef struct virshNodeDeviceEventData virshNodeDeviceEventData; @@ -850,12 +844,12 @@ vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED, vshEventDone(data->ctl); } -static vshEventCallback vshEventCallbacks[] = { +virshNodedevEventCallback virshNodedevEventCallbacks[] = { { "lifecycle", VIR_NODE_DEVICE_EVENT_CALLBACK(vshEventLifecyclePrint), }, { "update", vshEventGenericPrint, } }; -verify(VIR_NODE_DEVICE_EVENT_ID_LAST == ARRAY_CARDINALITY(vshEventCallbacks)); +verify(VIR_NODE_DEVICE_EVENT_ID_LAST == ARRAY_CARDINALITY(virshNodedevEventCallbacks)); static const vshCmdInfo info_node_device_event[] = { @@ -914,7 +908,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) size_t i; for (i = 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) - vshPrint(ctl, "%s\n", vshEventCallbacks[i].name); + vshPrint(ctl, "%s\n", virshNodedevEventCallbacks[i].name); return true; } @@ -926,7 +920,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) } for (event = 0; event < VIR_NODE_DEVICE_EVENT_ID_LAST; event++) - if (STREQ(eventName, vshEventCallbacks[event].name)) + if (STREQ(eventName, virshNodedevEventCallbacks[event].name)) break; if (event == VIR_NODE_DEVICE_EVENT_ID_LAST) { vshError(ctl, _("unknown event type %s"), eventName); @@ -937,7 +931,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd) data.loop = vshCommandOptBool(cmd, "loop"); data.timestamp = vshCommandOptBool(cmd, "timestamp"); data.count = 0; - data.cb = &vshEventCallbacks[event]; + data.cb = &virshNodedevEventCallbacks[event]; if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) return false; if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) diff --git a/tools/virsh-nodedev.h b/tools/virsh-nodedev.h index c64f7df83c..d32ca39c52 100644 --- a/tools/virsh-nodedev.h +++ b/tools/virsh-nodedev.h @@ -28,6 +28,14 @@ # include "virsh.h" +struct virshNodedevEventCallback { + const char *name; + virConnectNodeDeviceEventGenericCallback cb; +}; +typedef struct virshNodedevEventCallback virshNodedevEventCallback; + +extern virshNodedevEventCallback virshNodedevEventCallbacks[]; + extern const vshCmdDef nodedevCmds[]; #endif /* VIRSH_NODEDEV_H */ -- GitLab