]>
Commit | Line | Data |
---|---|---|
4676c0af DM |
1 | Index: new/qemu-options.hx |
2 | =================================================================== | |
24bb7da3 DM |
3 | --- new.orig/qemu-options.hx 2014-11-20 06:45:06.000000000 +0100 |
4 | +++ new/qemu-options.hx 2014-11-20 06:50:44.000000000 +0100 | |
5 | @@ -386,6 +386,12 @@ | |
f0e7a188 | 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 | =================================================================== | |
24bb7da3 DM |
20 | --- new.orig/vl.c 2014-11-20 06:45:06.000000000 +0100 |
21 | +++ new/vl.c 2014-11-20 06:50:44.000000000 +0100 | |
e549ff74 | 22 | @@ -101,6 +101,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 | |
1d91c55e | 30 | |
24bb7da3 | 31 | @@ -154,6 +156,7 @@ |
92bf040c | 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; | |
24bb7da3 | 39 | @@ -2738,6 +2741,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 | 46 | int snapshot, linux_boot; |
4676c0af | 47 | const char *initrd_filename; |
24bb7da3 DM |
48 | const char *kernel_filename, *kernel_cmdline; |
49 | @@ -3560,6 +3566,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++; | |
24bb7da3 | 71 | @@ -3844,6 +3865,40 @@ |
e549ff74 DM |
72 | OBJECT_CLASS(machine_class)))); |
73 | object_property_add_child(object_get_root(), "machine", | |
74 | OBJECT(current_machine), &error_abort); | |
75 | + | |
4676c0af | 76 | + if (cpuunits && !fairsched_id) { |
e549ff74 DM |
77 | + fprintf(stderr, "cpuunits specified without -id"); |
78 | + exit(1); | |
4676c0af DM |
79 | + } |
80 | + | |
81 | + if (fairsched_id && cpuunits) { | |
07a7849d DM |
82 | + int ret; |
83 | + int weight = cpuunits ? 500000/cpuunits : 500; | |
84 | + pid_t cpid = getpid(); | |
4676c0af | 85 | + |
07a7849d DM |
86 | + ret = syscall(__NR_fairsched_rmnod, fairsched_id); |
87 | + if (ret == -EBUSY) { | |
88 | + fprintf (stderr, "unable to create fairsched node - still in use\n"); | |
89 | + exit(1); | |
90 | + } | |
4676c0af | 91 | + |
07a7849d DM |
92 | + ret = syscall(__NR_fairsched_mknod, 0, weight, fairsched_id); |
93 | + if (ret != fairsched_id) { | |
94 | + fprintf (stderr, "unable to create fairsched node\n"); | |
95 | + exit(1); | |
96 | + } | |
4676c0af | 97 | + |
07a7849d DM |
98 | + ret = syscall(__NR_fairsched_mvpr, cpid, fairsched_id); |
99 | + if (ret != 0) { | |
100 | + fprintf (stderr, "unable to move procces to fairsched group"); | |
101 | + exit (1); | |
102 | + } | |
4676c0af | 103 | + |
07a7849d DM |
104 | + /* note: we can never remove ourself from the group, so the empty group |
105 | + will exist after we finish | |
106 | + */ | |
4676c0af DM |
107 | + } |
108 | + | |
07a7849d | 109 | cpu_exec_init_all(); |
4676c0af | 110 | |
e549ff74 | 111 | if (machine_class->hw_version) { |
4676c0af DM |
112 | Index: new/vzsyscalls.h |
113 | =================================================================== | |
114 | --- /dev/null 1970-01-01 00:00:00.000000000 +0000 | |
24bb7da3 | 115 | +++ new/vzsyscalls.h 2014-11-20 06:50:44.000000000 +0100 |
4676c0af DM |
116 | @@ -0,0 +1,47 @@ |
117 | +/* | |
118 | + * Copyright (C) 2000-2008, Parallels, Inc. All rights reserved. | |
119 | + * | |
120 | + * This program is free software; you can redistribute it and/or modify | |
121 | + * it under the terms of the GNU General Public License as published by | |
122 | + * the Free Software Foundation; either version 2 of the License, or | |
123 | + * (at your option) any later version. | |
124 | + * | |
125 | + * This program is distributed in the hope that it will be useful, | |
126 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
127 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
128 | + * GNU General Public License for more details. | |
129 | + * | |
130 | + * You should have received a copy of the GNU General Public License | |
131 | + * along with this program; if not, write to the Free Software | |
132 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
133 | + */ | |
134 | +#ifndef _VZSYSCALLS_H_ | |
135 | +#define _VZSYSCALLS_H_ | |
136 | + | |
137 | +#include <sys/syscall.h> | |
138 | + | |
139 | +#ifdef __x86_64__ | |
140 | +#define __NR_fairsched_vcpus 499 | |
141 | +#define __NR_setluid 501 | |
142 | +#define __NR_setublimit 502 | |
143 | +#define __NR_fairsched_mknod 504 | |
144 | +#define __NR_fairsched_rmnod 505 | |
145 | +#define __NR_fairsched_chwt 506 | |
146 | +#define __NR_fairsched_mvpr 507 | |
147 | +#define __NR_fairsched_rate 508 | |
148 | +#define __NR_ioprio_set 251 | |
149 | +#elif defined(__i386__) | |
150 | +#define __NR_fairsched_mknod 500 | |
151 | +#define __NR_fairsched_rmnod 501 | |
152 | +#define __NR_fairsched_chwt 502 | |
153 | +#define __NR_fairsched_mvpr 503 | |
154 | +#define __NR_fairsched_rate 504 | |
155 | +#define __NR_fairsched_vcpus 505 | |
156 | +#define __NR_setluid 511 | |
157 | +#define __NR_setublimit 512 | |
158 | +#define __NR_ioprio_set 289 | |
159 | +#else | |
160 | +#error "no syscall for this arch" | |
161 | +#endif | |
162 | + | |
163 | +#endif |