mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
qemu: Support for overriding NOFILE limit
This patch adds max_files option to qemu.conf which can be used to override system default limit on number of opened files that are allowed for qemu user.
This commit is contained in:
parent
74ad69b708
commit
d8db0f9690
@ -50,6 +50,7 @@ module Libvirtd_qemu =
|
|||||||
| bool_entry "allow_disk_format_probing"
|
| bool_entry "allow_disk_format_probing"
|
||||||
| bool_entry "set_process_name"
|
| bool_entry "set_process_name"
|
||||||
| int_entry "max_processes"
|
| int_entry "max_processes"
|
||||||
|
| int_entry "max_files"
|
||||||
| str_entry "lock_manager"
|
| str_entry "lock_manager"
|
||||||
| int_entry "max_queued"
|
| int_entry "max_queued"
|
||||||
| int_entry "keepalive_interval"
|
| int_entry "keepalive_interval"
|
||||||
|
@ -299,11 +299,14 @@
|
|||||||
# set_process_name = 1
|
# set_process_name = 1
|
||||||
|
|
||||||
|
|
||||||
# If max_processes is set to a positive integer, libvirt will use it to set
|
# If max_processes is set to a positive integer, libvirt will use
|
||||||
# maximum number of processes that can be run by qemu user. This can be used to
|
# it to set the maximum number of processes that can be run by qemu
|
||||||
# override default value set by host OS.
|
# user. This can be used to override default value set by host OS.
|
||||||
|
# The same applies to max_files which sets the limit on the maximum
|
||||||
|
# number of opened files.
|
||||||
#
|
#
|
||||||
# max_processes = 0
|
# max_processes = 0
|
||||||
|
# max_files = 0
|
||||||
|
|
||||||
# To enable 'Sanlock' project based locking of the file
|
# To enable 'Sanlock' project based locking of the file
|
||||||
# content (to prevent two VMs writing to the same
|
# content (to prevent two VMs writing to the same
|
||||||
|
@ -443,6 +443,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
|
|||||||
CHECK_TYPE("max_processes", VIR_CONF_LONG);
|
CHECK_TYPE("max_processes", VIR_CONF_LONG);
|
||||||
if (p) driver->maxProcesses = p->l;
|
if (p) driver->maxProcesses = p->l;
|
||||||
|
|
||||||
|
p = virConfGetValue(conf, "max_files");
|
||||||
|
CHECK_TYPE("max_files", VIR_CONF_LONG);
|
||||||
|
if (p) driver->maxFiles = p->l;
|
||||||
|
|
||||||
p = virConfGetValue (conf, "lock_manager");
|
p = virConfGetValue (conf, "lock_manager");
|
||||||
CHECK_TYPE ("lock_manager", VIR_CONF_STRING);
|
CHECK_TYPE ("lock_manager", VIR_CONF_STRING);
|
||||||
if (p && p->str) {
|
if (p && p->str) {
|
||||||
|
@ -105,6 +105,7 @@ struct qemud_driver {
|
|||||||
unsigned int setProcessName : 1;
|
unsigned int setProcessName : 1;
|
||||||
|
|
||||||
int maxProcesses;
|
int maxProcesses;
|
||||||
|
int maxFiles;
|
||||||
|
|
||||||
int max_queued;
|
int max_queued;
|
||||||
|
|
||||||
|
@ -2166,9 +2166,9 @@ qemuProcessPrepareChardevDevice(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|||||||
static int
|
static int
|
||||||
qemuProcessLimits(struct qemud_driver *driver)
|
qemuProcessLimits(struct qemud_driver *driver)
|
||||||
{
|
{
|
||||||
if (driver->maxProcesses > 0) {
|
|
||||||
struct rlimit rlim;
|
struct rlimit rlim;
|
||||||
|
|
||||||
|
if (driver->maxProcesses > 0) {
|
||||||
rlim.rlim_cur = rlim.rlim_max = driver->maxProcesses;
|
rlim.rlim_cur = rlim.rlim_max = driver->maxProcesses;
|
||||||
if (setrlimit(RLIMIT_NPROC, &rlim) < 0) {
|
if (setrlimit(RLIMIT_NPROC, &rlim) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
@ -2178,6 +2178,18 @@ qemuProcessLimits(struct qemud_driver *driver)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (driver->maxFiles > 0) {
|
||||||
|
/* Max number of opened files is one greater than
|
||||||
|
* actual limit. See man setrlimit */
|
||||||
|
rlim.rlim_cur = rlim.rlim_max = driver->maxFiles + 1;
|
||||||
|
if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("cannot set max opened files to %d"),
|
||||||
|
driver->maxFiles);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,8 @@ vnc_auto_unix_socket = 1
|
|||||||
|
|
||||||
max_processes = 12345
|
max_processes = 12345
|
||||||
|
|
||||||
|
max_files = 67890
|
||||||
|
|
||||||
lock_manager = \"fcntl\"
|
lock_manager = \"fcntl\"
|
||||||
|
|
||||||
keepalive_interval = 1
|
keepalive_interval = 1
|
||||||
@ -242,6 +244,8 @@ keepalive_count = 42
|
|||||||
{ "#empty" }
|
{ "#empty" }
|
||||||
{ "max_processes" = "12345" }
|
{ "max_processes" = "12345" }
|
||||||
{ "#empty" }
|
{ "#empty" }
|
||||||
|
{ "max_files" = "67890" }
|
||||||
|
{ "#empty" }
|
||||||
{ "lock_manager" = "fcntl" }
|
{ "lock_manager" = "fcntl" }
|
||||||
{ "#empty" }
|
{ "#empty" }
|
||||||
{ "keepalive_interval" = "1" }
|
{ "keepalive_interval" = "1" }
|
||||||
|
Loading…
Reference in New Issue
Block a user