]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fri Dec 7 14:49:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 7 Dec 2007 14:56:37 +0000 (14:56 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 7 Dec 2007 14:56:37 +0000 (14:56 +0000)
* 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.

ChangeLog
src/console.c
src/console.h
src/libvirt.c
src/remote_internal.c
src/uuid.c
src/virsh.c

index f1f5856e91c9ca7b30317e4071808aaf0e90c189..fd07a616174eacd5686399f9a26737e1d5d73c07 100644 (file)
--- a/ChangeLog
+++ b/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
index ab83fcf800be72a704eedc08e9d394865cb10e00..6b336d98a745ef34ca8b5231ab221967bc8163af 100644 (file)
@@ -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
index 7f146526b8152758d78cb33fe65f0d814203737a..279800d947d1eda92e4017409f2c4f5415605a5c 100644 (file)
@@ -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__ */
 
 /*
index 5a7a2eb05507adf44a908703f05e19a44797116c..2f4848e93eb99d8752cb63ef146d3b9c9bacd379 100644 (file)
 #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);
 
index 5a3a63d18a460490cee324d81223e720720042e7..8174ba54b82238dd3c73b4f9c21f93c23048da29 100644 (file)
 #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"
 
@@ -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);
index c00a1b5a7496c0b562a53ceb6c62e141cd7f5b9d..b2022c493aaea64ea885e86b2940c0a4c0769f42 100644 (file)
 
 #define qemudLog(level, msg...) fprintf(stderr, msg)
 
+#ifndef ENODATA
+#define ENODATA EIO
+#endif
+
 static int
 virUUIDGenerateRandomBytes(unsigned char *buf,
                            int buflen)
index 92fef77a5c124ba3dd232345a8a07f9722514efc..375a3c2b9a365dbf7487da3325aa47b873485fc4 100644 (file)
@@ -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"));
     }
 }