Bug 1132652

Summary: virt-sysprep firstboot doesn't work with RHEL 7 guest
Product: Red Hat Enterprise Linux 6 Reporter: j.vandeville
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.5CC: huzhan, leiwang, mbooth, ptoscano, rjones, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-18 10:30:27 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:

Description j.vandeville 2014-08-21 18:41:11 UTC
Description of problem:

The /usr/lib/virt-sysprep/firstboot.sh script test if the argument $1 is "start". It's working with upstart/System V but not with systemd, the default init of RHEL7. $1 seems to be always empty and the script is never executed.

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

libguestfs-tools-c-1.20.11-2.el6.x86_64

How reproducible:


Steps to Reproduce:
1. Create a RHEL7 VM on a RHEL6.5 host
2. Use virt-sysprep with firstboot option
3. Check if the script is executed at first boot

Actual results:

The firstboot script is never executed

Expected results:

The firstboot script must be executed

Additional info:

Comment 2 Richard W.M. Jones 2014-08-21 19:52:27 UTC
Pino, can you check if the updated virt-sysprep in RHEL 6.6
(bug 1037166) can successfully create a working firstboot script
in a RHEL 7 guest?

Comment 3 Lingfei Kong 2014-08-28 09:53:46 UTC
Can reproduce with libguestfs-tools-c-1.20.11-2.el6.x86_64

Steps to reproduce:
1. Create a RHEL7 VM on a RHEL6.6 host
2. Create a script used to test:
#cat test.sh 
#!/bin/bash

echo "Hello World"
touch /hello_world

3. Use virt-sysprep with firstboot option
#virt-sysprep --firstboot test.sh -a rhel77.img

4. Check in rhel7 guest:
Can not find  /hello_world2
There no such lines in /root/virt-sysprep-firstboot.log:
"Hello World"




3. Check if the script is executed at first boot

Comment 4 Lingfei Kong 2014-08-28 10:01:25 UTC
(In reply to Richard W.M. Jones from comment #2)
> Pino, can you check if the updated virt-sysprep in RHEL 6.6
> (bug 1037166) can successfully create a working firstboot script
> in a RHEL 7 guest?

(In reply to Richard W.M. Jones from comment #2)
> Pino, can you check if the updated virt-sysprep in RHEL 6.6
> (bug 1037166) can successfully create a working firstboot script
> in a RHEL 7 guest?

Hi Richard,
I test with the latest libguestfs-1.20.11-10.el6,  it works well with this package

Steps:
Steps to reproduce:
1. Create a RHEL7 VM on a RHEL6.6 host
2. Create a script used to test:
#cat test.sh 
#!/bin/bash

echo "Hello World2"
touch /hello_world2

3. Use virt-sysprep with firstboot option
#virt-sysprep --firstboot test.sh -a rhel77.img

4. Check in rhel7 guest:
Can find file: /hello_world2
Can find the following line in /root/virt-sysprep-firstboot.log:
"Hello World2"

Comment 5 Richard W.M. Jones 2014-08-28 10:03:53 UTC
Looks good to me.

Comment 6 Lingfei Kong 2014-08-28 10:11:23 UTC
(In reply to Richard W.M. Jones from comment #5)
> Looks good to me.
I'm sorry, there is some thing wrong with my browser when i paste my comment, maybe cause by network delay and this lead to Comment 4 looks confusion. The actual result is 'virt-sysprep --firstboot' works well with rhel7 in libguestfs-1.20.11-10.el6. :-)

Comment 7 j.vandeville 2014-11-02 10:15:32 UTC
There is another bug with libguestfs-tools-1.20.11-11.el6.x86_64 and RHEL 7

I use a very simple script to update the guest at first boot :

yum clean all
yum -y update
reboot 

It’s working well with RHEL 6.X but with RHEL 7, the script is never deleted and the guest is stuck  in a infinity loop of reboot

Should I create a new bug for this ?

Thanks

Comment 8 Richard W.M. Jones 2014-11-02 11:08:57 UTC
(In reply to j.vandeville from comment #7)
> There is another bug with libguestfs-tools-1.20.11-11.el6.x86_64 and RHEL 7

RHEL 7 guest?

Anyway, yes, please file new bugs for any issues you find.

Comment 9 Pino Toscano 2014-11-04 08:33:35 UTC
So it seems like firstboot scripts work with RHEL 7 guests, right?

The problem reported in comment 7 is bug 1159651, which has just been fixed upstream (and affects only scripts which cause the virt-sysprep firstboot sequence to not complete).

(In reply to Lingfei Kong from comment #3)
> There no such lines in /root/virt-sysprep-firstboot.log:
> "Hello World"

There's a related issue, i.e. that the /root/virt-sysprep-firstboot.log log file will contain only the output of the last script run. A patch fixing this has been sent to the mailing list:
  https://www.redhat.com/archives/libguestfs/2014-November/msg00009.html

Comment 10 Hu Zhang 2015-11-18 10:13:11 UTC
Not reproduced with libguestfs-tools-c-1.20.11-14.el6.x86_64 on rhel 6.7.

Steps:
Steps to reproduce:
1. Create a RHEL7.1 VM on a RHEL6.7 host
2. Create a script used to test:
#cat test.sh 
#!/bin/bash

echo "Hello World2"
touch /hello_world2

3. Use virt-sysprep with firstboot option
#virt-sysprep --firstboot test.sh -a rhel7.1.img

4. Check in rhel7.1 guest:
Can find file: /hello_world2
Can find the following line in /root/virt-sysprep-firstboot.log:
"Hello World2"

Comment 11 Pino Toscano 2015-11-18 10:30:27 UTC
Thanks Hu Zhang for testing this.

I confirm that this was fixed by the updates for the virt-sysprep addition in RHEL 6.6.

Regarding the issue mentioned in comment #7, it is bug #1159651, fixed in RHEL 6.7.