From nobody Sat Apr 27 17:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561516453; cv=none; d=zoho.com; s=zohoarc; b=DFk25CatKlVy3HEoYj0HskZ5qU1yCj5AowFWZ3lU5BlIGoHXwxTst6zyRugrmVrRraMxo2JrQt2svlWY0MDl3hyTLiJS8tdX7bg/3E9qWQTaIBE8yfXywWmVRWHm84345uNX9NwfAjJHEENsqZQVz8VFuX39632vUmy62rVGCOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561516453; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=I/bjLTd/1YHMTbglHk1uwq049G1bbJuk0nNR9Wo1Qg8=; b=N0KKmLicYFv48uowHQsJwdrFixJAUfbaXDEqtrf83wANymXpJCtQO8CwQG+Dj9Ccd0whtSKaQzIvO4L5qdsWCxSnVzNUIJ/hri6wVeF0bwIFb02lE/Jq1pd3lVCRUNyDM5dRJfg0zUJTTViYWJtIURWE/Lj0dmnaHBvljQIuqf8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561516453926183.6776353715926; Tue, 25 Jun 2019 19:34:13 -0700 (PDT) Received: from localhost ([::1]:36322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxlB-0002lX-Rq for importer@patchew.org; Tue, 25 Jun 2019 22:34:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48225) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxjH-0001Vx-Ml for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfxj9-0001iI-GG for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:06 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:33043) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfxj5-0001c2-NC for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:01 -0400 Received: by mail-pl1-x643.google.com with SMTP id c14so528529plo.0 for ; Tue, 25 Jun 2019 19:31:56 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id n184sm15472697pfn.21.2019.06.25.19.31.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 19:31:55 -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=I/bjLTd/1YHMTbglHk1uwq049G1bbJuk0nNR9Wo1Qg8=; b=hWtLGl8F5bjoBgvNPJQ2MczWAYTA3EDi+arSvUINmh9JvC9HhV5pXMl5qoo5tONQLN vU9245UYjLChENsNWSVW9quwmGBqYGRmghdxoVoVYHv+0pVD6keTeXK4lBq9tWyT1Uhk McrpiOCgM5NE9WJJ5qUV1QEBgy2vWB8zkTAWH3hjyPgzq95PGimrU2E9Vbnq1AnSMHI7 id6r2xgLnoZilUJ7Dw465jBKlWMQLQzRdBd8B5n9jF9yvD4iqWWhpCC8zwqWWnAT8hug YQpOz6dnYZ5FyIUH3y2gTOAg5i7op/jVYH0mSxTwQ5nDJAaaN0fSB3JQepOqa/rK8CE2 /xfA== 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=I/bjLTd/1YHMTbglHk1uwq049G1bbJuk0nNR9Wo1Qg8=; b=fBhAILC1ZvflgDXCfmM48DCt5UONhF+xG6fKba8DQlz/jXpyj2hFXZx58OicYi8kLg us4ccOqkl6BbZyIzYDkRCklqFa4DKOmyAW5rLTGHmtWqqIbxl46SU/eAjeZB4R5/pbaH X+uGpnCRT9blPwA4Rw1X6/lLcDXgc6BW8KjwImikfgIw8A9q3szfkWAVp62nPrqyLWgw 9Zd1DIwpwdq3dJi6j62fNiCzRxNV/eeNrC4OA5/cODnXesIj1fqRK4GW+rWWD/nRWMxK OuQMHFOC6GrWY9JYVBloAeVxi7YHWmrsotBfo2Ioq0KkmopUeDFWdWXnxMsEj8alPV+m Je8A== X-Gm-Message-State: APjAAAXPeRBkGl3T6JK8aiNwgqh38i5MUIJ+T/ubVB2MtlfkubRiybeW KKVSlIP52BGQXgKjWSv9G3E= X-Google-Smtp-Source: APXvYqxv6bHA0DyR8WZw3TpjBkOkjddwCN/jRgHbFDfO07slB+wNsyb9e1Fa6IPFl1DdI1fEZTbAzQ== X-Received: by 2002:a17:902:684:: with SMTP id 4mr2217225plh.138.1561516315608; Tue, 25 Jun 2019 19:31:55 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Wed, 26 Jun 2019 10:31:26 +0800 Message-Id: <20190626023130.31315-2-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626023130.31315-1-xieyongji@baidu.com> References: <20190626023130.31315-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::643 Subject: [Qemu-devel] [PATCH v4 1/5] virtio: add "use-started" property 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: lvivier@redhat.com, ehabkost@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, Xie Yongji Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Xie Yongji In order to avoid migration issues, we introduce a "use-started" property to the base virtio device to indicate whether use "started" flag or not. This property will be true by default and set to false when machine type <=3D 4.0. Suggested-by: Greg Kurz Signed-off-by: Xie Yongji Reviewed-by: Greg Kurz Tested-by: Greg Kurz --- hw/block/vhost-user-blk.c | 4 ++-- hw/core/machine.c | 1 + hw/virtio/virtio.c | 18 +++++++----------- include/hw/virtio/virtio.h | 21 +++++++++++++++++++++ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9cb61336a6..85bc4017e7 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -191,7 +191,7 @@ static void vhost_user_blk_stop(VirtIODevice *vdev) static void vhost_user_blk_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserBlk *s =3D VHOST_USER_BLK(vdev); - bool should_start =3D vdev->started; + bool should_start =3D virtio_device_started(vdev, status); int ret; =20 if (!vdev->vm_running) { @@ -317,7 +317,7 @@ static int vhost_user_blk_connect(DeviceState *dev) } =20 /* restore vhost state */ - if (vdev->started) { + if (virtio_device_started(vdev, vdev->status)) { ret =3D vhost_user_blk_start(vdev); if (ret < 0) { error_report("vhost-user-blk: vhost start failed: %s", diff --git a/hw/core/machine.c b/hw/core/machine.c index ea5a01aa49..ea84bd6788 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -30,6 +30,7 @@ GlobalProperty hw_compat_4_0[] =3D { { "bochs-display", "edid", "false" }, { "virtio-vga", "edid", "false" }, { "virtio-gpu-pci", "edid", "false" }, + { "virtio-device", "use-started", "false" }, }; const size_t hw_compat_4_0_len =3D G_N_ELEMENTS(hw_compat_4_0); =20 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e1e90fcfd6..c9a6ca04b8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1162,10 +1162,8 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t va= l) } } } - vdev->started =3D val & VIRTIO_CONFIG_S_DRIVER_OK; - if (unlikely(vdev->start_on_kick && vdev->started)) { - vdev->start_on_kick =3D false; - } + + virtio_set_started(vdev, val & VIRTIO_CONFIG_S_DRIVER_OK); =20 if (k->set_status) { k->set_status(vdev, val); @@ -1536,8 +1534,7 @@ static bool virtio_queue_notify_aio_vq(VirtQueue *vq) ret =3D vq->handle_aio_output(vdev, vq); =20 if (unlikely(vdev->start_on_kick)) { - vdev->started =3D true; - vdev->start_on_kick =3D false; + virtio_set_started(vdev, true); } } =20 @@ -1557,8 +1554,7 @@ static void virtio_queue_notify_vq(VirtQueue *vq) vq->handle_output(vdev, vq); =20 if (unlikely(vdev->start_on_kick)) { - vdev->started =3D true; - vdev->start_on_kick =3D false; + virtio_set_started(vdev, true); } } } @@ -1579,8 +1575,7 @@ void virtio_queue_notify(VirtIODevice *vdev, int n) } =20 if (unlikely(vdev->start_on_kick)) { - vdev->started =3D true; - vdev->start_on_kick =3D false; + virtio_set_started(vdev, true); } } =20 @@ -2291,7 +2286,7 @@ static void virtio_vmstate_change(void *opaque, int r= unning, RunState state) VirtIODevice *vdev =3D opaque; BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); - bool backend_run =3D running && vdev->started; + bool backend_run =3D running && virtio_device_started(vdev, vdev->stat= us); vdev->vm_running =3D running; =20 if (backend_run) { @@ -2669,6 +2664,7 @@ static void virtio_device_instance_finalize(Object *o= bj) =20 static Property virtio_properties[] =3D { DEFINE_VIRTIO_COMMON_FEATURES(VirtIODevice, host_features), + DEFINE_PROP_BOOL("use-started", VirtIODevice, use_started, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 27c0efc3d0..15d5366939 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -105,6 +105,7 @@ struct VirtIODevice uint16_t device_id; bool vm_running; bool broken; /* device in invalid state, needs reset */ + bool use_started; bool started; bool start_on_kick; /* virtio 1.0 transitional devices support that */ VMChangeStateEntry *vmstate; @@ -351,4 +352,24 @@ static inline bool virtio_is_big_endian(VirtIODevice *= vdev) /* Devices conforming to VIRTIO 1.0 or later are always LE. */ return false; } + +static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t statu= s) +{ + if (vdev->use_started) { + return vdev->started; + } + + return status & VIRTIO_CONFIG_S_DRIVER_OK; +} + +static inline void virtio_set_started(VirtIODevice *vdev, bool started) +{ + if (started) { + vdev->start_on_kick =3D false; + } + + if (vdev->use_started) { + vdev->started =3D started; + } +} #endif --=20 2.17.1 From nobody Sat Apr 27 17:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561516455; cv=none; d=zoho.com; s=zohoarc; b=I9IJxCx1KRTio4XCx15aOUdkuy6aHD6ZW+0+unosnN3oZiiKZDFHTQ05BdJ7u3DjEGuHxlHgh/s6BPX578BNH34o4o4G439Pn7jpw2AlIxFSvsIedvWRUfhyMTZtbbcLyJrBrYZF4nvHCZSsBGjrScQa8ilAvDIwulxSWXfNmEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561516455; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZANkgcEABhOltym3gLKIP0mcuZJzRoKGZl25eRTEJFU=; b=g7K4GLwE2yiJb6c7wHTcUnwejVNjqTLAiSooxlYTlnQbfKic9dVvfNQTjBwlKdvDs+YktQCAGvWlD7CFYvgtytqvy49yiEZNDk7LHadNhVdQormBCZgkt9CzmShD9sGPZau2AmWt/3VEqAV39BuoZRGdbx/VWFCF7mfewyD8liE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561516455851483.45696985346365; Tue, 25 Jun 2019 19:34:15 -0700 (PDT) Received: from localhost ([::1]:36320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxlA-0002jr-9h for importer@patchew.org; Tue, 25 Jun 2019 22:34:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48227) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxjH-0001Vy-Nj for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfxj9-0001jE-NY for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:06 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:47075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfxj9-0001fG-Fd for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:03 -0400 Received: by mail-pg1-x52e.google.com with SMTP id v9so386699pgr.13 for ; Tue, 25 Jun 2019 19:31:59 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id u2sm353994pjv.9.2019.06.25.19.31.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 19:31:58 -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=ZANkgcEABhOltym3gLKIP0mcuZJzRoKGZl25eRTEJFU=; b=J2LQS1kRcu5HSJZh6fvzxCSTxlLQ8agb0MsunsieFMLh4JXQgrYXAzhI1uImXHLDlN bYOkVJdDAqZa5zQIelaB3vDIOjhAjJiOh7GWIKDQCu639PSt8dZ3gF2Hx9zqUYgyqzpj PPhYw2H8QB3kTfVDFVUPkVF28GMJPlKJOIHGYdKo8Z0u/AiszeFlWOOT8LQK4/p+jAbi 9Mllp8OGiygWZxbZeRtHVwRpxxzuc3vbq6cRhfxNICR6F51HxGn3JT/fb8Fcr/n7PDQT owwVk5/Sm1aWG0tMGgvivsHCbPcyRls0w9S/t0Mv/QsQ2L8zGqOiaX5QgUN0I7iKFHf5 u7Fw== 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=ZANkgcEABhOltym3gLKIP0mcuZJzRoKGZl25eRTEJFU=; b=eKvij9FQK1/LNrGEr85jhmnX/PfIRYYJepD0gl1kRzeyCU6M6/1FGtCQJFl5SOhPG2 2XrOHSeLN2uWWkLn2fDHgfGnvk8NcuMeq0iU6+N9KeD4Fe9RZsa9UF2EJkDigm2yT1DB Och1OCM1sDDoIk6wUCndOzVOLNz7l7W0pIMm2ueS9L2BimmL7nMVFyRmNZTnayhnB6nk ODf9qivncv0P0Nr14pkkYalFVlo0qW2zrYFBJVT1piw+JxPWPkRMooo7PbtYZaBgprnV ET7JnXhuWt0E/ZOOyilC2dt59jG04btR+gGApRxRkXg/u05HGmjDK+y9p99PVYUkf036 z5Gw== X-Gm-Message-State: APjAAAUpxFFm5w72zmGqbzAnABvetH7bhgvcCEUwJg3qiyGl01VYhfcn XaVPGxsYI6X2x1x8Z0f+hxg= X-Google-Smtp-Source: APXvYqxX351UP6VCQEt1E9bLS6Rbd09cht0WglPjQrU07cQRkoyBUm3aYnzuE+Uj7osajhgvlBMRwA== X-Received: by 2002:a65:418d:: with SMTP id a13mr281245pgq.332.1561516318808; Tue, 25 Jun 2019 19:31:58 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Wed, 26 Jun 2019 10:31:27 +0800 Message-Id: <20190626023130.31315-3-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626023130.31315-1-xieyongji@baidu.com> References: <20190626023130.31315-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::52e Subject: [Qemu-devel] [PATCH v4 2/5] virtio: Set "start_on_kick" for legacy devices 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: lvivier@redhat.com, ehabkost@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, Xie Yongji Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Xie Yongji Besides virtio 1.0 transitional devices, we should also set "start_on_kick" flag for legacy devices (virtio 0.9). Signed-off-by: Xie Yongji Reviewed-by: Greg Kurz --- hw/virtio/virtio.c | 6 ++---- include/hw/virtio/virtio.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index c9a6ca04b8..f7504d1395 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1212,8 +1212,7 @@ void virtio_reset(void *opaque) k->reset(vdev); } =20 - vdev->start_on_kick =3D (virtio_host_has_feature(vdev, VIRTIO_F_VERSIO= N_1) && - !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_= 1)); + vdev->start_on_kick =3D !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSIO= N_1); vdev->started =3D false; vdev->broken =3D false; vdev->guest_features =3D 0; @@ -2325,8 +2324,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, g_malloc0(sizeof(*vdev->vector_queues) * nvectors); } =20 - vdev->start_on_kick =3D (virtio_host_has_feature(vdev, VIRTIO_F_VERSIO= N_1) && - !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_= 1)); + vdev->start_on_kick =3D !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSIO= N_1); vdev->started =3D false; vdev->device_id =3D device_id; vdev->status =3D 0; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 15d5366939..b189788cb2 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -107,7 +107,7 @@ struct VirtIODevice bool broken; /* device in invalid state, needs reset */ bool use_started; bool started; - bool start_on_kick; /* virtio 1.0 transitional devices support that */ + bool start_on_kick; /* when virtio 1.0 feature has not been negotiated= */ VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; --=20 2.17.1 From nobody Sat Apr 27 17:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561516700; cv=none; d=zoho.com; s=zohoarc; b=UcAs5VbXck/aZGGUiTLH6ciTcocPnDl5Z/AB7k1x0nLoaixrtiX6aTxSaUoRahj4rRYQIa1MGWWO2/1toeMQfMq+K9c9BcKGdxv8dj3FTF3jUtCL6gkRLFCX3+VjiU9WZmNaqb65KjMFKO1SGaml2yV1TJr/2Xxgq5Voez58sns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561516700; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hL8K5Kz2dooDS7h4mI8LPQsh2fPsmgF3Cej6yW+tB9U=; b=iX64hTfliB1ROM6ED8GYiEuiCHtxz0auWNGeh+L4lX4ST5iMxLpQ+9VKqdKqsDmsIFMU5hBkRVCpanAjRbfu4Ey//Vd7WlO2dSvttgHv8qbOQQbwHu5Fl15nEacFBqMRD+FKs6BZ06Nc0SuMVIGSJ4OTaS+pSphojSLa2NnNuRk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561516700015756.341293429233; Tue, 25 Jun 2019 19:38:20 -0700 (PDT) Received: from localhost ([::1]:36340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxp7-0005tr-Vx for importer@patchew.org; Tue, 25 Jun 2019 22:38:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48230) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxjH-0001Vz-O0 for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfxj9-0001jU-Qq for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:06 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:36082) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfxj9-0001hJ-Iv for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:03 -0400 Received: by mail-pl1-x644.google.com with SMTP id k8so520452plt.3 for ; Tue, 25 Jun 2019 19:32:02 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id y16sm21043219pff.89.2019.06.25.19.32.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 19:32:01 -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=hL8K5Kz2dooDS7h4mI8LPQsh2fPsmgF3Cej6yW+tB9U=; b=MjQ4nGV2MX4jdP0vA4TQ7mJgoitzIHWqQD+d8oxOhMboAfiEOBq/HvnsL2XdXEIMb7 lqNio7vmqciecdeHoSh6JpHVvs4U2Gx561vUvM8KLgy4Ai54HhZqLaFs1dGEBfmy1PlQ uOCYTDrUHQ8Wg/X017hXrWGddFQhmyqahG5lnmGqCCDWBOpEV0/RQEKz/lJhCQ8JJtVP wnDaBHPOs9IabFN9glr09tOoKlzi7hzy71nqceN0/UXNI6UHBuy+6SxdzV7nhdStAouD h0HE5bjPUmfRw2LYar/l50OZP8qYGzPp7lir8rDtpEn5ol0Y9bMPMe/qwUJxX+2Uh0J2 P2qA== 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=hL8K5Kz2dooDS7h4mI8LPQsh2fPsmgF3Cej6yW+tB9U=; b=APMDWkwjIAb1O1Z6fvIB2VaAk5Z0R3+N5q6esJdWkW49IIVRkzONJn0iC2TtHKxVBD qCO8WOj8WaXpkX860lBNc3KgNs3zEXpsnqPoGltVVdAxC8FcsMESk7Md+YY8E5IJDJB5 Ls87fPTBy8R4dhDJJVyvARHWINYmzkQfL/UTAu57eFVLQ/5hzvy8s8xypAaG+cxEE9So zKlMcMh8pHAH8JnxDMOOpQCKvpTLFCBAKZXL4L5e7ATcnTa9DKAxq14MKiqDPnGlZ/be jDryacPl6UmPvReDY9q1/x6PVtG3Qa/bq2gC59xmzOKUveyGNLw6TyxjtuRWjmBKrOHb peVA== X-Gm-Message-State: APjAAAVRU1WQf2Ld+TRIetKQd9jcT5hvLO/RpRElW+BIf+pq6h3uscwZ i5Mvh3XaGDSBisu5FTlYcbQ= X-Google-Smtp-Source: APXvYqxN97+rj8d7/wycLADPgymISub6wgYCxHgzR8Ry4dOT+EVsTcXiATpmTYhq7Y4zPnchQCIJlQ== X-Received: by 2002:a17:902:e01:: with SMTP id 1mr2231993plw.268.1561516322032; Tue, 25 Jun 2019 19:32:02 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Wed, 26 Jun 2019 10:31:28 +0800 Message-Id: <20190626023130.31315-4-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626023130.31315-1-xieyongji@baidu.com> References: <20190626023130.31315-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::644 Subject: [Qemu-devel] [PATCH v4 3/5] virtio: Set "start_on_kick" on virtio_set_features() 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: lvivier@redhat.com, ehabkost@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, Xie Yongji Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Xie Yongji The guest feature is not set correctly on virtio_reset() and virtio_init(). So we should not use it to set "start_on_kick" at that point. This patch set "start_on_kick" on virtio_set_features() instead. Fixes: badaf79cfdbd3 ("virtio: Introduce started flag to VirtioDevice") Signed-off-by: Xie Yongji Reviewed-by: Greg Kurz --- hw/virtio/virtio.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index f7504d1395..5fd25d98a9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1212,7 +1212,7 @@ void virtio_reset(void *opaque) k->reset(vdev); } =20 - vdev->start_on_kick =3D !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSIO= N_1); + vdev->start_on_kick =3D false; vdev->started =3D false; vdev->broken =3D false; vdev->guest_features =3D 0; @@ -2063,14 +2063,21 @@ int virtio_set_features(VirtIODevice *vdev, uint64_= t val) return -EINVAL; } ret =3D virtio_set_features_nocheck(vdev, val); - if (!ret && virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { - /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches. */ - int i; - for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { - if (vdev->vq[i].vring.num !=3D 0) { - virtio_init_region_cache(vdev, i); + if (!ret) { + if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { + /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches. */ + int i; + for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { + if (vdev->vq[i].vring.num !=3D 0) { + virtio_init_region_cache(vdev, i); + } } } + + if (!virtio_device_started(vdev, vdev->status) && + !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { + vdev->start_on_kick =3D true; + } } return ret; } @@ -2222,6 +2229,11 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int= version_id) } } =20 + if (!virtio_device_started(vdev, vdev->status) && + !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { + vdev->start_on_kick =3D true; + } + rcu_read_lock(); for (i =3D 0; i < num; i++) { if (vdev->vq[i].vring.desc) { @@ -2324,7 +2336,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, g_malloc0(sizeof(*vdev->vector_queues) * nvectors); } =20 - vdev->start_on_kick =3D !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSIO= N_1); + vdev->start_on_kick =3D false; vdev->started =3D false; vdev->device_id =3D device_id; vdev->status =3D 0; --=20 2.17.1 From nobody Sat Apr 27 17:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561516712; cv=none; d=zoho.com; s=zohoarc; b=CGojNYphxRnhp+3mmUiKNutjedufOhCvg/K3d7vUIGydaOx2jU1ra4dcuGJU1Xzgjpi/SOxCb80h0nzHsg374s44VjQiseOhDfiphmplyxnrqW9n/w8/FpKO8SYxsHRC1eLy9aQhld51fnkKA6UxVMklubgQPRr6V41qMzooHl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561516712; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IRZxfIBWQYVYbj7iYvlX3G7D8+JN2aZ0YIiAZvFz7kI=; b=DW/Zi5+ClKODgD/JME8vSsV4W/jN0adOeUk0a/czjBjyTzKbBn7l9hsAadpn17YQbqvSQtsvq4HyBHIIjlwqCtKsdCAZayjUz4eI7N5uip6wGOACpxoieuSLNFsQ71yyg8ymOvRNXszjt8KgPYA+eNEexSaVfIFGaKELITFvglI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561516712014336.6773639734464; Tue, 25 Jun 2019 19:38:32 -0700 (PDT) Received: from localhost ([::1]:36342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxpM-0005wX-2B for importer@patchew.org; Tue, 25 Jun 2019 22:38:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48372) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxjP-0001Yq-Sg for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfxjN-00020v-Gl for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:19 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:43702) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfxjL-0001lP-C4 for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:15 -0400 Received: by mail-pg1-x543.google.com with SMTP id f25so393657pgv.10 for ; Tue, 25 Jun 2019 19:32:06 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id 30sm341032pjk.17.2019.06.25.19.32.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 19:32: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=IRZxfIBWQYVYbj7iYvlX3G7D8+JN2aZ0YIiAZvFz7kI=; b=ku+Uu4DY1q1G+NrrF4UG5WsLr7HSDTnS1CBnoHpdXnb/fLmjN+n5P6nALPs93ACScA 8e7i8t/8rnwN/lm3psF1zJsL+UwgwMy3EuYgJbI28o0u/6cF/BCgmzRuv5NxQR2yc4dM NGtzUVfNaWE7zkyO7j6dqBFnVrjPtNRFYwl1M0J17YICXo+s4aRl2zJI6MQDc+r0extq ZRnrATH9q6q/9yOo4OP9V3VxTSqWnb2nY5f8bscD+rtivD3wfPqa7vf0H/Ie2Xmdvl0Y Pt0UqLtUGsfgFXf2vilh62MUNaQ02Wjc2n3hMMXABmex5hkQ22J3qoGTDqYmjPMr4gjy W6Sw== 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=IRZxfIBWQYVYbj7iYvlX3G7D8+JN2aZ0YIiAZvFz7kI=; b=qLHbRtaosvyJHaEH4B4OBB+bNdVqPO9K7c5L4FeoP1wv41XnLoknsQ6QVyIf9AnrgS 6Ry7PU1DLjvvNiIsGHxmgBv8oyT0TEgcNpH3pHGd/OBE9Qd3SeJGDqCeEHuuUlgnnalp zA9OQJ1AS2Y0/L5JiX8qudBGTpWS2T+z/mAIkn14UIhEv1LzHVz8fJ3UNydBuUSSJU8c uy4InS2U59kyaT4vUXf4gIqpMOmCpHVRNnc0JGvTL04cuTRIaTgGVTn929GQh1RBtZBa vnNKULRyBCk3ocoGrdfxQwfOJbPaktRdazmKB5IhWU3rSAQKHeO84d3TqcFFoE8StxZB AH8Q== X-Gm-Message-State: APjAAAVwG+WaPciFZm8cBhzjaJfkNLn1CNcR9jZjicJxRnnzRXtXjdux hfdGiPZLe5KoFO8kCrxerPc= X-Google-Smtp-Source: APXvYqxh7ptZOf6BKv6W6talr2pQpF3kmDVD9d3OAyBG8JgePtIaA9nTC6D/pbgPx+p7WMFd2LtKgw== X-Received: by 2002:a17:90a:3585:: with SMTP id r5mr1414694pjb.15.1561516325699; Tue, 25 Jun 2019 19:32:05 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Wed, 26 Jun 2019 10:31:29 +0800 Message-Id: <20190626023130.31315-5-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626023130.31315-1-xieyongji@baidu.com> References: <20190626023130.31315-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::543 Subject: [Qemu-devel] [PATCH v4 4/5] virtio: Make sure we get correct state of device on handle_aio_output() 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: lvivier@redhat.com, ehabkost@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, Xie Yongji Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Xie Yongji We should set the flags: "start_on_kick" and "started" after we call the kick functions (handle_aio_output() and handle_output()). Signed-off-by: Xie Yongji --- hw/virtio/virtio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 5fd25d98a9..e098fc8ef0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1571,10 +1571,10 @@ void virtio_queue_notify(VirtIODevice *vdev, int n) event_notifier_set(&vq->host_notifier); } else if (vq->handle_output) { vq->handle_output(vdev, vq); - } =20 - if (unlikely(vdev->start_on_kick)) { - virtio_set_started(vdev, true); + if (unlikely(vdev->start_on_kick)) { + virtio_set_started(vdev, true); + } } } =20 --=20 2.17.1 From nobody Sat Apr 27 17:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561516714; cv=none; d=zoho.com; s=zohoarc; b=cbFXFNqKatcFfvA9aKUxmA5LMAHyk5DIgcmhAQdapvFq2uX0PQWOgr3xQ/7YLyEOjMkuVhPFV4co/eLBQDE6ilkxQT9oYJzXXuJfPLLN0qxt/V/QzYNZNEYeDYNNsxThEeIROo/xVtaM2Bdla4dJ0Pj43cQkocqbrpclz/uzXN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561516714; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8MJqz+TiFePml7vV+waCP1DUA2DS40UgJSmuxu49ueA=; b=eYIaBzX88SwkUZ/R1Z8QaCSdAoAtw2TjHnZp5uDyWYd2oS+9QTEH+pAi4LFVLw1yLFZvEHWisvYzUk7kZ6dfwdt8L/ITZ7XMrNyhATNHveDSPwFvajwtYxP9HB7/AR6e3XX822DYklP8w1XQYerPQFsE0ir3zyft+1vRQj4kT60= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561516714446360.7818972511193; Tue, 25 Jun 2019 19:38:34 -0700 (PDT) Received: from localhost ([::1]:36344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxpP-00061J-H3 for importer@patchew.org; Tue, 25 Jun 2019 22:38:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48376) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfxjP-0001Yv-Th for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfxjN-00021n-MZ for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:19 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:33238) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfxjN-0001p7-Ch for qemu-devel@nongnu.org; Tue, 25 Jun 2019 22:32:17 -0400 Received: by mail-pg1-x541.google.com with SMTP id m4so418522pgk.0 for ; Tue, 25 Jun 2019 19:32:10 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id t5sm16256309pgh.46.2019.06.25.19.32.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2019 19:32:08 -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=8MJqz+TiFePml7vV+waCP1DUA2DS40UgJSmuxu49ueA=; b=Jq2pFT21SogPA8uk6WWe+O8YpfocN0ejdVfo07PAHg8bCrS8cTMyfyv7obWsaVtg64 uk2ssvi0EzdFCoNZqjO2jNmA8Q3pzbma0kivweJHmTEMO+FcNr/ueeBcAMptlAF5Lvyq CtOkiVVk6UrYaB2VKvUeLnf/4F8MahgPOv7ITJ46uItz6m8oOh2gWeT2cv0YNoM7Muio gZImUsJbV4nx7bCdw1N71zJuagTMwOjSn+Gq3P1gM8OTVkQi/cnmo8jxFKo/zZum6mQo ZThroV4ztM7kUS9E8wEg9EoQM0YDWQpaJ8QfTyvNfwnqQ0I3lRjZO66C0Us02jWmolLH d+qA== 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=8MJqz+TiFePml7vV+waCP1DUA2DS40UgJSmuxu49ueA=; b=U5w9+ob6FRrFo27doBFCKZEBaVJB9MGSTE2tvO+hyP0wmVhPZaEZ8dDcb2Fvc61Bog lKahjz1BUzswUINy5Bf0WUl0gtgDhbgJ6d1w8ph1nzgJulMj/yGxgIfHcmjLCyX6RpRf yOjfEW2zdBMqhP31NaHAWv4e193VH7kubuUy2zAtRYkTWPIMR8dT0IaYamyxDE9PLAv6 OT9YpnBQT6Wkkk5h55W+raevK96OHl7hiV72WBY9Igb9lXqhg81aJq+bEd2vjgBKR48C iNYZ9H7rHWOEozkuumsidR8edJWOR+WgGvChLOHsJy9HRr2lsTXJk+DWyB91mveyFEaq gvGw== X-Gm-Message-State: APjAAAWIY81P2VF/EOkJ+bX73SChSzYVP9l8IiC2g1DhLZahJGjMD8hR 6QBD56BqSLgUnmoZnJYEEdQ= X-Google-Smtp-Source: APXvYqwSCbQ1vpcbDv/QpqbgiwvloC+qEMXNIwGSoF2CTmUKbPqyCTjHZyPMcE6Mfl2/5vbzJ6azYA== X-Received: by 2002:a63:f746:: with SMTP id f6mr297876pgk.56.1561516329240; Tue, 25 Jun 2019 19:32:09 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Wed, 26 Jun 2019 10:31:30 +0800 Message-Id: <20190626023130.31315-6-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626023130.31315-1-xieyongji@baidu.com> References: <20190626023130.31315-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 v4 5/5] virtio: Don't change "started" flag on virtio_vmstate_change() 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: lvivier@redhat.com, ehabkost@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, Xie Yongji Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e098fc8ef0..18f9f4c372 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1163,7 +1163,10 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t va= l) } } =20 - virtio_set_started(vdev, val & VIRTIO_CONFIG_S_DRIVER_OK); + if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) !=3D + (val & VIRTIO_CONFIG_S_DRIVER_OK)) { + virtio_set_started(vdev, val & VIRTIO_CONFIG_S_DRIVER_OK); + } =20 if (k->set_status) { k->set_status(vdev, val); --=20 2.17.1