<feed xmlns='http://www.w3.org/2005/Atom'>
<title>bwlp/qemu.git/include/hw/virtio, branch spice_video_codecs</title>
<subtitle>Experimental fork of QEMU with video encoding patches</subtitle>
<id>https://git.openslx.org/bwlp/qemu.git/atom/include/hw/virtio?h=spice_video_codecs</id>
<link rel='self' href='https://git.openslx.org/bwlp/qemu.git/atom/include/hw/virtio?h=spice_video_codecs'/>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/'/>
<updated>2022-12-01T07:30:18+00:00</updated>
<entry>
<title>include/hw: VM state takes precedence in virtio_device_should_start</title>
<updated>2022-12-01T07:30:18+00:00</updated>
<author>
<name>Alex Bennée</name>
</author>
<published>2022-11-30T11:24:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=4987e5bf2e9262094fd89d2b8e4d5bd6c4c7312f'/>
<id>urn:sha1:4987e5bf2e9262094fd89d2b8e4d5bd6c4c7312f</id>
<content type='text'>
The VM status should always preempt the device status for these
checks. This ensures the device is in the correct state when we
suspend the VM prior to migrations. This restores the checks to the
order they where in before the refactoring moved things around.

While we are at it lets improve our documentation of the various
fields involved and document the two functions.

Fixes: 9f6bcfd99f (hw/virtio: move vm_running check to virtio_device_started)
Fixes: 259d69c00b (hw/virtio: introduce virtio_device_should_start)
Signed-off-by: Alex Bennée &lt;alex.bennee@linaro.org&gt;
Tested-by: Christian Borntraeger &lt;borntraeger@linux.ibm.com&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Message-Id: &lt;20221130112439.2527228-6-alex.bennee@linaro.org&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>hw/virtio: generalise CHR_EVENT_CLOSED handling</title>
<updated>2022-12-01T07:30:13+00:00</updated>
<author>
<name>Alex Bennée</name>
</author>
<published>2022-11-30T11:24:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=71e076a07dc195129fe25d90d4b276be3b2f12d8'/>
<id>urn:sha1:71e076a07dc195129fe25d90d4b276be3b2f12d8</id>
<content type='text'>
..and use for both virtio-user-blk and virtio-user-gpio. This avoids
the circular close by deferring shutdown due to disconnection until a
later point. virtio-user-blk already had this mechanism in place so
generalise it as a vhost-user helper function and use for both blk and
gpio devices.

While we are at it we also fix up vhost-user-gpio to re-establish the
event handler after close down so we can reconnect later.

Signed-off-by: Alex Bennée &lt;alex.bennee@linaro.org&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Reviewed-by: Raphael Norwitz &lt;raphael.norwitz@nutanix.com&gt;
Message-Id: &lt;20221130112439.2527228-5-alex.bennee@linaro.org&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>hw/virtio: add started_vu status field to vhost-user-gpio</title>
<updated>2022-12-01T07:30:09+00:00</updated>
<author>
<name>Alex Bennée</name>
</author>
<published>2022-11-30T11:24:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=060f4a944072ecf37cece0f16a0609babfb679b8'/>
<id>urn:sha1:060f4a944072ecf37cece0f16a0609babfb679b8</id>
<content type='text'>
As per the fix to vhost-user-blk in f5b22d06fb (vhost: recheck dev
state in the vhost_migration_log routine) we really should track the
connection and starting separately.

Signed-off-by: Alex Bennée &lt;alex.bennee@linaro.org&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Message-Id: &lt;20221130112439.2527228-4-alex.bennee@linaro.org&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vhost: enable vrings in vhost_dev_start() for vhost-user devices</title>
<updated>2022-12-01T07:30:04+00:00</updated>
<author>
<name>Stefano Garzarella</name>
</author>
<published>2022-11-30T11:24:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=4daa5054c599c8aec70f1264a01341a15921c145'/>
<id>urn:sha1:4daa5054c599c8aec70f1264a01341a15921c145</id>
<content type='text'>
Commit 02b61f38d3 ("hw/virtio: incorporate backend features in features")
properly negotiates VHOST_USER_F_PROTOCOL_FEATURES with the vhost-user
backend, but we forgot to enable vrings as specified in
docs/interop/vhost-user.rst:

    If ``VHOST_USER_F_PROTOCOL_FEATURES`` has not been negotiated, the
    ring starts directly in the enabled state.

    If ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, the ring is
    initialized in a disabled state and is enabled by
    ``VHOST_USER_SET_VRING_ENABLE`` with parameter 1.

Some vhost-user front-ends already did this by calling
vhost_ops.vhost_set_vring_enable() directly:
- backends/cryptodev-vhost.c
- hw/net/virtio-net.c
- hw/virtio/vhost-user-gpio.c

