Bug 811112

Summary: [RFE][virt-sysprep] hostname can not be changed on rhel system
Product: Red Hat Enterprise Linux 6 Reporter: Qin Guan <qguan>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2CC: leiwang, moli, qwan, yuzhou
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.16.18-2.el6 Doc Type: Enhancement
Doc Text:
No Documentation needed
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 07:01:43 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 Qin Guan 2012-04-10 07:40:41 UTC
Description of problem:
The hostname can not be changed on RHEL system via virt-sysprep tool.
On RHEL system, "$type/$distro" has the value of "linux/rhel", which is not in the virt-sysprep support list. 

In the script, hostname can be changed only when:

    case "$type/$distro" in
        linux/fedora)
        ...
        linux/debian|linux/ubuntu)
        ...
    esac

Suggest to add redhat-based linux system into support list, like linux/fedora|linux/rhel|linux/centos|linux/scientificlinux. 

Version-Release number of selected component (if applicable):
libguestfs-tools-1.16.15-1.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. on latest rhel6.3 host, update to use the latest libguestfs-tool (1.16.15-1.el6) package
2. provision a rhel6 kvm guest (named rhel6u2-x64)
3. reset the domain with new hostname specified:
# virt-sysprep -d rhel6u2-x64 --hostname=rhel6u2-x64.nay.redhat.com

Actual results:
Hostname not changed and no warning/error message printed.

Expected results:
Hostname can be changed.

Additional info:

Comment 1 Richard W.M. Jones 2012-04-10 13:21:11 UTC
Upstream commit:
https://github.com/libguestfs/libguestfs/commit/60b87d0a5c97a458cefb6c5d31eeede7709f5a3d

This fix will be backported to libguestfs 1.16.16.

Comment 3 Qixiang Wan 2012-04-17 07:04:47 UTC
Verified with libguestfs-tools-1.16.18-2.el6.x86_64.

Before fix (libguestfs-tools-1.16.15-1.el6.x86_64):

# guestfish --ro -a rhel.raw -i cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oldinstance.example.com
# virt-sysprep -a rhel.raw --hostname=newinstance.example.com
# guestfish --ro -a rhel.raw -i cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oldinstance.example.com

After fix:

# guestfish --ro -a rhel.raw -i cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oldinstance.example.com

# virt-sysprep -a rhel.raw --hostname=newinstance.example.com
# guestfish --ro -a rhel.raw -i cat /etc/sysconfig/network
HOSTNAME=newinstance.example.com
NETWORKING=yes

Comment 4 Richard W.M. Jones 2012-04-26 12:26:46 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No Documentation needed

Comment 6 errata-xmlrpc 2012-06-20 07:01:43 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.

http://rhn.redhat.com/errata/RHSA-2012-0774.html