qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] fix win32 compilation
@ 2013-04-22 18:53 Paolo Bonzini
  2013-04-22 18:53 ` [Qemu-devel] [PATCH 1/2] add missing inclusions of config-host.h Paolo Bonzini
  2013-04-22 18:53 ` [Qemu-devel] [PATCH 2/2] win32: add readv/writev emulation Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-04-22 18:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, sw

Blue,

here is a fix for the Win32 compilation problem that you reported.

Paolo Bonzini (2):
  add missing inclusions of config-host.h
  win32: add readv/writev emulation

 include/qemu-common.h       | 22 ++--------------------
 include/qemu/osdep.h        | 16 ++++++++++++++++
 qga/channel-posix.c         |  1 +
 tests/libi2c-omap.c         |  1 +
 tests/libqtest.c            |  1 +
 tests/tcg/test-i386-fprem.c |  1 +
 tests/test-mul64.c          |  1 +
 ui/sdl_zoom.c               |  1 +
 ui/vnc.c                    |  1 +
 util/hbitmap.c              |  1 +
 util/iov.c                  |  2 +-
 util/osdep.c                | 42 ++++++++++++++++++++++++++++++++++++++++++
 12 files changed, 69 insertions(+), 21 deletions(-)

-- 
1.8.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 1/2] add missing inclusions of config-host.h
  2013-04-22 18:53 [Qemu-devel] [PATCH 0/2] fix win32 compilation Paolo Bonzini
@ 2013-04-22 18:53 ` Paolo Bonzini
  2013-04-22 18:53 ` [Qemu-devel] [PATCH 2/2] win32: add readv/writev emulation Paolo Bonzini
  1 sibling, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-04-22 18:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, sw

The next patch will add a dependency of qemu/osdep.h on config-host.h.
It could be nicer to use qemu-common.h, but I prefer to be safer this
close to hard feature freeze.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qga/channel-posix.c         | 1 +
 tests/libi2c-omap.c         | 1 +
 tests/libqtest.c            | 1 +
 tests/tcg/test-i386-fprem.c | 1 +
 tests/test-mul64.c          | 1 +
 ui/sdl_zoom.c               | 1 +
 ui/vnc.c                    | 1 +
 util/hbitmap.c              | 1 +
 8 files changed, 8 insertions(+)

diff --git a/qga/channel-posix.c b/qga/channel-posix.c
index e65dda3..30d978e 100644
--- a/qga/channel-posix.c
+++ b/qga/channel-posix.c
@@ -5,6 +5,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config-host.h"
 #include "qemu/osdep.h"
 #include "qemu/sockets.h"
 #include "qga/channel.h"
diff --git a/tests/libi2c-omap.c b/tests/libi2c-omap.c
index c52458c..68d40f3 100644
--- a/tests/libi2c-omap.c
+++ b/tests/libi2c-omap.c
@@ -11,6 +11,7 @@
 #include <glib.h>
 #include <string.h>
 
+#include "config-host.h"
 #include "qemu/osdep.h"
 #include "qemu/bswap.h"
 #include "libqtest.h"
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 884f959..b40269e 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <string.h>
 
+#include "config-host.h"
 #include "qemu/compiler.h"
 #include "qemu/osdep.h"
 
diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c
index e91fb1a..b64e842 100644
--- a/tests/tcg/test-i386-fprem.c
+++ b/tests/tcg/test-i386-fprem.c
@@ -22,6 +22,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
+#include "config-host.h"
 #include "qemu/compiler.h"
 #include "qemu/osdep.h"
 #include <stdio.h>
diff --git a/tests/test-mul64.c b/tests/test-mul64.c
index a0a17f7..9a6a1ec 100644
--- a/tests/test-mul64.c
+++ b/tests/test-mul64.c
@@ -8,6 +8,7 @@
 
 #include <glib.h>
 #include <stdint.h>
+#include "config-host.h"
 #include "qemu/host-utils.h"
 #include "qemu/osdep.h"
 
diff --git a/ui/sdl_zoom.c b/ui/sdl_zoom.c
index 2625c45..b9b7322 100644
--- a/ui/sdl_zoom.c
+++ b/ui/sdl_zoom.c
@@ -11,6 +11,7 @@
  *
  */
 
+#include "config-host.h"
 #include "sdl_zoom.h"
 #include "qemu/osdep.h"
 #include <glib.h>
diff --git a/ui/vnc.c b/ui/vnc.c
index 8ee66b7..e7c28f2 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -24,6 +24,7 @@
  * THE SOFTWARE.
  */
 
+#include "config-host.h"
 #include "vnc.h"
 #include "vnc-jobs.h"
 #include "sysemu/sysemu.h"
diff --git a/util/hbitmap.c b/util/hbitmap.c
index d936831..fc04d3b 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -9,6 +9,7 @@
  * later.  See the COPYING file in the top-level directory.
  */
 
+#include "config-host.h"
 #include <string.h>
 #include <glib.h>
 #include <assert.h>
-- 
1.8.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH 2/2] win32: add readv/writev emulation
  2013-04-22 18:53 [Qemu-devel] [PATCH 0/2] fix win32 compilation Paolo Bonzini
  2013-04-22 18:53 ` [Qemu-devel] [PATCH 1/2] add missing inclusions of config-host.h Paolo Bonzini
@ 2013-04-22 18:53 ` Paolo Bonzini
  2013-04-23 17:40   ` Stefan Weil
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2013-04-22 18:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, sw

Commit e9d8fbf (qemu-file: do not use stdio for qemu_fdopen, 2013-03-27)
introduced a usage of writev, which mingw32 does not have.  Even though
qemu_fdopen itself is not used on mingw32, the future-proof solution is
to add an implementation of it.  This is simple and similar to how we
emulate sendmsg/recvmsg in util/iov.c.

Some files include osdep.h without qemu-common.h, so move the definition
of iovec to osdep.h too, and include osdep.h from qemu-common.h
unconditionally (protection against including files when NEED_CPU_H is
defined is not needed since the removal of AREG0).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu-common.h | 22 ++--------------------
 include/qemu/osdep.h  | 16 ++++++++++++++++
 util/iov.c            |  2 +-
 util/osdep.c          | 42 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index 3b1873e..2cfb1f0 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -84,20 +84,6 @@
 # error Unknown pointer size
 #endif
 
-#ifndef CONFIG_IOVEC
-#define CONFIG_IOVEC
-struct iovec {
-    void *iov_base;
-    size_t iov_len;
-};
-/*
- * Use the same value as Linux for now.
- */
-#define IOV_MAX		1024
-#else
-#include <sys/uio.h>
-#endif
-
 typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
@@ -122,16 +108,12 @@ static inline char *realpath(const char *path, char *resolved_path)
 void configure_icount(const char *option);
 extern int use_icount;
 
-/* FIXME: Remove NEED_CPU_H.  */
-#ifndef NEED_CPU_H
-
 #include "qemu/osdep.h"
 #include "qemu/bswap.h"
 
-#else
-
+/* FIXME: Remove NEED_CPU_H.  */
+#ifdef NEED_CPU_H
 #include "cpu.h"
-
 #endif /* !defined(NEED_CPU_H) */
 
 /* main function, renamed */
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 8b465fd..e2697d6 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -161,6 +161,22 @@ int qemu_close(int fd);
 int qemu_create_pidfile(const char *filename);
 int qemu_get_thread_id(void);
 
+#ifndef CONFIG_IOVEC
+struct iovec {
+    void *iov_base;
+    size_t iov_len;
+};
+/*
+ * Use the same value as Linux for now.
+ */
+#define IOV_MAX		1024
+
+ssize_t readv(int fd, struct iovec *iov, unsigned iov_cnt);
+ssize_t writev(int fd, struct iovec *iov, unsigned iov_cnt);
+#else
+#include <sys/uio.h>
+#endif
+
 #ifdef _WIN32
 static inline void qemu_timersub(const struct timeval *val1,
                                  const struct timeval *val2,
diff --git a/util/iov.c b/util/iov.c
index d32226d..78bbbe1 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -99,7 +99,7 @@ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt)
 static ssize_t
 do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
 {
-#if defined CONFIG_IOVEC && defined CONFIG_POSIX
+#ifdef CONFIG_POSIX
     ssize_t ret;
     struct msghdr msg;
     memset(&msg, 0, sizeof(msg));
diff --git a/util/osdep.c b/util/osdep.c
index bd59ac9..5f306a6 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -406,3 +406,45 @@ bool fips_get_state(void)
     return fips_enabled;
 }
 
+#ifndef CONFIG_IOVEC
+/* helper function for iov_send_recv() */
+static ssize_t
+readv_writev(int fd, struct iovec *iov, unsigned iov_cnt, bool do_write)
+{
+    unsigned i = 0;
+    ssize_t ret = 0;
+    while (i < iov_cnt) {
+        ssize_t r = do_write
+            ? write(fd, iov[i].iov_base, iov[i].iov_len)
+            : read(fd, iov[i].iov_base, iov[i].iov_len);
+        if (r > 0) {
+            ret += r;
+        } else if (!r) {
+            break;
+        } else if (errno == EINTR) {
+            continue;
+        } else {
+            /* else it is some "other" error,
+             * only return if there was no data processed. */
+            if (ret == 0) {
+                ret = -1;
+            }
+            break;
+        }
+        i++;
+    }
+    return ret;
+}
+
+ssize_t
+readv(int fd, struct iovec *iov, unsigned iov_cnt)
+{
+    return readv_writev(fd, iov, iov_cnt, false);
+}
+
+ssize_t
+writev(int fd, struct iovec *iov, unsigned iov_cnt)
+{
+    return readv_writev(fd, iov, iov_cnt, true);
+}
+#endif
-- 
1.8.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] win32: add readv/writev emulation
  2013-04-22 18:53 ` [Qemu-devel] [PATCH 2/2] win32: add readv/writev emulation Paolo Bonzini
