+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
#include "config.h"
+#ifndef __MINGW32__
+
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
return ret;
}
+#endif /* !__MINGW32__ */
+
/*
* Local variables:
* indent-tabs-mode: nil
#ifndef __VIR_CONSOLE_H__
#define __VIR_CONSOLE_H__
+#ifndef __MINGW32__
+
#ifdef __cplusplus
extern "C" {
#endif
}
#endif
+#endif /* !__MINGW32__ */
+
#endif /* __VIR_CONSOLE_H__ */
/*
#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"
*/
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:
*
return(0);
initialized = 1;
+#if HAVE_WINSOCK2_H
+ if (winsock_init () == -1) return -1;
+#endif
+
if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR))
return (-1);
#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>
#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"
return NULL;
}
+#ifndef WIN32
/**
* qemuForkDaemon:
*
return (0);
}
-
+#endif
enum virDrvOpenRemoteFlags {
VIR_DRV_OPEN_REMOTE_RO = (1 << 0),
break;
}
+#ifndef WIN32
case trans_unix: {
if (!sockname) {
if (flags & VIR_DRV_OPEN_REMOTE_USER) {
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) */
gnutls_deinit (priv->session);
}
close (priv->sock);
+#ifndef WIN32
if (priv->pid > 0) {
pid_t reap;
do {
continue;
} while (reap != -1 && reap != priv->pid);
}
+#endif
}
if (priv->hostname) {
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, "")) &&
}
}
}
+#endif
memset(priv, 0, sizeof(struct private_data));
priv->magic = DEAD;
#endif
close (priv->sock);
+#ifndef WIN32
if (priv->pid > 0) {
pid_t reap;
do {
continue;
} while (reap != -1 && reap != priv->pid);
}
+#endif
/* Free hostname copy */
if (priv->hostname) free (priv->hostname);
#define qemudLog(level, msg...) fprintf(stderr, msg)
+#ifndef ENODATA
+#define ENODATA EIO
+#endif
+
static int
virUUIDGenerateRandomBytes(unsigned char *buf,
int buflen)
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? */
{NULL, 0, 0, NULL}
};
+#ifndef __MINGW32__
+
static int
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
*/
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,
return TRUE;
}
+#ifndef O_SYNC
+#define O_SYNC 0
+#endif
+#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
+
/**
* vshOpenLogFile:
*
}
/* 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"));
}
}