1
The following changes since commit 0b5e750bea635b167eb03d86c3d9a09bbd43bc06:
1
The following changes since commit cc6613e244e86c66f83467eab5284825d7057cea:
2
2
3
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2019-02-12 10:53:37 +0000)
3
Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging (2019-09-03 11:06:09 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://github.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 42824b4d16da56a50ff4027f6cd22378e0e2666e:
9
for you to fetch changes up to ebb6ff25cd888a52a64a9adc3692541c6d1d9a42:
10
10
11
virtio-blk: set correct config size for the host driver (2019-02-13 16:18:17 +0800)
11
virtio-blk: Cancel the pending BH when the dataplane is reset (2019-09-03 16:11:18 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Pull request
15
15
16
Fix a virtio-blk migration regression.
17
18
----------------------------------------------------------------
16
----------------------------------------------------------------
19
17
20
Changpeng Liu (1):
18
Philippe Mathieu-Daudé (1):
21
virtio-blk: set correct config size for the host driver
19
virtio-blk: Cancel the pending BH when the dataplane is reset
22
20
23
hw/block/virtio-blk.c | 13 +++++++++----
21
hw/block/dataplane/virtio-blk.c | 3 +++
24
1 file changed, 9 insertions(+), 4 deletions(-)
22
1 file changed, 3 insertions(+)
25
23
26
--
24
--
27
2.20.1
25
2.21.0
28
26
29
27
diff view generated by jsdifflib
1
From: Changpeng Liu <changpeng.liu@intel.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Commit caa1ee43 "vhost-user-blk: add discard/write zeroes features
3
When 'system_reset' is called, the main loop clear the memory
4
support" added fields to struct virtio_blk_config. This changes
4
region cache before the BH has a chance to execute. Later when
5
the size of the config space and breaks migration from QEMU 3.1
5
the deferred function is called, some assumptions that were
6
and older:
6
made when scheduling them are no longer true when they actually
7
execute.
7
8
8
qemu-system-ppc64: get_pci_config_device: Bad config data: i=0x10 read: 41 device: 1 cmask: ff wmask: 80 w1cmask:0
9
This is what happens using a virtio-blk device (fresh RHEL7.8 install):
9
qemu-system-ppc64: Failed to load PCIDevice:config
10
qemu-system-ppc64: Failed to load virtio-blk:virtio
11
qemu-system-ppc64: error while loading state for instance 0x0 of device 'pci@800000020000000:01.0/virtio-blk'
12
qemu-system-ppc64: load of migration failed: Invalid argument
13
10
14
Since virtio-blk doesn't support the "discard" and "write zeroes"
11
$ (sleep 12.3; echo system_reset; sleep 12.3; echo system_reset; sleep 1; echo q) \
15
features, it shouldn't even expose the associated fields in the
12
| qemu-system-x86_64 -m 4G -smp 8 -boot menu=on \
16
config space actually. Just include all fields up to num_queues to
13
-device virtio-blk-pci,id=image1,drive=drive_image1 \
17
match QEMU 3.1 and older.
14
-drive file=/var/lib/libvirt/images/rhel78.qcow2,if=none,id=drive_image1,format=qcow2,cache=none \
15
-device virtio-net-pci,netdev=net0,id=nic0,mac=52:54:00:c4:e7:84 \
16
-netdev tap,id=net0,script=/bin/true,downscript=/bin/true,vhost=on \
17
-monitor stdio -serial null -nographic
18
(qemu) system_reset
19
(qemu) system_reset
20
(qemu) qemu-system-x86_64: hw/virtio/virtio.c:225: vring_get_region_caches: Assertion `caches != NULL' failed.
21
Aborted
18
22
19
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
23
(gdb) bt
20
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
24
Thread 1 (Thread 0x7f109c17b680 (LWP 10939)):
21
Message-id: 1550022537-27565-1-git-send-email-changpeng.liu@intel.com
25
#0 0x00005604083296d1 in vring_get_region_caches (vq=0x56040a24bdd0) at hw/virtio/virtio.c:227
22
Message-Id: <1550022537-27565-1-git-send-email-changpeng.liu@intel.com>
26
#1 0x000056040832972b in vring_avail_flags (vq=0x56040a24bdd0) at hw/virtio/virtio.c:235
27
#2 0x000056040832d13d in virtio_should_notify (vdev=0x56040a240630, vq=0x56040a24bdd0) at hw/virtio/virtio.c:1648
28
#3 0x000056040832d1f8 in virtio_notify_irqfd (vdev=0x56040a240630, vq=0x56040a24bdd0) at hw/virtio/virtio.c:1662
29
#4 0x00005604082d213d in notify_guest_bh (opaque=0x56040a243ec0) at hw/block/dataplane/virtio-blk.c:75
30
#5 0x000056040883dc35 in aio_bh_call (bh=0x56040a243f10) at util/async.c:90
31
#6 0x000056040883dccd in aio_bh_poll (ctx=0x560409161980) at util/async.c:118
32
#7 0x0000560408842af7 in aio_dispatch (ctx=0x560409161980) at util/aio-posix.c:460
33
#8 0x000056040883e068 in aio_ctx_dispatch (source=0x560409161980, callback=0x0, user_data=0x0) at util/async.c:261
34
#9 0x00007f10a8fca06d in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
35
#10 0x0000560408841445 in glib_pollfds_poll () at util/main-loop.c:215
36
#11 0x00005604088414bf in os_host_main_loop_wait (timeout=0) at util/main-loop.c:238
37
#12 0x00005604088415c4 in main_loop_wait (nonblocking=0) at util/main-loop.c:514
38
#13 0x0000560408416b1e in main_loop () at vl.c:1923
39
#14 0x000056040841e0e8 in main (argc=20, argv=0x7ffc2c3f9c58, envp=0x7ffc2c3f9d00) at vl.c:4578
40
41
Fix this by cancelling the BH when the virtio dataplane is stopped.
42
43
[This is version of the patch was modified as discussed with Philippe on
44
the mailing list thread.
45
--Stefan]
46
47
Reported-by: Yihuang Yu <yihyu@redhat.com>
48
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
49
Fixes: https://bugs.launchpad.net/qemu/+bug/1839428
50
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
51
Message-Id: <20190816171503.24761-1-philmd@redhat.com>
23
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
52
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
24
---
53
---
25
hw/block/virtio-blk.c | 13 +++++++++----
54
hw/block/dataplane/virtio-blk.c | 3 +++
26
1 file changed, 9 insertions(+), 4 deletions(-)
55
1 file changed, 3 insertions(+)
27
56
28
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
57
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
29
index XXXXXXX..XXXXXXX 100644
58
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/block/virtio-blk.c
59
--- a/hw/block/dataplane/virtio-blk.c
31
+++ b/hw/block/virtio-blk.c
60
+++ b/hw/block/dataplane/virtio-blk.c
32
@@ -XXX,XX +XXX,XX @@
61
@@ -XXX,XX +XXX,XX @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev)
33
#include "hw/virtio/virtio-bus.h"
62
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
34
#include "hw/virtio/virtio-access.h"
63
}
35
64
36
+/* We don't support discard yet, hide associated config fields. */
65
+ qemu_bh_cancel(s->bh);
37
+#define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \
66
+ notify_guest_bh(s); /* final chance to notify guest */
38
+ max_discard_sectors)
39
+
67
+
40
static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
68
/* Clean up guest notifier (irq) */
41
VirtIOBlockReq *req)
69
k->set_guest_notifiers(qbus->parent, nvqs, false);
42
{
70
43
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
44
blkcfg.alignment_offset = 0;
45
blkcfg.wce = blk_enable_write_cache(s->blk);
46
virtio_stw_p(vdev, &blkcfg.num_queues, s->conf.num_queues);
47
- memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
48
+ memcpy(config, &blkcfg, VIRTIO_BLK_CFG_SIZE);
49
+ QEMU_BUILD_BUG_ON(VIRTIO_BLK_CFG_SIZE > sizeof(blkcfg));
50
}
51
52
static void virtio_blk_set_config(VirtIODevice *vdev, const uint8_t *config)
53
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_set_config(VirtIODevice *vdev, const uint8_t *config)
54
VirtIOBlock *s = VIRTIO_BLK(vdev);
55
struct virtio_blk_config blkcfg;
56
57
- memcpy(&blkcfg, config, sizeof(blkcfg));
58
+ memcpy(&blkcfg, config, VIRTIO_BLK_CFG_SIZE);
59
+ QEMU_BUILD_BUG_ON(VIRTIO_BLK_CFG_SIZE > sizeof(blkcfg));
60
61
aio_context_acquire(blk_get_aio_context(s->blk));
62
blk_set_enable_write_cache(s->blk, blkcfg.wce != 0);
63
@@ -XXX,XX +XXX,XX @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
64
return;
65
}
66
67
- virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
68
- sizeof(struct virtio_blk_config));
69
+ virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, VIRTIO_BLK_CFG_SIZE);
70
71
s->blk = conf->conf.blk;
72
s->rq = NULL;
73
--
71
--
74
2.20.1
72
2.21.0
75
73
76
74
diff view generated by jsdifflib