Skip to contentSkip to conversation

main: Hide F_GETFD and FD_CLOEXEC use for _WIN32

PATCH In review Corey Bryant 4 participants 6 messages Oct 22, 2012 – Oct 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 main: Hide F_GETFD and FD_CLOEXEC use for _WIN32

---
 vl.c | 2 ++
 1 file changed, 2 insertions(+)
vl.c +2 -0
index 200d849..94c667d 100644
@@ -812,11 +812,13 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
         return -1;
     }
 
+#ifndef _WIN32
     if (fcntl(fd, F_GETFD) & FD_CLOEXEC) {
         qerror_report(ERROR_CLASS_GENERIC_ERROR,
                       "fd is not valid or already in use");
         return -1;
     }
+#endif
 
     if (fdset_id < 0) {
         qerror_report(ERROR_CLASS_GENERIC_ERROR,
Signature · 1 line
1.7.11.4
#1 lore raw
Quoted 11 lines · On Mon, 22 Oct 2012 09:53:44 -0400 Corey Bryant <[email protected]>…
---
 vl.c | 2 ++
 1 file changed, 2 insertions(+)
vl.c +0 -0
index 200d849..94c667d 100644

vl.c static int parse_add_fd(QemuOpts *opts, void *opaque) · line 821

Quoted 10 lines
vl.c +2 -0
@@ -812,11 +812,13 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
         return -1;
     }
 
+#ifndef _WIN32
     if (fcntl(fd, F_GETFD) & FD_CLOEXEC) {
         qerror_report(ERROR_CLASS_GENERIC_ERROR,
                       "fd is not valid or already in use");
         return -1;
     }
+#endif

Which series is this from? The command-line support for fd sets?

qerror_report() is deprecated.

Quoted 3 lines
vl.c +0 -0
     if (fdset_id < 0) {
         qerror_report(ERROR_CLASS_GENERIC_ERROR,
#2 lore raw
Quoted 27 lines · Luiz Capitulino
Quoted 11 lines · On Mon, 22 Oct 2012 09:53:44 -0400 Corey Bryant <[email protected]>…
---
  vl.c | 2 ++
  1 file changed, 2 insertions(+)
vl.c +0 -0
index 200d849..94c667d 100644

vl.c static int parse_add_fd(QemuOpts *opts, void *opaque) · line 821

Quoted 10 lines
vl.c +2 -0
@@ -812,11 +812,13 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
          return -1;
      }
 
+#ifndef _WIN32
      if (fcntl(fd, F_GETFD) & FD_CLOEXEC) {
          qerror_report(ERROR_CLASS_GENERIC_ERROR,
                        "fd is not valid or already in use");
          return -1;
      }
+#endif

Which series is this from? The command-line support for fd sets?

Quoted 2 lines

qerror_report() is deprecated.

Kevin, please let me know if you want me to fix this. Otherwise I assume you'll modify the v5 patch.

Quoted 4 lines
Quoted 3 lines
vl.c +0 -0
      if (fdset_id < 0) {
          qerror_report(ERROR_CLASS_GENERIC_ERROR,
Signature · 2 lines
Regards,
Corey Bryant
#3 lore raw

Am 22.10.2012 19:46, schrieb Corey Bryant:

Quoted 30 lines · Luiz Capitulino
Quoted 27 lines
Quoted 11 lines · On Mon, 22 Oct 2012 09:53:44 -0400 Corey Bryant <[email protected]>…
---
  vl.c | 2 ++
  1 file changed, 2 insertions(+)
vl.c +0 -0
index 200d849..94c667d 100644

vl.c static int parse_add_fd(QemuOpts *opts, void *opaque) · line 821

Quoted 10 lines
vl.c +2 -0
@@ -812,11 +812,13 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
          return -1;
      }
 
+#ifndef _WIN32
      if (fcntl(fd, F_GETFD) & FD_CLOEXEC) {
          qerror_report(ERROR_CLASS_GENERIC_ERROR,
                        "fd is not valid or already in use");
          return -1;
      }
+#endif

Which series is this from? The command-line support for fd sets?

Quoted 5 lines
Quoted 2 lines

qerror_report() is deprecated.

Kevin, please let me know if you want me to fix this. Otherwise I assume you'll modify the v5 patch.

Any conversion of interfaces should be done on top.

Kevin

#4 lore raw
In reply to Corey Bryant

Am 22.10.2012 15:53, schrieb Corey Bryant:

Quoted 13 lines
---
  vl.c | 2 ++
  1 file changed, 2 insertions(+)
vl.c +0 -0
index 200d849..94c667d 100644
@@ -812,11 +812,13 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
          return -1;
      }
 

vl.c static int parse_add_fd(QemuOpts *opts, void *opaque) · line 824

Quoted 10 lines
vl.c +2 -0
+#ifndef _WIN32
      if (fcntl(fd, F_GETFD)&  FD_CLOEXEC) {
          qerror_report(ERROR_CLASS_GENERIC_ERROR,
                        "fd is not valid or already in use");
          return -1;
      }
+#endif
 
      if (fdset_id<  0) {
          qerror_report(ERROR_CLASS_GENERIC_ERROR,

Are you sure that all other hosts provide F_GETFD and FD_CLOEXEC and that MinGW will never do that?
Maybe testing those two macros instead of _WIN32 would be better:

#if defined(F_GETFD) && defined(FD_CLOEXEC)
...
#endif

I also think that this patch should be merged with the one which adds that code and not applied as a separate patch (otherwise git bisect would be broken).

Regards
Stefan Weil

#5 lore raw
Quoted 23 lines · Stefan Weil

Am 22.10.2012 15:53, schrieb Corey Bryant:

Quoted 22 lines
---
  vl.c | 2 ++
  1 file changed, 2 insertions(+)
vl.c +2 -0
index 200d849..94c667d 100644
@@ -812,11 +812,13 @@ static int parse_add_fd(QemuOpts *opts, void
 *opaque)
          return -1;
      }
 
+#ifndef _WIN32
      if (fcntl(fd, F_GETFD)&  FD_CLOEXEC) {
          qerror_report(ERROR_CLASS_GENERIC_ERROR,
                        "fd is not valid or already in use");
          return -1;
      }
+#endif
 
Quoted 6 lines
Quoted 2 lines
vl.c +0 -0
      if (fdset_id<  0) {

qerror_report(ERROR_CLASS_GENERIC_ERROR,

Are you sure that all other hosts provide F_GETFD and FD_CLOEXEC and that MinGW will never do that?

I don't know for sure but use of F_GETFD and FD_CLOEXEC broke the build for MinGW.

Quoted 9 lines

Maybe testing those two macros instead of _WIN32 would be better:

#if defined(F_GETFD) && defined(FD_CLOEXEC)
...
#endif

I also think that this patch should be merged with the one which adds that code and not applied as a separate patch (otherwise git bisect would be broken).

Kevin ended up providing a fix for this in "[PATCH v5] qemu-config: Add new -add-fd command line option" which fails the -add-fd command for Windows. This is in-line with how the QMP add-fd command behaves.

Signature · 2 lines
Regards,
Corey Bryant