Skip to contentSkip to conversation

QOM devices patch queue 2015-12-03

GIT PULL Andreas Färber 3 participants 7 messages Dec 3, 2015 – Dec 4, 2015

lore
Share & tools
lore
#0 lore raw

Hello Peter,

This is my QOM (devices) patch queue for 2.5. Please pull.

Regards,
Andreas

Cc Peter Maydell <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Marc-André Lureau <[email protected]>

The following changes since commit 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3:

ui: vnc: avoid floating point exception (2015-12-03 13:34:50 +0000)

are available in the git repository at:

git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-peter

for you to fetch changes up to 43c2a474d71918c138ecc6ad7c747d9e9557b6c9:

qom-test: Fix qmp() leaks (2015-12-03 20:22:15 +0100)

----------------------------------------------------------------
QOM infrastructure fixes and device conversions

* Typo fix
* qom-test and related fixes

----------------------------------------------------------------
Andreas Färber (1):
tests: Fix check-report-qtest-% target

Cao jin (1):
qom: Update documentation comment of struct Object

Marc-André Lureau (1):
qom-test: Fix qmp() leaks

Markus Armbruster (1):
tests: Use proper functions types instead of void (*fn)

 include/qom/object.h    |  3 ---
 tests/Makefile          |  4 ++--
 tests/ide-test.c        |  4 ++--
 tests/libqtest.c        | 13 +++++++++----
 tests/libqtest.h        |  6 +++---
 tests/qom-test.c        | 21 ++++++++++++++-------
 tests/vhost-user-test.c |  3 ++-
 7 files changed, 32 insertions(+), 22 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/4] tests: Fix check-report-qtest-% target

Commit e253c28 ("tests: Fix how qom-test is run") introduced $(qtest-generic-y) and used it for check-qtest-% target, but did not update check-report-qtest-%. This causes check-report-qtest-aarch64.xml target to fail with a gtester usage error for lack of test arguments.

Fix this by adding $(qtest-generic-y) in check-report-qtest-%. Also add it in check-clean target, spotted by Markus.

---
 tests/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/Makefile +2 -2
index 0ef00a1..a1d03b4 100644
@@ -612,7 +612,7 @@ $(patsubst %, check-%, $(check-unit-y)): check-%: %
 $(patsubst %, check-report-qtest-%.xml, $(QTEST_TARGETS)): check-report-qtest-%.xml: $(check-qtest-y)
 	$(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
 		QTEST_QEMU_IMG=qemu-img$(EXESUF) \
-	  gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $(check-qtest-$*-y),"GTESTER $@")
+	  gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $(check-qtest-$*-y) $(check-qtest-generic-y),"GTESTER $@")
 
 check-report-unit.xml: $(check-unit-y)
 	$(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^, "GTESTER $@")
@@ -660,7 +660,7 @@ check: check-qapi-schema check-unit check-qtest
 check-clean:
 	$(MAKE) -C tests/tcg clean
 	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
-	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)))
+	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
 
 clean: check-clean
 
Signature · 1 line
2.6.2
#2 lore raw

[Qemu-devel] [PULL 2/4] qom: Update documentation comment of struct Object

In reply to Andreas Färber

From: Cao jin <[email protected]>

It doesn't have "GSList *interfaces" anymore, drop the paragraph.

---
 include/qom/object.h | 3 ---
 1 file changed, 3 deletions(-)
include/qom/object.h +0 -3
index f172fea..4509166 100644
@@ -394,9 +394,6 @@ struct ObjectClass
  * As a result, #Object contains a reference to the objects type as its
  * first member.  This allows identification of the real type of the object at
  * run time.
