From patchwork Wed May 29 07:09:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 10966289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC77C912 for ; Wed, 29 May 2019 07:40:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDDC91FFFE for ; Wed, 29 May 2019 07:40:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1D3328775; Wed, 29 May 2019 07:40:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 71C211FFFE for ; Wed, 29 May 2019 07:40:40 +0000 (UTC) Received: from localhost ([127.0.0.1]:49191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVtCR-0000NT-HC for patchwork-qemu-devel@patchwork.kernel.org; Wed, 29 May 2019 03:40:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVsjq-0000ii-9y for qemu-devel@nongnu.org; Wed, 29 May 2019 03:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVsjp-0006UD-F6 for qemu-devel@nongnu.org; Wed, 29 May 2019 03:11:06 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:44335) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVsjp-0006Tw-AE for qemu-devel@nongnu.org; Wed, 29 May 2019 03:11:05 -0400 Received: by mail-pg1-x541.google.com with SMTP id n2so784667pgp.11 for ; Wed, 29 May 2019 00:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=03Gb86KPthOkR7l6zYdtWIDlcvr0+sRNjxvLK/QpGew=; b=hQWpyhYlwSHOhN/SueOAIqFdWmoyD/uiyvQeDhsrU9lwzfY0LR9HcTKxRdk91JOfPu ekvlEx5fk333DQ4OwlJepksehspXut72/mttjMKwOvMVKdtD5hmlAue7v6Rhw5mpat78 JDZxo9vFaFDOSqBQPeseIjQhpG3hcLSJreCa5mZcmLURywxX6m8O1B63PPA+WPNDZW1U yePDGdXd3svxLJR99sPo/qRsyz0aXbxvrVaHSuXA+j7LtJBPNV0glwx2M8M0UQJ/ctKD dzMSy0JVQE/v3w+afuowpVlDtfWTMydjnoWN2fbcSZZ0NS1cQW+X8edRz/GyByqcUWqd 007g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=03Gb86KPthOkR7l6zYdtWIDlcvr0+sRNjxvLK/QpGew=; b=CQCgg9QEtql3JppTt+9XYpJG6JG4oS+Tqsrkm/VDOX7fNrs6TBS/SVxrMJJ4qj135t nfMhHEsoPII/7zx15kFjr38ZsXeNDFSAacYHIJKHuBapsvY2wiU5WvOjv896vC/172OI q/3jjN54OeD/iWFbXK3wYMYqO+fc5kV9UzslVtR58dTwZXha/Xc+buvvGs7n3TZJ7Vm0 /6Vw1CGtyq/yEXZ3s3NqXQN44vkL6K3v5zYcIADV5DL4sKobP2IFVccusqVF85wS3/pV mbHS70pOlr6YN7KyXOv9CbXTIIxEbb1ZjHdMWZxojhHMtqkzyWBYAhcCLTfmyLC7Jo0Y f9iw== X-Gm-Message-State: APjAAAUFwJjzlLmdj8ee56m8q3zGlpGfisHfXVt4iX7uGiPTMQdbvuyU xuwH5QrMJczHw9wlCS2xK7M= X-Google-Smtp-Source: APXvYqx2m0DQRuE0UpGlMyawvNWbiJaTsYKzI5K/s3kFSlKdrsMqG1z59naEXToy/x5J0snGiNVM9Q== X-Received: by 2002:a63:2325:: with SMTP id j37mr135339747pgj.137.1559113864504; Wed, 29 May 2019 00:11:04 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id c127sm17387040pfb.107.2019.05.29.00.11.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 00:11:04 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org, dgilbert@redhat.com Date: Wed, 29 May 2019 15:09:54 +0800 Message-Id: <20190529070955.25565-5-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190529070955.25565-1-xieyongji@baidu.com> References: <20190529070955.25565-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH 4/5] virtio: Don't change "started" flag on virtio_vmstate_change() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xie Yongji , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xie Yongji We will call virtio_set_status() on virtio_vmstate_change(). The "started" flag should not be changed in this case. Otherwise, we may get an incorrect value when we set "started" flag but not set DRIVER_OK in source VM. Signed-off-by: Xie Yongji --- hw/virtio/virtio.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8a81374492..9e17293d46 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1162,9 +1162,13 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val) } } } - vdev->started = val & VIRTIO_CONFIG_S_DRIVER_OK; - if (unlikely(vdev->start_on_kick && vdev->started)) { - vdev->start_on_kick = false; + + if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) != + (val & VIRTIO_CONFIG_S_DRIVER_OK)) { + vdev->started = val & VIRTIO_CONFIG_S_DRIVER_OK; + if (unlikely(vdev->start_on_kick && vdev->started)) { + vdev->start_on_kick = false; + } } if (k->set_status) {