1 |
cardoe 13/05/28 17:07:00 |
2 |
|
3 |
Added: |
4 |
libvirt-1.0.5.1-0001-cgroup-be-robust-against-cgroup-movement-races.patch |
5 |
libvirt-1.0.5.1-0002-qemu-fix-NBD-migration-to-hosts-with-IPv6-enabled.patch |
6 |
Log: |
7 |
Bump to fix cgroup movement race and nbd based migrations on IPv6 enabled hosts. |
8 |
|
9 |
(Portage version: 2.1.11.62/cvs/Linux x86_64, signed Manifest commit with key D7DFA8D318FA9AEF!) |
10 |
|
11 |
Revision Changes Path |
12 |
1.1 app-emulation/libvirt/files/libvirt-1.0.5.1-0001-cgroup-be-robust-against-cgroup-movement-races.patch |
13 |
|
14 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirt-1.0.5.1-0001-cgroup-be-robust-against-cgroup-movement-races.patch?rev=1.1&view=markup |
15 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirt-1.0.5.1-0001-cgroup-be-robust-against-cgroup-movement-races.patch?rev=1.1&content-type=text/plain |
16 |
|
17 |
Index: libvirt-1.0.5.1-0001-cgroup-be-robust-against-cgroup-movement-races.patch |
18 |
=================================================================== |
19 |
From b4541a2f3d7ed9e1522065195b4f31529228e493 Mon Sep 17 00:00:00 2001 |
20 |
From: Eric Blake <eblake@××××××.com> |
21 |
Date: Mon, 20 May 2013 20:30:30 -0600 |
22 |
Subject: [PATCH 1/2] cgroup: be robust against cgroup movement races |
23 |
|
24 |
https://bugzilla.redhat.com/show_bug.cgi?id=965169 documents a |
25 |
problem starting domains when cgroups are enabled; I was able |
26 |
to reliably reproduce the race about 5% of the time when I added |
27 |
hooks to domain startup by 3 seconds (as that seemed to be about |
28 |
the length of time that qemu created and then closed a temporary |
29 |
thread, probably related to aio handling of initially opening |
30 |
a disk image). The problem has existed since we introduced |
31 |
virCgroupMoveTask in commit 9102829 (v0.10.0). |
32 |
|
33 |
There are some inherent TOCTTOU races when moving tasks between |
34 |
kernel cgroups, precisely because threads can be created or |
35 |
completed in the window between when we read a thread id from the |
36 |
source and when we write to the destination. As the goal of |
37 |
virCgroupMoveTask is merely to move ALL tasks into the new |
38 |
cgroup, it is sufficient to iterate until no more threads are |
39 |
being created in the old group, and ignoring any threads that |
40 |
die before we can move them. |
41 |
|
42 |
It would be nicer to start the threads in the right cgroup to |
43 |
begin with, but by default, all child threads are created in |
44 |
the same cgroup as their parent, and we don't want vcpu child |
45 |
threads in the emulator cgroup, so I don't see any good way |
46 |
of avoiding the move. It would also be nice if the kernel were |
47 |
to implement something like rename() as a way to atomically move |
48 |
a group of threads from one cgroup to another, instead of forcing |
49 |
a window where we have to read and parse the source, then format |
50 |
and write back into the destination. |
51 |
|
52 |
* src/util/vircgroup.c (virCgroupAddTaskStrController): Ignore |
53 |
ESRCH, because a thread ended between read and write attempts. |
54 |
(virCgroupMoveTask): Loop until all threads have moved. |
55 |
|
56 |
Signed-off-by: Eric Blake <eblake@××××××.com> |
57 |
(cherry picked from commit 83e4c77547f5b721afad19a452f41c31daeee8c5) |
58 |
--- |
59 |
src/util/vircgroup.c | 28 ++++++++++++++++++++-------- |
60 |
1 file changed, 20 insertions(+), 8 deletions(-) |
61 |
|
62 |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c |
63 |
index b05fc45..92b185e 100644 |
64 |
--- a/src/util/vircgroup.c |
65 |
+++ b/src/util/vircgroup.c |
66 |
@@ -1037,7 +1037,11 @@ static int virCgroupAddTaskStrController(virCgroupPtr group, |
67 |
goto cleanup; |
68 |
|
69 |
rc = virCgroupAddTaskController(group, p, controller); |
70 |
- if (rc != 0) |
71 |
+ /* A thread that exits between when we first read the source |
72 |
+ * tasks and now is not fatal. */ |
73 |
+ if (rc == -ESRCH) |
74 |
+ rc = 0; |
75 |
+ else if (rc != 0) |
76 |
goto cleanup; |
77 |
|
78 |
next = strchr(cur, '\n'); |
79 |
@@ -1074,15 +1078,23 @@ int virCgroupMoveTask(virCgroupPtr src_group, virCgroupPtr dest_group) |
80 |
!dest_group->controllers[i].mountPoint) |
81 |
continue; |
82 |
|
83 |
- rc = virCgroupGetValueStr(src_group, i, "tasks", &content); |
84 |
- if (rc != 0) |
85 |
- return rc; |
86 |
+ /* New threads are created in the same group as their parent; |
87 |
+ * but if a thread is created after we first read we aren't |
88 |
+ * aware that it needs to move. Therefore, we must iterate |
89 |
+ * until content is empty. */ |
90 |
+ while (1) { |
91 |
+ rc = virCgroupGetValueStr(src_group, i, "tasks", &content); |
92 |
+ if (rc != 0) |
93 |
+ return rc; |
94 |
+ if (!*content) |
95 |
+ break; |
96 |
|
97 |
- rc = virCgroupAddTaskStrController(dest_group, content, i); |
98 |
- if (rc != 0) |
99 |
- goto cleanup; |
100 |
+ rc = virCgroupAddTaskStrController(dest_group, content, i); |
101 |
+ if (rc != 0) |
102 |
+ goto cleanup; |
103 |
|
104 |
- VIR_FREE(content); |
105 |
+ VIR_FREE(content); |
106 |
+ } |
107 |
} |
108 |
|
109 |
cleanup: |
110 |
-- |
111 |
1.8.1.5 |
112 |
|
113 |
|
114 |
|
115 |
|
116 |
1.1 app-emulation/libvirt/files/libvirt-1.0.5.1-0002-qemu-fix-NBD-migration-to-hosts-with-IPv6-enabled.patch |
117 |
|
118 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirt-1.0.5.1-0002-qemu-fix-NBD-migration-to-hosts-with-IPv6-enabled.patch?rev=1.1&view=markup |
119 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/libvirt/files/libvirt-1.0.5.1-0002-qemu-fix-NBD-migration-to-hosts-with-IPv6-enabled.patch?rev=1.1&content-type=text/plain |
120 |
|
121 |
Index: libvirt-1.0.5.1-0002-qemu-fix-NBD-migration-to-hosts-with-IPv6-enabled.patch |
122 |
=================================================================== |
123 |
From 3accd7eb25f3646e15511af4cb0d09c3bf2ce143 Mon Sep 17 00:00:00 2001 |
124 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@××××××.com> |
125 |
Date: Thu, 23 May 2013 15:51:05 +0200 |
126 |
Subject: [PATCH 2/2] qemu: fix NBD migration to hosts with IPv6 enabled |
127 |
|
128 |
Since f03dcc5 we use [::] as the listening address both on qemu |
129 |
command line in -incoming and in nbd-server-start QMP command. |
130 |
However the latter requires just :: without the braces. |
131 |
(cherry picked from commit 2326006410a921bba38c0ce67a367cd1ea88cc33) |
132 |
--- |
133 |
src/qemu/qemu_migration.c | 8 +++++++- |
134 |
1 file changed, 7 insertions(+), 1 deletion(-) |
135 |
|
136 |
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c |
137 |
index 6ad1c30..adc967a 100644 |
138 |
--- a/src/qemu/qemu_migration.c |
139 |
+++ b/src/qemu/qemu_migration.c |
140 |
@@ -1114,6 +1114,12 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver, |
141 |
unsigned short port = 0; |
142 |
char *diskAlias = NULL; |
143 |
size_t i; |
144 |
+ const char *host; |
145 |
+ |
146 |
+ if (STREQ(listenAddr, "[::]")) |
147 |
+ host = "::"; |
148 |
+ else |
149 |
+ host = listenAddr; |
150 |
|
151 |
for (i = 0; i < vm->def->ndisks; i++) { |
152 |
virDomainDiskDefPtr disk = vm->def->disks[i]; |
153 |
@@ -1135,7 +1141,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver, |
154 |
|
155 |
if (!port && |
156 |
((virPortAllocatorAcquire(driver->remotePorts, &port) < 0) || |
157 |
- (qemuMonitorNBDServerStart(priv->mon, listenAddr, port) < 0))) { |
158 |
+ (qemuMonitorNBDServerStart(priv->mon, host, port) < 0))) { |
159 |
qemuDomainObjExitMonitor(driver, vm); |
160 |
goto cleanup; |
161 |
} |
162 |
-- |
163 |
1.8.1.5 |