The next patch will use it in virsh-completer.c for returning the name
list of nodedev events.
Signed-off-by: Lin Ma <lma(a)suse.com>
---
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..66cf46c22f 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;
+ vshNodedevEventCallback *cb;
};
typedef struct virshNodeDeviceEventData virshNodeDeviceEventData;
@@ -850,12 +844,12 @@ vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
vshEventDone(data->ctl);
}
-static vshEventCallback vshEventCallbacks[] = {
+vshNodedevEventCallback vshNodedevEventCallbacks[] = {
{ "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(vshNodedevEventCallbacks));
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", vshNodedevEventCallbacks[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, vshNodedevEventCallbacks[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 = &vshNodedevEventCallbacks[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..931beb982d 100644
--- a/tools/virsh-nodedev.h
+++ b/tools/virsh-nodedev.h
@@ -28,6 +28,14 @@
# include "virsh.h"
+struct vshNodedevEventCallback {
+ const char *name;
+ virConnectNodeDeviceEventGenericCallback cb;
+};
+typedef struct vshNodedevEventCallback vshNodedevEventCallback;
+
+extern vshNodedevEventCallback vshNodedevEventCallbacks[];
+
extern const vshCmdDef nodedevCmds[];
#endif /* VIRSH_NODEDEV_H */
--
2.16.2