]>
Commit | Line | Data |
---|---|---|
4676c0af DM |
1 | Index: new/qemu-options.hx |
2 | =================================================================== | |
f0e7a188 DM |
3 | --- new.orig/qemu-options.hx 2013-11-26 10:50:22.000000000 +0100 |
4 | +++ new/qemu-options.hx 2013-11-26 11:04:08.000000000 +0100 | |
5 | @@ -362,6 +362,12 @@ | |
6 | @table @option | |
4676c0af DM |
7 | ETEXI |
8 | ||
9 | +DEF("id", HAS_ARG, QEMU_OPTION_id, | |
10 | + "-id n set the faisched ID\n", QEMU_ARCH_ALL) | |
11 | + | |
12 | +DEF("cpuunits", HAS_ARG, QEMU_OPTION_cpuunits, | |
13 | + "-cpuuinits n set fairsched cpu units\n", QEMU_ARCH_ALL) | |
14 | + | |
15 | DEF("fda", HAS_ARG, QEMU_OPTION_fda, | |
16 | "-fda/-fdb file use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL) | |
17 | DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL) | |
18 | Index: new/vl.c | |
19 | =================================================================== | |
f0e7a188 DM |
20 | --- new.orig/vl.c 2013-11-26 10:50:23.000000000 +0100 |
21 | +++ new/vl.c 2013-11-26 11:04:08.000000000 +0100 | |
22 | @@ -155,6 +155,8 @@ | |
4676c0af | 23 | #endif |
92bf040c | 24 | #include "sysemu/qtest.h" |
4676c0af DM |
25 | |
26 | +#include "vzsyscalls.h" | |
27 | + | |
92bf040c | 28 | #include "disas/disas.h" |
4676c0af | 29 | |
92bf040c DM |
30 | #include "qemu/sockets.h" |
31 | @@ -207,6 +209,7 @@ | |
32 | CharDriverState *sclp_hds[MAX_SCLP_CONSOLES]; | |
b4818867 | 33 | int win2k_install_hack = 0; |
4676c0af DM |
34 | int singlestep = 0; |
35 | +int fairsched_id = 0; | |
36 | int smp_cpus = 1; | |
37 | int max_cpus = 0; | |
38 | int smp_cores = 1; | |
f0e7a188 | 39 | @@ -2819,6 +2822,9 @@ |
b4818867 | 40 | int main(int argc, char **argv, char **envp) |
4676c0af | 41 | { |
4676c0af DM |
42 | int i; |
43 | + int cpuunits = 0; | |
24565bc0 DM |
44 | + long int fairsched_id_long = 0; |
45 | + char *ep; | |
4676c0af DM |
46 | int snapshot, linux_boot; |
47 | const char *icount_option = NULL; | |
48 | const char *initrd_filename; | |
f0e7a188 | 49 | @@ -3553,6 +3559,21 @@ |
4676c0af DM |
50 | exit(1); |
51 | } | |
52 | break; | |
53 | + case QEMU_OPTION_id: | |
24565bc0 DM |
54 | + fairsched_id_long = strtol(optarg, &ep, 10); |
55 | + fairsched_id = fairsched_id_long; | |
56 | + if (*ep != 0 || fairsched_id_long < 100 || fairsched_id_long > INT_MAX) { | |
4676c0af DM |
57 | + fprintf(stderr, "Invalid ID\n"); |
58 | + exit(1); | |
59 | + } | |
60 | + break; | |
61 | + case QEMU_OPTION_cpuunits: | |
62 | + cpuunits = atoi(optarg); | |
63 | + if (cpuunits < 8 || cpuunits > 500000) { | |
64 | + fprintf(stderr, "Invalid value for cpuunits\n"); | |
65 | + exit(1); | |
66 | + } | |
67 | + break; | |
68 | case QEMU_OPTION_vnc: | |
69 | #ifdef CONFIG_VNC | |
70 | display_remote++; | |
f0e7a188 | 71 | @@ -4136,6 +4157,39 @@ |
07a7849d DM |
72 | } |
73 | } | |
4676c0af DM |
74 | |
75 | + if (cpuunits && !fairsched_id) { | |
76 | + fprintf(stderr, "cpuunits specified without -id"); | |
77 | + exit (1); | |
78 | + } | |
79 | + | |
80 | + if (fairsched_id && cpuunits) { | |
07a7849d DM |
81 | + int ret; |
82 | + int weight = cpuunits ? 500000/cpuunits : 500; | |
83 | + pid_t cpid = getpid(); | |
4676c0af | 84 | + |
07a7849d DM |
85 | + ret = syscall(__NR_fairsched_rmnod, fairsched_id); |
86 | + if (ret == -EBUSY) { | |
87 | + fprintf (stderr, "unable to create fairsched node - still in use\n"); | |
88 | + exit(1); | |
89 | + } | |
4676c0af | 90 | + |
07a7849d DM |
91 | + ret = syscall(__NR_fairsched_mknod, 0, weight, fairsched_id); |
92 | + if (ret != fairsched_id) { | |
93 | + fprintf (stderr, "unable to create fairsched node\n"); | |
94 | + exit(1); | |
95 | + } | |
4676c0af | 96 | + |
07a7849d DM |
97 | + ret = syscall(__NR_fairsched_mvpr, cpid, fairsched_id); |
98 | + if (ret != 0) { | |
99 | + fprintf (stderr, "unable to move procces to fairsched group"); | |
100 | + exit (1); | |
101 | + } | |
4676c0af | 102 | + |
07a7849d DM |
103 | + /* note: we can never remove ourself from the group, so the empty group |
104 | + will exist after we finish | |
105 | + */ | |
4676c0af DM |
106 | + } |
107 | + | |
07a7849d | 108 | cpu_exec_init_all(); |
4676c0af | 109 | |
f0e7a188 | 110 | blk_mig_init(); |
4676c0af DM |
111 | Index: new/vzsyscalls.h |
112 | =================================================================== | |
113 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | |
f0e7a188 | 114 | +++ new/vzsyscalls.h 2013-11-26 11:04:08.000000000 +0100 |
4676c0af DM |
115 | @@ -0,0 +1,47 @@ |
116 | +/* | |
117 | + * Copyright (C) 2000-2008, Parallels, Inc. All rights reserved. | |
118 | + * | |
119 | + * This program is free software; you can redistribute it and/or modify | |
120 | + * it under the terms of the GNU General Public License as published by | |
121 | + * the Free Software Foundation; either version 2 of the License, or | |
122 | + * (at your option) any later version. | |
123 | + * | |
124 | + * This program is distributed in the hope that it will be useful, | |
125 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
126 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
127 | + * GNU General Public License for more details. | |
128 | + * | |
129 | + * You should have received a copy of the GNU General Public License | |
130 | + * along with this program; if not, write to the Free Software | |
131 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
132 | + */ | |
133 | +#ifndef _VZSYSCALLS_H_ | |
134 | +#define _VZSYSCALLS_H_ | |
135 | + | |
136 | +#include <sys/syscall.h> | |
137 | + | |
138 | +#ifdef __x86_64__ | |
139 | +#define __NR_fairsched_vcpus 499 | |
140 | +#define __NR_setluid 501 | |
141 | +#define __NR_setublimit 502 | |
142 | +#define __NR_fairsched_mknod 504 | |
143 | +#define __NR_fairsched_rmnod 505 | |
144 | +#define __NR_fairsched_chwt 506 | |
145 | +#define __NR_fairsched_mvpr 507 | |
146 | +#define __NR_fairsched_rate 508 | |
147 | +#define __NR_ioprio_set 251 | |
148 | +#elif defined(__i386__) | |
149 | +#define __NR_fairsched_mknod 500 | |
150 | +#define __NR_fairsched_rmnod 501 | |
151 | +#define __NR_fairsched_chwt 502 | |
152 | +#define __NR_fairsched_mvpr 503 | |
153 | +#define __NR_fairsched_rate 504 | |
154 | +#define __NR_fairsched_vcpus 505 | |
155 | +#define __NR_setluid 511 | |
156 | +#define __NR_setublimit 512 | |
157 | +#define __NR_ioprio_set 289 | |
158 | +#else | |
159 | +#error "no syscall for this arch" | |
160 | +#endif | |
161 | + | |
162 | +#endif |