From patchwork Wed Nov 2 16:09:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 620839 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp4409731pvb; Wed, 2 Nov 2022 09:11:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7iSrMudfKv0fsDW5dFAzrg7VoUFOeQP9RDIp1sJreGnHjjaUDQiH4hkxPiqYkwnR/pHM2k X-Received: by 2002:a05:620a:13e1:b0:6fa:3f2c:c62e with SMTP id h1-20020a05620a13e100b006fa3f2cc62emr9574071qkl.251.1667405490718; Wed, 02 Nov 2022 09:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667405490; cv=none; d=google.com; s=arc-20160816; b=Jlame72bjbU54WcWgGev9A369d83+omPbPEomc/5pca8Xf2pPU4fqQbUVC6qzA0M2u dEpWvqBb7BI+MRdp00wU2lU1//noyXPvDV7YLMn9gzjDMptnc1NHdniOvrW9+/XrypIL lPmmZSOpn/4CSEbqWZHj5lI9UeFRVhFcLvntU9Ql4Hw9JdWFU0LR+Gu9QhtqX3IG57TG fWOh6dRtUYQgF/0ZQwwJoW+3mLedxewz5la9iHBIUOPCYDs3Y5BSEjZL3F2bVcS2mJjC PjwEr4BbGVAEdyCu0o8ZfQb65SQ0auMJVGjhRaS2CPg4dImkMEdaQ/BS7klml+5p9sKR 6KZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6cIEnv/B6TNmwuy+yjMUUsEZp+0oTgySRy8CBJkVXno=; b=So1bmWE+Gy/aMlr4XPxPIayjnUm+QxwBnBTk0YyVls8J8v3k5ArBkjeCJEMawtSyhA bxUkJolQjh1Sn2TXcbgH845YuHvNzs0ERhCUfjjDTba5CtN3oFEBHrKMGy8XgA+7LzZ3 yxfWYnBlWhfy4v0jDn7txuBMsRPS9UEKCVYsQ6qtMGHIGEKeoHRucGRSQBqoWysfm2kN +zwZaWLW3KIgzSY6ZY9Zk7/u4OfGPwxTfx52Zbonl1w2RR5iKqcGxysB3leDOqstpzNk t04gIUCgi427n/LsshSSoqbB7d5oLd4NLjRuvdjb/f7X0et1a2HVhUxsG3BDr462KmyJ ScMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J6rH5oqJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b34-20020a05620a272200b006fa509fd0besi2741814qkp.634.2022.11.02.09.11.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Nov 2022 09:11:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J6rH5oqJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqGJe-0006J5-4f; Wed, 02 Nov 2022 12:10:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqGJa-00069i-Ay for qemu-devel@nongnu.org; Wed, 02 Nov 2022 12:10:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqGJV-0002c0-Pz for qemu-devel@nongnu.org; Wed, 02 Nov 2022 12:10:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667405401; 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: in-reply-to:in-reply-to:references:references; bh=6cIEnv/B6TNmwuy+yjMUUsEZp+0oTgySRy8CBJkVXno=; b=J6rH5oqJ3EA2+HkvrNLRx+jrDYUpBFYRAg+yLuAvacQIWnazxlVF1fjlWoa8N90p/FSj+R HYGo2HLBm+i/1EDYUpKNncl1VxX7VjlytOTQ4ErOKRtKjaJp6IDkJpEuR7UnFRzhF/XZR5 lbbFNEt986hZoCymK6bUTgxzgkyp6N8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-457-KVWgaSKcMoylhKBfQ1x_MA-1; Wed, 02 Nov 2022 12:10:00 -0400 X-MC-Unique: KVWgaSKcMoylhKBfQ1x_MA-1 Received: by mail-wm1-f70.google.com with SMTP id 9-20020a1c0209000000b003cf6fce8005so519063wmc.9 for ; Wed, 02 Nov 2022 09:09:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6cIEnv/B6TNmwuy+yjMUUsEZp+0oTgySRy8CBJkVXno=; b=hswpenK21DfKndBx+3VXFNjNXpBD/7selFekSK3PQzMbMT+PWOsVsBP5vtqadVOkZa quoQC45I+pdmPxQiGIR8IL65NdiCp7BgL2A+wRaggiUuxofS5BKnOFxNkd1uiqzQ5nZ4 QxF6hxohwviJzhfYVbgiC+7K6k8n4mSmDTd7Sfhb7xkIKJgkipv0QkP0TnNT4J24xa+/ m4/SBnFtrm4y5vxjaNdWYU6AeL7QhPHqKfvHeZ7l0WZakjH8KPCWVuAPANZxnVPD8NIj 0mo/PcShzI8u0lcaUTf6jkC94EOuEfbctZb7uil+zedb5RZ7io1P9DGNGf3L8LmXOZZs 16Fg== X-Gm-Message-State: ACrzQf0EiI5mb3ba6Mxggltv0vM3hG8VDk81kEAejp6KfUH+eK+Pvi6c l/SdExk4nHFvR7ZI8SZKamzk+0mWzP6TTVdVQ87Pz94gjYWk/7QQikhZgK4B8EBSbi/46ef7JhB HnIvSEv99n/1VjnNc8dOvtjJ6UdSPMUBO0uJImDJ9j5xxxlt68J9oZxKEfavK X-Received: by 2002:a05:600c:3655:b0:3cf:7082:dc18 with SMTP id y21-20020a05600c365500b003cf7082dc18mr11745827wmq.36.1667405398481; Wed, 02 Nov 2022 09:09:58 -0700 (PDT) X-Received: by 2002:a05:600c:3655:b0:3cf:7082:dc18 with SMTP id y21-20020a05600c365500b003cf7082dc18mr11745802wmq.36.1667405398206; Wed, 02 Nov 2022 09:09:58 -0700 (PDT) Received: from redhat.com ([2.52.15.189]) by smtp.gmail.com with ESMTPSA id co4-20020a0560000a0400b002238ea5750csm16421280wrb.72.2022.11.02.09.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:09:57 -0700 (PDT) Date: Wed, 2 Nov 2022 12:09:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Christian Borntraeger , Philippe =?utf-8?q?Mathi?= =?utf-8?q?eu-Daud=C3=A9?= Subject: [PULL v2 34/82] virtio: re-order vm_running and use_started checks Message-ID: <20221102160336.616599-35-mst@redhat.com> References: <20221102160336.616599-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221102160336.616599-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.048, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée During migration the virtio device state can be restored before we restart the VM. As no devices can be running while the VM is paused it makes sense to bail out early in that case. This returns the order introduced in: 9f6bcfd99f (hw/virtio: move vm_running check to virtio_device_started) to what virtio-sock was doing longhand. Signed-off-by: Alex Bennée Cc: Christian Borntraeger Message-Id: <20221014132108.2559156-1-alex.bennee@linaro.org> Tested-by: Christian Borntraeger Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index f41b4a7e64..ebb58feaac 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -385,14 +385,14 @@ static inline bool virtio_is_big_endian(VirtIODevice *vdev) static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) { - if (vdev->use_started) { - return vdev->started; - } - if (!vdev->vm_running) { return false; } + if (vdev->use_started) { + return vdev->started; + } + return status & VIRTIO_CONFIG_S_DRIVER_OK; }