RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1160203 - log of virt-sysprep contains only the output of the last script
Summary: log of virt-sysprep contains only the output of the last script
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: 1160199
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-04 10:27 UTC by Pino Toscano
Modified: 2015-07-22 05:56 UTC (History)
8 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: 1160199
Environment:
Last Closed: 2015-07-22 05:56:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


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

Description Pino Toscano 2014-11-04 10:27:08 UTC
+++ This bug was initially created as a clone of Bug #1160199 +++

Description of problem:

The firstboot.sh helper script, added by virt-sysprep to run firstboot scripts, does not properly write its log file.  Due to the usage of "tee" and not "tee -a", every time its log gets overwritten, so at the end it will contain only the output of the last script run.

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

libguestfs-1.20.11-11.el6

How reproducible:

Everytime.

Steps to Reproduce:
1. $ virt-sysprep ... --firstboot-command 'echo first' --firstboot-command 'echo second'
2. run the guest
3. $ examine ~root/virt-sysprep-firstboot.log in the guest

Actual results (surrounded within BEGIN .. END for clarity):
-- BEGIN -------
second
-- END -------

Expected results:
-- BEGIN -------
/usr/lib/virt-sysprep/firstboot.sh start
Scripts dir: /usr/lib/virt-sysprep/scripts
=== Running /usr/lib/virt-sysprep/scripts/0001-1415095601-qxl365px ===
first
=== Running /usr/lib/virt-sysprep/scripts/0002-1415095601-nc22p8kr ===
second
-- END -------

(The actual names of the files in /usr/lib/virt-sysprep/scripts/ are sequential, but their suffixes are autogenerated.)

Additional info:

This has been fixed already:
https://github.com/libguestfs/libguestfs/commit/25cad1e62fa73e9cfd9a0e3d1d330165b19339ec

Comment 2 Chao Zhang 2014-12-11 07:46:39 UTC
The bug cannot be reproduced with libguestfs-1.20.11-11.el6.
It seems to be that libguestfs-1.20.11-11.el6 do not support the command "--firstboot-command".


Steps:

1. $ virt-sysprep --firstboot-command 'echo first' --firstboot-command 'echo second' -d kvm1

Actual results:

virt-sysprep: unknown option `--firstboot-command'.
virt-sysprep: reset or unconfigure a virtual machine so clones can be made
....(no "--firstboot-command" info)

2. $ man virt-sysprep
....(no "--firstboot-command" info)

Comment 4 Richard W.M. Jones 2014-12-11 09:42:51 UTC
We rebased virt-sysprep.

It turned out that the rebased virt-sysprep contained a bug in a
new feature (--firstboot-command) to do with how it writes log files,
and this bug was filed to fix that.

Therefore there isn't a way to reproduce the bug, all we can do
is check that the bug doesn't exist in the latest virt-sysprep.

Comment 6 Wei Shi 2014-12-11 10:12:29 UTC
Gosh, closed it accidentally.

Comment 7 Richard W.M. Jones 2014-12-11 10:53:04 UTC
I'd prefer if it could be verified by QA.

Comment 8 Pino Toscano 2014-12-16 11:52:52 UTC
(In reply to Chao Zhang from comment #2)
> The bug cannot be reproduced with libguestfs-1.20.11-11.el6.
> It seems to be that libguestfs-1.20.11-11.el6 do not support the command
> "--firstboot-command".
> 
> 
> Steps:
> 
> 1. $ virt-sysprep --firstboot-command 'echo first' --firstboot-command 'echo
> second' -d kvm1
> 
> Actual results:
> 
> virt-sysprep: unknown option `--firstboot-command'.
> virt-sysprep: reset or unconfigure a virtual machine so clones can be made
> ....(no "--firstboot-command" info)
> 
> 2. $ man virt-sysprep
> ....(no "--firstboot-command" info)

The bug was initially reproduced on master, where --firstboot-command exists, so I just cloned that given the firstboot capabilities exist in 6.6+.

Indeed there's no --firstboot-command, but there's --firstboot, which is used to run existing scripts, and it is indeed affected by the issue.

Putting back to ON_QA.

Comment 9 Hu Zhang 2015-03-11 01:56:36 UTC
Verified with the package version:
libguestfs-1.20.11-14.el6.x86_64

Verify steps:
1. Edit two simple shell scripts as following.
 # cat /path/to/echo1.sh
echo first
 # cat /path/to/echo1.sh
echo second
 
2. Run the following command
# virt-sysprep -a $image --firstboot /path/to/echo1.sh --firstboot /path/to/echo2.sh
 
3. Run the guest, login and check the log file ~root/virt-sysprep-firstboot.log in the guest.
# cat /root/virt-sysprep-firstboot.log
/usr/lib/virt-sysprep/firstboot.sh start
Scripts dir: /usr/lib/virt-sysprep/scripts
=== Running /usr/lib/virt-sysprep/scripts/0001-1426038326-gpsyazqb ===
first
=== Running /usr/lib/virt-sysprep/scripts/0002-1426038326-nv6iu426 ===
second

It returns the expected result.

Comment 11 errata-xmlrpc 2015-07-22 05:56:16 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.