From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=45.249.212.35; helo=huawei.com; envelope-from=zhengxiang9@huawei.com; receiver=edk2-devel@lists.01.org Received: from huawei.com (unknown [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B958A2205B925 for ; Thu, 11 Jan 2018 17:30:30 -0800 (PST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B81B386529CC4; Fri, 12 Jan 2018 09:35:39 +0800 (CST) Received: from [127.0.0.1] (10.177.29.32) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Fri, 12 Jan 2018 09:35:31 +0800 To: Maxime Coquelin CC: Paolo Bonzini , Laszlo Ersek , , Ard Biesheuvel , "Jordan Justen" , Shannon Zhao References: <20171213031632.11856-1-zhengxiang9@huawei.com> <06533b91-8ff0-1ad2-56fa-5f2c4f56bb19@redhat.com> <7161de6e-99c2-ed81-bbf6-c7a89336c36d@redhat.com> <835f9103-1892-4963-9bbb-1fa9b417af60@huawei.com> <8940cc0e-64e7-c253-a8e0-5081eab4efbe@redhat.com> From: "zhengxiang (A)" Message-ID: <25eadf31-e2ce-751a-e167-398ecde2c381@huawei.com> Date: Fri, 12 Jan 2018 09:35:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.177.29.32] X-CFilter-Loop: Reflected Subject: Re: [PATCH] OvmfPkg/VirtioScsiDxe: Allocate all required vrings at VirtioScsiInit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jan 2018 01:30:31 -0000 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit Hi Maxime, On 2018/1/11 22:46, Maxime Coquelin wrote: > > > On 01/11/2018 02:23 PM, Maxime Coquelin wrote: >> Hi Xiang, >> >> On 12/14/2017 02:25 PM, zhengxiang (A) wrote: >>> >>> >>> On 2017/12/14 17:06, Paolo Bonzini wrote: >>>> On 14/12/2017 07:55, zhengxiang (A) wrote: >>>>> Hello Laszlo and Paolo, >>>>> >>>>> Thanks for your review! >>>>> >>>>> On 2017/12/13 19:16, Laszlo Ersek wrote: >>>>>> On 12/13/17 10:29, Paolo Bonzini wrote: >>>>>>> On 13/12/2017 09:35, Laszlo Ersek wrote: >>>>>>>> Perhaps you can update vhost-scsi similarly to the last patch of >>>>>>>> Maxime's v4 series, even without "VIRTIO_SCSI_F_MQ" -- in the >>>>>>>> SET_FEATURES request handler, just destroy the unused virtqueues that >>>>>>>> have not been configured by the guest driver until that time? >>>>>>> Yes, this is the right solution.  We can assume that if the descriptor >>>>>>> address is equal to zero, the queue is not in use.  This is not in the >>>>>>> spec as far as I can see, but it is QEMU's assumption.  I will send a >>>>>>> patch to the virtio specification. >>>>> >>>>> I would try this solution! However, is there any possibility that the allocated >>>>> descriptor address is exactly equal to zero and the queue is in use? >>>> >>>> That would break QEMU's virtio implementation, so it's pretty unlikely. >>>> >>>> Paolo >>>> >>> >>> So could I judge the not-in-use queues by adding the below sentence in order >>> to skip calling vhost_virtqueue_start? >>> >>> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c >>> index e4290ce..05c3322 100644 >>> --- a/hw/virtio/vhost.c >>> +++ b/hw/virtio/vhost.c >>> @@ -1532,6 +1532,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) >>>           goto fail_mem; >>>       } >>>       for (i = 0; i < hdev->nvqs; ++i) { >>> +        if (virtio_queue_get_desc_addr(vdev, i) == 0) continue; > > BTW, the queue index is wrong here, it should be: > > if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) == 0) >     continue; > Thank you for correcting my mistake. I will post this patch for more discussions. >>>           r = vhost_virtqueue_start(hdev, >>>                                     vdev, >>>                                     hdev->vqs + i, >>> >> > > Maxime > > . > Thanks, Xiang