1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/alpha/kernel/osf_sys.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/alpha/kernel/osf_sys.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/alpha/kernel/osf_sys.c 2006-05-11 16:06:22 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/alpha/kernel/osf_sys.c 2006-05-29 16:49:23 +0200
@@ -887,7 +887,7 @@ osf_gettimeofday(struct timeval32 __user
{
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/ia64/ia32/sys_ia32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/ia64/ia32/sys_ia32.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/ia64/ia32/sys_ia32.c 2006-04-28 05:07:10 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/ia64/ia32/sys_ia32.c 2006-05-29 16:49:39 +0200
@@ -1191,7 +1191,7 @@ sys32_gettimeofday (struct compat_timeva
{
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/mips/kernel/linux32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/mips/kernel/linux32.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/mips/kernel/linux32.c 2006-04-26 19:06:59 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/mips/kernel/linux32.c 2006-05-29 16:49:44 +0200
@@ -300,7 +300,7 @@ sys32_gettimeofday(struct compat_timeval
{
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/parisc/kernel/sys_parisc32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/parisc/kernel/sys_parisc32.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/parisc/kernel/sys_parisc32.c 2006-04-26 19:06:59 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/parisc/kernel/sys_parisc32.c 2006-05-29 16:50:03 +0200
@@ -203,11 +203,11 @@ static inline long get_ts32(struct times
asmlinkage int
sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz)
{
- extern void do_gettimeofday(struct timeval *tv);
+ extern void vx_gettimeofday(struct timeval *tv);
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_compat_timeval(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/powerpc/kernel/sys_ppc32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/powerpc/kernel/sys_ppc32.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/powerpc/kernel/sys_ppc32.c 2006-04-09 13:49:43 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/powerpc/kernel/sys_ppc32.c 2006-05-29 16:50:23 +0200
@@ -340,7 +340,7 @@ asmlinkage long compat_sys_gettimeofday(
{
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/s390/kernel/compat_linux.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/s390/kernel/compat_linux.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/s390/kernel/compat_linux.c 2006-02-18 14:39:48 +0100
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/s390/kernel/compat_linux.c 2006-05-29 16:53:03 +0200
@@ -595,7 +595,7 @@ asmlinkage long sys32_gettimeofday(struc
{
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/sparc64/kernel/sys_sparc32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/sparc64/kernel/sys_sparc32.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/sparc64/kernel/sys_sparc32.c 2006-02-18 14:39:49 +0100
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/sparc64/kernel/sys_sparc32.c 2006-05-29 16:53:09 +0200
@@ -788,7 +788,7 @@ asmlinkage long sys32_gettimeofday(struc
{
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/arch/x86_64/ia32/sys_ia32.c linux-2.6.16.17-vs2.1.1-rc21.2/arch/x86_64/ia32/sys_ia32.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/arch/x86_64/ia32/sys_ia32.c 2006-04-26 19:07:00 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/arch/x86_64/ia32/sys_ia32.c 2006-05-29 16:53:21 +0200
@@ -461,7 +461,7 @@ sys32_gettimeofday(struct compat_timeval
{
if (tv) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (put_tv32(tv, &ktv))
return -EFAULT;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/fs/exec.c linux-2.6.16.17-vs2.1.1-rc21.2/fs/exec.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/fs/exec.c 2006-04-26 19:07:00 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/fs/exec.c 2006-05-29 16:54:23 +0200
@@ -1323,7 +1323,7 @@ static void format_corename(char *corena
/* UNIX time of coredump */
case 't': {
struct timeval tv;
- do_gettimeofday(&tv);
+ vx_gettimeofday(&tv);
rc = snprintf(out_ptr, out_end - out_ptr,
"%lu", tv.tv_sec);
if (rc > out_end - out_ptr)
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/time.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/time.h
--- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/time.h 2006-02-15 13:54:35 +0100
+++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/time.h 2006-05-29 17:31:53 +0200
@@ -147,6 +147,8 @@ extern struct timespec ns_to_timespec(co
*/
extern struct timeval ns_to_timeval(const nsec_t nsec);
+#include <linux/vs_time.h>
+
#endif /* __KERNEL__ */
#define NFDBITS __NFDBITS
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vs_time.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vs_time.h
--- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vs_time.h 1970-01-01 01:00:00 +0100
+++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vs_time.h 2006-05-29 18:03:54 +0200
@@ -0,0 +1,19 @@
+#ifndef _VX_VS_TIME_H
+#define _VX_VS_TIME_H
+
+
+/* time faking stuff */
+
+#ifdef CONFIG_VSERVER_VTIME
+
+extern void vx_gettimeofday(struct timeval *tv);
+extern int vx_settimeofday(struct timeval *tv);
+
+#else
+#define vx_gettimeofday(t) do_gettimeofday(t)
+#define vx_settimeofday(t) do_settimeofday(t)
+#endif
+
+#else
+#warning duplicate inclusion
+#endif
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/context.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/context.h
--- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/context.h 2006-05-02 02:06:16 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/context.h 2006-05-29 17:49:04 +0200
@@ -35,6 +35,7 @@
#define VXF_VIRT_UPTIME 0x00020000
#define VXF_VIRT_CPU 0x00040000
#define VXF_VIRT_LOAD 0x00080000
+#define VXF_VIRT_TIME 0x00100000
#define VXF_HIDE_MOUNT 0x01000000
#define VXF_HIDE_NETIF 0x02000000
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/cvirt_def.h linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/cvirt_def.h
--- linux-2.6.16.17-vs2.1.1-rc21.1/include/linux/vserver/cvirt_def.h 2006-04-26 19:07:00 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/include/linux/vserver/cvirt_def.h 2006-05-29 17:36:22 +0200
@@ -43,6 +43,7 @@ struct _vx_cvirt {
atomic_t nr_onhold; /* processes on hold */
uint32_t onhold_last; /* jiffies when put on hold */
+ struct timeval bias_tv; /* time offset to the host */
struct timespec bias_idle;
struct timespec bias_uptime; /* context creation point */
uint64_t bias_clock; /* offset in clock_t */
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/compat.c linux-2.6.16.17-vs2.1.1-rc21.2/kernel/compat.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/compat.c 2006-02-18 14:40:37 +0100
+++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/compat.c 2006-05-29 16:58:56 +0200
@@ -841,7 +841,7 @@ asmlinkage long compat_sys_time(compat_t
compat_time_t i;
struct timeval tv;
- do_gettimeofday(&tv);
+ vx_gettimeofday(&tv);
i = tv.tv_sec;
if (tloc) {
@@ -865,7 +865,7 @@ asmlinkage long compat_sys_stime(compat_
if (err)
return err;
- do_settimeofday(&tv);
+ vx_settimeofday(&tv);
return 0;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/time.c linux-2.6.16.17-vs2.1.1-rc21.2/kernel/time.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/time.c 2006-02-18 14:40:38 +0100
+++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/time.c 2006-05-29 16:59:20 +0200
@@ -61,7 +61,7 @@ asmlinkage long sys_time(time_t __user *
time_t i;
struct timeval tv;
- do_gettimeofday(&tv);
+ vx_gettimeofday(&tv);
i = tv.tv_sec;
if (tloc) {
@@ -92,7 +92,7 @@ asmlinkage long sys_stime(time_t __user
if (err)
return err;
- do_settimeofday(&tv);
+ vx_settimeofday(&tv);
return 0;
}
@@ -102,7 +102,7 @@ asmlinkage long sys_gettimeofday(struct
{
if (likely(tv != NULL)) {
struct timeval ktv;
- do_gettimeofday(&ktv);
+ vx_gettimeofday(&ktv);
if (copy_to_user(tv, &ktv, sizeof(ktv)))
return -EFAULT;
}
@@ -176,7 +176,7 @@ int do_sys_settimeofday(struct timespec
/* SMP safe, again the code in arch/foo/time.c should
* globally block out interrupts when it runs.
*/
- return do_settimeofday(tv);
+ return vx_settimeofday(tv);
}
return 0;
}
@@ -558,7 +558,7 @@ void getnstimeofday(struct timespec *tv)
{
struct timeval x;
- do_gettimeofday(&x);
+ vx_gettimeofday(&x);
tv->tv_sec = x.tv_sec;
tv->tv_nsec = x.tv_usec * NSEC_PER_USEC;
}
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/Kconfig linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/Kconfig
--- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/Kconfig 2006-05-11 21:00:03 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/Kconfig 2006-05-29 18:02:20 +0200
@@ -66,6 +66,16 @@ config VSERVER_COWBL
when writing to them (which will implicitely break the
link and create a copy of the unified file)
+config VSERVER_VTIME
+ bool "Enable Virtualized Guest Time"
+ depends on EXPERIMENTAL
+ default n
+ help
+ This enables per guest time offsets to allow for
+ adjusting the system clock individually per guest.
+ this adds some overhead to the time functions and
+ therefore should not be enabled without good reason.
+
config VSERVER_PROC_SECURE
bool "Enable Proc Security"
depends on PROC_FS
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt.c linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt.c
--- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt.c 2006-04-26 19:07:00 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt.c 2006-05-29 18:04:24 +0200
@@ -255,3 +255,43 @@ out_put:
put_vx_info(vxi);
return (name ? 0 : -EFAULT);
}
+
+#ifdef CONFIG_VSERVER_VTIME
+
+/* virtualized time base */
+
+void vx_gettimeofday(struct timeval *tv)
+{
+ do_gettimeofday(tv);
+ if (!vx_flags(VXF_VIRT_TIME, 0))
+ return;
+
+ tv->tv_sec += current->vx_info->cvirt.bias_tv.tv_sec;
+ tv->tv_usec += current->vx_info->cvirt.bias_tv.tv_usec;
+
+ if (tv->tv_usec >= USEC_PER_SEC) {
+ tv->tv_sec++;
+ tv->tv_usec -= USEC_PER_SEC;
+ } else if (tv->tv_usec < 0) {
+ tv->tv_sec--;
+ tv->tv_usec += USEC_PER_SEC;
+ }
+}
+
+int vx_settimeofday(struct timeval *tv)
+{
+ struct timeval tvs;
+
+ if (!vx_flags(VXF_VIRT_TIME, 0))
+ return do_settimeofday(tv);
+
+ do_gettimeofday(&tvs);
+ current->vx_info->cvirt.bias_tv.tv_sec =
+ tv->tv_sec - tvs.tv_sec;
+ current->vx_info->cvirt.bias_tv.tv_usec =
+ tv->tv_usec - tvs.tv_usec;
+ return 0;
+}
+
+#endif
+
diff -NurpP --minimal linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt_init.h linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt_init.h
--- linux-2.6.16.17-vs2.1.1-rc21.1/kernel/vserver/cvirt_init.h 2006-04-26 19:07:00 +0200
+++ linux-2.6.16.17-vs2.1.1-rc21.2/kernel/vserver/cvirt_init.h 2006-05-29 17:38:33 +0200
@@ -11,6 +11,8 @@ static inline void vx_info_init_cvirt(st
nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
* NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
cvirt->bias_clock = nsec_to_clock_t(nsuptime);
+ cvirt->bias_tv.tv_sec = 0;
+ cvirt->bias_tv.tv_usec = 0;
jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
atomic_set(&cvirt->nr_threads, 0);
|