All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Alexander Mikhalitsyn <alexander@mihalicyn.com>
Cc: qemu-devel@nongnu.org, "Kevin Wolf" <kwolf@redhat.com>,
	qemu-block@nongnu.org, "Fam Zheng" <fam@euphon.net>,
	"Stéphane Graber" <stgraber@stgraber.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Jesper Devantier" <foss@defmacro.it>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Keith Busch" <kbusch@kernel.org>, "Peter Xu" <peterx@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Alexander Mikhalitsyn" <aleksandr.mikhalitsyn@futurfusion.io>
Subject: Re: [PATCH v6 8/8] tests/qtest/nvme-test: add migration test with full CQ
Date: Tue, 28 Apr 2026 12:13:34 -0400	[thread overview]
Message-ID: <20260428161334.GA278591@fedora> (raw)
In-Reply-To: <CAJqdLro_fUh0-yEjum0z6c2FvNsLjr95MMaA7EX810dqm+=upg@mail.gmail.com>

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

On Tue, Apr 28, 2026 at 05:55:12PM +0200, Alexander Mikhalitsyn wrote:
> Am Mo., 27. Apr. 2026 um 22:00 Uhr schrieb Stefan Hajnoczi
> > On Sun, Apr 19, 2026 at 03:01:39PM +0200, Alexander Mikhalitsyn wrote:
> > > +
> > > +        #define GUEST_MEM_READB(field) \
> > > +                            qtest_readb(ctrl->pdev->bus->qts, (uint64_t)&(field))
> > > +
> > > +        g_assert_cmpint(GUEST_MEM_READB(reqs[i].phys_identify->ieee[0]), ==, 0x0);
> >
> > I was trying to figure out why phys_identify has a pointer type although
> > it is a guest memory address that cannot be dereferenced in C code. I
> > guess the reason is so that the GUEST_MEM_READB() macro can use the
> > address-of operator instead of explicitly calculating the offset of
> > ieee[0], ieee[1], etc? I found this confusing and potentially dangerous
> > (the compiler won't stop the pointer from being dereferenced if someone
> > does it by mistake).
> 
> Exactly, that was my intention, to be able to use address-of operation
> in conjunction
> with structure-dereference operator. To prevent accidental mistakes, I
> used "phys_"
> prefix in structure member names (like "cq->phys_cqe" or
> "reqs[i].phys_identify").
> 
> >
> > It took more time to review the pointer trick than the straightforward
> > approach would have taken. I'd avoid it, but it's a question of coding
> > style and up to you.
> 
> No problem, I think the fact that this code confused you means that my idea
> wasn't that good as I thought ;-) I think I should then change a type for
> phys_identify and phys_cqe to u64 and then add explicit address arithmetic
> or continue to use "arrow" operator but in a special macro like
> GUEST_MEM_READ_SOMETHING(...).
> WDYT?

Encapsulating the address-of operator trick inside a macro would be a
nice solution. By localizing the pointer type just within the macro,
it's more obvious what the intention is and the rest of the program uses
the uint64_t type.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2026-04-28 16:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-19 13:01 [PATCH v6 0/8] hw/nvme: add basic live migration support Alexander Mikhalitsyn
2026-04-19 13:01 ` [PATCH v6 1/8] tests/functional/migration: add VM launch/configure hooks Alexander Mikhalitsyn
2026-04-19 13:01 ` [PATCH v6 2/8] hw/nvme: add migration blockers for non-supported cases Alexander Mikhalitsyn
2026-04-19 13:01 ` [PATCH v6 3/8] hw/nvme: split nvme_init_sq/nvme_init_cq into helpers Alexander Mikhalitsyn
2026-04-29  6:20   ` Klaus Jensen
2026-04-19 13:01 ` [PATCH v6 4/8] hw/nvme: set CQE.sq_id earlier in nvme_process_sq Alexander Mikhalitsyn
2026-04-29  6:18   ` Klaus Jensen
2026-04-19 13:01 ` [PATCH v6 5/8] hw/nvme: unmap req->sg earlier in nvme_enqueue_req_completion Alexander Mikhalitsyn
2026-04-29  6:19   ` Klaus Jensen
2026-04-19 13:01 ` [PATCH v6 6/8] hw/nvme: add basic live migration support Alexander Mikhalitsyn
2026-04-27 21:03   ` Stefan Hajnoczi
2026-04-28 15:38     ` Alexander Mikhalitsyn
2026-04-19 13:01 ` [PATCH v6 7/8] tests/functional/x86_64: add migration test for NVMe device Alexander Mikhalitsyn
2026-04-19 13:01 ` [PATCH v6 8/8] tests/qtest/nvme-test: add migration test with full CQ Alexander Mikhalitsyn
2026-04-27 20:00   ` Stefan Hajnoczi
2026-04-28 15:55     ` Alexander Mikhalitsyn
2026-04-28 16:13       ` Stefan Hajnoczi [this message]

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=20260428161334.GA278591@fedora \
    --to=stefanha@redhat.com \
    --cc=aleksandr.mikhalitsyn@futurfusion.io \
    --cc=alexander@mihalicyn.com \
    --cc=fam@euphon.net \
    --cc=farosas@suse.de \
    --cc=foss@defmacro.it \
    --cc=hreitz@redhat.com \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stgraber@stgraber.org \
    --cc=zhao1.liu@intel.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 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.