From patchwork Mon Feb 22 11:49:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 1443059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KDGuydF+; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DkgX12HDhz9s1l for ; Mon, 22 Feb 2021 22:51:59 +1100 (AEDT) Received: from localhost ([::1]:42082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lE9kr-0003qI-JY for incoming@patchwork.ozlabs.org; Mon, 22 Feb 2021 06:51:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lE9ii-0002rQ-4K for qemu-devel@nongnu.org; Mon, 22 Feb 2021 06:49:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lE9ig-0005tC-Ix for qemu-devel@nongnu.org; Mon, 22 Feb 2021 06:49:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613994581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tYTo3cly4fpzaMCYqtpm/UrbCHSc2K+BwtgMtLr7EsU=; b=KDGuydF+Uec9w2mnC4jFwDN3TsXlkK9qceljQX1CH+MHG7Cxn3BTmxRYrozHNL0hwdSrV0 iqgmUSw2or2sOAVy9wPWrf+2yrONcMbPiiL20rQK943Jcijnq0dsgg/NMiKOu7e2eK/gQl vCcDNpnJgr8fILh6M6vpfUqwt23eOVo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-128-ex7tngm-OZy5WO1lKfWrPw-1; Mon, 22 Feb 2021 06:49:40 -0500 X-MC-Unique: ex7tngm-OZy5WO1lKfWrPw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37CFC1E561 for ; Mon, 22 Feb 2021 11:49:39 +0000 (UTC) Received: from localhost (ovpn-112-255.ams2.redhat.com [10.36.112.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0156D5D9CC; Mon, 22 Feb 2021 11:49:32 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH] vhost: simplify vhost_dev_init() fail_busyloop label Date: Mon, 22 Feb 2021 11:49:31 +0000 Message-Id: <20210222114931.272308-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Stefano Garzarella Reviewed-by: Philippe Mathieu-Daudé --- 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;