- *
- * #Object also contains a list of #Interfaces that this object
- * implements.
  */
 struct Object
 {
Signature · 1 line
2.6.2
#3 lore raw

[Qemu-devel] [PULL 4/4] qom-test: Fix qmp() leaks

In reply to Andreas Färber

From: Marc-André Lureau <[email protected]>

Before this patch ASAN reported:
SUMMARY: AddressSanitizer: 677165875 byte(s) leaked in 1272437 allocation(s)

After this patch:
SUMMARY: AddressSanitizer: 465 byte(s) leaked in 32 allocation(s)

Message-Id: <[email protected]>

[Straightforwardly rebased onto the previous patch]
---
 tests/qom-test.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
tests/qom-test.c +14 -7
index fde04e7..3e5e873 100644
@@ -47,7 +47,7 @@ static bool is_blacklisted(const char *arch, const char *mach)
 static void test_properties(const char *path, bool recurse)
 {
     char *child_path;
-    QDict *response, *tuple;
+    QDict *response, *tuple, *tmp;
     QList *list;
     QListEntry *entry;
 
@@ -57,6 +57,7 @@ static void test_properties(const char *path, bool recurse)
     g_assert(response);
 
     if (!recurse) {
+        QDECREF(response);
         return;
     }
 
@@ -75,14 +76,16 @@ static void test_properties(const char *path, bool recurse)
         } else {
             const char *prop = qdict_get_str(tuple, "name");
             g_test_message("Testing property %s.%s", path, prop);
-            response = qmp("{ 'execute': 'qom-get',"
-                           "  'arguments': { 'path': %s,"
-                           "                 'property': %s } }",
-                           path, prop);
+            tmp = qmp("{ 'execute': 'qom-get',"
+                      "  'arguments': { 'path': %s,"
+                      "                 'property': %s } }",
+                      path, prop);
             /* qom-get may fail but should not, e.g., segfault. */
-            g_assert(response);
+            g_assert(tmp);
+            QDECREF(tmp);
         }
     }
+    QDECREF(response);
 }
 
 static void test_machine(gconstpointer data)
@@ -98,9 +101,11 @@ static void test_machine(gconstpointer data)
 
     response = qmp("{ 'execute': 'quit' }");
     g_assert(qdict_haskey(response, "return"));
+    QDECREF(response);
 
     qtest_end();
     g_free(args);
+    g_free((void *)machine);
 }
 
 static void add_machine_test_cases(void)
@@ -129,10 +134,12 @@ static void add_machine_test_cases(void)
         mname = qstring_get_str(qstr);
         if (!is_blacklisted(arch, mname)) {
             path = g_strdup_printf("qom/%s", mname);
-            qtest_add_data_func(path, mname, test_machine);
+            qtest_add_data_func(path, g_strdup(mname), test_machine);
         }
     }
+
     qtest_end();
+    QDECREF(response);
 }
 
 int main(int argc, char **argv)
Signature · 1 line
2.6.2
#4 lore raw

[Qemu-devel] [PULL 3/4] tests: Use proper functions types instead of void (*fn)

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

We have several function parameters declared as void (*fn). This is just a stupid way to write void *, and the only purpose writing it like that could serve is obscuring the sin of bypassing the type system without need.

The original sin is commit 49ee359: its qtest_add_func() is a wrapper for g_test_add_func(). Fix the parameter type to match g_test_add_func()'s. This uncovers type errors in ide-test.c; fix them.

Commit 7949c0e faithfully repeated the sin for qtest_add_data_func(). Fix it the same way, along with a harmless type error uncovered in vhost-user-test.c.

Commit 063c23d repeated it for qtest_add_abrt_handler(). The screwy parameter gets assigned to GHook member func, so change its type to match. Requires wrapping kill_qemu() to keep the type checker happy.

---
 tests/ide-test.c        |  4 ++--
 tests/libqtest.c        | 13 +++++++++----
 tests/libqtest.h        |  6 +++---
 tests/vhost-user-test.c |  3 ++-
 4 files changed, 16 insertions(+), 10 deletions(-)
tests/ide-test.c +2 -2
index c3aacd2..b864701 100644
@@ -593,12 +593,12 @@ static void test_flush_nodev(void)
     ide_test_quit();
 }
 
-static void test_pci_retry_flush(const char *machine)
+static void test_pci_retry_flush(void)
 {
     test_retry_flush("pc");
 }
 
-static void test_isa_retry_flush(const char *machine)
+static void test_isa_retry_flush(void)
 {
     test_retry_flush("isapc");
 }
tests/libqtest.c +9 -4
index 9753161..c52ceb2 100644
@@ -110,6 +110,11 @@ static void kill_qemu(QTestState *s)
     }
 }
 
