Skip to contentSkip to conversation

libqtest leak fix & cleanup

PATCH Applied Markus Armbruster 3 participants 6 messages Jun 20, 2013 – Jul 18, 2013

lore
Share & tools
lore
#0 lore raw

v2 cover libqtest leak fix & cleanup

v2: qtest_start() function comment

Markus Armbruster (2):
libqtest: Plug fd and memory leaks in qtest_quit()
libqtest: New qtest_end() to go with qtest_start()

 tests/fdc-test.c    |  2 +-
 tests/hd-geo-test.c |  8 ++++----
 tests/ide-test.c    |  2 +-
 tests/libqtest.c    |  4 ++++
 tests/libqtest.h    | 12 ++++++++++++
 5 files changed, 22 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH v2 1/2 libqtest: Plug fd and memory leaks in qtest_quit()

---
 tests/libqtest.c | 4 ++++
 1 file changed, 4 insertions(+)
tests/libqtest.c +4 -0
index 879ffe9..bb82069 100644
@@ -171,12 +171,16 @@ void qtest_quit(QTestState *s)
         waitpid(pid, &status, 0);
     }
 
+    close(s->fd);
+    close(s->qmp_fd);
+    g_string_free(s->rx, true);
     unlink(s->pid_file);
     unlink(s->socket_path);
     unlink(s->qmp_socket_path);
     g_free(s->pid_file);
     g_free(s->socket_path);
     g_free(s->qmp_socket_path);
+    g_free(s);
 }
 
 static void socket_sendf(int fd, const char *fmt, va_list ap)
Signature · 1 line
1.7.11.7
#2 lore raw

PATCH v2 2/2 libqtest: New qtest_end() to go with qtest_start()

In reply to Markus Armbruster
---
 tests/fdc-test.c    |  2 +-
 tests/hd-geo-test.c |  8 ++++----
 tests/ide-test.c    |  2 +-
 tests/libqtest.h    | 12 ++++++++++++
 4 files changed, 18 insertions(+), 6 deletions(-)
tests/fdc-test.c +1 -1
index 4b0301d..fd198dc 100644
@@ -556,7 +556,7 @@ int main(int argc, char **argv)
     ret = g_test_run();
 
     /* Cleanup */
-    qtest_quit(global_qtest);
+    qtest_end();
     unlink(test_image);
 
     return ret;
tests/hd-geo-test.c +4 -4
index 9a31e85..b72042e 100644
@@ -244,7 +244,7 @@ static void test_ide_none(void)
     setup_common(argv, ARRAY_SIZE(argv));
     qtest_start(g_strjoinv(" ", argv));
     test_cmos();
-    qtest_quit(global_qtest);
+    qtest_end();
 }
 
 static void test_ide_mbr(bool use_device, MBRcontents mbr)
@@ -262,7 +262,7 @@ static void test_ide_mbr(bool use_device, MBRcontents mbr)
     }
     qtest_start(g_strjoinv(" ", argv));
     test_cmos();
-    qtest_quit(global_qtest);
+    qtest_end();
 }
 
 /*
@@ -334,7 +334,7 @@ static void test_ide_drive_user(const char *dev, bool trans)
     g_free(opts);
     qtest_start(g_strjoinv(" ", argv));
     test_cmos();
-    qtest_quit(global_qtest);
+    qtest_end();
 }
 
 /*
@@ -387,7 +387,7 @@ static void test_ide_drive_cd_0(void)
     }
     qtest_start(g_strjoinv(" ", argv));
     test_cmos();
-    qtest_quit(global_qtest);
+    qtest_end();
 }
 
 int main(int argc, char **argv)
tests/ide-test.c +1 -1
index 7e2eb94..7307f1d 100644
@@ -122,7 +122,7 @@ static void ide_test_start(const char *cmdline_fmt, ...)
 
 static void ide_test_quit(void)
 {
-    qtest_quit(global_qtest);
+    qtest_end();
 }
 
 static QPCIDevice *get_pci_device(uint16_t *bmdma_base)
tests/libqtest.h +12 -0
index 437bda3..0f6aade 100644
@@ -17,6 +17,7 @@
 #ifndef LIBQTEST_H
 #define LIBQTEST_H
 
+#include <stddef.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdarg.h>
@@ -319,6 +320,17 @@ static inline QTestState *qtest_start(const char *args)
 }
 
 /**
+ * qtest_end:
+ *
+ * Shut down the QEMU process started by qtest_start().
+ */
+static inline void qtest_end(void)
+{
+    qtest_quit(global_qtest);
+    global_qtest = NULL;
+}
+
+/**
  * qmp:
  * @fmt...: QMP message to send to qemu
  *
Signature · 1 line
1.7.11.7
Reviewed-by on the v2 series
#3 lore raw
In reply to Markus Armbruster

Am 20.06.2013 08:55, schrieb Markus Armbruster:

Quoted 1 line

v2: qtest_start() function comment

Thanks, series

Andreas

Quoted 11 lines

Markus Armbruster (2):
libqtest: Plug fd and memory leaks in qtest_quit()
libqtest: New qtest_end() to go with qtest_start()

 tests/fdc-test.c    |  2 +-
 tests/hd-geo-test.c |  8 ++++----
 tests/ide-test.c    |  2 +-
 tests/libqtest.c    |  4 ++++
 tests/libqtest.h    | 12 ++++++++++++
 5 files changed, 22 insertions(+), 6 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#4 lore raw
In reply to Markus Armbruster

Ping?

Quoted 12 lines · Markus Armbruster

v2: qtest_start() function comment

Markus Armbruster (2):
libqtest: Plug fd and memory leaks in qtest_quit()
libqtest: New qtest_end() to go with qtest_start()

 tests/fdc-test.c    |  2 +-
 tests/hd-geo-test.c |  8 ++++----
 tests/ide-test.c    |  2 +-
 tests/libqtest.c    |  4 ++++
 tests/libqtest.h    | 12 ++++++++++++
 5 files changed, 22 insertions(+), 6 deletions(-)