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