All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization
@ 2014-03-11 12:24 Marcel Apfelbaum
  2014-03-11 12:24 ` [Qemu-devel] [PATCH V3 1/2] tests/libqtest: " Marcel Apfelbaum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 12:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha, armbru, aliguori, afaerber

V2 -> V3:
     Addressed Eric Blake's review:
     - Corrected a typo.
     - Replace the commented Makefile part

V1 -> V2:
    Addressed Stefan Hajnoczi's review:
    - Dropped qtest_state_valid API
    - Moved socket options in socket_accept. 

'socket_accept' waits for Qemu to initialize its unix socket.
If Qemu encounters an error during command line parsing,
it can exit before initializing the communication channel.

Using a timeout for sockets fixes the issue, but is not
enough. We need to know which test from check-qtest-*
fails.

We tweak the Makefile to produce per-test output.
The effect is that the output will grow, but we will know
which qtest failed. This helps when an assert is made on
other code and not in the test itself.


Marcel Apfelbaum (1):
  tests/libqtest: Fix possible deadlock in qtest initialization

Stefan Hajnoczi (1):
  tests: Tweak the Makefile to produce per-test output.

 tests/Makefile   |  2 +-
 tests/libqtest.c | 11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH V3 1/2] tests/libqtest: Fix possible deadlock in qtest initialization
  2014-03-11 12:24 [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization Marcel Apfelbaum
@ 2014-03-11 12:24 ` Marcel Apfelbaum
  2014-03-11 12:24 ` [Qemu-devel] [PATCH V3 2/2] tests: Tweak the Makefile to produce per-test output Marcel Apfelbaum
  2014-03-11 12:32 ` [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization Eric Blake
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 12:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha, armbru, aliguori, afaerber

'socket_accept' waits for Qemu to initialize its unix socket.
If Qemu encounters an error during command line parsing,
it can exit before initializing the communication channel.

Using a timeout for sockets fixes the issue.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 tests/libqtest.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index f587d36..f1ba254 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -34,6 +34,7 @@
 #include "qapi/qmp/json-parser.h"
 
 #define MAX_IRQ 256
+#define SOCKET_TIMEOUT 5
 
 QTestState *global_qtest;
 
@@ -78,12 +79,16 @@ static int socket_accept(int sock)
     struct sockaddr_un addr;
     socklen_t addrlen;
     int ret;
+    struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT,
+                               .tv_usec = 0 };
+
+    setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout,
+               sizeof(timeout));
 
     addrlen = sizeof(addr);
     do {
         ret = accept(sock, (struct sockaddr *)&addr, &addrlen);
     } while (ret == -1 && errno == EINTR);
-    g_assert_no_errno(ret);
     close(sock);
 
     return ret;
@@ -91,7 +96,7 @@ static int socket_accept(int sock)
 
 static void kill_qemu(QTestState *s)
 {
-    if (s->qemu_pid != -1) {
+    if (s && s->qemu_pid != -1) {
         kill(s->qemu_pid, SIGTERM);
         waitpid(s->qemu_pid, NULL, 0);
     }
@@ -153,6 +158,8 @@ QTestState *qtest_init(const char *extra_args)
     g_free(socket_path);
     g_free(qmp_socket_path);
 
+    g_assert(s->fd >= 0 && s->qmp_fd >= 0);
+
     s->rx = g_string_new("");
     for (i = 0; i < MAX_IRQ; i++) {
         s->irq_level[i] = false;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH V3 2/2] tests: Tweak the Makefile to produce per-test output.
  2014-03-11 12:24 [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization Marcel Apfelbaum
  2014-03-11 12:24 ` [Qemu-devel] [PATCH V3 1/2] tests/libqtest: " Marcel Apfelbaum
@ 2014-03-11 12:24 ` Marcel Apfelbaum
  2014-03-11 12:32 ` [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization Eric Blake
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2014-03-11 12:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha, armbru, aliguori, afaerber

From: Stefan Hajnoczi <stefanha@redhat.com>

The effect is that the output will grow, but we will know
which qtest failed. This helps when an assert is made on
other code and not in the test itself.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
 tests/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index b17d41e..cbf90e1 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -273,7 +273,7 @@ check-help:
 	@echo "changed with variable GTESTER_OPTIONS."
 
 SPEED = quick
-GTESTER_OPTIONS = -k $(if $(V),--verbose,-q)
+GTESTER_OPTIONS = -k $(if $(V),--verbose,)
 GCOV_OPTIONS = -n $(if $(V),-f,)
 
 # gtester tests, possibly with verbose output
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization
  2014-03-11 12:24 [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization Marcel Apfelbaum
  2014-03-11 12:24 ` [Qemu-devel] [PATCH V3 1/2] tests/libqtest: " Marcel Apfelbaum
  2014-03-11 12:24 ` [Qemu-devel] [PATCH V3 2/2] tests: Tweak the Makefile to produce per-test output Marcel Apfelbaum
@ 2014-03-11 12:32 ` Eric Blake
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2014-03-11 12:32 UTC (permalink / raw)
  To: Marcel Apfelbaum, qemu-devel; +Cc: kwolf, armbru, aliguori, stefanha, afaerber

[-- Attachment #1: Type: text/plain, Size: 1035 bytes --]

On 03/11/2014 06:24 AM, Marcel Apfelbaum wrote:
> V2 -> V3:
>      Addressed Eric Blake's review:
>      - Corrected a typo.
>      - Replace the commented Makefile part
> 
> V1 -> V2:
>     Addressed Stefan Hajnoczi's review:
>     - Dropped qtest_state_valid API
>     - Moved socket options in socket_accept. 
> 
> 'socket_accept' waits for Qemu to initialize its unix socket.
> If Qemu encounters an error during command line parsing,
> it can exit before initializing the communication channel.
> 
> Using a timeout for sockets fixes the issue, but is not
> enough. We need to know which test from check-qtest-*
> fails.
> 
> We tweak the Makefile to produce per-test output.
> The effect is that the output will grow, but we will know
> which qtest failed. This helps when an assert is made on
> other code and not in the test itself.
> 

Series:
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-11 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-11 12:24 [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization Marcel Apfelbaum
2014-03-11 12:24 ` [Qemu-devel] [PATCH V3 1/2] tests/libqtest: " Marcel Apfelbaum
2014-03-11 12:24 ` [Qemu-devel] [PATCH V3 2/2] tests: Tweak the Makefile to produce per-test output Marcel Apfelbaum
2014-03-11 12:32 ` [Qemu-devel] [PATCH V3 0/2] tests: Fix possible deadlock in qtest initialization Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.