Bug 1113065

Summary: supermin: exception: Out of memory
Product: Red Hat Enterprise Linux 7 Reporter: Richard W.M. Jones <rjones>
Component: superminAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: blc, leiwang, linl, ptoscano, rjones, sherold, wshi, xchen
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: supermin-5.1.16-4.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1099172 Environment:
Last Closed: 2016-11-03 23:03:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1099172    
Bug Blocks: 1021150, 1288337, 1301891    

Description Richard W.M. Jones 2014-06-25 11:32:47 UTC
+++ This bug was initially created as a clone of Bug #1099172 +++

Description of problem:

(Reported by Stef Walter)

mkdir -p ~/.guestfs-1000
/usr/bin/supermin --build --verbose --if-newer --lock ~/.guestfs-1000/lock --copy-kernel -f ext2 --host-cpu x86_64 /usr/lib64/guestfs/supermin.d -o ~/.guestfs-1000/appliance.d

fails with the error:

supermin: exception: Out of memory

I asked Stef to use -v -v -v, and the end of the output is:

  - /var/lib/systemd/coredump
  - /var/lib/systemd/random-seed
  - /var/lib/tpm
  - /var/local
  - /var/lock
  - /var/log
  - /var/log/README
  - /var/log/journal
  - /var/log/lastlog
  - /var/log/tallylog
  - /var/spool
  - /var/spool/mail
  - /var/mail
  - /var/nis
  - /var/opt
  - /var/preserve
  - /var/run
  - /var/run/console
  - /var/run/dbus
  - /var/run/faillock
  - /var/run/mdadm
  - /var/run/sepermit
  - /var/run/setrans
  - /var/spool
  - /var/spool/lpd
  - /var/spool/mail
  - /var/tmp
  - /var/yp
supermin: kernel: picked kernel vmlinuz-3.14.4-200.fc20.x86_64
supermin: kernel: picked modules path /lib/modules/3.14.4-200.fc20.x86_64
supermin: kernel: kernel_version 3.14.4-200.fc20.x86_64
supermin: kernel: modules /lib/modules/3.14.4-200.fc20.x86_64
supermin: ext2: creating empty ext2 filesystem '/data/.guestfs-1000/appliance.d.ci1uy50n/root'
mke2fs 1.42.8 (20-Jun-2013)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done 

supermin: ext2: populating from base image
supermin: ext2: copying files from host filesystem
supermin: exception: Out of memory

It turns out the exception is raised from C code:

/* Read in the whole file into memory.  Check the size is still 'size'. */
static char *
read_whole_file (const char *filename, size_t size)
{
  char *buf = malloc (size);
  if (buf == NULL)
    caml_raise_out_of_memory ();

/var/log/lastlog (in this case) was a huge file which caused
the out of memory error.

Version-Release number of selected component (if applicable):

supermin 5.1.7

Comment 3 Richard W.M. Jones 2014-07-21 07:19:22 UTC
Yes, that's bug 1021150.

Also there are preview packages available:

https://www.redhat.com/archives/libguestfs/2014-May/msg00090.html

Comment 7 Richard W.M. Jones 2015-04-16 14:05:46 UTC
Move to RHEL 7.3 (cannot do 7.2 as not on the ACL).

Comment 8 Richard W.M. Jones 2016-07-06 11:30:07 UTC
Patch posted:
https://www.redhat.com/archives/libguestfs/2016-July/msg00014.html

Comment 10 Xianghua Chen 2016-07-21 03:15:27 UTC
Verified with the packages:
libguestfs-1.32.6-1.el7.x86_64

Verify steps:
# mkdir -p ~/.guestfs-1000
# supermin5 --build --verbose --if-newer --lock ~/.guestfs-1000/lock --copy-kernel -f ext2 --host-cpu x86_64 /usr/lib64/guestfs/supermin.d -o ~/.guestfs-1000/appliance.d
... ...
supermin: ext2: creating empty ext2 filesystem '/root/.guestfs-1000/appliance.d.r40z5zco/root'
supermin: ext2: populating from base image
supermin: ext2: copying files from host filesystem
supermin: ext2: copying kernel modules
supermin: ext2: creating minimal initrd '/root/.guestfs-1000/appliance.d.r40z5zco/initrd'
supermin: ext2: wrote 27 modules to minimal initrd
supermin: renaming /root/.guestfs-1000/appliance.d.r40z5zco to /root/.guestfs-1000/appliance.d


No error occurred.

So verified.

Comment 12 errata-xmlrpc 2016-11-03 23:03:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHEA-2016-2154.html