mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
Fri Dec 7 14:49:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* src/console.c, src/console.h, src/virsh.c: Disable text console on Windows. * src/libvirt.c: Use replacement getpass from Gnulib. * src/libvirt.c: Initialize Winsock before use. * src/remote_internal.c: Header file fixes for Windows. Don't fail if AI_ADDRCONFIG isn't defined. Disable unsupported stuff under Windows. * src/uuid.c: ENODATA unavailable on Windows, use EIO instead. * src/virsh.c: No uid_t / getuid on Windows. * src/virsh.c: No O_SYNC on Windows.
This commit is contained in:
parent
f3ebd20d35
commit
0d14fc0cbb
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
Fri Dec 7 14:49:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
|
||||
|
||||
* src/console.c, src/console.h, src/virsh.c: Disable
|
||||
text console on Windows.
|
||||
* src/libvirt.c: Use replacement getpass from Gnulib.
|
||||
* src/libvirt.c: Initialize Winsock before use.
|
||||
* src/remote_internal.c: Header file fixes for Windows.
|
||||
Don't fail if AI_ADDRCONFIG isn't defined. Disable
|
||||
unsupported stuff under Windows.
|
||||
* src/uuid.c: ENODATA unavailable on Windows, use EIO instead.
|
||||
* src/virsh.c: No uid_t / getuid on Windows.
|
||||
* src/virsh.c: No O_SYNC on Windows.
|
||||
|
||||
Fri Dec 7 14:47:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
|
||||
|
||||
* src/internal.h: Use gnulib gettext library. Define
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef __MINGW32__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -193,6 +195,8 @@ int vshRunConsole(const char *tty) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* !__MINGW32__ */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* indent-tabs-mode: nil
|
||||
|
@ -23,6 +23,8 @@
|
||||
#ifndef __VIR_CONSOLE_H__
|
||||
#define __VIR_CONSOLE_H__
|
||||
|
||||
#ifndef __MINGW32__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -33,6 +35,8 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !__MINGW32__ */
|
||||
|
||||
#endif /* __VIR_CONSOLE_H__ */
|
||||
|
||||
/*
|
||||
|
@ -23,6 +23,11 @@
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/uri.h>
|
||||
#include "getpass.h"
|
||||
|
||||
#if HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
#include "driver.h"
|
||||
@ -144,6 +149,21 @@ static virConnectAuth virConnectAuthDefault = {
|
||||
*/
|
||||
virConnectAuthPtr virConnectAuthPtrDefault = &virConnectAuthDefault;
|
||||
|
||||
#if HAVE_WINSOCK2_H
|
||||
static int
|
||||
winsock_init (void)
|
||||
{
|
||||
WORD winsock_version, err;
|
||||
WSADATA winsock_data;
|
||||
|
||||
/* http://msdn2.microsoft.com/en-us/library/ms742213.aspx */
|
||||
winsock_version = MAKEWORD (2, 2);
|
||||
err = WSAStartup (winsock_version, &winsock_data);
|
||||
if (err != 0)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* virInitialize:
|
||||
*
|
||||
@ -161,6 +181,10 @@ virInitialize(void)
|
||||
return(0);
|
||||
initialized = 1;
|
||||
|
||||
#if HAVE_WINSOCK2_H
|
||||
if (winsock_init () == -1) return -1;
|
||||
#endif
|
||||
|
||||
if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR))
|
||||
return (-1);
|
||||
|
||||
|
@ -31,15 +31,29 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PATHS_H
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WINSOCK2_H
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <pwd.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
@ -51,9 +65,15 @@
|
||||
#endif
|
||||
#include <libxml/uri.h>
|
||||
|
||||
#include "getaddrinfo.h"
|
||||
|
||||
/* AI_ADDRCONFIG is missing on some systems. */
|
||||
#ifndef AI_ADDRCONFIG
|
||||
# define AI_ADDRCONFIG 0
|
||||
#endif
|
||||
|
||||
#include "internal.h"
|
||||
#include "driver.h"
|
||||
#include "getaddrinfo.h"
|
||||
#include "remote_internal.h"
|
||||
#include "remote_protocol.h"
|
||||
|
||||
@ -207,6 +227,7 @@ remoteFindDaemonPath(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
/**
|
||||
* qemuForkDaemon:
|
||||
*
|
||||
@ -286,7 +307,7 @@ remoteForkDaemon(virConnectPtr conn)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
enum virDrvOpenRemoteFlags {
|
||||
VIR_DRV_OPEN_REMOTE_RO = (1 << 0),
|
||||
@ -554,6 +575,7 @@ doRemoteOpen (virConnectPtr conn,
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
case trans_unix: {
|
||||
if (!sockname) {
|
||||
if (flags & VIR_DRV_OPEN_REMOTE_USER) {
|
||||
@ -720,6 +742,16 @@ doRemoteOpen (virConnectPtr conn,
|
||||
priv->sock = sv[0];
|
||||
priv->pid = pid;
|
||||
}
|
||||
#else /* WIN32 */
|
||||
|
||||
case trans_unix:
|
||||
case trans_ssh:
|
||||
case trans_ext:
|
||||
error (conn, VIR_ERR_INVALID_ARG,
|
||||
_("transport methods unix, ssh and ext are not supported under Windows"));
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
} /* switch (transport) */
|
||||
|
||||
|
||||
@ -769,6 +801,7 @@ doRemoteOpen (virConnectPtr conn,
|
||||
gnutls_deinit (priv->session);
|
||||
}
|
||||
close (priv->sock);
|
||||
#ifndef WIN32
|
||||
if (priv->pid > 0) {
|
||||
pid_t reap;
|
||||
do {
|
||||
@ -777,6 +810,7 @@ doRemoteOpen (virConnectPtr conn,
|
||||
continue;
|
||||
} while (reap != -1 && reap != priv->pid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (priv->hostname) {
|
||||
@ -808,6 +842,7 @@ remoteOpen (virConnectPtr conn,
|
||||
if (flags & VIR_CONNECT_RO)
|
||||
rflags |= VIR_DRV_OPEN_REMOTE_RO;
|
||||
|
||||
#if WITH_QEMU
|
||||
if (uri &&
|
||||
uri->scheme && STREQ (uri->scheme, "qemu") &&
|
||||
(!uri->server || STREQ (uri->server, "")) &&
|
||||
@ -822,6 +857,7 @@ remoteOpen (virConnectPtr conn,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
memset(priv, 0, sizeof(struct private_data));
|
||||
priv->magic = DEAD;
|
||||
@ -1306,6 +1342,7 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
|
||||
#endif
|
||||
close (priv->sock);
|
||||
|
||||
#ifndef WIN32
|
||||
if (priv->pid > 0) {
|
||||
pid_t reap;
|
||||
do {
|
||||
@ -1314,6 +1351,7 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
|
||||
continue;
|
||||
} while (reap != -1 && reap != priv->pid);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Free hostname copy */
|
||||
if (priv->hostname) free (priv->hostname);
|
||||
|
@ -36,6 +36,10 @@
|
||||
|
||||
#define qemudLog(level, msg...) fprintf(stderr, msg)
|
||||
|
||||
#ifndef ENODATA
|
||||
#define ENODATA EIO
|
||||
#endif
|
||||
|
||||
static int
|
||||
virUUIDGenerateRandomBytes(unsigned char *buf,
|
||||
int buflen)
|
||||
|
26
src/virsh.c
26
src/virsh.c
@ -202,7 +202,9 @@ typedef struct __vshControl {
|
||||
virConnectPtr conn; /* connection to hypervisor (MAY BE NULL) */
|
||||
vshCmd *cmd; /* the current command */
|
||||
char *cmdstr; /* string with command */
|
||||
#ifndef __MINGW32__
|
||||
uid_t uid; /* process owner */
|
||||
#endif /* __MINGW32__ */
|
||||
int imode; /* interactive mode? */
|
||||
int quiet; /* quiet mode */
|
||||
int debug; /* print debug messages? */
|
||||
@ -457,6 +459,8 @@ static vshCmdOptDef opts_console[] = {
|
||||
{NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#ifndef __MINGW32__
|
||||
|
||||
static int
|
||||
cmdConsole(vshControl * ctl, vshCmd * cmd)
|
||||
{
|
||||
@ -506,6 +510,17 @@ cmdConsole(vshControl * ctl, vshCmd * cmd)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* __MINGW32__ */
|
||||
|
||||
static int
|
||||
cmdConsole(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
|
||||
{
|
||||
vshError (ctl, FALSE, _("console not implemented on this platform"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
/*
|
||||
* "list" command
|
||||
*/
|
||||
@ -4508,17 +4523,21 @@ vshInit(vshControl * ctl)
|
||||
if (ctl->conn)
|
||||
return FALSE;
|
||||
|
||||
#ifndef __MINGW32__
|
||||
ctl->uid = getuid();
|
||||
#endif
|
||||
|
||||
vshOpenLogFile(ctl);
|
||||
|
||||
/* set up the library error handler */
|
||||
virSetErrorFunc(NULL, virshErrorHandler);
|
||||
|
||||
#ifndef __MINGW32__
|
||||
/* Force a non-root, Xen connection to readonly */
|
||||
if ((ctl->name == NULL ||
|
||||
!strcasecmp(ctl->name, "xen")) && ctl->uid != 0)
|
||||
ctl->readonly = 1;
|
||||
#endif
|
||||
|
||||
ctl->conn = virConnectOpenAuth(ctl->name,
|
||||
virConnectAuthPtrDefault,
|
||||
@ -4537,6 +4556,11 @@ vshInit(vshControl * ctl)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef O_SYNC
|
||||
#define O_SYNC 0
|
||||
#endif
|
||||
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
|
||||
|
||||
/**
|
||||
* vshOpenLogFile:
|
||||
*
|
||||
@ -4566,7 +4590,7 @@ vshOpenLogFile(vshControl *ctl)
|
||||
}
|
||||
|
||||
/* log file open */
|
||||
if ((ctl->log_fd = open(ctl->logfile, O_WRONLY | O_APPEND | O_CREAT | O_SYNC, FILE_MODE)) < 0) {
|
||||
if ((ctl->log_fd = open(ctl->logfile, LOGFILE_FLAGS, FILE_MODE)) < 0) {
|
||||
vshError(ctl, TRUE, _("failed to open the log file. check the log file path"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user