But most didn't do that, so we would leave the vrings disabled and some
backends would not work. We observed this issue with the rust version of
virtiofsd [1], which uses the event loop [2] provided by the
vhost-user-backend crate where requests are not processed if vring is
not enabled.

Let's fix this issue by enabling the vrings in vhost_dev_start() for
vhost-user front-ends that don't already do this directly. Same thing
also in vhost_dev_stop() where we disable vrings.

[1] https://gitlab.com/virtio-fs/virtiofsd
[2] https://github.com/rust-vmm/vhost/blob/240fc2966/crates/vhost-user-backend/src/event_loop.rs#L217

Fixes: 02b61f38d3 ("hw/virtio: incorporate backend features in features")
Reported-by: German Maglione &lt;gmaglione@redhat.com&gt;
Tested-by: German Maglione &lt;gmaglione@redhat.com&gt;
Signed-off-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt;
Acked-by: Raphael Norwitz &lt;raphael.norwitz@nutanix.com&gt;
Message-Id: &lt;20221123131630.52020-1-sgarzare@redhat.com&gt;
Signed-off-by: Alex Bennée &lt;alex.bennee@linaro.org&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Message-Id: &lt;20221130112439.2527228-3-alex.bennee@linaro.org&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>virtio-net: fix for heap-buffer-overflow</title>
<updated>2022-11-10T15:18:55+00:00</updated>
<author>
<name>Xuan Zhuo</name>
</author>
<published>2022-11-10T09:57:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=f47af0af0db5933664c621b8af8067ebbcbe66cd'/>
<id>urn:sha1:f47af0af0db5933664c621b8af8067ebbcbe66cd</id>
<content type='text'>
Run shell script:

    cat &lt;&lt; EOF | valgrind qemu-system-i386 -display none -machine accel=qtest, -m \
    512M -M q35 -nodefaults -device virtio-net,netdev=net0 -netdev \
    user,id=net0 -qtest stdio
    outl 0xcf8 0x80000810
    outl 0xcfc 0xc000
    outl 0xcf8 0x80000804
    outl 0xcfc 0x01
    outl 0xc00d 0x0200
    outl 0xcf8 0x80000890
    outb 0xcfc 0x4
    outl 0xcf8 0x80000889
    outl 0xcfc 0x1c000000
    outl 0xcf8 0x80000893
    outw 0xcfc 0x100
    EOF

Got:
    ==68666== Invalid read of size 8
    ==68666==    at 0x688536: virtio_net_queue_enable (virtio-net.c:575)
    ==68666==    by 0x6E31AE: memory_region_write_accessor (memory.c:492)
    ==68666==    by 0x6E098D: access_with_adjusted_size (memory.c:554)
    ==68666==    by 0x6E4DB3: memory_region_dispatch_write (memory.c:1521)
    ==68666==    by 0x6E31AE: memory_region_write_accessor (memory.c:492)
    ==68666==    by 0x6E098D: access_with_adjusted_size (memory.c:554)
    ==68666==    by 0x6E4DB3: memory_region_dispatch_write (memory.c:1521)
    ==68666==    by 0x6EBCD3: flatview_write_continue (physmem.c:2820)
    ==68666==    by 0x6EBFBF: flatview_write (physmem.c:2862)
    ==68666==    by 0x6EF5E7: address_space_write (physmem.c:2958)
    ==68666==    by 0x6DFDEC: cpu_outw (ioport.c:70)
    ==68666==    by 0x6F6DF0: qtest_process_command (qtest.c:480)
    ==68666==  Address 0x29087fe8 is 24 bytes after a block of size 416 in arena "client"

That is reported by Alexander Bulekov. https://gitlab.com/qemu-project/qemu/-/issues/1309

Here, the queue_index is the index of the cvq, but in some cases cvq
does not have the corresponding NetClientState, so overflow appears.

I add a check here, ignore illegal queue_index and cvq queue_index.

Note the queue_index is below the VIRTIO_QUEUE_MAX but greater or equal
than cvq index could hit this. Other devices are similar.

Fixes: 7f863302 ("virtio-net: support queue_enable")
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1309
Reported-by: Alexander Bulekov &lt;alxndr@bu.edu&gt;
Signed-off-by: Xuan Zhuo &lt;xuanzhuo@linux.alibaba.com&gt;
Message-Id: &lt;20221110095739.130393-1-xuanzhuo@linux.alibaba.com&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>hw/virtio: introduce virtio_device_should_start</title>
<updated>2022-11-07T19:08:18+00:00</updated>
<author>
<name>Alex Bennée</name>
</author>
<published>2022-11-07T12:14:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=259d69c00b67c02a67f3bdbeeea71c2c0af76c35'/>
<id>urn:sha1:259d69c00b67c02a67f3bdbeeea71c2c0af76c35</id>
<content type='text'>
The previous fix to virtio_device_started revealed a problem in its
use by both the core and the device code. The core code should be able
to handle the device "starting" while the VM isn't running to handle
the restoration of migration state. To solve this duel use introduce a
new helper for use by the vhost-user backends who all use it to feed a
should_start variable.

