]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/fairsched.diff
796696daaabead44eb2e1a21110002cfc36ab84e
[pve-qemu-kvm.git] / debian / patches / fairsched.diff
1 Index: new/qemu-options.hx
2 ===================================================================
3 --- new.orig/qemu-options.hx 2012-03-12 06:44:56.000000000 +0100
4 +++ new/qemu-options.hx 2012-03-13 07:25:22.000000000 +0100
5 @@ -95,6 +95,12 @@
6 are split equally.
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 ===================================================================
20 --- new.orig/vl.c 2012-03-12 06:44:56.000000000 +0100
21 +++ new/vl.c 2012-03-13 07:25:22.000000000 +0100
22 @@ -153,6 +153,8 @@
23 #include "fsdev/qemu-fsdev.h"
24 #endif
25
26 +#include "vzsyscalls.h"
27 +
28 #include "disas.h"
29
30 #include "qemu_socket.h"
31 @@ -203,6 +205,7 @@
32 int win2k_install_hack = 0;
33 int usb_enabled = 0;
34 int singlestep = 0;
35 +int fairsched_id = 0;
36 int smp_cpus = 1;
37 int max_cpus = 0;
38 int smp_cores = 1;
39 @@ -2045,7 +2048,7 @@
40 }
41
42 static int debugcon_parse(const char *devname)
43 -{
44 +{
45 QemuOpts *opts;
46
47 if (!qemu_chr_new("debugcon", devname, NULL)) {
48 @@ -2258,6 +2261,7 @@
49 int main(int argc, char **argv, char **envp)
50 {
51 int i;
52 + int cpuunits = 0;
53 int snapshot, linux_boot;
54 const char *icount_option = NULL;
55 const char *initrd_filename;
56 @@ -3022,6 +3026,20 @@
57 exit(1);
58 }
59 break;
60 + case QEMU_OPTION_id:
61 + fairsched_id = atoi(optarg);
62 + if (fairsched_id < 100 || fairsched_id >= 1000000) {
63 + fprintf(stderr, "Invalid ID\n");
64 + exit(1);
65 + }
66 + break;
67 + case QEMU_OPTION_cpuunits:
68 + cpuunits = atoi(optarg);
69 + if (cpuunits < 8 || cpuunits > 500000) {
70 + fprintf(stderr, "Invalid value for cpuunits\n");
71 + exit(1);
72 + }
73 + break;
74 case QEMU_OPTION_vnc:
75 #ifdef CONFIG_VNC
76 display_remote++;
77 @@ -3093,8 +3111,8 @@
78 }
79 p += 8;
80 os_set_proc_name(p);
81 - }
82 - }
83 + }
84 + }
85 break;
86 case QEMU_OPTION_prom_env:
87 if (nb_prom_envs >= MAX_PROM_ENVS) {
88 @@ -3411,6 +3429,39 @@
89 }
90 }
91
92 + if (cpuunits && !fairsched_id) {
93 + fprintf(stderr, "cpuunits specified without -id");
94 + exit (1);
95 + }
96 +
97 + if (fairsched_id && cpuunits) {
98 + int ret;
99 + int weight = cpuunits ? 500000/cpuunits : 500;
100 + pid_t cpid = getpid();
101 +
102 + ret = syscall(__NR_fairsched_rmnod, fairsched_id);
103 + if (ret == -EBUSY) {
104 + fprintf (stderr, "unable to create fairsched node - still in use\n");
105 + exit(1);
106 + }
107 +
108 + ret = syscall(__NR_fairsched_mknod, 0, weight, fairsched_id);
109 + if (ret != fairsched_id) {
110 + fprintf (stderr, "unable to create fairsched node\n");
111 + exit(1);
112 + }
113 +
114 + ret = syscall(__NR_fairsched_mvpr, cpid, fairsched_id);
115 + if (ret != 0) {
116 + fprintf (stderr, "unable to move procces to fairsched group");
117 + exit (1);
118 + }
119 +
120 + /* note: we can never remove ourself from the group, so the empty group
121 + will exist after we finish
122 + */
123 + }
124 +
125 cpu_exec_init_all();
126
127 bdrv_init_with_whitelist();
128 Index: new/vzsyscalls.h
129 ===================================================================
130 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
131 +++ new/vzsyscalls.h 2012-03-13 07:25:22.000000000 +0100
132 @@ -0,0 +1,47 @@
133 +/*
134 + * Copyright (C) 2000-2008, Parallels, Inc. All rights reserved.
135 + *
136 + * This program is free software; you can redistribute it and/or modify
137 + * it under the terms of the GNU General Public License as published by
138 + * the Free Software Foundation; either version 2 of the License, or
139 + * (at your option) any later version.
140 + *
141 + * This program is distributed in the hope that it will be useful,
142 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
143 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144 + * GNU General Public License for more details.
145 + *
146 + * You should have received a copy of the GNU General Public License
147 + * along with this program; if not, write to the Free Software
148 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
149 + */
150 +#ifndef _VZSYSCALLS_H_
151 +#define _VZSYSCALLS_H_
152 +
153 +#include <sys/syscall.h>
154 +
155 +#ifdef __x86_64__
156 +#define __NR_fairsched_vcpus 499
157 +#define __NR_setluid 501
158 +#define __NR_setublimit 502
159 +#define __NR_fairsched_mknod 504
160 +#define __NR_fairsched_rmnod 505
161 +#define __NR_fairsched_chwt 506
162 +#define __NR_fairsched_mvpr 507
163 +#define __NR_fairsched_rate 508
164 +#define __NR_ioprio_set 251
165 +#elif defined(__i386__)
166 +#define __NR_fairsched_mknod 500
167 +#define __NR_fairsched_rmnod 501
168 +#define __NR_fairsched_chwt 502
169 +#define __NR_fairsched_mvpr 503
170 +#define __NR_fairsched_rate 504
171 +#define __NR_fairsched_vcpus 505
172 +#define __NR_setluid 511
173 +#define __NR_setublimit 512
174 +#define __NR_ioprio_set 289
175 +#else
176 +#error "no syscall for this arch"
177 +#endif
178 +
179 +#endif