let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
let bool_val = store /0|1/
+ let int_val = store /[0-9]+/
let str_array_element = [ seq "el" . str_val ] . del /[ \t\n]*/ ""
let str_array_val = counter "el" . array_start . ( str_array_element . ( array_sep . str_array_element ) * ) ? . array_end
let str_entry (kw:string) = [ key kw . value_sep . str_val ]
let bool_entry (kw:string) = [ key kw . value_sep . bool_val ]
+ let int_entry (kw:string) = [ key kw . value_sep . int_val ]
let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
| bool_entry "clear_emulator_capabilities"
| bool_entry "allow_disk_format_probing"
| bool_entry "set_process_name"
+ | int_entry "max_processes"
(* Each enty in the config is one of the following three ... *)
let entry = vnc_entry
# its arguments) appear in process listings.
#
# set_process_name = 1
+
+
+# If max_processes is set to a positive integer, libvirt will use it to set
+# maximum number of processes that can be run by qemu user. This can be used to
+# override default value set by host OS.
+#
+# max_processes = 0
CHECK_TYPE ("set_process_name", VIR_CONF_LONG);
if (p) driver->setProcessName = p->l;
+ p = virConfGetValue(conf, "max_processes");
+ CHECK_TYPE("max_processes", VIR_CONF_LONG);
+ if (p) driver->maxProcesses = p->l;
+
virConfFree (conf);
return 0;
}
unsigned int allowDiskFormatProbing : 1;
unsigned int setProcessName : 1;
+ int maxProcesses;
+
virCapsPtr caps;
/* An array of callbacks */
#include <unistd.h>
#include <signal.h>
#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include "qemu_process.h"
#include "qemu_domain.h"
}
+static int
+qemuProcessLimits(struct qemud_driver *driver)
+{
+ if (driver->maxProcesses > 0) {
+ struct rlimit rlim;
+
+ rlim.rlim_cur = rlim.rlim_max = driver->maxProcesses;
+ if (setrlimit(RLIMIT_NPROC, &rlim) < 0) {
+ virReportSystemError(errno,
+ _("cannot limit number of processes to %d"),
+ driver->maxProcesses);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
struct qemuProcessHookData {
virConnectPtr conn;
virDomainObjPtr vm;
{
struct qemuProcessHookData *h = data;
+ if (qemuProcessLimits(h->driver) < 0)
+ return -1;
+
/* This must take place before exec(), so that all QEMU
* memory allocation is on the correct NUMA node
*/
allow_disk_format_probing = 1
vnc_auto_unix_socket = 1
+
+max_processes = 12345
"
test Libvirtd_qemu.lns get conf =
{ "allow_disk_format_probing" = "1" }
{ "#empty" }
{ "vnc_auto_unix_socket" = "1" }
+{ "#empty" }
+{ "max_processes" = "12345" }