* [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label
@ 2021-02-22 11:49 Stefan Hajnoczi
2021-02-23 10:53 ` Stefano Garzarella
2021-02-23 11:15 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2021-02-22 11:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi, Michael S. Tsirkin
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(-)
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label
2021-02-22 11:49 [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label Stefan Hajnoczi
@ 2021-02-23 10:53 ` Stefano Garzarella
2021-02-23 11:15 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2021-02-23 10:53 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel, Michael S. Tsirkin
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label
2021-02-22 11:49 [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label Stefan Hajnoczi
2021-02-23 10:53 ` Stefano Garzarella
@ 2021-02-23 11:15 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-02-23 11:15 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel; +Cc: Michael S. Tsirkin
On 2/22/21 12:49 PM, 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: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-23 11:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-22 11:49 [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label Stefan Hajnoczi
2021-02-23 10:53 ` Stefano Garzarella
2021-02-23 11:15 ` Philippe Mathieu-Daudé
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).