Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1515831

Summary: [RFE] Add API to access guest-get-hostname from QEMU-GA
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Tomáš Golembiovský <tgolembi>
Component: libvirtAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Lili Zhu <lizhu>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: chhu, dyuan, fjin, jdenemar, jsuchane, pkrempa, rbalakri, xuzhang, zpeng
Target Milestone: rcKeywords: FutureFeature
Target Release: 8.0Flags: areis: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-5.9.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-05 09:43:16 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomáš Golembiovský 2017-11-21 12:58:02 UTC
Please add API for getting hostname from the guest: guest-get-hostname command from QEMU-GA.
Currently there is no supported way how to access the information.

Comment 4 Peter Krempa 2019-09-04 15:12:27 UTC
This data is available by two ways now:

Since:

ommit 25736a4c7ed50c101b4f87935f350f1a39a89f6e
Author: Julio Faracco <jcfaracco>
Date:   Wed Sep 5 01:20:54 2018 -0300

    qemu: adding domainGetHostname support for QEMU
    
    This commit adds support to use the function qemuAgentGetHostname()
    to obtain the domain hostname using QEMU-GA command.

v4.7.0-44-g25736a4c7e

(this makes it available via virsh domhostname or virDomainGetHostname)

And since:

commit 02697fdbd1aae48092de6082a3d9b787a0b9e052
Author: Jonathon Jongsma <jjongsma>
Date:   Fri Aug 23 11:31:22 2019 -0500

    qemu: Implement virDomainGetGuestInfo()
    
    Iimplements the new guest information API by querying requested
    information via the guest agent.

v5.6.0-366-g02697fdbd1
(via virsh guestinfo, virDomainGetGuestInfo)

Comment 6 Lili Zhu 2020-02-05 10:43:44 UTC
Verify this bug with:
qemu-guest-agent-4.2.0-6.module+el8.2.0+5453+31b2b136.x86_64
libvirt-6.0.0-2.module+el8.2.0+5513+34927b6c.x86_64

1) prepare windows and rhel guests
# virsh list --all
 Id   Name                       State
-------------------------------------------
 2    win10                      running
 3    rhel8.2                    running

For the 1st way mentioned in Comment 4:
2)check the guest hostname in linux guest
[root@newhost ~]# cat /etc/hostname 
newhost

3) check the guest hostname in windows guest
C:\Users\test>hostname
win10-guest

4)get hostname vis guest agent API domhostname
# virsh domhostname rhel8.2
newhost
 
# virsh domhostname win10
WIN10-GUEST

5) change the of the two hostnames and restart guests, check the hostname again
# virsh domhostname rhel8.2
linux-rename

[root@8-1-virt ~]# virsh domhostname win10 
WIN10-RENAME

For the 2nd way mentioned in Comment 4:
Please refer to the verification steps in Bug 1705514

Comment 7 Lili Zhu 2020-02-21 03:02:15 UTC
As the testing match with expected results, mark the bug as verified

Comment 9 errata-xmlrpc 2020-05-05 09:43: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://access.redhat.com/errata/RHBA-2020:2017