+static void kill_qemu_hook_func(void *s)
+{
+    kill_qemu(s);
+}
+
 static void sigabrt_handler(int signo)
 {
     g_hook_list_invoke(&abrt_hooks, FALSE);
@@ -133,7 +138,7 @@ static void cleanup_sigabrt_handler(void)
     sigaction(SIGABRT, &sigact_old, NULL);
 }
 
-void qtest_add_abrt_handler(void (*fn), const void *data)
+void qtest_add_abrt_handler(GHookFunc fn, const void *data)
 {
     GHook *hook;
 
@@ -170,7 +175,7 @@ QTestState *qtest_init(const char *extra_args)
     sock = init_socket(socket_path);
     qmpsock = init_socket(qmp_socket_path);
 
-    qtest_add_abrt_handler(kill_qemu, s);
+    qtest_add_abrt_handler(kill_qemu_hook_func, s);
 
     s->qemu_pid = fork();
     if (s->qemu_pid == 0) {
@@ -755,14 +760,14 @@ void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size)
     g_strfreev(args);
 }
 
-void qtest_add_func(const char *str, void (*fn))
+void qtest_add_func(const char *str, GTestFunc fn)
 {
     gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str);
     g_test_add_func(path, fn);
     g_free(path);
 }
 
-void qtest_add_data_func(const char *str, const void *data, void (*fn))
+void qtest_add_data_func(const char *str, const void *data, GTestDataFunc fn)
 {
     gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str);
     g_test_add_data_func(path, data, fn);
tests/libqtest.h +3 -3
index df08745..d11b5a4 100644
@@ -416,7 +416,7 @@ const char *qtest_get_arch(void);
  * The path is prefixed with the architecture under test, as
  * returned by qtest_get_arch().
  */
-void qtest_add_func(const char *str, void (*fn));
+void qtest_add_func(const char *str, GTestFunc fn);
 
 /**
  * qtest_add_data_func:
@@ -428,7 +428,7 @@ void qtest_add_func(const char *str, void (*fn));
  * The path is prefixed with the architecture under test, as
  * returned by qtest_get_arch().
  */
