qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Thomas Huth <thuth@redhat.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Laurent Vivier <lvivier@redhat.com>,
	qemu-block@nongnu.org, Amit Shah <amit@kernel.org>,
	Jason Wang <jasowang@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Markus Armbruster <armbru@redhat.com>, Greg Kurz <groug@kaod.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/6] tests/libqos: Make generic virtio code independent from global_qtest
Date: Tue, 13 Aug 2019 10:18:16 -0500	[thread overview]
Message-ID: <04a21d67-7a8b-20bf-2d8c-56d714ebb07d@redhat.com> (raw)
In-Reply-To: <20190813093047.27948-2-thuth@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 3652 bytes --]

On 8/13/19 4:30 AM, Thomas Huth wrote:
> The libqos library functions should never depend on global_qtest,
> since these functions might be used in tests that track multiple
> test states. Pass around a pointer to the QTestState instead.

Thanks for picking up on my initial RFC along these lines a couple years
ago now; it's taking us a while, but these cleanups are worthwhile.

> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---

> @@ -193,7 +193,7 @@ void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq,
>                   0);
>  }
>  
> -QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
> +QVRingIndirectDesc *qvring_indirect_desc_setup(QTestState *qs, QVirtioDevice *d,
>                                          QGuestAllocator *alloc, uint16_t elem)
>  {

Pre-existing, but indentation is off; maybe you want to fix that while here.


> -void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head)
> +void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
> +                     uint32_t free_head)
>  {
>      /* vq->avail->idx */
> -    uint16_t idx = readw(vq->avail + 2);
> +    uint16_t idx = qtest_readw(qts, vq->avail + 2);
>      /* vq->used->flags */
>      uint16_t flags;
>      /* vq->used->avail_event */
>      uint16_t avail_event;
>  
>      /* vq->avail->ring[idx % vq->size] */
> -    writew(vq->avail + 4 + (2 * (idx % vq->size)), free_head);
> +    qtest_writew(qts, vq->avail + 4 + (2 * (idx % vq->size)), free_head);
>      /* vq->avail->idx */
> -    writew(vq->avail + 2, idx + 1);
> +    qtest_writew(qts, vq->avail + 2, idx + 1);
>  
>      /* Must read after idx is updated */
> -    flags = readw(vq->avail);
> -    avail_event = readw(vq->used + 4 +
> +    flags = qtest_readw(qts, vq->avail);
> +    avail_event = qtest_readw(qts, vq->used + 4 +
>                                  sizeof(struct vring_used_elem) * vq->size);

Here as well.

> @@ -333,23 +337,25 @@ bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len)
>          sizeof(struct vring_used_elem);
>  
>      if (desc_idx) {
> -        *desc_idx = readl(elem_addr + offsetof(struct vring_used_elem, id));
> +        *desc_idx = qtest_readl(qts, elem_addr +
> +                                     offsetof(struct vring_used_elem, id));

This one works as-is, although it gives me a double-take when the
indentation is not right after a ( in the line above.  I probably would
have written either:

        *desc_idx = qtest_readl(qts,
                                elem_addr + offsetof(struct
vring_used_elem, id));

or

        *desc_idx = qtest_readl(qts, (elem_addr +
                                      offsetof(struct vring_used_elem,
id)));

or even introduce a temp variable to bring down the line length.


> @@ -131,17 +131,20 @@ void qvirtqueue_cleanup(const QVirtioBus *bus, QVirtQueue *vq,
>  
>  void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq,
>                   uint64_t addr);
> -QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
> +QVRingIndirectDesc *qvring_indirect_desc_setup(QTestState *qs, QVirtioDevice *d,
>                                          QGuestAllocator *alloc, uint16_t elem);

Another pre-existing odd indentation (here, it looks like line length
was the reason).

Indentation is minor, so:

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

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


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

  reply	other threads:[~2019-08-13 15:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13  9:30 [Qemu-devel] [PATCH 0/6] First batch of global_qtest-removement patches for QEMU 4.2 Thomas Huth
2019-08-13  9:30 ` [Qemu-devel] [PATCH 1/6] tests/libqos: Make generic virtio code independent from global_qtest Thomas Huth
2019-08-13 15:18   ` Eric Blake [this message]
2019-08-14 19:59     ` [Qemu-devel] [PATCH v2] " Thomas Huth
2019-08-13  9:30 ` [Qemu-devel] [PATCH 2/6] tests/libqos: Make virtio-pci " Thomas Huth
2019-08-13 15:19   ` Eric Blake
2019-08-13  9:30 ` [Qemu-devel] [PATCH 3/6] tests/libqtest: Remove unused function hmp() Thomas Huth
2019-08-13 15:20   ` Eric Blake
2019-08-13 17:38     ` Thomas Huth
2019-08-13  9:30 ` [Qemu-devel] [PATCH 4/6] tests/libqtest: Clean up qtest_cb_for_every_machine() wrt global_qtest Thomas Huth
2019-08-13 15:21   ` Eric Blake
2019-08-13  9:30 ` [Qemu-devel] [PATCH 5/6] tests/libqtest: Make qtest_qmp_device_add/del independent from global_qtest Thomas Huth
2019-08-13 15:22   ` Eric Blake
2019-08-13  9:30 ` [Qemu-devel] [PATCH 6/6] tests/libqtest: Make qmp_assert_success() " Thomas Huth
2019-08-13 15:24   ` Eric Blake
2019-08-13 15:00 ` [Qemu-devel] [PATCH 0/6] First batch of global_qtest-removement patches for QEMU 4.2 Stefan Hajnoczi

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=04a21d67-7a8b-20bf-2d8c-56d714ebb07d@redhat.com \
    --to=eblake@redhat.com \
    --cc=amit@kernel.org \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=fam@euphon.net \
    --cc=groug@kaod.org \
    --cc=jasowang@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.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).