]> xenbits.xensource.com Git - libvirt.git/commitdiff
init: raise default system aio limits
authorEric Blake <eblake@redhat.com>
Tue, 4 Oct 2011 15:44:25 +0000 (09:44 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 5 Oct 2011 20:49:35 +0000 (14:49 -0600)
https://bugzilla.redhat.com/show_bug.cgi?id=740899 documents that
if qemu uses aio=native for its disks, then it consumes 128 aio
requests per disk.  On a host with multiple guests, this can quickly
run out of kernel aio requests with the default aio-max-nr of
65536.  Kernel developers have confirmed that there is no up-front
cost to raising this limit (a larger limit merely implies that more
aio requests can be issued in parallel, which in turn will result
in more kernel memory allocation, only if the system really does use
that many requests).  Since the system default limit prevents 256
disks, which is well within libvirt's current scalability, this
patch installs a file to raise the limit and document it in case a
system administrator has further cause to tune the limit.  The
install only works on platforms new enough to source /etc/sysctl.d/*
alongside /etc/sysctl.conf (F14 and RHEL 6).

* daemon/libvirtd.sysctl: New file.
* daemon/Makefile.am (EXTRA_DIST): Ship it.
(install-init, uninstall-init): Install it.
* libvirt.spec.in (%files): Include it in rpm.

daemon/Makefile.am
daemon/libvirtd.sysctl [new file with mode: 0644]
libvirt.spec.in

index 690bf851aa46bba0a5de90ad05604a35c63e60ec..1cf2b730b83de02d13234e894b703e5f5b7067e1 100644 (file)
@@ -38,6 +38,7 @@ EXTRA_DIST =                                          \
        libvirtd.policy-1                               \
        libvirtd.sasl                                   \
        libvirtd.sysconf                                \
+       libvirtd.sysctl                                 \
        libvirtd.aug                                    \
        libvirtd.logrotate.in                           \
        libvirtd.qemu.logrotate.in                      \
@@ -252,16 +253,20 @@ install-logrotate: $(LOGROTATE_CONFS)
 
 if LIBVIRT_INIT_SCRIPT_RED_HAT
 install-init: libvirtd.init
-       mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
+       mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d \
+         $(DESTDIR)$(sysconfdir)/sysconfig \
+         $(DESTDIR)$(sysconfdir)/sysctl.d
        $(INSTALL_SCRIPT) libvirtd.init \
          $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd
-       mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
        $(INSTALL_DATA) $(srcdir)/libvirtd.sysconf \
          $(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
+       $(INSTALL_DATA) $(srcdir)/libvirtd.sysctl \
+         $(DESTDIR)$(sysconfdir)/sysctl.d/libvirtd
 
 uninstall-init:
        rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd \
-               $(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
+               $(DESTDIR)$(sysconfdir)/sysconfig/libvirtd \
+               $(DESTDIR)$(sysconfdir)/sysctl.d/libvirtd
 
 BUILT_SOURCES += libvirtd.init
 
diff --git a/daemon/libvirtd.sysctl b/daemon/libvirtd.sysctl
new file mode 100644 (file)
index 0000000..275482c
--- /dev/null
@@ -0,0 +1,8 @@
+# The kernel allocates aio memory on demand, and this number limits the
+# number of parallel aio requests; the only drawback of a larger limit is
+# that a malicious guest could issue parallel requests to cause the kernel
+# to set aside memory.  Set this number at least as large as
+#   128 * (number of virtual disks on the host)
+# Libvirt uses a default of 1M requests to allow 8k disks, with at most
+# 64M of kernel memory if all disks hit an aio request at the same time.
+fs.aio-max-nr = 1048576
index b87e3f6cb815eb58b51e7a24fdef0ec46010f2e5..9f5797adae74da8554cd345bfe0f11b6dc8f29fc 100644 (file)
@@ -962,6 +962,11 @@ fi
 %doc daemon/libvirtd.upstart
 %config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
 %config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
+%if 0%{?fedora} >= 14 || 0%{?rhel} >= 6
+%config(noreplace) %{_sysconfdir}/sysctl.d/libvirtd
+%else
+rm -f $RPM_BUILD_ROOT%{_sysconfdir}/sysctl.d/libvirtd
+%endif
 %if %{with_dtrace}
 %{_datadir}/systemtap/tapset/libvirtd.stp
 %endif