Bug 1159651 - virt-sysprep firstboot script is not deleted if it reboot a RHEL 7 guest
Summary: virt-sysprep firstboot script is not deleted if it reboot a RHEL 7 guest
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs
Version: 6.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Pino Toscano
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1160043
TreeView+ depends on / blocked
 
Reported: 2014-11-02 17:00 UTC by j.vandeville
Modified: 2015-07-22 05:56 UTC (History)
7 users (show)

Fixed In Version: libguestfs-1.20.11-12.el6
Doc Type: Bug Fix
Doc Text:
Due to an incorrect implementation of the libguestfs firstboot scripts runner, the firstboot scripts logged only the last executed script instead of all executed scripts. In addition, firstboot scripts that cause booting to stop, such as a script that reboots the guest, were unintentionally executed on every boot. These problems have now been fixed.
Clone Of:
: 1160043 (view as bug list)
Environment:
Last Closed: 2015-07-22 05:56:11 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1444 normal SHIPPED_LIVE libguestfs bug fix and enhancement update 2015-07-20 18:44:02 UTC

Description j.vandeville 2014-11-02 17:00:03 UTC
Description of problem:

I use a very simple script to update my VM at first boot :

yum clean all
yum -y update
reboot

On rhel6.x guest, the script is deleted but on rhel7 guest, the script is never deleted and the guest is stuck in a infinity loop of reboot. If I remove the "reboot" command, the script is correctly deleted.

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

libguestfs-tools-1.20.11-11.el6.x86_64

Steps to Reproduce:
1. Create a RHEL7 VM on a RHEL6.6 host
2. Create a simple script with the reboot command
3. Use virt-sysprep --enable firstboot --firstboot script.sh -d rhel7_guest
4. Launch the VM

Actual results:

The script is never deleted and the guest is stuck in a infinity loop of reboot

Expected results:

The script should be deleted after its first execution

Additional info:

Comment 2 Pino Toscano 2014-11-03 19:50:46 UTC
This bug is not specific to RHEL guests, but practically on any guest.

Basically, /usr/lib/virt-sysprep/firstboot.sh (which is the helper script created by virt-sysprep/builder/customize to run the first boot scripts) does the following:

  if test "$1" = "start"
  then
    for f in $d/* ; do
      if test -x "$f"
      then
        echo '=== Running' $f '===' 2>&1 | tee $logfile
        $f 2>&1 | tee $logfile
        rm -f $f
      fi
    done
  fi

so, each first boot script is deleted only after it has been completed. Needless to say, if a script does not return then it is not removed, and thus executed again at the next boot.

Patch posted to the mailing list to attempt working around such situations:
  https://www.redhat.com/archives/libguestfs/2014-November/msg00005.html

Comment 3 j.vandeville 2014-11-03 20:52:29 UTC
It's working with RHEL6.X guest. The script is always deleted, even if it reboot the system

Comment 4 Richard W.M. Jones 2014-11-03 22:15:50 UTC
This patch has been accepted upstream and should fix the
issue for all RHEL and other guests:

https://www.redhat.com/archives/libguestfs/2014-November/msg00007.html

Comment 5 Pino Toscano 2014-11-04 08:09:31 UTC
Fixed with upstream commit
https://github.com/libguestfs/libguestfs/commit/f8ed15462fbb03c5b19972361f2a2e6fed4c5f02
which is in libguestfs >= 1.29.5.

Comment 7 Chao Zhang 2014-12-11 06:44:59 UTC
Verify with libguestfs-tools-1.20.11-12.el6.x86_64


Steps to verify:

1. Create a RHEL7 VM on a RHEL6.6 host
#virsh define RHEL-Server-7.0-64-hvm.xml

2. Create a simple script with the reboot command
#cat script.sh
yum clean all
yum -y update
reboot

3. Use virt-sysprep --enable firstboot --firstboot script.sh -d rhel7_guest
#virt-sysprep --enable firstboot --firstboot script.sh -d rhel7_guest

4. Launch the VM
Launch the guest. The script has been deleted after its first execution.

Comment 9 errata-xmlrpc 2015-07-22 05:56:11 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/RHBA-2015-1444.html


Note You need to log in before you can comment on or make changes to this bug.