Re: [Qemu-devel] [PATCH 0/1] block: Eliminate the S_1KiB, S_2KiB, ... macros

2019-01-13 Thread Leonid Bloch
On 1/11/19 9:14 PM, Markus Armbruster wrote:
> Back in September, Leonid Block added a whole bunch of macros (commit

* Bloch. :)

> 540b8492618) to improve readability of qcow2.h a bit (commit
> b6a95c6d100).  He later used them to fix the "vdi" driver's parameter
> cluster_size's default value (commit 3dd5b8f4718).  He has now
> proposed a further patch[1] to auto-generate these macros.  That patch
> feels overengineered to me.
> 
> On closer examination, I found I dislike the macros before his new
> patch.  So did Eric Blake.
> 
> The macros exist because the common KiB, MiB, ... macros aren't usable
> when you need a literal rather than a constant expression.
> stringify() does, and we use it to define the QemuOpts default value.
> 
> Eric proposed to improve QemuOpts to accept integer default values,
> too[2].  Before I review that patch series, I want to establish a
> "stupidest solution that can possibly work" baseline.  And that's what
> this patch is.
> 
> [1] [PATCH v2 0/1] include: Auto-generate the sizes lookup table
> Message-ID: <20190103213320.2653-1-lbl...@janustech.com>
> 
> [2] [PATCH v3 0/6] include: Auto-generate the sizes lookup table
> Message-Id: <20190110191901.5082-1-ebl...@redhat.com>
> 
> Markus Armbruster (1):
>block: Eliminate the S_1KiB, S_2KiB, ... macros
> 
>   block/qcow2.h| 10 +++---
>   block/vdi.c  |  3 +-
>   include/qemu/units.h | 73 
>   3 files changed, 7 insertions(+), 79 deletions(-)
> 


Re: [Qemu-devel] [PATCH 1/1] block: Eliminate the S_1KiB, S_2KiB, ... macros

2019-01-13 Thread Leonid Bloch
Hi,

On 1/11/19 9:14 PM, Markus Armbruster wrote:
> We define 54 macros for the powers of two >= 1024.  We use six, in six
> macro definitions.  Four of them could just as well use the common MiB
> macro, so do that.  The remaining two can't, because they get passed
> to stringify.  Replace the macro by the literal number there.
> Slightly harder to read in one instance (1048576 vs. S_1MiB), so add a
> comment there.  The other instance is a wash: 65536 vs S_64KiB.  65536
> has been good enough for more than seven years there.
> 
> This effectively reverts commit 540b8492618 and 1240ac558d3.
> 
> Signed-off-by: Markus Armbruster 
> ---
>   block/qcow2.h| 10 +++---
>   block/vdi.c  |  3 +-
>   include/qemu/units.h | 73 
>   3 files changed, 7 insertions(+), 79 deletions(-)
> 
> diff --git a/block/qcow2.h b/block/qcow2.h
> index a98d24500b..2380cbfb41 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -50,11 +50,11 @@
>   
>   /* 8 MB refcount table is enough for 2 PB images at 64k cluster size
>* (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */
> -#define QCOW_MAX_REFTABLE_SIZE S_8MiB
> +#define QCOW_MAX_REFTABLE_SIZE (8 * MiB)
>   
>   /* 32 MB L1 table is enough for 2 PB images at 64k cluster size
>* (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */
> -#define QCOW_MAX_L1_SIZE S_32MiB
> +#define QCOW_MAX_L1_SIZE (32 * MiB)
>   
>   /* Allow for an average of 1k per snapshot table entry, should be plenty of
>* space for snapshot names and IDs */
> @@ -81,15 +81,15 @@
>   #define MIN_REFCOUNT_CACHE_SIZE 4 /* clusters */
>   
>   #ifdef CONFIG_LINUX
> -#define DEFAULT_L2_CACHE_MAX_SIZE S_32MiB
> +#define DEFAULT_L2_CACHE_MAX_SIZE (32 * MiB)
>   #define DEFAULT_CACHE_CLEAN_INTERVAL 600  /* seconds */
>   #else
> -#define DEFAULT_L2_CACHE_MAX_SIZE S_8MiB
> +#define DEFAULT_L2_CACHE_MAX_SIZE (8 * MiB)
>   /* Cache clean interval is currently available only on Linux, so must be 0 
> */
>   #define DEFAULT_CACHE_CLEAN_INTERVAL 0
>   #endif
>   
> -#define DEFAULT_CLUSTER_SIZE S_64KiB
> +#define DEFAULT_CLUSTER_SIZE 65536

/* Note: can't use 64 * KiB here, because it's passed to stringify() */

Otherwise fine with me. The other solutions (including mine) indeed seem 
overengineered compared to this.

Leonid.

>   
>   #define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts"
>   #define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request"
> diff --git a/block/vdi.c b/block/vdi.c
> index 2380daa583..bf1d19dd68 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -85,7 +85,8 @@
>   #define BLOCK_OPT_STATIC "static"
>   
>   #define SECTOR_SIZE 512
> -#define DEFAULT_CLUSTER_SIZE S_1MiB
> +#define DEFAULT_CLUSTER_SIZE 1048576
> +/* Note: can't use 1 * MiB, because it's passed to stringify() */
>   
>   #if defined(CONFIG_VDI_DEBUG)
>   #define VDI_DEBUG 1
> diff --git a/include/qemu/units.h b/include/qemu/units.h
> index 1c959d182e..692db3fbb2 100644
> --- a/include/qemu/units.h
> +++ b/include/qemu/units.h
> @@ -17,77 +17,4 @@
>   #define PiB (INT64_C(1) << 50)
>   #define EiB (INT64_C(1) << 60)
>   
> -/*
> - * The following lookup table is intended to be used when a literal string of
> - * the number of bytes is required (for example if it needs to be 
> stringified).
> - * It can also be used for generic shortcuts of power-of-two sizes.
> - * This table is generated using the AWK script below:
> - *
> - *  BEGIN {
> - *  suffix="KMGTPE";
> - *  for(i=10; i<64; i++) {
> - *  val=2**i;
> - *  s=substr(suffix, int(i/10), 1);
> - *  n=2**(i%10);
> - *  pad=21-int(log(n)/log(10));
> - *  printf("#define S_%d%siB %*d\n", n, s, pad, val);
> - *  }
> - *  }
> - */
> -
> -#define S_1KiB  1024
> -#define S_2KiB  2048
> -#define S_4KiB  4096
> -#define S_8KiB  8192
> -#define S_16KiB16384
> -#define S_32KiB32768
> -#define S_64KiB65536
> -#define S_128KiB  131072
> -#define S_256KiB  262144
> -#define S_512KiB  524288
> -#define S_1MiB   1048576
> -#define S_2MiB   2097152
> -#define S_4MiB   4194304
> -#define S_8MiB   8388608
> -#define S_16MiB 16777216
> -#define S_32MiB 33554432
> -#define S_64MiB 67108864
> -#define S_128MiB   134217728
> -#define S_256MiB   268435456
> -#define S_512MiB   536870912
> -#define S_1GiB1073741824
> -#define S_2GiB2147483648
> -#define S_4GiB4294967296
> -#define S_8GiB8589934592
> -#define S_16GiB  17179869184
> -#define S_32GiB  34359738368
> -#define S_64GiB  68719476736
> -#define S_128GiB137438953472
> -#define S_256GiB274877906944
> -#define S_512GiB549755813888
> -#define S_1TiB 109951162777

[Qemu-devel] [PATCH v2 2/4] qga: fix send_response error handling

2019-01-13 Thread Basil Salman
Sometimes qemu-ga fails to send a response to client due to memory allocation
issues due to a large response message, this can be experienced while trying
to read large number of bytes using QMP command guest-file-read.

Added a check to send an error response to qemu-ga client in such cases.

Signed-off-by: Basil Salman 
---
 qga/main.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/qga/main.c b/qga/main.c
index 87a0711c14..964275c40c 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -561,6 +561,8 @@ static void process_command(GAState *s, QDict *req)
 {
 QDict *rsp;
 int ret;
+QDict *ersp;
+Error *err = NULL;
 
 g_assert(req);
 g_debug("processing command");
@@ -569,9 +571,20 @@ static void process_command(GAState *s, QDict *req)
 ret = send_response(s, rsp);
 if (ret < 0) {
 g_warning("error sending response: %s", strerror(-ret));
+goto err;
 }
 qobject_unref(rsp);
 }
+return;
+err:
+error_setg(&err, "Insufficient system resources exist to "
+  "complete the requested service");
+ersp = qmp_error_response(err);
+ret = send_response(s, ersp);
+if (ret < 0) {
+g_warning("error sending error response: %s", strerror(-ret));
+}
+qobject_unref(ersp);
 }
 
 /* handle requests/control events coming in over the channel */
-- 
2.17.2




[Qemu-devel] [PATCH v2 0/4] QGA - Win fixes

2019-01-13 Thread Basil Salman
This patch series addresses serveral issues with qga-win please review
them and share your thoughts.

Basil Salman (3):
  qga-win: prevent crash when executing guest-file-read with large count
  qga: fix send_response error handling
  qga: Installer: Wait for installation to finish

Sameeh Jubran (1):
  qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error

 qga/commands-win32.c  |  8 +++-
 qga/installer/qemu-ga.wxs |  2 +-
 qga/main.c| 13 +
 qga/vss-win32/install.cpp | 11 +++
 4 files changed, 32 insertions(+), 2 deletions(-)

-- 
2.17.2




[Qemu-devel] [PATCH v2 1/4] qga-win: prevent crash when executing guest-file-read with large count

2019-01-13 Thread Basil Salman
BZ: #1594054
guest-file-read command is currently implelmented to read from a
file handle count number of bytes. when executed with a very large count number
qemu-ga crashes.
after some digging turns out that qemu-ga crashes after trying to allocate
a buffer large enough to save the data read in it, the buffer was allocated 
using
g_malloc0 which is not fail safe, and results a crash in case of failure.
g_malloc0 was replaced with g_try_malloc0() which returns NULL on failure,
A check was added for that case in order to prevent qemu-ga from crashing
and to send a response to the qemu-ga client accordingly.

Signed-off-by: Basil Salman 
---
 qga/commands-win32.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 62e1b51dfe..4260faa573 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -345,7 +345,13 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool 
has_count,
 }
 
 fh = gfh->fh;
-buf = g_malloc0(count+1);
+buf = g_try_malloc0(count + 1);
+if (!buf) {
+error_setg(errp,
+   "failed to allocate sufficient memory"
+   "to complete the requested service");
+return read_data;
+}
 is_ok = ReadFile(fh, buf, count, &read_count, NULL);
 if (!is_ok) {
 error_setg_win32(errp, GetLastError(), "failed to read file");
-- 
2.17.2




[Qemu-devel] [PATCH v2 3/4] qga: Installer: Wait for installation to finish

2019-01-13 Thread Basil Salman
Installation might fail if we don't wait for the provider
unregisteration process to finish.

Signed-off-by: Sameeh Jubran 
Signed-off-by: Basil Salman 
---
 qga/installer/qemu-ga.wxs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs
index 64bf90bd85..f6781752e6 100644
--- a/qga/installer/qemu-ga.wxs
+++ b/qga/installer/qemu-ga.wxs
@@ -81,7 +81,7 @@
   Arguments="-d --retry-path"
   >
 
-
+
   
   
   
-- 
2.17.2




[Qemu-devel] [PATCH v2 4/4] qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error

2019-01-13 Thread Basil Salman
From: Sameeh Jubran 

This patch handles the case where VSS Provider is already registered,
where in such case qga uninstalls the provider and registers it again.

Signed-off-by: Sameeh Jubran 
Signed-off-by: Basil Salman 
---
 qga/vss-win32/install.cpp | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index 6713e58670..a456841360 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -443,6 +443,17 @@ STDAPI DllRegisterServer(void)
  VSS_PROV_SOFTWARE,
  const_cast(QGA_PROVIDER_VERSION),
  g_gProviderVersion);
+if (hr == (long int) VSS_E_PROVIDER_ALREADY_REGISTERED) {
+DllUnregisterServer();
+hr = pVssAdmin->RegisterProvider(g_gProviderId, CLSID_QGAVSSProvider,
+ const_cast
+ (QGA_PROVIDER_LNAME),
+ VSS_PROV_SOFTWARE,
+ const_cast
+ (QGA_PROVIDER_VERSION),
+ g_gProviderVersion);
+}
+
 if (FAILED(hr)) {
 errmsg_dialog(hr, "RegisterProvider failed");
 }
-- 
2.17.2




Re: [Qemu-devel] [PATCH v3] usb: assign unique serial numbers to hid devices

2019-01-13 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190110120843.3839-1-kra...@redhat.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20190110120843.3839-1-kra...@redhat.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH] target/ppc/kvm: Drop useless include directive

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/154713023826.379171.4010754027183178230.st...@bahia.lan/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH] target/ppc/kvm: Drop useless include directive
Type: series
Message-id: 154713023826.379171.4010754027183178230.st...@bahia.lan

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback --color=always base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
  File "patchew-tester8/src/patchew-cli", line 521, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf, True)
  File "patchew-tester8/src/patchew-cli", line 48, in git_clone_repo
stdout=logf, stderr=logf)
  File "/usr/lib64/python3.3/subprocess.py", line 544, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'remote', 'add', '-f', 
'--mirror=fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384', 
'https://github.com/patchew-project/qemu']' returned non-zero exit status -9



The full log is available at
http://patchew.org/logs/154713023826.379171.4010754027183178230.st...@bahia.lan/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH] contrib/gitdm: Fix a typo

2019-01-13 Thread no-reply
Patchew URL: https://patchew.org/QEMU/201905.8270-1-phi...@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH] contrib/gitdm: Fix a typo
Type: series
Message-id: 201905.8270-1-phi...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback --color=always base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
  File "patchew-tester2/src/patchew-cli", line 521, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf, True)
  File "patchew-tester2/src/patchew-cli", line 48, in git_clone_repo
stdout=logf, stderr=logf)
  File "/usr/lib64/python3.3/subprocess.py", line 544, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'remote', 'add', '-f', 
'--mirror=fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384', 
'https://github.com/patchew-project/qemu']' returned non-zero exit status -9



The full log is available at
http://patchew.org/logs/201905.8270-1-phi...@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH] target/ppc/kvm: Drop useless include directive

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/154713023826.379171.4010754027183178230.st...@bahia.lan/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/154713023826.379171.4010754027183178230.st...@bahia.lan/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH v3] usb: assign unique serial numbers to hid devices

2019-01-13 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190110120843.3839-1-kra...@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH v3] usb: assign unique serial numbers to hid 
devices
Type: series
Message-id: 20190110120843.3839-1-kra...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback --color=always base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
  File "patchew-tester7/src/patchew-cli", line 521, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf, True)
  File "patchew-tester7/src/patchew-cli", line 48, in git_clone_repo
stdout=logf, stderr=logf)
  File "/usr/lib64/python3.3/subprocess.py", line 544, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'remote', 'add', '-f', 
'--mirror=fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384', 
'https://github.com/patchew-project/qemu']' returned non-zero exit status -9



The full log is available at
http://patchew.org/logs/20190110120843.3839-1-kra...@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH] target/ppc/kvm: Drop useless include directive

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/154713023826.379171.4010754027183178230.st...@bahia.lan/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/154713023826.379171.4010754027183178230.st...@bahia.lan/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[Qemu-devel] [PATCH for-4.0 0/5] fix some segmentation faults and migration issues

2019-01-13 Thread Fei Li
All these five patches have gotten the Reviewed-by: the first patch
is to fix one segmentation fault and the other four are to fix some
migration issues.

To be more detail, they are extracted from previous
"[PATCH for-4.0 v9 16/16] qemu_thread_create: propagate errors to
callers to handle.", but actually these five patches are derivative
and not relevant to the mentioned qemu_thread_create patch series.
Thus send them separately to make them be merged earlier.

Fei Li (5):
  Fix segmentation fault when qemu_signal_init fails
  migration: fix the multifd code when receiving less channels
  migration: multifd_save_cleanup() can't fail, simplify
  migration: add more error handling for postcopy_ram_enable_notify
  migration: unify error handling for process_incoming_migration_co

 migration/channel.c  | 11 ++-
 migration/migration.c| 40 +---
 migration/migration.h|  2 +-
 migration/postcopy-ram.c |  1 +
 migration/ram.c  | 28 ++--
 migration/ram.h  |  4 ++--
 migration/savevm.c   |  1 +
 util/main-loop.c |  8 
 8 files changed, 54 insertions(+), 41 deletions(-)

-- 
2.17.2 (Apple Git-113)





[Qemu-devel] [PATCH for-4.0 3/5] migration: multifd_save_cleanup() can't fail, simplify

2019-01-13 Thread Fei Li
From: Fei Li 

multifd_save_cleanup() takes an Error ** argument and returns an
error code even though it can't actually fail.  Its callers
dutifully check for failure.  Remove the useless argument and return
value, and simplify the callers.

Cc: Dr. David Alan Gilbert 
Cc: Markus Armbruster 
Signed-off-by: Fei Li 
Reviewed-by: Juan Quintela 
---
 migration/migration.c |  5 +
 migration/ram.c   | 11 ---
 migration/ram.h   |  2 +-
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 24cb4b9d0d..5d322eb9d6 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1386,7 +1386,6 @@ static void migrate_fd_cleanup(void *opaque)
 qemu_savevm_state_cleanup();
 
 if (s->to_dst_file) {
-Error *local_err = NULL;
 QEMUFile *tmp;
 
 trace_migrate_fd_cleanup();
@@ -1397,9 +1396,7 @@ static void migrate_fd_cleanup(void *opaque)
 }
 qemu_mutex_lock_iothread();
 
-if (multifd_save_cleanup(&local_err) != 0) {
-error_report_err(local_err);
-}
+multifd_save_cleanup();
 qemu_mutex_lock(&s->qemu_file_lock);
 tmp = s->to_dst_file;
 s->to_dst_file = NULL;
diff --git a/migration/ram.c b/migration/ram.c
index 47c7ab2229..43c2b442af 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -917,13 +917,12 @@ static void multifd_send_terminate_threads(Error *err)
 }
 }
 
-int multifd_save_cleanup(Error **errp)
+void multifd_save_cleanup(void)
 {
 int i;
-int ret = 0;
 
 if (!migrate_use_multifd()) {
-return 0;
+return;
 }
 multifd_send_terminate_threads(NULL);
 for (i = 0; i < migrate_multifd_channels(); i++) {
@@ -953,7 +952,6 @@ int multifd_save_cleanup(Error **errp)
 multifd_send_state->pages = NULL;
 g_free(multifd_send_state);
 multifd_send_state = NULL;
-return ret;
 }
 
 static void multifd_send_sync_main(void)
@@ -1071,9 +1069,8 @@ static void multifd_new_send_channel_async(QIOTask *task, 
gpointer opaque)
 Error *local_err = NULL;
 
 if (qio_task_propagate_error(task, &local_err)) {
-if (multifd_save_cleanup(&local_err) != 0) {
-migrate_set_error(migrate_get_current(), local_err);
-}
+migrate_set_error(migrate_get_current(), local_err);
+multifd_save_cleanup();
 } else {
 p->c = QIO_CHANNEL(sioc);
 qio_channel_set_delay(p->c, false);
diff --git a/migration/ram.h b/migration/ram.h
index 046d3074be..936177b3e9 100644
--- a/migration/ram.h
+++ b/migration/ram.h
@@ -43,7 +43,7 @@ uint64_t ram_bytes_remaining(void);
 uint64_t ram_bytes_total(void);
 
 int multifd_save_setup(void);
-int multifd_save_cleanup(Error **errp);
+void multifd_save_cleanup(void);
 int multifd_load_setup(void);
 int multifd_load_cleanup(Error **errp);
 bool multifd_recv_all_channels_created(void);
-- 
2.17.2 (Apple Git-113)





[Qemu-devel] [PATCH for-4.0 5/5] migration: unify error handling for process_incoming_migration_co

2019-01-13 Thread Fei Li
From: Fei Li 

In the current code, if process_incoming_migration_co() fails we do
the same error handing: set the error state, close the source file,
do the cleanup for multifd, and then exit(EXIT_FAILURE). To make the
code clearer, add a "goto fail" to unify the error handling.

Cc: Dr. David Alan Gilbert 
Signed-off-by: Fei Li 
Reviewed-by: Dr. David Alan Gilbert 
---
 migration/migration.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 5d322eb9d6..ded151b1bf 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -438,15 +438,13 @@ static void process_incoming_migration_co(void *opaque)
 /* Make sure all file formats flush their mutable metadata */
 bdrv_invalidate_cache_all(&local_err);
 if (local_err) {
-migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
-MIGRATION_STATUS_FAILED);
 error_report_err(local_err);
-exit(EXIT_FAILURE);
+goto fail;
 }
 
 if (colo_init_ram_cache() < 0) {
 error_report("Init ram cache failed");
-exit(EXIT_FAILURE);
+goto fail;
 }
 
 qemu_thread_create(&mis->colo_incoming_thread, "COLO incoming",
@@ -461,20 +459,22 @@ static void process_incoming_migration_co(void *opaque)
 }
 
 if (ret < 0) {
-Error *local_err = NULL;
-
-migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
-  MIGRATION_STATUS_FAILED);
 error_report("load of migration failed: %s", strerror(-ret));
-qemu_fclose(mis->from_src_file);
-if (multifd_load_cleanup(&local_err) != 0) {
-error_report_err(local_err);
-}
-exit(EXIT_FAILURE);
+goto fail;
 }
 mis->bh = qemu_bh_new(process_incoming_migration_bh, mis);
 qemu_bh_schedule(mis->bh);
 mis->migration_incoming_co = NULL;
+return;
+fail:
+local_err = NULL;
+migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE,
+  MIGRATION_STATUS_FAILED);
+qemu_fclose(mis->from_src_file);
+if (multifd_load_cleanup(&local_err) != 0) {
+error_report_err(local_err);
+}
+exit(EXIT_FAILURE);
 }
 
 static void migration_incoming_setup(QEMUFile *f)
-- 
2.17.2 (Apple Git-113)





[Qemu-devel] [PATCH for-4.0 1/5] Fix segmentation fault when qemu_signal_init fails

2019-01-13 Thread Fei Li
From: Fei Li 

When qemu_signal_init() fails in qemu_init_main_loop(), we return
without setting an error.  Its callers crash then when they try to
report the error with error_report_err().

To avoid such segmentation fault, add a new Error parameter to make
the call trace to propagate the err to the final caller.

Fixes: 2f78e491d7b46542158ce0b8132ee4e05bc0ade4
Cc: Paolo Bonzini 
Signed-off-by: Fei Li 
Reviewed-by: Fam Zheng 
Reviewed-by: Markus Armbruster 
---
 util/main-loop.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/util/main-loop.c b/util/main-loop.c
index affe0403c5..443cb4cfe8 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -71,7 +71,7 @@ static void sigfd_handler(void *opaque)
 }
 }
 
-static int qemu_signal_init(void)
+static int qemu_signal_init(Error **errp)
 {
 int sigfd;
 sigset_t set;
@@ -96,7 +96,7 @@ static int qemu_signal_init(void)
 sigdelset(&set, SIG_IPI);
 sigfd = qemu_signalfd(&set);
 if (sigfd == -1) {
-fprintf(stderr, "failed to create signalfd\n");
+error_setg_errno(errp, errno, "failed to create signalfd");
 return -errno;
 }
 
@@ -109,7 +109,7 @@ static int qemu_signal_init(void)
 
 #else /* _WIN32 */
 
-static int qemu_signal_init(void)
+static int qemu_signal_init(Error **errp)
 {
 return 0;
 }
@@ -148,7 +148,7 @@ int qemu_init_main_loop(Error **errp)
 
 init_clocks(qemu_timer_notify_cb);
 
-ret = qemu_signal_init();
+ret = qemu_signal_init(errp);
 if (ret) {
 return ret;
 }
-- 
2.17.2 (Apple Git-113)





[Qemu-devel] [PATCH for-4.0 4/5] migration: add more error handling for postcopy_ram_enable_notify

2019-01-13 Thread Fei Li
From: Fei Li 

Call postcopy_ram_incoming_cleanup() to do the cleanup when
postcopy_ram_enable_notify fails. Besides, report the error
message when qemu_ram_foreach_migratable_block() fails.

Cc: Dr. David Alan Gilbert 
Signed-off-by: Fei Li 
Reviewed-by: Dr. David Alan Gilbert 
---
 migration/postcopy-ram.c | 1 +
 migration/savevm.c   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index e5c02a32c5..fa09dba534 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1117,6 +1117,7 @@ int postcopy_ram_enable_notify(MigrationIncomingState 
*mis)
 
 /* Mark so that we get notified of accesses to unwritten areas */
 if (qemu_ram_foreach_migratable_block(ram_block_enable_notify, mis)) {
+error_report("ram_block_enable_notify failed");
 return -1;
 }
 
diff --git a/migration/savevm.c b/migration/savevm.c
index 9e45fb4f3f..d784e8aa40 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1729,6 +1729,7 @@ static int 
loadvm_postcopy_handle_listen(MigrationIncomingState *mis)
  */
 if (migrate_postcopy_ram()) {
 if (postcopy_ram_enable_notify(mis)) {
+postcopy_ram_incoming_cleanup(mis);
 return -1;
 }
 }
-- 
2.17.2 (Apple Git-113)





[Qemu-devel] [PATCH for-4.0 2/5] migration: fix the multifd code when receiving less channels

2019-01-13 Thread Fei Li
From: Fei Li 

In our current code, when multifd is used during migration, if there
is an error before the destination receives all new channels, the
source keeps running, however the destination does not exit but keeps
waiting until the source is killed deliberately.

Fix this by dumping the specific error and let users decide whether
to quit from the destination side when failing to receive packet via
some channel. And update the comment for multifd_recv_new_channel().

Cc: Dr. David Alan Gilbert 
Cc: Peter Xu 
Cc: Markus Armbruster 
Signed-off-by: Fei Li 
Reviewed-by: Peter Xu 
---
 migration/channel.c   | 11 ++-
 migration/migration.c |  9 +++--
 migration/migration.h |  2 +-
 migration/ram.c   | 17 ++---
 migration/ram.h   |  2 +-
 5 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/migration/channel.c b/migration/channel.c
index 33e0e9b82f..20e4c8e2dc 100644
--- a/migration/channel.c
+++ b/migration/channel.c
@@ -30,6 +30,7 @@
 void migration_channel_process_incoming(QIOChannel *ioc)
 {
 MigrationState *s = migrate_get_current();
+Error *local_err = NULL;
 
 trace_migration_set_incoming_channel(
 ioc, object_get_typename(OBJECT(ioc)));
@@ -38,13 +39,13 @@ void migration_channel_process_incoming(QIOChannel *ioc)
 *s->parameters.tls_creds &&
 !object_dynamic_cast(OBJECT(ioc),
  TYPE_QIO_CHANNEL_TLS)) {
-Error *local_err = NULL;
 migration_tls_channel_process_incoming(s, ioc, &local_err);
-if (local_err) {
-error_report_err(local_err);
-}
 } else {
-migration_ioc_process_incoming(ioc);
+migration_ioc_process_incoming(ioc, &local_err);
+}
+
+if (local_err) {
+error_report_err(local_err);
 }
 }
 