We can also pick up a change vhost_user_blk_set_status while we are at
it which follows the same pattern.

Fixes: 9f6bcfd99f (hw/virtio: move vm_running check to virtio_device_started)
Signed-off-by: Alex Bennée &lt;alex.bennee@linaro.org&gt;
Cc: "Michael S. Tsirkin" &lt;mst@redhat.com&gt;
Message-Id: &lt;20221107121407.1010913-1-alex.bennee@linaro.org&gt;
</content>
</entry>
<entry>
<title>vhost: expose vhost_virtqueue_stop()</title>
<updated>2022-11-07T18:12:20+00:00</updated>
<author>
<name>Kangjie Xu</name>
</author>
<published>2022-10-17T09:25:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=e1f101d9f60c81b5186098b6dfd196b2730f2070'/>
<id>urn:sha1:e1f101d9f60c81b5186098b6dfd196b2730f2070</id>
<content type='text'>
Expose vhost_virtqueue_stop(), we need to use it when resetting a
virtqueue.

Signed-off-by: Kangjie Xu &lt;kangjie.xu@linux.alibaba.com&gt;
Signed-off-by: Xuan Zhuo &lt;xuanzhuo@linux.alibaba.com&gt;
Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Message-Id: &lt;20221017092558.111082-9-xuanzhuo@linux.alibaba.com&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>vhost: expose vhost_virtqueue_start()</title>
<updated>2022-11-07T18:12:20+00:00</updated>
<author>
<name>Kangjie Xu</name>
</author>
<published>2022-10-17T09:25:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=ff48b62809fc3d50e335965c6cb69bec20a495f3'/>
<id>urn:sha1:ff48b62809fc3d50e335965c6cb69bec20a495f3</id>
<content type='text'>
Expose vhost_virtqueue_start(), we need to use it when restarting a
virtqueue.

Signed-off-by: Kangjie Xu &lt;kangjie.xu@linux.alibaba.com&gt;
Signed-off-by: Xuan Zhuo &lt;xuanzhuo@linux.alibaba.com&gt;
Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Message-Id: &lt;20221017092558.111082-8-xuanzhuo@linux.alibaba.com&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>virtio-pci: support queue reset</title>
<updated>2022-11-07T18:12:20+00:00</updated>
<author>
<name>Xuan Zhuo</name>
</author>
<published>2022-10-17T09:25:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=805d782d284cba013707d5edf38b04047b21d4b5'/>
<id>urn:sha1:805d782d284cba013707d5edf38b04047b21d4b5</id>
<content type='text'>
PCI devices support vq reset.

Based on this function, the driver can adjust the size of the ring, and
quickly recycle the buffer in the ring.

The migration of the virtio devices will not happen during a reset
operation. This is becuase the global iothread lock is held. Migration
thread also needs the lock. As a result, when migration of virtio
devices starts, the 'reset' status of VirtIOPCIQueue will always be 0.
Thus, we do not need to add it in vmstate_virtio_pci_modern_queue_state.

Signed-off-by: Xuan Zhuo &lt;xuanzhuo@linux.alibaba.com&gt;
Signed-off-by: Kangjie Xu &lt;kangjie.xu@linux.alibaba.com&gt;
Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Message-Id: &lt;20221017092558.111082-6-xuanzhuo@linux.alibaba.com&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
<entry>
<title>virtio: core: vq reset feature negotation support</title>
<updated>2022-11-07T18:12:20+00:00</updated>
<author>
<name>Kangjie Xu</name>
</author>
<published>2022-10-17T09:25:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.openslx.org/bwlp/qemu.git/commit/?id=69e1c14aa22284f933a6ea134b96d5cb5a88a94d'/>
<id>urn:sha1:69e1c14aa22284f933a6ea134b96d5cb5a88a94d</id>
<content type='text'>
A a new command line parameter "queue_reset" is added.

Meanwhile, the vq reset feature is disabled for pre-7.2 machines.

Signed-off-by: Kangjie Xu &lt;kangjie.xu@linux.alibaba.com&gt;
Signed-off-by: Xuan Zhuo &lt;xuanzhuo@linux.alibaba.com&gt;
Acked-by: Jason Wang &lt;jasowang@redhat.com&gt;
Message-Id: &lt;20221017092558.111082-5-xuanzhuo@linux.alibaba.com&gt;
Reviewed-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
</content>
</entry>
</feed>
