qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Steve Sistare <steven.sistare@oracle.com>, qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
	Steve Sistare <steven.sistare@oracle.com>
Subject: Re: [PATCH V1 03/11] tests/qtest: qtest_create_test_state
Date: Mon, 29 Sep 2025 11:52:57 -0300	[thread overview]
Message-ID: <87y0pxux86.fsf@suse.de> (raw)
In-Reply-To: <1758291153-349744-4-git-send-email-steven.sistare@oracle.com>

Steve Sistare <steven.sistare@oracle.com> writes:

> Refactor qtest_spawn_qemu and create a subroutine to create a QTestState
> object, to be used in a subsequent patch.
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
>  tests/qtest/libqtest.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index 551bc8c..3fa9317 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -409,22 +409,29 @@ static pid_t qtest_create_process(char *cmd)
>  }
>  #endif /* _WIN32 */
>  
> -static QTestState *qtest_spawn_qemu(const char *qemu_bin, const char *args)
> +static QTestState *qtest_create_test_state(int pid)
>  {
>      QTestState *s = g_new0(QTestState, 1);
> +
> +    s->qemu_pid = pid;
> +    qtest_add_abrt_handler(kill_qemu_hook_func, s);
> +    return s;
> +}
> +
> +static QTestState *qtest_spawn_qemu(const char *qemu_bin, const char *args)
> +{
> +    int pid;
>      g_autoptr(GString) command = g_string_new("");
>  
>      g_string_printf(command, CMD_EXEC "%s %s", qemu_bin, args);
>  
> -    qtest_add_abrt_handler(kill_qemu_hook_func, s);
> -
>      if (!silence_spawn_log) {
>          g_test_message("starting QEMU: %s", command->str);
>      }
>  
>  #ifndef _WIN32
> -    s->qemu_pid = fork();
> -    if (s->qemu_pid == 0) {
> +    pid = fork();
> +    if (pid == 0) {
>  #ifdef __linux__
>          /*
>           * Although we register a ABRT handler to kill off QEMU
> @@ -447,10 +454,10 @@ static QTestState *qtest_spawn_qemu(const char *qemu_bin, const char *args)
>          exit(1);
>      }
>  #else
> -    s->qemu_pid = qtest_create_process(command->str);
> +    pid = qtest_create_process(command->str);
>  #endif /* _WIN32 */
>  
> -    return s;
> +    return qtest_create_test_state(pid);
>  }
>  
>  static char *qtest_socket_path(const char *suffix)

Reviewed-by: Fabiano Rosas <farosas@suse.de>


  reply	other threads:[~2025-09-29 14:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19 14:12 [PATCH V1 00/11] cpr-exec test Steve Sistare
2025-09-19 14:12 ` [PATCH V1 01/11] tests/qtest: export qtest_qemu_binary Steve Sistare
2025-09-29 14:47   ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 02/11] tests/qtest: qtest_qemu_args Steve Sistare
2025-09-29 14:51   ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 03/11] tests/qtest: qtest_create_test_state Steve Sistare
2025-09-29 14:52   ` Fabiano Rosas [this message]
2025-09-19 14:12 ` [PATCH V1 04/11] tests/qtest: qtest_qemu_spawn_func Steve Sistare
2025-09-29 14:57   ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 05/11] tests/qtest: qtest_init_after_exec Steve Sistare
2025-09-29 14:59   ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 06/11] migration-test: only_source option Steve Sistare
2025-09-29 20:27   ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 07/11] migration-test: shm path accessor Steve Sistare
2025-09-29 20:28   ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 08/11] migration-test: misc exports Steve Sistare
2025-09-19 14:12 ` [PATCH V1 09/11] migration-test: migrate_args Steve Sistare
2025-09-29 20:32   ` Fabiano Rosas
2025-09-30 14:35     ` Steven Sistare
2025-09-30 19:51   ` Fabiano Rosas
2025-09-30 19:59     ` Steven Sistare
2025-09-30 21:14       ` Steven Sistare
2025-10-01 12:16         ` Fabiano Rosas
2025-09-19 14:12 ` [PATCH V1 10/11] migration-test: strv parameter Steve Sistare
2025-09-19 14:12 ` [PATCH V1 11/11] migration-test: test cpr-exec Steve Sistare
2025-09-30 17:08   ` Peter Xu
2025-09-30 18:23     ` Steven Sistare
2025-09-30 19:02       ` Peter Xu
2025-09-30 19:07         ` Steven Sistare
2025-09-30 14:35 ` [PATCH V1 00/11] cpr-exec test Fabiano Rosas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y0pxux86.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=steven.sistare@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).