mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virsh-secret: Rename vshEventCallback to virshSecretEventCallback
The next patch will use it in virsh-completer.c for returning the name list of secret events. The patch code originally authored by Michal Privoznik, Please refer to https://www.redhat.com/archives/libvir-list/2018-May/msg01022.html I splitted it to 2 patches with tiny change. Signed-off-by: Lin Ma <lma@suse.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
4c5154677a
commit
bee2331f2b
@ -571,18 +571,12 @@ virshSecretEventToString(int event)
|
|||||||
return str ? _(str) : _("unknown");
|
return str ? _(str) : _("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vshEventCallback {
|
|
||||||
const char *name;
|
|
||||||
virConnectSecretEventGenericCallback cb;
|
|
||||||
};
|
|
||||||
typedef struct vshEventCallback vshEventCallback;
|
|
||||||
|
|
||||||
struct virshSecretEventData {
|
struct virshSecretEventData {
|
||||||
vshControl *ctl;
|
vshControl *ctl;
|
||||||
bool loop;
|
bool loop;
|
||||||
bool timestamp;
|
bool timestamp;
|
||||||
int count;
|
int count;
|
||||||
vshEventCallback *cb;
|
virshSecretEventCallback *cb;
|
||||||
};
|
};
|
||||||
typedef struct virshSecretEventData virshSecretEventData;
|
typedef struct virshSecretEventData virshSecretEventData;
|
||||||
|
|
||||||
@ -652,11 +646,12 @@ vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
vshEventDone(data->ctl);
|
vshEventDone(data->ctl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static vshEventCallback vshEventCallbacks[] = {
|
virshSecretEventCallback virshSecretEventCallbacks[] = {
|
||||||
{ "lifecycle",
|
{ "lifecycle",
|
||||||
VIR_SECRET_EVENT_CALLBACK(vshEventLifecyclePrint), },
|
VIR_SECRET_EVENT_CALLBACK(vshEventLifecyclePrint), },
|
||||||
{ "value-changed", vshEventGenericPrint, },
|
{ "value-changed", vshEventGenericPrint, },
|
||||||
};
|
};
|
||||||
|
verify(VIR_SECRET_EVENT_ID_LAST == ARRAY_CARDINALITY(virshSecretEventCallbacks));
|
||||||
|
|
||||||
static const vshCmdInfo info_secret_event[] = {
|
static const vshCmdInfo info_secret_event[] = {
|
||||||
{.name = "help",
|
{.name = "help",
|
||||||
@ -713,7 +708,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++)
|
for (i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++)
|
||||||
vshPrint(ctl, "%s\n", vshEventCallbacks[i].name);
|
vshPrint(ctl, "%s\n", virshSecretEventCallbacks[i].name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +719,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (event = 0; event < VIR_SECRET_EVENT_ID_LAST; event++)
|
for (event = 0; event < VIR_SECRET_EVENT_ID_LAST; event++)
|
||||||
if (STREQ(eventName, vshEventCallbacks[event].name))
|
if (STREQ(eventName, virshSecretEventCallbacks[event].name))
|
||||||
break;
|
break;
|
||||||
if (event == VIR_SECRET_EVENT_ID_LAST) {
|
if (event == VIR_SECRET_EVENT_ID_LAST) {
|
||||||
vshError(ctl, _("unknown event type %s"), eventName);
|
vshError(ctl, _("unknown event type %s"), eventName);
|
||||||
@ -735,7 +730,7 @@ cmdSecretEvent(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 = &virshSecretEventCallbacks[event];
|
||||||
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -28,6 +28,14 @@
|
|||||||
|
|
||||||
# include "virsh.h"
|
# include "virsh.h"
|
||||||
|
|
||||||
|
struct virshSecretEventCallback {
|
||||||
|
const char *name;
|
||||||
|
virConnectSecretEventGenericCallback cb;
|
||||||
|
};
|
||||||
|
typedef struct virshSecretEventCallback virshSecretEventCallback;
|
||||||
|
|
||||||
|
extern virshSecretEventCallback virshSecretEventCallbacks[];
|
||||||
|
|
||||||
extern const vshCmdDef secretCmds[];
|
extern const vshCmdDef secretCmds[];
|
||||||
|
|
||||||
#endif /* VIRSH_SECRET_H */
|
#endif /* VIRSH_SECRET_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user