@ 2013-04-23 17:40   ` Stefan Weil
  2013-04-23 18:22     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Weil @ 2013-04-23 17:40 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: blauwirbel, qemu-devel

Am 22.04.2013 20:53, schrieb Paolo Bonzini:
> Commit e9d8fbf (qemu-file: do not use stdio for qemu_fdopen, 2013-03-27)
> introduced a usage of writev, which mingw32 does not have.  Even though
> qemu_fdopen itself is not used on mingw32, the future-proof solution is
> to add an implementation of it.  This is simple and similar to how we
> emulate sendmsg/recvmsg in util/iov.c.
>
> Some files include osdep.h without qemu-common.h, so move the definition
> of iovec to osdep.h too, and include osdep.h from qemu-common.h
> unconditionally (protection against including files when NEED_CPU_H is
> defined is not needed since the removal of AREG0).
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu-common.h | 22 ++--------------------
>  include/qemu/osdep.h  | 16 ++++++++++++++++
>  util/iov.c            |  2 +-
>  util/osdep.c          | 42 ++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 61 insertions(+), 21 deletions(-)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index 3b1873e..2cfb1f0 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -84,20 +84,6 @@
>  # error Unknown pointer size
>  #endif
>  
> -#ifndef CONFIG_IOVEC
> -#define CONFIG_IOVEC
> -struct iovec {
> -    void *iov_base;
> -    size_t iov_len;
> -};
> -/*
> - * Use the same value as Linux for now.
> - */
> -#define IOV_MAX		1024
> -#else
> -#include <sys/uio.h>
> -#endif
> -
>  typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
>      GCC_FMT_ATTR(2, 3);
>  
> @@ -122,16 +108,12 @@ static inline char *realpath(const char *path, char *resolved_path)
>  void configure_icount(const char *option);
>  extern int use_icount;
>  
> -/* FIXME: Remove NEED_CPU_H.  */
> -#ifndef NEED_CPU_H
> -
>  #include "qemu/osdep.h"
>  #include "qemu/bswap.h"
>  
> -#else
> -
> +/* FIXME: Remove NEED_CPU_H.  */
> +#ifdef NEED_CPU_H
>  #include "cpu.h"
> -
>  #endif /* !defined(NEED_CPU_H) */
>  
>  /* main function, renamed */
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 8b465fd..e2697d6 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -161,6 +161,22 @@ int qemu_close(int fd);
>  int qemu_create_pidfile(const char *filename);
>  int qemu_get_thread_id(void);
>  
> +#ifndef CONFIG_IOVEC
> +struct iovec {
> +    void *iov_base;
> +    size_t iov_len;
> +};
> +/*
> + * Use the same value as Linux for now.
> + */
> +#define IOV_MAX		1024
> +
> +ssize_t readv(int fd, struct iovec *iov, unsigned iov_cnt);
> +ssize_t writev(int fd, struct iovec *iov, unsigned iov_cnt);
> +#else
> +#include <sys/uio.h>
> +#endif
> +
>  #ifdef _WIN32
>  static inline void qemu_timersub(const struct timeval *val1,
>                                   const struct timeval *val2,
> diff --git a/util/iov.c b/util/iov.c
> index d32226d..78bbbe1 100644
> --- a/util/iov.c
> +++ b/util/iov.c
> @@ -99,7 +99,7 @@ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt)
>  static ssize_t
>  do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
>  {
> -#if defined CONFIG_IOVEC && defined CONFIG_POSIX
> +#ifdef CONFIG_POSIX
>      ssize_t ret;
>      struct msghdr msg;
>      memset(&msg, 0, sizeof(msg));
> diff --git a/util/osdep.c b/util/osdep.c
> index bd59ac9..5f306a6 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -406,3 +406,45 @@ bool fips_get_state(void)
>      return fips_enabled;
>  }
>  
> +#ifndef CONFIG_IOVEC
> +/* helper function for iov_send_recv() */
> +static ssize_t
> +readv_writev(int fd, struct iovec *iov, unsigned iov_cnt, bool do_write)
> +{
> +    unsigned i = 0;
> +    ssize_t ret = 0;
> +    while (i < iov_cnt) {
> +        ssize_t r = do_write
> +            ? write(fd, iov[i].iov_base, iov[i].iov_len)
> +            : read(fd, iov[i].iov_base, iov[i].iov_len);
> +        if (r > 0) {
> +            ret += r;
> +        } else if (!r) {
> +            break;
> +        } else if (errno == EINTR) {
> +            continue;
> +        } else {
> +            /* else it is some "other" error,
> +             * only return if there was no data processed. */
> +            if (ret == 0) {
> +                ret = -1;
> +            }
> +            break;
> +        }
> +        i++;
> +    }
> +    return ret;
> +}
> +
> +ssize_t
> +readv(int fd, struct iovec *iov, unsigned iov_cnt)
> +{
> +    return readv_writev(fd, iov, iov_cnt, false);
> +}
> +
> +ssize_t
> +writev(int fd, struct iovec *iov, unsigned iov_cnt)
> +{
> +    return readv_writev(fd, iov, iov_cnt, true);
> +}
> +#endif

Hi Paolo,

your patch looks good, but maybe you could modify the signatures
of readv, writev to match the Linux originals (missing const, use int):

    ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
    ssize_t writev(int fd, const struct iovec *iov, int iovcnt);

In an updated patch the tab characters could be replaced by a space
to make checkpatch.pl happy.

Regards,
Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] win32: add readv/writev emulation
  2013-04-23 17:40   ` Stefan Weil
@ 2013-04-23 18:22     ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-04-23 18:22 UTC (permalink / raw)
  To: Stefan Weil, Blue Swirl, qemu-devel

> Hi Paolo,
> 
> your patch looks good, but maybe you could modify the signatures
> of readv, writev to match the Linux originals (missing const, use int):
> 
>     ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
>     ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
> 
> In an updated patch the tab characters could be replaced by a space
> to make checkpatch.pl happy.

Ok, I'll send it tomorrow.  I'll make a pull request myself to
streamline the process in time for -rc0.

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-23 18:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-22 18:53 [Qemu-devel] [PATCH 0/2] fix win32 compilation Paolo Bonzini
2013-04-22 18:53 ` [Qemu-devel] [PATCH 1/2] add missing inclusions of config-host.h Paolo Bonzini
2013-04-22 18:53 ` [Qemu-devel] [PATCH 2/2] win32: add readv/writev emulation Paolo Bonzini
2013-04-23 17:40   ` Stefan Weil
2013-04-23 18:22     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).