diff --git a/migration/migration.c b/migration/migration.c
index ffc4d9e556..24cb4b9d0d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -541,7 +541,7 @@ void migration_fd_process_incoming(QEMUFile *f)
 migration_incoming_process();
 }
 
-void migration_ioc_process_incoming(QIOChannel *ioc)
+void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
 {
 MigrationIncomingState *mis = migration_incoming_get_current();
 bool start_migration;
@@ -563,9 +563,14 @@ void migration_ioc_process_incoming(QIOChannel *ioc)
  */
 start_migration = !migrate_use_multifd();
 } else {
+Error *local_err = NULL;
 /* Multiple connections */
 assert(migrate_use_multifd());
-start_migration = multifd_recv_new_channel(ioc);
+start_migration = multifd_recv_new_channel(ioc, &local_err);
+if (local_err) {
+error_propagate(errp, local_err);
+return;
+}
 }
 
 if (start_migration) {
diff --git a/migration/migration.h b/migration/migration.h
index e413d4d8b6..02b7304610 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -229,7 +229,7 @@ struct MigrationState
 void migrate_set_state(int *state, int old_state, int new_state);
 
 void migration_fd_process_incoming(QEMUFile *f);
-void migration_ioc_process_incoming(QIOChannel *ioc);
+void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp);
 void migration_incoming_process(void);
 
 bool  migration_has_all_channels(void);
diff --git a/migration/ram.c b/migration/ram.c
index 1849979fed..47c7ab2229 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1322,8 +1322,13 @@ bool multifd_recv_all_channels_created(void)
 return thread_count == atomic_read(&multifd_recv_state->count);
 }
 
-/* Return true if multifd is ready for the migration, otherwise false */
-bool multifd_recv_new_channel(QIOChannel *ioc)
+/*
+ * Try to receive all multifd channels to get ready for the migration.
+ * - Return true and do not set @errp when correctly receving all channels;
+ * - Return false and do not set @errp when correctly receiving the current 
one;
+ * - Return false and set @errp when failing to receive the current channel.
+ */
+bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp)
 {
 MultiFDRecvParams *p;
 Error *local_err = NULL;
@@ -1332,6 +1337,10 @@ bool multifd_recv_new_channel(QIOChannel *ioc)
 id = multifd_recv_initial_packet(ioc, &local_err);
 if (id < 0) {
 multifd_recv_terminate_threads(local_err);
+error_propagate_prepend(errp, local_err,
+"failed to receive packet"
+" via multifd channel %d: ",
+atomic_read(&multifd_recv_state->count));
 return false;
 }
 
@@ -1340,6 +1349,7 @@ bool multifd_recv_new_channel(QIOChannel *ioc)
 error_setg(&local_err, "multifd: received id '%d' already setup'",
id);
 multifd_recv_terminate_threads(local_err);
+error_propagate(errp, local_err);
 return false;
 }
 p->c = ioc;
@@ -1351,7 +1361,8 @@ bool mul

Re: [Qemu-devel] [PATCH v1 0/3] [RFC] get real IOMMU information from VFIO IOMMU

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/1547037680-21458-1-git-send-email-pmo...@linux.ibm.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/1547037680-21458-1-git-send-email-pmo...@linux.ibm.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH v5 0/4] allow to load initrd below 4G for recent kernel

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/1547197071-14504-1-git-send-email-lizhij...@cn.fujitsu.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 1547197071-14504-1-git-send-email-lizhij...@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH v5 0/4] allow to load initrd below 4G for recent 
kernel

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback --color=always base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
 * [new tag] 
patchew/1547197071-14504-1-git-send-email-lizhij...@cn.fujitsu.com -> 
patchew/1547197071-14504-1-git-send-email-lizhij...@cn.fujitsu.com
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Switched to a new branch 'test'
a527fea i386: allow to load initrd below 4G for recent linux
7236341 i386: import & use bootparam.h
ae2981c hw/core/loader.c: Read as long as possible in load_image_size()
49e603a unify len and addr type for memory/address APIs

=== OUTPUT BEGIN ===
1/4 Checking commit 49e603a945f2 (unify len and addr type for memory/address 
APIs)
WARNING: line over 80 characters
#38: FILE: exec.c:2852:
+  MemTxAttrs attrs, uint8_t *buf, hwaddr 
len);

total: 0 errors, 1 warnings, 270 lines checked

Patch 1/4 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/4 Checking commit ae2981cbf961 (hw/core/loader.c: Read as long as possible in 
load_image_size())
3/4 Checking commit 7236341ea82b (i386: import & use bootparam.h)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#42: 
new file mode 100644

ERROR: line over 90 characters
#91: FILE: scripts/update-linux-headers.sh:125:
+sed -e '/__ASSEMBLY__/,/__ASSEMBLY__/d' 
$tmpdir/include/asm/bootparam.h > $tmpdir/bootparam.h

WARNING: line over 80 characters
#92: FILE: scripts/update-linux-headers.sh:126:
+cp_portable $tmpdir/bootparam.h 
"$output/include/standard-headers/asm-$arch"

total: 1 errors, 2 warnings, 64 lines checked

Patch 3/4 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

4/4 Checking commit a527fea2b274 (i386: allow to load initrd below 4G for 
recent linux)
ERROR: spaces required around that '+' (ctx:VxV)
#41: FILE: hw/i386/pc.c:1124:
+lduw_p(header+0x236) & XLF_CAN_BE_LOADED_ABOVE_4G) {
  ^

total: 1 errors, 0 warnings, 30 lines checked

Patch 4/4 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/1547197071-14504-1-git-send-email-lizhij...@cn.fujitsu.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[Qemu-devel] [PATCH] hw/misc/edu: add msi_uninit() for pci_edu_uninit()

2019-01-13 Thread Fei Li
From: Fei Li 

Let's supplement the msi_uninit() when failing to realize
the pci edu device.

Cc: Markus Armbruster 
Cc: Peter Xu 
Cc: Michael S. Tsirkin 
Cc: Marcel Apfelbaum 
Signed-off-by: Fei Li 
---
 hw/misc/edu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index cdcf550dd7..4feb7503de 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -367,6 +367,7 @@ static void pci_edu_uninit(PCIDevice *pdev)
 {
 EduState *edu = EDU(pdev);
 
+msi_uninit(pdev);
 qemu_mutex_lock(&edu->thr_mutex);
 edu->stopping = true;
 qemu_mutex_unlock(&edu->thr_mutex);
-- 
2.17.2 (Apple Git-113)




Re: [Qemu-devel] [PATCH v9 00/21] Fixing record/replay and adding reverse debugging

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/154703587757.13472.3898702635363120794.stgit@pasha-VirtualBox/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/154703587757.13472.3898702635363120794.stgit@pasha-VirtualBox/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH v2 0/3] optimize waiting for free thread to do compression

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190111063732.10484-1-xiaoguangr...@tencent.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20190111063732.10484-1-xiaoguangr...@tencent.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH] hw/ppc/spapr: Encode the SCSI channel (bus) in the SRP LUNs

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/1547042603-21147-1-git-send-email-th...@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/1547042603-21147-1-git-send-email-th...@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH v1 00/19] testing/next queue for travis and docker

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190110174516.21586-1-alex.ben...@linaro.org/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20190110174516.21586-1-alex.ben...@linaro.org/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH 0/4] Add ignore-external migration capability

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190110120120.9943-1-yury-ko...@yandex-team.ru/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20190110120120.9943-1-yury-ko...@yandex-team.ru/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH] contrib/gitdm: Fix a typo

2019-01-13 Thread Paolo Bonzini
On 11/01/19 23:39, Philippe Mathieu-Daudé wrote:
> On 1/11/19 10:28 PM, no-re...@patchew.org wrote:
>> Patchew URL: 
>> https://patchew.org/QEMU/201905.8270-1-phi...@redhat.com/
>>
>> Hi,
>>
>> This series seems to have some coding style problems. See output below for
>> more information:
>>
>> Message-id: 201905.8270-1-phi...@redhat.com
>> Type: series
>> Subject: [Qemu-devel] [PATCH] contrib/gitdm: Fix a typo
>>
>> === TEST SCRIPT BEGIN ===
>> #!/bin/bash
>> git config --local diff.renamelimit 0
>> git config --local diff.renames True
>> git config --local diff.algorithm histogram
>> ./scripts/checkpatch.pl --mailback --color=always base..
> I suppose Paolo expected his PR to land to upgrade patchew, and patchew
> is still processing from an old queue?
> 

Yeah, patchew was still processing tags that didn't have my PR applied.

Anyhow, I'll hijack this to note that now:

1) The test script for checkpatch is now much simple, compare
https://patchew.org/QEMU/20190103085638.17600-1-phi...@redhat.com/ (old)
to https://patchew.org/QEMU/20190109110144.18633-1-stefa...@redhat.com/
(new).  Improvement of "cut and paste" ability was a nice side effect of
the new TAP-based "make check", and this goes in the same direction.

2) Patchew is showing colored output---for now only for checkpatch. :)
More precisely, output is captured from a PTY, via script(1).  This
turned out to be a bit more tricky than I expected (script doesn't like
having its stdin redirected from /dev/null), but it's fixed now.

3) I bumped the tester from -j8 to -j14, hoping that the queue will be
smaller, and temporarily deployed a second tester on my own workstation.
 This in turn caused some issues because pulling a git repo with 12000
tags is not for the faint of heart, but everything should be running
normally now and future deployments will optimize this (check
https://patchew.org/Patchew/ to see the issues).

Paolo



Re: [Qemu-devel] [PATCH for-4.0 v9 09/16] qemu_thread: supplement error handling for pci_edu_realize

2019-01-13 Thread Fei Li



在 2019/1/8 上午1:29, Markus Armbruster 写道:

Fei Li  writes:


Utilize the existed errp to propagate the error instead of the
temporary &error_abort.

Cc: Markus Armbruster 
Cc: Jiri Slaby 
Signed-off-by: Fei Li 
---
  hw/misc/edu.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 3f4ba7ded3..011fe6e0b7 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -356,9 +356,10 @@ static void pci_edu_realize(PCIDevice *pdev, Error **errp)
  
  qemu_mutex_init(&edu->thr_mutex);

  qemu_cond_init(&edu->thr_cond);
-/* TODO: let the further caller handle the error instead of abort() here */
-qemu_thread_create(&edu->thread, "edu", edu_fact_thread,
-   edu, QEMU_THREAD_JOINABLE, &error_abort);
+if (!qemu_thread_create(&edu->thread, "edu", edu_fact_thread,
+edu, QEMU_THREAD_JOINABLE, errp)) {
+return;

You need to clean up everything that got initialized so far.  You might
want to call qemu_thread_create() earlier so you have less to clean up.


Just to make sure about how to do the cleanup. I notice that in 
device_set_realized(),
the current code does not call "dc->unrealize(dev, NULL);" when dc->realize() 
fails.

    if (dc->realize) {
    dc->realize(dev, &local_err);
    }

    if (local_err != NULL) {
    goto fail;
    }

Is this on purpose? (Maybe due to some devices' realize() do their own cleanup
when fails? Sorry for the unsure, it is such a common function that I did not
check all. :( ) Or else, I prefer to do the cleanup in a unified manner, e.g. call 
"dc->unrealize(dev, NULL);" which is the pci_qdev_unrealize() for pci devices.

Have a nice day
Fei




Re: [Qemu-devel] [PATCH for-4.0 v9 12/16] qemu_thread: supplement error handling for iothread_complete/qemu_signalfd_compat

2019-01-13 Thread Fei Li



在 2019/1/9 上午12:18, fei 写道:



在 2019年1月8日,01:50,Markus Armbruster  写道:

Fei Li  writes:


For iothread_complete: utilize the existed errp to propagate the
error and do the corresponding cleanup to replace the temporary
&error_abort.

For qemu_signalfd_compat: add a local_err to hold the error, and
return the corresponding error code to replace the temporary
&error_abort.

I'd split the patch.

Ok.

Cc: Markus Armbruster 
Cc: Eric Blake 
Signed-off-by: Fei Li 
---
iothread.c  | 17 +++--
util/compatfd.c | 11 ---
2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/iothread.c b/iothread.c
index 8e8aa01999..7335dacf0b 100644
--- a/iothread.c
+++ b/iothread.c
@@ -164,9 +164,7 @@ static void iothread_complete(UserCreatable *obj, Error 
**errp)
 &local_error);
 if (local_error) {
 error_propagate(errp, local_error);
-aio_context_unref(iothread->ctx);
-iothread->ctx = NULL;
-return;
+goto fail;
 }

 qemu_mutex_init(&iothread->init_done_lock);
@@ -178,9 +176,12 @@ static void iothread_complete(UserCreatable *obj, Error 
**errp)
  */
 name = object_get_canonical_path_component(OBJECT(obj));
 thread_name = g_strdup_printf("IO %s", name);
-/* TODO: let the further caller handle the error instead of abort() here */
-qemu_thread_create(&iothread->thread, thread_name, iothread_run,
-   iothread, QEMU_THREAD_JOINABLE, &error_abort);
+if (!qemu_thread_create(&iothread->thread, thread_name, iothread_run,
+iothread, QEMU_THREAD_JOINABLE, errp)) {
+g_free(thread_name);
+g_free(name);

I suspect you're missing cleanup here:

   qemu_cond_destroy(&iothread->init_done_cond);
   qemu_mutex_destroy(&iothread->init_done_lock);

I remember I checked the code, when ucc->complete() fails, there’s a finalize() 
function to do the destroy.


To be specific, the qemu_xxx_destroy() is called by

object_unref() => object_finalize() => object_deinit() => 
type->instance_finalize(obj); (that is, iothread_instance_finalize).


For the iothread_complete(), it is only called in 
user_creatable_complete() as ucc->complete().
I checked the code, when callers of user_creatable_complete() fails, all 
of them will call
object_unref() to call the qemu_xxx_destroy(), except one &error_abort 
case (e.i. desugar_shm()).

But did not test all the callers, so let’s wait for Stefan’s feedback. :)

But again, I did not do all the test. Correct me if I am wrong. :)

But I'm not 100% sure, to be honest.  Stefan, can you help?



+goto fail;
+}
 g_free(thread_name);
 g_free(name);


I'd avoid the code duplication like this:

   thread_ok = qemu_thread_create(&iothread->thread, thread_name,
  iothread_run, iothread,
  QEMU_THREAD_JOINABLE, errp);
   g_free(thread_name);
   g_free(name);
   if (!thread_ok) {
   qemu_cond_destroy(&iothread->init_done_cond);
   qemu_mutex_destroy(&iothread->init_done_lock);
   goto fail;
   }


Ok, thanks.

Have a nice day
Fei

Matter of taste.

Hmm, iothread.c has no maintainer.  Stefan, you created it, would you be
willing to serve as maintainer?






Re: [Qemu-devel] [PATCH] hw/misc/edu: add msi_uninit() for pci_edu_uninit()

2019-01-13 Thread Marcel Apfelbaum




On 1/13/19 4:36 PM, Fei Li wrote:

From: Fei Li 

Let's supplement the msi_uninit() when failing to realize
the pci edu device.

Cc: Markus Armbruster 
Cc: Peter Xu 
Cc: Michael S. Tsirkin 
Cc: Marcel Apfelbaum 
Signed-off-by: Fei Li 
---
  hw/misc/edu.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index cdcf550dd7..4feb7503de 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -367,6 +367,7 @@ static void pci_edu_uninit(PCIDevice *pdev)
  {
  EduState *edu = EDU(pdev);
  
+msi_uninit(pdev);

  qemu_mutex_lock(&edu->thr_mutex);
  edu->stopping = true;
  qemu_mutex_unlock(&edu->thr_mutex);


Reviewed-by: Marcel Apfelbaum

Thanks,
Marcel




Re: [Qemu-devel] [PATCH] ui: vnc: finish removing TABs

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20181217231629.24147-1-pbonz...@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20181217231629.24147-1-pbonz...@redhat.com
Subject: [Qemu-devel] [PATCH] ui: vnc: finish removing TABs

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
 * [new tag] patchew/20181217231629.24147-1-pbonz...@redhat.com -> 
patchew/20181217231629.24147-1-pbonz...@redhat.com
Switched to a new branch 'test'
21e3281 ui: vnc: finish removing TABs

=== OUTPUT BEGIN ===
ERROR: braces {} are necessary for all arms of this statement
#66: FILE: ui/vnc-enc-hextile-template.h:49:
+if (irow[i] == bg)
[...]
+else if (irow[i] == fg)
[...]

ERROR: braces {} are necessary for all arms of this statement
#68: FILE: ui/vnc-enc-hextile-template.h:51:
+else if (irow[i] == fg)
[...]

ERROR: braces {} are necessary for all arms of this statement
#76: FILE: ui/vnc-enc-hextile-template.h:59:
+if (n_colors > 2)
[...]

ERROR: braces {} are necessary for all arms of this statement
#146: FILE: ui/vnc-enc-hextile-template.h:95:
+if (min_x == -1)
[...]

ERROR: braces {} are necessary for all arms of this statement
#172: FILE: ui/vnc-enc-hextile-template.h:117:
+if (!*has_bg || *last_bg != bg)
[...]

ERROR: braces {} are necessary for all arms of this statement
#195: FILE: ui/vnc-enc-hextile-template.h:127:
+if (irow[i] == bg)
[...]

WARNING: Block comments use a leading /* on a separate line
#271: FILE: ui/vnc-enc-hextile-template.h:175:
+/* we really don't have to invalidate either the bg or fg

WARNING: Block comments use * on subsequent lines
#272: FILE: ui/vnc-enc-hextile-template.h:176:
+/* we really don't have to invalidate either the bg or fg
+   but we've lost the old values.  oh well. */

WARNING: Block comments use a trailing */ on a separate line
#272: FILE: ui/vnc-enc-hextile-template.h:176:
+   but we've lost the old values.  oh well. */

ERROR: braces {} are necessary for all arms of this statement
#301: FILE: ui/vnc-enc-hextile-template.h:192:
+if (flags & 0x02)
[...]

ERROR: braces {} are necessary for all arms of this statement
#303: FILE: ui/vnc-enc-hextile-template.h:194:
+if (flags & 0x04)
[...]

WARNING: Block comments use a trailing */ on a separate line
#339: FILE: ui/vnc-enc-zywrle.h:56:
+{0xFF00, 0x00FF, 0x00FF}, */

ERROR: "(foo*)" should be "(foo *)"
#630: FILE: ui/vnc-enc-zywrle.h:217:
+r = (((uint8_t*)src)[S_1]<< 1)& 0xF8;   \

ERROR: spaces required around that '<<' (ctx:VxW)
#630: FILE: ui/vnc-enc-zywrle.h:217:
+r = (((uint8_t*)src)[S_1]<< 1)& 0xF8;   \
  ^

ERROR: spaces required around that '&' (ctx:VxW)
#630: FILE: ui/vnc-enc-zywrle.h:217:
+r = (((uint8_t*)src)[S_1]<< 1)& 0xF8;   \
   ^

ERROR: "(foo*)" should be "(foo *)"
#631: FILE: ui/vnc-enc-zywrle.h:218:
+g = (((uint8_t*)src)[S_1]<< 6) | (((uint8_t*)src)[S_0]>> 2);\

ERROR: spaces required around that '<<' (ctx:VxW)
#631: FILE: ui/vnc-enc-zywrle.h:218:
+g = (((uint8_t*)src)[S_1]<< 6) | (((uint8_t*)src)[S_0]>> 2);\
  ^

ERROR: spaces required around that '>>' (ctx:VxW)
#631: FILE: ui/vnc-enc-zywrle.h:218:
+g = (((uint8_t*)src)[S_1]<< 6) | (((uint8_t*)src)[S_0]>> 2);\
   ^

ERROR: "(foo*)" should be "(foo *)"
#634: FILE: ui/vnc-enc-zywrle.h:220:
+b =  (((uint8_t*)src)[S_0]<< 3)& 0xF8;  \

ERROR: spaces required around that '<<' (ctx:VxW)
#634: FILE: ui/vnc-enc-zywrle.h:220:
+b =  (((uint8_t*)src)[S_0]<< 3)& 0xF8;  \
   ^

ERROR: spaces required around that '&' (ctx:VxW)
#634: FILE: ui/vnc-enc-zywrle.h:220:
+b =  (((uint8_t*)src)[S_0]<< 3)& 0xF8;  \
^

ERROR: "(foo*)" should be "(foo *)"
#647: FILE: ui/vnc-enc-zywrle.h:228:
+((uint8_t*)dst)[S_1] = (uint8_t)((r >> 1)|(g >> 6));\

ERROR: spaces required around that '|' (ctx:VxV)
#647: FILE: ui/vnc-enc-zywrle.h:228:
+((uint8_t*)dst)[S_1] = (uint8_t)((r >> 1)|(g >> 6));\
  ^

ERROR: "(foo*)" should be "(foo *)"
#648: FILE: ui/vnc-enc-zywrle.h:229:
+((uint8_t*)dst)[S_0] = (uint8_t)(((b >> 3)|(g << 2))& 0xFF);\

ERROR: spaces required 

Re: [Qemu-devel] [PATCH] qga: check length of command-line & environment variables

2019-01-13 Thread P J P
+-- On Fri, 11 Jan 2019, Daniel P. Berrangé wrote --+
| qga/commands.c already includes qemu/osdep.h which includs unistd.h.
|
| The build problem patchew reported was from *mingw* builds where
| sysconf does not exist.

I see; Not sure how to fix it. Maybe with conditional declaration?

#ifdef __MINGW[32|64]__
extern long int sysconf (int __name);
#endif

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F


Re: [Qemu-devel] [PATCH v2 0/3] optimize waiting for free thread to do compression

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190111063732.10484-1-xiaoguangr...@tencent.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14
=== TEST SCRIPT END ===

  CC  aarch64-softmmu/trace/generated-helpers.o
  CC  aarch64-softmmu/target/arm/translate-sve.o
/tmp/qemu-test/src/migration/ram.c: In function 
'compress_page_with_multi_thread':
/tmp/qemu-test/src/migration/ram.c:2064:26: error: comparison of constant '2' 
with boolean expression is always false [-Werror=bool-compare]
 adaptive = (adaptive == COMPRESS_WAIT_THREAD_ADAPTIVE);
  ^~
/tmp/qemu-test/src/migration/ram.c:2060:9: error: unused variable 
'compress_wait_thread' [-Werror=unused-variable]
 int compress_wait_thread = migrate_compress_wait_thread();
 ^~~~
/tmp/qemu-test/src/migration/ram.c:2063:10: error: 'adaptive' is used 
uninitialized in this function [-Werror=uninitialized]
 wait = (adaptive == COMPRESS_WAIT_THREAD_ON);
 ~^~~
cc1: all warnings being treated as errors
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: migration/ram.o] Error 1
make[1]: *** Waiting for unfinished jobs
/tmp/qemu-test/src/migration/ram.c: In function 
'compress_page_with_multi_thread':
/tmp/qemu-test/src/migration/ram.c:2064:26: error: comparison of constant '2' 
with boolean expression is always false [-Werror=bool-compare]
 adaptive = (adaptive == COMPRESS_WAIT_THREAD_ADAPTIVE);
  ^~
/tmp/qemu-test/src/migration/ram.c:2060:9: error: unused variable 
'compress_wait_thread' [-Werror=unused-variable]
 int compress_wait_thread = migrate_compress_wait_thread();
 ^~~~
/tmp/qemu-test/src/migration/ram.c:2063:10: error: 'adaptive' is used 
uninitialized in this function [-Werror=uninitialized]
 wait = (adaptive == COMPRESS_WAIT_THREAD_ON);
 ~^~~
cc1: all warnings being treated as errors


The full log is available at
http://patchew.org/logs/20190111063732.10484-1-xiaoguangr...@tencent.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH 0/5] vfio/display: add edid support.

2019-01-13 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190111093116.17188-1-kra...@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH 0/5] vfio/display: add edid support.
Type: series
Message-id: 20190111093116.17188-1-kra...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]  patchew/20190113143641.38936-1-lifei1...@126.com -> 
patchew/20190113143641.38936-1-lifei1...@126.com
Switched to a new branch 'test'
d3b83e9 some logging
46b3123 vfio/display: delay link up event
6ae7726 vfio/display: add xres + yres properties
d8234fb vfio/display: add edid support.
45e1bc1 vfio: update kernel headers.

=== OUTPUT BEGIN ===
1/5 Checking commit 45e1bc16552c (vfio: update kernel headers.)
2/5 Checking commit d8234fb5723c (vfio/display: add edid support.)
ERROR: line over 90 characters
#44: FILE: hw/vfio/display.c:40:
+static void vfio_display_edid_update(VFIOPCIDevice *vdev, bool enabled, int 
prefx, int prefy)

