]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Drop qemuDomainMemoryLimit
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 9 Aug 2013 12:46:54 +0000 (14:46 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 19 Aug 2013 09:16:58 +0000 (11:16 +0200)
This function is to guess the correct limit for maximal memory
usage by qemu for given domain. This can never be guessed
correctly, not to mention all the pains and sleepless nights this
code has caused. Once somebody discovers algorithm to solve the
Halting Problem, we can compute the limit algorithmically. But
till then, this code should never see the light of the release
again.

src/qemu/qemu_cgroup.c
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_hotplug.c

index dc949db4dd36b90addbf81f68e2215609e5d9844..9673e8e7e5b3a350b346910e842cb155ad369813 100644 (file)
@@ -428,8 +428,7 @@ qemuSetupMemoryCgroup(virDomainObjPtr vm)
         }
     }
 
-    if (virCgroupSetMemoryHardLimit(priv->cgroup,
-                                    qemuDomainMemoryLimit(vm->def)) < 0)
+    if (virCgroupSetMemoryHardLimit(priv->cgroup, vm->def->mem.hard_limit) < 0)
         return -1;
 
     if (vm->def->mem.soft_limit != 0 &&
index 8b628d68d550a361594bf203cd19357f294644a5..c8f7df227cd21bdbc6a6ca72cf54f90af55b1b47 100644 (file)
@@ -9220,7 +9220,7 @@ qemuBuildCommandLine(virConnectPtr conn,
     }
 
     if (mlock)
-        virCommandSetMaxMemLock(cmd, qemuDomainMemoryLimit(def) * 1024);
+        virCommandSetMaxMemLock(cmd, def->mem.hard_limit * 1024);
 
     virObjectUnref(cfg);
     return cmd;
index 393af6b68f0fd89b78a035a8506f1f0e972f2d3b..7f4d17d126457ac8065f2a32a1d8028935f94e62 100644 (file)
@@ -2306,55 +2306,6 @@ cleanup:
     return ret;
 }
 
-
-unsigned long long
-qemuDomainMemoryLimit(virDomainDefPtr def)
-{
-    unsigned long long mem;
-    size_t i;
-
-    if (def->mem.hard_limit) {
-        mem = def->mem.hard_limit;
-    } else {
-        /* If there is no hard_limit set, compute a reasonable one to avoid
-         * system thrashing caused by exploited qemu.  A 'reasonable
-         * limit' has been chosen:
-         *     (1 + k) * (domain memory + total video memory) + (32MB for
-         *     cache per each disk) + F
-         * where k = 0.5 and F = 400MB.  The cache for disks is important as
-         * kernel cache on the host side counts into the RSS limit.
-         * Moreover, VFIO requires some amount for IO space. Alex Williamson
-         * suggested adding 1GiB for IO space just to be safe (some finer
-         * tuning might be nice, though).
-         *
-         * Technically, the disk cache does not have to be included in
-         * RLIMIT_MEMLOCK but it doesn't hurt as it's just an upper limit and
-         * it makes this function and its usage simpler.
-         */
-        mem = def->mem.max_balloon;
-        for (i = 0; i < def->nvideos; i++)
-            mem += def->videos[i]->vram;
-        mem *= 1.5;
-        mem += def->ndisks * 32768;
-        mem += 409600;
-
-        for (i = 0; i < def->nhostdevs; i++) {
-            virDomainHostdevDefPtr hostdev = def->hostdevs[i];
-            if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
-                hostdev->source.subsys.type ==
-                    VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
-                hostdev->source.subsys.u.pci.backend ==
-                    VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
-                mem += 1024 * 1024;
-                break;
-            }
-        }
-    }
-
-    return mem;
-}
-
-
 int
 qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
                            virDomainObjPtr vm)
index 0a4a51ec4ea402b35d4f232f50264f4ca490ef1c..21f116c6d3b76ebb479b61eab823a33ae1c5ed5b 100644 (file)
@@ -365,8 +365,6 @@ extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
 extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
 extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
 
-unsigned long long qemuDomainMemoryLimit(virDomainDefPtr def);
-
 int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
                                virDomainObjPtr vm);
 
index 85d2ca9fabc37829416f1179f703eb19600b1b46..478f33183ba1043adc90f9a4c51c59dd466ae5d8 100644 (file)
@@ -1030,7 +1030,7 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
          */
         vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
         virProcessSetMaxMemLock(vm->pid,
-                                qemuDomainMemoryLimit(vm->def) * 1024);
+                                vm->def->mem.hard_limit * 1024);
         vm->def->hostdevs[vm->def->nhostdevs--] = NULL;
     }