93c32f Backport Bonzini's vhost-net fix (RHBZ#848400).

Authored and Committed by rjones@redhat.com 12 years ago
    Backport Bonzini's vhost-net fix (RHBZ#848400).
    
        
0001-virtio-fix-vhost-handling.patch ADDED
@@ -0,0 +1,134 @@
1
+ From 26b9b5fe17cc1b6be2e8bf8b9d16094f420bb8ad Mon Sep 17 00:00:00 2001
2
+ From: Paolo Bonzini <pbonzini@redhat.com>
3
+ Date: Mon, 6 Aug 2012 15:26:14 +0200
4
+ Subject: [PATCH] virtio: fix vhost handling
5
+
6
+ Commit b1f416aa8d870fab71030abc9401cfc77b948e8e breaks vhost_net
7
+ because it always registers the virtio_pci_host_notifier_read() handler
8
+ function on the ioeventfd, even when vhost_net.ko is using the ioeventfd.
9
+ The result is both QEMU and vhost_net.ko polling on the same eventfd
10
+ and the virtio_net.ko guest driver seeing inconsistent results:
11
+
12
+ # ifconfig eth0 192.168.0.1 netmask 255.255.255.0
13
+ virtio_net virtio0: output:id 0 is not a head!
14
+
15
+ To fix this, proceed the same as we do for irqfd: add a parameter to
16
+ virtio_queue_set_host_notifier_fd_handler and in that case only set
17
+ the notifier, not the handler.
18
+
19
+ Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
20
+ Tested-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
21
+ Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
22
+ Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
23
+ Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
24
+ ---
25
+ hw/virtio-pci.c | 14 +++++++-------
26
+ hw/virtio.c | 7 +++++--
27
+ hw/virtio.h | 3 ++-
28
+ 3 files changed, 14 insertions(+), 10 deletions(-)
29
+
30
+ diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
31
+ index 3ab9747..125eded 100644
32
+ --- a/hw/virtio-pci.c
33
+ +++ b/hw/virtio-pci.c
34
+ @@ -160,7 +160,7 @@ static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
35
+ }
36
+
37
+ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
38
+ - int n, bool assign)
39
+ + int n, bool assign, bool set_handler)
40
+ {
41
+ VirtQueue *vq = virtio_get_queue(proxy->vdev, n);
42
+ EventNotifier *notifier = virtio_queue_get_host_notifier(vq);
43
+ @@ -173,13 +173,13 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,
44
+ __func__, r);
45
+ return r;
46
+ }
47
+ - virtio_queue_set_host_notifier_fd_handler(vq, true);
48
+ + virtio_queue_set_host_notifier_fd_handler(vq, true, set_handler);
49
+ memory_region_add_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2,
50
+ true, n, notifier);
51
+ } else {
52
+ memory_region_del_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTIFY, 2,
53
+ true, n, notifier);
54
+ - virtio_queue_set_host_notifier_fd_handler(vq, false);
55
+ + virtio_queue_set_host_notifier_fd_handler(vq, false, false);
56
+ event_notifier_cleanup(notifier);
57
+ }
58
+ return r;
59
+ @@ -200,7 +200,7 @@ static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy)
60
+ continue;
61
+ }
62
+
63
+ - r = virtio_pci_set_host_notifier_internal(proxy, n, true);
64
+ + r = virtio_pci_set_host_notifier_internal(proxy, n, true, true);
65
+ if (r < 0) {
66
+ goto assign_error;
67
+ }
68
+ @@ -214,7 +214,7 @@ assign_error:
69
+ continue;
70
+ }
71
+
72
+ - r = virtio_pci_set_host_notifier_internal(proxy, n, false);
73
+ + r = virtio_pci_set_host_notifier_internal(proxy, n, false, false);
74
+ assert(r >= 0);
75
+ }
76
+ proxy->ioeventfd_started = false;
77
+ @@ -235,7 +235,7 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
78
+ continue;
79
+ }
80
+
81
+ - r = virtio_pci_set_host_notifier_internal(proxy, n, false);
82
+ + r = virtio_pci_set_host_notifier_internal(proxy, n, false, false);
83
+ assert(r >= 0);
84
+ }
85
+ proxy->ioeventfd_started = false;
86
+ @@ -683,7 +683,7 @@ static int virtio_pci_set_host_notifier(void *opaque, int n, bool assign)
87
+ * currently only stops on status change away from ok,
88
+ * reset, vmstop and such. If we do add code to start here,
89
+ * need to check vmstate, device state etc. */
90
+ - return virtio_pci_set_host_notifier_internal(proxy, n, assign);
91
+ + return virtio_pci_set_host_notifier_internal(proxy, n, assign, false);
92
+ }
93
+
94
+ static void virtio_pci_vmstate_change(void *opaque, bool running)
95
+ diff --git a/hw/virtio.c b/hw/virtio.c
96
+ index d146f86..209c763 100644
97
+ --- a/hw/virtio.c
98
+ +++ b/hw/virtio.c
99
+ @@ -1021,13 +1021,16 @@ static void virtio_queue_host_notifier_read(EventNotifier *n)
100
+ }
101
+ }
102
+
103
+ -void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign)
104
+ +void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
105
+ + bool set_handler)
106
+ {
107
+ - if (assign) {
108
+ + if (assign && set_handler) {
109
+ event_notifier_set_handler(&vq->host_notifier,
110
+ virtio_queue_host_notifier_read);
111
+ } else {
112
+ event_notifier_set_handler(&vq->host_notifier, NULL);
113
+ + }
114
+ + if (!assign) {
115
+ /* Test and clear notifier before after disabling event,
116
+ * in case poll callback didn't have time to run. */
117
+ virtio_queue_host_notifier_read(&vq->host_notifier);
118
+ diff --git a/hw/virtio.h b/hw/virtio.h
119
+ index f8b5535..7a4f564 100644
120
+ --- a/hw/virtio.h
121
+ +++ b/hw/virtio.h
122
+ @@ -233,7 +233,8 @@ EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq);
123
+ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
124
+ bool with_irqfd);
125
+ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
126
+ -void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign);
127
+ +void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
128
+ + bool set_handler);
129
+ void virtio_queue_notify_vq(VirtQueue *vq);
130
+ void virtio_irq(VirtQueue *vq);
131
+ #endif
132
+ --
133
+ 1.7.10.4
134
+
file modified
+8 -1
qemu.spec CHANGED
@@ -40,7 +40,7 @@
40
40
Summary: QEMU is a FAST! processor emulator
41
41
Name: qemu
42
42
Version: 1.2
43
- Release: 0.2.%{gitdate}git%{gitcommit}%{?dist}
43
+ Release: 0.3.%{gitdate}git%{gitcommit}%{?dist}
44
44
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
45
45
Epoch: 2
46
46
License: GPLv2+ and LGPLv2+ and BSD
@@ -91,6 +91,9 @@ Patch1: 0001-mips-Fix-link-error-with-piix4_pm_init.patch
91
91
# Sent upstream on August 13 2012
92
92
Patch2: 0002-configure-Add-disable-kvm-options.patch
93
93
94
+ # Fix broken vhost-net (upstream).
95
+ Patch3: 0001-virtio-fix-vhost-handling.patch
96
+
94
97
# The infamous chardev flow control patches
95
98
Patch101: 0101-char-Split-out-tcp-socket-close-code-in-a-separate-f.patch
96
99
Patch102: 0102-char-Add-a-QemuChrHandlers-struct-to-initialise-char.patch
@@ -383,6 +386,7 @@ such as kvm_stat.
383
386
384
387
%patch1 -p1
385
388
%patch2 -p1
389
+ %patch3 -p1
386
390
387
391
%patch101 -p1
388
392
%patch102 -p1
@@ -867,6 +871,9 @@ fi
867
871
%{_mandir}/man1/qemu-img.1*
868
872
869
873
%changelog
874
+ * Mon Aug 20 2012 Richard W.M. Jones <rjones@redhat.com> - 1.2-0.3.20120806git3e430569
875
+ - Backport Bonzini's vhost-net fix (RHBZ#848400).
876
+
870
877
* Tue Aug 14 2012 Cole Robinson <crobinso@redhat.com> - 1.2-0.2.20120806git3e430569
871
878
- Bump release number, previous build forgot but the dist bump helped us out
872
879