Re: [PATCH] hw/arm/aspeed: Map the UART5 device unconditionally

2020-09-06 Thread Cédric Le Goater
On 9/5/20 11:24 PM, Philippe Mathieu-Daudé wrote:
> The UART5 is present on the machine regardless there is a
> character device connected to it. Map it unconditionally.
> 
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Cédric Le Goater 

> ---
>  hw/arm/aspeed_ast2600.c | 8 +++-
>  hw/arm/aspeed_soc.c | 8 +++-
>  2 files changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
> index 9d95e421435..1450bde7cf2 100644
> --- a/hw/arm/aspeed_ast2600.c
> +++ b/hw/arm/aspeed_ast2600.c
> @@ -325,11 +325,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, 
> Error **errp)
>  }
>  
>  /* UART - attach an 8250 to the IO space as our UART5 */
> -if (serial_hd(0)) {
> -qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_DEV_UART5);
> -serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2,
> -   uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN);
> -}
> +serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2,
> +   aspeed_soc_get_irq(s, ASPEED_DEV_UART5),
> +   38400, serial_hd(0), DEVICE_LITTLE_ENDIAN);
>  
>  /* I2C */
>  object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
> diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
> index 35be126db6f..7eefd54ac07 100644
> --- a/hw/arm/aspeed_soc.c
> +++ b/hw/arm/aspeed_soc.c
> @@ -283,11 +283,9 @@ static void aspeed_soc_realize(DeviceState *dev, Error 
> **errp)
>  }
>  
>  /* UART - attach an 8250 to the IO space as our UART5 */
> -if (serial_hd(0)) {
> -qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_DEV_UART5);
> -serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2,
> -   uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN);
> -}
> +serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2,
> +   aspeed_soc_get_irq(s, ASPEED_DEV_UART5), 38400,
> +   serial_hd(0), DEVICE_LITTLE_ENDIAN);
>  
>  /* I2C */
>  object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
> 




Re: [PATCH v5 2/2] hw: hyperv: vmbus: Fix 32bit compilation

2020-09-06 Thread Philippe Mathieu-Daudé
Cc'ing qemu-trivial@

Can we add the commit description Richard wrote?

---
Fix 32-bit build error for vmbus:

  hw/hyperv/vmbus.c: In function ‘gpadl_iter_io’:
  hw/hyperv/vmbus.c:383:13: error: cast to pointer from integer of
different size [-Werror=int-to-pointer-cast]
  383 | p = (void *)(((uintptr_t)iter->map & TARGET_PAGE_MASK) |
off_in_page);
  | ^
  cc1: all warnings being treated as errors

Fixes: 0d71f7082d7 ("vmbus: vmbus implementation")
---

On 7/15/20 10:43 AM, Jon Doron wrote:
> Signed-off-by: Jon Doron 
> ---
>  hw/hyperv/vmbus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
> index 34392e892a..c28bb4201b 100644
> --- a/hw/hyperv/vmbus.c
> +++ b/hw/hyperv/vmbus.c
> @@ -383,7 +383,8 @@ static ssize_t gpadl_iter_io(GpadlIter *iter, void *buf, 
> uint32_t len)
>  }
>  }
>  
> -p = (void *)(((uintptr_t)iter->map & TARGET_PAGE_MASK) | 
> off_in_page);
> +p = (void *)(uintptr_t)(((uintptr_t)iter->map & TARGET_PAGE_MASK) |
> +off_in_page);
>  if (iter->dir == DMA_DIRECTION_FROM_DEVICE) {
>  memcpy(p, buf, cplen);
>  } else {
> 




Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that actually works with sg

2020-09-06 Thread Tom Yan
In commit 867eccfed84f96b54f4a432c510a02c2ce03b430, Levitsky appears
to have assumed that the only "SCSI Passthrough" is `-device
scsi-generic`, while the fact is there's also `-device scsi-block`
(passthrough without the sg driver). Unlike `-device scsi-hd`, getting
max_sectors is necessary to it (more precisely, hw_max_sectors might
what matters, but BLKSECTGET reports max_sectors, so).

I'm unsure about how qemu-nbd works, but the commit clearly wasn't the
right approach to fix the original issue it addresses. (It should for
example ignore the max_transfer if it will never matter in to it, or
overrides it in certain cases; when I glimpsed over
https://bugzilla.redhat.com/show_bug.cgi?id=1647104, I don't see how
it could be file-posix problem when it is reporting the right thing,
regardless of whether "removing" the code helps.)

I don't think we want to "mark" `-device scsi-block` as sg either. It
will probably bring even more unexpected problems, because they are
literally different sets of things behind the scene / in the kernel.

On Fri, 4 Sep 2020 at 10:09, Tom Yan  wrote:
>
> sg devices have different major/minor than their corresponding
> block devices. Using sysfs to get max segments never really worked
> for them.
>
> Fortunately the sg driver provides an ioctl to get sg_tablesize,
> which is apparently equivalent to max segments.
>
> Signed-off-by: Tom Yan 
> ---
>  block/file-posix.c | 17 -
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 411a23cf99..9e37594145 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -1178,6 +1178,21 @@ static int sg_get_max_transfer_length(int fd)
>  #endif
>  }
>
> +static int sg_get_max_segments(int fd)
> +{
> +#ifdef SG_GET_SG_TABLESIZE
> +long max_segments = 0;
> +
> +if (ioctl(fd, SG_GET_SG_TABLESIZE, &max_segments) == 0) {
> +return max_segments;
> +} else {
> +return -errno;
> +}
> +#else
> +return -ENOSYS;
> +#endif
> +}
> +
>  static int get_max_transfer_length(int fd)
>  {
>  #if defined(BLKSECTGET) && defined(BLKSSZGET)
> @@ -1268,7 +1283,7 @@ static void hdev_refresh_limits(BlockDriverState *bs, 
> Error **errp)
>  bs->bl.max_transfer = pow2floor(ret);
>  }
>
> -ret = get_max_segments(s->fd);
> +ret = bs->sg ? sg_get_max_segments(s->fd) : get_max_segments(s->fd);
>  if (ret > 0) {
>  bs->bl.max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
> ret * qemu_real_host_page_size);
> --
> 2.28.0
>



Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that actually works with sg

2020-09-06 Thread Tom Yan
Maybe you want to add some condition for this:
https://github.com/qemu/qemu/blob/v5.1.0/nbd/server.c#L659
Or not clamp it at all.

On Sun, 6 Sep 2020 at 18:58, Tom Yan  wrote:
>
> In commit 867eccfed84f96b54f4a432c510a02c2ce03b430, Levitsky appears
> to have assumed that the only "SCSI Passthrough" is `-device
> scsi-generic`, while the fact is there's also `-device scsi-block`
> (passthrough without the sg driver). Unlike `-device scsi-hd`, getting
> max_sectors is necessary to it (more precisely, hw_max_sectors might
> what matters, but BLKSECTGET reports max_sectors, so).
>
> I'm unsure about how qemu-nbd works, but the commit clearly wasn't the
> right approach to fix the original issue it addresses. (It should for
> example ignore the max_transfer if it will never matter in to it, or
> overrides it in certain cases; when I glimpsed over
> https://bugzilla.redhat.com/show_bug.cgi?id=1647104, I don't see how
> it could be file-posix problem when it is reporting the right thing,
> regardless of whether "removing" the code helps.)
>
> I don't think we want to "mark" `-device scsi-block` as sg either. It
> will probably bring even more unexpected problems, because they are
> literally different sets of things behind the scene / in the kernel.
>
> On Fri, 4 Sep 2020 at 10:09, Tom Yan  wrote:
> >
> > sg devices have different major/minor than their corresponding
> > block devices. Using sysfs to get max segments never really worked
> > for them.
> >
> > Fortunately the sg driver provides an ioctl to get sg_tablesize,
> > which is apparently equivalent to max segments.
> >
> > Signed-off-by: Tom Yan 
> > ---
> >  block/file-posix.c | 17 -
> >  1 file changed, 16 insertions(+), 1 deletion(-)
> >
> > diff --git a/block/file-posix.c b/block/file-posix.c
> > index 411a23cf99..9e37594145 100644
> > --- a/block/file-posix.c
> > +++ b/block/file-posix.c
> > @@ -1178,6 +1178,21 @@ static int sg_get_max_transfer_length(int fd)
> >  #endif
> >  }
> >
> > +static int sg_get_max_segments(int fd)
> > +{
> > +#ifdef SG_GET_SG_TABLESIZE
> > +long max_segments = 0;
> > +
> > +if (ioctl(fd, SG_GET_SG_TABLESIZE, &max_segments) == 0) {
> > +return max_segments;
> > +} else {
> > +return -errno;
> > +}
> > +#else
> > +return -ENOSYS;
> > +#endif
> > +}
> > +
> >  static int get_max_transfer_length(int fd)
> >  {
> >  #if defined(BLKSECTGET) && defined(BLKSSZGET)
> > @@ -1268,7 +1283,7 @@ static void hdev_refresh_limits(BlockDriverState *bs, 
> > Error **errp)
> >  bs->bl.max_transfer = pow2floor(ret);
> >  }
> >
> > -ret = get_max_segments(s->fd);
> > +ret = bs->sg ? sg_get_max_segments(s->fd) : get_max_segments(s->fd);
> >  if (ret > 0) {
> >  bs->bl.max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
> > ret * qemu_real_host_page_size);
> > --
> > 2.28.0
> >



Re: [PATCH 1/2] tests: Trying fixes test-replication.c on msys2/mingw.

2020-09-06 Thread Yonggang Luo
On Sun, Sep 6, 2020 at 5:49 AM Stefan Weil  wrote:

