summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-05-08 08:44:34 +0100
committerRichard Jones <rjones@redhat.com>2009-05-08 08:44:34 +0100
commit93ad7365e400915e6ce7fe6896ca7b599e7cf83a (patch)
treed9d0ef30660f658f76809c838d8a563d885010e6
parentd50dbf2d7cda1edc18d5249dae051cd58e65b99a (diff)
downloadlibguestfs-93ad7365e400915e6ce7fe6896ca7b599e7cf83a.tar.gz
libguestfs-93ad7365e400915e6ce7fe6896ca7b599e7cf83a.tar.xz
libguestfs-93ad7365e400915e6ce7fe6896ca7b599e7cf83a.zip
Change memory calculation to choose a generous amount of memory.
-rw-r--r--src/guestfs.c40
1 files changed, 7 insertions, 33 deletions
diff --git a/src/guestfs.c b/src/guestfs.c
index 9060c111..15111dbf 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -650,7 +650,6 @@ guestfs_launch (guestfs_h *g)
char *kernel = NULL, *initrd = NULL;
char unixsock[256];
struct sockaddr_un addr;
- struct stat statbuf;
/* Configured? */
if (!g->cmdline) {
@@ -710,39 +709,14 @@ guestfs_launch (guestfs_h *g)
goto cleanup0;
}
- /* Choose a suitable memory size (in MB). This is more art
- * than science, but you can help by doing
- * ./configure --enable-debug-command
- * and then running:
- * debug sh free
- * debug mem ''
- * and seeing how much free memory is left for particular
- * configurations.
- *
- * It's also helpful to report both the compressed and uncompressed
- * size of the initramfs (ls -lh initramfs*.img; du -sh initramfs).
- *
- * XXX KVM virtio balloon driver?
+ /* Choose a suitable memory size. Previously we tried to choose
+ * a minimal memory size, but this isn't really necessary since
+ * recent QEMU and KVM don't do anything nasty like locking
+ * memory into core any more. This we can safely choose a
+ * large, generous amount of memory, and it'll just get swapped
+ * on smaller systems.
*/
- if (stat (initrd, &statbuf) != -1) {
- /* Approximate size of the initramfs after it is decompressed
- * in kernel memory. The compression factor is ~2.5-3.
- */
- memsize = 3 * statbuf.st_size / 1024 / 1024;
-
- /* Approximate size used by the kernel. */
- memsize += 10;
-
- /* Want to give userspace some room, so: */
- memsize += 128;
-
-#if SIZEOF_LONG == 8
- /* On 64 bit, assume some overhead. */
- memsize += 64;
-#endif
- } else
- memsize = 512;
-
+ memsize = 384;
/* Make the temporary directory containing the socket. */
if (!g->tmpdir) {