From 05642e8bd1b92c07425c2a22d65a7c26b19a2235 Mon Sep 17 00:00:00 2001 From: Lin Ma Date: Wed, 23 May 2018 14:32:41 +0800 Subject: [PATCH] virsh: Move vshEventCallback structure definition to virsh-domain.h The next patch will use it in virsh-completer.c for returning the strings of domain event name. At the same time, rename it to avoid possible name clashing. Signed-off-by: Lin Ma Signed-off-by: Michal Privoznik --- tools/virsh-domain.c | 20 +++++++------------- tools/virsh-domain.h | 8 ++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index cfbbf5a7bc..202b7406e2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12832,18 +12832,12 @@ virshDomainEventTrayChangeToString(int reason) return str ? _(str) : _("unknown"); } -struct vshEventCallback { - const char *name; - virConnectDomainEventGenericCallback cb; -}; -typedef struct vshEventCallback vshEventCallback; - struct virshDomEventData { vshControl *ctl; bool loop; int *count; bool timestamp; - vshEventCallback *cb; + virshDomainEventCallback *cb; int id; }; typedef struct virshDomEventData virshDomEventData; @@ -13278,7 +13272,7 @@ virshEventBlockThresholdPrint(virConnectPtr conn ATTRIBUTE_UNUSED, } -static vshEventCallback vshEventCallbacks[] = { +virshDomainEventCallback virshDomainEventCallbacks[] = { { "lifecycle", VIR_DOMAIN_EVENT_CALLBACK(virshEventLifecyclePrint), }, { "reboot", virshEventGenericPrint, }, @@ -13328,7 +13322,7 @@ static vshEventCallback vshEventCallbacks[] = { { "block-threshold", VIR_DOMAIN_EVENT_CALLBACK(virshEventBlockThresholdPrint), }, }; -verify(VIR_DOMAIN_EVENT_ID_LAST == ARRAY_CARDINALITY(vshEventCallbacks)); +verify(VIR_DOMAIN_EVENT_ID_LAST == ARRAY_CARDINALITY(virshDomainEventCallbacks)); static const vshCmdInfo info_event[] = { {.name = "help", @@ -13388,7 +13382,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "list")) { for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++) - vshPrint(ctl, "%s\n", vshEventCallbacks[event].name); + vshPrint(ctl, "%s\n", virshDomainEventCallbacks[event].name); return true; } @@ -13396,7 +13390,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) return false; if (eventName) { for (event = 0; event < VIR_DOMAIN_EVENT_ID_LAST; event++) - if (STREQ(eventName, vshEventCallbacks[event].name)) + if (STREQ(eventName, virshDomainEventCallbacks[event].name)) break; if (event == VIR_DOMAIN_EVENT_ID_LAST) { vshError(ctl, _("unknown event type %s"), eventName); @@ -13416,7 +13410,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) data[i].loop = loop; data[i].count = &count; data[i].timestamp = timestamp; - data[i].cb = &vshEventCallbacks[i]; + data[i].cb = &virshDomainEventCallbacks[i]; data[i].id = -1; } } else { @@ -13426,7 +13420,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) data[0].loop = vshCommandOptBool(cmd, "loop"); data[0].count = &count; data[0].timestamp = timestamp; - data[0].cb = &vshEventCallbacks[event]; + data[0].cb = &virshDomainEventCallbacks[event]; data[0].id = -1; } if (vshCommandOptTimeoutToMs(ctl, cmd, &timeout) < 0) diff --git a/tools/virsh-domain.h b/tools/virsh-domain.h index 3f9d12a5ff..d4407c6a77 100644 --- a/tools/virsh-domain.h +++ b/tools/virsh-domain.h @@ -28,6 +28,14 @@ # include "virsh.h" +struct virshDomainEventCallback { + const char *name; + virConnectDomainEventGenericCallback cb; +}; +typedef struct virshDomainEventCallback virshDomainEventCallback; + +extern virshDomainEventCallback virshDomainEventCallbacks[]; + extern const vshCmdDef domManagementCmds[]; #endif /* VIRSH_DOMAIN_H */