mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
* src/libvirt_private.syms src/qemu_driver.c src/test.c
src/uml_driver.c src/util.c src/util.h src/xen_unified.c: unify hostname lookup using virGetHostname convenience function, patch by David Lutterkort daniel
This commit is contained in:
parent
6c996bfc8f
commit
fbba4423e9
@ -1,3 +1,10 @@
|
|||||||
|
Wed Jan 7 11:38:04 CET 2009 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* src/libvirt_private.syms src/qemu_driver.c src/test.c
|
||||||
|
src/uml_driver.c src/util.c src/util.h src/xen_unified.c:
|
||||||
|
unify hostname lookup using virGetHostname convenience function,
|
||||||
|
patch by David Lutterkort
|
||||||
|
|
||||||
Tue Jan 6 20:38:23 +0100 2009 Jim Meyering <meyering@redhat.com>
|
Tue Jan 6 20:38:23 +0100 2009 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
update from gnulib; use its time_r module for localtime_r on mingw
|
update from gnulib; use its time_r module for localtime_r on mingw
|
||||||
|
@ -277,6 +277,7 @@ virEventAddHandle;
|
|||||||
virEventRemoveHandle;
|
virEventRemoveHandle;
|
||||||
virExec;
|
virExec;
|
||||||
virFormatMacAddr;
|
virFormatMacAddr;
|
||||||
|
virGetHostname;
|
||||||
virParseMacAddr;
|
virParseMacAddr;
|
||||||
virFileDeletePid;
|
virFileDeletePid;
|
||||||
virFileExists;
|
virFileExists;
|
||||||
|
@ -1636,23 +1636,16 @@ cleanup:
|
|||||||
static char *
|
static char *
|
||||||
qemudGetHostname (virConnectPtr conn)
|
qemudGetHostname (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int r;
|
char *result;
|
||||||
char hostname[HOST_NAME_MAX+1], *str;
|
|
||||||
|
|
||||||
r = gethostname (hostname, HOST_NAME_MAX+1);
|
result = virGetHostname();
|
||||||
if (r == -1) {
|
if (result == NULL) {
|
||||||
qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
|
qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
|
||||||
"%s", strerror (errno));
|
"%s", strerror (errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Caller frees this string. */
|
/* Caller frees this string. */
|
||||||
str = strdup (hostname);
|
return result;
|
||||||
if (str == NULL) {
|
|
||||||
qemudReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
|
|
||||||
"%s", strerror (errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemudListDomains(virConnectPtr conn, int *ids, int nids) {
|
static int qemudListDomains(virConnectPtr conn, int *ids, int nids) {
|
||||||
@ -4326,4 +4319,3 @@ int qemuRegister(void) {
|
|||||||
virRegisterStateDriver(&qemuStateDriver);
|
virRegisterStateDriver(&qemuStateDriver);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/test.c
16
src/test.c
@ -656,22 +656,16 @@ static int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
static char *testGetHostname (virConnectPtr conn)
|
static char *testGetHostname (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int r;
|
char *result;
|
||||||
char hostname [HOST_NAME_MAX+1], *str;
|
|
||||||
|
|
||||||
r = gethostname (hostname, HOST_NAME_MAX+1);
|
result = virGetHostname();
|
||||||
if (r == -1) {
|
if (result == NULL) {
|
||||||
testError (conn, VIR_ERR_SYSTEM_ERROR, "%s",
|
testError (conn, VIR_ERR_SYSTEM_ERROR, "%s",
|
||||||
strerror (errno));
|
strerror (errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
str = strdup (hostname);
|
/* Caller frees this string. */
|
||||||
if (str == NULL) {
|
return result;
|
||||||
testError (conn, VIR_ERR_SYSTEM_ERROR, "%s",
|
|
||||||
strerror (errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
|
static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
|
@ -1149,23 +1149,16 @@ cleanup:
|
|||||||
static char *
|
static char *
|
||||||
umlGetHostname (virConnectPtr conn)
|
umlGetHostname (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int r;
|
char *result;
|
||||||
char hostname[HOST_NAME_MAX+1], *str;
|
|
||||||
|
|
||||||
r = gethostname (hostname, HOST_NAME_MAX+1);
|
result = virGetHostname();
|
||||||
if (r == -1) {
|
if (result == NULL) {
|
||||||
umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
|
umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
|
||||||
"%s", strerror (errno));
|
"%s", strerror (errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Caller frees this string. */
|
/* Caller frees this string. */
|
||||||
str = strdup (hostname);
|
return result;
|
||||||
if (str == NULL) {
|
|
||||||
umlReportError (conn, NULL, NULL, VIR_ERR_SYSTEM_ERROR,
|
|
||||||
"%s", strerror (errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int umlListDomains(virConnectPtr conn, int *ids, int nids) {
|
static int umlListDomains(virConnectPtr conn, int *ids, int nids) {
|
||||||
|
33
src/util.c
33
src/util.c
@ -47,6 +47,7 @@
|
|||||||
#ifdef HAVE_PATHS_H
|
#ifdef HAVE_PATHS_H
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
#include "virterror_internal.h"
|
#include "virterror_internal.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
@ -1338,6 +1339,38 @@ int virDiskNameToIndex(const char *name) {
|
|||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef AI_CANONIDN
|
||||||
|
#define AI_CANONIDN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char *virGetHostname(void)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
char hostname[HOST_NAME_MAX+1], *result;
|
||||||
|
struct addrinfo hints, *info;
|
||||||
|
|
||||||
|
r = gethostname (hostname, sizeof(hostname));
|
||||||
|
if (r == -1)
|
||||||
|
return NULL;
|
||||||
|
NUL_TERMINATE(hostname);
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
hints.ai_flags = AI_CANONNAME|AI_CANONIDN;
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
r = getaddrinfo(hostname, NULL, &hints, &info);
|
||||||
|
if (r != 0)
|
||||||
|
return NULL;
|
||||||
|
if (info->ai_canonname == NULL) {
|
||||||
|
freeaddrinfo(info);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Caller frees this string. */
|
||||||
|
result = strdup (info->ai_canonname);
|
||||||
|
freeaddrinfo(info);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* send signal to a single process */
|
/* send signal to a single process */
|
||||||
int virKillProcess(pid_t pid, int sig)
|
int virKillProcess(pid_t pid, int sig)
|
||||||
{
|
{
|
||||||
|
@ -166,6 +166,8 @@ static inline int getuid (void) { return 0; }
|
|||||||
static inline int getgid (void) { return 0; }
|
static inline int getgid (void) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char *virGetHostname(void);
|
||||||
|
|
||||||
int virKillProcess(pid_t pid, int sig);
|
int virKillProcess(pid_t pid, int sig);
|
||||||
|
|
||||||
#endif /* __VIR_UTIL_H__ */
|
#endif /* __VIR_UTIL_H__ */
|
||||||
|
@ -447,20 +447,15 @@ xenUnifiedGetVersion (virConnectPtr conn, unsigned long *hvVer)
|
|||||||
static char *
|
static char *
|
||||||
xenUnifiedGetHostname (virConnectPtr conn)
|
xenUnifiedGetHostname (virConnectPtr conn)
|
||||||
{
|
{
|
||||||
int r;
|
char *result;
|
||||||
char hostname [HOST_NAME_MAX+1], *str;
|
|
||||||
|
|
||||||
r = gethostname (hostname, HOST_NAME_MAX+1);
|
result = virGetHostname();
|
||||||
if (r == -1) {
|
if (result == NULL) {
|
||||||
xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno));
|
xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
str = strdup (hostname);
|
/* Caller frees this string. */
|
||||||
if (str == NULL) {
|
return result;
|
||||||
xenUnifiedError (conn, VIR_ERR_SYSTEM_ERROR, "%s", strerror(errno));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user