util: Introduce qemu_get_host_name()

This function offers operating system agnostic way to fetch host
name. It is implemented for both POSIX-like and Windows systems.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
Michal Privoznik
2020-06-22 20:19:35 +02:00
committed by Michael Roth
parent 844bd70b56
commit e47f4765af
3 changed files with 58 additions and 0 deletions

View File

@ -655,4 +655,14 @@ static inline void qemu_reset_optind(void)
#endif
}
/**
* qemu_get_host_name:
* @errp: Error object
*
* Operating system agnostic way of querying host name.
*
* Returns allocated hostname (caller should free), NULL on failure.
*/
char *qemu_get_host_name(Error **errp);
#endif