[libvirt PATCH v2 43/56] util: conditionalize FD stream to exclude WIN32

Daniel P. Berrangé posted 56 patches 6 years ago
There is a newer version of this series
[libvirt PATCH v2 43/56] util: conditionalize FD stream to exclude WIN32
Posted by Daniel P. Berrangé 6 years ago
Almost none of the virFDStream code will actually work
on WIN32 builds, nor is it used except for in the
virtualbox driver for screenshots. It is simpler to
wrap it all in a '#ifndef WIN32'.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/util/virfdstream.c | 122 +++++++++++++++++++++++++++++++----------
 1 file changed, 93 insertions(+), 29 deletions(-)

diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c
index c094876dee..05ac63c281 100644
--- a/src/util/virfdstream.c
+++ b/src/util/virfdstream.c
@@ -25,8 +25,8 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <sys/wait.h>
 #ifndef WIN32
+# include <sys/wait.h>
 # include <termios.h>
 #endif
 
@@ -47,6 +47,7 @@
 
 VIR_LOG_INIT("fdstream");
 
+#ifndef WIN32
 typedef enum {
     VIR_FDSTREAM_MSG_TYPE_DATA,
     VIR_FDSTREAM_MSG_TYPE_HOLE,
@@ -1159,7 +1160,6 @@ int virFDStreamOpen(virStreamPtr st,
 }
 
 
-#ifndef WIN32
 int virFDStreamConnectUNIX(virStreamPtr st,
                            const char *path,
                            bool abstract)
@@ -1209,16 +1209,7 @@ int virFDStreamConnectUNIX(virStreamPtr st,
     VIR_FORCE_CLOSE(fd);
     return -1;
 }
-#else
-int virFDStreamConnectUNIX(virStreamPtr st G_GNUC_UNUSED,
-                           const char *path G_GNUC_UNUSED,
-                           bool abstract G_GNUC_UNUSED)
-{
-    virReportSystemError(ENOSYS, "%s",
-                         _("UNIX domain sockets are not supported on this platform"));
-    return -1;
-}
-#endif
+
 
 static int
 virFDStreamOpenFileInternal(virStreamPtr st,
@@ -1240,9 +1231,6 @@ virFDStreamOpenFileInternal(virStreamPtr st,
               st, path, oflags, offset, length, mode);
 
     oflags |= O_NOCTTY;
-#ifdef O_BINARY
-    oflags |= O_BINARY;
-#endif
 
     if (oflags & O_CREAT)
         fd = open(path, oflags, mode);
@@ -1362,7 +1350,6 @@ int virFDStreamCreateFile(virStreamPtr st,
                                        false, false);
 }
 
-#ifndef WIN32
 int virFDStreamOpenPTY(virStreamPtr st,
                        const char *path,
                        unsigned long long offset,
@@ -1402,19 +1389,6 @@ int virFDStreamOpenPTY(virStreamPtr st,
     virFDStreamClose(st);
     return -1;
 }
-#else /* WIN32 */
-int virFDStreamOpenPTY(virStreamPtr st,
-                       const char *path,
-                       unsigned long long offset,
-                       unsigned long long length,
-                       int oflags)
-{
-    return virFDStreamOpenFileInternal(st, path,
-                                       offset, length,
-                                       oflags | O_CREAT, 0,
-                                       false, false);
-}
-#endif /* WIN32 */
 
 int virFDStreamOpenBlockDevice(virStreamPtr st,
                                const char *path,
@@ -1447,3 +1421,93 @@ int virFDStreamSetInternalCloseCb(virStreamPtr st,
     virObjectUnlock(fdst);
     return 0;
 }
+
+#else /* WIN32 */
+
+int
+virFDStreamOpen(virStreamPtr st G_GNUC_UNUSED,
+                int fd G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("File streams are not supported on this platform"));
+    return -1;
+}
+
+
+int
+virFDStreamConnectUNIX(virStreamPtr st G_GNUC_UNUSED,
+                       const char *path G_GNUC_UNUSED,
+                       bool abstract G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("File streams are not supported on this platform"));
+    return -1;
+}
+
+
+int
+virFDStreamOpenFile(virStreamPtr st G_GNUC_UNUSED,
+                    const char *path G_GNUC_UNUSED,
+                    unsigned long long offset G_GNUC_UNUSED,
+                    unsigned long long length G_GNUC_UNUSED,
+                    int oflags G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("File streams are not supported on this platform"));
+    return -1;
+}
+
+
+int
+virFDStreamCreateFile(virStreamPtr st G_GNUC_UNUSED,
+                      const char *path G_GNUC_UNUSED,
+                      unsigned long long offset G_GNUC_UNUSED,
+                      unsigned long long length G_GNUC_UNUSED,
+                      int oflags G_GNUC_UNUSED,
+                      mode_t mode G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("File streams are not supported on this platform"));
+    return -1;
+}
+
+
+int
+virFDStreamOpenPTY(virStreamPtr st G_GNUC_UNUSED,
+                   const char *path G_GNUC_UNUSED,
+                   unsigned long long offset G_GNUC_UNUSED,
+                   unsigned long long length G_GNUC_UNUSED,
+                   int oflags G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("File streams are not supported on this platform"));
+    return -1;
+}
+
+
+int
+virFDStreamOpenBlockDevice(virStreamPtr st G_GNUC_UNUSED,
+                           const char *path G_GNUC_UNUSED,
+                           unsigned long long offset G_GNUC_UNUSED,
+                           unsigned long long length G_GNUC_UNUSED,
+                           bool sparse G_GNUC_UNUSED,
+                           int oflags G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("File streams are not supported on this platform"));
+    return -1;
+}
+
+
+int
+virFDStreamSetInternalCloseCb(virStreamPtr st G_GNUC_UNUSED,
+                              virFDStreamInternalCloseCb cb G_GNUC_UNUSED,
+                              void *opaque G_GNUC_UNUSED,
+                              virFDStreamInternalCloseCbFreeOpaque fcb G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("File streams are not supported on this platform"));
+    return -1;
+}
+
+#endif /* WIN32 */
-- 
2.24.1

