From nobody Sun Apr 28 06:39:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528291635336142.90228722074096; Wed, 6 Jun 2018 06:27:15 -0700 (PDT) Received: from localhost ([::1]:52437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQYT4-0006SG-Hm for importer@patchew.org; Wed, 06 Jun 2018 09:27:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQYRp-0005rf-PS for qemu-devel@nongnu.org; Wed, 06 Jun 2018 09:25:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQYRm-0005hN-LC for qemu-devel@nongnu.org; Wed, 06 Jun 2018 09:25:57 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQYRm-0005go-El for qemu-devel@nongnu.org; Wed, 06 Jun 2018 09:25:54 -0400 Received: by mail-pf0-x241.google.com with SMTP id c22-v6so2728140pfi.2 for ; Wed, 06 Jun 2018 06:25:54 -0700 (PDT) Received: from localhost ([61.171.230.176]) by smtp.gmail.com with ESMTPSA id a14-v6sm15336629pgv.4.2018.06.06.06.25.52 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 06 Jun 2018 06:25:52 -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; bh=Xrh/eMR65kieVcffT7KHEcpzlmy5GAyaDE5BU3lVavw=; b=LakTVBAwaRJ7RG03v7pM4bOgGTJMsAM8cPpe3LAgWkQuoFLRPXPpJVsyT3l9nOwCYl Rb26jsWH95bY5OTxTyHzFtVmMxyIXiLPKSProVI6ZGVzSxZsWEDlk3TRc0zbnjjRUJI/ Ri4C7ix7fKtcRArQIsphLh2wgt0uZ3zNnl+670d/YE8WLVKUpR5/T8YAgRRaGBxGf6Xl nVcf8ObQ8IrR2fu5VtG5lBB6rrAsuYCx/z94IaZpmdkpHiOh4pKXGK+eLaR4SngjMYXR j7lEQaJpOSC2k8+I8h3ur11u2L41T0zSUisfRiZNPu5I+9S3vj9iaCwE8Wbv2igpynrI AG4A== 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; bh=Xrh/eMR65kieVcffT7KHEcpzlmy5GAyaDE5BU3lVavw=; b=kGWnp+oKuABlu24p/RI17lCTlTX+L2m+apFfduCWVgnZpCxmXxIYemqEVNbpNRi63E zagApdVBRh2Jto6wT0DLSTaEB06JFdPT2wVbItnXkOgz4BZJNxmu67BKYSDF4K6cspOY G62WprphX+y9faiAO1sBX5c/Fae36nRf5vGWp4CtkMgd9iLUAn8RN23ANZKnhj2IuOfS OlwShBmWlHqR3ydm7twjW3ff7b7yShEYYbQg4tIM8wQksbgcmV3//eCvLdw7K1NkNccf aoItiuDDeBiVSwmdVH9ucbiBH37LtrxuveFeE7xajXnptFqin9MwPVwdWolfUY0dYB5m ZtTQ== X-Gm-Message-State: APt69E1SyfxsT7u+rDJDMAh3Zi7mUoe3sEXbPVE7KtRwXkC6mqDSaUn5 hVAKL2DKKgUpLMfERcLMI+I= X-Google-Smtp-Source: ADUXVKKsh3yGiSibFYQK9cCWDvl1RKSZewRz5ZAMGpeIzfdorPSXhyLdrcZzciqx39TLPXpJbBzk4w== X-Received: by 2002:a63:9a52:: with SMTP id e18-v6mr2574982pgo.188.1528291553476; Wed, 06 Jun 2018 06:25:53 -0700 (PDT) From: Yongji Xie X-Google-Original-From: Yongji Xie To: mst@redhat.com, stefanha@redhat.com, changpeng.liu@intel.com Date: Wed, 6 Jun 2018 21:24:48 +0800 Message-Id: <1528291488-2586-1-git-send-email-xieyongji@baidu.com> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2] vhost-user-blk: start vhost when guest kicks 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: elohimes@gmail.com, nixun@baidu.com, qemu-devel@nongnu.org, chaiwen@baidu.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some old guests (before commit 7a11370e5: "virtio_blk: enable VQs early") kick virtqueue before setting VIRTIO_CONFIG_S_DRIVER_OK. This violates the virtio spec. But virtio 1.0 transitional devices support this behaviour. So we should start vhost when guest kicks in this case. Signed-off-by: Yongji Xie Signed-off-by: Chai Wen Signed-off-by: Ni Xun Reviewed-by: Stefan Hajnoczi --- hw/block/vhost-user-blk.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index d755223..1451940 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -217,7 +217,32 @@ static uint64_t vhost_user_blk_get_features(VirtIODevi= ce *vdev, =20 static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) { + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + int i; + + if (!(virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1) && + !virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1))) { + return; + } + + if (s->dev.started) { + return; + } + + /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start + * vhost here instead of waiting for .set_status(). + */ + vhost_user_blk_start(vdev); =20 + /* Kick right away to begin processing requests already in vring */ + for (i =3D 0; i < s->dev.nvqs; i++) { + VirtQueue *kick_vq =3D virtio_get_queue(vdev, i); + + if (!virtio_queue_get_desc_addr(vdev, i)) { + continue; + } + event_notifier_set(virtio_queue_get_host_notifier(kick_vq)); + } } =20 static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) --=20 1.7.9.5