WARNING: line over 80 characters
#122: FILE: hw/vfio/display.c:118:
+pread_field(vdev->vbasedev.fd, dpy->edid_info, dpy->edid_regs, 
edid_max_size);

ERROR: braces {} are necessary for all arms of this statement
#139: FILE: hw/vfio/display.c:135:
+if (!dpy->edid_regs)
[...]

total: 2 errors, 1 warnings, 156 lines checked

Patch 2/5 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

3/5 Checking commit 6ae77261d5f3 (vfio/display: add xres + yres properties)
ERROR: braces {} are necessary for all arms of this statement
#34: FILE: hw/vfio/display.c:124:
+if (!vdev->display_xres)
[...]

ERROR: braces {} are necessary for all arms of this statement
#36: FILE: hw/vfio/display.c:126:
+if (!vdev->display_yres)
[...]

total: 2 errors, 0 warnings, 38 lines checked

Patch 3/5 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

4/5 Checking commit 46b312391ae4 (vfio/display: delay link up event)
WARNING: line over 80 characters
#51: FILE: hw/vfio/display.c:89:
+timer_mod(dpy->edid_link_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 
100);

total: 0 errors, 1 warnings, 59 lines checked

Patch 4/5 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/5 Checking commit d3b83e9d78a1 (some logging)
ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 46 lines checked

Patch 5/5 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20190111093116.17188-1-kra...@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function

2019-01-13 Thread P J P
From: Prasad J Pandit 

While emulating identification protocol, tcp_emu() does not check
available space in the 'sc_rcv->sb_data' buffer. It could lead to
heap buffer overflow issue. Add check to avoid it.

Reported-by: Kira <864786...@qq.com>
Signed-off-by: Prasad J Pandit 
---
 slirp/tcp_subr.c | 4 
 1 file changed, 4 insertions(+)

Update v2: return 1 instead of 0
  -> https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg02182.html

diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index fa61349cbb..8b1bd8c8c0 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -635,6 +635,10 @@ tcp_emu(struct socket *so, struct mbuf *m)
socklen_t addrlen = sizeof(struct sockaddr_in);
struct sbuf *so_rcv = &so->so_rcv;
 
+if (m->m_len > so_rcv->sb_datalen
+- (so_rcv->sb_wptr - so_rcv->sb_data)) {
+return 1;
+}
memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
so_rcv->sb_wptr += m->m_len;
so_rcv->sb_rptr += m->m_len;
-- 
2.20.1




Re: [Qemu-devel] [PATCH] slirp: check data length while emulating ident function

2019-01-13 Thread P J P
+-- On Fri, 11 Jan 2019, Marc-André Lureau wrote --+
| > | Check looks correct, it should probably return 1.
| >
| > Function comment says return 1 if 'm' is valid and should be appended via
| > sbappend(). Not sure if unprocessed 'm' should go to sbappend().
| 
| If you look at the rest of the function, many similar error cases return 1.

True, not sure if that's right in this case. Nonetheless, I have sent a 
revised patch to return 1.
 
| Ok, could you add it to the commit message ? :)

No, I'm afraid not.

Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F


Re: [Qemu-devel] [PATCH v2 09/12] tests/tcg/mips: Test R5900 three-operand MADDU1

2019-01-13 Thread Fredrik Noring
Hi Aleksandar,

> - Suggestion: The next MIPS pull request is scehuled for Friday,
> Jan 18, 2018. It would be fantastic if you could prepare the
> following by Jan 14:
> 
>   * Add 32 TCGv_i64 registers that would represent higher halves
>   of R5900 general purpose registers.

Done!

>   * Add TCGv_i32 register SA (shift amount).

See notes below.

>   * Perhaps consider adding higher halves of registers HI an LO
>   independently on HI/LO array used by DSP.

For HI1 and LO1 only? I'm asking since HI0 and LO0 are implemented with
the DSP array anyway, for all ISAs.

>   * It is customary to implement R/W access while introducing
>   such registers:
> * Implement R/W access instructions to higher halves of
> R5900 GPRs:
>   * LQ

Done, including PCPYUD and PCPYLD for proper testing!

>   * SQ

Done, including testing!

> * Implement R/W access instructions to SA register:
>   * MFSA

The TX79 manual says that "the sole purpose of this instruction is to
permit the shift amount to be saved during a context switch" and that
"the shift amount is encoded in SA in an implementation-defined manner"
so it seems to make more sense for system mode rather than user mode?

One may want to choose an implementation that matches the actual R5900
hardware, even though the manual says it's arbitrary.

>   * MTSA

Likewise.

>   * MTSAH
>   * MTSAB

These instructions do not appear to be usable unless the corresponding
shift instructions are implemented as well?

I will post an R5900 multimedia instruction patch series shortly.

Fredrik



[Qemu-devel] [PATCH 0/9] target/mips: Limited support for R5900 multimedia instructions

2019-01-13 Thread Fredrik Noring
This series introduces limited support for R5900 multimedia instructions
(MMIs) by implementing and testing PCPYLD, PCPYUD, LQ and SQ.

32 128-bit multimedia registers (MMRs) are introduced. They are split into
two 64-bit halves: the lower halves are the GPRs and the upper halves are
accessible by the R5900-specific multimedia instructions.

The MMIs are only available with TARGET_MIPS64 since 64-bit GPRs are
required.

The relation between SQ and RDHWR may need to be revisited. I'm hoping to
discuss the details with Maciej.

This series has been successfully built with the 10 different build
configurations

{gcc,clang} x -m64 x mips{,64}el-{linux-user,softmmu}
{gcc,clang} x -m64 x mipsn32el-linux-user

in addition successfully completing the R5900 test suite

cd tests/tcg/mips/mipsr5900 && make check
cd tests/tcg/mips/mipsn32r5900 && make check

Fredrik Noring (9):
  target/mips: Require TARGET_MIPS64 for R5900 multimedia instructions
  target/mips: Introduce 32 R5900 128-bit multimedia registers
  target/mips: Support the R5900 PCPYLD multimedia instruction
  target/mips: Support the R5900 PCPYUD multimedia instruction
  target/mips: Support the R5900 LQ multimedia instruction
  target/mips: Support the R5900 SQ multimedia instruction
  tests/tcg/mips: Test R5900 multimedia instructions PCPYUD and PCPYLD
  tests/tcg/mips: Test R5900 multimedia instruction LQ
  tests/tcg/mips: Test R5900 multimedia instruction SQ

 target/mips/cpu.h |   2 +
 target/mips/translate.c   | 180 +++---
 tests/tcg/mips/mipsn32r5900/Makefile  |  27 
 tests/tcg/mips/mipsn32r5900/lq.c  | 111 
 tests/tcg/mips/mipsn32r5900/pcpyuld.c |  46 +++
 tests/tcg/mips/mipsn32r5900/sq.c  | 105 +++
 6 files changed, 452 insertions(+), 19 deletions(-)
 create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile
 create mode 100644 tests/tcg/mips/mipsn32r5900/lq.c
 create mode 100644 tests/tcg/mips/mipsn32r5900/pcpyuld.c
 create mode 100644 tests/tcg/mips/mipsn32r5900/sq.c

-- 
2.19.2




[Qemu-devel] [PATCH 1/9] target/mips: Require TARGET_MIPS64 for R5900 multimedia instructions

2019-01-13 Thread Fredrik Noring
The R5900 MMIs operate on 128-bit registers that will be split into
two halves: lower 64-bit GPRs and upper 64-bit MMRs. The MMIs will
therefore be left unimplemented in 32-bit mode with the o32 ABI.

Signed-off-by: Fredrik Noring 
---
 target/mips/translate.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 057aaf9a44..a538351032 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -27218,6 +27218,7 @@ static void decode_opc_special3_legacy(CPUMIPSState 
*env, DisasContext *ctx)
 }
 }
 
+#if defined(TARGET_MIPS64)
 static void decode_mmi0(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI0(ctx->opcode);
@@ -27351,6 +27352,7 @@ static void decode_mmi3(CPUMIPSState *env, DisasContext 
*ctx)
 break;
 }
 }
