mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
cac6d413f9
commit
a9f6b8fc8c
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue