From: Peter Xu <peterx@redhat.com>
To: Juraj Marcin <jmarcin@redhat.com>
Cc: qemu-devel@nongnu.org, Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH 2/4] tests/migration-test: Merge shmem_opts into memory_backend
Date: Fri, 21 Nov 2025 10:32:44 -0500 [thread overview]
Message-ID: <aSCGHJ8r8iSOSTZK@x1.local> (raw)
In-Reply-To: <bptgyz34rzqk5dkcd7kzp4aksdsqu4qm5vjlvvoacvypqqovqx@vzotefvcdkkq>
On Fri, Nov 21, 2025 at 01:46:31PM +0100, Juraj Marcin wrote:
> Hi Peter,
>
> you can add my R-b to the whole series, I just have a small nitpick
> below, but feel free to ignore it.
>
> Reviewed-by: Juraj Marcin <jmarcin@redhat.com>
Thanks a lot for the quick look. :)
>
> On 2025-11-17 17:39, Peter Xu wrote:
> > The two parameters are more or less duplicated in migrate_args(). They all
> > describe the memory type. When one is used, the other is not.
> >
> > mem_type currently uses numa parameter to specify the memory backend, while
> > memory_backend (the two users of such uses "-machine memory-backend=ID").
> >
> > This patch merges the use of the two variables so that we always generate a
> > memory object string and put it into "memory_backend" variable. Now we can
> > drop shmem_opts parameter in the function.
> >
> > Meanwhile we always use a memory-backend-* no matter which mem type is
> > used. This brings mem_type to be aligned with memory_backend usage, then
> > we stick with this as this is flexible enough.
> >
> > This paves way that we merge mem_type and memory_backend in MigrateStart.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > tests/qtest/migration/framework.c | 41 ++++++++++++++++++++-----------
> > 1 file changed, 26 insertions(+), 15 deletions(-)
> >
> > diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/framework.c
> > index 8fa39999a1..6df0e56c2a 100644
> > --- a/tests/qtest/migration/framework.c
> > +++ b/tests/qtest/migration/framework.c
> > @@ -260,23 +260,36 @@ static char *test_shmem_path(void)
> > return g_strdup_printf("/dev/shm/qemu-%d", getpid());
> > }
> >
> > +#define MIG_MEM_ID "mig.mem"
> > +
> > /* NOTE: caller is responsbile to free the string if returned */
> > static char *migrate_mem_type_get_opts(MemType type, const char *memory_size)
> > {
> > g_autofree char *shmem_path = NULL;
> > - char *backend = NULL;
> > + g_autofree char *backend = NULL;
> > + bool share = true;
> > + char *opts;
> >
> > switch (type) {
> > case MEM_TYPE_SHMEM:
> > shmem_path = test_shmem_path();
> > - backend = g_strdup_printf(
> > - "-object memory-backend-file,id=mem0,size=%s"
> > - ",mem-path=%s,share=on -numa node,memdev=mem0",
> > - memory_size, shmem_path);
> > - return backend;
> > + backend = g_strdup_printf("-object memory-backend-file,mem-path=%s",
> > + shmem_path);
> > + break;
> > + case MEM_TYPE_ANON:
> > + backend = g_strdup("-object memory-backend-ram");
> > + share = false;
> > + break;
>
> Wouldn't it be a bit nicer to add this case before SHMEM, so the order
> is the same as in the enum? The patch adding MEMFD follows is by adding
> it right after SHMEM (and before ANON).
Normally we don't need to order cases in a switch() (especially think about
when fallthrough cases could happen..), but sure I am happy to move it if
that at least makes it easier to read for you.
I'll wait for other comments to see if I'll just move it when merge or
repost.
Thanks,
>
> > default:
> > - return NULL;
> > + g_assert_not_reached();
> > + break;
> > }
> > +
> > + opts = g_strdup_printf("%s,id=%s,size=%s,share=%s",
> > + backend, MIG_MEM_ID, memory_size,
> > + share ? "on" : "off");
> > +
> > + return opts;
> > }
> >
> > int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
> > @@ -286,7 +299,7 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
> > gchar *cmd_source = NULL;
> > gchar *cmd_target = NULL;
> > const gchar *ignore_stderr;
> > - g_autofree char *shmem_opts = NULL;
> > + g_autofree char *mem_object = NULL;
> > const char *kvm_opts = NULL;
> > const char *arch = qtest_get_arch();
> > const char *memory_size;
> > @@ -350,12 +363,12 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
> > ignore_stderr = "";
> > }
> >
> > - shmem_opts = migrate_mem_type_get_opts(args->mem_type, memory_size);
> > -
> > if (args->memory_backend) {
> > memory_backend = g_strdup_printf(args->memory_backend, memory_size);
> > } else {
> > - memory_backend = g_strdup_printf("-m %s ", memory_size);
> > + mem_object = migrate_mem_type_get_opts(args->mem_type, memory_size);
> > + memory_backend = g_strdup_printf("-machine memory-backend=%s %s",
> > + MIG_MEM_ID, mem_object);
> > }
> >
> > if (args->use_dirty_ring) {
> > @@ -378,12 +391,11 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
> > "-name source,debug-threads=on "
> > "%s "
> > "-serial file:%s/src_serial "
> > - "%s %s %s %s",
> > + "%s %s %s",
> > kvm_opts ? kvm_opts : "",
> > machine, machine_opts,
> > memory_backend, tmpfs,
> > arch_opts ? arch_opts : "",
> > - shmem_opts ? shmem_opts : "",
> > args->opts_source ? args->opts_source : "",
> > ignore_stderr);
> >
> > @@ -400,13 +412,12 @@ int migrate_args(char **from, char **to, const char *uri, MigrateStart *args)
> > "%s "
> > "-serial file:%s/dest_serial "
> > "-incoming %s "
> > - "%s %s %s %s %s",
> > + "%s %s %s %s",
> > kvm_opts ? kvm_opts : "",
> > machine, machine_opts,
> > memory_backend, tmpfs, uri,
> > events,
> > arch_opts ? arch_opts : "",
> > - shmem_opts ? shmem_opts : "",
> > args->opts_target ? args->opts_target : "",
> > ignore_stderr);
> >
> > --
> > 2.50.1
> >
>
--
Peter Xu
next prev parent reply other threads:[~2025-11-22 4:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 22:39 [PATCH 0/4] tests/migration-test: Introduce mem_type Peter Xu
2025-11-17 22:39 ` [PATCH 1/4] tests/migration-test: Introduce MemType Peter Xu
2025-11-17 22:39 ` [PATCH 2/4] tests/migration-test: Merge shmem_opts into memory_backend Peter Xu
2025-11-21 12:46 ` Juraj Marcin
2025-11-21 15:32 ` Peter Xu [this message]
2025-11-17 22:39 ` [PATCH 3/4] tests/migration-test: Add MEM_TYPE_SHMEM Peter Xu
2025-11-17 22:39 ` [PATCH 4/4] tests/migration-test: Use MEM_TYPE_MEMFD for memory_backend Peter Xu
2025-11-21 17:50 ` [PATCH 0/4] tests/migration-test: Introduce mem_type 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=aSCGHJ8r8iSOSTZK@x1.local \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=jmarcin@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).