+#endif /* defined(TARGET_MIPS64) */
 
 static void decode_mmi(CPUMIPSState *env, DisasContext *ctx)
 {
@@ -27360,18 +27362,6 @@ static void decode_mmi(CPUMIPSState *env, DisasContext 
*ctx)
 int rd = extract32(ctx->opcode, 11, 5);
 
 switch (opc) {
-case MMI_OPC_CLASS_MMI0:
-decode_mmi0(env, ctx);
-break;
-case MMI_OPC_CLASS_MMI1:
-decode_mmi1(env, ctx);
-break;
-case MMI_OPC_CLASS_MMI2:
-decode_mmi2(env, ctx);
-break;
-case MMI_OPC_CLASS_MMI3:
-decode_mmi3(env, ctx);
-break;
 case MMI_OPC_MULT1:
 case MMI_OPC_MULTU1:
 case MMI_OPC_MADD:
@@ -27392,6 +27382,7 @@ static void decode_mmi(CPUMIPSState *env, DisasContext 
*ctx)
 case MMI_OPC_MFHI1:
 gen_HILO1_tx79(ctx, opc, rd);
 break;
+#if defined(TARGET_MIPS64)
 case MMI_OPC_PLZCW: /* TODO: MMI_OPC_PLZCW */
 case MMI_OPC_PMFHL: /* TODO: MMI_OPC_PMFHL */
 case MMI_OPC_PMTHL: /* TODO: MMI_OPC_PMTHL */
@@ -27403,6 +27394,19 @@ static void decode_mmi(CPUMIPSState *env, DisasContext 
*ctx)
 case MMI_OPC_PSRAW: /* TODO: MMI_OPC_PSRAW */
 generate_exception_end(ctx, EXCP_RI);/* TODO: MMI_OPC_CLASS_MMI */
 break;
+case MMI_OPC_CLASS_MMI0:
+decode_mmi0(env, ctx);
+break;
+case MMI_OPC_CLASS_MMI1:
+decode_mmi1(env, ctx);
+break;
+case MMI_OPC_CLASS_MMI2:
+decode_mmi2(env, ctx);
+break;
+case MMI_OPC_CLASS_MMI3:
+decode_mmi3(env, ctx);
+break;
+#endif
 default:
 MIPS_INVAL("TX79 MMI class");
 generate_exception_end(ctx, EXCP_RI);
-- 
2.19.2




[Qemu-devel] [PATCH 2/9] target/mips: Introduce 32 R5900 128-bit multimedia registers

2019-01-13 Thread Fredrik Noring
The 32 R5900 128-bit MMRs are split into two 64-bit halves: the lower
halves are the GPRs and the upper halves are accessible by the R5900-
specific multimedia instructions.

Signed-off-by: Fredrik Noring 
---
 target/mips/cpu.h   |  2 ++
 target/mips/translate.c | 14 --
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 03c03fd8c6..9ff4a68d90 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -180,6 +180,8 @@ struct TCState {
 #define MXU_CR_RD_EN1
 #define MXU_CR_MXU_EN   0
 
+/* Upper 64-bit MMRs (multimedia registers); the lower 64-bit are GPRs */
+uint64_t mmr[32];
 };
 
 typedef struct CPUMIPSState CPUMIPSState;
diff --git a/target/mips/translate.c b/target/mips/translate.c
index a538351032..9d5150ec8b 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -2455,7 +2455,10 @@ static TCGv_i32 fpu_fcr0, fpu_fcr31;
 static TCGv_i64 fpu_f64[32];
 static TCGv_i64 msa_wr_d[64];
 
-#if !defined(TARGET_MIPS64)
+#if defined(TARGET_MIPS64)
+/* Upper 64-bit MMRs (multimedia registers); the lower 64-bit are GPRs */
+static TCGv_i64 cpu_mmr[32];
+#else
 /* MXU registers */
 static TCGv mxu_gpr[NUMBER_OF_MXU_REGISTERS - 1];
 static TCGv mxu_CR;
@@ -29785,7 +29788,14 @@ void mips_tcg_init(void)
 fpu_fcr31 = tcg_global_mem_new_i32(cpu_env,
offsetof(CPUMIPSState, 
active_fpu.fcr31),
"fcr31");
-#if !defined(TARGET_MIPS64)
+#if defined(TARGET_MIPS64)
+cpu_mmr[0] = NULL;
+for (i = 1; i < 32; i++)
+cpu_mmr[i] = tcg_global_mem_new_i64(cpu_env,
+offsetof(CPUMIPSState,
+ active_tc.mmr[i]),
+regnames[i]);
+#else
 for (i = 0; i < NUMBER_OF_MXU_REGISTERS - 1; i++) {
 mxu_gpr[i] = tcg_global_mem_new(cpu_env,
 offsetof(CPUMIPSState,
-- 
2.19.2




[Qemu-devel] [PATCH 3/9] target/mips: Support the R5900 PCPYLD multimedia instruction

2019-01-13 Thread Fredrik Noring
Signed-off-by: Fredrik Noring 
---
 target/mips/translate.c | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 9d5150ec8b..40faf9cb36 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -27293,11 +27293,34 @@ static void decode_mmi1(CPUMIPSState *env, 
DisasContext *ctx)
 }
 }
 
+static void gen_mmi_pcpyld(DisasContext *ctx, int rd, int rs, int rt)
+{
+if (rd != 0) {
+if (rs != 0) {
+tcg_gen_mov_i64(cpu_mmr[rd], cpu_gpr[rs]);
+} else {
+tcg_gen_movi_i64(cpu_mmr[rd], 0);
+}
+
+if (rt != 0) {
+tcg_gen_mov_i64(cpu_gpr[rd], cpu_gpr[rt]);
+} else {
+tcg_gen_movi_i64(cpu_gpr[rd], 0);
+}
+}
+}
+
 static void decode_mmi2(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI2(ctx->opcode);
+int rs = extract32(ctx->opcode, 21, 5);
+int rt = extract32(ctx->opcode, 16, 5);
+int rd = extract32(ctx->opcode, 11, 5);
 
 switch (opc) {
+case MMI_OPC_2_PCPYLD:
+gen_mmi_pcpyld(ctx, rd, rs, rt);
+break;
 case MMI_OPC_2_PMADDW:/* TODO: MMI_OPC_2_PMADDW */
 case MMI_OPC_2_PSLLVW:/* TODO: MMI_OPC_2_PSLLVW */
 case MMI_OPC_2_PSRLVW:/* TODO: MMI_OPC_2_PSRLVW */
@@ -27307,7 +27330,6 @@ static void decode_mmi2(CPUMIPSState *env, DisasContext 
*ctx)
 case MMI_OPC_2_PINTH: /* TODO: MMI_OPC_2_PINTH */
 case MMI_OPC_2_PMULTW:/* TODO: MMI_OPC_2_PMULTW */
 case MMI_OPC_2_PDIVW: /* TODO: MMI_OPC_2_PDIVW */
-case MMI_OPC_2_PCPYLD:/* TODO: MMI_OPC_2_PCPYLD */
 case MMI_OPC_2_PMADDH:/* TODO: MMI_OPC_2_PMADDH */
 case MMI_OPC_2_PHMADH:/* TODO: MMI_OPC_2_PHMADH */
 case MMI_OPC_2_PAND:  /* TODO: MMI_OPC_2_PAND */
-- 
2.19.2




[Qemu-devel] [PATCH 6/9] target/mips: Support the R5900 SQ multimedia instruction

2019-01-13 Thread Fredrik Noring
Signed-off-by: Fredrik Noring 
---
 target/mips/translate.c | 44 +++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 79505bb6c2..1c7c649d36 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -2628,6 +2628,17 @@ static inline void gen_store_gpr (TCGv t, int reg)
 
 #if defined(TARGET_MIPS64)
 /* 128-bit multimedia register moves. */
+static inline void gen_load_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg)
+{
+if (reg == 0) {
+tcg_gen_movi_i64(hi, 0);
+tcg_gen_movi_i64(lo, 0);
+} else {
+tcg_gen_mov_i64(hi, cpu_mmr[reg]);
+tcg_gen_mov_i64(lo, cpu_gpr[reg]);
+}
+}
+
 static inline void gen_store_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg)
 {
 if (reg != 0) {
@@ -27512,7 +27523,36 @@ static void gen_mmi_lq(CPUMIPSState *env, DisasContext 
*ctx)
 
 static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset)
 {
-generate_exception_end(ctx, EXCP_RI);/* TODO: MMI_OPC_SQ */
+#if !defined(TARGET_MIPS64)
+generate_exception_end(ctx, EXCP_RI);
+#else
+TCGv_i64 addr = tcg_temp_new_i64();
+TCGv_i64 val0 = tcg_temp_new_i64();
+TCGv_i64 val1 = tcg_temp_new_i64();
+
+gen_base_offset_addr(ctx, addr, base, offset);
+
+/*
+ * The least significant four bits of the effective address are
+ * masked to zero, effectively creating an aligned address. No
+ * address exceptions due to alignment are possible.
+ */
+tcg_gen_andi_i64(addr, addr, ~0xFULL);
+
+#if defined(TARGET_WORDS_BIGENDIAN)
+gen_load_mmr(val0, val1, rt);
+#else
+gen_load_mmr(val1, val0, rt);
+#endif
+
+tcg_gen_qemu_st_i64(val0, addr, ctx->mem_idx, MO_UNALN | MO_64);
+tcg_gen_addi_i64(addr, addr, 8);
+tcg_gen_qemu_st_i64(val1, addr, ctx->mem_idx, MO_UNALN | MO_64);
+
+tcg_temp_free_i64(val1);
+tcg_temp_free_i64(val0);
+tcg_temp_free_i64(addr);
+#endif /* defined(TARGET_MIPS64) */
 }
 
 /*
@@ -27540,7 +27580,7 @@ static void decode_mmi_sq(CPUMIPSState *env, 
DisasContext *ctx)
 {
 int base = extract32(ctx->opcode, 21, 5);
 int rt = extract32(ctx->opcode, 16, 5);
-int offset = extract32(ctx->opcode, 0, 16);
+int offset = sextract32(ctx->opcode, 0, 16);
 
 #ifdef CONFIG_USER_ONLY
 uint32_t op1 = MASK_SPECIAL3(ctx->opcode);
-- 
2.19.2




[Qemu-devel] [PATCH 4/9] target/mips: Support the R5900 PCPYUD multimedia instruction

2019-01-13 Thread Fredrik Noring
Signed-off-by: Fredrik Noring 
---
 target/mips/translate.c | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 40faf9cb36..8c350729bc 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -27351,11 +27351,34 @@ static void decode_mmi2(CPUMIPSState *env, 
DisasContext *ctx)
 }
 }
 
+static void gen_mmi_pcpyud(DisasContext *ctx, int rd, int rs, int rt)
+{
+if (rd != 0) {
+if (rs != 0) {
+tcg_gen_mov_i64(cpu_gpr[rd], cpu_mmr[rs]);
+} else {
+tcg_gen_movi_i64(cpu_gpr[rd], 0);
+}
+
+if (rt != 0) {
+tcg_gen_mov_i64(cpu_mmr[rd], cpu_mmr[rt]);
+} else {
+tcg_gen_movi_i64(cpu_mmr[rd], 0);
+}
+}
+}
+
 static void decode_mmi3(CPUMIPSState *env, DisasContext *ctx)
 {
 uint32_t opc = MASK_MMI3(ctx->opcode);
+int rs = extract32(ctx->opcode, 21, 5);
+int rt = extract32(ctx->opcode, 16, 5);
+int rd = extract32(ctx->opcode, 11, 5);
 
 switch (opc) {
+case MMI_OPC_3_PCPYUD:
+gen_mmi_pcpyud(ctx, rd, rs, rt);
+break;
 case MMI_OPC_3_PMADDUW:/* TODO: MMI_OPC_3_PMADDUW */
 case MMI_OPC_3_PSRAVW: /* TODO: MMI_OPC_3_PSRAVW */
 case MMI_OPC_3_PMTHI:  /* TODO: MMI_OPC_3_PMTHI */
@@ -27363,7 +27386,6 @@ static void decode_mmi3(CPUMIPSState *env, DisasContext 
*ctx)
 case MMI_OPC_3_PINTEH: /* TODO: MMI_OPC_3_PINTEH */
 case MMI_OPC_3_PMULTUW:/* TODO: MMI_OPC_3_PMULTUW */
 case MMI_OPC_3_PDIVUW: /* TODO: MMI_OPC_3_PDIVUW */
-case MMI_OPC_3_PCPYUD: /* TODO: MMI_OPC_3_PCPYUD */
 case MMI_OPC_3_POR:/* TODO: MMI_OPC_3_POR */
 case MMI_OPC_3_PNOR:   /* TODO: MMI_OPC_3_PNOR */
 case MMI_OPC_3_PEXCH:  /* TODO: MMI_OPC_3_PEXCH */
-- 
2.19.2




[Qemu-devel] [PATCH 5/9] target/mips: Support the R5900 LQ multimedia instruction

2019-01-13 Thread Fredrik Noring
Signed-off-by: Fredrik Noring 
---
 target/mips/translate.c | 46 -
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/target/mips/translate.c b/target/mips/translate.c
index 8c350729bc..79505bb6c2 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -2626,6 +2626,17 @@ static inline void gen_store_gpr (TCGv t, int reg)
 tcg_gen_mov_tl(cpu_gpr[reg], t);
 }
 
+#if defined(TARGET_MIPS64)
+/* 128-bit multimedia register moves. */
+static inline void gen_store_mmr(TCGv_i64 hi, TCGv_i64 lo, int reg)
+{
+if (reg != 0) {
+tcg_gen_mov_i64(cpu_mmr[reg], hi);
+tcg_gen_mov_i64(cpu_gpr[reg], lo);
+}
+}
+#endif /* defined(TARGET_MIPS64) */
+
 /* Moves to/from shadow registers. */
 static inline void gen_load_srsgpr (int from, int to)
 {
@@ -27463,7 +27474,40 @@ static void decode_mmi(CPUMIPSState *env, DisasContext 
*ctx)
 
 static void gen_mmi_lq(CPUMIPSState *env, DisasContext *ctx)
 {
-generate_exception_end(ctx, EXCP_RI);/* TODO: MMI_OPC_LQ */
+#if !defined(TARGET_MIPS64)
+generate_exception_end(ctx, EXCP_RI);
+#else
+int base = extract32(ctx->opcode, 21, 5);
+int rt = extract32(ctx->opcode, 16, 5);
+int offset = sextract32(ctx->opcode, 0, 16);
+
+TCGv_i64 addr = tcg_temp_new_i64();
+TCGv_i64 val0 = tcg_temp_new_i64();
+TCGv_i64 val1 = tcg_temp_new_i64();
+
+gen_base_offset_addr(ctx, addr, base, offset);
+
+/*
+ * The least significant four bits of the effective address are
+ * masked to zero, effectively creating an aligned address. No
+ * address exceptions due to alignment are possible.
+ */
+tcg_gen_andi_i64(addr, addr, ~0xFULL);
+
+tcg_gen_qemu_ld_i64(val0, addr, ctx->mem_idx, MO_UNALN | MO_64);
+tcg_gen_addi_i64(addr, addr, 8);
+tcg_gen_qemu_ld_i64(val1, addr, ctx->mem_idx, MO_UNALN | MO_64);
+
+#if defined(TARGET_WORDS_BIGENDIAN)
+gen_store_mmr(val0, val1, rt);
+#else
+gen_store_mmr(val1, val0, rt);
+#endif
+
+tcg_temp_free_i64(val1);
+tcg_temp_free_i64(val0);
+tcg_temp_free_i64(addr);
+#endif /* defined(TARGET_MIPS64) */
 }
 
 static void gen_mmi_sq(DisasContext *ctx, int base, int rt, int offset)
-- 
2.19.2




Re: [Qemu-devel] [PATCH v2 0/9] Build ACPI Heterogeneous Memory Attribute Table (HMAT)

2019-01-13 Thread no-reply
Patchew URL: https://patchew.org/QEMU/2019053451.14304-1-tao3...@intel.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14
=== TEST SCRIPT END ===

  LINKaarch64-softmmu/qemu-system-aarch64w.exe
numa.o:numa.c:(.rdata$.refptr.hmat_cache_info[.refptr.hmat_cache_info]+0x0): 
undefined reference to `hmat_cache_info'
numa.o:numa.c:(.rdata$.refptr.hmat_lb_info[.refptr.hmat_lb_info]+0x0): 
undefined reference to `hmat_lb_info'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:196: qemu-system-aarch64w.exe] Error 1
make: *** [Makefile:428: subdir-aarch64-softmmu] Error 2
Traceback (most recent call last):


The full log is available at
http://patchew.org/logs/2019053451.14304-1-tao3...@intel.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[Qemu-devel] [PATCH 9/9] tests/tcg/mips: Test R5900 multimedia instruction SQ

2019-01-13 Thread Fredrik Noring
Signed-off-by: Fredrik Noring 
---
 tests/tcg/mips/mipsn32r5900/Makefile |   1 +
 tests/tcg/mips/mipsn32r5900/sq.c | 105 +++
 2 files changed, 106 insertions(+)
 create mode 100644 tests/tcg/mips/mipsn32r5900/sq.c

diff --git a/tests/tcg/mips/mipsn32r5900/Makefile 
b/tests/tcg/mips/mipsn32r5900/Makefile
index cb3ef9d26a..a9e9481457 100644
--- a/tests/tcg/mips/mipsn32r5900/Makefile
+++ b/tests/tcg/mips/mipsn32r5900/Makefile
@@ -10,6 +10,7 @@ CFLAGS  = -Wall -mabi=n32 -march=r5900 -static
 
 TESTCASES = lq.tst
 TESTCASES += pcpyuld.tst
+TESTCASES += sq.tst
 
 all: $(TESTCASES)
 
diff --git a/tests/tcg/mips/mipsn32r5900/sq.c b/tests/tcg/mips/mipsn32r5900/sq.c
new file mode 100644
index 00..97b21711ba
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/sq.c
@@ -0,0 +1,105 @@
+/*
+ * Test SQ.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#define GUARD_BYTE 0xA9
+
+/* 128-bit multimedia register */
+struct mmr { uint64_t hi, lo; } __attribute__((aligned(16)));
+
+static uint8_t data[64];
+
+#define SQ(value, base, offset) \
+__asm__ __volatile__ ( \
+"pcpyld  %0, %0, %1\n" \
+"sq %0, %3(%2)\n" \
+: \
+: "r" (value.hi), "r" (value.lo), \
+  "r" (base), "i" (offset))
+
+static void verify_sq(struct mmr value, const void *base, int16_t offset)
+{
+/*
+ * The least significant four bits of the effective address are
+ * masked to zero, effectively creating an aligned address. No
+ * address exceptions due to alignment are possible.
+ */
+const uint8_t *b = base;
+const uint8_t *o = &b[offset];
+const uint8_t *a = (const uint8_t*)((unsigned long)o & ~0xFUL);
+size_t i;
+
+for (i = 0; i < sizeof(data); i++) {
+ssize_t d = &data[i] - &a[0];
+
+if (d < 0) {
+assert(data[i] == GUARD_BYTE);
+} else if (d < 8) {
+assert(data[i] == ((value.lo >> (8 * (d - 0))) & 0xFF));
+} else if (d < 16) {
+assert(data[i] == ((value.hi >> (8 * (d - 8))) & 0xFF));
+} else {
+assert(data[i] == GUARD_BYTE);
+}
+}
+}
+
+#define VERIFY_SQ(base, offset) \
+do { \
+struct mmr value = { \
+.hi = 0x6665646362613938, \
+.lo = 0x3736353433323130 \
+}; \
+\
+memset(data, GUARD_BYTE, sizeof(data)); \
+SQ(value, base, offset); \
+verify_sq(value, base, offset); \
+} while (0)
+
+int main()
+{
+int i;
+
+for (i = 16; i < 48; i++) {
+VERIFY_SQ(&data[i], -16);
+VERIFY_SQ(&data[i], -15);
+VERIFY_SQ(&data[i], -14);
+VERIFY_SQ(&data[i], -13);
+VERIFY_SQ(&data[i], -12);
+VERIFY_SQ(&data[i], -11);
+VERIFY_SQ(&data[i], -10);
+VERIFY_SQ(&data[i], -9);
+VERIFY_SQ(&data[i], -8);
+VERIFY_SQ(&data[i], -7);
+VERIFY_SQ(&data[i], -6);
+VERIFY_SQ(&data[i], -5);
+VERIFY_SQ(&data[i], -4);
+VERIFY_SQ(&data[i], -3);
+VERIFY_SQ(&data[i], -2);
+VERIFY_SQ(&data[i], -1);
+VERIFY_SQ(&data[i],  0);
+VERIFY_SQ(&data[i],  1);
+VERIFY_SQ(&data[i],  2);
+VERIFY_SQ(&data[i],  3);
+VERIFY_SQ(&data[i],  4);
+VERIFY_SQ(&data[i],  5);
+VERIFY_SQ(&data[i],  6);
+VERIFY_SQ(&data[i],  7);
+VERIFY_SQ(&data[i],  8);
+VERIFY_SQ(&data[i],  9);
+VERIFY_SQ(&data[i],  10);
+VERIFY_SQ(&data[i],  11);
+VERIFY_SQ(&data[i],  12);
+VERIFY_SQ(&data[i],  13);
+VERIFY_SQ(&data[i],  14);
+VERIFY_SQ(&data[i],  15);
+VERIFY_SQ(&data[i],  16);
+}
+
+return 0;
+}
-- 
2.19.2




[Qemu-devel] [PATCH 7/9] tests/tcg/mips: Test R5900 multimedia instructions PCPYUD and PCPYLD

2019-01-13 Thread Fredrik Noring
Signed-off-by: Fredrik Noring 
---
 tests/tcg/mips/mipsn32r5900/Makefile  | 25 +++
 tests/tcg/mips/mipsn32r5900/pcpyuld.c | 46 +++
 2 files changed, 71 insertions(+)
 create mode 100644 tests/tcg/mips/mipsn32r5900/Makefile
 create mode 100644 tests/tcg/mips/mipsn32r5900/pcpyuld.c

diff --git a/tests/tcg/mips/mipsn32r5900/Makefile 
b/tests/tcg/mips/mipsn32r5900/Makefile
new file mode 100644
index 00..f4887678ae
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/Makefile
@@ -0,0 +1,25 @@
+-include ../../config-host.mak
+
+CROSS=mips64r5900el-unknown-linux-gnu-
+
+SIM=qemu-mipsn32el
+SIM_FLAGS=-cpu R5900
+
+CC  = $(CROSS)gcc
+CFLAGS  = -Wall -mabi=n32 -march=r5900 -static
+
+TESTCASES = pcpyuld.tst
+
+all: $(TESTCASES)
+
+%.tst: %.c
+   $(CC) $(CFLAGS) $< -o $@
+
+check: $(TESTCASES)
+   @for case in $(TESTCASES); do \
+echo $(SIM) $(SIM_FLAGS) ./$$case;\
+$(SIM) $(SIM_FLAGS) ./$$case; \
+   done
+
+clean:
+   $(RM) -rf $(TESTCASES)
diff --git a/tests/tcg/mips/mipsn32r5900/pcpyuld.c 
b/tests/tcg/mips/mipsn32r5900/pcpyuld.c
new file mode 100644
index 00..c92af6330b
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/pcpyuld.c
@@ -0,0 +1,46 @@
+/*
+ * Test PCPYUD and PCPYLD.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/* 128-bit multimedia register */
+struct mmr { uint64_t hi, lo; } __attribute__((aligned(16)));
+
+static void verify_zero(void)
+{
+__asm__ __volatile__ (
+"pcpyud  $0, $0, $0\n"
+"pcpyld  $0, $0, $0\n"
+);
+}
+
+static void verify_copy(void)
+{
+const struct mmr value = {
+.hi = 0x6665646362613938,
+.lo = 0x3736353433323130
+};
+struct mmr result = { };
+
+__asm__ __volatile__ (
+"pcpyld  %0, %2, %3\n"
+"move%1, %0\n"
+"pcpyud  %0, %0, %0\n"
+: "=r" (result.hi), "=r" (result.lo)
+: "r" (value.hi), "r" (value.lo));
+
+assert(value.hi == result.hi);
+assert(value.lo == result.lo);
+}
+
+int main()
+{
+verify_zero();
+verify_copy();
+
+return 0;
+}
-- 
2.19.2




[Qemu-devel] [PATCH 8/9] tests/tcg/mips: Test R5900 multimedia instruction LQ

2019-01-13 Thread Fredrik Noring
Signed-off-by: Fredrik Noring 
---
 tests/tcg/mips/mipsn32r5900/Makefile |   3 +-
 tests/tcg/mips/mipsn32r5900/lq.c | 111 +++
 2 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100644 tests/tcg/mips/mipsn32r5900/lq.c

diff --git a/tests/tcg/mips/mipsn32r5900/Makefile 
b/tests/tcg/mips/mipsn32r5900/Makefile
index f4887678ae..cb3ef9d26a 100644
--- a/tests/tcg/mips/mipsn32r5900/Makefile
+++ b/tests/tcg/mips/mipsn32r5900/Makefile
@@ -8,7 +8,8 @@ SIM_FLAGS=-cpu R5900
 CC  = $(CROSS)gcc
 CFLAGS  = -Wall -mabi=n32 -march=r5900 -static
 
-TESTCASES = pcpyuld.tst
+TESTCASES = lq.tst
+TESTCASES += pcpyuld.tst
 
 all: $(TESTCASES)
 
diff --git a/tests/tcg/mips/mipsn32r5900/lq.c b/tests/tcg/mips/mipsn32r5900/lq.c
new file mode 100644
index 00..5a16b12450
--- /dev/null
+++ b/tests/tcg/mips/mipsn32r5900/lq.c
@@ -0,0 +1,111 @@
+/*
+ * Test LQ.
+ */
+
+#include 
+#include 
+#include 
+
+/* 128-bit multimedia register */
+struct mmr { uint64_t hi, lo; } __attribute__((aligned(16)));
+
+#define LQ(base, offset) \
+({ \
+uint64_t hi, lo; \
+\
+__asm__ __volatile__ ( \
+"pcpyld  %1, %1, %1\n" \
+"lq %1, %3(%2)\n" \
+"pcpyud  %0, %1, %1\n" \
+: "=r" (hi), "=r" (lo) \
+: "r" (base), "i" (offset)); \
+\
+(struct mmr) { .hi = hi, .lo = lo }; \
+})
+
+static uint64_t ld_reference(const void *base, int16_t offset)
+{
+const uint8_t *p = base;
+uint64_t r = 0;
+int i;
+
+for (i = 0; i < 8; i++) {
+r |= (uint64_t)p[offset + i] << (8 * i);
+}
+
+return r;
+}
+
+static struct mmr lq_reference(const void *base, int16_t offset)
+{
+/*
+ * The least significant four bits of the effective address are
+ * masked to zero, effectively creating an aligned address. No
+ * address exceptions due to alignment are possible.
+ */
+const uint8_t *b = base;
+const uint8_t *o = &b[offset];
+const void *a = (const void*)((unsigned long)o & ~0xFUL);
+
+return (struct mmr) {
+.hi = ld_reference(a, 8),
+.lo = ld_reference(a, 0)
+};
+}
+
+static void assert_equal_mmr(struct mmr a, struct mmr b)
+{
+assert(a.hi == b.hi);
+assert(a.lo == b.lo);
+}
+
+#define VERIFY_LQ(base, offset) \
+assert_equal_mmr(LQ(base, offset), lq_reference(base, offset))
+
+int main()
+{
+static const char data[] __attribute__((aligned(16)))=
+"0123456789abcdef"
+"ghijklmnopqrstuv"
+"wxyzABCDEFGHIJKL"
+"MNOPQRSTUVWXYZ.,";
+int i;
+
+for (i = 16; i < 48; i++) {
+VERIFY_LQ(&data[i], -16);
+VERIFY_LQ(&data[i], -15);
+VERIFY_LQ(&data[i], -14);
+VERIFY_LQ(&data[i], -13);
+VERIFY_LQ(&data[i], -12);
+VERIFY_LQ(&data[i], -11);
+VERIFY_LQ(&data[i], -10);
+VERIFY_LQ(&data[i], -9);
+VERIFY_LQ(&data[i], -8);
+VERIFY_LQ(&data[i], -7);
+VERIFY_LQ(&data[i], -6);
+VERIFY_LQ(&data[i], -5);
+VERIFY_LQ(&data[i], -4);
+VERIFY_LQ(&data[i], -3);
+VERIFY_LQ(&data[i], -2);
+VERIFY_LQ(&data[i], -1);
+VERIFY_LQ(&data[i],  0);
+VERIFY_LQ(&data[i],  1);
+VERIFY_LQ(&data[i],  2);
+VERIFY_LQ(&data[i],  3);
+VERIFY_LQ(&data[i],  4);
+VERIFY_LQ(&data[i],  5);
+VERIFY_LQ(&data[i],  6);
+VERIFY_LQ(&data[i],  7);
+VERIFY_LQ(&data[i],  8);
+VERIFY_LQ(&data[i],  9);
+VERIFY_LQ(&data[i],  10);
+VERIFY_LQ(&data[i],  11);
+VERIFY_LQ(&data[i],  12);
+VERIFY_LQ(&data[i],  13);
+VERIFY_LQ(&data[i],  14);
+VERIFY_LQ(&data[i],  15);
+VERIFY_LQ(&data[i],  16);
+}
+
+return 0;
+}
-- 
2.19.2




Re: [Qemu-devel] [PATCH] hw/pvrdma: Post CQE when receive invalid gid index

2019-01-13 Thread Yuval Shaia
On Sat, Jan 12, 2019 at 05:11:39PM +0200, Marcel Apfelbaum wrote:
> 
> 
> On 1/9/19 10:15 PM, Yuval Shaia wrote:
> > This error should propagate back to guest.
> > 
> > Signed-off-by: Yuval Shaia 
> > ---
> >   hw/rdma/rdma_backend.h  | 1 +
> >   hw/rdma/vmw/pvrdma_qp_ops.c | 6 --
> >   2 files changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/hw/rdma/rdma_backend.h b/hw/rdma/rdma_backend.h
> > index a9ba40ae48..5114c90e67 100644
> > --- a/hw/rdma/rdma_backend.h
> > +++ b/hw/rdma/rdma_backend.h
> > @@ -32,6 +32,7 @@
> >   #define VENDOR_ERR_INVLKEY  0x207
> >   #define VENDOR_ERR_MR_SMALL 0x208
> >   #define VENDOR_ERR_INV_MAD_BUFF 0x209
> > +#define VENDOR_ERR_INV_GID_IDX  0x210
> >   /* Add definition for QP0 and QP1 as there is no userspace enums for them 
> > */
> >   enum ibv_special_qp_type {
> > diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
> > index 465bee8641..0565eba981 100644
> > --- a/hw/rdma/vmw/pvrdma_qp_ops.c
> > +++ b/hw/rdma/vmw/pvrdma_qp_ops.c
> > @@ -178,7 +178,8 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle)
> >   sgid = rdma_rm_get_gid(&dev->rdma_dev_res, 
> > wqe->hdr.wr.ud.av.gid_index);
> >   if (!sgid) {
> >   pr_dbg("Fail to get gid for idx %d\n", 
> > wqe->hdr.wr.ud.av.gid_index);
> > -return -EIO;
> > +complete_with_error(VENDOR_ERR_INV_GID_IDX, comp_ctx);
> 
> Informing the guest is OK, but are you sure it makes sense
> to continue sending the other work requests?

Yes, it is exactly what is expected. RDMA application (or driver) would
usually push several work requests to ring (optimally populating the entire
ring) and then ring the doorbell.
An error in a specific WR does not means all WRs in ring should not be
processed.

> Is maybe safer to return with error as before?

And what about the remaining WR in the ring? any way the device would have
to process them on next doorbell.

> 
> > +continue;
> >   }
> >   pr_dbg("sgid_id=%d, sgid=0x%llx\n", wqe->hdr.wr.ud.av.gid_index,
> >  sgid->global.interface_id);
> > @@ -189,7 +190,8 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle)
> >   if (sgid_idx <= 0) {
> >   pr_dbg("Fail to get bk sgid_idx for sgid_idx %d\n",
> >  wqe->hdr.wr.ud.av.gid_index);
> > -return -EIO;
> > +complete_with_error(VENDOR_ERR_INV_GID_IDX, comp_ctx);
> > +continue;
> 
> Same question here.
> 
> Thanks,
> Marcel
> >   }
> >   if (wqe->hdr.num_sge > dev->dev_attr.max_sge) {
> 



Re: [Qemu-devel] [PATCH 2/3] hw/rdma: modify struct initialization

2019-01-13 Thread Yuval Shaia
On Sat, Jan 12, 2019 at 05:02:24PM +0200, Marcel Apfelbaum wrote:
> Do not initialize structs with {0} since some
> CLANG versions do not support it.
> 
> Use memset instead.

It is easier than patching CLANG ha? :)

> 
> Signed-off-by: Marcel Apfelbaum 
> ---
>  contrib/rdmacm-mux/main.c | 12 +---
>  hw/rdma/rdma_backend.c| 16 
>  2 files changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/contrib/rdmacm-mux/main.c b/contrib/rdmacm-mux/main.c
> index 64676030c5..d01dc76927 100644
> --- a/contrib/rdmacm-mux/main.c
> +++ b/contrib/rdmacm-mux/main.c
> @@ -350,9 +350,11 @@ static int get_fd(const char *mad, int *fd, __be64 
> *gid_ifid)
>  static void *umad_recv_thread_func(void *args)
>  {
>  int rc;
> -RdmaCmMuxMsg msg = {0};
> +RdmaCmMuxMsg msg;
>  int fd = -2;
>  
> +memset(&msg, 0, sizeof(msg));
> +
>  msg.hdr.msg_type = RDMACM_MUX_MSG_TYPE_REQ;
>  msg.hdr.op_code = RDMACM_MUX_OP_CODE_MAD;
>  
> @@ -387,11 +389,13 @@ static void *umad_recv_thread_func(void *args)
>  static int read_and_process(int fd)
>  {
>  int rc;
> -RdmaCmMuxMsg msg = {0};
> +RdmaCmMuxMsg msg;
>  struct umad_hdr *hdr;
>  uint32_t *comm_id = 0;
>  uint16_t attr_id;
>  
> +memset(&msg, 0, sizeof(msg));
> +
>  rc = recv(fd, &msg, sizeof(msg), 0);
>  syslog(LOG_DEBUG, "Socket %d, recv %d\n", fd, rc);
>  
> @@ -744,7 +748,9 @@ static void signal_handler(int sig, siginfo_t *siginfo, 
> void *context)
>  static int init(void)
>  {
>  int rc;
> -struct sigaction sig = {0};
> +struct sigaction sig;
> +
> +memset(&sig, 0, sizeof(sig));
>  
>  rc = init_listener();
>  if (rc) {
> diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
> index c28bfbd44d..92e95aa640 100644
> --- a/hw/rdma/rdma_backend.c
> +++ b/hw/rdma/rdma_backend.c
> @@ -190,9 +190,11 @@ static inline int 
> rdmacm_mux_can_process_async(RdmaBackendDev *backend_dev)
>  
>  static int check_mux_op_status(CharBackend *mad_chr_be)
>  {
> -RdmaCmMuxMsg msg = {0};
> +RdmaCmMuxMsg msg;
>  int ret;
>  
> +memset(&msg, 0, sizeof(msg));
> +
>  pr_dbg("Reading response\n");
>  ret = qemu_chr_fe_read_all(mad_chr_be, (uint8_t *)&msg, sizeof(msg));
>  if (ret != sizeof(msg)) {
> @@ -387,10 +389,12 @@ static int build_host_sge_array(RdmaDeviceResources 
> *rdma_dev_res,
>  static int mad_send(RdmaBackendDev *backend_dev, uint8_t sgid_idx,
>  union ibv_gid *sgid, struct ibv_sge *sge, uint32_t 
> num_sge)
>  {
> -RdmaCmMuxMsg msg = {0};
> +RdmaCmMuxMsg msg;
>  char *hdr, *data;
>  int ret;
>  
> +memset(&msg, 0, sizeof(msg));
> +
>  pr_dbg("num_sge=%d\n", num_sge);
>  
>  if (num_sge != 2) {
> @@ -1112,9 +1116,11 @@ int rdma_backend_get_gid_index(RdmaBackendDev 
> *backend_dev,
>  int rdma_backend_add_gid(RdmaBackendDev *backend_dev, const char *ifname,
>   union ibv_gid *gid)
>  {
> -RdmaCmMuxMsg msg = {0};
> +RdmaCmMuxMsg msg;
>  int ret;
>  
> +memset(&msg, 0, sizeof(msg));
> +
>  pr_dbg("0x%llx, 0x%llx\n",
> (long long unsigned int)be64_to_cpu(gid->global.subnet_prefix),
> (long long unsigned int)be64_to_cpu(gid->global.interface_id));
> @@ -1138,9 +1144,11 @@ int rdma_backend_add_gid(RdmaBackendDev *backend_dev, 
> const char *ifname,
>  int rdma_backend_del_gid(RdmaBackendDev *backend_dev, const char *ifname,
>   union ibv_gid *gid)
>  {
> -RdmaCmMuxMsg msg = {0};
> +RdmaCmMuxMsg msg;
>  int ret;
>  
> +memset(&msg, 0, sizeof(msg));
> +
>  pr_dbg("0x%llx, 0x%llx\n",
> (long long unsigned int)be64_to_cpu(gid->global.subnet_prefix),
> (long long unsigned int)be64_to_cpu(gid->global.interface_id));

Reviewed-by: Yuval Shaia 

One comment though, should subject prefixed with hw/rdma or
contrib/rdmacm-mux?

> -- 
> 2.17.1
> 



Re: [Qemu-devel] [PATCH 3/3] contrib/rdmacm-mux: fix clang compilation

2019-01-13 Thread Yuval Shaia
On Sat, Jan 12, 2019 at 05:02:25PM +0200, Marcel Apfelbaum wrote:
> Fix Commit a5d2f6f877 (contrib/rdmacm-mux: Add implementation
>of RDMA User MAD multiplexer).
> 
> The above commit introduces a new contrib target, adding a global dependency
> to libumad library in case pvrdma configuration option is enabled.
> Clang forbids it:
> clang-6.0: error: -libumad: 'linker' input unused
>   [-Werror,-Wunused-command-line-argument]
> 
> Fix by limiting the scope to the rdmacm-mux target itself.
> 
> Reported-by: Cornelia Huck 
> Signed-off-by: Marcel Apfelbaum 
> ---
>  Makefile | 2 ++
>  contrib/rdmacm-mux/Makefile.objs | 1 -
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index a9ac16d94e..31e87e0c2d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -580,6 +580,8 @@ vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) 
> libvhost-user.a
>   $(call LINK, $^)
>  vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
>   $(call LINK, $^)
> +
> +rdmacm-mux$(EXESUF): LIBS += "-libumad"
>  rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
>   $(call LINK, $^)
>  
> diff --git a/contrib/rdmacm-mux/Makefile.objs 
> b/contrib/rdmacm-mux/Makefile.objs
> index e1ff4fe569..3df744af89 100644
> --- a/contrib/rdmacm-mux/Makefile.objs
> +++ b/contrib/rdmacm-mux/Makefile.objs
> @@ -1,4 +1,3 @@
>  ifdef CONFIG_PVRDMA
> -CFLAGS += -libumad

My bad, thanks for doing it the right way.

Reviewed-by: Yuval Shaia 

>  rdmacm-mux-obj-y = main.o
>  endif
> -- 
> 2.17.1
> 



Re: [Qemu-devel] [PATCH 2/3] hw/rdma: modify struct initialization

2019-01-13 Thread Yuval Shaia
On Sun, Jan 13, 2019 at 09:24:40PM +0200, Yuval Shaia wrote:
> On Sat, Jan 12, 2019 at 05:02:24PM +0200, Marcel Apfelbaum wrote:
> > Do not initialize structs with {0} since some
> > CLANG versions do not support it.
> > 
> > Use memset instead.
> 
> It is easier than patching CLANG ha? :)
> 
> > 
> > Signed-off-by: Marcel Apfelbaum 
> > ---
> >  contrib/rdmacm-mux/main.c | 12 +---
> >  hw/rdma/rdma_backend.c| 16 
> >  2 files changed, 21 insertions(+), 7 deletions(-)
> > 
> > diff --git a/contrib/rdmacm-mux/main.c b/contrib/rdmacm-mux/main.c
> > index 64676030c5..d01dc76927 100644
> > --- a/contrib/rdmacm-mux/main.c
> > +++ b/contrib/rdmacm-mux/main.c
> > @@ -350,9 +350,11 @@ static int get_fd(const char *mad, int *fd, __be64 
> > *gid_ifid)
> >  static void *umad_recv_thread_func(void *args)
> >  {
> >  int rc;
> > -RdmaCmMuxMsg msg = {0};
> > +RdmaCmMuxMsg msg;
> >  int fd = -2;
> >  
> > +memset(&msg, 0, sizeof(msg));
> > +
> >  msg.hdr.msg_type = RDMACM_MUX_MSG_TYPE_REQ;
> >  msg.hdr.op_code = RDMACM_MUX_OP_CODE_MAD;
> >  
> > @@ -387,11 +389,13 @@ static void *umad_recv_thread_func(void *args)
> >  static int read_and_process(int fd)
> >  {
> >  int rc;
> > -RdmaCmMuxMsg msg = {0};
> > +RdmaCmMuxMsg msg;
> >  struct umad_hdr *hdr;
> >  uint32_t *comm_id = 0;
> >  uint16_t attr_id;
> >  
> > +memset(&msg, 0, sizeof(msg));
> > +
> >  rc = recv(fd, &msg, sizeof(msg), 0);
> >  syslog(LOG_DEBUG, "Socket %d, recv %d\n", fd, rc);
> >  
> > @@ -744,7 +748,9 @@ static void signal_handler(int sig, siginfo_t *siginfo, 
> > void *context)
> >  static int init(void)
> >  {
> >  int rc;
> > -struct sigaction sig = {0};
> > +struct sigaction sig;
> > +
> > +memset(&sig, 0, sizeof(sig));
> >  
> >  rc = init_listener();
> >  if (rc) {
> > diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
> > index c28bfbd44d..92e95aa640 100644
> > --- a/hw/rdma/rdma_backend.c
> > +++ b/hw/rdma/rdma_backend.c
> > @@ -190,9 +190,11 @@ static inline int 
> > rdmacm_mux_can_process_async(RdmaBackendDev *backend_dev)
> >  
> >  static int check_mux_op_status(CharBackend *mad_chr_be)
> >  {
> > -RdmaCmMuxMsg msg = {0};
> > +RdmaCmMuxMsg msg;
> >  int ret;
> >  
> > +memset(&msg, 0, sizeof(msg));
> > +
> >  pr_dbg("Reading response\n");
> >  ret = qemu_chr_fe_read_all(mad_chr_be, (uint8_t *)&msg, sizeof(msg));
> >  if (ret != sizeof(msg)) {
> > @@ -387,10 +389,12 @@ static int build_host_sge_array(RdmaDeviceResources 
> > *rdma_dev_res,
> >  static int mad_send(RdmaBackendDev *backend_dev, uint8_t sgid_idx,
> >  union ibv_gid *sgid, struct ibv_sge *sge, uint32_t 
> > num_sge)
> >  {
> > -RdmaCmMuxMsg msg = {0};
> > +RdmaCmMuxMsg msg;
> >  char *hdr, *data;
> >  int ret;
> >  
> > +memset(&msg, 0, sizeof(msg));
> > +
> >  pr_dbg("num_sge=%d\n", num_sge);
> >  
> >  if (num_sge != 2) {
> > @@ -1112,9 +1116,11 @@ int rdma_backend_get_gid_index(RdmaBackendDev 
> > *backend_dev,
> >  int rdma_backend_add_gid(RdmaBackendDev *backend_dev, const char *ifname,
> >   union ibv_gid *gid)
> >  {
> > -RdmaCmMuxMsg msg = {0};
> > +RdmaCmMuxMsg msg;
> >  int ret;
> >  
> > +memset(&msg, 0, sizeof(msg));
> > +
> >  pr_dbg("0x%llx, 0x%llx\n",
> > (long long unsigned int)be64_to_cpu(gid->global.subnet_prefix),
> > (long long unsigned int)be64_to_cpu(gid->global.interface_id));
> > @@ -1138,9 +1144,11 @@ int rdma_backend_add_gid(RdmaBackendDev 
> > *backend_dev, const char *ifname,
> >  int rdma_backend_del_gid(RdmaBackendDev *backend_dev, const char *ifname,
> >   union ibv_gid *gid)
> >  {
> > -RdmaCmMuxMsg msg = {0};
> > +RdmaCmMuxMsg msg;
> >  int ret;
> >  
> > +memset(&msg, 0, sizeof(msg));
> > +
> >  pr_dbg("0x%llx, 0x%llx\n",
> > (long long unsigned int)be64_to_cpu(gid->global.subnet_prefix),
> > (long long unsigned int)be64_to_cpu(gid->global.interface_id));
> 
> Reviewed-by: Yuval Shaia 
> 
> One comment though, should subject prefixed with hw/rdma or
> contrib/rdmacm-mux?

Just noticed that patch took care of both so would it be better to have two
separate patches instead?

> 
> > -- 
> > 2.17.1
> > 
> 



Re: [Qemu-devel] [PATCH] crypto: finish removing TABs

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20181217231639.24250-1-pbonz...@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20181217231639.24250-1-pbonz...@redhat.com
Subject: [Qemu-devel] [PATCH] crypto: finish removing TABs

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Switched to a new branch 'test'
99bac12 crypto: finish removing TABs

=== OUTPUT BEGIN ===
ERROR: line over 90 characters
#26: FILE: crypto/aes.c:1064:
+0x1B00, 0x3600, /* for 128-bit blocks, Rijndael never uses 
more than 10 rcon values */

ERROR: braces {} are necessary for all arms of this statement
#47: FILE: crypto/aes.c:1077:
+if (!userKey || !key)
[...]

ERROR: braces {} are necessary for all arms of this statement
#49: FILE: crypto/aes.c:1079:
+if (bits != 128 && bits != 192 && bits != 256)
[...]

ERROR: spaces required around that '==' (ctx:VxV)
#61: FILE: crypto/aes.c:1084:
+if (bits==128)
 ^

ERROR: braces {} are necessary for all arms of this statement
#61: FILE: crypto/aes.c:1084:
+if (bits==128)
[...]
+else if (bits==192)
[...]
+else
[...]

ERROR: spaces required around that '==' (ctx:VxV)
#63: FILE: crypto/aes.c:1086:
+else if (bits==192)
  ^

ERROR: braces {} are necessary for all arms of this statement
#63: FILE: crypto/aes.c:1086:
+else if (bits==192)
[...]
+else
[...]

ERROR: space prohibited before that close parenthesis ')'
#76: FILE: crypto/aes.c:1091:
+rk[0] = GETU32(userKey );

ERROR: space prohibited after that open square bracket '['
#118: FILE: crypto/aes.c:1117:
+temp = rk[ 5];

ERROR: space prohibited after that open square bracket '['
#119: FILE: crypto/aes.c:1118:
+rk[ 6] = rk[ 0] ^

ERROR: space prohibited after that open square bracket '['
#143: FILE: crypto/aes.c:1124:
+rk[ 7] = rk[ 1] ^ rk[ 6];

ERROR: space prohibited after that open square bracket '['
#144: FILE: crypto/aes.c:1125:
+rk[ 8] = rk[ 2] ^ rk[ 7];

ERROR: space prohibited after that open square bracket '['
#145: FILE: crypto/aes.c:1126:
+rk[ 9] = rk[ 3] ^ rk[ 8];

ERROR: space prohibited after that open square bracket '['
#149: FILE: crypto/aes.c:1130:
+rk[10] = rk[ 4] ^ rk[ 9];

ERROR: space prohibited after that open square bracket '['
#150: FILE: crypto/aes.c:1131:
+rk[11] = rk[ 5] ^ rk[10];

ERROR: space prohibited after that open square bracket '['
#158: FILE: crypto/aes.c:1139:
+temp = rk[ 7];

ERROR: space prohibited after that open square bracket '['
#159: FILE: crypto/aes.c:1140:
+rk[ 8] = rk[ 0] ^

ERROR: space prohibited after that open square bracket '['
#174: FILE: crypto/aes.c:1146:
+rk[ 9] = rk[ 1] ^ rk[ 8];

ERROR: space prohibited after that open square bracket '['
#175: FILE: crypto/aes.c:1147:
+rk[10] = rk[ 2] ^ rk[ 9];

ERROR: space prohibited after that open square bracket '['
#176: FILE: crypto/aes.c:1148:
+rk[11] = rk[ 3] ^ rk[10];

ERROR: space prohibited after that open square bracket '['
#181: FILE: crypto/aes.c:1153:
+rk[12] = rk[ 4] ^

ERROR: space prohibited after that open square bracket '['
#189: FILE: crypto/aes.c:1158:
+rk[13] = rk[ 5] ^ rk[12];

ERROR: space prohibited after that open square bracket '['
#190: FILE: crypto/aes.c:1159:
+rk[14] = rk[ 6] ^ rk[13];

ERROR: space prohibited after that open square bracket '['
#191: FILE: crypto/aes.c:1160:
+rk[15] = rk[ 7] ^ rk[14];

ERROR: braces {} are necessary for all arms of this statement
#221: FILE: crypto/aes.c:1180:
+if (status < 0)
[...]

ERROR: spaces required around that '*' (ctx:VxV)
#239: FILE: crypto/aes.c:1186:
+for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
  ^

ERROR: space prohibited before that close square bracket ']'
#240: FILE: crypto/aes.c:1187:
+temp = rk[i]; rk[i] = rk[j]; rk[j] = temp;

ERROR: line over 90 characters
#245: FILE: crypto/aes.c:1192:
+/* apply the inverse MixColumn transform to all round keys but the 
first and the last: */

ERROR: space prohibited before that close parenthesis ')'
#311: FILE: crypto/aes.c:1240:
+s0 = GETU32(in ) ^ rk[0];

ERROR: spaces required around that '=' (ctx:VxV)
#574: FILE: crypto/aes.c:1617:
+for(n=0; n < AES_BLOCK_SIZE; ++n)
  ^

ERROR: space required before the open parenthes

Re: [Qemu-devel] [PATCH 00/13] Misc fixes / improvements for the docker and travis configs

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190109163114.17010-1-berra...@redhat.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20190109163114.17010-1-berra...@redhat.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH 1/3] contrib/rdmacm-mux: remove Wno-format-truncation flag

2019-01-13 Thread Yuval Shaia
On Sat, Jan 12, 2019 at 05:02:23PM +0200, Marcel Apfelbaum wrote:
> The flag is not recognized by some CLANG versions.
> Add proper constraints in code instead.
> 
> Signed-off-by: Marcel Apfelbaum 
> ---
>  contrib/rdmacm-mux/Makefile.objs | 2 +-
>  contrib/rdmacm-mux/main.c| 6 --
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/contrib/rdmacm-mux/Makefile.objs 
> b/contrib/rdmacm-mux/Makefile.objs
> index be3eacb6f7..e1ff4fe569 100644
> --- a/contrib/rdmacm-mux/Makefile.objs
> +++ b/contrib/rdmacm-mux/Makefile.objs
> @@ -1,4 +1,4 @@
>  ifdef CONFIG_PVRDMA
> -CFLAGS += -libumad -Wno-format-truncation
> +CFLAGS += -libumad
>  rdmacm-mux-obj-y = main.o
>  endif
> diff --git a/contrib/rdmacm-mux/main.c b/contrib/rdmacm-mux/main.c
> index 835a7f9214..64676030c5 100644
> --- a/contrib/rdmacm-mux/main.c
> +++ b/contrib/rdmacm-mux/main.c
> @@ -42,6 +42,8 @@
>  
>  /* The below can be override by command line parameter */
>  #define UNIX_SOCKET_PATH "/var/run/rdmacm-mux"
> +/* Has format %s-%s-%d" -- */
> +#define SOCKET_PATH_MAX (PATH_MAX - NAME_MAX - sizeof(int) - 2)
>  #define RDMA_PORT_NUM 1
>  
>  typedef struct RdmaCmServerArgs {
> @@ -95,7 +97,7 @@ static void help(const char *progname)
>  static void parse_args(int argc, char *argv[])
>  {
>  int c;
> -char unix_socket_path[PATH_MAX];
> +char unix_socket_path[SOCKET_PATH_MAX];
>  
>  strcpy(server.args.rdma_dev_name, "");
>  strcpy(unix_socket_path, UNIX_SOCKET_PATH);
> @@ -113,7 +115,7 @@ static void parse_args(int argc, char *argv[])
>  
>  case 's':
>  /* This is temporary, final name will build below */
> -strncpy(unix_socket_path, optarg, PATH_MAX);
> +strncpy(unix_socket_path, optarg, SOCKET_PATH_MAX);
>  break;
>  

Reviewed-by: Yuval Shaia 

>  case 'p':
> -- 
> 2.17.1
> 



Re: [Qemu-devel] [PULL 0/2] Linux user for 4.0 patches

2019-01-13 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190110083737.5036-1-laur...@vivier.eu/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20190110083737.5036-1-laur...@vivier.eu
Subject: [Qemu-devel] [PULL 0/2] Linux user for 4.0 patches

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
 * [new tag] patchew/20190110083737.5036-1-laur...@vivier.eu -> 
patchew/20190110083737.5036-1-laur...@vivier.eu
Switched to a new branch 'test'
47841e1 Add getsockopt for settable SOL_IPV6 options

=== OUTPUT BEGIN ===
ERROR: braces {} are necessary for all arms of this statement
#35: FILE: linux-user/syscall.c:2407:
+if (get_user_u32(len, optlen))
[...]

ERROR: braces {} are necessary for all arms of this statement
#37: FILE: linux-user/syscall.c:2409:
+if (len < 0)
[...]

ERROR: braces {} are necessary for all arms of this statement
#41: FILE: linux-user/syscall.c:2413:
+if (ret < 0)
[...]

ERROR: braces {} are necessary for all arms of this statement
#49: FILE: linux-user/syscall.c:2421:
+if (len > sizeof(int))
[...]

total: 4 errors, 0 warnings, 45 lines checked

Commit 47841e11e8dd (Add getsockopt for settable SOL_IPV6 options) has style 
problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20190110083737.5036-1-laur...@vivier.eu/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

Re: [Qemu-devel] [PATCH] ftgmac100: implement the new MDIO interface on Aspeed SoC

2019-01-13 Thread Andrew Jeffery



On Fri, 11 Jan 2019, at 23:27, Cédric Le Goater wrote:
> The PHY behind the MAC of an Aspeed SoC can be controlled using two
> different MDC/MDIO interfaces. The same registers PHYCR (MAC60) and
> PHYDATA (MAC64) are involved but they have a different layout.
> 
> BIT31 of the Feature Register (MAC40) controls which MDC/MDIO
> interface is active.
> 
> Signed-off-by: Cédric Le Goater 

Reviewed-by: Andrew Jeffery 

> ---
>  hw/net/ftgmac100.c | 80 +++---
>  1 file changed, 68 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 909c1182eebe..790430346b51 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -89,6 +89,18 @@
>  #define FTGMAC100_PHYDATA_MIIWDATA(x)   ((x) & 0x)
>  #define FTGMAC100_PHYDATA_MIIRDATA(x)   (((x) >> 16) & 0x)
>  
> +/*
> + * PHY control register - New MDC/MDIO interface
> + */
> +#define FTGMAC100_PHYCR_NEW_DATA(x) (((x) >> 16) & 0x)
> +#define FTGMAC100_PHYCR_NEW_FIRE(1 << 15)
> +#define FTGMAC100_PHYCR_NEW_ST_22   (1 << 12)
> +#define FTGMAC100_PHYCR_NEW_OP(x)   (((x) >> 10) & 3)
> +#define   FTGMAC100_PHYCR_NEW_OP_WRITE0x1
> +#define   FTGMAC100_PHYCR_NEW_OP_READ 0x2
> +#define FTGMAC100_PHYCR_NEW_DEV(x)  (((x) >> 5) & 0x1f)
> +#define FTGMAC100_PHYCR_NEW_REG(x)  ((x) & 0x1f)
> +
>  /*
>   * Feature Register
>   */
> @@ -269,9 +281,9 @@ static void phy_reset(FTGMAC100State *s)
>  s->phy_int = 0;
>  }
>  
> -static uint32_t do_phy_read(FTGMAC100State *s, int reg)
> +static uint16_t do_phy_read(FTGMAC100State *s, uint8_t reg)
>  {
> -uint32_t val;
> +uint16_t val;
>  
>  switch (reg) {
>  case MII_BMCR: /* Basic Control */
> @@ -336,7 +348,7 @@ static uint32_t do_phy_read(FTGMAC100State *s, int reg)
> MII_BMCR_FD | MII_BMCR_CTST)
>  #define MII_ANAR_MASK 0x2d7f
>  
> -static void do_phy_write(FTGMAC100State *s, int reg, uint32_t val)
> +static void do_phy_write(FTGMAC100State *s, uint8_t reg, uint16_t val)
>  {
>  switch (reg) {
>  case MII_BMCR: /* Basic Control */
> @@ -373,6 +385,55 @@ static void do_phy_write(FTGMAC100State *s, int 
> reg, uint32_t val)
>  }
>  }
>  
> +static void do_phy_new_ctl(FTGMAC100State *s)
> +{
> +uint8_t reg;
> +uint16_t data;
> +
> +if (!(s->phycr & FTGMAC100_PHYCR_NEW_ST_22)) {
> +qemu_log_mask(LOG_UNIMP, "%s: unsupported ST code\n", __func__);
> +return;
> +}
> +
> +/* Nothing to do */
> +if (!(s->phycr & FTGMAC100_PHYCR_NEW_FIRE)) {
> +return;
> +}
> +
> +reg = FTGMAC100_PHYCR_NEW_REG(s->phycr);
> +data = FTGMAC100_PHYCR_NEW_DATA(s->phycr);
> +
> +switch (FTGMAC100_PHYCR_NEW_OP(s->phycr)) {
> +case FTGMAC100_PHYCR_NEW_OP_WRITE:
> +do_phy_write(s, reg, data);
> +break;
> +case FTGMAC100_PHYCR_NEW_OP_READ:
> +s->phydata = do_phy_read(s, reg) & 0x;
> +break;
> +default:
> +qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid OP code %08x\n",
> +  __func__, s->phycr);
> +}
> +
> +s->phycr &= ~FTGMAC100_PHYCR_NEW_FIRE;
> +}
> +
> +static void do_phy_ctl(FTGMAC100State *s)
> +{
> +uint8_t reg = FTGMAC100_PHYCR_REG(s->phycr);
> +
> +if (s->phycr & FTGMAC100_PHYCR_MIIWR) {
> +do_phy_write(s, reg, s->phydata & 0x);
> +s->phycr &= ~FTGMAC100_PHYCR_MIIWR;
> +} else if (s->phycr & FTGMAC100_PHYCR_MIIRD) {
> +s->phydata = do_phy_read(s, reg) << 16;
> +s->phycr &= ~FTGMAC100_PHYCR_MIIRD;
> +} else {
> +qemu_log_mask(LOG_GUEST_ERROR, "%s: no OP code %08x\n",
> +  __func__, s->phycr);
> +}
> +}
> +
>  static int ftgmac100_read_bd(FTGMAC100Desc *bd, dma_addr_t addr)
>  {
>  if (dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd))) {
> @@ -628,7 +689,6 @@ static void ftgmac100_write(void *opaque, hwaddr addr,
>uint64_t value, unsigned size)
>  {
>  FTGMAC100State *s = FTGMAC100(opaque);
> -int reg;
>  
>  switch (addr & 0xff) {
>  case FTGMAC100_ISR: /* Interrupt status */
> @@ -711,14 +771,11 @@ static void ftgmac100_write(void *opaque, hwaddr addr,
>  break;
>  
>  case FTGMAC100_PHYCR:  /* PHY Device control */
> -reg = FTGMAC100_PHYCR_REG(value);
>  s->phycr = value;
> -if (value & FTGMAC100_PHYCR_MIIWR) {
> -do_phy_write(s, reg, s->phydata & 0x);
> -s->phycr &= ~FTGMAC100_PHYCR_MIIWR;
> +if (s->revr & FTGMAC100_REVR_NEW_MDIO_INTERFACE) {
> +do_phy_new_ctl(s);
>  } else {
> -s->phydata = do_phy_read(s, reg) << 16;
> -s->phycr &= ~FTGMAC100_PHYCR_MIIRD;
> +do_phy_ctl(s);
>  }
>  break;
>  case FTGMAC100_PHYDATA:
> @@ -728,8 +785,7 @@ static void ftgmac100_write(void *opaque, hwaddr addr,
>  s->dblac = value;
>  

Re: [Qemu-devel] [PATCH v3 0/5] kvm "virtio pmem" device

2019-01-13 Thread Dave Chinner
On Fri, Jan 11, 2019 at 02:45:04AM -0500, Pankaj Gupta wrote:
> 
> > 
> > On Wed, Jan 09, 2019 at 08:17:31PM +0530, Pankaj Gupta wrote:
> > >  This patch series has implementation for "virtio pmem".
> > >  "virtio pmem" is fake persistent memory(nvdimm) in guest
> > >  which allows to bypass the guest page cache. This also
> > >  implements a VIRTIO based asynchronous flush mechanism.
> > 
> > H. Sharing the host page cache direct into the guest VM. Sounds
> > like a good idea, but.
> > 
> > This means the guest VM can now run timing attacks to observe host
> > side page cache residency, and depending on the implementation I'm
> > guessing that the guest will be able to control host side page
> > cache eviction, too (e.g. via discard or hole punch operations).
> 
> Not sure how? this is similar to mmapping virtual memory by any userspace 
> process. Any host userspace process can do such attack on host page cache
> using mincore & mmap shared file. 

Mincore is for monitoring, not cached eviction. And it's not
required to observe cache residency, either. That's a wide open
field containing an uncountable number of moles...

> But i don't think guest can do this alone. For virtio-pmem usecase
> guest won't be using page cache so timing attack from only guest
> side is not possible unless host userspace can run checks on page
> cache eviction state using mincore etc.  As rightly described by
> Rik, guest will only access its own page cache pages and if guest
> page cache is managed directly by host, this saves alot of effort
> for guest in transferring guest state of page cache.  

Until you have images (and hence host page cache) shared between
multiple guests. People will want to do this, because it means they
only need a single set of pages in host memory for executable
binaries rather than a set of pages per guest. Then you have
multiple guests being able to detect residency of the same set of
pages. If the guests can then, in any way, control eviction of the
pages from the host cache, then we have a guest-to-guest information
leak channel.

i.e. it's something we need to be aware of and really careful about
enabling infrastructure that /will/ be abused if guests can find a
way to influence the host side cache residency.

Cheers,

Dave.
-- 
Dave Chinner
da...@fromorbit.com



Re: [Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function

2019-01-13 Thread Samuel Thibault
P J P, le dim. 13 janv. 2019 23:29:48 +0530, a ecrit:
> From: Prasad J Pandit 
> 
> While emulating identification protocol, tcp_emu() does not check
> available space in the 'sc_rcv->sb_data' buffer. It could lead to
> heap buffer overflow issue. Add check to avoid it.
> 
> Reported-by: Kira <864786...@qq.com>
> Signed-off-by: Prasad J Pandit 

Applied to my tree, thanks!

Samuel



Re: [Qemu-devel] [PATCH v3 0/5] kvm "virtio pmem" device

2019-01-13 Thread Matthew Wilcox
On Mon, Jan 14, 2019 at 10:29:02AM +1100, Dave Chinner wrote:
> Until you have images (and hence host page cache) shared between
> multiple guests. People will want to do this, because it means they
> only need a single set of pages in host memory for executable
> binaries rather than a set of pages per guest. Then you have
> multiple guests being able to detect residency of the same set of
> pages. If the guests can then, in any way, control eviction of the
> pages from the host cache, then we have a guest-to-guest information
> leak channel.

I don't think we should ever be considering something that would allow a
guest to evict page's from the host's pagecache [1].  The guest should
be able to kick its own references to the host's pagecache out of its
own pagecache, but not be able to influence whether the host or another
guest has a read-only mapping cached.

[1] Unless the guest is allowed to modify the host's file; obviously
truncation, holepunching, etc are going to evict pages from the host's
page cache.



Re: [Qemu-devel] [PATCH 0/4] Add ignore-external migration capability

2019-01-13 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/20190110120120.9943-1-yury-ko...@yandex-team.ru/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14
=== TEST SCRIPT END ===

  CC  aarch64-softmmu/balloon.o
  CC  x86_64-softmmu/hw/block/virtio-blk.o
/tmp/qemu-test/src/migration/ram.c: In function 'ram_load':
/tmp/qemu-test/src/migration/ram.c:4159:42: error: format '%lld' expects 
argument of type 'long long int', but argument 3 has type 'ram_addr_t {aka 
unsigned int}' [-Werror=format=]
 error_report("Mismatched RAM block offset %s "
  ^
In file included from 
/usr/i686-w64-mingw32/sys-root/mingw/include/inttypes.h:299:0,
---
  CC  aarch64-softmmu/hw/cpu/a15mpcore.o
  CC  aarch64-softmmu/hw/display/omap_dss.o
/tmp/qemu-test/src/migration/ram.c: In function 'ram_load':
/tmp/qemu-test/src/migration/ram.c:4159:42: error: format '%lld' expects 
argument of type 'long long int', but argument 3 has type 'ram_addr_t {aka 
unsigned int}' [-Werror=format=]
 error_report("Mismatched RAM block offset %s "
  ^
In file included from 
/usr/i686-w64-mingw32/sys-root/mingw/include/inttypes.h:299:0,


The full log is available at
http://patchew.org/logs/20190110120120.9943-1-yury-ko...@yandex-team.ru/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-de...@redhat.com

[Qemu-devel] [PULL 02/65] slirp: remove do_pty from fork_exec()

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

QEMU uses fork_exec() with do_pty values 0 or 3.
Let's clean up some unused code.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/misc.c | 55 ++--
 slirp/misc.h |  2 +-
 slirp/tcp_subr.c |  4 +---
 3 files changed, 18 insertions(+), 43 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index 57bdd808e2..e69d5f42c3 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -63,7 +63,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,
 #ifdef _WIN32
 
 int
-fork_exec(struct socket *so, const char *ex, int do_pty)
+fork_exec(struct socket *so, const char *ex)
 {
 /* not implemented */
 return 0;
@@ -77,13 +77,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
  * process, which connects to this socket, after which we
  * exec the wanted program.  If something (strange) happens,
  * the accept() call could block us forever.
- *
- * do_pty = 0   Fork/exec inetd style
- * do_pty = 1   Fork/exec using slirp.telnetd
- * do_ptr = 2   Fork/exec using pty
  */
 int
-fork_exec(struct socket *so, const char *ex, int do_pty)
+fork_exec(struct socket *so, const char *ex)
 {
 int s, cs;
 struct sockaddr_in addr, csaddr;
@@ -100,26 +96,20 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
DEBUG_CALL("fork_exec");
DEBUG_ARG("so = %p", so);
DEBUG_ARG("ex = %p", ex);
-   DEBUG_ARG("do_pty = %x", do_pty);
-
-   if (do_pty == 2) {
-return 0;
-   } else {
-   addr.sin_family = AF_INET;
-   addr.sin_port = 0;
-   addr.sin_addr.s_addr = INADDR_ANY;
 
-   if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 ||
-   bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
-   listen(s, 1) < 0) {
-   error_report("Error: inet socket: %s", strerror(errno));
-   if (s >= 0) {
-   closesocket(s);
-   }
+addr.sin_family = AF_INET;
+addr.sin_port = 0;
+addr.sin_addr.s_addr = INADDR_ANY;
 
-   return 0;
-   }
-   }
+s = qemu_socket(AF_INET, SOCK_STREAM, 0);
+if (s < 0 || bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
+listen(s, 1) < 0) {
+error_report("Error: inet socket: %s", strerror(errno));
+if (s >= 0) {
+closesocket(s);
+}
+return 0;
+}
 
 if (getsockname(s, (struct sockaddr *)&csaddr, &csaddrlen) < 0) {
 closesocket(s);
@@ -166,13 +156,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
 
i = 0;
bptr = g_strdup(ex); /* No need to free() this */
-   if (do_pty == 1) {
-   /* Setup "slirp.telnetd -x" */
-   argv[i++] = "slirp.telnetd";
-   argv[i++] = "-x";
-   argv[i++] = bptr;
-   } else
-  do {
+do {
/* Change the string into argv[] */
curarg = bptr;
while (*bptr != ' ' && *bptr != (char)0)
@@ -180,7 +164,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
c = *bptr;
*bptr++ = (char)0;
argv[i++] = g_strdup(curarg);
-  } while (c);
+} while (c);
 
 argv[i] = NULL;
execvp(argv[0], (char **)argv);
@@ -206,13 +190,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
 opt = 1;
 qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, 
sizeof(int));
qemu_set_nonblock(so->s);
-
-   /* Append the telnet options now */
-if (so->so_m != NULL && do_pty == 1)  {
-   sbappend(so, so->so_m);
-so->so_m = NULL;
-   }
-
return 1;
}
 }
diff --git a/slirp/misc.h b/slirp/misc.h
index 5211bbd30a..897650aea1 100644
--- a/slirp/misc.h
+++ b/slirp/misc.h
@@ -53,6 +53,6 @@ struct slirp_quehead {
 void slirp_insque(void *, void *);
 void slirp_remque(void *);
 int add_exec(struct ex_list **, int, char *, struct in_addr, int);
-int fork_exec(struct socket *so, const char *ex, int do_pty);
+int fork_exec(struct socket *so, const char *ex);
 
 #endif
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index fa61349cbb..0ccd8e1a96 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -951,7 +951,6 @@ int tcp_ctl(struct socket *so)
 Slirp *slirp = so->slirp;
 struct sbuf *sb = &so->so_snd;
 struct ex_list *ex_ptr;
-int do_pty;
 
 DEBUG_CALL("tcp_ctl");
 DEBUG_ARG("so = %p", so);
@@ -966,9 +965,8 @@ int tcp_ctl(struct socket *so)
 so->extra = (void *)ex_ptr->ex_exec;
 return 1;

[Qemu-devel] [PULL 11/65] slirp: remove dead declarations

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

An overdue cleanup. Remaining declarations could probably be moved in
other headers, such as slirp.h.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/main.h | 29 -
 1 file changed, 29 deletions(-)

diff --git a/slirp/main.h b/slirp/main.h
index 90053ce5ec..e04677944f 100644
--- a/slirp/main.h
+++ b/slirp/main.h
@@ -12,38 +12,9 @@
 #include 
 #endif
 
-#define TOWRITEMAX 512
-
-extern int slirp_socket;
-extern int slirp_socket_unit;
-extern int slirp_socket_port;
-extern uint32_t slirp_socket_addr;
-extern char *slirp_socket_passwd;
-extern int ctty_closed;
-
-/*
- * Get the difference in 2 times from updtim()
- * Allow for wraparound times, "just in case"
- * x is the greater of the 2 (current time) and y is
- * what it's being compared against.
- */
-#define TIME_DIFF(x,y) (x)-(y) < 0 ? ~0-(y)+(x) : (x)-(y)
-
-extern char *slirp_tty;
-extern char *exec_shell;
 extern u_int curtime;
 extern struct in_addr loopback_addr;
 extern unsigned long loopback_mask;
-extern char *username;
-extern char *socket_path;
-extern int towrite_max;
-extern int ppp_exit;
-extern int tcp_keepintvl;
-
-#define PROTO_SLIP 0x1
-#ifdef USE_PPP
-#define PROTO_PPP 0x2
-#endif
 
 int if_encap(Slirp *slirp, struct mbuf *ifm);
 ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags);
-- 
2.20.1




[Qemu-devel] [PULLv2 00/65] slirp updates

2019-01-13 Thread Samuel Thibault
The following changes since commit 27df21ca3886fff4dd3d70e515517667963a52f1:

  Merge remote-tracking branch 'remotes/kraxel/tags/misc-20190111-pull-request' 
into staging (2019-01-11 16:45:59 +)

are available in the Git repository at:

  https://people.debian.org/~sthibault/qemu.git tags/samuel-thibault

for you to fetch changes up to 341cb5fd7a15ebdaa821ff068b517e120f22c412:

  slirp: check data length while emulating ident function (2019-01-14 00:44:29 
+0100)


slirp updates

Gerd Hoffmann (1):
  slirp: add tftp tracing

Marc-André Lureau (61):
  slirp: associate slirp_output callback with the Slirp context
  slirp: remove do_pty from fork_exec()
  slirp: replace ex_pty with ex_chardev
  slirp: use a dedicated field for chardev pointer
  slirp: remove unused EMU_RSH
  slirp: rename /extra/chardev
  slirp: move internal function declarations
  slirp: remove Monitor dependency, return a string for info
  slirp: fix slirp_add_exec() leaks
  slirp: replace the poor-man string split with g_strsplit()
  slirp: remove dead declarations
  slirp: move socket pair creation in helper function
  slirp: remove unused M_TRAILINGSPACE
  slirp: use a callback structure to interface with qemu
  slirp: remove PROBE_CONN dead-code
  slirp: remove FULL_BOLT
  slirp: remove the disabled readv()/writev() code path
  slirp: remove HAVE_SYS_SIGNAL_H
  slirp: remove unused HAVE_SYS_BITYPES_H
  slirp: remove NO_UNIX_SOCKETS
  slirp: remove unused HAVE_SYS_STROPTS_H
  slirp: remove unused HAVE_ARPA_INET_H
  slirp: remove unused HAVE_SYS_WAIT_H
  slirp: remove unused HAVE_SYS_SELECT_H
  slirp: remove HAVE_SYS_IOCTL_H
  slirp: remove HAVE_SYS_FILIO_H
  slirp: remove unused DECLARE_IOVEC
  slirp: remove unused HAVE_INET_ATON
  slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent
  slirp: replace SIZEOF_CHAR_P with glib equivalent
  slirp: replace compile time DO_KEEPALIVE
  slirp: remove unused global slirp_instance
  slirp: replace error_report() with g_critical()
  slirp: improve a bit the debug macros
  slirp: add a callback to log guest errors
  slirp: remove #if notdef dead code
  slirp: remove unused sbflush()
  slirp: NULL is defined by stddef.h
  slirp: remove dead TCP_ACK_HACK code
  slirp: replace ARRAY_SIZE with G_N_ELEMENTS
  net: do not depend on slirp internals
  glib-compat: add g_spawn_async_with_fds() fallback
  slirp: simplify fork_exec()
  slirp: replace error_report() with g_critical()
  slirp: drop 

[Qemu-devel] [PULL 07/65] slirp: move internal function declarations

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Clarify that those functions are internal to slirp.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/libslirp.h | 3 ---
 slirp/slirp.h| 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 3e88dbaa01..a4f390ee89 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -7,9 +7,6 @@ typedef struct Slirp Slirp;
 
 typedef void (*slirp_output)(void *opaque, const uint8_t *pkt, int pkt_len);
 
-int get_dns_addr(struct in_addr *pdns_addr);
-int get_dns6_addr(struct in6_addr *pdns6_addr, uint32_t *scope_id);
-
 Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,
   struct in_addr vnetmask, struct in_addr vhost,
   bool in6_enabled,
diff --git a/slirp/slirp.h b/slirp/slirp.h
index e3d65d68ec..de299aa36c 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -232,6 +232,9 @@ extern Slirp *slirp_instance;
 
 void if_start(Slirp *);
 
+int get_dns_addr(struct in_addr *pdns_addr);
+int get_dns6_addr(struct in6_addr *pdns6_addr, uint32_t *scope_id);
+
 /* ncsi.c */
 void ncsi_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);
 
-- 
2.20.1




[Qemu-devel] [PULL 06/65] slirp: rename /extra/chardev

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Now it's only used for the chardev pointer.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.c| 4 ++--
 slirp/socket.h   | 2 +-
 slirp/tcp_subr.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/slirp/slirp.c b/slirp/slirp.c
index fac7849195..ab08694e37 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1088,10 +1088,10 @@ int slirp_add_exec(Slirp *slirp, void *chardev, const 
char *cmdline,
 
 ssize_t slirp_send(struct socket *so, const void *buf, size_t len, int flags)
 {
-if (so->s == -1 && so->extra) {
+if (so->s == -1 && so->chardev) {
 /* XXX this blocks entire thread. Rewrite to use
  * qemu_chr_fe_write and background I/O callbacks */
-qemu_chr_fe_write_all(so->extra, buf, len);
+qemu_chr_fe_write_all(so->chardev, buf, len);
 return len;
 }
 
diff --git a/slirp/socket.h b/slirp/socket.h
index 2f224bc34f..930ed95972 100644
--- a/slirp/socket.h
+++ b/slirp/socket.h
@@ -67,7 +67,7 @@ struct socket {
 
   struct sbuf so_rcv;  /* Receive buffer */
   struct sbuf so_snd;  /* Send buffer */
-  void * extra;/* Extra pointer */
+  void * chardev;
 };
 
 
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index fd7521854e..4b40850c7a 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -961,7 +961,7 @@ int tcp_ctl(struct socket *so)
 so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {
 if (ex_ptr->ex_chardev) {
 so->s = -1;
-so->extra = ex_ptr->ex_chardev;
+so->chardev = ex_ptr->ex_chardev;
 return 1;
 }
 DEBUG_MISC((dfd, " executing %s\n", ex_ptr->ex_exec));
-- 
2.20.1




[Qemu-devel] [PULL 03/65] slirp: replace ex_pty with ex_chardev

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

do_pty == 3 means to talk to a chardev.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/misc.c | 2 +-
 slirp/misc.h | 2 +-
 slirp/slirp.c| 4 ++--
 slirp/tcp_subr.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index e69d5f42c3..8f0b6004bd 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -53,7 +53,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,
*ex_ptr = g_new(struct ex_list, 1);
(*ex_ptr)->ex_fport = port;
(*ex_ptr)->ex_addr = addr;
-   (*ex_ptr)->ex_pty = do_pty;
+   (*ex_ptr)->ex_chardev = do_pty == 3;
(*ex_ptr)->ex_exec = (do_pty == 3) ? exec : g_strdup(exec);
(*ex_ptr)->ex_next = tmp_ptr;
return 0;
diff --git a/slirp/misc.h b/slirp/misc.h
index 897650aea1..1f8d11def6 100644
--- a/slirp/misc.h
+++ b/slirp/misc.h
@@ -9,7 +9,7 @@
 #define MISC_H
 
 struct ex_list {
-   int ex_pty; /* Do we want a pty? */
+   int ex_chardev;
struct in_addr ex_addr; /* Server address */
int ex_fport;   /* Port to telnet to */
const char *ex_exec;/* Command line of what to exec */
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 4d4c2c13b5..0498a092b9 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1455,7 +1455,7 @@ static void slirp_state_save(QEMUFile *f, void *opaque)
 struct ex_list *ex_ptr;
 
 for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next)
-if (ex_ptr->ex_pty == 3) {
+if (ex_ptr->ex_chardev) {
 struct socket *so;
 so = slirp_find_ctl_socket(slirp, ex_ptr->ex_addr,
ntohs(ex_ptr->ex_fport));
@@ -1490,7 +1490,7 @@ static int slirp_state_load(QEMUFile *f, void *opaque, 
int version_id)
 return -EINVAL;
 }
 for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
-if (ex_ptr->ex_pty == 3 &&
+if (ex_ptr->ex_chardev &&
 so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr &&
 so->so_fport == ex_ptr->ex_fport) {
 break;
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 0ccd8e1a96..dc19eea55a 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -960,7 +960,7 @@ int tcp_ctl(struct socket *so)
 for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
 if (ex_ptr->ex_fport == so->so_fport &&
 so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) {
-if (ex_ptr->ex_pty == 3) {
+if (ex_ptr->ex_chardev) {
 so->s = -1;
 so->extra = (void *)ex_ptr->ex_exec;
 return 1;
-- 
2.20.1




[Qemu-devel] [PULL 09/65] slirp: fix slirp_add_exec() leaks

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Free the list elements allocated in add_exec().

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/misc.h  | 2 +-
 slirp/slirp.c | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/slirp/misc.h b/slirp/misc.h
index 94829722cd..0bc5e74bc5 100644
--- a/slirp/misc.h
+++ b/slirp/misc.h
@@ -12,7 +12,7 @@ struct ex_list {
void *ex_chardev;
struct in_addr ex_addr; /* Server address */
int ex_fport;   /* Port to telnet to */
-   const char *ex_exec;/* Command line of what to exec */
+   char *ex_exec;  /* Command line of what to exec */
struct ex_list *ex_next;
 };
 
diff --git a/slirp/slirp.c b/slirp/slirp.c
index ab08694e37..1627436e7d 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -342,6 +342,14 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct 
in_addr vnetwork,
 
 void slirp_cleanup(Slirp *slirp)
 {
+struct ex_list *e, *next;
+
+for (e = slirp->exec_list; e; e = next) {
+next = e->ex_next;
+g_free(e->ex_exec);
+g_free(e);
+}
+
 QTAILQ_REMOVE(&slirp_instances, slirp, entry);
 
 unregister_savevm(NULL, "slirp", slirp);
-- 
2.20.1




[Qemu-devel] [PULL 17/65] slirp: remove FULL_BOLT

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Looking at git history, this looks like something from the past, when
there was a tty layer. Let's remove it.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/if.c   | 2 --
 slirp/slirp_config.h | 7 ---
 2 files changed, 9 deletions(-)

diff --git a/slirp/if.c b/slirp/if.c
index 590753c658..aa88cc4e76 100644
--- a/slirp/if.c
+++ b/slirp/if.c
@@ -131,12 +131,10 @@ diddit:
}
}
 
-#ifndef FULL_BOLT
/*
 * This prevents us from malloc()ing too many mbufs
 */
if_start(ifm->slirp);
-#endif
 }
 
 /*
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 721667e3ef..f0cc1c781b 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -5,13 +5,6 @@
 /* Define to 1 if you want KEEPALIVE timers */
 #define DO_KEEPALIVE 0
 
-/* Define this if you want slirp to write to the tty as fast as it can */
-/* This should only be set if you are using load-balancing, slirp does a */
-/* pretty good job on single modems already, and seting this will make */
-/* interactive sessions less responsive */
-/* X Talk about having fast modem as unit 0 */
-#undef FULL_BOLT
-
 /*/
 /*
  * Autoconf defined configuration options
-- 
2.20.1




[Qemu-devel] [PULL 05/65] slirp: remove unused EMU_RSH

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

EMU_RSH handling was dropped in commit
0d62c4cfe21752df4c1d6e2c2398f15d5eaa794a.

The assignment, and subsequent free() of ex_ptr->ex_exec to so->extra
looks unsafe (double free is likely to occur).

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/misc.h | 1 -
 slirp/slirp.c| 2 --
 slirp/socket.c   | 4 
 slirp/tcp_subr.c | 1 -
 4 files changed, 8 deletions(-)

diff --git a/slirp/misc.h b/slirp/misc.h
index 64ca88c3b7..94829722cd 100644
--- a/slirp/misc.h
+++ b/slirp/misc.h
@@ -26,7 +26,6 @@ struct ex_list {
 #define EMU_REALAUDIO 0x5
 #define EMU_RLOGIN 0x6
 #define EMU_IDENT 0x7
-#define EMU_RSH 0x8
 
 #define EMU_NOCONNECT 0x10 /* Don't connect */
 
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 0de46084c0..fac7849195 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1499,8 +1499,6 @@ static int slirp_state_load(QEMUFile *f, void *opaque, 
int version_id)
 }
 if (!ex_ptr)
 return -EINVAL;
-
-so->extra = (void *)ex_ptr->ex_exec;
 }
 
 return vmstate_load_state(f, &vmstate_slirp, slirp, version_id);
diff --git a/slirp/socket.c b/slirp/socket.c
index c01d8696af..041ec5061a 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -89,10 +89,6 @@ sofree(struct socket *so)
   soqfree(so, &slirp->if_fastq);
   soqfree(so, &slirp->if_batchq);
 
-  if (so->so_emu==EMU_RSH && so->extra) {
-   sofree(so->extra);
-   so->extra=NULL;
-  }
   if (so == slirp->tcp_last_so) {
   slirp->tcp_last_so = &slirp->tcb;
   } else if (so == slirp->udp_last_so) {
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index e7b2baa087..fd7521854e 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -541,7 +541,6 @@ static const struct tos_t tcptos[] = {
  {0, 23, IPTOS_LOWDELAY, 0},   /* telnet */
  {0, 80, IPTOS_THROUGHPUT, 0}, /* WWW */
  {0, 513, IPTOS_LOWDELAY, EMU_RLOGIN|EMU_NOCONNECT},   /* rlogin */
- {0, 514, IPTOS_LOWDELAY, EMU_RSH|EMU_NOCONNECT},  /* shell */
  {0, 544, IPTOS_LOWDELAY, EMU_KSH},/* kshell */
  {0, 543, IPTOS_LOWDELAY, 0},  /* klogin */
  {0, 6667, IPTOS_THROUGHPUT, EMU_IRC}, /* IRC */
-- 
2.20.1




[Qemu-devel] [PULL 01/65] slirp: associate slirp_output callback with the Slirp context

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Let's make the slirp interface a bit more library-like.
Associate the slirp_output() with a Slirp context.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 net/slirp.c  |  5 +++--
 slirp/libslirp.h |  9 +
 slirp/ncsi.c |  2 +-
 slirp/slirp.c| 11 +++
 slirp/slirp.h|  1 +
 5 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index 38ae65e4a9..dd06b0189e 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -99,7 +99,7 @@ static void slirp_smb_cleanup(SlirpState *s);
 static inline void slirp_smb_cleanup(SlirpState *s) { }
 #endif
 
-void slirp_output(void *opaque, const uint8_t *pkt, int pkt_len)
+static void net_slirp_output(void *opaque, const uint8_t *pkt, int pkt_len)
 {
 SlirpState *s = opaque;
 
@@ -378,7 +378,8 @@ static int net_slirp_init(NetClientState *peer, const char 
*model,
   ipv6, ip6_prefix, vprefix6_len, ip6_host,
   vhostname, tftp_server_name,
   tftp_export, bootfile, dhcp,
-  dns, ip6_dns, dnssearch, vdomainname, s);
+  dns, ip6_dns, dnssearch, vdomainname,
+  net_slirp_output, s);
 QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
 
 for (config = slirp_configs; config; config = config->next) {
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 42e42e9a2a..52dbb9feb5 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -5,6 +5,8 @@
 
 typedef struct Slirp Slirp;
 
+typedef void (*slirp_output)(void *opaque, const uint8_t *pkt, int pkt_len);
+
 int get_dns_addr(struct in_addr *pdns_addr);
 int get_dns6_addr(struct in6_addr *pdns6_addr, uint32_t *scope_id);
 
@@ -17,7 +19,9 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct 
in_addr vnetwork,
   const char *tftp_path, const char *bootfile,
   struct in_addr vdhcp_start, struct in_addr vnameserver,
   struct in6_addr vnameserver6, const char **vdnssearch,
-  const char *vdomainname, void *opaque);
+  const char *vdomainname,
+  slirp_output output,
+  void *opaque);
 void slirp_cleanup(Slirp *slirp);
 
 void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout);
@@ -26,9 +30,6 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error);
 
 void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len);
 
-/* you must provide the following functions: */
-void slirp_output(void *opaque, const uint8_t *pkt, int pkt_len);
-
 int slirp_add_hostfwd(Slirp *slirp, int is_udp,
   struct in_addr host_addr, int host_port,
   struct in_addr guest_addr, int guest_port);
diff --git a/slirp/ncsi.c b/slirp/ncsi.c
index 7116034afc..d7701f7785 100644
--- a/slirp/ncsi.c
+++ b/slirp/ncsi.c
@@ -163,5 +163,5 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int 
pkt_len)
 *pchecksum = htonl(checksum);
 ncsi_rsp_len += 4;
 
-slirp_output(slirp->opaque, ncsi_reply, ETH_HLEN + ncsi_rsp_len);
+slirp->output(slirp->opaque, ncsi_reply, ETH_HLEN + ncsi_rsp_len);
 }
diff --git a/slirp/slirp.c b/slirp/slirp.c
index ab2fc4eb8b..4d4c2c13b5 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -287,12 +287,15 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct 
in_addr vnetwork,
   const char *tftp_path, const char *bootfile,
   struct in_addr vdhcp_start, struct in_addr vnameserver,
   struct in6_addr vnameserver6, const char **vdnssearch,
-  const char *vdomainname, void *opaque)
+  const char *vdomainname,
+  slirp_output output,
+  void *opaque)
 {
 Slirp *slirp = g_malloc0(sizeof(Slirp));
 
 slirp_init_once();
 
+slirp->output = output;
 slirp->grand = g_rand_new();
 slirp->restricted = restricted;
 
@@ -832,7 +835,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int 
pkt_len)
 rah->ar_sip = ah->ar_tip;
 memcpy(rah->ar_tha, ah->ar_sha, ETH_ALEN);
 rah->ar_tip = ah->ar_sip;
-slirp_output(slirp->opaque, arp_reply, sizeof(arp_reply));
+slirp->output(slirp->opaque, arp_reply, sizeof(arp_reply));
 }
 break;
 case ARPOP_REPLY:
@@ -932,7 +935,7 @@ static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct 
ethhdr *eh,
 /* target IP */
 rah->ar_tip = iph->ip_dst.s_addr;
 slirp->client_ipaddr = iph->ip_dst;
-slirp_output(slirp->opaque, arp_req, sizeof(arp_req));
+slirp->output(slirp->opaque, arp_req, sizeof(arp_req));
 ifm->resolution_requested = true;
 
 /* Expire request and drop outgoing packet after 1 second */
@@ -1018,7 +1021,7 @@ int if_encap(Slirp *slirp, struct mbuf *ifm)
 eh->h_dest[0], eh->h_dest

[Qemu-devel] [PULL 14/65] slirp: remove unused M_TRAILINGSPACE

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/mbuf.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/slirp/mbuf.h b/slirp/mbuf.h
index bfdf8c4577..cbf17e136b 100644
--- a/slirp/mbuf.h
+++ b/slirp/mbuf.h
@@ -72,7 +72,6 @@
  * How much free room there is
  */
 #define M_FREEROOM(m) (M_ROOM(m) - (m)->m_len)
-#define M_TRAILINGSPACE M_FREEROOM
 
 struct mbuf {
/* XXX should union some of these! */
-- 
2.20.1




[Qemu-devel] [PULL 12/65] slirp: add tftp tracing

2019-01-13 Thread Samuel Thibault
From: Gerd Hoffmann 

Useful when debugging pxeboot, to see what the guest tries to do.

Signed-off-by: Gerd Hoffmann 
Reviewed-by: Liam Merwick 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Signed-off-by: Samuel Thibault 
---
 Makefile.objs  | 1 +
 slirp/tftp.c   | 3 +++
 slirp/trace-events | 5 +
 3 files changed, 9 insertions(+)
 create mode 100644 slirp/trace-events

diff --git a/Makefile.objs b/Makefile.objs
index 456115992a..2121120492 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -193,6 +193,7 @@ trace-events-subdirs += net
 trace-events-subdirs += qapi
 trace-events-subdirs += qom
 trace-events-subdirs += scsi
+trace-events-subdirs += slirp
 trace-events-subdirs += target/arm
 trace-events-subdirs += target/i386
 trace-events-subdirs += target/mips
diff --git a/slirp/tftp.c b/slirp/tftp.c
index a9bc4bb1b6..735b57aa55 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -26,6 +26,7 @@
 #include "slirp.h"
 #include "qemu-common.h"
 #include "qemu/cutils.h"
+#include "trace.h"
 
 static inline int tftp_session_in_use(struct tftp_session *spt)
 {
@@ -204,6 +205,7 @@ static void tftp_send_error(struct tftp_session *spt,
   struct mbuf *m;
   struct tftp_t *tp;
 
+  trace_slirp_tftp_error(msg);
   m = m_get(spt->slirp);
 
   if (!m) {
@@ -323,6 +325,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct 
sockaddr_storage *srcsas,
   break;
 }
   }
+  trace_slirp_tftp_rrq(req_fname);
 
   /* check mode */
   if ((pktlen - k) < 6) {
diff --git a/slirp/trace-events b/slirp/trace-events
new file mode 100644
index 00..ff8f656e8c
--- /dev/null
+++ b/slirp/trace-events
@@ -0,0 +1,5 @@
+# See docs/devel/tracing.txt for syntax documentation.
+
+# slirp/tftp.c
+slirp_tftp_rrq(const char *file) "file: %s"
+slirp_tftp_error(const char *file) "msg: %s"
-- 
2.20.1




[Qemu-devel] [PULL 10/65] slirp: replace the poor-man string split with g_strsplit()

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Use the glib function for the work, fix a potential crash on >256 words.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/misc.c | 21 +++--
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index ce323ef92e..4840187750 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -88,11 +88,8 @@ fork_exec(struct socket *so, const char *ex)
socklen_t addrlen = sizeof(addr);
 socklen_t csaddrlen = sizeof(csaddr);
int opt;
-   const char *argv[256];
-   /* don't want to clobber the original */
-   char *bptr;
-   const char *curarg;
-   int c, i, ret;
+   char **argv;
+   int ret;
pid_t pid;
 
DEBUG_CALL("fork_exec");
@@ -156,19 +153,7 @@ fork_exec(struct socket *so, const char *ex)
for (s = getdtablesize() - 1; s >= 3; s--)
   close(s);
 
-   i = 0;
-   bptr = g_strdup(ex); /* No need to free() this */
-do {
-   /* Change the string into argv[] */
-   curarg = bptr;
-   while (*bptr != ' ' && *bptr != (char)0)
-  bptr++;
-   c = *bptr;
-   *bptr++ = (char)0;
-   argv[i++] = g_strdup(curarg);
-} while (c);
-
-argv[i] = NULL;
+argv = g_strsplit(ex, " ", -1);
execvp(argv[0], (char **)argv);
 
/* Ooops, failed, let's tell the user why */
-- 
2.20.1




[Qemu-devel] [PULL 15/65] slirp: use a callback structure to interface with qemu

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

This will bring slirp a bit forward to the state of an independent
project.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Samuel Thibault 
---
 net/slirp.c  |  6 +-
 slirp/libslirp.h | 13 +++--
 slirp/ncsi.c |  2 +-
 slirp/slirp.c| 10 +-
 slirp/slirp.h|  2 +-
 5 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index b7319ca6b2..031c324f02 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -140,6 +140,10 @@ static NetClientInfo net_slirp_info = {
 .cleanup = net_slirp_cleanup,
 };
 
+static const SlirpCb slirp_cb = {
+.output = net_slirp_output,
+};
+
 static int net_slirp_init(NetClientState *peer, const char *model,
   const char *name, int restricted,
   bool ipv4, const char *vnetwork, const char *vhost,
@@ -379,7 +383,7 @@ static int net_slirp_init(NetClientState *peer, const char 
*model,
   vhostname, tftp_server_name,
   tftp_export, bootfile, dhcp,
   dns, ip6_dns, dnssearch, vdomainname,
-  net_slirp_output, s);
+  &slirp_cb, s);
 QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
 
 for (config = slirp_configs; config; config = config->next) {
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 04b6db9f49..a5d1b27b5e 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -5,7 +5,16 @@
 
 typedef struct Slirp Slirp;
 
-typedef void (*slirp_output)(void *opaque, const uint8_t *pkt, int pkt_len);
+/*
+ * Callbacks from slirp
+ *
+ * The opaque parameter comes from the opaque parameter given to slirp_init().
+ */
+typedef struct SlirpCb {
+/* Send an ethernet frame to the guest network.  */
+void (*output)(void *opaque, const uint8_t *pkt, int pkt_len);
+} SlirpCb;
+
 
 Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork,
   struct in_addr vnetmask, struct in_addr vhost,
@@ -17,7 +26,7 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct 
in_addr vnetwork,
   struct in_addr vdhcp_start, struct in_addr vnameserver,
   struct in6_addr vnameserver6, const char **vdnssearch,
   const char *vdomainname,
-  slirp_output output,
+  const SlirpCb *callbacks,
   void *opaque);
 void slirp_cleanup(Slirp *slirp);
 
diff --git a/slirp/ncsi.c b/slirp/ncsi.c
index d7701f7785..10decfb5ef 100644
--- a/slirp/ncsi.c
+++ b/slirp/ncsi.c
@@ -163,5 +163,5 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int 
pkt_len)
 *pchecksum = htonl(checksum);
 ncsi_rsp_len += 4;
 
-slirp->output(slirp->opaque, ncsi_reply, ETH_HLEN + ncsi_rsp_len);
+slirp->cb->output(slirp->opaque, ncsi_reply, ETH_HLEN + ncsi_rsp_len);
 }
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 1627436e7d..bab49e83e3 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -288,14 +288,14 @@ Slirp *slirp_init(int restricted, bool in_enabled, struct 
in_addr vnetwork,
   struct in_addr vdhcp_start, struct in_addr vnameserver,
   struct in6_addr vnameserver6, const char **vdnssearch,
   const char *vdomainname,
-  slirp_output output,
+  const SlirpCb *callbacks,
   void *opaque)
 {
 Slirp *slirp = g_malloc0(sizeof(Slirp));
 
 slirp_init_once();
 
-slirp->output = output;
+slirp->cb = callbacks;
 slirp->grand = g_rand_new();
 slirp->restricted = restricted;
 
@@ -843,7 +843,7 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int 
pkt_len)
 rah->ar_sip = ah->ar_tip;
 memcpy(rah->ar_tha, ah->ar_sha, ETH_ALEN);
 rah->ar_tip = ah->ar_sip;
-slirp->output(slirp->opaque, arp_reply, sizeof(arp_reply));
+slirp->cb->output(slirp->opaque, arp_reply, sizeof(arp_reply));
 }
 break;
 case ARPOP_REPLY:
@@ -943,7 +943,7 @@ static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct 
ethhdr *eh,
 /* target IP */
 rah->ar_tip = iph->ip_dst.s_addr;
 slirp->client_ipaddr = iph->ip_dst;
-slirp->output(slirp->opaque, arp_req, sizeof(arp_req));
+slirp->cb->output(slirp->opaque, arp_req, sizeof(arp_req));
 ifm->resolution_requested = true;
 
 /* Expire request and drop outgoing packet after 1 second */
@@ -1029,7 +1029,7 @@ int if_encap(Slirp *slirp, struct mbuf *ifm)
 eh->h_dest[0], eh->h_dest[1], eh->h_dest[2],
 eh->h_dest[3], eh->h_dest[4], eh->h_dest[5]));
 memcpy(buf + sizeof(struct ethhdr), ifm->m_data, ifm->m_len);
-slirp->output(slirp->opaque, buf, ifm->m_len + ETH_HLEN);
+slirp->cb->output(slirp->opaque, buf, ifm->m_len + ETH_HLEN);
 return 1;
 }
 
diff --git a/slirp

[Qemu-devel] [PULL 13/65] slirp: move socket pair creation in helper function

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Originally, the patch was fixing a bunch of issues, but Peter beat me
to it with earlier commit "slirp: fork_exec(): create and connect
child socket before fork()".

Factor out socket pair creation, to simplify the fork_exec() code.
Use the name socketpair_with_oob() since the code is actually similar
to what socketpair() would do, except that it uses TCP sockets, for
SLIRP to be able to call send with MSG_OOB (since SO_OOBINLINE is set,
this could probably be faked instead on regular unix sockets though).

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/misc.c | 142 +--
 1 file changed, 71 insertions(+), 71 deletions(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index 4840187750..7362e14339 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -73,85 +73,92 @@ fork_exec(struct socket *so, const char *ex)
 
 #else
 
-/*
- * XXX This is ugly
- * We create and bind a socket, then fork off to another
- * process, which connects to this socket, after which we
- * exec the wanted program.  If something (strange) happens,
- * the accept() call could block us forever.
- */
+static int
+slirp_socketpair_with_oob(int sv[2])
+{
+struct sockaddr_in addr = {
+.sin_family = AF_INET,
+.sin_port = 0,
+.sin_addr.s_addr = INADDR_ANY,
+};
+socklen_t addrlen = sizeof(addr);
+int ret, s;
+
+sv[1] = -1;
+s = qemu_socket(AF_INET, SOCK_STREAM, 0);
+if (s < 0 || bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
+listen(s, 1) < 0 ||
+getsockname(s, (struct sockaddr *)&addr, &addrlen) < 0) {
+goto err;
+}
+
+sv[1] = qemu_socket(AF_INET, SOCK_STREAM, 0);
+if (sv[1] < 0) {
+goto err;
+}
+/*
+ * This connect won't block because we've already listen()ed on
+ * the server end (even though we won't accept() the connection
+ * until later on).
+ */
+do {
+ret = connect(sv[1], (struct sockaddr *)&addr, addrlen);
+} while (ret < 0 && errno == EINTR);
+if (ret < 0) {
+goto err;
+}
+
+do {
+sv[0] = accept(s, (struct sockaddr *)&addr, &addrlen);
+} while (sv[0] < 0 && errno == EINTR);
+if (sv[0] < 0) {
+goto err;
+}
+
+closesocket(s);
+return 0;
+
+err:
+error_report("Error: slirp_socketpair(): %s", strerror(errno));
+if (s >= 0) {
+closesocket(s);
+}
+if (sv[1] >= 0) {
+closesocket(sv[1]);
+}
+return -1;
+}
+
 int
 fork_exec(struct socket *so, const char *ex)
 {
-int s, cs;
-struct sockaddr_in addr, csaddr;
-   socklen_t addrlen = sizeof(addr);
-socklen_t csaddrlen = sizeof(csaddr);
-   int opt;
char **argv;
-   int ret;
+   int opt, c, sp[2];
pid_t pid;
 
DEBUG_CALL("fork_exec");
DEBUG_ARG("so = %p", so);
DEBUG_ARG("ex = %p", ex);
 
-addr.sin_family = AF_INET;
-addr.sin_port = 0;
-addr.sin_addr.s_addr = INADDR_ANY;
-
-s = qemu_socket(AF_INET, SOCK_STREAM, 0);
-if (s < 0 || bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
-listen(s, 1) < 0) {
-error_report("Error: inet socket: %s", strerror(errno));
-if (s >= 0) {
-closesocket(s);
-}
+if (slirp_socketpair_with_oob(sp) < 0) {
 return 0;
 }
 
-if (getsockname(s, (struct sockaddr *)&csaddr, &csaddrlen) < 0) {
-closesocket(s);
-return 0;
-}
-cs = qemu_socket(AF_INET, SOCK_STREAM, 0);
-if (cs < 0) {
-closesocket(s);
-return 0;
-}
-csaddr.sin_addr = loopback_addr;
-/*
- * This connect won't block because we've already listen()ed on
- * the server end (even though we won't accept() the connection
- * until later on).
- */
-do {
-ret = connect(cs, (struct sockaddr *)&csaddr, csaddrlen);
-} while (ret < 0 && errno == EINTR);
-if (ret < 0) {
-closesocket(s);
-closesocket(cs);
-return 0;
-}
-
pid = fork();
switch(pid) {
 case -1:
error_report("Error: fork failed: %s", strerror(errno));
-closesocket(cs);
-   close(s);
+   closesocket(sp[0]);
+   closesocket(sp[1]);
return 0;
 
 case 0:
-setsid();
-
-   /* Set the DISPLAY */
-close(s);
-dup2(cs, 0);
-dup2(cs, 1);
-dup2(cs, 2);
-   for (s = getdtablesize() - 1; s >= 3; s--)
-  close(s);
+   setsid();
+   dup2(sp[1], 0);
+   dup2(sp[1], 1);
+   dup2(sp[1], 2);
+   for (c = getdtablesize() - 1; c >= 3; c--)
+  close(c);
 
 argv = g_strsplit(ex, 

[Qemu-devel] [PULL 21/65] slirp: remove NO_UNIX_SOCKETS

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h| 3 ---
 slirp/slirp_config.h | 6 --
 2 files changed, 9 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 57955a8965..fba77d0c3d 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -28,9 +28,6 @@ typedef char *caddr_t;
 #include 
 #endif
 
-#ifndef NO_UNIX_SOCKETS
-#include 
-#endif
 #ifndef _WIN32
 #include 
 #endif
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index a205dc8c28..4417b05d1c 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -58,9 +58,3 @@
 #ifndef _WIN32
 #define HAVE_INET_ATON
 #endif
-
-/* Define if you DON'T have unix-domain sockets */
-#undef NO_UNIX_SOCKETS
-#ifdef _WIN32
-#define NO_UNIX_SOCKETS
-#endif
-- 
2.20.1




[Qemu-devel] [PULL 19/65] slirp: remove HAVE_SYS_SIGNAL_H

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h| 3 ---
 slirp/slirp_config.h | 3 ---
 2 files changed, 6 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index f7c087456a..4c3c672ee6 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -35,9 +35,6 @@ typedef char *caddr_t;
 #ifndef NO_UNIX_SOCKETS
 #include 
 #endif
-#ifdef HAVE_SYS_SIGNAL_H
-# include 
-#endif
 #ifndef _WIN32
 #include 
 #endif
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 3ce64e088e..2605c4222b 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -50,9 +50,6 @@
 #define HAVE_ARPA_INET_H
 #endif
 
-/* Define if you have sys/signal.h */
-#undef HAVE_SYS_SIGNAL_H
-
 /* Define if you have sys/stropts.h */
 #undef HAVE_SYS_STROPTS_H
 
-- 
2.20.1




[Qemu-devel] [PULL 04/65] slirp: use a dedicated field for chardev pointer

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Let's not mix command line and chardev pointers.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 net/slirp.c  |  8 
 slirp/libslirp.h |  2 +-
 slirp/misc.c | 11 +++
 slirp/misc.h |  4 ++--
 slirp/slirp.c|  5 +++--
 slirp/tcp_subr.c |  2 +-
 6 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index dd06b0189e..58d880de8d 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -709,8 +709,8 @@ static int slirp_smb(SlirpState* s, const char 
*exported_dir,
  CONFIG_SMBD_COMMAND, s->smb_dir, smb_conf);
 g_free(smb_conf);
 
-if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0 ||
-slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 445) < 0) {
+if (slirp_add_exec(s->slirp, NULL, smb_cmdline, &vserver_addr, 139) < 0 ||
+slirp_add_exec(s->slirp, NULL, smb_cmdline, &vserver_addr, 445) < 0) {
 slirp_smb_cleanup(s);
 g_free(smb_cmdline);
 error_setg(errp, "Conflicting/invalid smbserver address");
@@ -774,7 +774,7 @@ static int slirp_guestfwd(SlirpState *s, const char 
*config_str, Error **errp)
 snprintf(buf, sizeof(buf), "guestfwd.tcp.%d", port);
 
 if ((strlen(p) > 4) && !strncmp(p, "cmd:", 4)) {
-if (slirp_add_exec(s->slirp, 0, &p[4], &server, port) < 0) {
+if (slirp_add_exec(s->slirp, NULL, &p[4], &server, port) < 0) {
 error_setg(errp, "Conflicting/invalid host:port in guest "
"forwarding rule '%s'", config_str);
 return -1;
@@ -801,7 +801,7 @@ static int slirp_guestfwd(SlirpState *s, const char 
*config_str, Error **errp)
 return -1;
 }
 
-if (slirp_add_exec(s->slirp, 3, &fwd->hd, &server, port) < 0) {
+if (slirp_add_exec(s->slirp, &fwd->hd, NULL, &server, port) < 0) {
 error_setg(errp, "Conflicting/invalid host:port in guest "
"forwarding rule '%s'", config_str);
 g_free(fwd);
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 52dbb9feb5..3e88dbaa01 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -35,7 +35,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp,
   struct in_addr guest_addr, int guest_port);
 int slirp_remove_hostfwd(Slirp *slirp, int is_udp,
  struct in_addr host_addr, int host_port);
-int slirp_add_exec(Slirp *slirp, int do_pty, const void *args,
+int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline,
struct in_addr *guest_addr, int guest_port);
 
 void slirp_connection_info(Slirp *slirp, Monitor *mon);
diff --git a/slirp/misc.c b/slirp/misc.c
index 8f0b6004bd..2784fc420f 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -37,7 +37,7 @@ remque(void *a)
   element->qh_rlink = NULL;
 }
 
-int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,
+int add_exec(struct ex_list **ex_ptr, void *chardev, const char *cmdline,
  struct in_addr addr, int port)
 {
struct ex_list *tmp_ptr;
@@ -50,11 +50,14 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, char 
*exec,
}
 
tmp_ptr = *ex_ptr;
-   *ex_ptr = g_new(struct ex_list, 1);
+   *ex_ptr = g_new0(struct ex_list, 1);
(*ex_ptr)->ex_fport = port;
(*ex_ptr)->ex_addr = addr;
-   (*ex_ptr)->ex_chardev = do_pty == 3;
-   (*ex_ptr)->ex_exec = (do_pty == 3) ? exec : g_strdup(exec);
+   if (chardev) {
+   (*ex_ptr)->ex_chardev = chardev;
+   } else {
+   (*ex_ptr)->ex_exec = g_strdup(cmdline);
+   }
(*ex_ptr)->ex_next = tmp_ptr;
return 0;
 }
diff --git a/slirp/misc.h b/slirp/misc.h
index 1f8d11def6..64ca88c3b7 100644
--- a/slirp/misc.h
+++ b/slirp/misc.h
@@ -9,7 +9,7 @@
 #define MISC_H
 
 struct ex_list {
-   int ex_chardev;
+   void *ex_chardev;
struct in_addr ex_addr; /* Server address */
int ex_fport;   /* Port to telnet to */
const char *ex_exec;/* Command line of what to exec */
@@ -52,7 +52,7 @@ struct slirp_quehead {
 
 void slirp_insque(void *, void *);
 void slirp_remque(void *);
-int add_exec(struct ex_list **, int, char *, struct in_addr, int);
+int add_exec(struct ex_list **, void *, const char *, struct in_addr, int);
 int fork_exec(struct socket *so, const char *ex);
 
 #endif
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 0498a092b9..0de46084c0 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1068,7 +1068,7 @@ int slirp_add_hostfwd(Slirp *slirp, int is_udp, struct 
in_addr host_addr,
 return 0;
 }
 
-int slirp_add_exec(Slirp *slirp, int do_pty, const void *args,
+int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline,
struct in_addr *guest_addr, int guest_port)
 {
 if (!guest_addr->s_addr) {
@@ -1081,7 +1081,8 @@ int slirp_add_exec(Slirp *slirp, int do_pty, const void 
*args,
   

[Qemu-devel] [PULL 32/65] slirp: replace compile time DO_KEEPALIVE

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Use a global variable instead (similar to slirp_debug)

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.c|  3 +++
 slirp/slirp.h|  6 +++---
 slirp/slirp_config.h | 12 
 slirp/tcp_input.c|  2 +-
 slirp/tcp_timer.c|  2 +-
 5 files changed, 8 insertions(+), 17 deletions(-)
 delete mode 100644 slirp/slirp_config.h

diff --git a/slirp/slirp.c b/slirp/slirp.c
index 76e94eb1cd..f11f9e9e51 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -35,6 +35,9 @@
 #include 
 #endif
 
+/* Define to 1 if you want KEEPALIVE timers */
+bool slirp_do_keepalive;
+
 /* host loopback address */
 struct in_addr loopback_addr;
 /* host loopback network mask */
diff --git a/slirp/slirp.h b/slirp/slirp.h
index 4a046e..05c203c8c7 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -1,8 +1,6 @@
 #ifndef SLIRP_H
 #define SLIRP_H
 
-#include "slirp_config.h"
-
 #ifdef _WIN32
 
 typedef char *caddr_t;
@@ -219,7 +217,9 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int 
pkt_len);
 #include 
 #endif
 
-#define SO_OPTIONS DO_KEEPALIVE
+
+extern bool slirp_do_keepalive;
+
 #define TCP_MAXIDLE (TCPTV_KEEPCNT * TCPTV_KEEPINTVL)
 
 /* dnssearch.c */
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
deleted file mode 100644
index 7147e0de04..00
--- a/slirp/slirp_config.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * User definable configuration options
- */
-
-/* Define to 1 if you want KEEPALIVE timers */
-#define DO_KEEPALIVE 0
-
-/*/
-/*
- * Autoconf defined configuration options
- * You shouldn't need to touch any of these
- */
diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c
index 09bdf9b482..6af63469da 100644
--- a/slirp/tcp_input.c
+++ b/slirp/tcp_input.c
@@ -481,7 +481,7 @@ findso:
 * Reset idle time and keep-alive timer.
 */
tp->t_idle = 0;
-   if (SO_OPTIONS)
+   if (slirp_do_keepalive)
   tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;
else
   tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE;
diff --git a/slirp/tcp_timer.c b/slirp/tcp_timer.c
index dc8288b511..a843e57a2b 100644
--- a/slirp/tcp_timer.c
+++ b/slirp/tcp_timer.c
@@ -262,7 +262,7 @@ tcp_timers(register struct tcpcb *tp, int timer)
if (tp->t_state < TCPS_ESTABLISHED)
goto dropit;
 
-   if ((SO_OPTIONS) && tp->t_state <= TCPS_CLOSE_WAIT) {
+   if (slirp_do_keepalive && tp->t_state <= TCPS_CLOSE_WAIT) {
if (tp->t_idle >= TCPTV_KEEP_IDLE + TCP_MAXIDLE)
goto dropit;
/*
-- 
2.20.1




[Qemu-devel] [PULL 18/65] slirp: remove the disabled readv()/writev() code path

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

The soread() function may be used on datagram sockets, and would
provide different behaviour if HAVE_READV was set, on empty datagrams.
This looks like a minor optimization, that never has been a strong
goal for slirp.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp_config.h |  3 ---
 slirp/socket.c   | 15 ---
 2 files changed, 18 deletions(-)

diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index f0cc1c781b..3ce64e088e 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -29,9 +29,6 @@
 /* Define if the machine is big endian */
 //#undef HOST_WORDS_BIGENDIAN
 
-/* Define if you have readv */
-#undef HAVE_READV
-
 /* Define if iovec needs to be declared */
 #undef DECLARE_IOVEC
 #ifdef _WIN32
diff --git a/slirp/socket.c b/slirp/socket.c
index 041ec5061a..7012c7c07d 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -187,12 +187,7 @@ soread(struct socket *so)
 */
sopreprbuf(so, iov, &n);
 
-#ifdef HAVE_READV
-   nn = readv(so->s, (struct iovec *)iov, n);
-   DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
-#else
nn = qemu_recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
-#endif
if (nn <= 0) {
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
return 0;
@@ -226,7 +221,6 @@ soread(struct socket *so)
}
}
 
-#ifndef HAVE_READV
/*
 * If there was no error, try and read the second time round
 * We read again if n = 2 (ie, there's another part of the buffer)
@@ -244,7 +238,6 @@ soread(struct socket *so)
 }
 
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
-#endif
 
/* Update fields */
sb->sb_cc += nn;
@@ -452,13 +445,7 @@ sowrite(struct socket *so)
}
/* Check if there's urgent data to send, and if so, send it */
 
-#ifdef HAVE_READV
-   nn = writev(so->s, (const struct iovec *)iov, n);
-
-   DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
-#else
nn = slirp_send(so, iov[0].iov_base, iov[0].iov_len,0);
-#endif
/* This should never happen, but people tell me it does *shrug* */
if (nn < 0 && (errno == EAGAIN || errno == EINTR))
return 0;
@@ -467,7 +454,6 @@ sowrite(struct socket *so)
goto err_disconnected;
}
 
-#ifndef HAVE_READV
if (n == 2 && nn == iov[0].iov_len) {
 int ret;
 ret = slirp_send(so, iov[1].iov_base, iov[1].iov_len,0);
@@ -475,7 +461,6 @@ sowrite(struct socket *so)
 nn += ret;
 }
 DEBUG_MISC((dfd, "  ... wrote nn = %d bytes\n", nn));
-#endif
 
/* Update sbuf */
sb->sb_cc -= nn;
-- 
2.20.1




[Qemu-devel] [PULL 24/65] slirp: remove unused HAVE_SYS_WAIT_H

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h| 4 
 slirp/slirp_config.h | 3 ---
 2 files changed, 7 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 400f585cec..1f47848271 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -40,10 +40,6 @@ typedef char *caddr_t;
 # include 
 #endif
 
-#ifdef HAVE_SYS_WAIT_H
-# include 
-#endif
-
 #ifdef HAVE_SYS_FILIO_H
 # include 
 #endif
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index e95284071a..9becb98e11 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -32,9 +32,6 @@
 #define DECLARE_IOVEC
 #endif
 
-/* Define if you have a POSIX.1 sys/wait.h */
-#undef HAVE_SYS_WAIT_H
-
 /* Define if you have sys/select.h */
 #undef HAVE_SYS_SELECT_H
 #ifndef _WIN32
-- 
2.20.1




[Qemu-devel] [PULL 20/65] slirp: remove unused HAVE_SYS_BITYPES_H

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h| 4 
 slirp/slirp_config.h | 3 ---
 2 files changed, 7 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 4c3c672ee6..57955a8965 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -19,10 +19,6 @@ typedef char *caddr_t;
 # endif
 #endif
 
-#ifdef HAVE_SYS_BITYPES_H
-# include 
-#endif
-
 #ifndef _WIN32
 #include 
 #endif
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 2605c4222b..a205dc8c28 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -23,9 +23,6 @@
 #define HAVE_SYS_FILIO_H
 #endif
 
-/* Define if you have sys/bitypes.h */
-#undef HAVE_SYS_BITYPES_H
-
 /* Define if the machine is big endian */
 //#undef HOST_WORDS_BIGENDIAN
 
-- 
2.20.1




[Qemu-devel] [PULL 08/65] slirp: remove Monitor dependency, return a string for info

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

There is nothing performance-sensitive in returning an allocated
string for info, and handling the monitor_printf() on the caller side.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 net/slirp.c  |  7 ---
 slirp/libslirp.h |  2 +-
 slirp/misc.c | 23 +--
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index 58d880de8d..b7319ca6b2 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -828,10 +828,11 @@ void hmp_info_usernet(Monitor *mon, const QDict *qdict)
 QTAILQ_FOREACH(s, &slirp_stacks, entry) {
 int id;
 bool got_hub_id = net_hub_id_for_client(&s->nc, &id) == 0;
-monitor_printf(mon, "Hub %d (%s):\n",
+char *info = slirp_connection_info(s->slirp);
+monitor_printf(mon, "Hub %d (%s):\n%s",
got_hub_id ? id : -1,
-   s->nc.name);
-slirp_connection_info(s->slirp, mon);
+   s->nc.name, info);
+g_free(info);
 }
 }
 
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index a4f390ee89..04b6db9f49 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -35,7 +35,7 @@ int slirp_remove_hostfwd(Slirp *slirp, int is_udp,
 int slirp_add_exec(Slirp *slirp, void *chardev, const char *cmdline,
struct in_addr *guest_addr, int guest_port);
 
-void slirp_connection_info(Slirp *slirp, Monitor *mon);
+char *slirp_connection_info(Slirp *slirp);
 
 void slirp_socket_recv(Slirp *slirp, struct in_addr guest_addr,
int guest_port, const uint8_t *buf, int size);
diff --git a/slirp/misc.c b/slirp/misc.c
index 2784fc420f..ce323ef92e 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -8,7 +8,6 @@
 #include "qemu/osdep.h"
 #include "slirp.h"
 #include "libslirp.h"
-#include "monitor/monitor.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 
@@ -198,8 +197,9 @@ fork_exec(struct socket *so, const char *ex)
 }
 #endif
 
-void slirp_connection_info(Slirp *slirp, Monitor *mon)
+char *slirp_connection_info(Slirp *slirp)
 {
+GString *str = g_string_new(NULL);
 const char * const tcpstates[] = {
 [TCPS_CLOSED]   = "CLOSED",
 [TCPS_LISTEN]   = "LISTEN",
@@ -221,8 +221,9 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
 const char *state;
 char buf[20];
 
-monitor_printf(mon, "  Protocol[State]FD  Source Address  Port   "
-"Dest. Address  Port RecvQ SendQ\n");
+g_string_append_printf(str,
+"  Protocol[State]FD  Source Address  Port   "
+"Dest. Address  Port RecvQ SendQ\n");
 
 for (so = slirp->tcb.so_next; so != &slirp->tcb; so = so->so_next) {
 if (so->so_state & SS_HOSTFWD) {
@@ -244,10 +245,10 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
 dst_port = so->so_fport;
 }
 snprintf(buf, sizeof(buf), "  TCP[%s]", state);
-monitor_printf(mon, "%-19s %3d %15s %5d ", buf, so->s,
+g_string_append_printf(str, "%-19s %3d %15s %5d ", buf, so->s,
src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*",
ntohs(src.sin_port));
-monitor_printf(mon, "%15s %5d %5d %5d\n",
+g_string_append_printf(str, "%15s %5d %5d %5d\n",
inet_ntoa(dst_addr), ntohs(dst_port),
so->so_rcv.sb_cc, so->so_snd.sb_cc);
 }
@@ -267,10 +268,10 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
 dst_addr = so->so_faddr;
 dst_port = so->so_fport;
 }
-monitor_printf(mon, "%-19s %3d %15s %5d ", buf, so->s,
+g_string_append_printf(str, "%-19s %3d %15s %5d ", buf, so->s,
src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*",
ntohs(src.sin_port));
-monitor_printf(mon, "%15s %5d %5d %5d\n",
+g_string_append_printf(str, "%15s %5d %5d %5d\n",
inet_ntoa(dst_addr), ntohs(dst_port),
so->so_rcv.sb_cc, so->so_snd.sb_cc);
 }
@@ -280,9 +281,11 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon)
  (so->so_expire - curtime) / 1000);
 src.sin_addr = so->so_laddr;
 dst_addr = so->so_faddr;
-monitor_printf(mon, "%-19s %3d %15s  -", buf, so->s,
+g_string_append_printf(str, "%-19s %3d %15s  -", buf, so->s,
src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*");
-monitor_printf(mon, "%15s  -%5d %5d\n", inet_ntoa(dst_addr),
+g_string_append_printf(str, "%15s  -%5d %5d\n", 
inet_ntoa(dst_addr),
so->so_rcv.sb_cc, so->so_snd.sb_cc);
 }
+
+return g_string_free(str, FALSE);
 }
-- 
2.20.1




[Qemu-devel] [PULL 28/65] slirp: remove unused DECLARE_IOVEC

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

It's actually qemu configure CONFIG_IOVEC that is being used.

slirp/ does not use it anyway

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp_config.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index f1ee927c15..833f25a965 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -14,12 +14,6 @@
 /* Define if the machine is big endian */
 //#undef HOST_WORDS_BIGENDIAN
 
-/* Define if iovec needs to be declared */
-#undef DECLARE_IOVEC
-#ifdef _WIN32
-#define DECLARE_IOVEC
-#endif
-
 /* Define to sizeof(char *) */
 #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
 
-- 
2.20.1




[Qemu-devel] [PULL 31/65] slirp: replace SIZEOF_CHAR_P with glib equivalent

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Samuel Thibault 
---
 slirp/ip.h   | 2 +-
 slirp/slirp_config.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/slirp/ip.h b/slirp/ip.h
index 83fc9cdfbf..243b6c8b24 100644
--- a/slirp/ip.h
+++ b/slirp/ip.h
@@ -177,7 +177,7 @@ struct  ip_timestamp {
 
 #defineIP_MSS  576 /* default maximum segment size 
*/
 
-#if SIZEOF_CHAR_P == 4
+#if GLIB_SIZEOF_VOID_P == 4
 struct mbuf_ptr {
struct mbuf *mptr;
uint32_t dummy;
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index b2def6d20c..7147e0de04 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -10,6 +10,3 @@
  * Autoconf defined configuration options
  * You shouldn't need to touch any of these
  */
-
-/* Define to sizeof(char *) */
-#define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
-- 
2.20.1




[Qemu-devel] [PULL 30/65] slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

One more step towards making the project independent from QEMU.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/ip.h   | 8 +---
 slirp/ip6.h  | 3 ++-
 slirp/ip6_icmp.h | 6 +++---
 slirp/slirp_config.h | 3 ---
 slirp/tcp.h  | 4 +++-
 5 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/slirp/ip.h b/slirp/ip.h
index 59cf4aa918..83fc9cdfbf 100644
--- a/slirp/ip.h
+++ b/slirp/ip.h
@@ -33,7 +33,9 @@
 #ifndef IP_H
 #define IP_H
 
-#ifdef HOST_WORDS_BIGENDIAN
+#include 
+
+#if G_BYTE_ORDER == G_BIG_ENDIAN
 # undef NTOHL
 # undef NTOHS
 # undef HTONL
@@ -69,7 +71,7 @@ typedef uint32_t n_long; /* long as received 
from the net */
  * Structure of an internet header, naked of options.
  */
 struct ip {
-#ifdef HOST_WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
uint8_t ip_v:4, /* version */
ip_hl:4;/* header length */
 #else
@@ -135,7 +137,7 @@ struct  ip_timestamp {
uint8_t ipt_code;   /* IPOPT_TS */
uint8_t ipt_len;/* size of structure (variable) */
uint8_t ipt_ptr;/* index of current entry */
-#ifdef HOST_WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
uint8_t ipt_oflw:4, /* overflow counter */
ipt_flg:4;  /* flags, see below */
 #else
diff --git a/slirp/ip6.h b/slirp/ip6.h
index b1bea43b3c..14e9c78735 100644
--- a/slirp/ip6.h
+++ b/slirp/ip6.h
@@ -6,6 +6,7 @@
 #ifndef SLIRP_IP6_H
 #define SLIRP_IP6_H
 
+#include 
 #include "net/eth.h"
 
 #define ALLNODES_MULTICAST  { .s6_addr = \
@@ -113,7 +114,7 @@ static inline void in6_compute_ethaddr(struct in6_addr ip,
  * Structure of an internet header, naked of options.
  */
 struct ip6 {
-#ifdef HOST_WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
 uint32_t
 ip_v:4, /* version */
 ip_tc_hi:4, /* traffic class */
diff --git a/slirp/ip6_icmp.h b/slirp/ip6_icmp.h
index b3378b17b5..32b0914055 100644
--- a/slirp/ip6_icmp.h
+++ b/slirp/ip6_icmp.h
@@ -34,7 +34,7 @@ struct ndp_rs { /* Router Solicitation Message */
 
 struct ndp_ra { /* Router Advertisement Message */
 uint8_t chl;/* Cur Hop Limit */
-#ifdef HOST_WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
 uint8_t
 M:1,
 O:1,
@@ -56,7 +56,7 @@ struct ndp_ns { /* Neighbor Solicitation Message */
 } QEMU_PACKED;
 
 struct ndp_na { /* Neighbor Advertisement Message */
-#ifdef HOST_WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
 uint32_t
 R:1,/* Router Flag */
 S:1,/* Solicited Flag */
@@ -125,7 +125,7 @@ struct ndpopt {
 #define ndpopt_linklayer ndpopt_body.linklayer_addr
 struct prefixinfo { /* Prefix Information */
 uint8_t prefix_length;
-#ifdef HOST_WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
 uint8_t L:1, A:1, reserved1:6;
 #else
 uint8_t reserved1:6, A:1, L:1;
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 5126711849..b2def6d20c 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -11,8 +11,5 @@
  * You shouldn't need to touch any of these
  */
 
-/* Define if the machine is big endian */
-//#undef HOST_WORDS_BIGENDIAN
-
 /* Define to sizeof(char *) */
 #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
diff --git a/slirp/tcp.h b/slirp/tcp.h
index 174d3d960c..47aaea6c5b 100644
--- a/slirp/tcp.h
+++ b/slirp/tcp.h
@@ -33,6 +33,8 @@
 #ifndef TCP_H
 #define TCP_H
 
+#include 
+
 typedefuint32_t tcp_seq;
 
 #define  PR_SLOWHZ   2   /* 2 slow timeouts per second 
(approx) */
@@ -51,7 +53,7 @@ struct tcphdr {
uint16_t th_dport;  /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
-#ifdef HOST_WORDS_BIGENDIAN
+#if G_BYTE_ORDER == G_BIG_ENDIAN
uint8_t th_off:4,   /* data offset */
th_x2:4;/* (unused) */
 #else
-- 
2.20.1




[Qemu-devel] [PULL 22/65] slirp: remove unused HAVE_SYS_STROPTS_H

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h| 5 -
 slirp/slirp_config.h | 3 ---
 2 files changed, 8 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index fba77d0c3d..400f585cec 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -54,11 +54,6 @@ typedef char *caddr_t;
 #define remque slirp_remque
 #define quehead slirp_quehead
 
-#ifdef HAVE_SYS_STROPTS_H
-#include 
-#endif
-
-
 #include "debug.h"
 
 #include "qemu/queue.h"
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 4417b05d1c..47811e36dc 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -47,9 +47,6 @@
 #define HAVE_ARPA_INET_H
 #endif
 
-/* Define if you have sys/stropts.h */
-#undef HAVE_SYS_STROPTS_H
-
 /* Define to sizeof(char *) */
 #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
 
-- 
2.20.1




[Qemu-devel] [PULL 27/65] slirp: remove HAVE_SYS_FILIO_H

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h| 2 +-
 slirp/slirp_config.h | 6 --
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 226bced429..4a046e 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -36,7 +36,7 @@ typedef char *caddr_t;
 # include 
 #endif
 
-#ifdef HAVE_SYS_FILIO_H
+#ifdef __APPLE__
 # include 
 #endif
 
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 0e78e92d94..f1ee927c15 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -11,12 +11,6 @@
  * You shouldn't need to touch any of these
  */
 
-/* Define if you have sys/filio.h */
-#undef HAVE_SYS_FILIO_H
-#ifdef __APPLE__
-#define HAVE_SYS_FILIO_H
-#endif
-
 /* Define if the machine is big endian */
 //#undef HOST_WORDS_BIGENDIAN
 
-- 
2.20.1




[Qemu-devel] [PULL 41/65] slirp: replace ARRAY_SIZE with G_N_ELEMENTS

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Do not require QEMU macro.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/ncsi.c | 2 +-
 slirp/tftp.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/slirp/ncsi.c b/slirp/ncsi.c
index 10decfb5ef..8594382270 100644
--- a/slirp/ncsi.c
+++ b/slirp/ncsi.c
@@ -128,7 +128,7 @@ void ncsi_input(Slirp *slirp, const uint8_t *pkt, int 
pkt_len)
 memset(reh->h_source, 0xff, ETH_ALEN);
 reh->h_proto = htons(ETH_P_NCSI);
 
-for (i = 0; i < ARRAY_SIZE(ncsi_rsp_handlers); i++) {
+for (i = 0; i < G_N_ELEMENTS(ncsi_rsp_handlers); i++) {
 if (ncsi_rsp_handlers[i].type == nh->type + 0x80) {
 handler = &ncsi_rsp_handlers[i];
 break;
diff --git a/slirp/tftp.c b/slirp/tftp.c
index 735b57aa55..a9ba1480db 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -359,7 +359,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct 
sockaddr_storage *srcsas,
   return;
   }
 
-  while (k < pktlen && nb_options < ARRAY_SIZE(option_name)) {
+  while (k < pktlen && nb_options < G_N_ELEMENTS(option_name)) {
   const char *key, *value;
 
   key = &tp->x.tp_buf[k];
@@ -403,7 +403,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct 
sockaddr_storage *srcsas,
   }
 
   if (nb_options > 0) {
-  assert(nb_options <= ARRAY_SIZE(option_name));
+  assert(nb_options <= G_N_ELEMENTS(option_name));
   tftp_send_oack(spt, option_name, option_value, nb_options, tp);
   return;
   }
-- 
2.20.1




[Qemu-devel] [PULL 37/65] slirp: remove #if notdef dead code

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/ip_input.c  | 200 --
 slirp/tcp_input.c |  39 -
 2 files changed, 239 deletions(-)

diff --git a/slirp/ip_input.c b/slirp/ip_input.c
index 094a807d41..d360620838 100644
--- a/slirp/ip_input.c
+++ b/slirp/ip_input.c
@@ -447,206 +447,6 @@ ip_slowtimo(Slirp *slirp)
 }
 }
 
-/*
- * Do option processing on a datagram,
- * possibly discarding it if bad options are encountered,
- * or forwarding it if source-routed.
- * Returns 1 if packet has been forwarded/freed,
- * 0 if the packet should be processed further.
- */
-
-#ifdef notdef
-
-int
-ip_dooptions(m)
-   struct mbuf *m;
-{
-   register struct ip *ip = mtod(m, struct ip *);
-   register u_char *cp;
-   register struct ip_timestamp *ipt;
-   register struct in_ifaddr *ia;
-   int opt, optlen, cnt, off, code, type, forward = 0;
-   struct in_addr *sin, dst;
-typedef uint32_t n_time;
-   n_time ntime;
-
-   dst = ip->ip_dst;
-   cp = (u_char *)(ip + 1);
-   cnt = (ip->ip_hl << 2) - sizeof (struct ip);
-   for (; cnt > 0; cnt -= optlen, cp += optlen) {
-   opt = cp[IPOPT_OPTVAL];
-   if (opt == IPOPT_EOL)
-   break;
-   if (opt == IPOPT_NOP)
-   optlen = 1;
-   else {
-   optlen = cp[IPOPT_OLEN];
-   if (optlen <= 0 || optlen > cnt) {
-   code = &cp[IPOPT_OLEN] - (u_char *)ip;
-   goto bad;
-   }
-   }
-   switch (opt) {
-
-   default:
-   break;
-
-   /*
-* Source routing with record.
-* Find interface with current destination address.
-* If none on this machine then drop if strictly routed,
-* or do nothing if loosely routed.
-* Record interface address and bring up next address
-* component.  If strictly routed make sure next
-* address is on directly accessible net.
-*/
-   case IPOPT_LSRR:
-   case IPOPT_SSRR:
-   if ((off = cp[IPOPT_OFFSET]) < IPOPT_MINOFF) {
-   code = &cp[IPOPT_OFFSET] - (u_char *)ip;
-   goto bad;
-   }
-   ipaddr.sin_addr = ip->ip_dst;
-   ia = (struct in_ifaddr *)
-   ifa_ifwithaddr((struct sockaddr *)&ipaddr);
-   if (ia == 0) {
-   if (opt == IPOPT_SSRR) {
-   type = ICMP_UNREACH;
-   code = ICMP_UNREACH_SRCFAIL;
-   goto bad;
-   }
-   /*
-* Loose routing, and not at next destination
-* yet; nothing to do except forward.
-*/
-   break;
-   }
-off--; /* 0 origin */
-   if (off > optlen - sizeof(struct in_addr)) {
-   /*
-* End of source route.  Should be for us.
-*/
-   save_rte(cp, ip->ip_src);
-   break;
-   }
-   /*
-* locate outgoing interface
-*/
-   bcopy((caddr_t)(cp + off), (caddr_t)&ipaddr.sin_addr,
-   sizeof(ipaddr.sin_addr));
-   if (opt == IPOPT_SSRR) {
-#defineINA struct in_ifaddr *
-#defineSA  struct sockaddr *
-   if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == 0)
-   ia = (INA)ifa_ifwithnet((SA)&ipaddr);
-   } else
-   ia = ip_rtaddr(ipaddr.sin_addr);
-   if (ia == 0) {
-   type = ICMP_UNREACH;
-   code = ICMP_UNREACH_SRCFAIL;
-   goto bad;
-   }
-   ip->ip_dst = ipaddr.sin_addr;
-   bcopy((caddr_t)&(IA_SIN(ia)->sin_addr),
-   (caddr_t)(cp + off), sizeof(struct in_addr));
-   cp[IPOPT_OFFSET] += sizeof(struct in_addr);
-   /*
-* Let ip_intr's mcast routing check handle mcast pkts
-*/
-   forward = !IN_

[Qemu-devel] [PULL 43/65] glib-compat: add g_spawn_async_with_fds() fallback

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 include/glib-compat.h | 56 +++
 1 file changed, 56 insertions(+)

diff --git a/include/glib-compat.h b/include/glib-compat.h
index fdf95a255d..8a078c5288 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -83,6 +83,62 @@ static inline gboolean g_strv_contains_qemu(const gchar 
*const *strv,
 }
 #define g_strv_contains(a, b) g_strv_contains_qemu(a, b)
 
+#if !GLIB_CHECK_VERSION(2, 58, 0)
+typedef struct QemuGSpawnFds {
+GSpawnChildSetupFunc child_setup;
+gpointer user_data;
+gint stdin_fd;
+gint stdout_fd;
+gint stderr_fd;
+} QemuGSpawnFds;
+
+static inline void
+qemu_gspawn_fds_setup(gpointer user_data)
+{
+QemuGSpawnFds *q = (QemuGSpawnFds *)user_data;
+
+dup2(q->stdin_fd, 0);
+dup2(q->stdout_fd, 1);
+dup2(q->stderr_fd, 2);
+q->child_setup(q->user_data);
+}
+#endif
+
+static inline gboolean
+g_spawn_async_with_fds_qemu(const gchar *working_directory,
+gchar **argv,
+gchar **envp,
+GSpawnFlags flags,
+GSpawnChildSetupFunc child_setup,
+gpointer user_data,
+GPid *child_pid,
+gint stdin_fd,
+gint stdout_fd,
+gint stderr_fd,
+GError **error)
+{
+#if GLIB_CHECK_VERSION(2, 58, 0)
+return g_spawn_async_with_fds(working_directory, argv, envp, flags,
+  child_setup, user_data,
+  child_pid, stdin_fd, stdout_fd, stderr_fd,
+  error);
+#else
+QemuGSpawnFds setup = {
+.child_setup = child_setup,
+.user_data = user_data,
+.stdin_fd = stdin_fd,
+.stdout_fd = stdout_fd,
+.stderr_fd = stderr_fd,
+};
+
+return g_spawn_async(working_directory, argv, envp, flags,
+ qemu_gspawn_fds_setup, &setup,
+ child_pid, error);
+#endif
+}
+
+#define g_spawn_async_with_fds(wd, argv, env, f, c, d, p, ifd, ofd, efd, err) \
+g_spawn_async_with_fds_qemu(wd, argv, env, f, c, d, p, ifd, ofd, efd, err)
 
 #if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0)
 /*
-- 
2.20.1




[Qemu-devel] [PULL 26/65] slirp: remove HAVE_SYS_IOCTL_H

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h| 2 +-
 slirp/slirp_config.h | 6 --
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 7606de962f..226bced429 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -32,7 +32,7 @@ typedef char *caddr_t;
 #include 
 #endif
 
-#if defined(HAVE_SYS_IOCTL_H)
+#ifndef _WIN32
 # include 
 #endif
 
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 68e75f3873..0e78e92d94 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -11,12 +11,6 @@
  * You shouldn't need to touch any of these
  */
 
-/* Define if you have sys/ioctl.h */
-#undef HAVE_SYS_IOCTL_H
-#ifndef _WIN32
-#define HAVE_SYS_IOCTL_H
-#endif
-
 /* Define if you have sys/filio.h */
 #undef HAVE_SYS_FILIO_H
 #ifdef __APPLE__
-- 
2.20.1




[Qemu-devel] [PULL 45/65] slirp: replace error_report() with g_critical()

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Reduce dependency on QEMU. QEMU could use a custom log handler if it
wants to redirect/filter it.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/slirp/misc.c b/slirp/misc.c
index 753b3da25b..b141446319 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -162,7 +162,7 @@ fork_exec(struct socket *so, const char *ex)
 g_strfreev(argv);
 
 if (err) {
-error_report("%s", err->message);
+g_critical("fork_exec: %s", err->message);
 g_error_free(err);
 closesocket(sp[0]);
 closesocket(sp[1]);
-- 
2.20.1




[Qemu-devel] [PULL 16/65] slirp: remove PROBE_CONN dead-code

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Nobody cares for over 14y. Somebody can revert or rewrite if
interested by that.

Signed-off-by: Marc-André Lureau 
Reviewed-by: Philippe Mathieu-Daudé 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.c| 41 -
 slirp/slirp_config.h |  4 
 2 files changed, 45 deletions(-)

diff --git a/slirp/slirp.c b/slirp/slirp.c
index bab49e83e3..76e94eb1cd 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -699,47 +699,6 @@ void slirp_pollfds_poll(GArray *pollfds, int select_error)
 }
 }
 }
-
-/*
- * Probe a still-connecting, non-blocking socket
- * to check if it's still alive
- */
-#ifdef PROBE_CONN
-if (so->so_state & SS_ISFCONNECTING) {
-ret = qemu_recv(so->s, &ret, 0, 0);
-
-if (ret < 0) {
-/* XXX */
-if (errno == EAGAIN || errno == EWOULDBLOCK ||
-errno == EINPROGRESS || errno == ENOTCONN) {
-continue; /* Still connecting, continue */
-}
-
-/* else failed */
-so->so_state &= SS_PERSISTENT_MASK;
-so->so_state |= SS_NOFDREF;
-
-/* tcp_input will take care of it */
-} else {
-ret = send(so->s, &ret, 0, 0);
-if (ret < 0) {
-/* XXX */
-if (errno == EAGAIN || errno == EWOULDBLOCK ||
-errno == EINPROGRESS || errno == ENOTCONN) {
-continue;
-}
-/* else failed */
-so->so_state &= SS_PERSISTENT_MASK;
-so->so_state |= SS_NOFDREF;
-} else {
-so->so_state &= ~SS_ISFCONNECTING;
-}
-
-}
-tcp_input((struct mbuf *)NULL, sizeof(struct ip), so,
-  so->so_ffamily);
-} /* SS_ISFCONNECTING */
-#endif
 }
 
 /*
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index c59f655207..721667e3ef 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -2,10 +2,6 @@
  * User definable configuration options
  */
 
-/* Define if you want the connection to be probed */
-/* XXX Not working yet, so ignore this for now */
-#undef PROBE_CONN
-
 /* Define to 1 if you want KEEPALIVE timers */
 #define DO_KEEPALIVE 0
 
-- 
2.20.1




[Qemu-devel] [PULL 25/65] slirp: remove unused HAVE_SYS_SELECT_H

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/main.h | 4 
 slirp/slirp.h| 4 
 slirp/slirp_config.h | 6 --
 3 files changed, 14 deletions(-)

diff --git a/slirp/main.h b/slirp/main.h
index e04677944f..4bc05fb904 100644
--- a/slirp/main.h
+++ b/slirp/main.h
@@ -8,10 +8,6 @@
 #ifndef SLIRP_MAIN_H
 #define SLIRP_MAIN_H
 
-#ifdef HAVE_SYS_SELECT_H
-#include 
-#endif
-
 extern u_int curtime;
 extern struct in_addr loopback_addr;
 extern unsigned long loopback_mask;
diff --git a/slirp/slirp.h b/slirp/slirp.h
index 1f47848271..7606de962f 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -36,10 +36,6 @@ typedef char *caddr_t;
 # include 
 #endif
 
-#ifdef HAVE_SYS_SELECT_H
-# include 
-#endif
-
 #ifdef HAVE_SYS_FILIO_H
 # include 
 #endif
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index 9becb98e11..68e75f3873 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -32,12 +32,6 @@
 #define DECLARE_IOVEC
 #endif
 
-/* Define if you have sys/select.h */
-#undef HAVE_SYS_SELECT_H
-#ifndef _WIN32
-#define HAVE_SYS_SELECT_H
-#endif
-
 /* Define to sizeof(char *) */
 #define SIZEOF_CHAR_P (HOST_LONG_BITS / 8)
 
-- 
2.20.1




[Qemu-devel] [PULL 33/65] slirp: remove unused global slirp_instance

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/slirp.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 05c203c8c7..d1b6bcefbb 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -199,8 +199,6 @@ struct Slirp {
 void *opaque;
 };
 
-extern Slirp *slirp_instance;
-
 #ifndef NULL
 #define NULL (void *)0
 #endif
-- 
2.20.1




[Qemu-devel] [PULL 38/65] slirp: remove unused sbflush()

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
Reviewed-by: Daniel P. Berrangé 
Signed-off-by: Samuel Thibault 
---
 slirp/sbuf.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/slirp/sbuf.h b/slirp/sbuf.h
index a722ecb629..644c201341 100644
--- a/slirp/sbuf.h
+++ b/slirp/sbuf.h
@@ -8,7 +8,6 @@
 #ifndef SBUF_H
 #define SBUF_H
 
-#define sbflush(sb) sbdrop((sb),(sb)->sb_cc)
 #define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)
 
 struct sbuf {
-- 
2.20.1




[Qemu-devel] [PULL 34/65] slirp: replace error_report() with g_critical()

2019-01-13 Thread Samuel Thibault
From: Marc-André Lureau 

Reduce dependency on QEMU. QEMU could use a custom log handler if it
wants to redirect/filter it.

Signed-off-by: Marc-André Lureau 
Signed-off-by: Samuel Thibault 
---
 slirp/ip6_icmp.c | 2 +-
 slirp/misc.c | 2 +-
 slirp/slirp.c| 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c
index cd1e0b9fe1..3c424df591 100644
--- a/slirp/ip6_icmp.c
+++ b/slirp/ip6_icmp.c
@@ -417,7 +417,7 @@ void icmp6_input(struct mbuf *m)
 icmp6_send_echoreply(m, slirp, ip, icmp);
 } else {
 /* TODO */
-error_report("external icmpv6 not supported yet");
+g_critical("external icmpv6 not supported yet");
 }
 break;
 
diff --git a/slirp/misc.c b/slirp/misc.c
index 7362e14339..ee3492a2ae 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -119,7 +119,7 @@ slirp_socketpair_with_oob(int sv[2])
 return 0;
 
 err:
-error_report("Error: slirp_socketpair(): %s", strerror(errno));
+g_critical("slirp_socketpair(): %s", strerror(errno));
 if (s >= 0) {
 closesocket(s);
 }
diff --git a/slirp/slirp.c b/slirp/slirp.c
index f11f9e9e51..8391d18faf 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1214,8 +1214,8 @@ static int sbuf_tmp_post_load(void *opaque, int version)
 }
 if (tmp->woff >= requested_len ||
 tmp->roff >= requested_len) {
-error_report("invalid sbuf offsets r/w=%u/%u len=%u",
- tmp->roff, tmp->woff, requested_len);
+g_critical("invalid sbuf offsets r/w=%u/%u len=%u",
+   tmp->roff, tmp->woff, requested_len);
 return -EINVAL;
 }
 
@@ -1323,7 +1323,7 @@ static int ss_family_post_load(void *opaque, int 
version_id)
 tss->parent->ss.ss_family = AF_INET6;
 break;
 default:
-error_report("invalid ss_family type %x", tss->portable_family);
+g_critical("invalid ss_family type %x", tss->portable_family);
 return -EINVAL;
 }
 
-- 
2.20.1




  1   2   >