-void qtest_add_data_func(const char *str, const void *data, void (*fn));
+void qtest_add_data_func(const char *str, const void *data, GTestDataFunc fn);
 
 /**
  * qtest_add:
@@ -450,7 +450,7 @@ void qtest_add_data_func(const char *str, const void *data, void (*fn));
         g_free(path); \
     } while (0)
 
-void qtest_add_abrt_handler(void (*fn), const void *data);
+void qtest_add_abrt_handler(GHookFunc fn, const void *data);
 
 /**
  * qtest_start:
tests/vhost-user-test.c +2 -1
index 29de739..991fd85 100644
@@ -173,8 +173,9 @@ static void wait_for_fds(TestServer *s)
     g_mutex_unlock(&s->data_mutex);
 }
 
-static void read_guest_mem(TestServer *s)
+static void read_guest_mem(const void *data)
 {
+    TestServer *s = (void *)data;
     uint32_t *guest_mem;
     int i, j;
     size_t size;
Signature · 1 line
2.6.2
#5 lore raw
In reply to Andreas Färber
Quoted 21 lines · Andreas Färber

Hello Peter,

This is my QOM (devices) patch queue for 2.5. Please pull.

Regards,
Andreas

Cc Peter Maydell <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Marc-André Lureau <[email protected]>

The following changes since commit 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3:

ui: vnc: avoid floating point exception (2015-12-03 13:34:50 +0000)

are available in the git repository at:

git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-peter

for you to fetch changes up to 43c2a474d71918c138ecc6ad7c747d9e9557b6c9:

Quoted 7 lines

qom-test: Fix qmp() leaks (2015-12-03 20:22:15 +0100)

----------------------------------------------------------------
QOM infrastructure fixes and device conversions

* Typo fix
* qom-test and related fixes

Unfortunately this fails to build with our minimum supported Glib version:

In file included from /Users/pm215/src/qemu-for-merges/tests/ds1338-test.c:20:
/Users/pm215/src/qemu-for-merges/tests/libqtest.h:419:38: error:
unknown type name 'GTestFunc'; did you mean 'GHashFunc'?

void qtest_add_func(const char *str, GTestFunc fn);
                                     ^~~~~~~~~
                                     GHashFunc
/sw/include/glib-2.0/glib/gtypes.h:90:27: note: 'GHashFunc' declared here
typedef guint           (*GHashFunc)            (gconstpointer  key);
                          ^

In file included from /Users/pm215/src/qemu-for-merges/tests/ds1338-test.c:20:
/Users/pm215/src/qemu-for-merges/tests/libqtest.h:431:61: error:
unknown type name 'GTestDataFunc'
void qtest_add_data_func(const char *str, const void *data, GTestDataFunc fn);

                                                            ^

/Users/pm215/src/qemu-for-merges/tests/ds1338-test.c:68:37: warning:
incompatible pointer types passing 'void (void)' to parameter of type 'GHashFunc' (aka 'guint (*)(gconstpointer)') [-Wincompatible-pointer-types]

    qtest_add_func("/ds1338/tx-rx", send_and_receive);
                                    ^~~~~~~~~~~~~~~~
/Users/pm215/src/qemu-for-merges/tests/libqtest.h:419:48: note:
passing argument to parameter 'fn' here
void qtest_add_func(const char *str, GTestFunc fn);
                                               ^

The GTestFunc and GTestDataFunc types were added in GLib 2.28, but we need to support 2.22.

(That last warning I think is just because clang guessed wrong about how to fix up the initial error.)

thanks
-- PMM

#6 lore raw
Quoted 58 lines · Peter Maydell
Quoted 21 lines · Andreas Färber

Hello Peter,

This is my QOM (devices) patch queue for 2.5. Please pull.

Regards,
Andreas

Cc Peter Maydell <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Marc-André Lureau <[email protected]>

The following changes since commit 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3:

ui: vnc: avoid floating point exception (2015-12-03 13:34:50 +0000)

are available in the git repository at:

git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-peter

for you to fetch changes up to 43c2a474d71918c138ecc6ad7c747d9e9557b6c9:

Quoted 7 lines

qom-test: Fix qmp() leaks (2015-12-03 20:22:15 +0100)

----------------------------------------------------------------
QOM infrastructure fixes and device conversions

* Typo fix
* qom-test and related fixes

Unfortunately this fails to build with our minimum supported Glib version:

In file included from /Users/pm215/src/qemu-for-merges/tests/ds1338-test.c:20:
/Users/pm215/src/qemu-for-merges/tests/libqtest.h:419:38: error:
unknown type name 'GTestFunc'; did you mean 'GHashFunc'?

void qtest_add_func(const char *str, GTestFunc fn);
                                     ^~~~~~~~~
                                     GHashFunc
/sw/include/glib-2.0/glib/gtypes.h:90:27: note: 'GHashFunc' declared here
typedef guint           (*GHashFunc)            (gconstpointer  key);
                          ^

In file included from /Users/pm215/src/qemu-for-merges/tests/ds1338-test.c:20:
/Users/pm215/src/qemu-for-merges/tests/libqtest.h:431:61: error:
unknown type name 'GTestDataFunc'
void qtest_add_data_func(const char *str, const void *data, GTestDataFunc fn);

                                                            ^

/Users/pm215/src/qemu-for-merges/tests/ds1338-test.c:68:37: warning:
incompatible pointer types passing 'void (void)' to parameter of type 'GHashFunc' (aka 'guint (*)(gconstpointer)') [-Wincompatible-pointer-types]

    qtest_add_func("/ds1338/tx-rx", send_and_receive);
                                    ^~~~~~~~~~~~~~~~
/Users/pm215/src/qemu-for-merges/tests/libqtest.h:419:48: note:
passing argument to parameter 'fn' here
void qtest_add_func(const char *str, GTestFunc fn);
                                               ^
Quoted 5 lines

The GTestFunc and GTestDataFunc types were added in GLib 2.28, but we need to support 2.22.

(That last warning I think is just because clang guessed wrong about how to fix up the initial error.)

My fault, sorry! I assumed the data types would be available where the functions are. The documentation fine print shows they got tacked on later.

Options:

0. Don't honor Andreas's pull request for 2.5.

1. Apply without my two patches.

2. Apply with just the second patch. Use Marc-André's version <[email protected]> to save you a straightforward rebase.

3. Apply with the obvious fixup patch I'm going to post shortly.