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 <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Lin Ma 2018-05-23 14:32:45 +08:00 committed by Michal Privoznik
parent cac6d413f9
commit a9f6b8fc8c
2 changed files with 14 additions and 12 deletions

View File

@ -773,18 +773,12 @@ virshNodeDeviceEventToString(int event)
return str ? _(str) : _("unknown"); return str ? _(str) : _("unknown");
} }
struct vshEventCallback {
const char *name;
virConnectNodeDeviceEventGenericCallback cb;
};
typedef struct vshEventCallback vshEventCallback;
struct virshNodeDeviceEventData { struct virshNodeDeviceEventData {
vshControl *ctl; vshControl *ctl;
bool loop; bool loop;
bool timestamp; bool timestamp;
int count; int count;
vshEventCallback *cb; virshNodedevEventCallback *cb;
}; };
typedef struct virshNodeDeviceEventData virshNodeDeviceEventData; typedef struct virshNodeDeviceEventData virshNodeDeviceEventData;
@ -850,12 +844,12 @@ vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
vshEventDone(data->ctl); vshEventDone(data->ctl);
} }
static vshEventCallback vshEventCallbacks[] = { virshNodedevEventCallback virshNodedevEventCallbacks[] = {
{ "lifecycle", { "lifecycle",
VIR_NODE_DEVICE_EVENT_CALLBACK(vshEventLifecyclePrint), }, VIR_NODE_DEVICE_EVENT_CALLBACK(vshEventLifecyclePrint), },
{ "update", vshEventGenericPrint, } { "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[] = { static const vshCmdInfo info_node_device_event[] = {
@ -914,7 +908,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
size_t i; size_t i;
for (i = 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; 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; return true;
} }
@ -926,7 +920,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
} }
for (event = 0; event < VIR_NODE_DEVICE_EVENT_ID_LAST; event++) for (event = 0; event < VIR_NODE_DEVICE_EVENT_ID_LAST; event++)
if (STREQ(eventName, vshEventCallbacks[event].name)) if (STREQ(eventName, virshNodedevEventCallbacks[event].name))
break; break;
if (event == VIR_NODE_DEVICE_EVENT_ID_LAST) { if (event == VIR_NODE_DEVICE_EVENT_ID_LAST) {
vshError(ctl, _("unknown event type %s"), eventName); vshError(ctl, _("unknown event type %s"), eventName);
@ -937,7 +931,7 @@ cmdNodeDeviceEvent(vshControl *ctl, const vshCmd *cmd)
data.loop = vshCommandOptBool(cmd, "loop"); data.loop = vshCommandOptBool(cmd, "loop");
data.timestamp = vshCommandOptBool(cmd, "timestamp"); data.timestamp = vshCommandOptBool(cmd, "timestamp");
data.count = 0; data.count = 0;
data.cb = &vshEventCallbacks[event]; data.cb = &virshNodedevEventCallbacks[event];
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
return false; return false;
if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0) if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)

View File

@ -28,6 +28,14 @@
# include "virsh.h" # include "virsh.h"
struct virshNodedevEventCallback {
const char *name;
virConnectNodeDeviceEventGenericCallback cb;
};
typedef struct virshNodedevEventCallback virshNodedevEventCallback;
extern virshNodedevEventCallback virshNodedevEventCallbacks[];
extern const vshCmdDef nodedevCmds[]; extern const vshCmdDef nodedevCmds[];
#endif /* VIRSH_NODEDEV_H */ #endif /* VIRSH_NODEDEV_H */