Re: [libvirt] [ [PATCH v3 1/8] virsh-secret: Rename vshEventCallback to vshSecretEventCallback

2018-05-24 Thread Michal Privoznik
On 05/23/2018 08:32 AM, Lin Ma wrote:
> 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 
> ---
>  tools/virsh-secret.c | 17 ++---
>  tools/virsh-secret.h |  8 
>  2 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
> index 9e4ec61a88..07bc54d1bf 100644
> --- a/tools/virsh-secret.c
> +++ b/tools/virsh-secret.c
> @@ -571,18 +571,12 @@ virshSecretEventToString(int event)
>  return str ? _(str) : _("unknown");
>  }
>  
> -struct vshEventCallback {
> -const char *name;
> -virConnectSecretEventGenericCallback cb;
> -};
> -typedef struct vshEventCallback vshEventCallback;
> -
>  struct virshSecretEventData {
>  vshControl *ctl;
>  bool loop;
>  bool timestamp;
>  int count;
> -vshEventCallback *cb;
> +vshSecretEventCallback *cb;
>  };
>  typedef struct virshSecretEventData virshSecretEventData;
>  
> @@ -652,11 +646,12 @@ vshEventGenericPrint(virConnectPtr conn 
> ATTRIBUTE_UNUSED,
>  vshEventDone(data->ctl);
>  }
>  
> -static vshEventCallback vshEventCallbacks[] = {
> +vshSecretEventCallback vshSecretEventCallbacks[] = {

Since you're renaming this, it should be virshSecret... because it's
related to virsh, not vsh.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [ [PATCH v3 1/8] virsh-secret: Rename vshEventCallback to vshSecretEventCallback

2018-05-23 Thread Lin Ma
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 
---
 tools/virsh-secret.c | 17 ++---
 tools/virsh-secret.h |  8 
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 9e4ec61a88..07bc54d1bf 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -571,18 +571,12 @@ virshSecretEventToString(int event)
 return str ? _(str) : _("unknown");
 }
 
-struct vshEventCallback {
-const char *name;
-virConnectSecretEventGenericCallback cb;
-};
-typedef struct vshEventCallback vshEventCallback;
-
 struct virshSecretEventData {
 vshControl *ctl;
 bool loop;
 bool timestamp;
 int count;
-vshEventCallback *cb;
+vshSecretEventCallback *cb;
 };
 typedef struct virshSecretEventData virshSecretEventData;
 
@@ -652,11 +646,12 @@ vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
 vshEventDone(data->ctl);
 }
 
-static vshEventCallback vshEventCallbacks[] = {
+vshSecretEventCallback vshSecretEventCallbacks[] = {
 { "lifecycle",
   VIR_SECRET_EVENT_CALLBACK(vshEventLifecyclePrint), },
 { "value-changed", vshEventGenericPrint, },
 };
+verify(VIR_SECRET_EVENT_ID_LAST == ARRAY_CARDINALITY(vshSecretEventCallbacks));
 
 static const vshCmdInfo info_secret_event[] = {
 {.name = "help",
@@ -713,7 +708,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
 size_t i;
 
 for (i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++)
-vshPrint(ctl, "%s\n", vshEventCallbacks[i].name);
+vshPrint(ctl, "%s\n", vshSecretEventCallbacks[i].name);
 return true;
 }
 
@@ -724,7 +719,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
 return false;
 }
 for (event = 0; event < VIR_SECRET_EVENT_ID_LAST; event++)
-if (STREQ(eventName, vshEventCallbacks[event].name))
+if (STREQ(eventName, vshSecretEventCallbacks[event].name))
 break;
 if (event == VIR_SECRET_EVENT_ID_LAST) {
 vshError(ctl, _("unknown event type %s"), eventName);
@@ -735,7 +730,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
 data.loop = vshCommandOptBool(cmd, "loop");
 data.timestamp = vshCommandOptBool(cmd, "timestamp");
 data.count = 0;
-data.cb = [event];
+data.cb = [event];
 if (vshCommandOptTimeoutToMs(ctl, cmd, ) < 0)
 return false;
 
diff --git a/tools/virsh-secret.h b/tools/virsh-secret.h
index dda22b021e..c70a2b5c75 100644
--- a/tools/virsh-secret.h
+++ b/tools/virsh-secret.h
@@ -28,6 +28,14 @@
 
 # include "virsh.h"
 
+struct vshSecretEventCallback {
+const char *name;
+virConnectSecretEventGenericCallback cb;
+};
+typedef struct vshSecretEventCallback vshSecretEventCallback;
+
+extern vshSecretEventCallback vshSecretEventCallbacks[];
+
 extern const vshCmdDef secretCmds[];
 
 #endif /* VIRSH_SECRET_H */
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [ [PATCH v3 1/8] virsh-secret: Rename vshEventCallback to vshSecretEventCallback

2018-05-23 Thread Lin Ma
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 
---
 tools/virsh-secret.c | 17 ++---
 tools/virsh-secret.h |  8 
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 9e4ec61a88..07bc54d1bf 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -571,18 +571,12 @@ virshSecretEventToString(int event)
 return str ? _(str) : _("unknown");
 }
 
-struct vshEventCallback {
-const char *name;
-virConnectSecretEventGenericCallback cb;
-};
-typedef struct vshEventCallback vshEventCallback;
-
 struct virshSecretEventData {
 vshControl *ctl;
 bool loop;
 bool timestamp;
 int count;
-vshEventCallback *cb;
+vshSecretEventCallback *cb;
 };
 typedef struct virshSecretEventData virshSecretEventData;
 
@@ -652,11 +646,12 @@ vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED,
 vshEventDone(data->ctl);
 }
 
-static vshEventCallback vshEventCallbacks[] = {
+vshSecretEventCallback vshSecretEventCallbacks[] = {
 { "lifecycle",
   VIR_SECRET_EVENT_CALLBACK(vshEventLifecyclePrint), },
 { "value-changed", vshEventGenericPrint, },
 };
+verify(VIR_SECRET_EVENT_ID_LAST == ARRAY_CARDINALITY(vshSecretEventCallbacks));
 
 static const vshCmdInfo info_secret_event[] = {
 {.name = "help",
@@ -713,7 +708,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
 size_t i;
 
 for (i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++)
-vshPrint(ctl, "%s\n", vshEventCallbacks[i].name);
+vshPrint(ctl, "%s\n", vshSecretEventCallbacks[i].name);
 return true;
 }
 
@@ -724,7 +719,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
 return false;
 }
 for (event = 0; event < VIR_SECRET_EVENT_ID_LAST; event++)
-if (STREQ(eventName, vshEventCallbacks[event].name))
+if (STREQ(eventName, vshSecretEventCallbacks[event].name))
 break;
 if (event == VIR_SECRET_EVENT_ID_LAST) {
 vshError(ctl, _("unknown event type %s"), eventName);
@@ -735,7 +730,7 @@ cmdSecretEvent(vshControl *ctl, const vshCmd *cmd)
 data.loop = vshCommandOptBool(cmd, "loop");
 data.timestamp = vshCommandOptBool(cmd, "timestamp");
 data.count = 0;
-data.cb = [event];
+data.cb = [event];
 if (vshCommandOptTimeoutToMs(ctl, cmd, ) < 0)
 return false;
 
diff --git a/tools/virsh-secret.h b/tools/virsh-secret.h
index dda22b021e..c70a2b5c75 100644
--- a/tools/virsh-secret.h
+++ b/tools/virsh-secret.h
@@ -28,6 +28,14 @@
 
 # include "virsh.h"
 
+struct vshSecretEventCallback {
+const char *name;
+virConnectSecretEventGenericCallback cb;
+};
+typedef struct vshSecretEventCallback vshSecretEventCallback;
+
+extern vshSecretEventCallback vshSecretEventCallbacks[];
+
 extern const vshCmdDef secretCmds[];
 
 #endif /* VIRSH_SECRET_H */
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list