From 7edd2cf1a2eace84e3f8753e912449ae8871802f Mon Sep 17 00:00:00 2001
From: Peter Maydell <peter.maydell@linaro.org>
Date: Sun, 21 Apr 2013 13:30:03 +0100
Subject: [PATCH 1/5] linux-user: fix compile error due to stray colon at end
 of #ifdef line
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Remove a stray colon from the end of a #ifdef line. Some versions
of gcc complain about this:
 linux-user/syscall.c: In function ‘do_syscall’:
 linux-user/syscall.c:7606:28: error: extra tokens at end of #ifdef directive [-Werror]

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-By: Riku Voipio <riku.voipio@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c705960d7e..30e93bc0d0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7603,7 +7603,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #else
     case TARGET_NR_sendfile:
-#ifdef TARGET_NR_sendfile64:
+#ifdef TARGET_NR_sendfile64
     case TARGET_NR_sendfile64:
 #endif
         goto unimplemented;

From d49b8e0b299df3f0472945eb6d33b8413d102046 Mon Sep 17 00:00:00 2001
From: Gabriel Kerneis <gabriel@kerneis.info>
Date: Tue, 23 Apr 2013 18:15:12 +0100
Subject: [PATCH 2/5] s390x: use CONFIG_INT128 to detect __uint128_t

Target s390x uses ad-hoc macro magic to guess if the compiler
supports the GCC extension __uint128_t.  This patch uses the
the dedicated macro CONFIG_INT128 defined by configure instead.

This fixes compilation with the CIL source code analyzer, which
uses GCC as a preprocessor but does not support __uint128_t.

Signed-off-by: Gabriel Kerneis <gabriel@kerneis.info>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 target-s390x/int_helper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c
index af16b21baa..85e49aafa6 100644
--- a/target-s390x/int_helper.c
+++ b/target-s390x/int_helper.c
@@ -97,8 +97,7 @@ uint64_t HELPER(divu64)(CPUS390XState *env, uint64_t ah, uint64_t al,
         ret = al / b;
     } else {
         /* ??? Move i386 idivq helper to host-utils.  */
-#if HOST_LONG_BITS == 64 && defined(__GNUC__)
-        /* assuming 64-bit hosts have __uint128_t */
+#ifdef CONFIG_INT128
         __uint128_t a = ((__uint128_t)ah << 64) | al;
         __uint128_t q = a / b;
         env->retxl = a % b;

From 48c75f484de13d59df6ae0e6becfe4ad4cd41ad5 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 25 Apr 2013 18:41:16 +0200
Subject: [PATCH 3/5] qemu-doc: Option -ignore-environment removed.

Has been removed in commit fc9c54124d134dbd76338a92a91804dab2df8166.

Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 qemu-doc.texi | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/qemu-doc.texi b/qemu-doc.texi
index dfea4d3799..64493ebfce 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -2683,9 +2683,6 @@ Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
 Set the x86 stack size in bytes (default=524288)
 @item -cpu model
 Select CPU model (-cpu help for list and additional feature selection)
-@item -ignore-environment
-Start with an empty environment. Without this option,
-the initial environment is a copy of the caller's environment.
 @item -E @var{var}=@var{value}
 Set environment @var{var} to @var{value}.
 @item -U @var{var}

From b702d2aebeb6b1392f42262f537f70e6890233a7 Mon Sep 17 00:00:00 2001
From: Ed Maste <emaste@freebsd.org>
Date: Thu, 25 Apr 2013 13:38:28 -0400
Subject: [PATCH 4/5] virtio: Fix compilation without CONFIG_VHOST_SCSI

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/s390x/s390-virtio-bus.c | 2 ++
 hw/s390x/virtio-ccw.c      | 2 ++
 hw/s390x/virtio-ccw.h      | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index cf51a85fcf..a7e81d159f 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -691,7 +691,9 @@ static void s390_virtio_register_types(void)
     type_register_static(&s390_virtio_blk);
     type_register_static(&s390_virtio_net);
     type_register_static(&s390_virtio_scsi);
+#ifdef CONFIG_VHOST_SCSI
     type_register_static(&s390_vhost_scsi);
+#endif
     type_register_static(&s390_virtio_rng);
     type_register_static(&s390_virtio_bridge_info);
 }
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index b857413fa4..c0f26460a9 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1095,7 +1095,9 @@ static void virtio_ccw_register(void)
     type_register_static(&virtio_ccw_net);
     type_register_static(&virtio_ccw_balloon);
     type_register_static(&virtio_ccw_scsi);
+#ifdef CONFIG_VHOST_SCSI
     type_register_static(&vhost_ccw_scsi);
+#endif
     type_register_static(&virtio_ccw_rng);
     type_register_static(&virtual_css_bridge_info);
 }
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index 04ba1b99ee..121a5f8c4a 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -101,6 +101,7 @@ typedef struct VirtIOSCSICcw {
     VirtIOSCSI vdev;
 } VirtIOSCSICcw;
 
+#ifdef CONFIG_VHOST_SCSI
 /* vhost-scsi-ccw */
 
 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw"
@@ -111,6 +112,7 @@ typedef struct VHostSCSICcw {
     VirtioCcwDevice parent_obj;
     VHostSCSI vdev;
 } VHostSCSICcw;
+#endif
 
 /* virtio-blk-ccw */
 

From 6ea8430d98c48eb67e47d14dfe8c0fdb86413555 Mon Sep 17 00:00:00 2001
From: Ed Maste <emaste@freebsd.org>
Date: Thu, 25 Apr 2013 13:59:41 -0400
Subject: [PATCH 5/5] bsd-user: Track change in FreeBSD SYSCTL(9) types

Originally from Garrett Cooper in FreeBSD PR ports/155558
http://www.freebsd.org/cgi/query-pr.cgi?pr=155558

Signed-off-by: Ed Maste <emaste@freebsd.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 bsd-user/syscall.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index 18b43f1a2a..69e3466a08 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -211,7 +211,11 @@ static int sysctl_oldcvt(void *holdp, size_t holdlen, uint32_t kind)
         *(uint64_t *)holdp = tswap64(*(unsigned long *)holdp);
         break;
 #endif
+#if !defined(__FreeBSD_version) || __FreeBSD_version < 900031
     case CTLTYPE_QUAD:
+#else
+    case CTLTYPE_U64:
+#endif
         *(uint64_t *)holdp = tswap64(*(uint64_t *)holdp);
         break;
     case CTLTYPE_STRING: