Return-Path: virtio-comment-return-1794-cohuck=redhat.com@lists.oasis-open.org Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: Received: from lists.oasis-open.org (oasis-open.org [10.110.1.242]) by lists.oasis-open.org (Postfix) with ESMTP id 7707A9865CD for ; Thu, 25 Mar 2021 02:42:50 +0000 (UTC) References: <20210322034717.35135-1-jasowang@redhat.com> <20210322034717.35135-2-jasowang@redhat.com> From: Jason Wang Message-ID: <2274873f-68a3-0d4b-8bd4-0fca77dffcb1@redhat.com> Date: Thu, 25 Mar 2021 10:42:38 +0800 MIME-Version: 1.0 In-Reply-To: Subject: Re: [virtio-comment] [PATCH V2 1/2] virtio: introduce virtqueue state as basic facility Content-Type: multipart/alternative; boundary="------------F28638FEDFDFFDD195E55A1E" To: Stefan Hajnoczi Cc: virtio-comment@lists.oasis-open.org List-ID: --------------F28638FEDFDFFDD195E55A1E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable =E5=9C=A8 2021/3/24 =E4=B8=8B=E5=8D=885:38, Stefan Hajnoczi =E5=86=99=E9=81= =93: > On Wed, Mar 24, 2021 at 04:15:55PM +0800, Jason Wang wrote: >> =E5=9C=A8 2021/3/23 =E4=B8=8B=E5=8D=886:27, Stefan Hajnoczi =E5=86=99=E9= =81=93: >>> On Mon, Mar 22, 2021 at 11:47:16AM +0800, Jason Wang wrote: >>>> +The \field{used_wrap_counter} field is the wrap counter that is used >>>> +by the device. >>>> + >>>> +The used state is unnecessary when VIRTIO_RING_F_PACKED is not >>>> +negotiated. >>>> + >>>> +See also \ref{sec:Packed Virtqueues / Driver and Device Ring Wrap Cou= nters}. >>>> + >>>> +\drivernormative{\subsection}{Virtqueue State}{Basic Facilities of a = Virtio Device / Virtqueue State} >>>> + >>>> +If VIRTIO_F_QUEUE_STATE has been negotiated, a driver MUST set the >>>> +state of each virtqueue after setting the FEATURE_OK status bit but >>>> +before setting the DRIVER_OK status bit. >>>> + >>>> +If VIRTIO_F_QUEUE_STATE has been negotiated. a driver MUST reset the >>> s/negotiated./negotiated,/ >>> >>>> +device before getting the virtqueue state. >>> Interesting approach, but it makes sense that the device must be stoppe= d >>> before we mess with the queue state :). >>> >>> I wonder whether requiring the device to keep state across reset will >>> cause issues in the future or for testing/fuzzing. >>> >>> Another approach would have been to add a new status register bit for >>> pausing the device. That reminds me of vhost. >> >> That's the way I did here: >> https://lists.oasis-open.org/archives/virtio-comment/202012/msg00027.htm= l > That design seems less risky. I think modifying the semantics of device > reset might end up being a problem. Defining an explicit paused state > for saving/loading state seems cleaner. > > Why did you end up switching approaches? I try to seek some short-cut withut introducing new status bit but I end=20 up realizing it might not work as expected. Another reason is that, by using new status bit, we need to ability to=20 resume the device by clearing the bit which is somehow conflict with=20 what spec requries: " 2.1.1 Driver Requirements: Device Status Field The driver MUST NOT clear adevice statusbit. " Maybe we can have an exception for the device stop/pause in this case. Thanks > > Stefan --------------F28638FEDFDFFDD195E55A1E Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


=E5=9C=A8 2021/3/24 =E4=B8=8B=E5=8D=885:= 38, Stefan Hajnoczi =E5=86=99=E9=81=93:
On Wed, Mar 24, 2021 at 04:15:=
55PM +0800, Jason Wang wrote:
=E5=9C=A8 2021/3/23 =E4=B8=
=8B=E5=8D=886:27, Stefan Hajnoczi =E5=86=99=E9=81=93:
On Mon, Mar 22, 2021 at 11=
:47:16AM +0800, Jason Wang wrote:
+The \field{used_wrap_co=
unter} field is the wrap counter that is used
+by the device.
+
+The used state is unnecessary when VIRTIO_RING_F_PACKED is not
+negotiated.
+
+See also \ref{sec:Packed Virtqueues / Driver and Device Ring Wrap Counters=
}.
+
+\drivernormative{\subsection}{Virtqueue State}{Basic Facilities of a Virti=
o Device / Virtqueue State}
+
+If VIRTIO_F_QUEUE_STATE has been negotiated, a driver MUST set the
+state of each virtqueue after setting the FEATURE_OK status bit but
+before setting the DRIVER_OK status bit.
+
+If VIRTIO_F_QUEUE_STATE has been negotiated. a driver MUST reset the
s/negotiated./negotiated,/

+device before getting t=
he virtqueue state.
Interesting approach, but =
it makes sense that the device must be stopped
before we mess with the queue state :).

I wonder whether requiring the device to keep state across reset will
cause issues in the future or for testing/fuzzing.

Another approach would have been to add a new status register bit for
pausing the device. That reminds me of vhost.

That's the way I did here:
https://lists.oasis-open.org/arc=
hives/virtio-comment/202012/msg00027.html
That design seems less risky. I think modifying the semantics of device
reset might end up being a problem. Defining an explicit paused state
for saving/loading state seems cleaner.

Why did you end up switching approaches?


I try to seek some short-cut withut introducing new status bit but I end up realizing it might not work as expected.

Another reason is that, by using new status bit, we need to ability to resume the device by clearing the bit which is somehow conflict with what spec requries:

"

2.1.1 Driver Requirements: Device Status Field

The driver MUST NOT clear a=C2=A0device status=C2=A0bit.

"

Maybe we can have an exception for the device stop/pause in this case.

Thanks



Stefan
--------------F28638FEDFDFFDD195E55A1E--