[Qemu-devel] [PATCH for-3.1?] qtest: log QEMU command line

Paolo Bonzini posted 1 patch 6 years, 11 months ago
Test asan passed
Test checkpatch passed
Test docker-quick@centos7 passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20181115122930.25732-1-pbonzini@redhat.com
tests/libqtest.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
[Qemu-devel] [PATCH for-3.1?] qtest: log QEMU command line
Posted by Paolo Bonzini 6 years, 11 months ago
Record the command line that was used to start QEMU.  This can be
useful for debugging.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/libqtest.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 44ce118cfc..f6e061da44 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -215,24 +215,28 @@ QTestState *qtest_init_without_qmp_handshake(bool use_oob,
 
     qtest_add_abrt_handler(kill_qemu_hook_func, s);
 
+    command = g_strdup_printf("exec %s "
+                              "-qtest unix:%s,nowait "
+                              "-qtest-log %s "
+                              "-chardev socket,path=%s,nowait,id=char0 "
+                              "-mon chardev=char0,mode=control%s "
+                              "-machine accel=qtest "
+                              "-display none "
+                              "%s", qemu_binary, socket_path,
+                              getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
+                              qmp_socket_path, use_oob ? ",x-oob=on" : "",
+                              extra_args ?: "");
+
+    g_test_message("starting QEMU: %s\n", command);
+
     s->qemu_pid = fork();
     if (s->qemu_pid == 0) {
         setenv("QEMU_AUDIO_DRV", "none", true);
-        command = g_strdup_printf("exec %s "
-                                  "-qtest unix:%s,nowait "
-                                  "-qtest-log %s "
-                                  "-chardev socket,path=%s,nowait,id=char0 "
-                                  "-mon chardev=char0,mode=control%s "
-                                  "-machine accel=qtest "
-                                  "-display none "
-                                  "%s", qemu_binary, socket_path,
-                                  getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
-                                  qmp_socket_path, use_oob ? ",x-oob=on" : "",
-                                  extra_args ?: "");
         execlp("/bin/sh", "sh", "-c", command, NULL);
         exit(1);
     }
 
+    g_free(command);
     s->fd = socket_accept(sock);
     if (s->fd >= 0) {
         s->qmp_fd = socket_accept(qmpsock);
-- 
2.19.1


Re: [Qemu-devel] [PATCH for-3.1?] qtest: log QEMU command line
Posted by Laurent Vivier 6 years, 11 months ago
On 15/11/2018 13:29, Paolo Bonzini wrote:
> Record the command line that was used to start QEMU.  This can be
> useful for debugging.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/libqtest.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)

It seems to be a good idea.

Reviewed-by: Laurent Vivier <lvivier@redhat.com>



Re: [Qemu-devel] [PATCH for-3.1?] qtest: log QEMU command line
Posted by Thomas Huth 6 years, 11 months ago
On 2018-11-15 13:29, Paolo Bonzini wrote:
> Record the command line that was used to start QEMU.  This can be
> useful for debugging.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/libqtest.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 44ce118cfc..f6e061da44 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -215,24 +215,28 @@ QTestState *qtest_init_without_qmp_handshake(bool use_oob,
>  
>      qtest_add_abrt_handler(kill_qemu_hook_func, s);
>  
> +    command = g_strdup_printf("exec %s "
> +                              "-qtest unix:%s,nowait "
> +                              "-qtest-log %s "
> +                              "-chardev socket,path=%s,nowait,id=char0 "
> +                              "-mon chardev=char0,mode=control%s "
> +                              "-machine accel=qtest "
> +                              "-display none "
> +                              "%s", qemu_binary, socket_path,
> +                              getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
> +                              qmp_socket_path, use_oob ? ",x-oob=on" : "",
> +                              extra_args ?: "");
> +
> +    g_test_message("starting QEMU: %s\n", command);

I think we don't need the trailing \n here, do we? Looking at the output
when I run a test with --verbose, it seems like glib is taking care of
this already... (if you agree, I can fix it up when picking the patch up)

 Thomas