[PATCH v2 09/10] viriscsitest: Introduce testIscsiadmCbData struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some tests will want to pass their own callback data into the
testIscsiadmCbData callback. Introduce testIscsiadmCbData struct
to give this some form and order.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/viriscsitest.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c
index 361bf6a8da..c6e0e3b8ff 100644
--- a/tests/viriscsitest.c
+++ b/tests/viriscsitest.c
@@ -60,6 +60,10 @@ const char *iscsiadmSendtargetsOutput =
     "10.20.30.40:3260,1 iqn.2008-04.example:example1:iscsi.bar\n"
     "10.20.30.40:3260,1 iqn.2009-04.example:example1:iscsi.seven\n";
 
+struct testIscsiadmCbData {
+    bool output_version;
+};
+
 static void testIscsiadmCb(const char *const*args,
                            const char *const*env ATTRIBUTE_UNUSED,
                            const char *input ATTRIBUTE_UNUSED,
@@ -68,12 +72,13 @@ static void testIscsiadmCb(const char *const*args,
                            int *status,
                            void *opaque)
 {
-    int *output_version = opaque;
+    struct testIscsiadmCbData *data = opaque;
+
     if (args[0] && STREQ(args[0], ISCSIADM) &&
         args[1] && STREQ(args[1], "--mode") &&
         args[2] && STREQ(args[2], "session") &&
         args[3] == NULL) {
-        if (*output_version == 1)
+        if (data->output_version)
             ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutputNonFlash));
         else
             ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutput));
@@ -113,11 +118,13 @@ static int
 testISCSIGetSession(const void *data)
 {
     const struct testSessionInfo *info = data;
-    int ver = info->output_version;
+    struct testIscsiadmCbData cbData = { 0 };
     char *actual_session = NULL;
     int ret = -1;
 
-    virCommandSetDryRun(NULL, testIscsiadmCb, &ver);
+    cbData.output_version = info->output_version;
+
+    virCommandSetDryRun(NULL, testIscsiadmCb, &cbData);
 
     actual_session = virISCSIGetSession(info->device_path, true);
 
-- 
2.16.4

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux