From nobody Wed May 15 05:15:45 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=1559633988; cv=none; d=zoho.com; s=zohoarc; b=iIPWgAPQSHRQUJNKaR0AL56kOIfUc2LRtKDvR9gdbWiexCYPVlBsOJPyot91yZhLoPJY9MpWGX5waTTV8PQ0VSVR2/JNvql6C/hAwvGwY8umqZID1fZLm/16GWSAOW4DX4G3WH1CQVBt8uMWH8a0mYkUZ1OjSbrk6RgNLxhpukM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559633988; 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=kr819H7lf43YtonHy3KPFOGfzuzf63KXY2ivIp5O1R0=; b=cuM7iyn2Q1fs1ydbQHIBb5B5LeUrIw+JOqZcsH2mKQx0MrgtUVbfaaa0Gajb+RXyJ3oIQ02Y2dF5HqrKxuknyshtNyBzcf8KPkJiv1Ja8J9tBWSTmaWlMGKEz8t4qIzaw184+o7rOroWrfQNnijgk4K7NKfLXkQ6fhKvk4YOA4Y= 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 155963398882424.323593658606114; Tue, 4 Jun 2019 00:39:48 -0700 (PDT) Received: from localhost ([127.0.0.1]:47460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY42n-0004ME-RB for importer@patchew.org; Tue, 04 Jun 2019 03:39:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY3yo-0001F2-JU for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hY3yn-0003fS-HQ for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:34 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42692) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hY3yn-0003bq-97 for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:33 -0400 Received: by mail-pf1-x444.google.com with SMTP id q10so1935602pff.9 for ; Tue, 04 Jun 2019 00:35:33 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id v4sm20017907pfe.180.2019.06.04.00.35.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2019 00:35:31 -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=kr819H7lf43YtonHy3KPFOGfzuzf63KXY2ivIp5O1R0=; b=MK92V1Hgrn/hsMFylc7hj2LnV3wXX11rAB9Eta32S35opPYOOdlpYR2jEURZKXyeVM czKPdr0MQhGoHIh5M9kITpTzmmkuS+c6YPJl7LQqeQGsJ/z2/3RWS0zjHkMPSwY+safp uRuFgQbZM6K2W+JjKiLmRtG23D9dW9ZvIffVwDTm7W0GHEX3wkHZsd/mh7J2moxp7Tqa w60QfT/E+r9vPKETb4cDK73gQxFcZ7JBAeDWnB/eHrCxzpV0ioz9t0EHFXv6B5fVG69m dmfgy/jbn+oYkYG8VgOs9VXKVb/m1mrMRzUEwk/DjMIyxpp0tPn2llsHe/rKUNuK3TOo giZg== 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=kr819H7lf43YtonHy3KPFOGfzuzf63KXY2ivIp5O1R0=; b=MJqHuU6FYl54UrWY34rMkr0V8t3w+W7Yg+ZlZrf79Kma8pNdgo4zM83/+qZQ1L2fx3 22lhotlGiwiBJjX055Ws7jFwEHO9NZEU1VrBq6JMhINYMFB94Qo9WHwCvdZxwO8segxD s9qb6mzlJ5QiTn/yMTLbCR/fACn5cZFju1rnFC0GDALJ7KFypM6cxR5eY5UK0vs9rPm+ J2mIiOWaii8JJaMJuz5h6h5c9r72r8L9MRF68AEDNtYNwt167sjUubJKeR2P/GlBDM8m ZEsUVoRHD3tMVmrvG5uqPBeUmFS9iKSpqowVl909oQIYl53utp64bmOCzSOYzbtW5Uhy O9rg== X-Gm-Message-State: APjAAAUFexMrIgnMKdaY0BBegI6ozvGswJqLIgJDkR3rfOd5WAhp+9uj TQjG9tUSlpYyP9pqObnP+Vk= X-Google-Smtp-Source: APXvYqwuMS0dJ7cxNZCohtYFJjt4GsyYFUIGCVZ3dLdjYoEZ1NImmL/yEHWLGzH7x/uduqxJIwdl7A== X-Received: by 2002:a63:e408:: with SMTP id a8mr34019828pgi.146.1559633732044; Tue, 04 Jun 2019 00:35:32 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Tue, 4 Jun 2019 15:34:55 +0800 Message-Id: <20190604073459.15651-2-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604073459.15651-1-xieyongji@baidu.com> References: <20190604073459.15651-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::444 Subject: [Qemu-devel] [PATCH v2 1/5] virtio: Set "start_on_kick" on virtio_set_features() 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 , dgilbert@redhat.com, qemu-devel@nongnu.org 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 | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 07f4a64b48..6508b2faad 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1214,8 +1214,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 false; vdev->started =3D false; vdev->broken =3D false; vdev->guest_features =3D 0; @@ -2069,14 +2068,22 @@ 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 (!vdev->started && + virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) && + !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { + vdev->start_on_kick =3D true; + } } return ret; } @@ -2228,6 +2235,12 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int= version_id) } } =20 + if (!vdev->started && + virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) && + !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) { @@ -2330,8 +2343,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 false; vdev->started =3D false; vdev->device_id =3D device_id; vdev->status =3D 0; --=20 2.17.1 From nobody Wed May 15 05:15:45 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=1559633865; cv=none; d=zoho.com; s=zohoarc; b=et9ylwORUPze4ENL1gUv3QaCInbxbDNmVGmKRrDtj70yuADwYA9iLVR5UpTOMnlhkmQ/cqv6FLjWlm1Webvg7OVHQqAm2RnqcC/JfRzuTnmgPW3xhcMBaBY0FrvGSjroostwUN8JsWuUvBNfD2S9cvQFip3YCvj8W460AZ85dN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559633865; 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=mls9WkvxiCV9h+B5dVJf3CgBUNhcd0qcQOsSbC06TbQ=; b=OQihTaVt82SfUEM1s48j7g59399amh0do7xC0wJ1I5TliPIVvlkt0x48KO/dnCtcyUeo5fkWbLkb2Ko3rj3i8A1po+74+45e0IjlFKhkgo/r8PGehElR4HNodZo3at4UHP6Wos36UvUR7QN7hulXhS7N325uIJNvMMhV2UUCmQQ= 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 15596338656761021.9605760431308; Tue, 4 Jun 2019 00:37:45 -0700 (PDT) Received: from localhost ([127.0.0.1]:47441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY40m-0002UJ-69 for importer@patchew.org; Tue, 04 Jun 2019 03:37:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY3yr-0001GU-CB for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hY3yq-0003on-Cl for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:37 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:41771) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hY3yq-0003ml-7F for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:36 -0400 Received: by mail-pf1-x42d.google.com with SMTP id q17so12154489pfq.8 for ; Tue, 04 Jun 2019 00:35:36 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id v4sm21873288pff.45.2019.06.04.00.35.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2019 00:35:34 -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=mls9WkvxiCV9h+B5dVJf3CgBUNhcd0qcQOsSbC06TbQ=; b=rK/QmNWmn4e0FGHrbWzG7rRrSw+ccnnilCZesqL47xV8hz6FBF9/7pM0SQG/fBpoJi 37BWWRz4I3M1/LgAFfDLKbkaXeg8aZDwGs0xJb6W/r5f24810+29n+a3x3/L4t61dR1O ChnJ+/eDuIy2kjuWfK8SIG2ekOwBfno4KQBvS7POBNC/cUR4bYyOXcBNDC0xSO/wW9nA K6NoXIr4U38hynsSdtR9Yio3tuR/VqzFUfsAYPNRsk+t4jJp/v4W/qxvro5G5iHGcx38 GHtYQrr2n+dT7kKE2tDKwa0bstxQLkc6VAnuCKduExSYgWZ6K+hoJ3MYu7phQ+HJicHV HfpA== 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=mls9WkvxiCV9h+B5dVJf3CgBUNhcd0qcQOsSbC06TbQ=; b=j5c21KEDXamtgUQhFur9Qi4ZUs50o9dQlg1g9Cg6YTRXq4u27uyAiOcBBRZQHcuWF4 UWgSkk7IyA9V6EsWK0SM4V4/DUf4m+jPK0vcZPgWEc4BNlMVs9a5FoyZV3KIKS3KVc2R F/Qdt/Clv8v51EjpOHJ5EYyGw4zMoG8WuZfG8nhljS4ELi+31RtYZoRaHNazkSrENyqd W8iEYLlcPRU7X3aVyIqoD2rxxphBD4vI5Gnes+yakmYqVzz1cbsFVEZ6YWPoflXD4L66 vJXpA+gYNTfgf0I2zn8m3Fx403eYGuDpvjO/kyQrLB69TiCgloto3WGiwDJWI14Sw9Dw tzEA== X-Gm-Message-State: APjAAAVRSa89x6WE+nepmQSthAR8ZUn2VetGFpQMB03mzky0Ks7zW/Ow feCd2461DD83gTO+OL9mW1I= X-Google-Smtp-Source: APXvYqw09hqw8C9PVYcNr2Qy5x3GQV9m9N6aSqHjalp+TSPeh5bmwnOttTDqsL2o37dWAKZovNgNTg== X-Received: by 2002:a63:2706:: with SMTP id n6mr34631171pgn.238.1559633735217; Tue, 04 Jun 2019 00:35:35 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Tue, 4 Jun 2019 15:34:56 +0800 Message-Id: <20190604073459.15651-3-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604073459.15651-1-xieyongji@baidu.com> References: <20190604073459.15651-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::42d Subject: [Qemu-devel] [PATCH v2 2/5] virtio: Set "start_on_kick" for legacy devices 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 , dgilbert@redhat.com, qemu-devel@nongnu.org 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 --- hw/virtio/virtio.c | 2 -- include/hw/virtio/virtio.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6508b2faad..6ec45d8f0a 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2080,7 +2080,6 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t = val) } =20 if (!vdev->started && - virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) && !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { vdev->start_on_kick =3D true; } @@ -2236,7 +2235,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int = version_id) } =20 if (!vdev->started && - virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) && !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { vdev->start_on_kick =3D true; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 27c0efc3d0..303242b3c2 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -106,7 +106,7 @@ struct VirtIODevice bool vm_running; bool broken; /* device in invalid state, needs reset */ 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 Wed May 15 05:15:45 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=1559633993; cv=none; d=zoho.com; s=zohoarc; b=JuQPevDhPlvDjbeAiKvo4UxVg+QjAmIqUqKzucu1HxHydfhCiI+Q3/rD69T5MxHJXNIrHhqewNPWtJ85nmwaCvcaa9VMosUdX2bhPZeqmvtnGsB0U6ciBQtynC/fCuBuO3rXllu8cBNw5gi6iLABFLmEuSWp609MfaP3SNravP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559633993; 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=XTNMBKN2X1BkfbMgr70LpEg84K+wAte084VIv3k+D1I=; b=TVQ0YXRIsPXgdQdX7Fc9HSlDbMQavzKAE95oD+RT6tJDDcMbckQjJa7cC67VsK2n0T2vU2zOxPsSPig0fgFcbbm2ZWCBSHiJwCT1EKFIbCl2XdnWn14ZrqhkHAUXKnY82MDcL/zVK2Gc7s7WbBWDDkoZSdGgfnITRPZkiAqFsjU= 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 1559633993799964.2676324553591; Tue, 4 Jun 2019 00:39:53 -0700 (PDT) Received: from localhost ([127.0.0.1]:47462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY42w-0004Qo-LH for importer@patchew.org; Tue, 04 Jun 2019 03:39:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY3yu-0001IS-9o for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hY3yt-00045Y-ER for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:40 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:34498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hY3yt-0003y4-8E for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:39 -0400 Received: by mail-pg1-x541.google.com with SMTP id h2so6598602pgg.1 for ; Tue, 04 Jun 2019 00:35:39 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id b16sm17232845pfd.12.2019.06.04.00.35.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2019 00:35:37 -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=XTNMBKN2X1BkfbMgr70LpEg84K+wAte084VIv3k+D1I=; b=eRY7kWAUZ8kn8Qqjp0Boz4O+CM1SK9RoFVjsxl4IlCWcIT0XPsDCg0rY6hBO1QZy/k OIqwzZQf6tJWZMbD5I+3ssuCzh9vNOmWcUTn4fd3rWHjoVO5WoB8eDzNmCv2ihGZenAS +InfQzqHdphxpS46Ng40pLDGH6sbLF/WSUZOUbPJZbtyYq9PqlaXrNBrYHV2h1CtgafL wVsKZv8IMPB1R/GXXEBYfUede9bWmbXDfA8q59vLUfN3v79jJQxWEpVQ3DBNUx5CGMmw cOSd3Ymj9SFCz08t6KNiO+na2J8UNr2HGQW//fpGKxv2d/bQwV7vqB+aI5SI1tMsmY/p j3xA== 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=XTNMBKN2X1BkfbMgr70LpEg84K+wAte084VIv3k+D1I=; b=H6rZqgWMLOVMEi6lZL3vyaLnwaxir8V5wys7s0eiICP8kLA1LsdhKp60NEU26X/5ia CLtCTMPAQCABPlegR4r7Ucav+KJlQ1fFhVPR6dhCyPg8SYua/FgD49AippAAhpOLVguf coVEjJ9/Oz8+594VhFnz4uef4oSUKZX0DXD/xLl7dUHmxBYydKVvqZPpWuup7aIbtAFn AGTqdwE5olZViHSEwTvrYtFDVDfvjWZv/SlH2snkZAK7pJy3TeHzf16tqEpRV2NUDBnB UswIaisO23eNbggRR6gDffveeepMqjgFYnZkJbQvRv3bHnXv8qyXdZ4hUFkaFo4Nj1nG 88mw== X-Gm-Message-State: APjAAAU0P9aZ30crxFd4WF3G9R78su1dk2P0/79bDXwxDAmH6W+8hdbA 89GrXTvruAvNWXJvjoZ7s40= X-Google-Smtp-Source: APXvYqybLj7SVGuaVCTwtM8siXHKLSXVO1OnORlyJUFJmtcl5/6c0LO2gFkEgMz1OAfPGgsY7ltXcA== X-Received: by 2002:a17:90a:62c6:: with SMTP id k6mr33981582pjs.7.1559633738223; Tue, 04 Jun 2019 00:35:38 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Tue, 4 Jun 2019 15:34:57 +0800 Message-Id: <20190604073459.15651-4-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604073459.15651-1-xieyongji@baidu.com> References: <20190604073459.15651-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 v2 3/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.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xie Yongji , dgilbert@redhat.com, qemu-devel@nongnu.org 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6ec45d8f0a..3dc2f8c223 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1575,11 +1575,11 @@ 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)) { - vdev->started =3D true; - vdev->start_on_kick =3D false; + if (unlikely(vdev->start_on_kick)) { + vdev->started =3D true; + vdev->start_on_kick =3D false; + } } } =20 --=20 2.17.1 From nobody Wed May 15 05:15:45 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=1559633875; cv=none; d=zoho.com; s=zohoarc; b=gDAa5q9dkdXV0c409xv3A+sR2v9Ho/4dQHgzxOD2g2fZfTsRBbNow6WFaSvc0bf+lxAJuOVEjVEVrE75NgFcllFnMxWues1+ME90XLf5IbEXHD2IK4uZhYzKCWnWy8OG1fQfj2lU7zJLIfwJjBFYUzLb7HPezeMwUcYXWzn3hCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559633875; 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=0LFWE+6YBWNetnIjT0/2k7O7uyx6xdsCiXpzjLGF0E8=; b=YZF4W8f8+8eXC0iApj0I2L0/348qkLt66gEHhI7j4drc5qT0D1f8uJe1tfhfh7XKOyWt/hd5ZUK/+B2dj0Z6uQ10M9diZQvBuA6BMBZ7MPbBhao8h69Zhzpc63mOIPfAmLgzlAdxEzTVWrqkiyMY34C5RpflKay2e61wdqCo/6Q= 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 1559633875029103.89074019225995; Tue, 4 Jun 2019 00:37:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:47444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY40v-0002bT-0g for importer@patchew.org; Tue, 04 Jun 2019 03:37:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY3yx-0001Kp-Nm for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hY3yw-0004UC-Ov for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:43 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:44655) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hY3yw-0004Mh-Iw for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:42 -0400 Received: by mail-pg1-x544.google.com with SMTP id n2so9825624pgp.11 for ; Tue, 04 Jun 2019 00:35:42 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id m8sm26428531pff.137.2019.06.04.00.35.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2019 00:35:41 -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=0LFWE+6YBWNetnIjT0/2k7O7uyx6xdsCiXpzjLGF0E8=; b=fKZQwn8dh+OPZQuQscBOTSRkc+9+3XY6psxqRvrxoGcuSBJEKvVNSrBxf+qckjp8vS 4d60AIbV8oOgRD/lBPZ/kVrSlX10ip3Yenowg6DXILhKRz3xm/D/kprXQt78ckxR8fyu Gpb+H5e1A31zZ2DBd62/WCwqzwjQ/M5o6VLE4tuvVw76rzU0oR/3qNJsypGkPkS7eV2z tPDLhn5mC9nvuQTIGMotOLHkmgIQeOLi7kUl34Y5+UK9ezRpOpR95pl4qj6JAbcANaiE 0s/l4h77kE0/YRXmToBMPZb6BgIkCA6HjptG+jSfcWXWSfwsDLIcLtMNZO3pUAFM4NPR 4EJQ== 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=0LFWE+6YBWNetnIjT0/2k7O7uyx6xdsCiXpzjLGF0E8=; b=PHcrCR96BYtwuQr9HWl+3HC9gSFbnMDog6NNIblG194SZ+oKRZmTyyjupFXvRmNQ/d SaDeKSbEfN9W7EHrY6+38WtWXpYBVoiP95reX2hglr0yUcLR4QBxTvczl9qx0+8+Qm8H +cQDpqNOi2gr5qGs44eJbXVCo/dzJ1NVu5b5ouSbSU1UAzxD/i4a2rvNcWpxNptucAMn I/cN9VYzoR052dJ4QwKwdr1PoD/D8/hKigQ1+8323ZVfN+hx0eBrDqWN4VLtxO/pnGYS EzNnBx+mX/aEvk+ps5mYMXDDyOF0FcSyRyEi6406z8KxE0M0rn28acZXJJBrSG4VEt71 oz9w== X-Gm-Message-State: APjAAAVnZ06+wArZxR7TEVwhrRtQ79mZojqBNBQYlAHH6+jcRCZrxrx8 sECY/hQU1fuyO4fJWlw4YTMdurdT X-Google-Smtp-Source: APXvYqyth0u6KIGmJPcmLqnzefKa4kPF5OCC+7EHSY2dFyQUU+p23NQa+LC+1w6yYeOBDTMO1FUHTg== X-Received: by 2002:a17:90a:7f02:: with SMTP id k2mr35414091pjl.78.1559633741441; Tue, 04 Jun 2019 00:35:41 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Tue, 4 Jun 2019 15:34:58 +0800 Message-Id: <20190604073459.15651-5-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604073459.15651-1-xieyongji@baidu.com> References: <20190604073459.15651-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::544 Subject: [Qemu-devel] [PATCH v2 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 , dgilbert@redhat.com, qemu-devel@nongnu.org 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3dc2f8c223..3960619bd4 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1162,9 +1162,13 @@ 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; + + if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) !=3D + (val & VIRTIO_CONFIG_S_DRIVER_OK)) { + vdev->started =3D val & VIRTIO_CONFIG_S_DRIVER_OK; + if (unlikely(vdev->start_on_kick && vdev->started)) { + vdev->start_on_kick =3D false; + } } =20 if (k->set_status) { --=20 2.17.1 From nobody Wed May 15 05:15:45 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=1559633874; cv=none; d=zoho.com; s=zohoarc; b=RDDqLuUr1OBoxmEDHiMbiciWfQB4e2Eb4YvgKHNocbSYpN1vmOqYduQu2Uy3IKTEz2XqvPnTdUH/1W81LIXAKOpgZ5IKHFlmK6wSx5mVYaUT6wtWk8T5IuvB1k1jyyDIKJTj8xbWWXNSQmlZ6iqxL2lC+OJFenFWMAAggwxgXJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559633874; 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=BlmwWQSrvfnPLK3snMGwGG+KcVuIss3R/7Aben6MrQw=; b=gm8bVWMPwYayEJuiZXAV2npds7Zk3bnhJMNXp/4nL4jdG/WjRCryCzDt65vOtH+yuu7SKjXwNjlVFReQRf7DRRfsMp3bfSZ27br7jgJMc3AP7h/36/CKKWdh0oI5FDlZ+jaOg8cwKGKwMYHrSMgW+3LuM4PapUBCvQdj7TDhhlw= 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 1559633874077223.71350823580735; Tue, 4 Jun 2019 00:37:54 -0700 (PDT) Received: from localhost ([127.0.0.1]:47446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY410-0002hQ-1x for importer@patchew.org; Tue, 04 Jun 2019 03:37:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hY3z1-0001Ns-ES for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hY3z0-0004wQ-3V for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:47 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45280) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hY3yz-0004tR-TY for qemu-devel@nongnu.org; Tue, 04 Jun 2019 03:35:46 -0400 Received: by mail-pg1-x541.google.com with SMTP id w34so9815477pga.12 for ; Tue, 04 Jun 2019 00:35:45 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id m20sm995215pjn.16.2019.06.04.00.35.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2019 00:35:44 -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=BlmwWQSrvfnPLK3snMGwGG+KcVuIss3R/7Aben6MrQw=; b=VJ8WpLxq43rtFJQ9KMSJSFwSHLmfhxYJ4phcnhQLO6VuOcNa81TtNGRMs0fdFpCz4S yMfq4G9kHxo9Ec2eTESm5PTfnDoK6OUxen1oNS73U0n91eYHkJ0QXHj52gsZqrpzfahN /RmFv5nfN+i+cyKFfF1bJbAqD50f+QSF1inhSLMz5PjFFM4VrqQkhbxh3drXMEiGTQ2Q tXu4b6yN4NGx+yLNF3qfN7ATT/xtHSzHTp08k9D2e2PiXZBvteBuZXDk9NA0eByrlB03 Usi2BvVjXKSxhtbwixUXfgZhz8wOAQyVXYHUYT01uiMz1HVWDIaa01cdcmmd2+CeVYuw 7S+Q== 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=BlmwWQSrvfnPLK3snMGwGG+KcVuIss3R/7Aben6MrQw=; b=Fm+KzA9QW4PNGmNlfpofHLQyGEwLDm6ue3MgTY/vJENnfGCmIOQqveHGCvu3JWTdJX mvcq6808w3mxT1RxVlfV7jBunKn+o7Eudvrm/sbPCJNNtVwnxdETy/qyGg6hWOIUINSA uUOww/PQZ+8MsO2LvcfX7AjfiFsUsEnvIelgl+q1u1NK4vUdksRuHRbGKd1QrQDa96ol 8kmGd9dQmHLExZX90+H3cma8oyC157PcLabkIOOFu0b+0bcqlEXnyKSlajVA6hSqaikL 8/YxB4PPFG6LNw5plmzQgD7s5d5BIU1wH5tC0+qE7MNg/HnVbkTbNg+B7rNcvKz8EAr6 cm3Q== X-Gm-Message-State: APjAAAXcy6d1Hy0UIz3fhD9jYTTxVfi9ZszkNF1zUIVdFgQYAm3zGRUe CpoY+CjOxQpa4XCB7BQEpIQqgqm+ X-Google-Smtp-Source: APXvYqyx2Cn2oWru565C85iqVbPdB5kTgKZHSX0YYGuquvXmTkPAhf81/XoH66oZlUvYcmoIecANXA== X-Received: by 2002:a17:90a:6348:: with SMTP id v8mr35026298pjs.34.1559633744907; Tue, 04 Jun 2019 00:35:44 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, groug@kaod.org Date: Tue, 4 Jun 2019 15:34:59 +0800 Message-Id: <20190604073459.15651-6-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604073459.15651-1-xieyongji@baidu.com> References: <20190604073459.15651-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 v2 5/5] virtio: add "use-started" property 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 , dgilbert@redhat.com, qemu-devel@nongnu.org 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.1. Signed-off-by: Xie Yongji --- hw/block/vhost-user-blk.c | 4 ++-- hw/core/machine.c | 4 +++- hw/virtio/virtio.c | 21 ++++++++------------- include/hw/virtio/virtio.h | 21 +++++++++++++++++++++ 4 files changed, 34 insertions(+), 16 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 f1a0f45f9c..133c113ebf 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -24,7 +24,9 @@ #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" =20 -GlobalProperty hw_compat_4_0_1[] =3D {}; +GlobalProperty hw_compat_4_0_1[] =3D { + { "virtio-device", "use-started", "false" }, +}; const size_t hw_compat_4_0_1_len =3D G_N_ELEMENTS(hw_compat_4_0_1); =20 GlobalProperty hw_compat_4_0[] =3D {}; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3960619bd4..9af2e339af 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1165,10 +1165,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t va= l) =20 if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) !=3D (val & VIRTIO_CONFIG_S_DRIVER_OK)) { - 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) { @@ -1539,8 +1536,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 @@ -1560,8 +1556,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); } } } @@ -1581,8 +1576,7 @@ void virtio_queue_notify(VirtIODevice *vdev, int n) 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); } } } @@ -2083,7 +2077,7 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t = val) } } =20 - if (!vdev->started && + if (!virtio_device_started(vdev, vdev->status) && !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { vdev->start_on_kick =3D true; } @@ -2238,7 +2232,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int = version_id) } } =20 - if (!vdev->started && + if (!virtio_device_started(vdev, vdev->status) && !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { vdev->start_on_kick =3D true; } @@ -2306,7 +2300,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) { @@ -2683,6 +2677,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 303242b3c2..b189788cb2 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; /* when virtio 1.0 feature has not been negotiated= */ 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