On 29/03/2016 16:09, Michael S. Tsirkin wrote:
>> > Another small comment, this can be written simply as
>> >
>> > if (s->dataplane) {
>> > virtio_blk_data_plane_start(s->dataplane);
>
> True, it's best not to poke at dataplane_started.
>
> > } else {
> > virtio_blk_handle_vq(s, vq);
> > }
> >
>
> I prefer the return style I think, to stress the
> fact that this is an unusual, unexpected case.
We're getting dangerously close to personal preference, but I've noticed
virtio-scsi that you get a very common pattern of:
void virtio_scsi_handle_ctrl_vq(VirtIOSCSI *s, VirtQueue *vq)
{
... virtqueue_pop ...
}
static void virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,
VirtQueue *vq)
{
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
assert(dataplane active and started);
virtio_scsi_handle_ctrl_vq(s, vq);
}
static void virtio_scsi_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
if (dataplane active) {
virtio_scsi_dataplane_start(s);
} else {
virtio_scsi_handle_ctrl_vq(s, vq);
}
}
so it's not really an unusual, unexpected case but a complete
separation between the dataplane case (handle_output starts
dataplane) and the non-dataplane case (handle_output just does
a cast and calls the actual workhorse).
Paolo