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