> Am 05.09.20 um 23:10 schrieb Yonggang Luo:
>
> > On Windows there is no path like /tmp/s_local_disk.XX
> >
> > Signed-off-by: Yonggang Luo 
> > ---
> >  tests/test-replication.c | 13 +
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > diff --git a/tests/test-replication.c b/tests/test-replication.c
> > index 9ab3666a90..3cf544a133 100644
> > --- a/tests/test-replication.c
> > +++ b/tests/test-replication.c
> > @@ -23,14 +23,14 @@
> >
> >  /* primary */
> >  #define P_ID "primary-id"
> > -static char p_local_disk[] = "/tmp/p_local_disk.XX";
> > +static char p_local_disk[PATH_MAX];
> >
> >  /* secondary */
> >  #define S_ID "secondary-id"
> >  #define S_LOCAL_DISK_ID "secondary-local-disk-id"
> > -static char s_local_disk[] = "/tmp/s_local_disk.XX";
> > -static char s_active_disk[] = "/tmp/s_active_disk.XX";
> > -static char s_hidden_disk[] = "/tmp/s_hidden_disk.XX";
> > +static char s_local_disk[PATH_MAX];
> > +static char s_active_disk[PATH_MAX];
> > +static char s_hidden_disk[PATH_MAX];
> >
> >  /* FIXME: steal from blockdev.c */
> >  QemuOptsList qemu_drive_opts = {
> > @@ -571,6 +571,11 @@ static void setup_sigabrt_handler(void)
> >  int main(int argc, char **argv)
> >  {
> >  int ret;
> > +const char *tmpdir = g_get_tmp_dir();
> > +sprintf(p_local_disk, "%s/p_local_disk.XX", tmpdir);
> > +sprintf(s_local_disk, "%s/s_local_disk.XX", tmpdir);
> > +sprintf(s_active_disk, "%s/s_active_disk.XX", tmpdir);
> > +sprintf(s_hidden_disk, "%s/s_hidden_disk.XX", tmpdir);
> >  qemu_init_main_loop(&error_fatal);
> >  bdrv_init();
> >
>
>
> Maybe it is possible to use get_tmp_filename() (which could be
> simplified by using g_get_tmp_dir).
>
What  does get_tmp_filename mean? I didn't understand

>
> And please use snprintf instead of sprintf. I am afraid that a path can
> be longer than PATH_MAX, even if the tmpdir path is normally rather short.
>
 OK, I'll use  snprintf

>
> You could also allocate the different filenames dynamically instead of
> limiting them to PATH_MAX characters.
>
as a test, it's too complicated,

>
> Regards
>
> Stefan Weil
>
>
>

-- 
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that actually works with sg

2020-09-06 Thread Maxim Levitsky
On Sun, 2020-09-06 at 19:04 +0800, Tom Yan wrote:
> Maybe you want to add some condition for this:
> https://github.com/qemu/qemu/blob/v5.1.0/nbd/server.c#L659
> Or not clamp it at all.
> 
> On Sun, 6 Sep 2020 at 18:58, Tom Yan  wrote:
> > In commit 867eccfed84f96b54f4a432c510a02c2ce03b430, Levitsky appears
> > to have assumed that the only "SCSI Passthrough" is `-device
> > scsi-generic`, while the fact is there's also `-device scsi-block`
> > (passthrough without the sg driver). Unlike `-device scsi-hd`, getting
> > max_sectors is necessary to it (more precisely, hw_max_sectors might
> > what matters, but BLKSECTGET reports max_sectors, so).
> > 
> > I'm unsure about how qemu-nbd works, but the commit clearly wasn't the
> > right approach to fix the original issue it addresses. (It should for
> > example ignore the max_transfer if it will never matter in to it, or
> > overrides it in certain cases; when I glimpsed over
> > https://bugzilla.redhat.com/show_bug.cgi?id=1647104, I don't see how
> > it could be file-posix problem when it is reporting the right thing,
> > regardless of whether "removing" the code helps.)
> > 
> > I don't think we want to "mark" `-device scsi-block` as sg either. It
> > will probably bring even more unexpected problems, because they are
> > literally different sets of things behind the scene / in the kernel.

Yes, I did overlook the fact that scsi-block is kind of hybrid passthough 
device,
doing SG_IO for some things and regular IO for others.

I don't think that my approach was wrong way to fix the problem, but as you 
found
out, abusing 'bs->sg' hack (which I would be very happy to remove completely)
wasn't a good idea.
I actualy was aware of scsi-block and that it does SG_IO but it 
was forgotten some where on the way.

So in summary what the problem is and what I think is the right solution:


Each qemu block driver exposes block limits and assumes that they are the same 
for two IO interfaces the block driver can expose:

1. Regular qemu blk_pread/pwrite alike functions
2. blk_ioctl (tiny wrapper against SG_IO), supported by posix-raw on 
   host block devices/sg char devices, and by iscsi

The problem is that these two interfaces can have different block limits.

I don't know about iscsi, but for files, doing regular IO is always unlimited,
since it passes through the kernel block layer and segemented there on 
demand which is faster that doing it in userspace, while SG_IO is passed as is
to the underlying SCSI device and lacks this segmentation.

Regardless of how NBD uses these limits, I think that these limits should be 
correctly
exposed by the block drivers, and therefore I propose is that each qemu block 
driver 
would expose a pair of block limits.
One for the regular block IO, and other for SG_IO.

Then block driver clients (like scsi devices that you mention, nbd, etc) 
can choose which limit to use, depending on which IO api they use.
The scsi-generic, and scsi-block can use the SG_IO limits, 
while the rest  can use the normal (unlimited for file I/O) limits, including 
the NBD.

Best regards,
Maxim Levitsky

> > 
> > On Fri, 4 Sep 2020 at 10:09, Tom Yan  wrote:
> > > sg devices have different major/minor than their corresponding
> > > block devices. Using sysfs to get max segments never really worked
> > > for them.
> > > 
> > > Fortunately the sg driver provides an ioctl to get sg_tablesize,
> > > which is apparently equivalent to max segments.
> > > 
> > > Signed-off-by: Tom Yan 
> > > ---
> > >  block/file-posix.c | 17 -
> > >  1 file changed, 16 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/block/file-posix.c b/block/file-posix.c
> > > index 411a23cf99..9e37594145 100644
> > > --- a/block/file-posix.c
> > > +++ b/block/file-posix.c
> > > @@ -1178,6 +1178,21 @@ static int sg_get_max_transfer_length(int fd)
> > >  #endif
> > >  }
> > > 
> > > +static int sg_get_max_segments(int fd)
> > > +{
> > > +#ifdef SG_GET_SG_TABLESIZE
> > > +long max_segments = 0;
> > > +
> > > +if (ioctl(fd, SG_GET_SG_TABLESIZE, &max_segments) == 0) {
> > > +return max_segments;
> > > +} else {
> > > +return -errno;
> > > +}
> > > +#else
> > > +return -ENOSYS;
> > > +#endif
> > > +}
> > > +
> > >  static int get_max_transfer_length(int fd)
> > >  {
> > >  #if defined(BLKSECTGET) && defined(BLKSSZGET)
> > > @@ -1268,7 +1283,7 @@ static void hdev_refresh_limits(BlockDriverState 
> > > *bs, Error **errp)
> > >  bs->bl.max_transfer = pow2floor(ret);
> > >  }
> > > 
> > > -ret = get_max_segments(s->fd);
> > > +ret = bs->sg ? sg_get_max_segments(s->fd) : get_max_segments(s->fd);
> > >  if (ret > 0) {
> > >  bs->bl.max_transfer = MIN_NON_ZERO(bs->bl.max_transfer,
> > > ret * 
> > > qemu_real_host_page_size);
> > > --
> > > 2.28.0
> > > 





Re: [PULL 0/5] tcg patch queue

2020-09-06 Thread Peter Maydell
On Thu, 3 Sep 2020 at 22:41, Richard Henderson
 wrote:
>
> The following changes since commit 3dd23a4fb8fd72d2220a90a809f213999ffe7f3a:
>
>   Merge remote-tracking branch 'remotes/legoater/tags/pull-aspeed-20200901' 
> into staging (2020-09-03 14:12:48 +0100)
>
> are available in the Git repository at:
>
>   https://github.com/rth7680/qemu.git tags/pull-tcg-20200903
>
> for you to fetch changes up to fe4b0b5bfa96c38ad1cad0689a86cca9f307e353:
>
>   tcg: Implement 256-bit dup for tcg_gen_gvec_dup_mem (2020-09-03 13:13:58 
> -0700)
>
> 
> Improve inlining in cputlb.c.
> Fix vector abs fallback.
> Only set parallel_cpus for SMP.
> Add vector dupm for 256-bit elements.
>
> 


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.2
for any user-visible changes.

-- PMM



QEMU | Pipeline #186502358 has failed for master | 227de21e

2020-09-06 Thread GitLab via


Your pipeline has failed.

Project: QEMU ( https://gitlab.com/qemu-project/qemu )
Branch: master ( https://gitlab.com/qemu-project/qemu/-/commits/master )

Commit: 227de21e ( 
https://gitlab.com/qemu-project/qemu/-/commit/227de21ed0759e275a469394af72c999d0134bb5
 )
Commit Message: Merge remote-tracking branch 'remotes/rth/tags/...
Commit Author: Peter Maydell ( https://gitlab.com/pm215 )

Pipeline #186502358 ( 
https://gitlab.com/qemu-project/qemu/-/pipelines/186502358 ) triggered by Alex 
Bennée ( https://gitlab.com/stsquad )
had 1 failed build.

Job #723251737 ( https://gitlab.com/qemu-project/qemu/-/jobs/723251737/raw )

Stage: test
Name: acceptance-system-fedora
Trace: 13:57:56 ERROR| 
13:57:56 ERROR| Reproduced traceback from: 
/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py:846
13:57:56 ERROR| Traceback (most recent call last):
13:57:56 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/acceptance/avocado_qemu/__init__.py", 
line 171, in setUp
13:57:56 ERROR| self.cancel("No QEMU binary defined or found in the build 
tree")
13:57:56 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py",
 line 1081, in cancel
13:57:56 ERROR| raise exceptions.TestCancel(message)
13:57:56 ERROR| avocado.core.exceptions.TestCancel: No QEMU binary defined or 
found in the build tree
13:57:56 ERROR| 
13:57:56 ERROR| CANCEL 
31-tests/acceptance/vnc.py:Vnc.test_change_password_requires_a_password -> 
TestCancel: No QEMU binary defined or found in the build tree
13:57:56 INFO | 
13:57:56 DEBUG| PARAMS (key=arch, path=*, default=None) => None
13:57:56 DEBUG| PARAMS (key=machine, path=*, default=None) => None
13:57:56 DEBUG| PARAMS (key=qemu_bin, path=*, default=None) => None
13:57:56 ERROR| 
13:57:56 ERROR| Reproduced traceback from: 
/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py:846
13:57:56 ERROR| Traceback (most recent call last):
13:57:56 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/acceptance/avocado_qemu/__init__.py", 
line 171, in setUp
13:57:56 ERROR| self.cancel("No QEMU binary defined or found in the build 
tree")
13:57:56 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py",
 line 1081, in cancel
13:57:56 ERROR| raise exceptions.TestCancel(message)
13:57:56 ERROR| avocado.core.exceptions.TestCancel: No QEMU binary defined or 
found in the build tree
13:57:56 ERROR| 
13:57:56 ERROR| CANCEL 32-tests/acceptance/vnc.py:Vnc.test_change_password -> 
TestCancel: No QEMU binary defined or found in the build tree
13:57:56 INFO | 
$ du -chs ${CI_PROJECT_DIR}/avocado-cache
323M/builds/qemu-project/qemu/avocado-cache
323Mtotal
section_end:1599400679:after_script
ERROR: Job failed: exit code 1



-- 
You're receiving this email because of your account on gitlab.com.





[PATCH] tests/vm: Add Haiku test based on their vagrant images

2020-09-06 Thread Alexander von Gluck IV
Signed-off-by: Alexander von Gluck IV 
---
 tests/keys/vagrant |  27 +
 tests/keys/vagrant.pub |   1 +
 tests/vm/basevm.py |   5 +-
 tests/vm/haiku.x86_64  | 121 +
 4 files changed, 152 insertions(+), 2 deletions(-)
 create mode 100644 tests/keys/vagrant
 create mode 100644 tests/keys/vagrant.pub
 create mode 100755 tests/vm/haiku.x86_64

diff --git a/tests/keys/vagrant b/tests/keys/vagrant
new file mode 100644
index 00..7d6a083909
--- /dev/null
+++ b/tests/keys/vagrant
@@ -0,0 +1,27 @@
+-BEGIN RSA PRIVATE KEY-
+MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
+w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
+kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
+hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
+Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW
+yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd
+ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1
+Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf
+TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK
+iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A
+sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf
+4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP
+cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk
+EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN
+CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX
+3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG
+YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj
+3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+
+dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz
+6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC
+P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF
+llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ
+kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH
++vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ
+NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
+-END RSA PRIVATE KEY-
diff --git a/tests/keys/vagrant.pub b/tests/keys/vagrant.pub
new file mode 100644
index 00..18a9c00fd5
--- /dev/null
+++ b/tests/keys/vagrant.pub
@@ -0,0 +1 @@
+ssh-rsa 
B3NzaC1yc2EBIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
 vagrant insecure public key
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 3fac20e929..00f1d5ca8d 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -44,6 +44,7 @@ DEFAULT_CONFIG = {
 'machine' : 'pc',
 'guest_user'  : "qemu",
 'guest_pass'  : "qemupass",
+'root_user'   : "root",
 'root_pass'   : "qemupass",
 'ssh_key_file': SSH_KEY_FILE,
 'ssh_pub_key_file': SSH_PUB_KEY_FILE,
@@ -245,13 +246,13 @@ class BaseVM(object):
 return self._ssh_do(self._config["guest_user"], cmd, False)
 
 def ssh_root(self, *cmd):
-return self._ssh_do("root", cmd, False)
+return self._ssh_do(self._config["root_user"], cmd, False)
 
 def ssh_check(self, *cmd):
 self._ssh_do(self._config["guest_user"], cmd, True)
 
 def ssh_root_check(self, *cmd):
-self._ssh_do("root", cmd, True)
+self._ssh_do(self._config["root_user"], cmd, True)
 
 def build_image(self, img):
 raise NotImplementedError
diff --git a/tests/vm/haiku.x86_64 b/tests/vm/haiku.x86_64
new file mode 100755
index 00..922f51
--- /dev/null
+++ b/tests/vm/haiku.x86_64
@@ -0,0 +1,121 @@
+#!/usr/bin/env python3
+#
+# Haiku VM image
+#
+# Copyright 2020 Haiku, Inc.
+#
+# Authors:
+#  Alexander von Gluck IV 
+#
+# This code is licensed under the GPL version 2 or later.  See
+# the COPYING file in the top-level directory.
+#
+
+import os
+import re
+import sys
+import time
+import socket
+import subprocess
+import basevm
+
+VAGRANT_KEY_FILE = os.path.join(os.path.dirname(__file__),
+"..", "keys", "vagrant")
+
+VAGRANT_PUB_KEY_FILE = os.path.join(os.path.dirname(__file__),
+"..", "keys", "vagrant.pub")
+
+HAIKU_CONFIG = {
+'cpu' : "max",
+'machine' : 'pc',
+'guest_user'  : "vagrant",
+'guest_pass'  : "",
+'root_user'   : "vagrant",
+'root_pass'   : "",
+'ssh_key_file': VAGRANT_KEY_FILE,
+'ssh_pub_key_file': VAGRANT_PUB_KEY_FILE,
+'memory'  : "4G",
+'extra_args'  : [],
+'qemu_args'   : "-device VGA",
+'dns' : "",
+'ssh_port': 0,
+'

Re: [PATCH] tests/vm: Add Haiku test based on their vagrant images

2020-09-06 Thread Alexander von Gluck IV
September 6, 2020 9:35 AM, "Alexander von Gluck IV"  
wrote:
> Signed-off-by: Alexander von Gluck IV 
> ---
> tests/keys/vagrant | 27 +
> tests/keys/vagrant.pub | 1 +
> tests/vm/basevm.py | 5 +-
> tests/vm/haiku.x86_64 | 121 +
> 4 files changed, 152 insertions(+), 2 deletions(-)
> create mode 100644 tests/keys/vagrant
> create mode 100644 tests/keys/vagrant.pub
> create mode 100755 tests/vm/haiku.x86_64
> 
> diff --git a/tests/keys/vagrant b/tests/keys/vagrant
> new file mode 100644
> index 00..7d6a083909
> --- /dev/null
> +++ b/tests/keys/vagrant
> @@ -0,0 +1,27 @@
> +-BEGIN RSA PRIVATE KEY-
> +MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
>
> diff --git a/tests/keys/vagrant.pub b/tests/keys/vagrant.pub
> new file mode 100644
> index 00..18a9c00fd5
> --- /dev/null
> +++ b/tests/keys/vagrant.pub
> @@ -0,0 +1 @@
> +ssh-rsa
> B3NzaC1yc2EBIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oX

A little background information for context. These are the Vagrant SSH keys 
which are packed with every vagrant OS image and allow OS access for 
automation.  The python vm tester knowing of these lets it leverage Vagrant OS 
images for testing without much work.



> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -44,6 +44,7 @@ DEFAULT_CONFIG = {
> 'machine' : 'pc',
> 'guest_user' : "qemu",
> 'guest_pass' : "qemupass",
> + 'root_user' : "root",
> 'root_pass' : "qemupass",
> 'ssh_key_file' : SSH_KEY_FILE,
> 'ssh_pub_key_file': SSH_PUB_KEY_FILE,
> @@ -245,13 +246,13 @@ class BaseVM(object):
> return self._ssh_do(self._config["guest_user"], cmd, False)
> 
> def ssh_root(self, *cmd):
> - return self._ssh_do("root", cmd, False)
> + return self._ssh_do(self._config["root_user"], cmd, False)
> 
> def ssh_check(self, *cmd):
> self._ssh_do(self._config["guest_user"], cmd, True)
> 
> def ssh_root_check(self, *cmd):
> - self._ssh_do("root", cmd, True)
> + self._ssh_do(self._config["root_user"], cmd, True)
> 
> def build_image(self, img):
> raise NotImplementedError


Haiku's user is UID 0, so essentially our root user isn't named root.
This adds the (optional) ability to override the root username.


> diff --git a/tests/vm/haiku.x86_64 b/tests/vm/haiku.x86_64
> new file mode 100755
> index 00..922f51
> --- /dev/null
> +++ b/tests/vm/haiku.x86_64
> @@ -0,0 +1,121 @@
> +#!/usr/bin/env python3
> +#
> +# Haiku VM image
> +#
> +# Copyright 2020 Haiku, Inc.
> +#
> +# Authors:
> +# Alexander von Gluck IV 
> +#
> +# This code is licensed under the GPL version 2 or later. See
> +# the COPYING file in the top-level directory.
> +#


This build script works as expected, transferring the qemu archive over
via the virtio block device and building it.

More information here (including output of tools):
https://bugs.launchpad.net/qemu/+bug/1715203

This purpose of this is trying to prevent the need to remove
upstream qemu support for Haiku.

We have some out-of-tree patches to fix the error seen in our ports, i'll
work on upstreaming these.


 -- Alex



[Bug 1715203] Re: Maintain Haiku support

2020-09-06 Thread kallisti5
A patch for this work has been posted to the qemu-dev ML.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1715203

Title:
  Maintain Haiku support

Status in QEMU:
  Confirmed

Bug description:
  It was pointed out that the 2.10 release notes are pushing to drop
  Haiku support.  The qemu port is currently working as-is under Haiku.

  Was there a reason this was recommended? Is there anything Haiku can
  do to keep it from being dropped?

  We're working on a docker container to cross-compile rust-lang for
  Haiku, could this be of some use to qemu when complete?

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1715203/+subscriptions



Re: [PULL 00/30] ppc-for-5.2 queue 20200904

2020-09-06 Thread Peter Maydell
On Fri, 4 Sep 2020 at 04:47, David Gibson  wrote:
>
> The following changes since commit 67a7bfe560a1bba59efab085cb3430f45176d382:
>
>   Merge remote-tracking branch 
> 'remotes/huth-gitlab/tags/pull-request-2020-09-03' into staging (2020-09-03 
> 16:58:25 +0100)
>
> are available in the Git repository at:
>
>   git://github.com/dgibson/qemu.git tags/ppc-for-5.2-20200904
>
> for you to fetch changes up to b172606ecf29a140073f7787251a9d70ecb53b6e:
>
>   spapr_numa: move NVLink2 associativity handling to spapr_numa.c (2020-09-04 
> 13:40:09 +1000)
>
> 
> ppc patch queue 2020-09-04
>
> Next pull request for qemu-5.2.  The biggest thing here is the
> generalization of ARM's start-powered-off machine property to all
> targets.  This can fix a number of odd little edge cases where KVM
> could run vcpus before they were properly initialized.  This does
> include changes to a number of files that aren't normally in my
> purview.  There are suitable Acked-by lines and Peter requested this
> come in via my tree, since the most pressing requirement for it is in
> pseries machines with the POWER secure virtual machine facility.
>
> In addition we have:
>  * The start of Daniel Barboza's rework and clean up of pseries
>machine NUMA handling
>  * Correction to behaviour of the nvdimm= generic machine property on
>pseries
>  * An optimization to the allocation of XIVE interrupts on KVM
>  * Some fixes for confused behaviour with kernel_irqchip when both
>XICS and XIVE are in play
>  * Add HIOMAP comamnd to pnv flash
>  * Properly advertise the fact that spapr_vscsi doesn't handle
>hotplugged disks
>  * Some assorted minor enhancements

Hi -- this fails to build for Windows:

../../hw/ppc/spapr_numa.c: In function 'spapr_numa_fixup_cpu_dt':
../../hw/ppc/spapr_numa.c:77:5: error: unknown type name 'uint'
 uint vcpu_assoc_size = NUMA_ASSOC_SIZE + 1;
 ^

That should probably be using one of the standard C types.

The 'check-tcg' tests for the linux-user static build also
failed on an s390x test:

  CHECK   debian-s390x-cross
  BUILD   s390x-linux-user guest-tests with docker qemu/debian-s390x-cross
  RUN tests for s390x
  TESTthreadcount on s390x
Unhandled trap: 0x10003
PSW=mask 00018000 addr 010004f0 cc 00
R00= R01= R02=
R03=
R04= R05= R06=
R07=
R08= R09= R10=
R11=
R12= R13= R14=
R15=0040008006c0

../Makefile.target:153: recipe for target 'run-threadcount' failed
make[2]: *** [run-threadcount] Error 1


thanks
-- PMM



Re: [PULL 00/46] Next round of Meson bugfixes and cleanups

2020-09-06 Thread Peter Maydell
On Fri, 4 Sep 2020 at 12:45, Paolo Bonzini  wrote:
>
> The following changes since commit 67a7bfe560a1bba59efab085cb3430f45176d382:
>
>   Merge remote-tracking branch 
> 'remotes/huth-gitlab/tags/pull-request-2020-09-03' into staging (2020-09-03 
> 16:58:25 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 4be1987db8b361f17c50bea582c6056cd54c4752:
>
>   meson: remove linkage of sdl to baum (2020-09-04 07:33:28 -0400)
>
> Finally a favorable diffstat appears...
>
> 
> meson related:
> * convert unit tests
> * bugfixes for mtest2make
> * miscellaneous bugfixes
> * dead code removal and configure cleanups
> * oss-fuzz fixes
> * msys fixes

Merge conflict in meson.build (looks fairly minor but I wasn't
sure of the resolution). Could you rebase and resend, please ?

thanks
-- PMM



Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that actually works with sg

2020-09-06 Thread Tom Yan
I don't disagree with your proposal, but the thing is, do we even need
another field/limit for case 1? For example, do we *really* need to
clamp sizes[2] (NBD_INFO_BLOCK_SIZE) in nbd/server.c and
max_io_sectors (SCSIBlockLimits) in hw/scsi/scsi-disk.c to to any kind
of "dynamic" limit?

Either way I can add another field (`max_pwrite`, maybe?) to
BlockLimits, as an infrastructure/hint, but what should be switched to
it, and what value should each block driver set it to, is probably
beyond what I can take.

IMHO my patches should be merged first (they are really just fixing a
regression and some bugs). If anyone finds it necessary and is capable
and willing to fix the insufficiency of BlockLimits, they can do it
afterwards with another patch series as an improvement. I can add a
patch to remove the clamping in nbd/server.c as a perhaps-temporary
measure to address the original issue, if desired.

On Sun, 6 Sep 2020 at 20:53, Maxim Levitsky  wrote:
>
> On Sun, 2020-09-06 at 19:04 +0800, Tom Yan wrote:
> > Maybe you want to add some condition for this:
> > https://github.com/qemu/qemu/blob/v5.1.0/nbd/server.c#L659
> > Or not clamp it at all.
> >
> > On Sun, 6 Sep 2020 at 18:58, Tom Yan  wrote:
> > > In commit 867eccfed84f96b54f4a432c510a02c2ce03b430, Levitsky appears
> > > to have assumed that the only "SCSI Passthrough" is `-device
> > > scsi-generic`, while the fact is there's also `-device scsi-block`
> > > (passthrough without the sg driver). Unlike `-device scsi-hd`, getting
> > > max_sectors is necessary to it (more precisely, hw_max_sectors might
> > > what matters, but BLKSECTGET reports max_sectors, so).
> > >
> > > I'm unsure about how qemu-nbd works, but the commit clearly wasn't the
> > > right approach to fix the original issue it addresses. (It should for
> > > example ignore the max_transfer if it will never matter in to it, or
> > > overrides it in certain cases; when I glimpsed over
> > > https://bugzilla.redhat.com/show_bug.cgi?id=1647104, I don't see how
> > > it could be file-posix problem when it is reporting the right thing,
> > > regardless of whether "removing" the code helps.)
> > >
> > > I don't think we want to "mark" `-device scsi-block` as sg either. It
> > > will probably bring even more unexpected problems, because they are
> > > literally different sets of things behind the scene / in the kernel.
>
> Yes, I did overlook the fact that scsi-block is kind of hybrid passthough 
> device,
> doing SG_IO for some things and regular IO for others.
>
> I don't think that my approach was wrong way to fix the problem, but as you 
> found
> out, abusing 'bs->sg' hack (which I would be very happy to remove completely)
> wasn't a good idea.
> I actualy was aware of scsi-block and that it does SG_IO but it
> was forgotten some where on the way.
>
> So in summary what the problem is and what I think is the right solution:
>
>
> Each qemu block driver exposes block limits and assumes that they are the same
> for two IO interfaces the block driver can expose:
>
> 1. Regular qemu blk_pread/pwrite alike functions
> 2. blk_ioctl (tiny wrapper against SG_IO), supported by posix-raw on
>host block devices/sg char devices, and by iscsi
>
> The problem is that these two interfaces can have different block limits.
>
> I don't know about iscsi, but for files, doing regular IO is always unlimited,
> since it passes through the kernel block layer and segemented there on
> demand which is faster that doing it in userspace, while SG_IO is passed as is
> to the underlying SCSI device and lacks this segmentation.
>
> Regardless of how NBD uses these limits, I think that these limits should be 
> correctly
> exposed by the block drivers, and therefore I propose is that each qemu block 
> driver
> would expose a pair of block limits.
> One for the regular block IO, and other for SG_IO.
>
> Then block driver clients (like scsi devices that you mention, nbd, etc)
> can choose which limit to use, depending on which IO api they use.
> The scsi-generic, and scsi-block can use the SG_IO limits,
> while the rest  can use the normal (unlimited for file I/O) limits, including 
> the NBD.
>
> Best regards,
> Maxim Levitsky
>
> > >
> > > On Fri, 4 Sep 2020 at 10:09, Tom Yan  wrote:
> > > > sg devices have different major/minor than their corresponding
> > > > block devices. Using sysfs to get max segments never really worked
> > > > for them.
> > > >
> > > > Fortunately the sg driver provides an ioctl to get sg_tablesize,
> > > > which is apparently equivalent to max segments.
> > > >
> > > > Signed-off-by: Tom Yan 
> > > > ---
> > > >  block/file-posix.c | 17 -
> > > >  1 file changed, 16 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/block/file-posix.c b/block/file-posix.c
> > > > index 411a23cf99..9e37594145 100644
> > > > --- a/block/file-posix.c
> > > > +++ b/block/file-posix.c
> > > > @@ -1178,6 +1178,21 @@ static int sg_get_max_transfer_length(int fd)
> > > >  #endif
> > > >  }

Re: [PATCH] linux-user: Add support for a group of '_V2' btrfs ioctls

2020-09-06 Thread Laurent Vivier
Le 23/08/2020 à 21:59, Filip Bozuta a écrit :
> This patch introduces functionality for following btrfs ioctls:
> 
> BTRFS_IOC_SUBVOL_CREATE_V2 - Adding a new btrfs subvolume
> 
> Create a new btrfs subvolume (same as with BTRFS_IOC_SUBVOL_CREATE).
> The third ioctl's argument is a pointer to a following type:
> 
> struct btrfs_ioctl_vol_args_v2 {
>   __s64 fd;
>   __u64 transid;
>   __u64 flags;
>   union {
>   struct {
>   __u64 size;
>   struct btrfs_qgroup_inherit __user *qgroup_inherit;
>   };
>   __u64 unused[4];
>   };
>   union {
>   char name[BTRFS_SUBVOL_NAME_MAX + 1];
>   __u64 devid;
>   __u64 subvolid; /* added in kernel version 5.8 */
>   };
> };
> 
> When calling this ioctl, the 'name' field should be filled with
> the aproppriate value that contains the name of the subvolume that
> is to be created. The flags field can take values that are
> 'BTRFS_SUBVOL_RDONLY' or 'BTRFS_SUBVOL_QGROUP_INHERIT'. If the
> latter is specified, the field 'qgroup_inherit' should be filled
> with aproppriate values of the quota group in which the newly
> created subvolume is to be added. The definition of
> 'struct btrfs_qgroup_inherit' can be found at:
> 
> https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L90
> 
> BTRFS_IOC_SNAP_CREATE_V2 - Adding a btrfs snapshot for a subvolume
> 
> Create a new btrfs snapshot for a specified subvolume (same as with
> BTRFS_IOC_SNAP_CREATE). The ioctl's third argument is a pointer to
> the above mentioned 'struct btrfs_ioctl_vol_args_v2'. Before calling
> this ioctl, field 'fd' should be filled with the aproppriate file
> descriptor value for the btrfs subvolume for which the snapshot is
> to be created. Also, the 'name' field should be filled with the
> aproppriate value that represents the name of the snapshot that is
> to be created. The 'flags' field takes the same values as in case
> of 'BTRFS_IOC_SUBVOL_CREATE_V2' and represents the same functionality.
> 
> BTRFS_IOC_RM_DEV_V2 - Removing a btrfs device
> 
> Delete a btrfs device (same as with BTRFS_IOC_RM_DEV). The ioctl's third
> argument is a pointer to the above mentioned 'struct 
> btrfs_ioctl_vol_args_v2'.
> Before calling this ioctl, either the 'name' or the 'devid' field should
> be filled with the name or id of the device that is to be removed. Also, 
> the
> flags field should be filled either with 0 or 'BTRFS_DEVICE_SPEC_BY_ID'
> depending on if the device is gonna be specified via name or id.
> 
> BTRFS_IOC_SNAP_DESTROY_V2 - Removing a btrfs snapshot
> 
> Remove a btrfs snapshot (same as with BTRFS_IOC_SNAP_DESTROY). The ioctl's
> third argument is a pointer to the above mentioned 'struct 
> btrfs_ioctl_vol_args_v2'.
> Before calling this ioctl, either the 'name' or the 'subvolid' field 
> should
> be filled with the name or id of the snapshot that is to be removed. 
> Also, the
> flags field should be filled either with 0 or 'BTRFS_SUBVOL_SPEC_BY_ID'
> depending on if the snapshot is gonna be specified via name or id.
> 
> Implementation notes:
> 
> Since the third argument of the implemented ioctl's is a
> structure that contains unions, a special converting function
> 'target_to_host_btrfs_ioctl_vol_args_v2' was defined in 'syscall.c'.
> This function is called instead of 'thunk_convert()' to convert
> the values of the third argument from target to host. All of
> the ioctls in this patch are of type 'IOW' which is why a converting
> function from host to target is not required. Also, a separate printing
> function was defined in file 'strace.c' that is called instead of
> 'thunk_print()' to print the contents of the third argument.
> 
> Signed-off-by: Filip Bozuta 
> Based-on: <20200811164553.27713-2-filip.boz...@syrmia.com>
> Based-on: <20200723210233.349690-4-filip.boz...@syrmia.com>
> ---
>  linux-user/ioctls.h| 16 +++
>  linux-user/qemu.h  |  5 ++
>  linux-user/strace.c| 95 ++
>  linux-user/syscall.c   | 77 ++
>  linux-user/syscall_defs.h  | 28 +++
>  linux-user/syscall_types.h |  5 ++
>  thunk.c|  2 +-
>  7 files changed, 227 insertions(+), 1 deletion(-)
> 

> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
> index a69a0bd347..4add164673 100644
> --- a/linux-user/qemu.h
> +++ b/linux-user/qemu.h
> @@ -708,6 +708,11 @@ static inline uint64_t target_offset64(uint64_t word0, 
> uint64_t word1)
>  
>  void print_termios(void *arg);
>  
> +#if defined(BTRFS_IOC_SUBVOL_CREATE_V2) || defined(BTRFS_IOC_SNAP_CREATE_V2) 
> \
> + || defined(BTRFS_IOC_SNAP_DESTROY_V2)  || defined(BTRFS_IOC_RM_DEV_V2)

The #if is not needed on the declaration of the symbol.

Re: [PATCH 00/12] hw/riscv: Clean up the directory

2020-09-06 Thread Alistair Francis
On Thu, Sep 3, 2020 at 3:41 AM Bin Meng  wrote:
>
> From: Bin Meng 
>
> This is an effort to clean up the hw/riscv directory. Ideally it
> should only contain the RISC-V SoC / machine codes plus generic
> codes. Peripheral models for a specific SoC are moved to its
> corresponding hw/* subdirectories.
>
> This series should be applied after the PolarFire SoC series:
> http://patchwork.ozlabs.org/project/qemu-devel/list/?series=198727
>
>
> Bin Meng (12):
>   hw/riscv: Move sifive_e_prci model to hw/misc
>   hw/riscv: Move sifive_u_prci model to hw/misc
>   hw/riscv: Move sifive_u_otp model to hw/misc
>   hw/riscv: Move sifive_gpio model to hw/gpio
>   hw/riscv: Move sifive_clint model to hw/intc
>   hw/riscv: Move sifive_plic model to hw/intc
>   hw/riscv: Move riscv_htif model to hw/char
>   hw/riscv: Move sifive_uart model to hw/char
>   hw/riscv: Move sifive_test model to hw/misc
>   hw/riscv: Always build riscv_hart.c
>   hw/riscv: Drop CONFIG_SIFIVE
>   hw/riscv: Sort the Kconfig options in alphabetical order

Thanks!

Applied to riscv-to-apply.next

Alistair

>
>  {include/hw/riscv => hw/intc}/sifive_plic.h |  0
>  hw/riscv/trace.h|  1 -
>  include/hw/{riscv => char}/riscv_htif.h |  0
>  include/hw/{riscv => char}/sifive_uart.h|  0
>  include/hw/{riscv => gpio}/sifive_gpio.h|  0
>  include/hw/{riscv => intc}/sifive_clint.h   |  0
>  include/hw/{riscv => misc}/sifive_e_prci.h  |  0
>  include/hw/{riscv => misc}/sifive_test.h|  0
>  include/hw/{riscv => misc}/sifive_u_otp.h   |  0
>  include/hw/{riscv => misc}/sifive_u_prci.h  |  0
>  include/hw/riscv/sifive_e.h |  2 +-
>  include/hw/riscv/sifive_u.h |  6 +--
>  hw/{riscv => char}/riscv_htif.c |  2 +-
>  hw/{riscv => char}/sifive_uart.c|  2 +-
>  hw/{riscv => gpio}/sifive_gpio.c|  2 +-
>  hw/{riscv => intc}/sifive_clint.c   |  2 +-
>  hw/{riscv => intc}/sifive_plic.c|  2 +-
>  hw/{riscv => misc}/sifive_e_prci.c  |  2 +-
>  hw/{riscv => misc}/sifive_test.c|  2 +-
>  hw/{riscv => misc}/sifive_u_otp.c   |  2 +-
>  hw/{riscv => misc}/sifive_u_prci.c  |  2 +-
>  hw/riscv/microchip_pfsoc.c  |  4 +-
>  hw/riscv/sifive_e.c |  8 ++--
>  hw/riscv/sifive_u.c |  6 +--
>  hw/riscv/spike.c|  4 +-
>  hw/riscv/virt.c |  6 +--
>  hw/char/Kconfig |  6 +++
>  hw/char/meson.build |  2 +
>  hw/gpio/Kconfig |  3 ++
>  hw/gpio/meson.build |  1 +
>  hw/gpio/trace-events|  6 +++
>  hw/intc/Kconfig |  6 +++
>  hw/intc/meson.build |  2 +
>  hw/misc/Kconfig | 12 +
>  hw/misc/meson.build |  6 +++
>  hw/riscv/Kconfig| 74 
> +++--
>  hw/riscv/meson.build| 11 +
>  hw/riscv/trace-events   |  7 ---
>  meson.build |  1 -
>  39 files changed, 110 insertions(+), 82 deletions(-)
>  rename {include/hw/riscv => hw/intc}/sifive_plic.h (100%)
>  delete mode 100644 hw/riscv/trace.h
>  rename include/hw/{riscv => char}/riscv_htif.h (100%)
>  rename include/hw/{riscv => char}/sifive_uart.h (100%)
>  rename include/hw/{riscv => gpio}/sifive_gpio.h (100%)
>  rename include/hw/{riscv => intc}/sifive_clint.h (100%)
>  rename include/hw/{riscv => misc}/sifive_e_prci.h (100%)
>  rename include/hw/{riscv => misc}/sifive_test.h (100%)
>  rename include/hw/{riscv => misc}/sifive_u_otp.h (100%)
>  rename include/hw/{riscv => misc}/sifive_u_prci.h (100%)
>  rename hw/{riscv => char}/riscv_htif.c (99%)
>  rename hw/{riscv => char}/sifive_uart.c (99%)
>  rename hw/{riscv => gpio}/sifive_gpio.c (99%)
>  rename hw/{riscv => intc}/sifive_clint.c (99%)
>  rename hw/{riscv => intc}/sifive_plic.c (99%)
>  rename hw/{riscv => misc}/sifive_e_prci.c (99%)
>  rename hw/{riscv => misc}/sifive_test.c (98%)
>  rename hw/{riscv => misc}/sifive_u_otp.c (99%)
>  rename hw/{riscv => misc}/sifive_u_prci.c (99%)
>  delete mode 100644 hw/riscv/trace-events
>
> --
> 2.7.4
>
>



Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that actually works with sg

2020-09-06 Thread Maxim Levitsky
On Sun, 2020-09-06 at 23:26 +0800, Tom Yan wrote:
> I don't disagree with your proposal, but the thing is, do we even need
> another field/limit for case 1? For example, do we *really* need to
> clamp sizes[2] (NBD_INFO_BLOCK_SIZE) in nbd/server.c and
> max_io_sectors (SCSIBlockLimits) in hw/scsi/scsi-disk.c to to any kind
> of "dynamic" limit?

It depends on if we have other block drivers that have IO segment/max transfer 
sizes,
that we need to enforce, other than the SG_IO case.

Knowing that the commit that added these limits to file-posix, which I was 
fixing is relatively
new, I guess there are other cases for these limits.

I'll check this tomorrow.

> 
> Either way I can add another field (`max_pwrite`, maybe?) to
> BlockLimits, as an infrastructure/hint, but what should be switched to
> it, and what value should each block driver set it to, is probably
> beyond what I can take.

Implementation wise, I think I can do this, but I'll wait few days for the
feedback on my proposal.

Thanks for finding this bug!

Best regards,
Maxim Levitsky

> 
> IMHO my patches should be merged first (they are really just fixing a
> regression and some bugs). If anyone finds it necessary and is capable
> and willing to fix the insufficiency of BlockLimits, they can do it
> afterwards with another patch series as an improvement. I can add a
> patch to remove the clamping in nbd/server.c as a perhaps-temporary
> measure to address the original issue, if desired.
> 
> On Sun, 6 Sep 2020 at 20:53, Maxim Levitsky  wrote:
> > On Sun, 2020-09-06 at 19:04 +0800, Tom Yan wrote:
> > > Maybe you want to add some condition for this:
> > > https://github.com/qemu/qemu/blob/v5.1.0/nbd/server.c#L659
> > > Or not clamp it at all.
> > > 
> > > On Sun, 6 Sep 2020 at 18:58, Tom Yan  wrote:
> > > > In commit 867eccfed84f96b54f4a432c510a02c2ce03b430, Levitsky appears
> > > > to have assumed that the only "SCSI Passthrough" is `-device
> > > > scsi-generic`, while the fact is there's also `-device scsi-block`
> > > > (passthrough without the sg driver). Unlike `-device scsi-hd`, getting
> > > > max_sectors is necessary to it (more precisely, hw_max_sectors might
> > > > what matters, but BLKSECTGET reports max_sectors, so).
> > > > 
> > > > I'm unsure about how qemu-nbd works, but the commit clearly wasn't the
> > > > right approach to fix the original issue it addresses. (It should for
> > > > example ignore the max_transfer if it will never matter in to it, or
> > > > overrides it in certain cases; when I glimpsed over
> > > > https://bugzilla.redhat.com/show_bug.cgi?id=1647104, I don't see how
> > > > it could be file-posix problem when it is reporting the right thing,
> > > > regardless of whether "removing" the code helps.)
> > > > 
> > > > I don't think we want to "mark" `-device scsi-block` as sg either. It
> > > > will probably bring even more unexpected problems, because they are
> > > > literally different sets of things behind the scene / in the kernel.
> > 
> > Yes, I did overlook the fact that scsi-block is kind of hybrid passthough 
> > device,
> > doing SG_IO for some things and regular IO for others.
> > 
> > I don't think that my approach was wrong way to fix the problem, but as you 
> > found
> > out, abusing 'bs->sg' hack (which I would be very happy to remove 
> > completely)
> > wasn't a good idea.
> > I actualy was aware of scsi-block and that it does SG_IO but it
> > was forgotten some where on the way.
> > 
> > So in summary what the problem is and what I think is the right solution:
> > 
> > 
> > Each qemu block driver exposes block limits and assumes that they are the 
> > same
> > for two IO interfaces the block driver can expose:
> > 
> > 1. Regular qemu blk_pread/pwrite alike functions
> > 2. blk_ioctl (tiny wrapper against SG_IO), supported by posix-raw on
> >host block devices/sg char devices, and by iscsi
> > 
> > The problem is that these two interfaces can have different block limits.
> > 
> > I don't know about iscsi, but for files, doing regular IO is always 
> > unlimited,
> > since it passes through the kernel block layer and segemented there on
> > demand which is faster that doing it in userspace, while SG_IO is passed as 
> > is
> > to the underlying SCSI device and lacks this segmentation.
> > 
> > Regardless of how NBD uses these limits, I think that these limits should 
> > be correctly
> > exposed by the block drivers, and therefore I propose is that each qemu 
> > block driver
> > would expose a pair of block limits.
> > One for the regular block IO, and other for SG_IO.
> > 
> > Then block driver clients (like scsi devices that you mention, nbd, etc)
> > can choose which limit to use, depending on which IO api they use.
> > The scsi-generic, and scsi-block can use the SG_IO limits,
> > while the rest  can use the normal (unlimited for file I/O) limits, 
> > including the NBD.
> > 
> > Best regards,
> > Maxim Levitsky
> > 
> > > > On Fri, 4 Sep 2020 at 10:09, Tom Yan  wrote:

[PATCH] 9pfs: disable msize warning for synth driver

2020-09-06 Thread Christian Schoenebeck
Previous patch introduced a performance warning being logged on host
side if client connected with an 'msize' <= 8192. Disable this
performance warning for the synth driver to prevent that warning from
being printed whenever the 9pfs (qtest) test cases are running.

Introduce a new export flag V9FS_NO_PERF_WARN for that purpose, which
might also be used to disable such warnings from the CLI in future.

We could have also prevented the warning by simply raising P9_MAX_SIZE
in virtio-9p-test.c to any value larger than 8192, however in the
context of test cases it makes sense running for edge cases, which
includes the lowest 'msize' value supported by the server which is
4096, hence we want to preserve an msize of 4096 for the test client.

Signed-off-by: Christian Schoenebeck 
---
 fsdev/file-op-9p.h | 4 
 hw/9pfs/9p-synth.c | 2 ++
 hw/9pfs/9p.c   | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h
index f2f7772c86..d51cec2f3b 100644
--- a/fsdev/file-op-9p.h
+++ b/fsdev/file-op-9p.h
@@ -64,6 +64,10 @@ typedef struct ExtendedOps {
  */
 #define V9FS_REMAP_INODES   0x0200
 #define V9FS_FORBID_MULTIDEVS   0x0400
+/*
+ * Disables certain performance warnings from being logged on host side.
+ */
+#define V9FS_NO_PERF_WARN   0x0800
 
 #define V9FS_SEC_MASK   0x003C
 
diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index 7eb210ffa8..cec8c0eefc 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -541,6 +541,8 @@ static int synth_init(FsContext *ctx, Error **errp)
 QLIST_INIT(&synth_root.child);
 qemu_mutex_init(&synth_mutex);
 
+ctx->export_flags |= V9FS_NO_PERF_WARN;
+
 /* Add "." and ".." entries for root */
 v9fs_add_dir_node(&synth_root, synth_root.attr->mode,
   "..", synth_root.attr, synth_root.attr->inode);
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 99b6f24fd6..741d222c3f 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1354,7 +1354,7 @@ static void coroutine_fn v9fs_version(void *opaque)
 }
 
 /* 8192 is the default msize of Linux clients */
-if (s->msize <= 8192) {
+if (s->msize <= 8192 && !(s->ctx.export_flags & V9FS_NO_PERF_WARN)) {
 warn_report_once(
 "9p: degraded performance: a reasonable high msize should be "
 "chosen on client/guest side (chosen msize is <= 8192). See "
-- 
2.20.1




[PULL v2 01/46] qemu-iotests: move check-block back to Makefiles

2020-09-06 Thread Paolo Bonzini
check-block has its own test harness, unlike every other test.  If
we capture its output, as is in general nicer to do without V=1,
there will be no sign of progress.  So for lack of a better option
just move the invocation of the test back to Makefile rules.

As a side effect, this will also fix "make check" in --disable-tools
builds, as they were trying to run qemu-iotests without having
made qemu-img before.

Signed-off-by: Paolo Bonzini 
---
 meson.build|  1 -
 tests/Makefile.include | 15 ---
 tests/qemu-iotests/meson.build |  4 
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/meson.build b/meson.build
index 5aaa364730..85f3c01b98 100644
--- a/meson.build
+++ b/meson.build
@@ -1097,7 +1097,6 @@ if have_tools
  dependencies: [block, qemuutil], install: true)
   qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
dependencies: [block, qemuutil], install: true)
-  qemu_block_tools += [qemu_img, qemu_io, qemu_nbd]
 
   subdir('storage-daemon')
   subdir('contrib/rdmacm-mux')
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 9ac8f5b86a..08301f5bc9 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -468,7 +468,6 @@ check-tcg: $(RUN_TCG_TARGET_RULES)
 .PHONY: clean-tcg
 clean-tcg: $(CLEAN_TCG_TARGET_RULES)
 
-
 # Python venv for running tests
 
 .PHONY: check-venv check-acceptance
@@ -523,8 +522,18 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) 
get-vm-images
 # Consolidated targets
 
 .PHONY: check-block check-unit check check-clean get-vm-images
-check-block:
-check-build: build-unit
+check:
+
+ifeq ($(CONFIG_TOOLS)$(CONFIG_POSIX),yy)
+QEMU_IOTESTS_HELPERS-$(CONFIG_LINUX) = 
tests/qemu-iotests/socket_scm_helper$(EXESUF)
+check: check-block
+check-block: $(SRC_PATH)/tests/check-block.sh qemu-img$(EXESUF) \
+   qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
+   $(patsubst %-softmmu,qemu-system-%,$(filter 
%-softmmu,$(TARGET_DIRS)))
+   @$<
+endif
+
+check-build: build-unit $(QEMU_IOTESTS_HELPERS-y)
 
 check-clean:
rm -rf $(check-unit-y) tests/*.o tests/*/*.o $(QEMU_IOTESTS_HELPERS-y)
diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build
index 3de09fb8fa..60470936b4 100644
--- a/tests/qemu-iotests/meson.build
+++ b/tests/qemu-iotests/meson.build
@@ -4,7 +4,3 @@ if 'CONFIG_LINUX' in config_host
 else
 socket_scm_helper = []
 endif
-test('qemu-iotests', sh, args: [files('../check-block.sh')],
- depends: [qemu_block_tools, emulators, socket_scm_helper],
- suite: 'block', timeout: 1)
-
-- 
2.26.2



[PULL v2 00/46] Next round of Meson bugfixes and cleanups

2020-09-06 Thread Paolo Bonzini
The following changes since commit 227de21ed0759e275a469394af72c999d0134bb5:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20200903' into 
staging (2020-09-05 15:30:41 +0100)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 6264b35324d3766d3c2ff369c4e8ecba8bd5b571:

  meson: remove linkage of sdl to baum (2020-09-06 19:50:57 +0200)


meson related:
* convert unit tests
* bugfixes for mtest2make
* miscellaneous bugfixes
* dead code removal and configure cleanups
* oss-fuzz fixes
* msys fixes


Alexander Bulekov (3):
  oss-fuzz: fix rpath
  meson: specify fuzz linker script as a project arg
  fuzz: Add support for custom fuzzing library

Bruce Rogers (1):
  meson: remove linkage of sdl to baum

Marc-André Lureau (12):
  meson: build qapi tests library
  meson: declare tasn1 dependency
  meson: declare keyutils dependency
  meson: convert qht-bench
  meson: move keyutils dependency check
  meson: remove old socket_scm_helper rule
  meson: convert vhost-user-bridge
  meson: convert atomic*-bench
  tests: do not print benchmark output to stdout
  tests/migration/stress: remove unused exit_success
  meson: fix migration/stress compilation with glibc>=2.30
  meson: convert migration/initrd-stress

Paolo Bonzini (25):
  qemu-iotests: move check-block back to Makefiles
  mtest2make: split environment from test command
  mtest2make: split working directory from test command
  mtest2make: hide output of successful tests
  mtest2make: unify tests that appear in multiple suites
  meson: remove b_lundef option
  configure: do not include absolute paths in -I and -L paths
  configure: include cross sdl2-config in meson cross file
  ninjatool: use constant names for stamp files
  meson: fix libqos linking
  meson: convert the speed tests
  configure: remove dead code for in-tree builds
  meson: compute config_all_devices directly
  Makefile: remove dead variables and includes
  Makefile: inline the relevant parts of rules.mak
  configure: move disassembler configuration to meson
  configure: move C++ compiler handling to meson
  meson: keep all compiler flags detection together
  configure: move -ldl test to meson
  configure: remove unnecessary libm test
  configure: do not look for install(1)
  meson: get glib compilation flags from GLIB_CFLAGS
  configure: do not include dependency flags in QEMU_CFLAGS and LIBS
  configure: drop dead variables and functions
  docs: suggest Meson replacements for various configure functions

Thomas Huth (2):
  tests/Makefile: test-image-locking needs CONFIG_POSIX
  meson: convert the unit tests

Yonggang Luo (3):
  tests: handling signal on win32 properly
  configure: update dtc submodule
  meson: Convert undefsym.sh to undefsym.py

 .gitignore   |   2 -
 Makefile |  63 +++---
 Makefile.objs|  34 
 accel/tcg/meson.build|   2 +-
 chardev/meson.build  |   4 +-
 configure| 353 -
 disas/meson.build|   4 +-
 docs/devel/build-system.rst  |  18 +-
 hw/arm/meson.build   |   2 +-
 hw/mips/meson.build  |   2 +-
 hw/riscv/meson.build |   2 +-
 meson.build  | 152 ++
 monitor/meson.build  |   2 +-
 rules.mak| 158 ---
 scripts/empty.c  |   6 +
 scripts/grepy.sh |   3 -
 scripts/mtest2make.py| 100 +-
 scripts/ninjatool.py |   8 +-
 scripts/oss-fuzz/build.sh|   2 +-
 scripts/test-driver.py   |  35 
 scripts/undefsym.py  |  49 +
 scripts/undefsym.sh  |  20 --
 tests/Makefile.include   | 414 ++-
 tests/benchmark-crypto-cipher.c  |   8 +-
 tests/benchmark-crypto-hash.c|   2 +-
 tests/benchmark-crypto-hmac.c|   8 +-
 tests/docker/Makefile.include|   4 +
 tests/include/meson.build|  16 ++
 tests/meson.build| 257 
 tests/migration/initrd-stress.sh |  10 +
 tests/migration/meson.build  |  14 ++
 tests/migration/stress.c |  15 +-
 tests/qemu-iotests/meson.build   |   4 -
 tests/qtest/fuzz/meson.build |   7 +-
 tests/qtest/libqos/meson.build   |   9 +-
 tests/tcg/Makefile.qemu  |   2 -
 tests/test-crypto-secret.c   |  10 +-
 tests/test-qga.c |   2 +-
 tests/test-replication.c |   4 +
 39 files changed, 686 insertions(+), 1121 deletions(-)
 delete mode 100644 Makefile.objs

Re: [PULL 0/4] Ui 20200904 patches

2020-09-06 Thread Peter Maydell
On Fri, 4 Sep 2020 at 08:04, Gerd Hoffmann  wrote:
>
> The following changes since commit 67a7bfe560a1bba59efab085cb3430f45176d382:
>
>   Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-09=
> -03' into staging (2020-09-03 16:58:25 +0100)
>
> are available in the Git repository at:
>
>   git://git.kraxel.org/qemu tags/ui-20200904-pull-request
>
> for you to fetch changes up to dc26435edb469ebdadf298dc3945b95d08f743d4:
>
>   ui/gtk: Update refresh interval after widget is realized (2020-09-04 07:32:=
> 28 +0200)
>
> 
> ui: memleak fixes.
> gtk: refresh interval fix.
> spice: add mouse buttons.
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.2
for any user-visible changes.

-- PMM



Re: [PULL v2 00/46] Next round of Meson bugfixes and cleanups

2020-09-06 Thread Peter Maydell
On Sun, 6 Sep 2020 at 18:56, Paolo Bonzini  wrote:
>
> The following changes since commit 227de21ed0759e275a469394af72c999d0134bb5:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20200903' into 
> staging (2020-09-05 15:30:41 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 6264b35324d3766d3c2ff369c4e8ecba8bd5b571:
>
>   meson: remove linkage of sdl to baum (2020-09-06 19:50:57 +0200)
>
> 
> meson related:
> * convert unit tests
> * bugfixes for mtest2make
> * miscellaneous bugfixes
> * dead code removal and configure cleanups
> * oss-fuzz fixes
> * msys fixes

Build failure, Windows (this is the second "uint" type usage
I've seen today...):

../../tests/test-vmstate.c: In function 'int_cmp':
../../tests/test-vmstate.c:884:5: error: unknown type name 'uint'
 uint ua = GPOINTER_TO_UINT(a);
 ^
../../tests/test-vmstate.c:885:5: error: unknown type name 'uint'
 uint ub = GPOINTER_TO_UINT(b);
 ^
Makefile.ninja:5443: recipe for target
'tests/test-vmstate.exe.p/test-vmstate.c.obj' failed
make: *** [tests/test-vmstate.exe.p/test-vmstate.c.obj] Error 1
make: *** Waiting for unfinished jobs
../../tests/test-util-filemonitor.c: In function 'test_file_monitor_events':
../../tests/test-util-filemonitor.c:620:17: error: too many arguments
to function 'mkdir'
 if (mkdir(pathsrc, 0700) < 0) {
 ^
In file included from
/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/unistd.h:10:0,
 from /home/petmay01/qemu-for-merges/include/qemu/osdep.h:93,
 from ../../tests/test-util-filemonitor.c:21:
/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/io.h:280:15: note:
declared here
   int __cdecl mkdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
   ^



Build failure, OpenBSD:

In file included from ../src/hw/arm/nseries.c:30:
In file included from /home/qemu/qemu-test.yhbDti/src/include/hw/arm/omap.h:24:
In file included from
/home/qemu/qemu-test.yhbDti/src/include/hw/input/tsc2xxx.h:14:
/home/qemu/qemu-test.yhbDti/src/include/ui/console.h:11:11: fatal
error: 'epoxy/gl.h' file not found
# include 
  ^~~~
1 error generated.
gmake: *** [Makefile.ninja:1735:
libqemu-aarch64-softmmu.fa.p/hw_arm_nseries.c.o] Error 1



Odd warning on most but not all of the builds, though they went on to
complete OK:

make: Entering directory '/home/peter.maydell/qemu-freebsd/build'
/home/peter.maydell/qemu-freebsd/tests/Makefile.include:144: warning:
overriding recipe for target 'check-block'
Makefile.mtest:1345: warning: ignoring old recipe for target 'check-block'
config-host.mak is out-of-date, running configure
cross containers  no

NOTE: guest cross-compilers enabled: aarch64-linux-gnu-gcc cc
aarch64-linux-gnu-gcc cc
/usr/bin/python3 /home/peter.maydell/qemu-freebsd/meson/meson.py
--internal regenerate /home/peter.maydell/qemu-freebsd
/home/peter.maydell/qemu-freebsd/build --backend ninja
The Meson build system
Version: 0.55.1
[etc]


x86-64 clang build failed at the link stage (this is config we've
talked about before with
'../../configure' '--cc=clang' '--cxx=clang++' '--enable-gtk'
'--extra-cflags=-fsanitize=undefined  -fno-sanitize=shift-base
-Werror'
but where the clang++ doesn't work because the right libstdc++ happens
not to be present):

Linking target qemu-alpha
libcommon.fa.p/cpus-common.c.o: In function `cpu_list_add':
/home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:80:
undefined reference to `__ubsan_handle_type_mismatch_v1'
/home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:80:
undefined reference to `__ubsan_handle_type_mismatch_v1'
libcommon.fa.p/cpus-common.c.o: In function `cpu_get_free_index':
/home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:68:
undefined reference to `__ubsan_handle_type_mismatch_v1'
/home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:68:
undefined reference to `__ubsan_handle_type_mismatch_v1'
/home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:67:
undefined reference to `__ubsan_handle_type_mismatch_v1'
libcommon.fa.p/cpus-common.c.o:/home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:67:
more undefined references to `__ubsan_handle_type_mismatch_v1' follow
collect2: error: ld returned 1 exit status

thanks
-- PMM



QEMU | Pipeline #186543266 has failed for master | 7c37270b

2020-09-06 Thread GitLab via


Your pipeline has failed.

Project: QEMU ( https://gitlab.com/qemu-project/qemu )
Branch: master ( https://gitlab.com/qemu-project/qemu/-/commits/master )

Commit: 7c37270b ( 
https://gitlab.com/qemu-project/qemu/-/commit/7c37270b3fbe3d034ba80e488761461676e21eb4
 )
Commit Message: Merge remote-tracking branch 'remotes/kraxel/ta...
Commit Author: Peter Maydell ( https://gitlab.com/pm215 )

Pipeline #186543266 ( 
https://gitlab.com/qemu-project/qemu/-/pipelines/186543266 ) triggered by Alex 
Bennée ( https://gitlab.com/stsquad )
had 1 failed build.

Job #723384547 ( https://gitlab.com/qemu-project/qemu/-/jobs/723384547/raw )

Stage: test
Name: acceptance-system-fedora
Trace: 19:03:06 ERROR| 
19:03:06 ERROR| Reproduced traceback from: 
/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py:846
19:03:06 ERROR| Traceback (most recent call last):
19:03:06 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/acceptance/avocado_qemu/__init__.py", 
line 171, in setUp
19:03:06 ERROR| self.cancel("No QEMU binary defined or found in the build 
tree")
19:03:06 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py",
 line 1081, in cancel
19:03:06 ERROR| raise exceptions.TestCancel(message)
19:03:06 ERROR| avocado.core.exceptions.TestCancel: No QEMU binary defined or 
found in the build tree
19:03:06 ERROR| 
19:03:06 ERROR| CANCEL 
31-tests/acceptance/vnc.py:Vnc.test_change_password_requires_a_password -> 
TestCancel: No QEMU binary defined or found in the build tree
19:03:06 INFO | 
19:03:06 DEBUG| PARAMS (key=arch, path=*, default=None) => None
19:03:06 DEBUG| PARAMS (key=machine, path=*, default=None) => None
19:03:06 DEBUG| PARAMS (key=qemu_bin, path=*, default=None) => None
19:03:06 ERROR| 
19:03:06 ERROR| Reproduced traceback from: 
/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py:846
19:03:06 ERROR| Traceback (most recent call last):
19:03:06 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/acceptance/avocado_qemu/__init__.py", 
line 171, in setUp
19:03:06 ERROR| self.cancel("No QEMU binary defined or found in the build 
tree")
19:03:06 ERROR|   File 
"/builds/qemu-project/qemu/build/tests/venv/lib64/python3.8/site-packages/avocado/core/test.py",
 line 1081, in cancel
19:03:06 ERROR| raise exceptions.TestCancel(message)
19:03:06 ERROR| avocado.core.exceptions.TestCancel: No QEMU binary defined or 
found in the build tree
19:03:06 ERROR| 
19:03:06 ERROR| CANCEL 32-tests/acceptance/vnc.py:Vnc.test_change_password -> 
TestCancel: No QEMU binary defined or found in the build tree
19:03:06 INFO | 
$ du -chs ${CI_PROJECT_DIR}/avocado-cache
323M/builds/qemu-project/qemu/avocado-cache
323Mtotal
section_end:1599418988:after_script
ERROR: Job failed: exit code 1



-- 
You're receiving this email because of your account on gitlab.com.





RE: [PATCH v4 2/2] file-posix: add sg_get_max_segments that actually works with sg

2020-09-06 Thread Dmitry Fomichev


> -Original Message-
> From: Qemu-block  bounces+dmitry.fomichev=wdc@nongnu.org> On Behalf Of Maxim
> Levitsky
> Sent: Sunday, September 6, 2020 1:06 PM
> To: Tom Yan ; ebl...@redhat.com;
> pbonz...@redhat.com; f...@euphon.net; anie...@linux.vnet.ibm.com;
> kw...@redhat.com; mre...@redhat.com
> Cc: qemu-devel@nongnu.org; qemu-bl...@nongnu.org
> Subject: Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that
> actually works with sg
> 
> On Sun, 2020-09-06 at 23:26 +0800, Tom Yan wrote:
> > I don't disagree with your proposal, but the thing is, do we even need
> > another field/limit for case 1? For example, do we *really* need to
> > clamp sizes[2] (NBD_INFO_BLOCK_SIZE) in nbd/server.c and
> > max_io_sectors (SCSIBlockLimits) in hw/scsi/scsi-disk.c to to any kind
> > of "dynamic" limit?
> 
> It depends on if we have other block drivers that have IO segment/max
> transfer sizes,
> that we need to enforce, other than the SG_IO case.
> 
> Knowing that the commit that added these limits to file-posix, which I was
> fixing is relatively
> new, I guess there are other cases for these limits.
> 
> I'll check this tomorrow.
> 
> >
> > Either way I can add another field (`max_pwrite`, maybe?) to
> > BlockLimits, as an infrastructure/hint, but what should be switched to
> > it, and what value should each block driver set it to, is probably
> > beyond what I can take.
> 
> Implementation wise, I think I can do this, but I'll wait few days for the
> feedback on my proposal.
> 
> Thanks for finding this bug!

There was also 
https://lore.kernel.org/qemu-devel/20200811225122.17342-2-dmitry.fomic...@wdc.com/
posted three weeks ago, but, seemingly, it was ignored... sorry if this
bug is already being fixed in a different way, but I think the fix presented
in that patch is worth considering.

Very best,
Dmitry

> 
> Best regards,
>   Maxim Levitsky
> 
> >
> > IMHO my patches should be merged first (they are really just fixing a
> > regression and some bugs). If anyone finds it necessary and is capable
> > and willing to fix the insufficiency of BlockLimits, they can do it
> > afterwards with another patch series as an improvement. I can add a
> > patch to remove the clamping in nbd/server.c as a perhaps-temporary
> > measure to address the original issue, if desired.
> >
> > On Sun, 6 Sep 2020 at 20:53, Maxim Levitsky 
> wrote:
> > > On Sun, 2020-09-06 at 19:04 +0800, Tom Yan wrote:
> > > > Maybe you want to add some condition for this:
> > > > https://github.com/qemu/qemu/blob/v5.1.0/nbd/server.c#L659
> > > > Or not clamp it at all.
> > > >
> > > > On Sun, 6 Sep 2020 at 18:58, Tom Yan  wrote:
> > > > > In commit 867eccfed84f96b54f4a432c510a02c2ce03b430, Levitsky
> appears
> > > > > to have assumed that the only "SCSI Passthrough" is `-device
> > > > > scsi-generic`, while the fact is there's also `-device scsi-block`
> > > > > (passthrough without the sg driver). Unlike `-device scsi-hd`, getting
> > > > > max_sectors is necessary to it (more precisely, hw_max_sectors
> might
> > > > > what matters, but BLKSECTGET reports max_sectors, so).
> > > > >
> > > > > I'm unsure about how qemu-nbd works, but the commit clearly
> wasn't the
> > > > > right approach to fix the original issue it addresses. (It should for
> > > > > example ignore the max_transfer if it will never matter in to it, or
> > > > > overrides it in certain cases; when I glimpsed over
> > > > > https://bugzilla.redhat.com/show_bug.cgi?id=1647104, I don't see
> how
> > > > > it could be file-posix problem when it is reporting the right thing,
> > > > > regardless of whether "removing" the code helps.)
> > > > >
> > > > > I don't think we want to "mark" `-device scsi-block` as sg either. It
> > > > > will probably bring even more unexpected problems, because they
> are
> > > > > literally different sets of things behind the scene / in the kernel.
> > >
> > > Yes, I did overlook the fact that scsi-block is kind of hybrid passthough
> device,
> > > doing SG_IO for some things and regular IO for others.
> > >
> > > I don't think that my approach was wrong way to fix the problem, but as
> you found
> > > out, abusing 'bs->sg' hack (which I would be very happy to remove
> completely)
> > > wasn't a good idea.
> > > I actualy was aware of scsi-block and that it does SG_IO but it
> > > was forgotten some where on the way.
> > >
> > > So in summary what the problem is and what I think is the right solution:
> > >
> > >
> > > Each qemu block driver exposes block limits and assumes that they are
> the same
> > > for two IO interfaces the block driver can expose:
> > >
> > > 1. Regular qemu blk_pread/pwrite alike functions
> > > 2. blk_ioctl (tiny wrapper against SG_IO), supported by posix-raw on
> > >host block devices/sg char devices, and by iscsi
> > >
> > > The problem is that these two interfaces can have different block limits.
> > >
> > > I don't know about iscsi, but for files, doing regular IO is always 
> > > unlimited,
> > > since it 

[PULL 38/45] configure: drop dead variables and functions

2020-09-06 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 configure | 16 +---
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/configure b/configure
index 249da3dd00..d63d12ae96 100755
--- a/configure
+++ b/configure
@@ -331,7 +331,6 @@ audio_drv_list=""
 block_drv_rw_whitelist=""
 block_drv_ro_whitelist=""
 host_cc="cc"
-libs_tools=""
 audio_win_int=""
 libs_qga=""
 debug_info="yes"
@@ -439,7 +438,6 @@ mingw32="no"
 gcov="no"
 EXESUF=""
 HOST_DSOSUF=".so"
-LDFLAGS_SHARED="-shared"
 modules="no"
 module_upgrades="no"
 prefix="/usr/local"
@@ -863,7 +861,6 @@ Darwin)
   darwin="yes"
   hax="yes"
   hvf="yes"
-  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
   if [ "$cpu" = "x86_64" ] ; then
 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
 QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
@@ -4946,7 +4943,7 @@ elif compile_prog "" "$pthread_lib -lrt" ; then
   LIBS="$LIBS -lrt"
 fi
 
-# Check whether we need to link libutil for openpty()
+# Check whether we have openpty() in either libc or libutil
 cat > $TMPC << EOF
 extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
 int main(void) { return openpty(0, 0, 0, 0, 0); }
@@ -4957,7 +4954,6 @@ if compile_prog "" "" ; then
   have_openpty="yes"
 else
   if compile_prog "" "-lutil" ; then
-libs_tools="-lutil $libs_tools"
 have_openpty="yes"
   fi
 fi
@@ -6505,12 +6501,6 @@ else
 cxx=
 fi
 
-echo_version() {
-if test "$1" = "yes" ; then
-echo "($2)"
-fi
-}
-
 config_host_mak="config-host.mak"
 
 echo "# Automatically generated by configure - do not modify" > 
$config_host_mak
@@ -7428,7 +7418,6 @@ echo "NM=$nm" >> $config_host_mak
 echo "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
-echo "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
@@ -7440,13 +7429,10 @@ if test "$sparse" = "yes" ; then
 fi
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
-echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
-echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
-echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
 echo "LIBS_QGA=$libs_qga" >> $config_host_mak
 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
-- 
2.26.2



[PULL 17/45] meson: convert the unit tests

2020-09-06 Thread Paolo Bonzini
From: Thomas Huth 

Signed-off-by: Marc-André Lureau 
Message-Id: <20200828110734.1638685-7-marcandre.lur...@redhat.com>
Signed-off-by: Paolo Bonzini 
Signed-off-by: Thomas Huth 
---
 tests/Makefile.include | 254 +
 tests/meson.build  | 174 +++-
 tests/test-qga.c   |   2 +-
 3 files changed, 177 insertions(+), 253 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 490a923384..ce0a9fd780 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -38,254 +38,20 @@ export SRC_PATH
 SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
$(wildcard $(SRC_PATH)/default-configs/*-softmmu.mak)))
 
-check-unit-y += tests/check-qdict$(EXESUF)
-check-unit-y += tests/check-block-qdict$(EXESUF)
-check-unit-y += tests/check-qnum$(EXESUF)
-check-unit-y += tests/check-qstring$(EXESUF)
-check-unit-y += tests/check-qlist$(EXESUF)
-check-unit-y += tests/check-qnull$(EXESUF)
-check-unit-y += tests/check-qobject$(EXESUF)
-check-unit-y += tests/check-qjson$(EXESUF)
-check-unit-y += tests/check-qlit$(EXESUF)
-check-unit-y += tests/test-qobject-output-visitor$(EXESUF)
-check-unit-y += tests/test-clone-visitor$(EXESUF)
-check-unit-y += tests/test-qobject-input-visitor$(EXESUF)
-check-unit-$(CONFIG_SOFTMMU) += tests/test-qmp-cmds$(EXESUF)
-check-unit-y += tests/test-string-input-visitor$(EXESUF)
-check-unit-y += tests/test-string-output-visitor$(EXESUF)
-check-unit-y += tests/test-qmp-event$(EXESUF)
-check-unit-y += tests/test-opts-visitor$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-coroutine$(EXESUF)
-check-unit-y += tests/test-visitor-serialization$(EXESUF)
-check-unit-$(CONFIG_SOFTMMU) += tests/test-iov$(EXESUF)
-check-unit-y += tests/test-bitmap$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-aio$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-aio-multithread$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-throttle$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-thread-pool$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-hbitmap$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-bdrv-drain$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-bdrv-graph-mod$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-blockjob$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-blockjob-txn$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-block-backend$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-block-iothread$(EXESUF)
-ifeq ($(CONFIG_POSIX),y)
-check-unit-$(CONFIG_BLOCK) += tests/test-image-locking$(EXESUF)
-endif
-check-unit-y += tests/test-x86-cpuid$(EXESUF)
-# all code tested by test-x86-cpuid is inside topology.h
-ifeq ($(CONFIG_SOFTMMU),y)
-check-unit-y += tests/test-xbzrle$(EXESUF)
-check-unit-$(CONFIG_POSIX) += tests/test-vmstate$(EXESUF)
-endif
-check-unit-y += tests/test-cutils$(EXESUF)
-check-unit-y += tests/test-shift128$(EXESUF)
-check-unit-y += tests/test-mul64$(EXESUF)
-check-unit-y += tests/test-int128$(EXESUF)
-# all code tested by test-int128 is inside int128.h
-check-unit-y += tests/rcutorture$(EXESUF)
-check-unit-y += tests/test-rcu-list$(EXESUF)
-check-unit-y += tests/test-rcu-simpleq$(EXESUF)
-check-unit-y += tests/test-rcu-tailq$(EXESUF)
-check-unit-y += tests/test-rcu-slist$(EXESUF)
-check-unit-y += tests/test-qdist$(EXESUF)
-check-unit-y += tests/test-qht$(EXESUF)
-check-unit-y += tests/test-qht-par$(EXESUF)
-check-unit-y += tests/test-bitops$(EXESUF)
-check-unit-y += tests/test-bitcnt$(EXESUF)
-check-unit-y += tests/test-qgraph$(EXESUF)
-check-unit-y += tests/check-qom-interface$(EXESUF)
-check-unit-y += tests/check-qom-proplist$(EXESUF)
-check-unit-y += tests/test-qemu-opts$(EXESUF)
-check-unit-y += tests/test-keyval$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-write-threshold$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-crypto-hash$(EXESUF)
 check-speed-$(CONFIG_BLOCK) += tests/benchmark-crypto-hash$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-crypto-hmac$(EXESUF)
 check-speed-$(CONFIG_BLOCK) += tests/benchmark-crypto-hmac$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-crypto-cipher$(EXESUF)
 check-speed-$(CONFIG_BLOCK) += tests/benchmark-crypto-cipher$(EXESUF)
-check-unit-$(CONFIG_BLOCK) += tests/test-crypto-secret$(EXESUF)
-check-unit-$(call land,$(CONFIG_BLOCK),$(CONFIG_GNUTLS)) += 
tests/test-crypto-tlscredsx509$(EXESUF)
-check-unit-$(call land,$(CONFIG_BLOCK),$(CONFIG_GNUTLS)) += 
tests/test-crypto-tlssession$(EXESUF)
-ifndef CONFIG_TSAN
-# Some tests: test-char, test-qdev-global-props, and test-qga,
-# are not runnable under TSan due to a known issue.
-# https://github.com/google/sanitizers/issues/1116
-check-unit-$(CONFIG_SOFTMMU) += tests/test-char$(EXESUF)
-check-unit-$(CONFIG_SOFTMMU) += tests/test-qdev-global-props$(EXESUF)
-ifeq ($(CONFIG_GUEST_AGENT),y)
-check-unit-$(call land,$(CONFIG_LINUX),$(CONFIG_VIRTIO_SERIAL)) += 
tests/test-qga$(EXESUF)
-endif
-endif
-check-unit-$(CONFIG_SOFTMMU) += tests/test-timed-average$(EXESUF)
-check-unit-$

[PULL 00/45] Next round of Meson bugfixes and cleanups

2020-09-06 Thread Paolo Bonzini
The following changes since commit 227de21ed0759e275a469394af72c999d0134bb5:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20200903' into 
staging (2020-09-05 15:30:41 +0100)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 17701f5a5d5ca20e9af8034b219c9b11c66f325a:

  meson: remove linkage of sdl to baum (2020-09-06 22:07:58 +0200)


meson related:
* convert unit tests
* bugfixes for mtest2make
* miscellaneous bugfixes
* dead code removal and configure cleanups
* oss-fuzz fixes
* msys fixes


Alexander Bulekov (3):
  oss-fuzz: fix rpath
  meson: specify fuzz linker script as a project arg
  fuzz: Add support for custom fuzzing library

Bruce Rogers (1):
  meson: remove linkage of sdl to baum

Marc-André Lureau (12):
  meson: build qapi tests library
  meson: declare tasn1 dependency
  meson: declare keyutils dependency
  meson: convert qht-bench
  meson: move keyutils dependency check
  meson: remove old socket_scm_helper rule
  meson: convert vhost-user-bridge
  meson: convert atomic*-bench
  tests: do not print benchmark output to stdout
  tests/migration/stress: remove unused exit_success
  meson: fix migration/stress compilation with glibc>=2.30
  meson: convert migration/initrd-stress

Paolo Bonzini (24):
  qemu-iotests: move check-block back to Makefiles
  mtest2make: split environment from test command
  mtest2make: split working directory from test command
  mtest2make: hide output of successful tests
  mtest2make: unify tests that appear in multiple suites
  meson: remove b_lundef option
  configure: do not include absolute paths in -I and -L paths
  configure: include cross sdl2-config in meson cross file
  ninjatool: use constant names for stamp files
  meson: fix libqos linking
  meson: convert the speed tests
  configure: remove dead code for in-tree builds
  meson: compute config_all_devices directly
  Makefile: remove dead variables and includes
  Makefile: inline the relevant parts of rules.mak
  configure: move disassembler configuration to meson
  meson: keep all compiler flags detection together
  configure: move -ldl test to meson
  configure: remove unnecessary libm test
  configure: do not look for install(1)
  meson: get glib compilation flags from GLIB_CFLAGS
  configure: do not include dependency flags in QEMU_CFLAGS and LIBS
  configure: drop dead variables and functions
  docs: suggest Meson replacements for various configure functions

Thomas Huth (2):
  tests/Makefile: test-image-locking needs CONFIG_POSIX
  meson: convert the unit tests

Yonggang Luo (3):
  tests: handling signal on win32 properly
  configure: update dtc submodule
  meson: Convert undefsym.sh to undefsym.py

 .gitignore   |   2 -
 Makefile |  63 +++---
 Makefile.objs|  34 
 accel/tcg/meson.build|   2 +-
 chardev/meson.build  |   4 +-
 configure| 303 
 disas/meson.build|   4 +-
 docs/devel/build-system.rst  |  18 +-
 hw/arm/meson.build   |   2 +-
 hw/mips/meson.build  |   2 +-
 hw/riscv/meson.build |   2 +-
 meson.build  | 124 +---
 monitor/meson.build  |   2 +-
 rules.mak| 158 ---
 scripts/grepy.sh |   3 -
 scripts/mtest2make.py| 100 +-
 scripts/ninjatool.py |   8 +-
 scripts/oss-fuzz/build.sh|   2 +-
 scripts/test-driver.py   |  35 
 scripts/undefsym.py  |  49 +
 scripts/undefsym.sh  |  20 --
 tests/Makefile.include   | 414 ++-
 tests/benchmark-crypto-cipher.c  |   8 +-
 tests/benchmark-crypto-hash.c|   2 +-
 tests/benchmark-crypto-hmac.c|   8 +-
 tests/docker/Makefile.include|   4 +
 tests/include/meson.build|  16 ++
 tests/meson.build| 256 
 tests/migration/initrd-stress.sh |  10 +
 tests/migration/meson.build  |  14 ++
 tests/migration/stress.c |  15 +-
 tests/qemu-iotests/meson.build   |   4 -
 tests/qtest/fuzz/meson.build |   7 +-
 tests/qtest/libqos/meson.build   |   9 +-
 tests/tcg/Makefile.qemu  |   2 -
 tests/test-crypto-secret.c   |  10 +-
 tests/test-qga.c |   2 +-
 tests/test-replication.c |   4 +
 ui/meson.build   |   1 +
 39 files changed, 659 insertions(+), 1064 deletions(-)
 delete mode 100644 Makefile.objs
 delete mode 100644 rules.mak
 delete mode 100755 scripts/g

[REPORT] Nightly Performance Tests - Sunday, September 6, 2020

2020-09-06 Thread Ahmed Karaman

Host CPU : Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Host Memory  : 15.49 GB

Start Time (UTC) : 2020-09-06 22:30:01
End Time (UTC)   : 2020-09-06 23:03:15
Execution Time   : 0:33:13.596113

Status   : SUCCESS

Note:
Changes denoted by '-' are less than 0.01%.


SUMMARY REPORT - COMMIT 7c37270b

AVERAGE RESULTS

Target  Instructions  Latest  v5.1.0
--    --  --
aarch642 158 368 938   - +1.694%
alpha  1 914 974 770   - +3.525%
arm8 076 533 928   - +2.308%
hppa   4 261 662 205   - +3.163%
m68k   2 690 304 604   - +7.135%
mips   1 862 052 805   - +2.495%
mipsel 2 008 238 496   - +2.676%
mips64 1 918 641 080   - +2.818%
mips64el   2 051 560 694   - +3.026%
ppc2 480 167 504   - +3.109%
ppc64  2 576 714 539   - +3.143%
ppc64le2 558 857 542   - +3.173%
riscv641 406 726 161   - +2.652%
s390x  3 158 150 495   - +3.119%
sh42 364 464 886   - +3.331%
sparc643 318 827 014   - +3.861%
x86_64 1 775 819 330   - +2.157%


   DETAILED RESULTS

Test Program: dijkstra_double

Target  Instructions  Latest  v5.1.0
--    --  --
aarch643 062 603 221   - +1.424%
alpha  3 191 870 253   - +3.696%
arm   16 357 297 762   - +2.348%
hppa   7 228 377 811   - +3.086%
m68k   4 294 069 988   - +9.693%
mips   3 051 466 603   - +2.428%
mipsel 3 231 546 446   -  +2.87%
mips64 3 245 832 942   - +2.596%
mips64el   3 414 222 197   - +3.021%
ppc4 914 551 625   -  +4.74%
ppc64  5 098 153 168   - +4.565%
ppc64le5 082 421 772   -  +4.58%
riscv642 192 309 680   - +1.956%
s390x  4 584 599 723   - +2.898%
sh43 949 056 427   - +3.464%
sparc644 586 233 308   - +4.238%
x86_64 2 484 125 760   - +1.752%


Test Program: dijkstra_int32

Target  Instructions  Latest  v5.1.0
--    --  --
aarch642 210 214 520   - +1.494%
alpha  1 494 138 832   - +2.151%
arm8 263 050 249   - +2.667%
hppa   5 207 295 533   - +3.046%
m68k   1 725 891 138   - +2.529%
mips   1 495 259 637   - +1.494%
mipsel 1 497 166 282   -  +1.48%
mips64 1 715 436 791   - +1.894%
mips64el   1 695 217 041   - +1.909%
ppc2 014 591 618   - +1.821%
ppc64  2 206 271 717   - +2.139%
ppc64le2 198 003 699   - +2.146%
riscv641 354 920 580   - +2.396%
s390x  2 916 104 932   - +1.236%
sh41 990 549 868   -  +2.67%
sparc642 874 269 567   - +3.831%
x86_64 1 554 016 064   - +2.122%


Test Program: matmult_double

Target  Instructions  Latest  v5.1.0
--    --  --
aarch641 412 274 274   - +0.302%
alpha  3 233 999 758   - +7.473%
arm8 545 308 683   -  +1.09%
hppa   3 483 506 445   - +4.466%
m68k   3 919 121 861   -+18.433%
mips   2 344 796 448   - +4.092%
mipsel 3 329 919 320   - +5.178%
mips64 2 359 046 997   - +4.076%
mips

Re: [PATCH 01/13] pci: pass along the return value of dma_memory_rw

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:47写道:
>
> From: Klaus Jensen 
>
> Some might actually care about the return value of dma_memory_rw. So
> let us pass it along instead of ignoring it.
>
> There are no existing users of the return value, so this patch should be
> safe.
>
> Signed-off-by: Klaus Jensen 
> Reviewed-by: Philippe Mathieu-Daudé 
> Reviewed-by: Michael S. Tsirkin 
> Acked-by: Keith Busch 
> Message-Id: <20191011070141.188713-2-...@irrelevant.dk>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/hw/pci/pci.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 4ca7258b5b7..896cef9ad47 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -788,8 +788,7 @@ static inline AddressSpace 
> *pci_get_address_space(PCIDevice *dev)
>  static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr,
>   void *buf, dma_addr_t len, DMADirection dir)
>  {
> -dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir);
> -return 0;
> +return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir);
>  }
>
>  static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr,
> --
> 2.26.2
>
>



[PATCH] hw/input/tsc2xxx: Reduce MouseTransformInfo structure exposure

2020-09-06 Thread Philippe Mathieu-Daudé
Commit a5d7eb6534a ("Add TSC2301 touchscreen & keypad controller")
added the MouseTransformInfo declaration in "ui/console.h",
however it is only used in "hw/input/tsc2xxx.h".
Reduce the structure exposure by moving it to the single include
where it is used.

This should fix a build failure on OpenBSD:

  In file included from hw/arm/nseries.c:30:
  In file included from include/hw/arm/omap.h:24:
  In file included from include/hw/input/tsc2xxx.h:14:
  include/ui/console.h:11:11: fatal error: 'epoxy/gl.h' file not found
  # include 
^~~~
  1 error generated.
  gmake: *** [Makefile.ninja:1735:
  libqemu-aarch64-softmmu.fa.p/hw_arm_nseries.c.o] Error 1

Reported-by: Peter Maydell 
Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/input/tsc2xxx.h | 8 +++-
 include/ui/console.h   | 8 
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h
index 3cd8f1bf55b..5b76ebc1776 100644
--- a/include/hw/input/tsc2xxx.h
+++ b/include/hw/input/tsc2xxx.h
@@ -11,7 +11,13 @@
 #ifndef HW_INPUT_TSC2XXX_H
 #define HW_INPUT_TSC2XXX_H
 
-#include "ui/console.h"
+typedef struct MouseTransformInfo {
+/* Touchscreen resolution */
+int x;
+int y;
+/* Calibration values as used/generated by tslib */
+int a[7];
+} MouseTransformInfo;
 
 typedef struct uWireSlave {
 uint16_t (*receive)(void *opaque);
diff --git a/include/ui/console.h b/include/ui/console.h
index f35b4fc082b..30eed00dfcd 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -65,14 +65,6 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
 
 void kbd_put_ledstate(int ledstate);
 
-typedef struct MouseTransformInfo {
-/* Touchscreen resolution */
-int x;
-int y;
-/* Calibration values as used/generated by tslib */
-int a[7];
-} MouseTransformInfo;
-
 void hmp_mouse_set(Monitor *mon, const QDict *qdict);
 
 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
-- 
2.26.2




Re: [PATCH 04/13] dma: Let dma_memory_set() propagate MemTxResult

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:47写道:
>
> address_space_write() returns a MemTxResult type.
> Do not discard it, return it to the caller.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/sysemu/dma.h | 15 ++-
>  dma-helpers.c|  7 ---
>  2 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index 19bc9ad1b69..ad8a3f82f47 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -123,7 +123,20 @@ static inline int dma_memory_write(AddressSpace *as, 
> dma_addr_t addr,
>   DMA_DIRECTION_FROM_DEVICE);
>  }
>
> -int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t 
> len);
> +/**
> + * dma_memory_set: Fill memory with a constant byte from DMA controller.
> + *
> + * Return a MemTxResult indicating whether the operation succeeded
> + * or failed (eg unassigned memory, device rejected the transaction,
> + * IOMMU fault).
> + *
> + * @as: #AddressSpace to be accessed
> + * @addr: address within that address space
> + * @c: constant byte to fill the memory
> + * @len: the number of bytes to fill with the constant byte
> + */
> +MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr,
> +   uint8_t c, dma_addr_t len);
>
>  /**
>   * address_space_map: Map a physical memory region into a DMA controller
> diff --git a/dma-helpers.c b/dma-helpers.c
> index 41ef24a63b6..4a9e37d6d06 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -1,7 +1,7 @@
>  /*
>   * DMA helper functions
>   *
> - * Copyright (c) 2009 Red Hat
> + * Copyright (c) 2009,2020 Red Hat
>   *
>   * This work is licensed under the terms of the GNU General Public License
>   * (GNU GPL), version 2 or later.
> @@ -18,14 +18,15 @@
>
>  /* #define DEBUG_IOMMU */
>
> -int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t 
> len)
> +MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr,
> +   uint8_t c, dma_addr_t len)
>  {
>  dma_barrier(as, DMA_DIRECTION_FROM_DEVICE);
>
>  #define FILLBUF_SIZE 512
>  uint8_t fillbuf[FILLBUF_SIZE];
>  int l;
> -bool error = false;
> +MemTxResult error = MEMTX_OK;
>
>  memset(fillbuf, c, FILLBUF_SIZE);
>  while (len > 0) {
> --
> 2.26.2
>
>



Re: [PATCH 05/13] dma: Let dma_memory_rw() propagate MemTxResult

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:46写道:
>
> address_space_rw() returns a MemTxResult type.
> Do not discard it, return it to the caller.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/sysemu/dma.h | 30 ++
>  1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index ad8a3f82f47..661d7d0ca88 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -80,12 +80,13 @@ static inline bool dma_memory_valid(AddressSpace *as,
>MEMTXATTRS_UNSPECIFIED);
>  }
>
> -static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr,
> -void *buf, dma_addr_t len,
> -DMADirection dir)
> +static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as,
> +dma_addr_t addr,
> +void *buf, dma_addr_t len,
> +DMADirection dir)
>  {
> -return (bool)address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED,
> -  buf, len, dir == 
> DMA_DIRECTION_FROM_DEVICE);
> +return address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED,
> +buf, len, dir == DMA_DIRECTION_FROM_DEVICE);
>  }
>
>  static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t addr,
> @@ -101,9 +102,22 @@ static inline int dma_memory_write_relaxed(AddressSpace 
> *as, dma_addr_t addr,
>   DMA_DIRECTION_FROM_DEVICE);
>  }
>
> -static inline int dma_memory_rw(AddressSpace *as, dma_addr_t addr,
> -void *buf, dma_addr_t len,
> -DMADirection dir)
> +/**
> + * dma_memory_rw: Read from or write to an address space from DMA controller.
> + *
> + * Return a MemTxResult indicating whether the operation succeeded
> + * or failed (eg unassigned memory, device rejected the transaction,
> + * IOMMU fault).
> + *
> + * @as: #AddressSpace to be accessed
> + * @addr: address within that address space
> + * @buf: buffer with the data transferred
> + * @len: the number of bytes to read or write
> + * @dir: indicates the transfer direction
> + */
> +static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr,
> +void *buf, dma_addr_t len,
> +DMADirection dir)
>  {
>  dma_barrier(as, dir);
>
> --
> 2.26.2
>
>



Re: [PATCH 06/13] dma: Let dma_memory_read() propagate MemTxResult

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:50写道:
>
> dma_memory_rw_relaxed() returns a MemTxResult type.
> Do not discard it, return it to the caller.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/sysemu/dma.h | 21 +
>  1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index 661d7d0ca88..2961a96ad67 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -89,8 +89,9 @@ static inline MemTxResult 
> dma_memory_rw_relaxed(AddressSpace *as,
>  buf, len, dir == DMA_DIRECTION_FROM_DEVICE);
>  }
>
> -static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t addr,
> -  void *buf, dma_addr_t len)
> +static inline MemTxResult dma_memory_read_relaxed(AddressSpace *as,
> +  dma_addr_t addr,
> +  void *buf, dma_addr_t len)
>  {
>  return dma_memory_rw_relaxed(as, addr, buf, len, 
> DMA_DIRECTION_TO_DEVICE);
>  }
> @@ -124,8 +125,20 @@ static inline MemTxResult dma_memory_rw(AddressSpace 
> *as, dma_addr_t addr,
>  return dma_memory_rw_relaxed(as, addr, buf, len, dir);
>  }
>
> -static inline int dma_memory_read(AddressSpace *as, dma_addr_t addr,
> -  void *buf, dma_addr_t len)
> +/**
> + * dma_memory_read: Read from an address space from DMA controller.
> + *
> + * Return a MemTxResult indicating whether the operation succeeded
> + * or failed (eg unassigned memory, device rejected the transaction,
> + * IOMMU fault).  Called within RCU critical section.
> + *
> + * @as: #AddressSpace to be accessed
> + * @addr: address within that address space
> + * @buf: buffer with the data transferred
> + * @len: length of the data transferred
> + */
> +static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr,
> +  void *buf, dma_addr_t len)
>  {
>  return dma_memory_rw(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE);
>  }
> --
> 2.26.2
>
>



Re: [PATCH 07/13] dma: Let dma_memory_write() propagate MemTxResult

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:46写道:
>
> dma_memory_rw_relaxed() returns a MemTxResult type.
> Do not discard it, return it to the caller.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/sysemu/dma.h | 22 ++
>  1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index 2961a96ad67..f4ade067a46 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -96,8 +96,10 @@ static inline MemTxResult 
> dma_memory_read_relaxed(AddressSpace *as,
>  return dma_memory_rw_relaxed(as, addr, buf, len, 
> DMA_DIRECTION_TO_DEVICE);
>  }
>
> -static inline int dma_memory_write_relaxed(AddressSpace *as, dma_addr_t addr,
> -   const void *buf, dma_addr_t len)
> +static inline MemTxResult dma_memory_write_relaxed(AddressSpace *as,
> +   dma_addr_t addr,
> +   const void *buf,
> +   dma_addr_t len)
>  {
>  return dma_memory_rw_relaxed(as, addr, (void *)buf, len,
>   DMA_DIRECTION_FROM_DEVICE);
> @@ -143,8 +145,20 @@ static inline MemTxResult dma_memory_read(AddressSpace 
> *as, dma_addr_t addr,
>  return dma_memory_rw(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE);
>  }
>
> -static inline int dma_memory_write(AddressSpace *as, dma_addr_t addr,
> -   const void *buf, dma_addr_t len)
> +/**
> + * address_space_write: Write to address space from DMA controller.
> + *
> + * Return a MemTxResult indicating whether the operation succeeded
> + * or failed (eg unassigned memory, device rejected the transaction,
> + * IOMMU fault).
> + *
> + * @as: #AddressSpace to be accessed
> + * @addr: address within that address space
> + * @buf: buffer with the data transferred
> + * @len: the number of bytes to write
> + */
> +static inline MemTxResult dma_memory_write(AddressSpace *as, dma_addr_t addr,
> +   const void *buf, dma_addr_t len)
>  {
>  return dma_memory_rw(as, addr, (void *)buf, len,
>   DMA_DIRECTION_FROM_DEVICE);
> --
> 2.26.2
>
>



Re: [PATCH 08/13] dma: Let dma_memory_valid() take MemTxAttrs argument

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:48写道:
>
> Let devices specify transaction attributes when calling
> dma_memory_valid().
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/hw/ppc/spapr_vio.h | 2 +-
>  include/sysemu/dma.h   | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h
> index bed7df60e35..f134f6cf574 100644
> --- a/include/hw/ppc/spapr_vio.h
> +++ b/include/hw/ppc/spapr_vio.h
> @@ -96,7 +96,7 @@ static inline void spapr_vio_irq_pulse(SpaprVioDevice *dev)
>  static inline bool spapr_vio_dma_valid(SpaprVioDevice *dev, uint64_t taddr,
> uint32_t size, DMADirection dir)
>  {
> -return dma_memory_valid(&dev->as, taddr, size, dir);
> +return dma_memory_valid(&dev->as, taddr, size, dir, 
> MEMTXATTRS_UNSPECIFIED);
>  }
>
>  static inline int spapr_vio_dma_read(SpaprVioDevice *dev, uint64_t taddr,
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index f4ade067a46..b322aa5947b 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -73,11 +73,11 @@ static inline void dma_barrier(AddressSpace *as, 
> DMADirection dir)
>   * dma_memory_{read,write}() and check for errors */
>  static inline bool dma_memory_valid(AddressSpace *as,
>  dma_addr_t addr, dma_addr_t len,
> -DMADirection dir)
> +DMADirection dir, MemTxAttrs attrs)
>  {
>  return address_space_access_valid(as, addr, len,
>dir == DMA_DIRECTION_FROM_DEVICE,
> -  MEMTXATTRS_UNSPECIFIED);
> +  attrs);
>  }
>
>  static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as,
> --
> 2.26.2
>
>



Re: [PATCH 09/13] dma: Let dma_memory_set() take MemTxAttrs argument

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:49写道:
>
> Let devices specify transaction attributes when calling
> dma_memory_set().
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/hw/ppc/spapr_vio.h | 3 ++-
>  include/sysemu/dma.h   | 3 ++-
>  dma-helpers.c  | 5 ++---
>  hw/nvram/fw_cfg.c  | 3 ++-
>  4 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h
> index f134f6cf574..6e5c0840248 100644
> --- a/include/hw/ppc/spapr_vio.h
> +++ b/include/hw/ppc/spapr_vio.h
> @@ -116,7 +116,8 @@ static inline int spapr_vio_dma_write(SpaprVioDevice 
> *dev, uint64_t taddr,
>  static inline int spapr_vio_dma_set(SpaprVioDevice *dev, uint64_t taddr,
>  uint8_t c, uint32_t size)
>  {
> -return (dma_memory_set(&dev->as, taddr, c, size) != 0) ?
> +return (dma_memory_set(&dev->as, taddr,
> +   c, size, MEMTXATTRS_UNSPECIFIED) != 0) ?
>  H_DEST_PARM : H_SUCCESS;
>  }
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index b322aa5947b..d0381f9ae9b 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -175,9 +175,10 @@ static inline MemTxResult dma_memory_write(AddressSpace 
> *as, dma_addr_t addr,
>   * @addr: address within that address space
>   * @c: constant byte to fill the memory
>   * @len: the number of bytes to fill with the constant byte
> + * @attrs: memory transaction attributes
>   */
>  MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr,
> -   uint8_t c, dma_addr_t len);
> +   uint8_t c, dma_addr_t len, MemTxAttrs attrs);
>
>  /**
>   * address_space_map: Map a physical memory region into a DMA controller
> diff --git a/dma-helpers.c b/dma-helpers.c
> index 4a9e37d6d06..6a9735386dc 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -19,7 +19,7 @@
>  /* #define DEBUG_IOMMU */
>
>  MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t addr,
> -   uint8_t c, dma_addr_t len)
> +   uint8_t c, dma_addr_t len, MemTxAttrs attrs)
>  {
>  dma_barrier(as, DMA_DIRECTION_FROM_DEVICE);
>
> @@ -31,8 +31,7 @@ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t 
> addr,
>  memset(fillbuf, c, FILLBUF_SIZE);
>  while (len > 0) {
>  l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE;
> -error |= address_space_write(as, addr, MEMTXATTRS_UNSPECIFIED,
> - fillbuf, l);
> +error |= address_space_write(as, addr, attrs, fillbuf, l);
>  len -= l;
>  addr += l;
>  }
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index f3a4728288e..a15de06a10c 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -397,7 +397,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s)
>   * tested before.
>   */
>  if (read) {
> -if (dma_memory_set(s->dma_as, dma.address, 0, len)) {
> +if (dma_memory_set(s->dma_as, dma.address, 0, len,
> +   MEMTXATTRS_UNSPECIFIED)) {
>  dma.control |= FW_CFG_DMA_CTL_ERROR;
>  }
>  }
> --
> 2.26.2
>
>



Re: [PATCH 10/13] dma: Let dma_memory_rw_relaxed() take MemTxAttrs argument

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:53写道:
>
> We will add the MemTxAttrs argument to dma_memory_rw() in
> the next commit. Since dma_memory_rw_relaxed() is only used
> by dma_memory_rw(), modify it first in a separate commit to
> keep the next commit easier to review.
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/sysemu/dma.h | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index d0381f9ae9b..59331ec0bd3 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -83,9 +83,10 @@ static inline bool dma_memory_valid(AddressSpace *as,
>  static inline MemTxResult dma_memory_rw_relaxed(AddressSpace *as,
>  dma_addr_t addr,
>  void *buf, dma_addr_t len,
> -DMADirection dir)
> +DMADirection dir,
> +MemTxAttrs attrs)
>  {
> -return address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED,
> +return address_space_rw(as, addr, attrs,
>  buf, len, dir == DMA_DIRECTION_FROM_DEVICE);
>  }
>
> @@ -93,7 +94,9 @@ static inline MemTxResult 
> dma_memory_read_relaxed(AddressSpace *as,
>dma_addr_t addr,
>void *buf, dma_addr_t len)
>  {
> -return dma_memory_rw_relaxed(as, addr, buf, len, 
> DMA_DIRECTION_TO_DEVICE);
> +return dma_memory_rw_relaxed(as, addr, buf, len,
> + DMA_DIRECTION_TO_DEVICE,
> + MEMTXATTRS_UNSPECIFIED);
>  }
>
>  static inline MemTxResult dma_memory_write_relaxed(AddressSpace *as,
> @@ -102,7 +105,8 @@ static inline MemTxResult 
> dma_memory_write_relaxed(AddressSpace *as,
> dma_addr_t len)
>  {
>  return dma_memory_rw_relaxed(as, addr, (void *)buf, len,
> - DMA_DIRECTION_FROM_DEVICE);
> + DMA_DIRECTION_FROM_DEVICE,
> + MEMTXATTRS_UNSPECIFIED);
>  }
>
>  /**
> @@ -124,7 +128,8 @@ static inline MemTxResult dma_memory_rw(AddressSpace *as, 
> dma_addr_t addr,
>  {
>  dma_barrier(as, dir);
>
> -return dma_memory_rw_relaxed(as, addr, buf, len, dir);
> +return dma_memory_rw_relaxed(as, addr, buf, len, dir,
> + MEMTXATTRS_UNSPECIFIED);
>  }
>
>  /**
> --
> 2.26.2
>
>



[PATCH v2 1/2] hw/mips/mipssim: Use MMIO serial device on fake ISA I/O

2020-09-06 Thread Philippe Mathieu-Daudé
The 'mipssim' is not a real hardware, it is a simulator.

There is an ISA MMIO space mapped at 0x1fd0, however
this is not a real ISA bus (no ISA IRQ). So can not use
the TYPE_ISA_SERIAL device...
Instead we have been using a plain MMIO device, but named
it IO.

TYPE_SERIAL_IO is a superset of TYPE_SERIAL_MM, using
regshift=0 and endianness=DEVICE_LITTLE_ENDIAN.

Directly use the TYPE_SERIAL_MM device, enforcing the
regshift/endianness values. 'regshift' default is already
'0'. 'endianness' is meaningless for 8-bit accesses.

This change breaks migration back compatibility, but
this is not an issue for the mipssim machine.

Suggested-by: Peter Maydell 
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/mips/mipssim.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index 1b3b7622035..5d4ad74828d 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -216,10 +216,11 @@ mips_mipssim_init(MachineState *machine)
  * MIPS CPU INT2, which is interrupt 4.
  */
 if (serial_hd(0)) {
-DeviceState *dev = qdev_new(TYPE_SERIAL_IO);
+DeviceState *dev = qdev_new(TYPE_SERIAL_MM);
 
 qdev_prop_set_chr(dev, "chardev", serial_hd(0));
-qdev_set_legacy_instance_id(dev, 0x3f8, 2);
+qdev_prop_set_uint8(dev, "regshift", 0);
+qdev_prop_set_uint8(dev, "endianness", DEVICE_LITTLE_ENDIAN);
 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
 sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, env->irq[4]);
 sysbus_add_io(SYS_BUS_DEVICE(dev), 0x3f8,
-- 
2.26.2




[PATCH v2 0/2] hw/char: Remove TYPE_SERIAL_IO

2020-09-06 Thread Philippe Mathieu-Daudé
Remove the TYPE_SERIAL_IO which is simply a superset of
TYPE_SERIAL_MM, as suggested by Paolo and Peter here:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg721806.html

Since v1:
- Reword migration comment (Marc-André)

Philippe Mathieu-Daudé (2):
  hw/mips/mipssim: Use MMIO serial device on fake ISA I/O
  hw/char/serial: Remove TYPE_SERIAL_IO (superset of TYPE_SERIAL_MM)

 include/hw/char/serial.h |  9 -
 hw/char/serial.c | 41 
 hw/mips/mipssim.c|  5 +++--
 3 files changed, 3 insertions(+), 52 deletions(-)

-- 
2.26.2




[PATCH v2 2/2] hw/char/serial: Remove TYPE_SERIAL_IO (superset of TYPE_SERIAL_MM)

2020-09-06 Thread Philippe Mathieu-Daudé
TYPE_SERIAL_IO is a superset of TYPE_SERIAL_MM, and it is
not used anymore. Remove it.

Suggested-by: Paolo Bonzini 
Suggested-by: Peter Maydell 
Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/char/serial.h |  9 -
 hw/char/serial.c | 41 
 2 files changed, 50 deletions(-)

diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 535fa23a2b8..81d7ba1917f 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -88,12 +88,6 @@ typedef struct SerialMM {
 uint8_t endianness;
 } SerialMM;
 
-typedef struct SerialIO {
-SysBusDevice parent;
-
-SerialState serial;
-} SerialIO;
-
 extern const VMStateDescription vmstate_serial;
 extern const MemoryRegionOps serial_io_ops;
 
@@ -105,9 +99,6 @@ void serial_set_frequency(SerialState *s, uint32_t 
frequency);
 #define TYPE_SERIAL_MM "serial-mm"
 #define SERIAL_MM(s) OBJECT_CHECK(SerialMM, (s), TYPE_SERIAL_MM)
 
-#define TYPE_SERIAL_IO "serial-io"
-#define SERIAL_IO(s) OBJECT_CHECK(SerialIO, (s), TYPE_SERIAL_IO)
-
 SerialMM *serial_mm_init(MemoryRegion *address_space,
  hwaddr base, int regshift,
  qemu_irq irq, int baudbase,
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 23864794929..fd80ae55929 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -985,46 +985,6 @@ const MemoryRegionOps serial_io_ops = {
 .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
-static void serial_io_realize(DeviceState *dev, Error **errp)
-{
-SerialIO *sio = SERIAL_IO(dev);
-SerialState *s = &sio->serial;
-
-if (!qdev_realize(DEVICE(s), NULL, errp)) {
-return;
-}
-
-memory_region_init_io(&s->io, OBJECT(dev), &serial_io_ops, s, "serial", 8);
-sysbus_init_mmio(SYS_BUS_DEVICE(sio), &s->io);
-sysbus_init_irq(SYS_BUS_DEVICE(sio), &s->irq);
-}
-
-static void serial_io_class_init(ObjectClass *klass, void* data)
-{
-DeviceClass *dc = DEVICE_CLASS(klass);
-
-dc->realize = serial_io_realize;
-/* No dc->vmsd: class has no migratable state */
-}
-
-static void serial_io_instance_init(Object *o)
-{
-SerialIO *sio = SERIAL_IO(o);
-
-object_initialize_child(o, "serial", &sio->serial, TYPE_SERIAL);
-
-qdev_alias_all_properties(DEVICE(&sio->serial), o);
-}
-
-
-static const TypeInfo serial_io_info = {
-.name = TYPE_SERIAL_IO,
-.parent = TYPE_SYS_BUS_DEVICE,
-.instance_size = sizeof(SerialIO),
-.instance_init = serial_io_instance_init,
-.class_init = serial_io_class_init,
-};
-
 static Property serial_properties[] = {
 DEFINE_PROP_CHR("chardev", SerialState, chr),
 DEFINE_PROP_UINT32("baudbase", SerialState, baudbase, 115200),
@@ -1178,7 +1138,6 @@ static const TypeInfo serial_mm_info = {
 static void serial_register_types(void)
 {
 type_register_static(&serial_info);
-type_register_static(&serial_io_info);
 type_register_static(&serial_mm_info);
 }
 
-- 
2.26.2




Re: [PATCH 11/13] dma: Let dma_memory_rw() take MemTxAttrs argument

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:53写道:
>
> Let devices specify transaction attributes when calling
> dma_memory_rw().
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/hw/pci/pci.h |  3 ++-
>  include/sysemu/dma.h | 11 ++-
>  dma-helpers.c|  3 ++-
>  hw/intc/spapr_xive.c |  3 ++-
>  hw/usb/hcd-ohci.c| 10 ++
>  5 files changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 896cef9ad47..0c3217e019c 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -788,7 +788,8 @@ static inline AddressSpace 
> *pci_get_address_space(PCIDevice *dev)
>  static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr,
>   void *buf, dma_addr_t len, DMADirection dir)
>  {
> -return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir);
> +return dma_memory_rw(pci_get_address_space(dev), addr, buf, len,
> + dir, MEMTXATTRS_UNSPECIFIED);
>  }
>
>  static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr,
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index 59331ec0bd3..0695d430119 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -121,15 +121,15 @@ static inline MemTxResult 
> dma_memory_write_relaxed(AddressSpace *as,
>   * @buf: buffer with the data transferred
>   * @len: the number of bytes to read or write
>   * @dir: indicates the transfer direction
> + * @attrs: memory transaction attributes
>   */
>  static inline MemTxResult dma_memory_rw(AddressSpace *as, dma_addr_t addr,
>  void *buf, dma_addr_t len,
> -DMADirection dir)
> +DMADirection dir, MemTxAttrs attrs)
>  {
>  dma_barrier(as, dir);
>
> -return dma_memory_rw_relaxed(as, addr, buf, len, dir,
> - MEMTXATTRS_UNSPECIFIED);
> +return dma_memory_rw_relaxed(as, addr, buf, len, dir, attrs);
>  }
>
>  /**
> @@ -147,7 +147,8 @@ static inline MemTxResult dma_memory_rw(AddressSpace *as, 
> dma_addr_t addr,
>  static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr,
>void *buf, dma_addr_t len)
>  {
> -return dma_memory_rw(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE);
> +return dma_memory_rw(as, addr, buf, len,
> + DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED);
>  }
>
>  /**
> @@ -166,7 +167,7 @@ static inline MemTxResult dma_memory_write(AddressSpace 
> *as, dma_addr_t addr,
> const void *buf, dma_addr_t len)
>  {
>  return dma_memory_rw(as, addr, (void *)buf, len,
> - DMA_DIRECTION_FROM_DEVICE);
> + DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED);
>  }
>
>  /**
> diff --git a/dma-helpers.c b/dma-helpers.c
> index 6a9735386dc..6c3b2200f16 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -305,7 +305,8 @@ static uint64_t dma_buf_rw(uint8_t *ptr, int32_t len, 
> QEMUSGList *sg,
>  while (len > 0) {
>  ScatterGatherEntry entry = sg->sg[sg_cur_index++];
>  int32_t xfer = MIN(len, entry.len);
> -dma_memory_rw(sg->as, entry.base, ptr, xfer, dir);
> +dma_memory_rw(sg->as, entry.base, ptr, xfer, dir,
> +  MEMTXATTRS_UNSPECIFIED);
>  ptr += xfer;
>  len -= xfer;
>  resid -= xfer;
> diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
> index 4bd0d606ba1..dbf73a8bf47 100644
> --- a/hw/intc/spapr_xive.c
> +++ b/hw/intc/spapr_xive.c
> @@ -1666,7 +1666,8 @@ static target_ulong h_int_esb(PowerPCCPU *cpu,
>  mmio_addr = xive->vc_base + xive_source_esb_mgmt(xsrc, lisn) + 
> offset;
>
>  if (dma_memory_rw(&address_space_memory, mmio_addr, &data, 8,
> -  (flags & SPAPR_XIVE_ESB_STORE))) {
> +  (flags & SPAPR_XIVE_ESB_STORE),
> +  MEMTXATTRS_UNSPECIFIED)) {
>  qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to access ESB @0x%"
>HWADDR_PRIx "\n", mmio_addr);
>  return H_HARDWARE;
> diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
> index 1e6e85e86a8..bac1adf439c 100644
> --- a/hw/usb/hcd-ohci.c
> +++ b/hw/usb/hcd-ohci.c
> @@ -586,7 +586,8 @@ static int ohci_copy_td(OHCIState *ohci, struct ohci_td 
> *td,
>  if (n > len)
>  n = len;
>
> -if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, n, dir)) {
> +if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf,
> +  n, dir, MEMTXATTRS_UNSPECIFIED)) {
>  return -1;
>  }
>  if (n == len) {
> @@ -595,7 +596,7 @@ static int ohci_copy_td(OHCIState *ohci, struct ohci_td 
> *td,
>  ptr = td->be & ~0xfffu;
>  buf += n;
>  if (dma_memory_rw(ohci->as, p

Re: [PATCH 12/13] dma: Let dma_memory_read/write() take MemTxAttrs argument

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:52写道:
>
> Let devices specify transaction attributes when calling
> dma_memory_read() or dma_memory_write().
>
> Patch created mechanically using spatch with this script:
>
>   @@
>   expression E1, E2, E3, E4;
>   @@
>   (
>   - dma_memory_read(E1, E2, E3, E4)
>   + dma_memory_read(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED)
>   |
>   - dma_memory_write(E1, E2, E3, E4)
>   + dma_memory_write(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED)
>   )
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/hw/ppc/spapr_vio.h|  6 --
>  include/sysemu/dma.h  | 20 
>  hw/arm/musicpal.c | 13 +++--
>  hw/arm/smmu-common.c  |  3 ++-
>  hw/arm/smmuv3.c   | 14 +-
>  hw/core/generic-loader.c  |  3 ++-
>  hw/dma/pl330.c| 12 
>  hw/dma/sparc32_dma.c  | 16 ++--
>  hw/dma/xlnx-zynq-devcfg.c |  6 --
>  hw/dma/xlnx_dpdma.c   | 10 ++
>  hw/i386/amd_iommu.c   | 16 +---
>  hw/i386/intel_iommu.c | 28 +---
>  hw/ide/macio.c|  2 +-
>  hw/intc/xive.c|  7 ---
>  hw/misc/bcm2835_property.c|  3 ++-
>  hw/misc/macio/mac_dbdma.c | 10 ++
>  hw/net/allwinner-sun8i-emac.c | 21 ++---
>  hw/net/ftgmac100.c| 25 -
>  hw/net/imx_fec.c  | 32 
>  hw/nvram/fw_cfg.c |  9 ++---
>  hw/pci-host/pnv_phb3.c|  5 +++--
>  hw/pci-host/pnv_phb3_msi.c|  9 ++---
>  hw/pci-host/pnv_phb4.c|  7 ---
>  hw/sd/allwinner-sdhost.c  | 14 --
>  hw/sd/sdhci.c | 35 ++-
>  hw/usb/hcd-dwc2.c |  8 
>  hw/usb/hcd-ehci.c |  6 --
>  hw/usb/hcd-ohci.c | 18 +++---
>  28 files changed, 221 insertions(+), 137 deletions(-)
>
> diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h
> index 6e5c0840248..8168f4fc5a5 100644
> --- a/include/hw/ppc/spapr_vio.h
> +++ b/include/hw/ppc/spapr_vio.h
> @@ -102,14 +102,16 @@ static inline bool spapr_vio_dma_valid(SpaprVioDevice 
> *dev, uint64_t taddr,
>  static inline int spapr_vio_dma_read(SpaprVioDevice *dev, uint64_t taddr,
>   void *buf, uint32_t size)
>  {
> -return (dma_memory_read(&dev->as, taddr, buf, size) != 0) ?
> +return (dma_memory_read(&dev->as, taddr,
> +buf, size, MEMTXATTRS_UNSPECIFIED) != 0) ?
>  H_DEST_PARM : H_SUCCESS;
>  }
>
>  static inline int spapr_vio_dma_write(SpaprVioDevice *dev, uint64_t taddr,
>const void *buf, uint32_t size)
>  {
> -return (dma_memory_write(&dev->as, taddr, buf, size) != 0) ?
> +return (dma_memory_write(&dev->as, taddr,
> + buf, size, MEMTXATTRS_UNSPECIFIED) != 0) ?
>  H_DEST_PARM : H_SUCCESS;
>  }
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index 0695d430119..b9cb9c8944b 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -143,12 +143,14 @@ static inline MemTxResult dma_memory_rw(AddressSpace 
> *as, dma_addr_t addr,
>   * @addr: address within that address space
>   * @buf: buffer with the data transferred
>   * @len: length of the data transferred
> + * @attrs: memory transaction attributes
>   */
>  static inline MemTxResult dma_memory_read(AddressSpace *as, dma_addr_t addr,
> -  void *buf, dma_addr_t len)
> +  void *buf, dma_addr_t len,
> +  MemTxAttrs attrs)
>  {
>  return dma_memory_rw(as, addr, buf, len,
> - DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED);
> + DMA_DIRECTION_TO_DEVICE, attrs);
>  }
>
>  /**
> @@ -162,12 +164,14 @@ static inline MemTxResult dma_memory_read(AddressSpace 
> *as, dma_addr_t addr,
>   * @addr: address within that address space
>   * @buf: buffer with the data transferred
>   * @len: the number of bytes to write
> + * @attrs: memory transaction attributes
>   */
>  static inline MemTxResult dma_memory_write(AddressSpace *as, dma_addr_t addr,
> -   const void *buf, dma_addr_t len)
> +   const void *buf, dma_addr_t len,
> +   MemTxAttrs attrs)
>  {
>  return dma_memory_rw(as, addr, (void *)buf, len,
> - DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED);
> + DMA_DIRECTION_FROM_DEVICE, attrs);
>  }
>
>  /**
> @@ -240,7 +244,7 @@ static inline void dma_memory_unmap(AddressSpace *as,
> 

Re: [PATCH 13/13] dma: Let dma_memory_map() take MemTxAttrs argument

2020-09-06 Thread Li Qiang
Philippe Mathieu-Daudé  于2020年9月4日周五 下午11:52写道:
>
> Let devices specify transaction attributes when calling
> dma_memory_map().
>
> Patch created mechanically using spatch with this script:
>
>   @@
>   expression E1, E2, E3, E4;
>   @@
>   - dma_memory_map(E1, E2, E3, E4)
>   + dma_memory_map(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED)
>
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Li Qiang 

> ---
>  include/hw/pci/pci.h| 3 ++-
>  include/sysemu/dma.h| 5 +++--
>  dma-helpers.c   | 3 ++-
>  hw/display/virtio-gpu.c | 8 ++--
>  hw/hyperv/vmbus.c   | 8 +---
>  hw/ide/ahci.c   | 9 ++---
>  hw/usb/libhw.c  | 3 ++-
>  hw/virtio/virtio.c  | 6 --
>  8 files changed, 30 insertions(+), 15 deletions(-)
>
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 0c3217e019c..a221dfb3b08 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -831,7 +831,8 @@ static inline void *pci_dma_map(PCIDevice *dev, 
> dma_addr_t addr,
>  {
>  void *buf;
>
> -buf = dma_memory_map(pci_get_address_space(dev), addr, plen, dir);
> +buf = dma_memory_map(pci_get_address_space(dev), addr, plen, dir,
> + MEMTXATTRS_UNSPECIFIED);
>  return buf;
>  }
>
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index b9cb9c8944b..bb8b0a059f5 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -203,16 +203,17 @@ MemTxResult dma_memory_set(AddressSpace *as, dma_addr_t 
> addr,
>   * @addr: address within that address space
>   * @len: pointer to length of buffer; updated on return
>   * @dir: indicates the transfer direction
> + * @attrs: memory attributes
>   */
>  static inline void *dma_memory_map(AddressSpace *as,
> dma_addr_t addr, dma_addr_t *len,
> -   DMADirection dir)
> +   DMADirection dir, MemTxAttrs attrs)
>  {
>  hwaddr xlen = *len;
>  void *p;
>
>  p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE,
> -  MEMTXATTRS_UNSPECIFIED);
> +  attrs);
>  *len = xlen;
>  return p;
>  }
> diff --git a/dma-helpers.c b/dma-helpers.c
> index 6c3b2200f16..0507a6f95b9 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -143,7 +143,8 @@ static void dma_blk_cb(void *opaque, int ret)
>  while (dbs->sg_cur_index < dbs->sg->nsg) {
>  cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;
>  cur_len = dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte;
> -mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir);
> +mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir,
> + MEMTXATTRS_UNSPECIFIED);
>  /*
>   * Make reads deterministic in icount mode. Windows sometimes issues
>   * disk read requests with overlapping SGs. It leads
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 5f0dd7c1500..be7f5cdee46 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -648,7 +648,9 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
>  hwaddr len = l;
>  (*iov)[i].iov_len = l;
>  (*iov)[i].iov_base = dma_memory_map(VIRTIO_DEVICE(g)->dma_as,
> -a, &len, 
> DMA_DIRECTION_TO_DEVICE);
> +a, &len,
> +DMA_DIRECTION_TO_DEVICE,
> +MEMTXATTRS_UNSPECIFIED);
>  if (addr) {
>  (*addr)[i] = a;
>  }
> @@ -1049,7 +1051,9 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, 
> size_t size,
>  hwaddr len = res->iov[i].iov_len;
>  res->iov[i].iov_base =
>  dma_memory_map(VIRTIO_DEVICE(g)->dma_as,
> -   res->addrs[i], &len, DMA_DIRECTION_TO_DEVICE);
> +   res->addrs[i], &len,
> +   DMA_DIRECTION_TO_DEVICE,
> +   MEMTXATTRS_UNSPECIFIED);
>
>  if (!res->iov[i].iov_base || len != res->iov[i].iov_len) {
>  /* Clean up the half-a-mapping we just created... */
> diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
> index 75af6b83dde..56621d72e5b 100644
> --- a/hw/hyperv/vmbus.c
> +++ b/hw/hyperv/vmbus.c
> @@ -372,7 +372,8 @@ static ssize_t gpadl_iter_io(GpadlIter *iter, void *buf, 
> uint32_t len)
>
>  maddr = (iter->gpadl->gfns[idx] << TARGET_PAGE_BITS) | 
> off_in_page;
>
> -iter->map = dma_memory_map(iter->as, maddr, &mlen, iter->dir);
> +iter->map = dma_memory_map(iter->as, maddr, &mlen, iter->dir,
> +   MEMTXATTRS_UNSPECIFIED);
>  if (mlen != pgleft) {
>  dma_memory_unmap(iter->as, iter->m

Re: elf2dmp: Fix memory leak on main() error paths

2020-09-06 Thread Li Qiang
AlexChen  于2020年8月26日周三 下午6:16写道:
>
> From: AlexChen 

Reviewed-by: Li Qiang 

>
> The 'kdgb' is allocating memory in get_kdbg(), but it is not freed
> in both fill_header() and fill_context() failed branches, fix it.
>
> Signed-off-by: AlexChen 
> ---
>  contrib/elf2dmp/main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
> index 9a2dbc2902..ac746e49e0 100644
> --- a/contrib/elf2dmp/main.c
> +++ b/contrib/elf2dmp/main.c
> @@ -568,12 +568,12 @@ int main(int argc, char *argv[])
>  if (fill_header(&header, &ps, &vs, KdDebuggerDataBlock, kdbg,
>  KdVersionBlock, qemu_elf.state_nr)) {
>  err = 1;
> -goto out_pdb;
> +goto out_kdbg;
>  }
>
>  if (fill_context(kdbg, &vs, &qemu_elf)) {
>  err = 1;
> -goto out_pdb;
> +goto out_kdbg;
>  }
>
>  if (write_dump(&ps, &header, argv[2])) {
> --
> 2.19.1
>
>



Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that actually works with sg

2020-09-06 Thread Tom Yan
Your patch only fixed it for sg devices. S_ISBLK() will never be true
when sg_get_max_segments() is only called in raw_refresh_limits() when
bs->sg is true.

With that said, it's not like we cannot ditch the bs->sg check in
raw_refresh_limits() and switch to S_ISBLK()/S_ISCHR(). (Although not
strictly necessary, I would also do S_ISCHR() for
SG_GET_SG_TABLESIZE.)

I don't know if it's a better approach though. Seems repetitive to me
(and bs->sg is not only used/checked in
file-posix/raw_refresh_limits):
https://github.com/qemu/qemu/blob/v5.1.0/block/file-posix.c#L3390
https://github.com/qemu/qemu/blob/v5.1.0/block/file-posix.c#L3504

On Mon, 7 Sep 2020 at 03:50, Dmitry Fomichev  wrote:
>
>
>
> > -Original Message-
> > From: Qemu-block  > bounces+dmitry.fomichev=wdc@nongnu.org> On Behalf Of Maxim
> > Levitsky
> > Sent: Sunday, September 6, 2020 1:06 PM
> > To: Tom Yan ; ebl...@redhat.com;
> > pbonz...@redhat.com; f...@euphon.net; anie...@linux.vnet.ibm.com;
> > kw...@redhat.com; mre...@redhat.com
> > Cc: qemu-devel@nongnu.org; qemu-bl...@nongnu.org
> > Subject: Re: [PATCH v4 2/2] file-posix: add sg_get_max_segments that
> > actually works with sg
> >
> > On Sun, 2020-09-06 at 23:26 +0800, Tom Yan wrote:
> > > I don't disagree with your proposal, but the thing is, do we even need
> > > another field/limit for case 1? For example, do we *really* need to
> > > clamp sizes[2] (NBD_INFO_BLOCK_SIZE) in nbd/server.c and
> > > max_io_sectors (SCSIBlockLimits) in hw/scsi/scsi-disk.c to to any kind
> > > of "dynamic" limit?
> >
> > It depends on if we have other block drivers that have IO segment/max
> > transfer sizes,
> > that we need to enforce, other than the SG_IO case.
> >
> > Knowing that the commit that added these limits to file-posix, which I was
> > fixing is relatively
> > new, I guess there are other cases for these limits.
> >
> > I'll check this tomorrow.
> >
> > >
> > > Either way I can add another field (`max_pwrite`, maybe?) to
> > > BlockLimits, as an infrastructure/hint, but what should be switched to
> > > it, and what value should each block driver set it to, is probably
> > > beyond what I can take.
> >
> > Implementation wise, I think I can do this, but I'll wait few days for the
> > feedback on my proposal.
> >
> > Thanks for finding this bug!
>
> There was also 
> https://lore.kernel.org/qemu-devel/20200811225122.17342-2-dmitry.fomic...@wdc.com/
> posted three weeks ago, but, seemingly, it was ignored... sorry if this
> bug is already being fixed in a different way, but I think the fix presented
> in that patch is worth considering.
>
> Very best,
> Dmitry
>
> >
> > Best regards,
> >   Maxim Levitsky
> >
> > >
> > > IMHO my patches should be merged first (they are really just fixing a
> > > regression and some bugs). If anyone finds it necessary and is capable
> > > and willing to fix the insufficiency of BlockLimits, they can do it
> > > afterwards with another patch series as an improvement. I can add a
> > > patch to remove the clamping in nbd/server.c as a perhaps-temporary
> > > measure to address the original issue, if desired.
> > >
> > > On Sun, 6 Sep 2020 at 20:53, Maxim Levitsky 
> > wrote:
> > > > On Sun, 2020-09-06 at 19:04 +0800, Tom Yan wrote:
> > > > > Maybe you want to add some condition for this:
> > > > > https://github.com/qemu/qemu/blob/v5.1.0/nbd/server.c#L659
> > > > > Or not clamp it at all.
> > > > >
> > > > > On Sun, 6 Sep 2020 at 18:58, Tom Yan  wrote:
> > > > > > In commit 867eccfed84f96b54f4a432c510a02c2ce03b430, Levitsky
> > appears
> > > > > > to have assumed that the only "SCSI Passthrough" is `-device
> > > > > > scsi-generic`, while the fact is there's also `-device scsi-block`
> > > > > > (passthrough without the sg driver). Unlike `-device scsi-hd`, 
> > > > > > getting
> > > > > > max_sectors is necessary to it (more precisely, hw_max_sectors
> > might
> > > > > > what matters, but BLKSECTGET reports max_sectors, so).
> > > > > >
> > > > > > I'm unsure about how qemu-nbd works, but the commit clearly
> > wasn't the
> > > > > > right approach to fix the original issue it addresses. (It should 
> > > > > > for
> > > > > > example ignore the max_transfer if it will never matter in to it, or
> > > > > > overrides it in certain cases; when I glimpsed over
> > > > > > https://bugzilla.redhat.com/show_bug.cgi?id=1647104, I don't see
> > how
> > > > > > it could be file-posix problem when it is reporting the right thing,
> > > > > > regardless of whether "removing" the code helps.)
> > > > > >
> > > > > > I don't think we want to "mark" `-device scsi-block` as sg either. 
> > > > > > It
> > > > > > will probably bring even more unexpected problems, because they
> > are
> > > > > > literally different sets of things behind the scene / in the kernel.
> > > >
> > > > Yes, I did overlook the fact that scsi-block is kind of hybrid 
> > > > passthough
> > device,
> > > > doing SG_IO for some things and regular IO for others.
> > > >
> > > > I don't think

Re: [PATCH] hw: virtio-pmem: detach the element fromt the virtqueue when error occurs

2020-09-06 Thread Li Qiang
ping!

Li Qiang  于2020年8月28日周五 上午9:21写道:
>
> Kindly ping.
>
> Li Qiang  于2020年8月14日周五 上午12:52写道:
> >
> > If error occurs while processing the virtio request we should call
> > 'virtqueue_detach_element' to detach the element from the virtqueue
> > before free the elem.
> >
> > Signed-off-by: Li Qiang 
> > ---
> >  hw/virtio/virtio-pmem.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c
> > index 1e0c137497..ddb0125901 100644
> > --- a/hw/virtio/virtio-pmem.c
> > +++ b/hw/virtio/virtio-pmem.c
> > @@ -77,6 +77,7 @@ static void virtio_pmem_flush(VirtIODevice *vdev, 
> > VirtQueue *vq)
> >
> >  if (req_data->elem.out_num < 1 || req_data->elem.in_num < 1) {
> >  virtio_error(vdev, "virtio-pmem request not proper");
> > +virtqueue_detach_element(vq, (VirtQueueElement *)req_data, 0);
> >  g_free(req_data);
> >  return;
> >  }
> > --
> > 2.17.1
> >
> >



Re: [PATCH v2] virtio-mem: detach the element from the virtqueue when error occurs

2020-09-06 Thread Li Qiang
Ping!

Li Qiang  于2020年8月28日周五 上午9:21写道:
>
> Kindly ping.
>
> Li Qiang  于2020年8月16日周日 下午10:23写道:
> >
> > If error occurs while processing the virtio request we should call
> > 'virtqueue_detach_element' to detach the element from the virtqueue
> > before free the elem.
> >
> > Signed-off-by: Li Qiang 
> > ---
> > Change since v1:
> > Change the subject
> > Avoid using the goto label
> >
> >  hw/virtio/virtio-mem.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> > index 7740fc613f..e6ffc781b3 100644
> > --- a/hw/virtio/virtio-mem.c
> > +++ b/hw/virtio/virtio-mem.c
> > @@ -318,6 +318,7 @@ static void virtio_mem_handle_request(VirtIODevice 
> > *vdev, VirtQueue *vq)
> >  if (iov_to_buf(elem->out_sg, elem->out_num, 0, &req, len) < len) {
> >  virtio_error(vdev, "virtio-mem protocol violation: invalid 
> > request"
> >   " size: %d", len);
> > +virtqueue_detach_element(vq, elem, 0);
> >  g_free(elem);
> >  return;
> >  }
> > @@ -327,6 +328,7 @@ static void virtio_mem_handle_request(VirtIODevice 
> > *vdev, VirtQueue *vq)
> >  virtio_error(vdev, "virtio-mem protocol violation: not enough 
> > space"
> >   " for response: %zu",
> >   iov_size(elem->in_sg, elem->in_num));
> > +virtqueue_detach_element(vq, elem, 0);
> >  g_free(elem);
> >  return;
> >  }
> > @@ -348,6 +350,7 @@ static void virtio_mem_handle_request(VirtIODevice 
> > *vdev, VirtQueue *vq)
> >  default:
> >  virtio_error(vdev, "virtio-mem protocol violation: unknown 
> > request"
> >   " type: %d", type);
> > +virtqueue_detach_element(vq, elem, 0);
> >  g_free(elem);
> >  return;
> >  }
> > --
> > 2.17.1
> >
> >



Re: [PATCH] hw: ide: check the pointer before do dma memory unmap

2020-09-06 Thread Li Qiang
Ping!

Li Qiang  于2020年9月1日周二 下午6:34写道:
>
> Ping.
>
> Li Qiang  于2020年8月15日周六 下午3:21写道:
> >
> > In 'map_page' we need to check the return value of
> > 'dma_memory_map' to ensure the we actully maped something.
> > Otherwise, we will hit an assert in 'address_space_unmap'.
> > This is because we can't find the MR with the NULL buffer.
> > This is the LP#1884693:
> >
> > -->https://bugs.launchpad.net/qemu/+bug/1884693
> >
> > Reported-by: Alexander Bulekov 
> > Signed-off-by: Li Qiang 
> > ---
> >  hw/ide/ahci.c | 5 +
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
> > index 009120f88b..63e9fccdbe 100644
> > --- a/hw/ide/ahci.c
> > +++ b/hw/ide/ahci.c
> > @@ -250,6 +250,11 @@ static void map_page(AddressSpace *as, uint8_t **ptr, 
> > uint64_t addr,
> >  }
> >
> >  *ptr = dma_memory_map(as, addr, &len, DMA_DIRECTION_FROM_DEVICE);
> > +
> > +if (!*ptr) {
> > +return;
> > +}
> > +
> >  if (len < wanted) {
> >  dma_memory_unmap(as, *ptr, len, DMA_DIRECTION_FROM_DEVICE, len);
> >  *ptr = NULL;
> > --
> > 2.17.1
> >



[PATCH 0/7] hw/char/serial: Housekeeping

2020-09-06 Thread Philippe Mathieu-Daudé
Nothing very exciting, cleanups before more serious changes.

Philippe Mathieu-Daudé (7):
  hw/char/serial: Assert serial_ioport_read/write offset fits 8 bytes
  hw/char/serial: Replace commented DPRINTF() by trace event
  hw/char/serial: Remove old DEBUG_SERIAL commented code
  hw/char/serial: Rename I/O read/write trace events
  hw/char/serial: Make 'wakeup' property boolean
  hw/char/serial-isa: Alias QDEV properties from generic serial object
  hw/char/serial: Let SerialState have an 'id' field

 include/hw/char/serial.h |  3 ++-
 hw/char/serial-isa.c |  4 ++--
 hw/char/serial.c | 25 +++--
 hw/char/trace-events |  5 +++--
 4 files changed, 14 insertions(+), 23 deletions(-)

-- 
2.26.2




[PATCH 5/7] hw/char/serial: Make 'wakeup' property boolean

2020-09-06 Thread Philippe Mathieu-Daudé
Make the "wakeup" property introduced in commit 9826fd597df
("suspend: make serial ports wakeup the guest") a boolean.

As we want to reuse the generic serial properties in the
ISA model (next commit), expose this property.

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/char/serial.h | 2 +-
 hw/char/serial-isa.c | 2 +-
 hw/char/serial.c | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 535fa23a2b8..3d2a5b27e87 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -60,7 +60,7 @@ typedef struct SerialState {
 uint32_t baudbase;
 uint32_t tsr_retry;
 guint watch_tag;
-uint32_t wakeup;
+bool wakeup;
 
 /* Time when the last byte was successfully sent out of the tsr */
 uint64_t last_xmit_ts;
diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c
index b4c65949cd8..a0c338796d5 100644
--- a/hw/char/serial-isa.c
+++ b/hw/char/serial-isa.c
@@ -116,7 +116,7 @@ static Property serial_isa_properties[] = {
 DEFINE_PROP_UINT32("iobase",  ISASerialState, iobase,  -1),
 DEFINE_PROP_UINT32("irq",ISASerialState, isairq,  -1),
 DEFINE_PROP_CHR("chardev",   ISASerialState, state.chr),
-DEFINE_PROP_UINT32("wakeup", ISASerialState, state.wakeup, 0),
+DEFINE_PROP_BOOL("wakeup",   ISASerialState, state.wakeup, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/char/serial.c b/hw/char/serial.c
index ade4adfd526..ade89fadb44 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -1015,6 +1015,7 @@ static const TypeInfo serial_io_info = {
 static Property serial_properties[] = {
 DEFINE_PROP_CHR("chardev", SerialState, chr),
 DEFINE_PROP_UINT32("baudbase", SerialState, baudbase, 115200),
+DEFINE_PROP_BOOL("wakeup", SerialState, wakeup, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
2.26.2




[PATCH 2/7] hw/char/serial: Replace commented DPRINTF() by trace event

2020-09-06 Thread Philippe Mathieu-Daudé
Convert the old debug PRINTF() call to display the UART
baudrate to a trace event.

Reviewed-by: Richard Henderson 
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/char/serial.c | 4 +---
 hw/char/trace-events | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index a855ef66ea2..fb41337b661 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -187,9 +187,7 @@ static void serial_update_parameters(SerialState *s)
 ssp.stop_bits = stop_bits;
 s->char_transmit_time =  (NANOSECONDS_PER_SECOND / speed) * frame_size;
 qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
-
-DPRINTF("speed=%.2f parity=%c data=%d stop=%d\n",
-   speed, parity, data_bits, stop_bits);
+trace_serial_update_parameters(speed, parity, data_bits, stop_bits);
 }
 
 static void serial_update_msl(SerialState *s)
diff --git a/hw/char/trace-events b/hw/char/trace-events
index d20eafd56f8..85e39d9d62b 100644
--- a/hw/char/trace-events
+++ b/hw/char/trace-events
@@ -7,6 +7,7 @@ parallel_ioport_write(const char *desc, uint16_t addr, uint8_t 
value) "write [%s
 # serial.c
 serial_ioport_read(uint16_t addr, uint8_t value) "read addr 0x%02x val 0x%02x"
 serial_ioport_write(uint16_t addr, uint8_t value) "write addr 0x%02x val 
0x%02x"
+serial_update_parameters(uint64_t baudrate, char parity, int data_bits, int 
stop_bits) "baudrate=%"PRIu64" parity='%c' data=%d stop=%d"
 
 # virtio-serial-bus.c
 virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t 
value) "port %u, event %u, value %u"
-- 
2.26.2




[PATCH 1/7] hw/char/serial: Assert serial_ioport_read/write offset fits 8 bytes

2020-09-06 Thread Philippe Mathieu-Daudé
The serial device has 8 registers, each 8-bit. The MemoryRegionOps
'serial_io_ops' is initialized with max_access_size=1, and all
memory_region_init_io() callers correctly set the region size to
8 bytes:
- serial_io_realize
- serial_isa_realizefn
- serial_pci_realize
- multi_serial_pci_realize

It is safe to assert the offset argument of serial_ioport_read()
and serial_ioport_write() is always less than 8.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/char/serial.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 23864794929..a855ef66ea2 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -344,7 +344,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, 
uint64_t val,
 {
 SerialState *s = opaque;
 
-addr &= 7;
+assert(size == 1 && addr < 8);
 trace_serial_ioport_write(addr, val);
 switch(addr) {
 default:
@@ -485,7 +485,7 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr 
addr, unsigned size)
 SerialState *s = opaque;
 uint32_t ret;
 
-addr &= 7;
+assert(size == 1 && addr < 8);
 switch(addr) {
 default:
 case 0:
-- 
2.26.2




[PATCH 3/7] hw/char/serial: Remove old DEBUG_SERIAL commented code

2020-09-06 Thread Philippe Mathieu-Daudé
All useful DPRINTF() calls have been converted to trace
events.  Remove a pointless one in the IOEventHandler,
and drop the DEBUG_SERIAL ifdef'ry.

Reviewed-by: Richard Henderson 
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/char/serial.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index fb41337b661..1e70294f28a 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -36,8 +36,6 @@
 #include "trace.h"
 #include "hw/qdev-properties.h"
 
-//#define DEBUG_SERIAL
-
 #define UART_LCR_DLAB  0x80/* Divisor latch access bit */
 
 #define UART_IER_MSI   0x08/* Enable Modem status interrupt */
@@ -102,14 +100,6 @@
 
 #define MAX_XMIT_RETRY  4
 
-#ifdef DEBUG_SERIAL
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, "serial: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) \
-do {} while (0)
-#endif
-
 static void serial_receive1(void *opaque, const uint8_t *buf, int size);
 static void serial_xmit(SerialState *s);
 
@@ -636,7 +626,6 @@ static void serial_receive1(void *opaque, const uint8_t 
*buf, int size)
 static void serial_event(void *opaque, QEMUChrEvent event)
 {
 SerialState *s = opaque;
-DPRINTF("event %x\n", event);
 if (event == CHR_EVENT_BREAK)
 serial_receive_break(s);
 }
-- 
2.26.2




[PATCH 7/7] hw/char/serial: Let SerialState have an 'id' field

2020-09-06 Thread Philippe Mathieu-Daudé
When a SoC has multiple UARTs (some configured differently),
it is hard to associate events to their UART.

To be able to distinct trace events between various instances,
add an 'id' field. Update the trace format accordingly.

Reviewed-by: Richard Henderson 
Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/char/serial.h | 1 +
 hw/char/serial.c | 7 ---
 hw/char/trace-events | 6 +++---
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 3d2a5b27e87..3ee2d096a85 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -75,6 +75,7 @@ typedef struct SerialState {
 uint64_t char_transmit_time;/* time to transmit a char in ticks */
 int poll_msl;
 
+uint8_t id;
 QEMUTimer *modem_status_poll;
 MemoryRegion io;
 } SerialState;
diff --git a/hw/char/serial.c b/hw/char/serial.c
index ade89fadb44..e5a6b939f13 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -177,7 +177,7 @@ static void serial_update_parameters(SerialState *s)
 ssp.stop_bits = stop_bits;
 s->char_transmit_time =  (NANOSECONDS_PER_SECOND / speed) * frame_size;
 qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
-trace_serial_update_parameters(speed, parity, data_bits, stop_bits);
+trace_serial_update_parameters(s->id, speed, parity, data_bits, stop_bits);
 }
 
 static void serial_update_msl(SerialState *s)
@@ -333,7 +333,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, 
uint64_t val,
 SerialState *s = opaque;
 
 assert(size == 1 && addr < 8);
-trace_serial_write(addr, val);
+trace_serial_write(s->id, addr, val);
 switch(addr) {
 default:
 case 0:
@@ -550,7 +550,7 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr 
addr, unsigned size)
 ret = s->scr;
 break;
 }
-trace_serial_read(addr, ret);
+trace_serial_read(s->id, addr, ret);
 return ret;
 }
 
@@ -1013,6 +1013,7 @@ static const TypeInfo serial_io_info = {
 };
 
 static Property serial_properties[] = {
+DEFINE_PROP_UINT8("id", SerialState, id, 0),
 DEFINE_PROP_CHR("chardev", SerialState, chr),
 DEFINE_PROP_UINT32("baudbase", SerialState, baudbase, 115200),
 DEFINE_PROP_BOOL("wakeup", SerialState, wakeup, false),
diff --git a/hw/char/trace-events b/hw/char/trace-events
index cd36b63f39d..40800c9334c 100644
--- a/hw/char/trace-events
+++ b/hw/char/trace-events
@@ -5,9 +5,9 @@ parallel_ioport_read(const char *desc, uint16_t addr, uint8_t 
value) "read [%s]
 parallel_ioport_write(const char *desc, uint16_t addr, uint8_t value) "write 
[%s] addr 0x%02x val 0x%02x"
 
 # serial.c
-serial_read(uint16_t addr, uint8_t value) "read addr 0x%02x val 0x%02x"
-serial_write(uint16_t addr, uint8_t value) "write addr 0x%02x val 0x%02x"
-serial_update_parameters(uint64_t baudrate, char parity, int data_bits, int 
stop_bits) "baudrate=%"PRIu64" parity='%c' data=%d stop=%d"
+serial_read(uint8_t id, uint8_t addr, uint8_t value) "id#%u read addr 0x%x val 
0x%02x"
+serial_write(uint8_t id, uint8_t addr, uint8_t value) "id#%u write addr 0x%x 
val 0x%02x"
+serial_update_parameters(uint8_t id, uint64_t baudrate, char parity, int 
data_bits, int stop_bits) "id#%u baudrate=%"PRIu64" parity=%c data=%d stop=%d"
 
 # virtio-serial-bus.c
 virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t 
value) "port %u, event %u, value %u"
-- 
2.26.2




[PATCH 4/7] hw/char/serial: Rename I/O read/write trace events

2020-09-06 Thread Philippe Mathieu-Daudé
The serial_mm_read/write() handlers from the TYPE_SERIAL_MM device
call the serial_ioport_read/write() handlers with shifted offset.

When looking at the trace events from this MMIO device, it is
confusing to read the accesses as I/O. Simplify using generic
trace event names which make sense the various uses.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/char/serial.c | 4 ++--
 hw/char/trace-events | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 1e70294f28a..ade4adfd526 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -333,7 +333,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, 
uint64_t val,
 SerialState *s = opaque;
 
 assert(size == 1 && addr < 8);
-trace_serial_ioport_write(addr, val);
+trace_serial_write(addr, val);
 switch(addr) {
 default:
 case 0:
@@ -550,7 +550,7 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr 
addr, unsigned size)
 ret = s->scr;
 break;
 }
-trace_serial_ioport_read(addr, ret);
+trace_serial_read(addr, ret);
 return ret;
 }
 
diff --git a/hw/char/trace-events b/hw/char/trace-events
index 85e39d9d62b..cd36b63f39d 100644
--- a/hw/char/trace-events
+++ b/hw/char/trace-events
@@ -5,8 +5,8 @@ parallel_ioport_read(const char *desc, uint16_t addr, uint8_t 
value) "read [%s]
 parallel_ioport_write(const char *desc, uint16_t addr, uint8_t value) "write 
[%s] addr 0x%02x val 0x%02x"
 
 # serial.c
-serial_ioport_read(uint16_t addr, uint8_t value) "read addr 0x%02x val 0x%02x"
-serial_ioport_write(uint16_t addr, uint8_t value) "write addr 0x%02x val 
0x%02x"
+serial_read(uint16_t addr, uint8_t value) "read addr 0x%02x val 0x%02x"
+serial_write(uint16_t addr, uint8_t value) "write addr 0x%02x val 0x%02x"
 serial_update_parameters(uint64_t baudrate, char parity, int data_bits, int 
stop_bits) "baudrate=%"PRIu64" parity='%c' data=%d stop=%d"
 
 # virtio-serial-bus.c
-- 
2.26.2




[PATCH 6/7] hw/char/serial-isa: Alias QDEV properties from generic serial object

2020-09-06 Thread Philippe Mathieu-Daudé
Instead of overwritting the properties of the generic 'state'
object, alias them.
Note we can now propagate the "baudbase" property.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/char/serial-isa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c
index a0c338796d5..0626edda8d1 100644
--- a/hw/char/serial-isa.c
+++ b/hw/char/serial-isa.c
@@ -115,8 +115,6 @@ static Property serial_isa_properties[] = {
 DEFINE_PROP_UINT32("index",  ISASerialState, index,   -1),
 DEFINE_PROP_UINT32("iobase",  ISASerialState, iobase,  -1),
 DEFINE_PROP_UINT32("irq",ISASerialState, isairq,  -1),
-DEFINE_PROP_CHR("chardev",   ISASerialState, state.chr),
-DEFINE_PROP_BOOL("wakeup",   ISASerialState, state.wakeup, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -137,6 +135,8 @@ static void serial_isa_initfn(Object *o)
 ISASerialState *self = ISA_SERIAL(o);
 
 object_initialize_child(o, "serial", &self->state, TYPE_SERIAL);
+
+qdev_alias_all_properties(DEVICE(&self->state), o);
 }
 
 static const TypeInfo serial_isa_info = {
-- 
2.26.2




Re: [PATCH 07/17] hw/block/nvme: add symbolic command name to trace events

2020-09-06 Thread Philippe Mathieu-Daudé
On 9/4/20 4:19 PM, Klaus Jensen wrote:
> From: Klaus Jensen 
> 
> Add the symbolic command name to the pci_nvme_{io,admin}_cmd and
> pci_nvme_rw trace events.
> 
[...]> diff --git a/hw/block/trace-events b/hw/block/trace-events
> index 50d5702e6b80..0823d0fb47c5 100644
> --- a/hw/block/trace-events
> +++ b/hw/block/trace-events
> @@ -36,9 +36,9 @@ pci_nvme_dma_read(uint64_t prp1, uint64_t prp2) "DMA read, 
> prp1=0x%"PRIx64" prp2
>  pci_nvme_map_addr(uint64_t addr, uint64_t len) "addr 0x%"PRIx64" len 
> %"PRIu64""
>  pci_nvme_map_addr_cmb(uint64_t addr, uint64_t len) "addr 0x%"PRIx64" len 
> %"PRIu64""
>  pci_nvme_map_prp(uint64_t trans_len, uint32_t len, uint64_t prp1, uint64_t 
> prp2, int num_prps) "trans_len %"PRIu64" len %"PRIu32" prp1 0x%"PRIx64" prp2 
> 0x%"PRIx64" num_prps %d"
> -pci_nvme_io_cmd(uint16_t cid, uint32_t nsid, uint16_t sqid, uint8_t opcode) 
> "cid %"PRIu16" nsid %"PRIu32" sqid %"PRIu16" opc 0x%"PRIx8""
> -pci_nvme_admin_cmd(uint16_t cid, uint16_t sqid, uint8_t opcode) "cid 
> %"PRIu16" sqid %"PRIu16" opc 0x%"PRIx8""
> -pci_nvme_rw(const char *verb, uint32_t blk_count, uint64_t byte_count, 
> uint64_t lba) "%s %"PRIu32" blocks (%"PRIu64" bytes) from LBA %"PRIu64""
> +pci_nvme_io_cmd(uint16_t cid, uint32_t nsid, uint16_t sqid, uint8_t opcode, 
> const char *opname) "cid %"PRIu16" nsid %"PRIu32" sqid %"PRIu16" opc 
> 0x%"PRIx8" opname \"%s\""
> +pci_nvme_admin_cmd(uint16_t cid, uint16_t sqid, uint8_t opcode, const char 
> *opname) "cid %"PRIu16" sqid %"PRIu16" opc 0x%"PRIx8" opname \"%s\""
> +pci_nvme_rw(uint16_t cid, const char *verb, uint32_t nlb, uint64_t count, 
> uint64_t lba) "cid %"PRIu16" \"%s\" nlb %"PRIu32" count %"PRIu64" lba 
> 0x%"PRIx64""
>  pci_nvme_rw_cb(uint16_t cid) "cid %"PRIu16""
>  pci_nvme_write_zeroes(uint16_t cid, uint64_t slba, uint32_t nlb) "cid 
> %"PRIu16" slba %"PRIu64" nlb %"PRIu32""
>  pci_nvme_create_sq(uint64_t addr, uint16_t sqid, uint16_t cqid, uint16_t 
> qsize, uint16_t qflags) "create submission queue, addr=0x%"PRIx64", 
> sqid=%"PRIu16", cqid=%"PRIu16", qsize=%"PRIu16", qflags=%"PRIu16""
> 

I'd display the command name using simple quote.
Otherwise:
Reviewed-by: Philippe Mathieu-Daudé 




Re: [PATCH 09/17] hw/block/nvme: default request status to success

2020-09-06 Thread Philippe Mathieu-Daudé
On 9/4/20 4:19 PM, Klaus Jensen wrote:
> From: Klaus Jensen 
> 
> Make the default request status NVME_SUCCESS so only error status codes
> has to be set.

Typo 'has' -> 'have'.

> 
> Signed-off-by: Klaus Jensen 

Reviewed-by: Philippe Mathieu-Daudé 

> ---
>  hw/block/nvme.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 3e32f39c7c1d..64c8f232e3ea 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -231,6 +231,7 @@ static void nvme_req_clear(NvmeRequest *req)
>  {
>  req->ns = NULL;
>  memset(&req->cqe, 0x0, sizeof(req->cqe));
> +req->status = NVME_SUCCESS;
>  }
>  
>  static void nvme_req_exit(NvmeRequest *req)
> @@ -547,8 +548,6 @@ static void nvme_process_aers(void *opaque)
>  result->log_page = event->result.log_page;
>  g_free(event);
>  
> -req->status = NVME_SUCCESS;
> -
>  trace_pci_nvme_aer_post_cqe(result->event_type, result->event_info,
>  result->log_page);
>  
> @@ -713,7 +712,6 @@ static void nvme_aio_cb(void *opaque, int ret)
>  
>  if (!ret) {
>  block_acct_done(stats, acct);
> -req->status = NVME_SUCCESS;
>  } else {
>  uint16_t status;
>  
> 




Re: [PATCH 17/17] hw/block/nvme: change controller pci id

2020-09-06 Thread Philippe Mathieu-Daudé
+David in case

On 9/4/20 4:19 PM, Klaus Jensen wrote:
> From: Klaus Jensen 
> 
> There are two reasons for changing this:
> 
>   1. The nvme device currently uses an internal Intel device id.
> 
>   2. Since commits "nvme: fix write zeroes offset and count" and "nvme:
>  support multiple namespaces" the controller device no longer has
>  the quirks that the Linux kernel think it has.
> 
>  As the quirks are applied based on pci vendor and device id, change
>  them to get rid of the quirks.
> 
> To keep backward compatibility, add a new 'x-use-intel-id' parameter to
> the nvme device to force use of the Intel vendor and device id. This is
> off by default but add a compat property to set this for 5.1 machines
> and older.

So now what happens if you start a 5.1 machine with a recent kernel?
Simply the kernel will use unnecessary quirks, or are there more
changes in behavior?

> 
> Signed-off-by: Klaus Jensen 
> Reviewed-by: Keith Busch 
> Reviewed-by: Maxim Levitsky 
> ---
>  hw/block/nvme.c   | 12 ++--
>  hw/block/nvme.h   |  1 +
>  hw/core/machine.c |  1 +
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 453d3a89d475..8018f8679366 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -2749,6 +2749,15 @@ static void nvme_init_pci(NvmeCtrl *n, PCIDevice 
> *pci_dev, Error **errp)
>  
>  pci_conf[PCI_INTERRUPT_PIN] = 1;
>  pci_config_set_prog_interface(pci_conf, 0x2);
> +
> +if (n->params.use_intel_id) {
> +pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
> +pci_config_set_device_id(pci_conf, 0x5846);
> +} else {
> +pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REDHAT);
> +pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REDHAT_NVME);
> +}
> +
>  pci_config_set_class(pci_conf, PCI_CLASS_STORAGE_EXPRESS);
>  pcie_endpoint_cap_init(pci_dev, 0x80);
>  
> @@ -2903,6 +2912,7 @@ static Property nvme_props[] = {
>  DEFINE_PROP_UINT8("aerl", NvmeCtrl, params.aerl, 3),
>  DEFINE_PROP_UINT32("aer_max_queued", NvmeCtrl, params.aer_max_queued, 
> 64),
>  DEFINE_PROP_UINT8("mdts", NvmeCtrl, params.mdts, 7),
> +DEFINE_PROP_BOOL("x-use-intel-id", NvmeCtrl, params.use_intel_id, false),
>  DEFINE_PROP_END_OF_LIST(),
>  };
>  
> @@ -2919,8 +2929,6 @@ static void nvme_class_init(ObjectClass *oc, void *data)
>  pc->realize = nvme_realize;
>  pc->exit = nvme_exit;
>  pc->class_id = PCI_CLASS_STORAGE_EXPRESS;
> -pc->vendor_id = PCI_VENDOR_ID_INTEL;
> -pc->device_id = 0x5845;
>  pc->revision = 2;
>  
>  set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
> diff --git a/hw/block/nvme.h b/hw/block/nvme.h
> index 72260f2e8ea9..a734a5e1370d 100644
> --- a/hw/block/nvme.h
> +++ b/hw/block/nvme.h
> @@ -15,6 +15,7 @@ typedef struct NvmeParams {
>  uint8_t  aerl;
>  uint32_t aer_max_queued;
>  uint8_t  mdts;
> +bool use_intel_id;
>  } NvmeParams;
>  
>  typedef struct NvmeAsyncEvent {
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index ea26d612374d..67990232528c 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -34,6 +34,7 @@ GlobalProperty hw_compat_5_1[] = {
>  { "vhost-user-scsi", "num_queues", "1"},
>  { "virtio-blk-device", "num-queues", "1"},
>  { "virtio-scsi-device", "num_queues", "1"},
> +{ "nvme", "x-use-intel-id", "on"},
>  };
>  const size_t hw_compat_5_1_len = G_N_ELEMENTS(hw_compat_5_1);
>  
> 




Re: [PATCH 04/17] hw/block/nvme: alignment style fixes

2020-09-06 Thread Philippe Mathieu-Daudé
On 9/4/20 4:19 PM, Klaus Jensen wrote:
> From: Klaus Jensen 
> 
> Style fixes.
> 
> Signed-off-by: Klaus Jensen 
> ---
>  hw/block/nvme.c | 25 +
>  1 file changed, 13 insertions(+), 12 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé 




Re: [PATCH 02/17] hw/block/nvme: handle dma errors

2020-09-06 Thread Philippe Mathieu-Daudé
Hi Klaus,

On 9/4/20 4:19 PM, Klaus Jensen wrote:
> From: Klaus Jensen 
> 
> Handling DMA errors gracefully is required for the device to pass the
> block/011 test ("disable PCI device while doing I/O") in the blktests
> suite.
> 
> With this patch the device passes the test by retrying "critical"
> transfers (posting of completion entries and processing of submission
> queue entries).
> 
> If DMA errors occur at any other point in the execution of the command
> (say, while mapping the PRPs), the command is aborted with a Data
> Transfer Error status code.
> 
> Signed-off-by: Klaus Jensen 
> Acked-by: Keith Busch 
> Reviewed-by: Maxim Levitsky 
> ---
>  hw/block/nvme.c   | 43 ---
>  hw/block/trace-events |  2 ++
>  include/block/nvme.h  |  2 +-
>  3 files changed, 35 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 63078f600920..49bcdf31ced6 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -140,14 +140,14 @@ static inline void *nvme_addr_to_cmb(NvmeCtrl *n, 
> hwaddr addr)
>  return &n->cmbuf[addr - n->ctrl_mem.addr];
>  }
>  
> -static void nvme_addr_read(NvmeCtrl *n, hwaddr addr, void *buf, int size)
> +static int nvme_addr_read(NvmeCtrl *n, hwaddr addr, void *buf, int size)

If this get merged first:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg737483.html
then please return MemTxResult, ...

>  {
>  if (n->bar.cmbsz && nvme_addr_is_cmb(n, addr)) {
>  memcpy(buf, nvme_addr_to_cmb(n, addr), size);
> -return;
> +return 0;
>  }
>  
> -pci_dma_read(&n->parent_obj, addr, buf, size);
> +return pci_dma_read(&n->parent_obj, addr, buf, size);
>  }
>  
>  static int nvme_check_sqid(NvmeCtrl *n, uint16_t sqid)
> @@ -253,7 +253,7 @@ static uint16_t nvme_map_addr_cmb(NvmeCtrl *n, 
> QEMUIOVector *iov, hwaddr addr,
>  trace_pci_nvme_map_addr_cmb(addr, len);
>  
>  if (!nvme_addr_is_cmb(n, addr) || !nvme_addr_is_cmb(n, addr + len - 1)) {
> -return NVME_DATA_TRAS_ERROR;
> +return NVME_DATA_TRANSFER_ERROR;
>  }
>  
>  qemu_iovec_add(iov, nvme_addr_to_cmb(n, addr), len);
> @@ -307,6 +307,7 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, uint64_t prp1, 
> uint64_t prp2,
>  int num_prps = (len >> n->page_bits) + 1;
>  uint16_t status;
>  bool prp_list_in_cmb = false;
> +int ret;
>  
>  QEMUSGList *qsg = &req->qsg;
>  QEMUIOVector *iov = &req->iov;
> @@ -347,7 +348,11 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, uint64_t prp1, 
> uint64_t prp2,
>  
>  nents = (len + n->page_size - 1) >> n->page_bits;
>  prp_trans = MIN(n->max_prp_ents, nents) * sizeof(uint64_t);
> -nvme_addr_read(n, prp2, (void *)prp_list, prp_trans);
> +ret = nvme_addr_read(n, prp2, (void *)prp_list, prp_trans);
> +if (ret) {

... and check it (other cases following).

> +trace_pci_nvme_err_addr_read(prp2);
> +return NVME_DATA_TRANSFER_ERROR;
> +}
>  while (len != 0) {
>  uint64_t prp_ent = le64_to_cpu(prp_list[i]);
>  
> @@ -364,8 +369,12 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, uint64_t prp1, 
> uint64_t prp2,
>  i = 0;
>  nents = (len + n->page_size - 1) >> n->page_bits;
>  prp_trans = MIN(n->max_prp_ents, nents) * 
> sizeof(uint64_t);
> -nvme_addr_read(n, prp_ent, (void *)prp_list,
> -prp_trans);
> +ret = nvme_addr_read(n, prp_ent, (void *)prp_list,
> + prp_trans);
> +if (ret) {
> +trace_pci_nvme_err_addr_read(prp_ent);
> +return NVME_DATA_TRANSFER_ERROR;
> +}
>  prp_ent = le64_to_cpu(prp_list[i]);
>  }
>  
> @@ -457,6 +466,7 @@ static void nvme_post_cqes(void *opaque)
>  NvmeCQueue *cq = opaque;
>  NvmeCtrl *n = cq->ctrl;
>  NvmeRequest *req, *next;
> +int ret;
>  
>  QTAILQ_FOREACH_SAFE(req, &cq->req_list, entry, next) {
>  NvmeSQueue *sq;
> @@ -466,15 +476,21 @@ static void nvme_post_cqes(void *opaque)
>  break;
>  }
>  
> -QTAILQ_REMOVE(&cq->req_list, req, entry);
>  sq = req->sq;
>  req->cqe.status = cpu_to_le16((req->status << 1) | cq->phase);
>  req->cqe.sq_id = cpu_to_le16(sq->sqid);
>  req->cqe.sq_head = cpu_to_le16(sq->head);
>  addr = cq->dma_addr + cq->tail * n->cqe_size;
> +ret = pci_dma_write(&n->parent_obj, addr, (void *)&req->cqe,
> +sizeof(req->cqe));
> +if (ret) {
> +trace_pci_nvme_err_addr_write(addr);
> +timer_mod(cq->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
> +  500 * SCALE_MS);
> +break;
> +}
> +QTAILQ

Re: [PULL 00/30] ppc-for-5.2 queue 20200904

2020-09-06 Thread David Gibson
On Sun, Sep 06, 2020 at 04:20:10PM +0100, Peter Maydell wrote:
> On Fri, 4 Sep 2020 at 04:47, David Gibson  wrote:
> >
> > The following changes since commit 67a7bfe560a1bba59efab085cb3430f45176d382:
> >
> >   Merge remote-tracking branch 
> > 'remotes/huth-gitlab/tags/pull-request-2020-09-03' into staging (2020-09-03 
> > 16:58:25 +0100)
> >
> > are available in the Git repository at:
> >
> >   git://github.com/dgibson/qemu.git tags/ppc-for-5.2-20200904
> >
> > for you to fetch changes up to b172606ecf29a140073f7787251a9d70ecb53b6e:
> >
> >   spapr_numa: move NVLink2 associativity handling to spapr_numa.c 
> > (2020-09-04 13:40:09 +1000)
> >
> > 
> > ppc patch queue 2020-09-04
> >
> > Next pull request for qemu-5.2.  The biggest thing here is the
> > generalization of ARM's start-powered-off machine property to all
> > targets.  This can fix a number of odd little edge cases where KVM
> > could run vcpus before they were properly initialized.  This does
> > include changes to a number of files that aren't normally in my
> > purview.  There are suitable Acked-by lines and Peter requested this
> > come in via my tree, since the most pressing requirement for it is in
> > pseries machines with the POWER secure virtual machine facility.
> >
> > In addition we have:
> >  * The start of Daniel Barboza's rework and clean up of pseries
> >machine NUMA handling
> >  * Correction to behaviour of the nvdimm= generic machine property on
> >pseries
> >  * An optimization to the allocation of XIVE interrupts on KVM
> >  * Some fixes for confused behaviour with kernel_irqchip when both
> >XICS and XIVE are in play
> >  * Add HIOMAP comamnd to pnv flash
> >  * Properly advertise the fact that spapr_vscsi doesn't handle
> >hotplugged disks
> >  * Some assorted minor enhancements
> 
> Hi -- this fails to build for Windows:
> 
> ../../hw/ppc/spapr_numa.c: In function 'spapr_numa_fixup_cpu_dt':
> ../../hw/ppc/spapr_numa.c:77:5: error: unknown type name 'uint'
>  uint vcpu_assoc_size = NUMA_ASSOC_SIZE + 1;
>  ^

Huh, that's weird.  My testing run was less thorough than I'd usually
do, because so many tests were broken on the master branch, but I was
pretty sure I did do successful mingw builds.

> That should probably be using one of the standard C types.

Done.

> The 'check-tcg' tests for the linux-user static build also
> failed on an s390x test:
> 
>   CHECK   debian-s390x-cross
>   BUILD   s390x-linux-user guest-tests with docker qemu/debian-s390x-cross
>   RUN tests for s390x
>   TESTthreadcount on s390x
> Unhandled trap: 0x10003
> PSW=mask 00018000 addr 010004f0 cc 00
> R00= R01= R02=
> R03=
> R04= R05= R06=
> R07=
> R08= R09= R10=
> R11=
> R12= R13= R14=
> R15=0040008006c0
> 
> ../Makefile.target:153: recipe for target 'run-threadcount' failed
> make[2]: *** [run-threadcount] Error 1

Bother.  I did see that failure on Travis, but assumed it was a false
positive because there were so many failures on master there.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


[PATCH] hw/s390x/css: Remove double initialization

2020-09-06 Thread Philippe Mathieu-Daudé
Fix eventual copy/paste mistake introduced in commit bc994b74ea
("s390x/css: Use static initialization for channel_subsys fields").

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/s390x/css.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 519dc91316d..9961cfe7bf6 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -353,7 +353,6 @@ static ChannelSubSys channel_subsys = {
 .pending_crws = QTAILQ_HEAD_INITIALIZER(channel_subsys.pending_crws),
 .do_crw_mchk = true,
 .sei_pending = false,
-.do_crw_mchk = true,
 .crws_lost = false,
 .chnmon_active = false,
 .indicator_addresses =
-- 
2.26.2




Re: [PATCH] hw/block/nand: Decommission the NAND museum

2020-09-06 Thread Philippe Mathieu-Daudé
ping^2

On 8/22/20 10:03 PM, Philippe Mathieu-Daudé wrote:
> ping?
> 
> On 8/14/20 3:23 PM, Philippe Mathieu-Daudé wrote:
>> I forgot to Cc qemu-arm@, doing it now since most of the users
>> of this are ARM machines.
>>
>> On 8/14/20 3:21 PM, Philippe Mathieu-Daudé wrote:
>>> This is the QEMU equivalent of this Linux commit (but 7 years later):
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f7025a43a9da2
>>>
>>> The MTD subsystem has its own small museum of ancient NANDs
>>> in a form of the CONFIG_MTD_NAND_MUSEUM_IDS configuration option.
>>> The museum contains stone age NANDs with 256 bytes pages, as well
>>> as iron age NANDs with 512 bytes per page and up to 8MiB page size.
>>>
>>> It is with great sorrow that I inform you that the museum is being
>>> decommissioned. The MTD subsystem is out of budget for Kconfig
>>> options and already has too many of them, and there is a general
>>> kernel trend to simplify the configuration menu.
>>>
>>> We remove the stone age exhibits along with closing the museum,
>>> but some of the iron age ones are transferred to the regular NAND
>>> depot. Namely, only those which have unique device IDs are
>>> transferred, and the ones which have conflicting device IDs are
>>> removed.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé 
>>> ---
>>>  hw/block/nand.c | 13 ++---
>>>  1 file changed, 6 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/hw/block/nand.c b/hw/block/nand.c
>>> index 654e0cb5d1..7d7ccc9aa4 100644
>>> --- a/hw/block/nand.c
>>> +++ b/hw/block/nand.c
>>> @@ -137,7 +137,7 @@ static void mem_and(uint8_t *dest, const uint8_t *src, 
>>> size_t n)
>>>  # define ADDR_SHIFT16
>>>  # include "nand.c"
>>>  
>>> -/* Information based on Linux drivers/mtd/nand/nand_ids.c */
>>> +/* Information based on Linux drivers/mtd/nand/raw/nand_ids.c */
>>>  static const struct {
>>>  int size;
>>>  int width;
>>> @@ -153,15 +153,14 @@ static const struct {
>>>  [0xe8] = { 1,  8,  8, 4, 0 },
>>>  [0xec] = { 1,  8,  8, 4, 0 },
>>>  [0xea] = { 2,  8,  8, 4, 0 },
>>> -[0xd5] = { 4,  8,  9, 4, 0 },
>>>  [0xe3] = { 4,  8,  9, 4, 0 },
>>>  [0xe5] = { 4,  8,  9, 4, 0 },
>>> -[0xd6] = { 8,  8,  9, 4, 0 },
>>>  
>>> -[0x39] = { 8,  8,  9, 4, 0 },
>>> -[0xe6] = { 8,  8,  9, 4, 0 },
>>> -[0x49] = { 8,  16, 9, 4, NAND_BUSWIDTH_16 },
>>> -[0x59] = { 8,  16, 9, 4, NAND_BUSWIDTH_16 },
>>> +[0x6b] = { 4,8,9, 4, 0 },
>>> +[0xe3] = { 4,8,9, 4, 0 },
>>> +[0xe5] = { 4,8,9, 4, 0 },
>>> +[0xd6] = { 8,8,9, 4, 0 },
>>> +[0xe6] = { 8,8,9, 4, 0 },
>>>  
>>>  [0x33] = { 16, 8,  9, 5, 0 },
>>>  [0x73] = { 16, 8,  9, 5, 0 },
>>>
>>
> 



Re: [PULL v2 00/46] Next round of Meson bugfixes and cleanups

2020-09-06 Thread Yonggang Luo
On Mon, Sep 7, 2020 at 2:35 AM Peter Maydell 
wrote:

> On Sun, 6 Sep 2020 at 18:56, Paolo Bonzini  wrote:
> >
> > The following changes since commit
> 227de21ed0759e275a469394af72c999d0134bb5:
> >
> >   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20200903' into
> staging (2020-09-05 15:30:41 +0100)
> >
> > are available in the Git repository at:
> >
> >   https://gitlab.com/bonzini/qemu.git tags/for-upstream
> >
> > for you to fetch changes up to 6264b35324d3766d3c2ff369c4e8ecba8bd5b571:
> >
> >   meson: remove linkage of sdl to baum (2020-09-06 19:50:57 +0200)
> >
> > 
> > meson related:
> > * convert unit tests
> > * bugfixes for mtest2make
> > * miscellaneous bugfixes
> > * dead code removal and configure cleanups
> > * oss-fuzz fixes
> > * msys fixes
>
> Build failure, Windows (this is the second "uint" type usage
> I've seen today...):
>
> ../../tests/test-vmstate.c: In function 'int_cmp':
> ../../tests/test-vmstate.c:884:5: error: unknown type name 'uint'
>  uint ua = GPOINTER_TO_UINT(a);
>  ^
> ../../tests/test-vmstate.c:885:5: error: unknown type name 'uint'
>  uint ub = GPOINTER_TO_UINT(b);
>  ^
>
I've already fixes this issue, that patch can be quenued

> Makefile.ninja:5443: recipe for target
> 'tests/test-vmstate.exe.p/test-vmstate.c.obj' failed
> make: *** [tests/test-vmstate.exe.p/test-vmstate.c.obj] Error 1
> make: *** Waiting for unfinished jobs
> ../../tests/test-util-filemonitor.c: In function
> 'test_file_monitor_events':
> ../../tests/test-util-filemonitor.c:620:17: error: too many arguments
> to function 'mkdir'
>  if (mkdir(pathsrc, 0700) < 0) {
>  ^
> In file included from
> /usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/unistd.h:10:0,
>  from
> /home/petmay01/qemu-for-merges/include/qemu/osdep.h:93,
>  from ../../tests/test-util-filemonitor.c:21:
> /usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include/io.h:280:15: note:
> declared here
>int __cdecl mkdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
>^
>
>
>
> Build failure, OpenBSD:
>
> In file included from ../src/hw/arm/nseries.c:30:
> In file included from
> /home/qemu/qemu-test.yhbDti/src/include/hw/arm/omap.h:24:
> In file included from
> /home/qemu/qemu-test.yhbDti/src/include/hw/input/tsc2xxx.h:14:
> /home/qemu/qemu-test.yhbDti/src/include/ui/console.h:11:11: fatal
> error: 'epoxy/gl.h' file not found
> # include 
>   ^~~~
> 1 error generated.
> gmake: *** [Makefile.ninja:1735:
> libqemu-aarch64-softmmu.fa.p/hw_arm_nseries.c.o] Error 1
>
>
>
> Odd warning on most but not all of the builds, though they went on to
> complete OK:
>
> make: Entering directory '/home/peter.maydell/qemu-freebsd/build'
> /home/peter.maydell/qemu-freebsd/tests/Makefile.include:144: warning:
> overriding recipe for target 'check-block'
> Makefile.mtest:1345: warning: ignoring old recipe for target 'check-block'
> config-host.mak is out-of-date, running configure
> cross containers  no
>
> NOTE: guest cross-compilers enabled: aarch64-linux-gnu-gcc cc
> aarch64-linux-gnu-gcc cc
> /usr/bin/python3 /home/peter.maydell/qemu-freebsd/meson/meson.py
> --internal regenerate /home/peter.maydell/qemu-freebsd
> /home/peter.maydell/qemu-freebsd/build --backend ninja
> The Meson build system
> Version: 0.55.1
> [etc]
>
>
> x86-64 clang build failed at the link stage (this is config we've
> talked about before with
> '../../configure' '--cc=clang' '--cxx=clang++' '--enable-gtk'
> '--extra-cflags=-fsanitize=undefined  -fno-sanitize=shift-base
> -Werror'
> but where the clang++ doesn't work because the right libstdc++ happens
> not to be present):
>
> Linking target qemu-alpha
> libcommon.fa.p/cpus-common.c.o: In function `cpu_list_add':
> /home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:80:
> undefined reference to `__ubsan_handle_type_mismatch_v1'
> /home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:80:
> undefined reference to `__ubsan_handle_type_mismatch_v1'
> libcommon.fa.p/cpus-common.c.o: In function `cpu_get_free_index':
> /home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:68:
> undefined reference to `__ubsan_handle_type_mismatch_v1'
> /home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:68:
> undefined reference to `__ubsan_handle_type_mismatch_v1'
> /home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:67:
> undefined reference to `__ubsan_handle_type_mismatch_v1'
>
> libcommon.fa.p/cpus-common.c.o:/home/petmay01/linaro/qemu-for-merges/build/clang/../../cpus-common.c:67:
> more undefined references to `__ubsan_handle_type_mismatch_v1' follow
> collect2: error: ld returned 1 exit status
>
> thanks
> -- PMM
>
>

-- 
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


Re: [PATCH] tests: fixes test-vmstate.c compile error on msys2

2020-09-06 Thread Yonggang Luo
Bonzini, you need have a look at this

On Sat, Sep 5, 2020 at 2:38 PM Yonggang Luo  wrote:

> ../tests/test-vmstate.c: In function 'int_cmp':
> ../tests/test-vmstate.c:884:5: error: unknown type name 'uint'; did you
> mean 'uInt'?
>   884 | uint ua = GPOINTER_TO_UINT(a);
>   | ^~~~
>   | uInt
> ../tests/test-vmstate.c:885:5: error: unknown type name 'uint'; did you
> mean 'uInt'?
>   885 | uint ub = GPOINTER_TO_UINT(b);
>   | ^~~~
>   | uInt
> make: ***
> [Makefile.ninja:5461:tests/test-vmstate.exe.p/test-vmstate.c.obj] 错误 1
>
> Signed-off-by: Yonggang Luo 
> ---
>  tests/test-vmstate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
> index f7b3868881..f8de709a0b 100644
> --- a/tests/test-vmstate.c
> +++ b/tests/test-vmstate.c
> @@ -881,8 +881,8 @@ static gint interval_cmp(gconstpointer a,
> gconstpointer b, gpointer user_data)
>  /* ID comparison function */
>  static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data)
>  {
> -uint ua = GPOINTER_TO_UINT(a);
> -uint ub = GPOINTER_TO_UINT(b);
> +guint ua = GPOINTER_TO_UINT(a);
> +guint ub = GPOINTER_TO_UINT(b);
>  return (ua > ub) - (ua < ub);
>  }
>
> --
> 2.28.0.windows.1
>
>

-- 
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


[PATCH v2] configure: Fixes ncursesw detection under msys2/mingw and enable curses

2020-09-06 Thread Yonggang Luo
The mingw pkg-config are showing following absolute path and contains : as the 
separator,
so we must handling : properly.

-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L 
-IC:/CI-Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -pipe 
-lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lncursesw
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lcursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe -lncursesw 
-lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lcursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx -ltre 
-lintl -liconv
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw

MINGW doesn't have langinfo.h, only exist in glic and musl

gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe -lncursesw 
-lgnurx -ltre -lintl -liconv
test.c:4:10: fatal error: langinfo.h: No such file or directory
4 | #include 
  |  ^~~~
compilation terminated.

Signed-off-by: Yonggang Luo 
---
 configure   |  9 +++--
 ui/curses.c | 10 +-
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index f8cbd2898c..2dc25bda69 100755
--- a/configure
+++ b/configure
@@ -3620,8 +3620,8 @@ if test "$iconv" = "no" ; then
 fi
 if test "$curses" != "no" ; then
   if test "$mingw32" = "yes" ; then
-curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
-curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
+curses_inc_list="$($pkg_config --cflags ncursesw 
2>/dev/null):-I/${MSYSTEM,,}/include/ncursesw:"
+curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw"
   else
 curses_inc_list="$($pkg_config --cflags ncursesw 
2>/dev/null):-I/usr/include/ncursesw:"
 curses_lib_list="$($pkg_config --libs ncursesw 
2>/dev/null):-lncursesw:-lcursesw"
@@ -3631,17 +3631,14 @@ if test "$curses" != "no" ; then
 #include 
 #include 
 #include 
-#include 
 int main(void) {
-  const char *codeset;
   wchar_t wch = L'w';
   setlocale(LC_ALL, "");
   resize_term(0, 0);
   addwstr(L"wide chars\n");
   addnwstr(&wch, 1);
   add_wch(WACS_DEGREE);
-  codeset = nl_langinfo(CODESET);
-  return codeset != 0;
+  return 0;
 }
 EOF
   IFS=:
diff --git a/ui/curses.c b/ui/curses.c
index a59b23a9cf..f13804e942 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -30,7 +30,6 @@
 #endif
 #include 
 #include 
-#include 
 #include 
 
 #include "qapi/error.h"
@@ -526,6 +525,7 @@ static void font_setup(void)
 iconv_t nativecharset_to_ucs2;
 iconv_t font_conv;
 int i;
+g_autoptr(gchar) local_codeset = g_get_codeset();
 
 /*
  * Control characters are normally non-printable, but VGA does have
@@ -566,14 +566,14 @@ static void font_setup(void)
   0x25bc
 };
 
-ucs2_to_nativecharset = iconv_open(nl_langinfo(CODESET), "UCS-2");
+ucs2_to_nativecharset = iconv_open(local_codeset, "UCS-2");
 if (ucs2_to_nativecharset == (iconv_t) -1) {
 fprintf(stderr, "Could not convert font glyphs from UCS-2: '%s'\n",
 strerror(errno));
 exit(1);
 }
 
-nativecharset_to_ucs2 = iconv_open("UCS-2", nl_langinfo(CODESET));
+nativecharset_to_ucs2 = iconv_open("UCS-2", local_codeset);
 if (nativecharset_to_ucs2 == (iconv_t) -1) {
 iconv_close(ucs2_to_nativecharset);
 fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",
@@ -581,7 +581,7 @@ static void font_setup(void)
 exit(1);
 }
 
-font_conv = iconv_open(nl_langinfo(CODESET), font_charset);
+font_conv = iconv_open(local_codeset, font_charset);
 if (font_conv == (iconv_t) -1) {
 iconv_close(ucs2_to_nativecharset);
 iconv_close(nativecharset_to_ucs2);
@@ -602,7 +602,7 @@ static void font_setup(void)
 /* DEL */
 convert_ucs(0x7F, 0x2302, ucs2_to_nativecharset);
 
-if (strcmp(nl_langinfo(CODESET), "UTF-8")) {
+if (strcmp(local_codeset, "UTF-8")) {
 /* Non-Unicode capable, use termcap equivalents for those available */
 for (i = 0; i <= 0xFF; i++) {
 wchar_t wch[CCHARW_MAX];
-- 
2.28.0.windows.1




Re: [PATCH V2 for-5.2] hw/null-machine: Add the kvm_type() hook for MIPS

2020-09-06 Thread Philippe Mathieu-Daudé
You forgot to Cc the maintainers, doing it for you:

./scripts/get_maintainer.pl -f hw/core/null-machine.c
Eduardo Habkost  (supporter:Machine core)
Marcel Apfelbaum  (supporter:Machine core)

On 9/3/20 2:58 AM, Huacai Chen wrote:
> Hi, Philippe,
> 
> On Wed, Sep 2, 2020 at 9:55 PM Philippe Mathieu-Daudé  wrote:
>>
>> Hi Huacai,
>>
>> On 8/24/20 10:11 AM, Huacai Chen wrote:
>>> MIPS has two types of KVM: TE & VZ, and TE is the default type. Now,
>>> libvirt uses a null-machine to detect the kvm capability. In the MIPS
>>> case, it will return "KVM not supported" on a VZ platform by default.
>>> So, add the kvm_type() hook to the null-machine.
>>>
>>> This seems not a very good solution, but I cannot do it better now.
>>>
>>> Reviewed-by: Aleksandar Markovic 
>>> Signed-off-by: Huacai Chen 
>>> Co-developed-by: Jiaxun Yang 
>>> ---
>>>  hw/core/meson.build| 2 +-
>>>  hw/core/null-machine.c | 6 ++
>>>  2 files changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/core/meson.build b/hw/core/meson.build
>>> index fc91f98..b6591b9 100644
>>> --- a/hw/core/meson.build
>>> +++ b/hw/core/meson.build
>>> @@ -35,7 +35,6 @@ softmmu_ss.add(files(
>>>'machine-hmp-cmds.c',
>>>'machine.c',
>>>'nmi.c',
>>> -  'null-machine.c',
>>>'qdev-fw.c',
>>>'qdev-properties-system.c',
>>>'sysbus.c',
>>> @@ -45,5 +44,6 @@ softmmu_ss.add(files(
>>>
>>>  specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: files(
>>>'machine-qmp-cmds.c',
>>> +  'null-machine.c',
>>>'numa.c',
>>>  ))
>>> diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c
>>> index 7e69352..4b4ab76 100644
>>> --- a/hw/core/null-machine.c
>>> +++ b/hw/core/null-machine.c
>>> @@ -17,6 +17,9 @@
>>>  #include "sysemu/sysemu.h"
>>>  #include "exec/address-spaces.h"
>>>  #include "hw/core/cpu.h"
>>> +#ifdef TARGET_MIPS
>>> +#include "kvm_mips.h"
>>> +#endif
>>>
>>>  static void machine_none_init(MachineState *mch)
>>>  {
>>> @@ -55,6 +58,9 @@ static void machine_none_machine_init(MachineClass *mc)
>>>  mc->no_floppy = 1;
>>>  mc->no_cdrom = 1;
>>>  mc->no_sdcard = 1;
>>> +#ifdef TARGET_MIPS
>>> +mc->kvm_type = mips_kvm_type;
>>> +#endif
>>
>> I'm a bit confused here, you are taking the same path from your v4...
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg712550.html
>>
>> Did you rebase the correct version?
> The old patch has split to two parts, the first part is used by MIPS
> machine and already merged. This is the second part used by the
> null-machine (and libvirt use null-machine to detect kvm
> capabilities).
> 
> Huacai
>>
>>>  }
>>>
>>>  DEFINE_MACHINE("none", machine_none_machine_init)
>>>
> 



Re: [PATCH V8 for-5.2] hw/mips: Add Loongson-3 machine support (with KVM)

2020-09-06 Thread Philippe Mathieu-Daudé
Hi Huacai,

On 8/24/20 10:10 AM, Huacai Chen wrote:
> Add Loongson-3 based machine support, it use liointc as the interrupt
> controler and use GPEX as the pci controller. Currently it can only work
> with KVM, but we will add TCG support in future.
> 
> As the machine model is not based on any exiting physical hardware, the
> name of the machine is "loongson3-virt". It may be superseded in future
> by a real machine model. If this happens, then a regular deprecation
> procedure shall occur for "loongson3-virt" machine.
> 
> We now already have a full functional Linux kernel (based on Linux-5.4.x
> LTS, the kvm host side and guest side have both been upstream for Linux-
> 5.9, but Linux-5.9 has not been released yet) here:
> 
> https://github.com/chenhuacai/linux
> 
> Of course the upstream kernel is also usable (though it is "unstable"
> now):
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> 
> How to use QEMU/Loongson-3?
> 1, Download kernel source from the above URL;
> 2, Build a kernel with arch/mips/configs/loongson3_defconfig;
> 3, Boot the a Loongson-3A4000 host with this kernel;
> 4, Build QEMU-master with this patchset;
> 5, modprobe kvm;
> 6, Use QEMU with TCG (available in future):
>qemu-system-mips64el -M loongson3-virt,accel=tcg -cpu Loongson-3A1000 
> -kernel  -append ...

Please keep the codebase restricted to what is available in the present.

>Use QEMU with KVM (available at present):
>qemu-system-mips64el -M loongson3-virt,accel=kvm -cpu Loongson-3A4000 
> -kernel  -append ...

As I don't have the hardware to test this, I'll defer the overall
review to Aleksandar. I will only make some generic comments.

> 
>The "-cpu" parameter is optional here and QEMU will use the correct type 
> for TCG/KVM automatically.
> 
> Signed-off-by: Huacai Chen 
> Co-developed-by: Jiaxun Yang 
> ---
>  default-configs/mips64el-softmmu.mak |   1 +
>  hw/mips/Kconfig  |  11 +
>  hw/mips/loongson3_virt.c | 963 
> +++
>  hw/mips/meson.build  |   1 +
>  4 files changed, 976 insertions(+)
>  create mode 100644 hw/mips/loongson3_virt.c
> 
> diff --git a/default-configs/mips64el-softmmu.mak 
> b/default-configs/mips64el-softmmu.mak
> index 9f8a3ef..26c660a 100644
> --- a/default-configs/mips64el-softmmu.mak
> +++ b/default-configs/mips64el-softmmu.mak
> @@ -3,6 +3,7 @@
>  include mips-softmmu-common.mak
>  CONFIG_IDE_VIA=y
>  CONFIG_FULOONG=y
> +CONFIG_LOONGSON3V=y
>  CONFIG_ATI_VGA=y
>  CONFIG_RTL8139_PCI=y
>  CONFIG_JAZZ=y
> diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
> index 67d39c5..cc5609b 100644
> --- a/hw/mips/Kconfig
> +++ b/hw/mips/Kconfig
> @@ -45,6 +45,17 @@ config FULOONG
>  bool
>  select PCI_BONITO
>  
> +config LOONGSON3V
> +bool
> +select PCKBD
> +select SERIAL
> +select GOLDFISH_RTC
> +select LOONGSON_LIOINTC
> +select PCI_EXPRESS_GENERIC_BRIDGE
> +select VIRTIO_VGA
> +select QXL if SPICE
> +select MSI_NONBROKEN
> +
>  config MIPS_CPS
>  bool
>  select PTIMER
> diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
> new file mode 100644
> index 000..8524dda
> --- /dev/null
> +++ b/hw/mips/loongson3_virt.c
> @@ -0,0 +1,963 @@
> +/*
> + * Generic Loongson-3 Platform support
> + *
> + * Copyright (c) 2017-2020 Huacai Chen (che...@lemote.com)

Since "Co-developed-by: Jiaxun Yang", should he appears here too?

> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see .
> + */
> +
> +/*
> + * Generic virtualized PC Platform based on Loongson-3 CPU (MIPS64R2 with
> + * extensions, 800~2000MHz)
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "qemu/units.h"
> +#include "qapi/error.h"
> +#include "cpu.h"
> +#include "elf.h"
> +#include "kvm_mips.h"
> +#include "hw/boards.h"
> +#include "hw/char/serial.h"
> +#include "hw/mips/mips.h"
> +#include "hw/mips/cpudevs.h"
> +#include "hw/misc/empty_slot.h"
> +#include "hw/intc/i8259.h"
> +#include "hw/loader.h"
> +#include "hw/isa/superio.h"
> +#include "hw/pci/msi.h"
> +#include "hw/pci/pci.h"
> +#include "hw/pci/pci_host.h"
> +#include "hw/pci-host/gpex.h"
> +#include "hw/rtc/mc146818rtc.h"
> +#include "hw/usb.h"
> +#include "net/net.h"
> +#include "exec/address-spaces.h"
> +#include "sysemu/kvm.h"
> +#include "sysemu/qtest.h"

[PATCH v3] configure: Fixes ncursesw detection under msys2/mingw and enable curses

2020-09-06 Thread Yonggang Luo
The mingw pkg-config are showing following absolute path and contains : as the 
separator,
so we must handling : properly.

-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L 
-IC:/CI-Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -pipe 
-lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lncursesw
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lcursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe -lncursesw 
-lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lcursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx -ltre 
-lintl -liconv
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw

MINGW doesn't have langinfo.h, only exist in glic and musl

gcc test.c -DNCURSES_WIDECHAR -I/mingw64/include/ncursesw -pipe -lncursesw 
-lgnurx -ltre -lintl -liconv
test.c:4:10: fatal error: langinfo.h: No such file or directory
4 | #include 
  |  ^~~~
compilation terminated.

Signed-off-by: Yonggang Luo 
---
 configure   |  9 +++--
 ui/curses.c | 10 +-
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index f8cbd2898c..2dc25bda69 100755
--- a/configure
+++ b/configure
@@ -3620,8 +3620,8 @@ if test "$iconv" = "no" ; then
 fi
 if test "$curses" != "no" ; then
   if test "$mingw32" = "yes" ; then
-curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
-curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
+curses_inc_list="$($pkg_config --cflags ncursesw 
2>/dev/null):-I/${MSYSTEM,,}/include/ncursesw:"
+curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw"
   else
 curses_inc_list="$($pkg_config --cflags ncursesw 
2>/dev/null):-I/usr/include/ncursesw:"
 curses_lib_list="$($pkg_config --libs ncursesw 
2>/dev/null):-lncursesw:-lcursesw"
@@ -3631,17 +3631,14 @@ if test "$curses" != "no" ; then
 #include 
 #include 
 #include 
-#include 
 int main(void) {
-  const char *codeset;
   wchar_t wch = L'w';
   setlocale(LC_ALL, "");
   resize_term(0, 0);
   addwstr(L"wide chars\n");
   addnwstr(&wch, 1);
   add_wch(WACS_DEGREE);
-  codeset = nl_langinfo(CODESET);
-  return codeset != 0;
+  return 0;
 }
 EOF
   IFS=:
diff --git a/ui/curses.c b/ui/curses.c
index a59b23a9cf..12bc682cf9 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -30,7 +30,6 @@
 #endif
 #include 
 #include 
-#include 
 #include 
 
 #include "qapi/error.h"
@@ -526,6 +525,7 @@ static void font_setup(void)
 iconv_t nativecharset_to_ucs2;
 iconv_t font_conv;
 int i;
+g_autofree gchar *local_codeset = g_get_codeset();
 
 /*
  * Control characters are normally non-printable, but VGA does have
@@ -566,14 +566,14 @@ static void font_setup(void)
   0x25bc
 };
 
-ucs2_to_nativecharset = iconv_open(nl_langinfo(CODESET), "UCS-2");
+ucs2_to_nativecharset = iconv_open(local_codeset, "UCS-2");
 if (ucs2_to_nativecharset == (iconv_t) -1) {
 fprintf(stderr, "Could not convert font glyphs from UCS-2: '%s'\n",
 strerror(errno));
 exit(1);
 }
 
-nativecharset_to_ucs2 = iconv_open("UCS-2", nl_langinfo(CODESET));
+nativecharset_to_ucs2 = iconv_open("UCS-2", local_codeset);
 if (nativecharset_to_ucs2 == (iconv_t) -1) {
 iconv_close(ucs2_to_nativecharset);
 fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",
@@ -581,7 +581,7 @@ static void font_setup(void)
 exit(1);
 }
 
-font_conv = iconv_open(nl_langinfo(CODESET), font_charset);
+font_conv = iconv_open(local_codeset, font_charset);
 if (font_conv == (iconv_t) -1) {
 iconv_close(ucs2_to_nativecharset);
 iconv_close(nativecharset_to_ucs2);
@@ -602,7 +602,7 @@ static void font_setup(void)
 /* DEL */
 convert_ucs(0x7F, 0x2302, ucs2_to_nativecharset);
 
-if (strcmp(nl_langinfo(CODESET), "UTF-8")) {
+if (strcmp(local_codeset, "UTF-8")) {
 /* Non-Unicode capable, use termcap equivalents for those available */
 for (i = 0; i <= 0xFF; i++) {
 wchar_t wch[CCHARW_MAX];
-- 
2.28.0.windows.1




[PATCH 0/4] Acceptance Tests: update assets location and cancel tests if missing

2020-09-06 Thread Cleber Rosa
This updates a couple of asset locations, because their locations on
their origin distributions are not permanently stable.

To minimize the inconvenciente caused by test and job failures in the
future, an option is enabled that will cancel (AKA skip) tests early
when those assets are not available.

Cleber Rosa (3):
  Acceptance tests: use an available kernel image package for arm
  boot linux test: update arm bionic URL
  Acceptance tests: cancel tests on missing assets

Pavel Dovgaluk (1):
  tests: bump avocado version

 tests/Makefile.include   |   2 +-
 tests/acceptance/boot_linux_console.py   | 164 +++
 tests/acceptance/linux_initrd.py |   6 +-
 tests/acceptance/linux_ssh_mips_malta.py |   6 +-
 tests/acceptance/machine_arm_canona1100.py   |   3 +-
 tests/acceptance/machine_arm_integratorcp.py |   9 +-
 tests/acceptance/machine_arm_n8x0.py |   3 +-
 tests/acceptance/machine_avr6.py |   3 +-
 tests/acceptance/machine_m68k_nextcube.py|   3 +-
 tests/acceptance/machine_mips_malta.py   |   6 +-
 tests/acceptance/machine_rx_gdbsim.py|   9 +-
 tests/acceptance/machine_sparc64_sun4u.py|   3 +-
 tests/acceptance/machine_sparc_leon3.py  |   3 +-
 tests/acceptance/ppc_prep_40p.py |   8 +-
 tests/acceptance/replay_kernel.py|  51 --
 tests/requirements.txt   |   2 +-
 16 files changed, 171 insertions(+), 110 deletions(-)

-- 
2.25.4





Re: [PATCH v5 09/11] meson: Fixes qapi tests.

2020-09-06 Thread Yonggang Luo
On Sat, Sep 5, 2020 at 4:42 PM Thomas Huth  wrote:

> On 05/09/2020 08.23, Yonggang Luo wrote:
> > The error are:
> > +@end table
> > +
> > +@end deftypefn
> > +
> > make: *** [Makefile.mtest:63: check-qapi-schema] Error 1
> >
> > Signed-off-by: Yonggang Luo 
> > ---
> >  tests/qapi-schema/meson.build | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/tests/qapi-schema/meson.build
> b/tests/qapi-schema/meson.build
> > index c87d141417..67ba0a5ebd 100644
> > --- a/tests/qapi-schema/meson.build
> > +++ b/tests/qapi-schema/meson.build
> > @@ -220,6 +220,7 @@ qapi_doc = custom_target('QAPI doc',
> >
> >  # "full_path()" needed here to work around
> >  # https://github.com/mesonbuild/meson/issues/7585
> > -test('QAPI doc', diff, args: ['-u', files('doc-good.texi'),
> qapi_doc[0].full_path()],
> > +test('QAPI doc', diff, args: ['--strip-trailing-cr',
> > +  '-u', files('doc-good.texi'),
> qapi_doc[0].full_path()],
>
> I just had a look at the POSIX man page of "diff", and it seems like
> "'--strip-trailing-cr" is not a portable option :-( Thus this will
> likely fail on the BSDs and Solaris-based systems.
> I think it's maybe best if you replace it with "-b" instead.

updated

>
>  Thomas
>
>

-- 
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


[PATCH 1/4] Acceptance tests: use an available kernel image package for arm

2020-09-06 Thread Cleber Rosa
Which means a newer kernel version.  Expected output was changed
to match the new kernel too.

Signed-off-by: Cleber Rosa 
---
 tests/acceptance/boot_linux_console.py | 44 +-
 tests/acceptance/replay_kernel.py  |  8 ++---
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index aaa781a581..751b47b8fd 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -490,12 +490,12 @@ class BootLinuxConsole(LinuxKernelTest):
 :avocado: tags=arch:arm
 :avocado: tags=machine:cubieboard
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.8.0-sunxi/'
+   'linux-image-dev-sunxi_20.08_armhf.deb')
+deb_hash = 'ae553a9f7d43b18abfa8f3e64bf2d31878b9be89'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
+'/boot/vmlinuz-5.8.0-sunxi')
 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
@@ -522,7 +522,7 @@ class BootLinuxConsole(LinuxKernelTest):
 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
 'Allwinner sun4i/sun5i')
 exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
-'system-control@1c0')
+'1c0.system-control')
 # cubieboard's reboot is not functioning; omit reboot test.
 
 def test_arm_cubieboard_sata(self):
@@ -530,12 +530,12 @@ class BootLinuxConsole(LinuxKernelTest):
 :avocado: tags=arch:arm
 :avocado: tags=machine:cubieboard
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.8.0-sunxi/'
+   'linux-image-dev-sunxi_20.08_armhf.deb')
+deb_hash = 'ae553a9f7d43b18abfa8f3e64bf2d31878b9be89'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
+'/boot/vmlinuz-5.8.0-sunxi')
 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
@@ -573,12 +573,12 @@ class BootLinuxConsole(LinuxKernelTest):
 :avocado: tags=arch:arm
 :avocado: tags=machine:orangepi-pc
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.8.0-sunxi/'
+   'linux-image-dev-sunxi_20.08_armhf.deb')
+deb_hash = 'ae553a9f7d43b18abfa8f3e64bf2d31878b9be89'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
+'/boot/vmlinuz-5.8.0-sunxi')
 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 
@@ -598,12 +598,12 @@ class BootLinuxConsole(LinuxKernelTest):
 :avocado: tags=arch:arm
 :avocado: tags=machine:orangepi-pc
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.8.0-sunxi/'
+   'linux-image-dev-sunxi_20.08_armhf.deb')
+deb_hash = 'ae553a9f7d43b18abfa8f3e64bf2d31878b9be89'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
+'/boot/vmlinuz-5.8.0-sunxi')
 dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-p

Re: [PATCH] configure: Fixes ncursesw detection under msys2/mingw and enable curses

2020-09-06 Thread Yonggang Luo
On Sun, Sep 6, 2020 at 11:28 AM Richard Henderson <
richard.hender...@linaro.org> wrote:

> On 9/5/20 1:42 PM, Yonggang Luo wrote:
> > +nativecharset_to_ucs2 = iconv_open("UCS-2", g_get_codeset());
>
> g_get_codeset():
> "a newly allocated string containing the name of the character set. This
> string
> must be freed with g_free()."
>
> You need to plug the memory leak.
>
> It's probably worth fixing the mistake in which we call this function four
> times from the same function.
>
Done with autofree

>
>
> r~
>


-- 
 此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo


[PATCH 2/4] boot linux test: update arm bionic URL

2020-09-06 Thread Cleber Rosa
Which uses an xz compressed file, which has builtin support for
decompression on avocado.utils.archive.  So the check for P7ZIP can be
dropped, and extraction logic simplified.

Signed-off-by: Cleber Rosa 
---
 tests/acceptance/boot_linux_console.py | 20 ++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 751b47b8fd..c75c512c8b 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -22,12 +22,6 @@ from avocado.utils import process
 from avocado.utils import archive
 from avocado.utils.path import find_command, CmdNotFoundError
 
-P7ZIP_AVAILABLE = True
-try:
-find_command('7z')
-except CmdNotFoundError:
-P7ZIP_AVAILABLE = False
-
 """
 Round up to next power of 2
 """
@@ -687,7 +681,6 @@ class BootLinuxConsole(LinuxKernelTest):
 self.vm.wait()
 
 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
-@skipUnless(P7ZIP_AVAILABLE, '7z not installed')
 def test_arm_orangepi_bionic(self):
 """
 :avocado: tags=arch:arm
@@ -695,14 +688,13 @@ class BootLinuxConsole(LinuxKernelTest):
 :avocado: tags=device:sd
 """
 
-# This test download a 196MB compressed image and expand it to 1GB
+# This test download a 275MB compressed image and expand it to 1.1GB
 image_url = ('https://dl.armbian.com/orangepipc/archive/'
- 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
-image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e'
-image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash)
-image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
-image_path = os.path.join(self.workdir, image_name)
-process.run("7z e -o%s %s" % (self.workdir, image_path_7z))
+ 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
+image_hash = 
'b4d6775f5673486329e45a0586bf06b6dbe792199fd182ac6b9c7bb6c7d3e6dd'
+image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
+ algorithm='sha256')
+image_path = archive.extract(image_path_xz, self.workdir)
 image_pow2ceil_expand(image_path)
 
 self.vm.set_console()
-- 
2.25.4




[PATCH 3/4] tests: bump avocado version

2020-09-06 Thread Cleber Rosa
From: Pavel Dovgalyuk 

Reverse debugging test uses gdb remote client of avocado framework.
This client was fixed since the currently used version 76.
Therefore this patch bumps the version to 81 and fixes command
line version compatibility issue.

Signed-off-by: Pavel Dovgalyuk 
Message-Id: <159903462803.28509.16851113546106095750.stgit@pasha-ThinkPad-X280>
Reviewed-by: Willian Rampazzo 
Reviewed-by: Cleber Rosa 
Tested-by: Cleber Rosa 
---
 tests/Makefile.include | 2 +-
 tests/requirements.txt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 9ac8f5b86a..0687c8bcda 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -517,7 +517,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) 
get-vm-images
 --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
 --filter-by-tags-include-empty --filter-by-tags-include-empty-key \
 $(AVOCADO_TAGS) \
-$(if $(GITLAB_CI),,--failfast=on) tests/acceptance, \
+$(if $(GITLAB_CI),,--failfast) tests/acceptance, \
 "AVOCADO", "tests/acceptance")
 
 # Consolidated targets
diff --git a/tests/requirements.txt b/tests/requirements.txt
index f9c84b4ba1..036691c922 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,5 +1,5 @@
 # Add Python module requirements, one per line, to be installed
 # in the tests/venv Python virtual environment. For more info,
 # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
-avocado-framework==76.0
+avocado-framework==81.0
 pycdlib==1.9.0
-- 
2.25.4




[PATCH 4/4] Acceptance tests: cancel tests on missing assets

2020-09-06 Thread Cleber Rosa
Asset files used on the acceptance tests (kernel, initrd images)
unfortunately are not guaranteed to always be available at the same
location.

Let's cancel (kind of like a skip) the test, when the asset is
missing.  This should prevent false positives, when failure are not
caused by changes in QEMU itself.

Reference: 
https://avocado-framework.readthedocs.io/en/81.0/api/test/avocado.html#avocado.Test.fetch_asset
Signed-off-by: Cleber Rosa 
---
 tests/acceptance/boot_linux_console.py   | 102 ---
 tests/acceptance/linux_initrd.py |   6 +-
 tests/acceptance/linux_ssh_mips_malta.py |   6 +-
 tests/acceptance/machine_arm_canona1100.py   |   3 +-
 tests/acceptance/machine_arm_integratorcp.py |   9 +-
 tests/acceptance/machine_arm_n8x0.py |   3 +-
 tests/acceptance/machine_avr6.py |   3 +-
 tests/acceptance/machine_m68k_nextcube.py|   3 +-
 tests/acceptance/machine_mips_malta.py   |   6 +-
 tests/acceptance/machine_rx_gdbsim.py|   9 +-
 tests/acceptance/machine_sparc64_sun4u.py|   3 +-
 tests/acceptance/machine_sparc_leon3.py  |   3 +-
 tests/acceptance/ppc_prep_40p.py |   8 +-
 tests/acceptance/replay_kernel.py|  43 +---
 14 files changed, 138 insertions(+), 69 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index c75c512c8b..c3c6ccac7c 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -99,7 +99,8 @@ class BootLinuxConsole(LinuxKernelTest):
   '/linux/releases/29/Everything/x86_64/os/images/pxeboot'
   '/vmlinuz')
 kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
-kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash,
+   cancel_on_missing=True)
 
 self.vm.set_console()
 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
@@ -119,7 +120,8 @@ class BootLinuxConsole(LinuxKernelTest):
'20130217T032700Z/pool/main/l/linux-2.6/'
'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
 deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
-deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash,
+cancel_on_missing=True)
 kernel_path = self.extract_from_deb(deb_path,
 '/boot/vmlinux-2.6.32-5-4kc-malta')
 
@@ -151,7 +153,8 @@ class BootLinuxConsole(LinuxKernelTest):
'20130217T032700Z/pool/main/l/linux-2.6/'
'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
 deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
-deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash,
+cancel_on_missing=True)
 kernel_path = self.extract_from_deb(deb_path,
 '/boot/vmlinux-2.6.32-5-5kc-malta')
 
@@ -173,14 +176,16 @@ class BootLinuxConsole(LinuxKernelTest):
'20160601T041800Z/pool/main/l/linux/'
'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb')
 deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8'
-deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash,
+cancel_on_missing=True)
 kernel_path = self.extract_from_deb(deb_path,
 '/boot/vmlinux-4.5.0-2-4kc-malta')
 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
   '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
   'mips/rootfs.cpio.gz')
 initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99'
-initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
+initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash,
+  cancel_on_missing=True)
 initrd_path = self.workdir + "rootfs.cpio"
 archive.gzip_uncompress(initrd_path_gz, initrd_path)
 
@@ -215,13 +220,15 @@ class BootLinuxConsole(LinuxKernelTest):
   'raw/9ad2df38/mips/malta/mips64el/'
   'vmlinux-3.19.3.mtoman.20150408')
 kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754'
-kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash,
+   cancel_on_missing=True)
 initrd_url = ('https://github.com/groeck/linux-build-test/'
   

Re: [PATCH] meson: Fixes qapi tests.

2020-09-06 Thread Thomas Huth
On 05/09/2020 23.26, Yonggang Luo wrote:
> Use -b to ignore-space-change
>
> The error are:
> +@end table
> +
> +@end deftypefn

I'd maybe just say "Use -b to ignore CR vs. CR-LF issues on Windows" and
omit the incomplete example (the diff in the test run that you linked in
an older mail showed that the diff was about the whole file due to the
different line endings).

> make: *** [Makefile.mtest:63: check-qapi-schema] Error 1
> 
> Signed-off-by: Yonggang Luo 
> ---
>  tests/qapi-schema/meson.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
> index c87d141417..f1449298b0 100644
> --- a/tests/qapi-schema/meson.build
> +++ b/tests/qapi-schema/meson.build
> @@ -220,6 +220,6 @@ qapi_doc = custom_target('QAPI doc',
>  
>  # "full_path()" needed here to work around
>  # https://github.com/mesonbuild/meson/issues/7585
> -test('QAPI doc', diff, args: ['-u', files('doc-good.texi'), 
> qapi_doc[0].full_path()],
> +test('QAPI doc', diff, args: ['-b', '-u', files('doc-good.texi'), 
> qapi_doc[0].full_path()],
>   depends: qapi_doc,
>   suite: ['qapi-schema', 'qapi-doc'])
> 

Reviewed-by: Thomas Huth 




Re: [PATCH 03/13] dma: Document address_space_map/address_space_unmap() prototypes

2020-09-06 Thread Edgar E. Iglesias
On Fri, Sep 04, 2020 at 05:44:29PM +0200, Philippe Mathieu-Daudé wrote:
> Add documentation based on address_space_map / address_space_unmap.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  include/sysemu/dma.h | 30 +-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
> index 80c5bc3e02d..19bc9ad1b69 100644
> --- a/include/sysemu/dma.h
> +++ b/include/sysemu/dma.h
> @@ -1,7 +1,7 @@
>  /*
>   * DMA helper functions
>   *
> - * Copyright (c) 2009 Red Hat
> + * Copyright (c) 2009, 2020 Red Hat
>   *
>   * This work is licensed under the terms of the GNU General Public License
>   * (GNU GPL), version 2 or later.
> @@ -125,6 +125,20 @@ static inline int dma_memory_write(AddressSpace *as, 
> dma_addr_t addr,
>  
>  int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t 
> len);
>  
> +/**
> + * address_space_map: Map a physical memory region into a DMA controller
> + *virtual address

It may be easier to understand this if you change DMA controller virtual address
to host virtual address.

Either way:
Reviewed-by: Edgar E. Iglesias 



> + *
> + * May map a subset of the requested range, given by and returned in @plen.
> + * May return %NULL and set *@plen to zero(0), if resources needed to perform
> + * the mapping are exhausted.
> + * Use only for reads OR writes - not for read-modify-write operations.
> + *
> + * @as: #AddressSpace to be accessed
> + * @addr: address within that address space
> + * @len: pointer to length of buffer; updated on return
> + * @dir: indicates the transfer direction
> + */
>  static inline void *dma_memory_map(AddressSpace *as,
> dma_addr_t addr, dma_addr_t *len,
> DMADirection dir)
> @@ -138,6 +152,20 @@ static inline void *dma_memory_map(AddressSpace *as,
>  return p;
>  }
>  
> +/**
> + * address_space_unmap: Unmaps a memory region previously mapped
> + *  by dma_memory_map()
> + *
> + * Will also mark the memory as dirty if @dir == %DMA_DIRECTION_FROM_DEVICE.
> + * @access_len gives the amount of memory that was actually read or written
> + * by the caller.
> + *
> + * @as: #AddressSpace used
> + * @buffer: host pointer as returned by address_space_map()
> + * @len: buffer length as returned by address_space_map()
> + * @dir: indicates the transfer direction
> + * @access_len: amount of data actually transferred
> + */
>  static inline void dma_memory_unmap(AddressSpace *as,
>  void *buffer, dma_addr_t len,
>  DMADirection dir, dma_addr_t access_len)
> -- 
> 2.26.2
> 



Re: [PATCH 00/13] dma: Let the DMA API take MemTxAttrs argument and propagate MemTxResult

2020-09-06 Thread Edgar E. Iglesias
On Fri, Sep 04, 2020 at 05:44:26PM +0200, Philippe Mathieu-Daudé wrote:
> Salvaging cleanups patches from the RFC series "Forbid DMA write
> accesses to MMIO regions" [*], propagating MemTxResult and
> adding documentation.
> 
> [*] https://www.mail-archive.com/qemu-block@nongnu.org/msg72924.html

On the whole series:
Reviewed-by: Edgar E. Iglesias 



> 
> Klaus Jensen (1):
>   pci: pass along the return value of dma_memory_rw
> 
> Philippe Mathieu-Daudé (12):
>   docs/devel/loads-stores: Add regexp for DMA functions
>   dma: Document address_space_map/address_space_unmap() prototypes
>   dma: Let dma_memory_set() propagate MemTxResult
>   dma: Let dma_memory_rw() propagate MemTxResult
>   dma: Let dma_memory_read() propagate MemTxResult
>   dma: Let dma_memory_write() propagate MemTxResult
>   dma: Let dma_memory_valid() take MemTxAttrs argument
>   dma: Let dma_memory_set() take MemTxAttrs argument
>   dma: Let dma_memory_rw_relaxed() take MemTxAttrs argument
>   dma: Let dma_memory_rw() take MemTxAttrs argument
>   dma: Let dma_memory_read/write() take MemTxAttrs argument
>   dma: Let dma_memory_map() take MemTxAttrs argument
> 
>  docs/devel/loads-stores.rst   |   2 +
>  include/hw/pci/pci.h  |   7 +-
>  include/hw/ppc/spapr_vio.h|  11 ++-
>  include/sysemu/dma.h  | 156 +++---
>  dma-helpers.c |  16 ++--
>  hw/arm/musicpal.c |  13 +--
>  hw/arm/smmu-common.c  |   3 +-
>  hw/arm/smmuv3.c   |  14 +--
>  hw/core/generic-loader.c  |   3 +-
>  hw/display/virtio-gpu.c   |   8 +-
>  hw/dma/pl330.c|  12 ++-
>  hw/dma/sparc32_dma.c  |  16 ++--
>  hw/dma/xlnx-zynq-devcfg.c |   6 +-
>  hw/dma/xlnx_dpdma.c   |  10 ++-
>  hw/hyperv/vmbus.c |   8 +-
>  hw/i386/amd_iommu.c   |  16 ++--
>  hw/i386/intel_iommu.c |  28 +++---
>  hw/ide/ahci.c |   9 +-
>  hw/ide/macio.c|   2 +-
>  hw/intc/spapr_xive.c  |   3 +-
>  hw/intc/xive.c|   7 +-
>  hw/misc/bcm2835_property.c|   3 +-
>  hw/misc/macio/mac_dbdma.c |  10 ++-
>  hw/net/allwinner-sun8i-emac.c |  21 +++--
>  hw/net/ftgmac100.c|  25 --
>  hw/net/imx_fec.c  |  32 ---
>  hw/nvram/fw_cfg.c |  12 ++-
>  hw/pci-host/pnv_phb3.c|   5 +-
>  hw/pci-host/pnv_phb3_msi.c|   9 +-
>  hw/pci-host/pnv_phb4.c|   7 +-
>  hw/sd/allwinner-sdhost.c  |  14 +--
>  hw/sd/sdhci.c |  35 +---
>  hw/usb/hcd-dwc2.c |   8 +-
>  hw/usb/hcd-ehci.c |   6 +-
>  hw/usb/hcd-ohci.c |  28 +++---
>  hw/usb/libhw.c|   3 +-
>  hw/virtio/virtio.c|   6 +-
>  37 files changed, 385 insertions(+), 189 deletions(-)
> 
> -- 
> 2.26.2
>