From: Stefano Garzarella <sgarzare@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label
Date: Tue, 23 Feb 2021 11:53:46 +0100 [thread overview]
Message-ID: <20210223105346.ii4ex7no5fd434zi@steredhat> (raw)
In-Reply-To: <20210222114931.272308-1-stefanha@redhat.com>
On Mon, Feb 22, 2021 at 11:49:31AM +0000, Stefan Hajnoczi wrote:
>Requiring a conditional for every goto is tedious:
>
> if (busyloop_timeout) {
> goto fail_busyloop;
> } else {
> goto fail;
> }
>
>Move the conditional to into the fail_busyloop label so that it's safe
>to jump to this label unconditionally.
>
>This change makes the migrate_add_blocker() error case more consistent.
>It jumped to fail_busyloop unconditionally whereas the memslots limits
>error case was conditional.
>
>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>---
> hw/virtio/vhost.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
>index 6e17d631f7..2a01662b08 100644
>--- a/hw/virtio/vhost.c
>+++ b/hw/virtio/vhost.c
>@@ -1388,18 +1388,16 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
> error_report("vhost backend memory slots limit is less"
> " than current number of present memory slots");
> r = -1;
>- if (busyloop_timeout) {
>- goto fail_busyloop;
>- } else {
>- goto fail;
>- }
>+ goto fail_busyloop;
> }
>
> return 0;
>
> fail_busyloop:
>- while (--i >= 0) {
>- vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
>+ if (busyloop_timeout) {
>+ while (--i >= 0) {
>+ vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
>+ }
> }
> fail:
> hdev->nvqs = n_initialized_vqs;
>--
>2.29.2
>
next prev parent reply other threads:[~2021-02-23 10:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 11:49 [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label Stefan Hajnoczi
2021-02-23 10:53 ` Stefano Garzarella [this message]
2021-02-23 11:15 ` Philippe Mathieu-Daudé
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=20210223105346.ii4ex7no5fd434zi@steredhat \
--to=sgarzare@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@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).