Re: [libvirt PATCH v2 43/56] util: conditionalize FD stream to exclude WIN32
Posted by Pavel Hrdina 6 years ago
On Tue, Jan 28, 2020 at 01:11:24PM +0000, Daniel P. Berrangé wrote:
> Almost none of the virFDStream code will actually work
> on WIN32 builds, nor is it used except for in the
> virtualbox driver for screenshots. It is simpler to
> wrap it all in a '#ifndef WIN32'.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/util/virfdstream.c | 122 +++++++++++++++++++++++++++++++----------
>  1 file changed, 93 insertions(+), 29 deletions(-)

If we are OK with breaking screenshots on virtualbox.  I guess that if
someone is really using it we will have a bug report and we can solve it.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Re: [libvirt PATCH v2 43/56] util: conditionalize FD stream to exclude WIN32
Posted by Daniel P. Berrangé 6 years ago
On Fri, Jan 31, 2020 at 04:13:45PM +0100, Pavel Hrdina wrote:
> On Tue, Jan 28, 2020 at 01:11:24PM +0000, Daniel P. Berrangé wrote:
> > Almost none of the virFDStream code will actually work
> > on WIN32 builds, nor is it used except for in the
> > virtualbox driver for screenshots. It is simpler to
> > wrap it all in a '#ifndef WIN32'.
> > 
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >  src/util/virfdstream.c | 122 +++++++++++++++++++++++++++++++----------
> >  1 file changed, 93 insertions(+), 29 deletions(-)
> 
> If we are OK with breaking screenshots on virtualbox.  I guess that if
> someone is really using it we will have a bug report and we can solve it.
> 
> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

I forgot we don't even support virtualbox on Windows any more, since
we moved it into libvirtd & we don't build libvirtd on Windows.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|