提交 a9f6b8fc 编写于 作者: L Lin Ma 提交者: Michal Privoznik

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: NLin Ma <lma@suse.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 cac6d413
...@@ -773,18 +773,12 @@ virshNodeDeviceEventToString(int event) ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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)
......
...@@ -28,6 +28,14 @@ ...@@ -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 */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册