Re: [Qemu-devel] SeaBIOS regression

2019-02-04 Thread Gerd Hoffmann
On Mon, Feb 04, 2019 at 04:10:37PM +0100, Thomas Huth wrote:
> 
>  Hi Gerd,
> 
> I noticed that certain FreeDOS images are not working correctly anymore
> with the current version of QEMU, for example
> http://www.qemu-advent-calendar.org/2016/download/day10.tar.xz ... It
> aborts with:
> 
>  Error reading from drive C: DOS area: write-protection violation attempted
> 
> I've bisected the issue, and it has apparently been introduced with:
> 
>  cd1bfd5ef336166b275a09dc9842542bf5e63ae3
>  seabios: update bios and vgabios binaries
> 
> Any idea what might be going wrong here?

Hmm, no.  bisect seabios?

cheers,
  Gerd




Re: [Qemu-devel] security implications of caching with virtio pmem (was Re: [PATCH v3 0/5] kvm "virtio pmem" device)

2019-02-04 Thread Pankaj Gupta


+CC [Dave Chinner], to maintain updated CC list  

> >  This patch series has implementation for "virtio pmem".
> >  "virtio pmem" is fake persistent memory(nvdimm) in guest
> >  which allows to bypass the guest page cache. This also
> >  implements a VIRTIO based asynchronous flush mechanism.
> 
> 
> At Pankaj's request I looked at information leak implications of virtio
> pmem in light of the recent page cache side channels paper
> (https://arxiv.org/pdf/1901.01161.pdf) - to see what
> kind of side channels it might create if any.  TLDR - I think that
> depending on the host side implementation there could be some, but this
> might be addressable by better documentation in both code and spec.
> The fake dax approach backing the guest memory by a host page cache
> does seem to have potential issues.
> 
> For clarity: we are talking about leaking information either to a VM, or
> within a VM (I did not look into leaks to hypervisor in configurations
> such as SEV) through host page cache.
> 
> Leaks into a VM: It seems clear that while pmem allows memory accesses
> versus read/write with e.g. a block device, from host page cache point
> of view this doesn't matter much: reads populate cache in the same way
> as memory faults.  Thus ignoring presence of information leaks (which is
> an interesting question e.g. in light of recent discard support) pmem
> doesn't seem to be any better or worse for leaking information into a
> VM.
> 
> Leaks within VM: Right now pmem seems to bypass the guest page cache
> completely.  Whether pmem memory is then resident in a page cache would
> be up to the device/host. Assuming that it is, the "Preventing
> Efficient Eviction while Increasing the System Performance"
> countermeasure for the page cache side channel attack would appear to
> become ineffective with pmem. What is suggested is a per-process
> management of the page cache, and host does not have visibility of
> processes within a VM. Another possible countermeasure - not discussed
> in the paper - could be modify the applications to lock the security
> relevant pages in memory.  Again this becomes impractical with pmem as
> host does not have visibility into that. However note that as long
> as the only countermeasure linux uses is "Privileged Access"
> (i.e. blocking mincore) nothing can be done as guest page cache
> remains as vulnerable as host page cache.
> 
> 
> Countermeasures: which host-side countermeasures can be designed would
> depend on which countermeasures are used guest-side - we would need to
> make sure they are not broken by pmem.  For "Preventing Efficient
> Eviction while Increasing the System Performance" modifying the host
> implementation to ensure that pmem device bypasses the host page cache
> would seem to address the security problem.Similarly, ensuring that a
> real memory device (e.g. DAX, RAM such as hugetlbfs, pmem for nested
> virt) is used for pmem would make the memory locking countermeasure
> work.  Whether with such limitations the device is still useful
> performance wise is an open question.  These questions probably should
> be addressed in the documentation, spec and possible qemu code.
> 
> 
> 
> Severity of the security implications: some people argue that the
> security implications of the page cache leaks are minor.  I do not have
> an opinion on this: the severity would seem to depend on the specific
> configuration.
> 
> 
> Other security implications: recent discussion seems to suggest there
> are other concerns around e.g. resource management and thus DOS
> potential. If that's so, it's a matter for a separate discussion
> as I didn't look into that in depth.
> 
> Some or all of the above might be based on a misunderstanding of the
> current pmem code, the whitepaper and linux page cache in general.
> If so I apologise, do not hesitate to call out any mistakes.
> 
> Thanks!
> 
> --
> MST
> 
> 



[Qemu-devel] [Bug 1545024] Re: compiling on armv7 crashes compile qlx.o

2019-02-04 Thread Thomas Huth
Looking through old bug tickets... can you still reproduce this issue
with the latest version of QEMU? Or could we close this ticket nowadays?

** Changed in: qemu
   Status: New => Incomplete

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

Title:
  compiling on armv7 crashes compile qlx.o

Status in QEMU:
  Incomplete

Bug description:
  If i try to compile qemu on armv7 cpu i get this error:

LINK  qemu-nbd
CCqemu-img.o
LINK  qemu-img
LINK  qemu-io
LINK  qemu-bridge-helper
CCqmp-marshal.o
CChw/display/qxl.o
  {standard input}: Assembler messages:
  {standard input}:1704: Error: bad instruction `lock'
  {standard input}:1704: Error: bad instruction `addl $0,0(%rsp)'
  {standard input}:1864: Error: bad instruction `lock'
  {standard input}:1864: Error: bad instruction `addl $0,0(%rsp)'
  {standard input}:5239: Error: bad instruction `lock'
  {standard input}:5239: Error: bad instruction `addl $0,0(%rsp)'
  {standard input}:5731: Error: bad instruction `lock'
  {standard input}:5731: Error: bad instruction `addl $0,0(%rsp)'
  {standard input}:11923: Error: bad instruction `lock'
  {standard input}:11923: Error: bad instruction `addl $0,0(%rsp)'
  {standard input}:13960: Error: bad instruction `lock'
  {standard input}:13960: Error: bad instruction `addl $0,0(%rsp)'
  {standard input}:14349: Error: bad instruction `lock'
  {standard input}:14349: Error: bad instruction `addl $0,0(%rsp)'
  /home/fleixi/git/qemu/rules.mak:57: recipe for target 'hw/display/qxl.o' 
failed
  make: *** [hw/display/qxl.o] Error 1

  Build options are:

   ./configure --target-list=i386-softmmu
  Install prefix/usr/local
  BIOS directory/usr/local/share/qemu
  binary directory  /usr/local/bin
  library directory /usr/local/lib
  module directory  /usr/local/lib/qemu
  libexec directory /usr/local/libexec
  include directory /usr/local/include
  config directory  /usr/local/etc
  local state directory   /usr/local/var
  Manual directory  /usr/local/share/man
  ELF interp prefix /usr/gnemul/qemu-%M
  Source path   /home/fleixi/git/qemu
  C compilercc
  Host C compiler   cc
  C++ compiler  c++
  Objective-C compiler cc
  ARFLAGS   rv
  CFLAGS-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -pthread 
-I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include  -g 
-mcpu=cortex-a15.cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4 -O2 -pipe 
-ffast-math -ftree-vectorize -mvectorize-with-neon-quad -fstack-protector 
--param=ssp-buffer-size=4
  QEMU_CFLAGS   -I/usr/include/pixman-1   -Werror  -D_GNU_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -fno-common  -Wendif-labels -Wmissing-include-dirs 
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self 
-Wignored-qualifiers -Wold-style-declaration -Wold-style-definition 
-Wtype-limits -fstack-protector-strong   -I/usr/include/libpng12  
-I/usr/local/include/spice-server -I/usr/local/include 
-I/usr/local/include/spice-1 -I/usr/include/glib-2.0 
-I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/pixman-1 
  LDFLAGS   -Wl,--warn-common -g 
  make  make
  install   install
  pythonpython -B
  smbd  /usr/sbin/smbd
  module supportno
  host CPU  arm
  host big endian   no
  target list   i386-softmmu
  tcg debug enabled no
  gprof enabled no
  sparse enabledno
  strip binariesyes
  profiler  no
  static build  no
  pixmansystem
  SDL support   no
  GTK support   yes
  GTK GL supportno
  GNUTLS supportno
  GNUTLS hash   no
  libgcrypt no
  nettleno
  libtasn1  no
  VTE support   no
  curses supportno
  virgl support no
  curl support  yes
  mingw32 support   no
  Audio drivers oss
  Block whitelist (rw) 
  Block whitelist (ro) 
  VirtFS supportno
  VNC support   yes
  VNC SASL support  yes
  VNC JPEG support  yes
  VNC PNG support   yes
  xen support   no
  brlapi supportno
  bluez  supportyes
  Documentation no
  PIE   no
  vde support   no
  netmap supportno
  Linux AIO support no
  ATTR/XATTR support yes
  Install blobs yes
  KVM support   yes
  RDMA support  no
  TCG interpreter   no
  fdt support   no
  preadv supportyes
  fdatasync yes
  madvise   yes
  posix_madvise yes
  sigev_thread_id   yes
  uuid support  no
  libcap-ng support no
  vhost-net support yes
  vhost-scsi support yes
  Trace backendslog
  spice support yes (0.12.10/0.12.6)
  rbd support   no
  xfsctl supportno
  smartcard support no
  libusbno
  usb net redir no
  OpenGL supportno
  libiscsi 

[Qemu-devel] [Bug 1546680] Re: Incorrect display colors when running big endian guest on POWER8 little endian host

2019-02-04 Thread Thomas Huth
IIRC there were some endianess fixes for this in the past ... can you
still reproduce this issue with the latest version of QEMU and a recent
kernel? Or could we close this ticket nowadays?

** Changed in: qemu
   Status: New => Incomplete

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

Title:
  Incorrect display colors when running big endian guest on POWER8
  little endian host

Status in QEMU:
  Incomplete

Bug description:
  When running a big endian CentOS guest on a little endian host system
  the display shows severe color issues, probably due to endianness not
  being properly detected / switched in the emulated display hardware.
  Little endian guests show no display issues on the same host hardware
  and software.

  See attachment for an example of the problem.

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



[Qemu-devel] [Bug 1547012] Re: qemu instances crashes with certain spice clients

2019-02-04 Thread Thomas Huth
Looking through old bug tickets... can you still reproduce this issue
with the latest version of QEMU? Or could we close this ticket nowadays?

** Changed in: qemu
   Status: New => Incomplete

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

Title:
  qemu instances crashes with certain spice clients

Status in QEMU:
  Incomplete

Bug description:
  It's possible to make qemu instances crash when using certain browsers
  connected as spice-clients.

  my environment:

  - OpenStack Kilo installed from ubuntu-cloud archive (qemu-system-x86 
2.2+dfsg-5expubuntu9.6~cloud0)
  - Using spice for web-console access

  How to reproduce:

  1. Start a VM on openstack
  2. access the OpenStack dashboard using iceweasel 43.0.4 
  3. Open the spice-console
  4. Leave the console open for few minutes
  5. The VM will crash on the hypervisor

  The content of qemu log-files for this particular VM:

  2016-02-18 07:25:23.655+: starting up
  LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin 
QEMU_AUDIO_DRV=spice /usr/bin/qemu-system-x86_64 -name instance-188f -S 
-machine pc-i440fx-utopic,accel=kvm,usb=off -cpu 
SandyBridge,+erms,+smep,+fsgsbase,+pdpe1gb,+rdrand,+f16c,+osxsave,+dca,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme
 -m 4096 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 
cb04ff25-056f-4f82-a2e8-1fbb762bc29e -smbios type=1,manufacturer=OpenStack 
Foundation,product=OpenStack 
Nova,version=2015.1.2,serial=----0cc47a45f5e8,uuid=cb04ff25-056f-4f82-a2e8-1fbb762bc29e
 -no-user-config -nodefaults -chardev 
socket,id=charmonitor,path=/var/lib/libvirt/qemu/instance-188f.monitor,server,nowait
 -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew 
-global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -boot strict=on 
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device 
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive 
file=rbd:libvirt/cb04ff25-056f-4f82-a2e8-1fbb762bc29e_disk:id=cinder:key=AQBYmdBUCDq7IBAA/7tLevRjdF3Bo7522xkFqA==:auth_supported=cephx\;none:mon_host=xxx.xxx.xxx.xxx\:6789\;xxx.xxx.xxx.xxx\:6789\;xxx.xxx.xxx.xxx\:6789\;xxx.xxx.xxx.xxx\:6789\;xxx.xxx.xxx.xxx\:6789,if=none,id=drive-virtio-disk0,format=raw,cache=writeback
 -device 
virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
 -netdev tap,fd=55,id=hostnet0,vhost=on,vhostfd=58 -device 
virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:a4:74:3b,bus=pci.0,addr=0x3 
-chardev 
file,id=charserial0,path=/var/lib/nova/instances/cb04ff25-056f-4f82-a2e8-1fbb762bc29e/console.log
 -device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charserial1 
-device isa-serial,chardev=charserial1,id=serial1 -chardev pty,id=charchannel0 
-device 
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0
 -spice port=5929,addr=172.24.1.30,disable-ticketing,seamless-migration=on -k 
fr-ch -device 
qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x2
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -msg timestamp=on
  char device redirected to /dev/pts/64 (label charserial1)
  char device redirected to /dev/pts/65 (label charchannel0)
  main_channel_link: add main channel client
  main_channel_handle_parsed: net test: latency 44.136000 ms, bitrate 
157538461538 bps (150240.384615 Mbps)
  inputs_connect: inputs channel client create
  red_dispatcher_set_cursor_peer:
  ((null):18188): SpiceWorker-CRITICAL **: 
red_worker.c:1629:common_alloc_recv_buf: unexpected message size 214862 (max is 
1024)
  2016-02-18 07:30:47.008+: shutting down

  It's funny because this error only occurs with certain browser
  versions, in my case with Iceweasel 43.0.4 and 44. 0 but it works well
  with Chrome 48.0.256482 and Firefox 44.0.2.

  Marking this a potential security issue as it could maybe lead to a
  denial-of-service if a user sends crafted packets.

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



[Qemu-devel] [PATCH] Remove deprecated -no-frame option

2019-02-04 Thread Thomas Huth
The -no-frame option has been deprecated with QEMU v2.12. It was only
useful with SDL1.2 - now that we've removed support for SDL1.2, we
can certainly remove the -no-frame option, too.

Signed-off-by: Thomas Huth 
---
 include/sysemu/sysemu.h |  1 -
 qemu-deprecated.texi|  6 --
 qemu-options.hx | 11 ---
 vl.c| 23 +++
 4 files changed, 3 insertions(+), 38 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 85877b7..4b5a6b7 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -102,7 +102,6 @@ extern const char *keyboard_layout;
 extern int win2k_install_hack;
 extern int alt_grab;
 extern int ctrl_grab;
-extern int no_frame;
 extern int smp_cpus;
 extern unsigned int max_cpus;
 extern int cursor_hide;
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 9cc20b3..0b508e7 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -37,12 +37,6 @@ would automatically enable USB support on the machine type.
 If using the new syntax, USB support must be explicitly
 enabled via the ``-machine usb=on'' argument.
 
-@subsection -no-frame (since 2.12.0)
-
-The @code{--no-frame} argument works with SDL 1.2 only. The other user
-interfaces never implemented this in the first place. So this will be
-removed together with SDL 1.2 support.
-
 @subsection -virtioconsole (since 3.0.0)
 
 Option @option{-virtioconsole} has been replaced by
diff --git a/qemu-options.hx b/qemu-options.hx
index 521511e..0180467 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1294,17 +1294,6 @@ mode using a curses/ncurses interface. Nothing is 
displayed in graphical
 mode.
 ETEXI
 
-DEF("no-frame", 0, QEMU_OPTION_no_frame,
-"-no-frame   open SDL window without a frame and window decorations\n",
-QEMU_ARCH_ALL)
-STEXI
-@item -no-frame
-@findex -no-frame
-Do not use decorations for SDL windows and start them using the whole
-available screen space. This makes the using QEMU in a dedicated desktop
-workspace more convenient.
-ETEXI
-
 DEF("alt-grab", 0, QEMU_OPTION_alt_grab,
 "-alt-grab   use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n",
 QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index 9cf0fbe..33d226f 100644
--- a/vl.c
+++ b/vl.c
@@ -160,7 +160,6 @@ static int rtc_host_datetime_offset = -1; /* valid & used 
only with
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
 static DisplayOptions dpy;
-int no_frame;
 static int num_serial_hds;
 static Chardev **serial_hds;
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
@@ -2113,18 +2112,7 @@ static void parse_display(const char *p)
 while (*opts) {
 const char *nextopt;
 
-if (strstart(opts, ",frame=", )) {
-g_printerr("The frame= sdl option is deprecated, and will be\n"
-   "removed in a future release.\n");
-opts = nextopt;
-if (strstart(opts, "on", )) {
-no_frame = 0;
-} else if (strstart(opts, "off", )) {
-no_frame = 1;
-} else {
-goto invalid_sdl_args;
-}
-} else if (strstart(opts, ",alt_grab=", )) {
+if (strstart(opts, ",alt_grab=", )) {
 opts = nextopt;
 if (strstart(opts, "on", )) {
 alt_grab = 1;
@@ -3596,11 +3584,6 @@ int main(int argc, char **argv, char **envp)
 dpy.has_full_screen = true;
 dpy.full_screen = true;
 break;
-case QEMU_OPTION_no_frame:
-g_printerr("The -no-frame switch is deprecated, and will be\n"
-   "removed in a future release.\n");
-no_frame = 1;
-break;
 case QEMU_OPTION_alt_grab:
 alt_grab = 1;
 break;
@@ -4279,8 +4262,8 @@ int main(int argc, char **argv, char **envp)
 dpy.type = DISPLAY_TYPE_NONE;
 }
 
-if ((no_frame || alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) {
-error_report("-no-frame, -alt-grab and -ctrl-grab are only valid "
+if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) {
+error_report("-alt-grab and -ctrl-grab are only valid "
  "for SDL, ignoring option");
 }
 if (dpy.has_window_close &&
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH 07/10] monitor: Expose pvrdma device statistics counters

2019-02-04 Thread Markus Armbruster
Yuval Shaia  writes:

> On Mon, Feb 04, 2019 at 09:23:49AM +0100, Markus Armbruster wrote:
>> Yuval Shaia  writes:
>> 
>> > On Fri, Feb 01, 2019 at 08:33:44AM +0100, Markus Armbruster wrote:
>> >> Eric Blake  writes:
>> >> 
>> >> > On 1/31/19 2:08 PM, Yuval Shaia wrote:
>> >> >> On Thu, Jan 31, 2019 at 07:17:16AM -0600, Eric Blake wrote:
>> >> >>> On 1/31/19 7:08 AM, Yuval Shaia wrote:
>> >>  Signed-off-by: Yuval Shaia 
>> >>  ---
>> >>   hmp-commands-info.hx | 14 ++
>> >>   monitor.c|  6 ++
>> >>   2 files changed, 20 insertions(+)
>> >> >> 
>> >> >> Hi Eric,
>> >> >> 
>> >> >>>
>> >> >>> Commit message should state WHY this is being added as an HMP-only
>> >> >>> command, and does not have a QMP counterpart.  It may be okay if the
>> >> >>> interface is only designed to be useful to developers, but having that
>> >> >>> justification in the git log is important.
>> >> >> 
>> >> >> Thanks for your review.
>> >> >> 
>> >> >> See, i need this interface mainly for development/debug purposes, to 
>> >> >> help
>> >> >> troubleshot problems and to give insights to what device "is doing".
>> >> >> 
>> >> >> Trace points are great but not effective in high load.
>> >> >> QMP as i see it, and correct me if i'm wrong, is used to report 
>> >> >> management
>> >> >> events etc and also here, is not effective in high load.
>> >> 
>> >> If QMP is not effective, HMP won't be effective, either.  But I guess
>> >> you mean something else, namely QMP *events* aren't effective, but
>> >> *polling* is.
>> >
>> > Yeah.
>> > I really meant to say "QMP is not effective *choice* for my needs".
>> >
>> >> 
>> >> That's an argument for polling, not an argument for not supporting QMP.
>> >> 
>> >> >> I choose this interface as it is interactive, i.e. whenever i need the 
>> >> >> info
>> >> >> i trigger 'info pvrdmastats' command from the monitor console.
>> >> >> 
>> >> >> During my research i notice that some devices (or families) have nice 
>> >> >> user
>> >> >> interface via virsh (blkstat, ifstat, memstat etc). Is it the 
>> >> >> preferred way
>> >> >> for non-devel/debug purposes?
>> >> 
>> >> Libvirt interfaces like these are built on top of *QMP* interfaces.  If
>> >> a libvirt interface would be useful, that's another argument for
>> >> supporting QMP.
>> >
>> > I was asking in a context of what is the standard way to do it.
>> 
>> You were right to ask it.
>> 
>> >> > Using existing HMP-only debug interfaces as the design you copied is
>> >> > indeed acceptable justification for making yours HMP-only as well.  So
>> >> > now you just need to copy the rationale from this email into your commit
>> >> > message, so it doesn't get lost.
>> >> 
>> >> Yes.  If we conclude HMP-only is okay, then the rationale for it goes
>> >> into your commit message.
>> >> 
>> >> If we conclude we want HMP and QMP, I'll be happy to assist you with
>> >> adapting your patch.
>> >
>> > Thanks!
>> > Well, for now i want only to expose debugging-related info and have no idea
>> > yet what would be the best to expose to end-users via QMP events.
>> > Device statistics for end-users are currently exposed by the device driver
>> > in guest. If in the future we will see that this info is also needed in the
>> > host then i'll revisit it.
>> 
>> For me, there are four cases of the "get information from QEMU to the
>> user":
>> 
>> 1. Information that is of use only for developers
>> 
>>a. When tracing works, use tracing
>> 
>>b. When it doesn't, we can consider QMP + HMP command, or HMP command
>>   only.  A QMP command would carry an x- prefix to mark it unstable.
>> 
>> 2. Information that is of use only for human users
>> 
>>Provide an HMP command.
>> 
>> 3. Information a management application such as libvirt wants to
>>provide, but not monitor
>> 
>>The QEMU part is just like for 4a below.  The difference is that the
>>management application doesn't poll automatically.
>> 
>> 4. Information a management application such as libvirt wants to monitor
>> 
>>This is not the case here, but I mention it for completeness.
>> 
>>a. The obvious way to monitor is regular polling via QMP.  Provide a
>>   QMP command to poll.
>> 
>>b. Another way is tracking a QMP event that reports changes, plus
>>   polling on reconnect.  This is generally more efficient.  Provide
>>   a QMP event tracking changes, and a command to poll.  The event
>>   may have to be rate-limited.
>> 
>>If the information is also useful for human users, throw in a command
>>to poll via HMP.
>> 
>> I'm not yet sure tracing doesn't work for your use case.  I replied
>> to your claim it's not effective upthread.  Let's discuss it there.
>
> We conclude there, and correct me if i misunderstood you, that for
> 'polling' it make sense to use HMP only.

Not in general; case 3. exists.  But as long as there's no interest in
plumbing the polling through a management application or 

Re: [Qemu-devel] [PATCH v3 3/3] util/cutils: Move function documentations to the header

2019-02-04 Thread Markus Armbruster
Philippe Mathieu-Daudé  writes:

> Many functions have documentation before the implementation in
> cutils.c. Since we expect documentation around the prototype
> declaration in headers,

We do?

There are two justifiable function comment placement styles: (1) next to
definition, and (2) next to declaration if it's in a header, else next
to definition.

The rationale for the latter is having the headers do double-duty as
interface documentation.

The rationale for the former is consistently placing the function
comments close to the code gives them a fighting chance to actually
match the code.

I'm in the "next to definition" camp.  If you want concise interface
specification, use something like Sphinx.

QEMU code is, as so often, in all camps.

> move the comments in cutils.h.

We document some cutils functions next to their definition, and some
next to their declaration.  The inconsistency is ugly, and your patch
fixes it.  I'd fix it in the other direction.

Even if we decide to fix this one in this direction, I object to the
sweeping generalization in the commit message :)



Re: [Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04

2019-02-04 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190205035704.26014-1-ebl...@redhat.com/



Hi,

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

Subject: [Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04
Message-id: 20190205035704.26014-1-ebl...@redhat.com
Type: series

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]  patchew/20190204204517.23698-1-phi...@redhat.com -> 
patchew/20190204204517.23698-1-phi...@redhat.com
 * [new tag] patchew/20190205035704.26014-1-ebl...@redhat.com -> 
patchew/20190205035704.26014-1-ebl...@redhat.com
Submodule 'capstone' (https://git.qemu.org/git/capstone.git) registered for 
path 'capstone'
Submodule 'dtc' (https://git.qemu.org/git/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (https://git.qemu.org/git/QemuMacDrivers.git) 
registered for path 'roms/QemuMacDrivers'
Submodule 'roms/SLOF' (https://git.qemu.org/git/SLOF.git) registered for path 
'roms/SLOF'
Submodule 'roms/ipxe' (https://git.qemu.org/git/ipxe.git) registered for path 
'roms/ipxe'
Submodule 'roms/openbios' (https://git.qemu.org/git/openbios.git) registered 
for path 'roms/openbios'
Submodule 'roms/openhackware' (https://git.qemu.org/git/openhackware.git) 
registered for path 'roms/openhackware'
Submodule 'roms/qemu-palcode' (https://git.qemu.org/git/qemu-palcode.git) 
registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (https://git.qemu.org/git/seabios.git/) registered for 
path 'roms/seabios'
Submodule 'roms/seabios-hppa' (https://github.com/hdeller/seabios-hppa.git) 
registered for path 'roms/seabios-hppa'
Submodule 'roms/sgabios' (https://git.qemu.org/git/sgabios.git) registered for 
path 'roms/sgabios'
Submodule 'roms/skiboot' (https://git.qemu.org/git/skiboot.git) registered for 
path 'roms/skiboot'
Submodule 'roms/u-boot' (https://git.qemu.org/git/u-boot.git) registered for 
path 'roms/u-boot'
Submodule 'roms/u-boot-sam460ex' (https://git.qemu.org/git/u-boot-sam460ex.git) 
registered for path 'roms/u-boot-sam460ex'
Submodule 'tests/fp/berkeley-softfloat-3' 
(https://github.com/cota/berkeley-softfloat-3) registered for path 
'tests/fp/berkeley-softfloat-3'
Submodule 'tests/fp/berkeley-testfloat-3' 
(https://github.com/cota/berkeley-testfloat-3) registered for path 
'tests/fp/berkeley-testfloat-3'
Submodule 'ui/keycodemapdb' (https://git.qemu.org/git/keycodemapdb.git) 
registered for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out 
'22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '88f18909db731a627456f26d779445f84e449536'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out 
'90c488d5f4a407342247b9ea869df1c2d9c8e266'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 
'a5b428e1c1eae703bdd62a3f527223c291ee3fdc'
Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 
'de4565cbe76ea9f7913a01f331be3ee901bb6e17'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 
'441a84d3a642a10b948369c63f32367e8ff6395b'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 
'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 
'51c237d7e20d05100eacadee2f61abc17e6bc097'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 
'a698c8995ffb2838296ec284fe3c4ad33dfca307'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out 
'1ef99a01572c2581c30e16e6fe69e9ea2ef92ce0'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 
'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out 
'e0ee24c27a172bcf482f6f2bc905e6211c134bcc'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 
'd85ca029f257b53a96da6c2fb421e78a003a9943'
Cloning into 'roms/u-boot-sam460ex'...
Submodule path 'roms/u-boot-sam460ex': checked out 
'60b3916f33e617a815973c5a6df77055b2e3a588'
Cloning into 'tests/fp/berkeley-softfloat-3'...
Submodule path 'tests/fp/berkeley-softfloat-3': checked out 
'b64af41c3276f97f0e181920400ee056b9c88037'
Cloning into 'tests/fp/berkeley-testfloat-3'...
Submodule path 'tests/fp/berkeley-testfloat-3': checked out 
'5a59dcec19327396a011a17fd924aed4fec416b3'
Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'6b3d716e2b6472eb7189d3220552280ef3d832ce'
Switched to a new branch 'test'
9f22048 block/nbd-client: rename read_reply_co to connection_co
e81ab27 block/nbd-client: don't check ioc
ce55b4b block/nbd-client: fix 

Re: [Qemu-devel] [PATCH qemu 1/3] vfio/spapr: Fix indirect levels calculation

2019-02-04 Thread David Gibson
On Thu, Jan 17, 2019 at 01:51:13PM +1100, Alexey Kardashevskiy wrote:
> The current code assumes that we can address more bits on a PCI bus
> for DMA than we really can but there is no way knowing the actual limit.
> 
> This makes a better guess for the number of levels and if the kernel
> fails to allocate that, this increases the level numbers till succeeded
> or reached the 64bit limit.
> 
> This adds levels to the trace point.
> 
> This may cause the kernel to warn about failed allocation:
>[65122.837458] Failed to allocate a TCE memory, level shift=28
> which might happen if MAX_ORDER is not large enough as it can vary:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/Kconfig?h=v5.0-rc2#n727
> 
> Signed-off-by: Alexey Kardashevskiy 
> ---
>  hw/vfio/spapr.c  | 38 +-
>  hw/vfio/trace-events |  2 +-
>  2 files changed, 30 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
> index becf71a..2675bf5 100644
> --- a/hw/vfio/spapr.c
> +++ b/hw/vfio/spapr.c
> @@ -146,7 +146,7 @@ int vfio_spapr_create_window(VFIOContainer *container,
>  int ret;
>  IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
>  uint64_t pagesize = memory_region_iommu_get_min_page_size(iommu_mr);
> -unsigned entries, pages;
> +unsigned entries, bits_total, bits_per_level, max_levels;
>  struct vfio_iommu_spapr_tce_create create = { .argsz = sizeof(create) };
>  long systempagesize = qemu_getrampagesize();

So, "systempagesize" is a bad name, since this is *not* the system
page size, but rather the (minimum) page size we're using to map guest
RAM...

> @@ -176,16 +176,35 @@ int vfio_spapr_create_window(VFIOContainer *container,
>  create.window_size = int128_get64(section->size);
>  create.page_shift = ctz64(pagesize);
>  /*
> - * SPAPR host supports multilevel TCE tables, there is some
> - * heuristic to decide how many levels we want for our table:
> - * 0..64 = 1; 65..4096 = 2; 4097..262144 = 3; 262145.. = 4
> + * SPAPR host supports multilevel TCE tables. We try to guess optimal
> + * levels number and if this fails (for example due to the host memory
> + * fragmentation), we increase levels. The DMA address structure is:
> + *  rxxx       
> 
> + * where:
> + *   r = reserved (bits >= 55 are reserved in the existing hardware)
> + *   i = IOMMU page offset (64K in this example)
> + *   x = bits to index a TCE which can be split to equal chunks to index
> + *  within the level.
> + * The aim is to split "x" to smaller possible number of levels.
>   */
>  entries = create.window_size >> create.page_shift;
> -pages = MAX((entries * sizeof(uint64_t)) / getpagesize(), 1);
> -pages = MAX(pow2ceil(pages), 1); /* Round up */
> -create.levels = ctz64(pages) / 6 + 1;
> -
> -ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, );
> +/* bits_total is number of "x" needed */
> +bits_total = ctz64((entries * sizeof(uint64_t)));
> +/*
> + * bits_per_level is a safe guess of how much we can allocate per level:
> + * 8 is the current minimum for CONFIG_FORCE_MAX_ZONEORDER and MAX_ORDER
> + * is usually bigger than that.
> + */
> +bits_per_level = ctz64(systempagesize) + 8;

..which is relevant, because here you really do want the system page
size, since you're guestimating what the kernel will be able to put on
a page, entirely unrelated to the guest page size.

> +create.levels = bits_total / bits_per_level;

Don't you need a div-rounded-up here?

> +create.levels = MAX(1, create.levels);
> +max_levels = (64 - create.page_shift) / ctz64(systempagesize);

And I think you want the real system page size here again.

> +for ( ; create.levels <= max_levels; ++create.levels) {
> +ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, );
> +if (!ret) {
> +break;
> +}
> +}
>  if (ret) {
>  error_report("Failed to create a window, ret = %d (%m)", ret);
>  return -errno;
> @@ -200,6 +219,7 @@ int vfio_spapr_create_window(VFIOContainer *container,
>  return -EINVAL;
>  }
>  trace_vfio_spapr_create_window(create.page_shift,
> +   create.levels,
> create.window_size,
> create.start_addr);
>  *pgsize = pagesize;
> diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
> index 0f9f810..adfa75e 100644
> --- a/hw/vfio/trace-events
> +++ b/hw/vfio/trace-events
> @@ -129,6 +129,6 @@ vfio_prereg_listener_region_add_skip(uint64_t start, 
> uint64_t end) "0x%"PRIx64"
>  vfio_prereg_listener_region_del_skip(uint64_t start, uint64_t end) 
> "0x%"PRIx64" - 0x%"PRIx64
>  vfio_prereg_register(uint64_t va, uint64_t size, int ret) 

Re: [Qemu-devel] [PATCH] ppc: add host-serial and host-model machine attributes

2019-02-04 Thread David Gibson
On Mon, Feb 04, 2019 at 10:10:05AM +, Daniel P. Berrangé wrote:
> On Mon, Feb 04, 2019 at 12:09:04PM +1100, David Gibson wrote:
> > On Sat, Feb 02, 2019 at 12:23:58AM +0530, P J P wrote:
> > > From: Prasad J Pandit 
> > > 
> > > On ppc hosts, hypervisor shares following system attributes
> > > 
> > >   - /proc/device-tree/system-id
> > >   - /proc/device-tree/model
> > > 
> > > with a guest. This could lead to information leakage and misuse.[*]
> > > Add machine attributes to control such system information exposure
> > > to a guest.
> > > 
> > > [*] https://wiki.openstack.org/wiki/OSSN/OSSN-0028
> > > 
> > > Reported-by: Daniel P. Berrangé 
> > > Fix-suggested-by: Daniel P. Berrangé 
> > > Signed-off-by: Prasad J Pandit 
> > 
> > Hm.  This seems like it might be overkill.  I mean, obviously we need
> > to not leak that host information, but it's not clear we really need
> > these properties at all.  They're not specified in PAPR (contrary to
> > my previous guess) and it's not clear what actually uses them.
> > 
> > I'm wondering if we can just ditch them entirely, or at least make
> > them default to not present without regard to machine version.
> > 
> > Yes, that's technically a compatibility breaking change, but it's hard
> > to see anything that actually relied on these as not being broken
> > already, so I think that's actually a fair trade off for the security
> > improvement here.
> 
> We cannot assume that no one is using it.
> 
> In fact this issue came to light precisely because a person on IRC
> was asking why x86 couldn't provide the same info as PPC, because
> they found it useful on PPC.

"Found it useful" is not the same as actually relying on.

> So we will definitely break people if we remove this from existing
> VMs.

I don't think that follows from the information you've presented so
far.

-- 
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


Re: [Qemu-devel] [PATCH v2 4/6] mips: Express dependencies of the Boston machine with kconfig

2019-02-04 Thread Thomas Huth
On 2019-02-04 21:26, Philippe Mathieu-Daudé wrote:
> Boston is built around a Xilinx FPGA, which includes a PCIe root port
> and an UART. An Intel EG20T PCH connects the I/O peripherals, but only
> the SATA bus is emulated.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/mips64el-softmmu.mak | 4 
>  hw/mips/Kconfig  | 5 +
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/default-configs/mips64el-softmmu.mak 
> b/default-configs/mips64el-softmmu.mak
> index 23445cfcf9..c6f1f9c9aa 100644
> --- a/default-configs/mips64el-softmmu.mak
> +++ b/default-configs/mips64el-softmmu.mak
> @@ -4,8 +4,4 @@ include mips-softmmu-common.mak
>  CONFIG_IDE_VIA=y
>  CONFIG_FULONG=y
>  CONFIG_VT82C686=y
> -CONFIG_AHCI=y
>  CONFIG_MIPS_BOSTON=y
> -CONFIG_FITLOADER=y
> -CONFIG_PCI_EXPRESS=y
> -CONFIG_PCI_EXPRESS_XILINX=y
> diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
> index ee6290d497..2940ff39ab 100644
> --- a/hw/mips/Kconfig
> +++ b/hw/mips/Kconfig
> @@ -49,3 +49,8 @@ config MIPS_CPS
>  
>  config MIPS_BOSTON
>  bool
> +select FITLOADER
> +select MIPS_CPS
> +select PCI_EXPRESS_XILINX
> +select AHCI
> +select SERIAL

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04

2019-02-04 Thread Eric Blake
On 2/4/19 10:08 PM, no-re...@patchew.org wrote:
> Patchew URL: 
> https://patchew.org/QEMU/20190205035704.26014-1-ebl...@redhat.com/
> 
> 
> 
> Hi,
> 
> This series seems to have some coding style problems. See output below for
> more information:
> 

> 2/8 Checking commit bd906b01ffe8 (nbd: generalize usage of nbd_read)
> ERROR: spaces required around that '*' (ctx:WxV)
> #85: FILE: include/block/nbd.h:356:
> + uint##bits##_t *val,   \
>  ^
> 
> total: 1 errors, 0 warnings, 386 lines checked
> 
> Patch 2/8 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.

False positive. Seeing past ## pasting in a macro is not trivial to fix
in checkpatch, so I'm intentionally ignoring this one.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 3/6] mips: Express dependencies of the r4k platform with kconfig

2019-02-04 Thread Thomas Huth
On 2019-02-04 21:26, Philippe Mathieu-Daudé wrote:
> This platform use standard PC devices connected to an ISA bus.
> Networking is provided by a ne2000 chipset.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/mips/Kconfig | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
> index ab006477c7..ee6290d497 100644
> --- a/hw/mips/Kconfig
> +++ b/hw/mips/Kconfig
> @@ -1,5 +1,15 @@
>  config R4K
>  bool
> +select ISA_BUS
> +select SERIAL_ISA
> +select I8259
> +select I8254
> +select MC146818RTC
> +select VGA_ISA
> +select NE2000_ISA
> +select IDE_ISA
> +# I8042
> +select PCKBD

I think you can now also remove "CONFIG_NE2000_ISA=y" from
default-configs/mips-softmmu-common.mak.

 Thomas



Re: [Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04

2019-02-04 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190205035704.26014-1-ebl...@redhat.com/



Hi,

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

Message-id: 20190205035704.26014-1-ebl...@redhat.com
Subject: [Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04
Type: series

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag] patchew/1549336101-17623-1-git-send-email-th...@redhat.com 
-> patchew/1549336101-17623-1-git-send-email-th...@redhat.com
 - [tag update]  patchew/20190204204517.23698-1-phi...@redhat.com -> 
patchew/20190204204517.23698-1-phi...@redhat.com
 * [new tag] patchew/20190205035704.26014-1-ebl...@redhat.com -> 
patchew/20190205035704.26014-1-ebl...@redhat.com
Switched to a new branch 'test'
9f22048 block/nbd-client: rename read_reply_co to connection_co
e81ab27 block/nbd-client: don't check ioc
ce55b4b block/nbd-client: fix nbd_reply_chunk_iter_receive
80c093f block/nbd-client: split connection from initialization
a24543e block/nbd: move connection code from block/nbd to block/nbd-client
467a28d block/nbd-client: split channel errors from export errors
bd906b0 nbd: generalize usage of nbd_read
3d3be1f qemu-nbd: Deprecate qemu-nbd --partition

=== OUTPUT BEGIN ===
1/8 Checking commit 3d3be1f9bcc8 (qemu-nbd: Deprecate qemu-nbd --partition)
2/8 Checking commit bd906b01ffe8 (nbd: generalize usage of nbd_read)
ERROR: spaces required around that '*' (ctx:WxV)
#85: FILE: include/block/nbd.h:356:
+ uint##bits##_t *val,   \
 ^

total: 1 errors, 0 warnings, 386 lines checked

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

3/8 Checking commit 467a28dbf261 (block/nbd-client: split channel errors from 
export errors)
4/8 Checking commit a24543ee7b41 (block/nbd: move connection code from 
block/nbd to block/nbd-client)
5/8 Checking commit 80c093f3b180 (block/nbd-client: split connection from 
initialization)
6/8 Checking commit ce55b4b331f9 (block/nbd-client: fix 
nbd_reply_chunk_iter_receive)
7/8 Checking commit e81ab27f828e (block/nbd-client: don't check ioc)
8/8 Checking commit 9f22048c0a07 (block/nbd-client: rename read_reply_co to 
connection_co)
=== OUTPUT END ===

Test command exited with code: 1


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

Re: [Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04

2019-02-04 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190205035704.26014-1-ebl...@redhat.com/



Hi,

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

Subject: [Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04
Type: series
Message-id: 20190205035704.26014-1-ebl...@redhat.com

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

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 t [tag update]patchew/20190204204517.23698-1-phi...@redhat.com -> 
patchew/20190204204517.23698-1-phi...@redhat.com
 * [new tag]   patchew/20190205035704.26014-1-ebl...@redhat.com -> 
patchew/20190205035704.26014-1-ebl...@redhat.com
Switched to a new branch 'test'
9f22048c0a block/nbd-client: rename read_reply_co to connection_co
e81ab27f82 block/nbd-client: don't check ioc
ce55b4b331 block/nbd-client: fix nbd_reply_chunk_iter_receive
80c093f3b1 block/nbd-client: split connection from initialization
a24543ee7b block/nbd: move connection code from block/nbd to block/nbd-client
467a28dbf2 block/nbd-client: split channel errors from export errors
bd906b01ff nbd: generalize usage of nbd_read
3d3be1f9bc qemu-nbd: Deprecate qemu-nbd --partition

=== OUTPUT BEGIN ===
1/8 Checking commit 3d3be1f9bcc8 (qemu-nbd: Deprecate qemu-nbd --partition)
2/8 Checking commit bd906b01ffe8 (nbd: generalize usage of nbd_read)
ERROR: spaces required around that '*' (ctx:WxV)
#85: FILE: include/block/nbd.h:356:
+ uint##bits##_t *val,   \
 ^

total: 1 errors, 0 warnings, 386 lines checked

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

3/8 Checking commit 467a28dbf261 (block/nbd-client: split channel errors from 
export errors)
4/8 Checking commit a24543ee7b41 (block/nbd: move connection code from 
block/nbd to block/nbd-client)
5/8 Checking commit 80c093f3b180 (block/nbd-client: split connection from 
initialization)
6/8 Checking commit ce55b4b331f9 (block/nbd-client: fix 
nbd_reply_chunk_iter_receive)
7/8 Checking commit e81ab27f828e (block/nbd-client: don't check ioc)
8/8 Checking commit 9f22048c0a07 (block/nbd-client: rename read_reply_co to 
connection_co)
=== OUTPUT END ===

Test command exited with code: 1


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

Re: [Qemu-devel] [PATCH v2 2/6] mips: Express dependencies of the Jazz machine with kconfig

2019-02-04 Thread Thomas Huth
On 2019-02-04 21:26, Philippe Mathieu-Daudé wrote:
> The Jazz use the RC4030 Asic to provide an EISA bus and DMA/IRQ. The
> framebuffer display is managed by a G364, the network card is a Sonic
> DP83932. A QLogic ESP216 provides a SCSI bus.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/mips-softmmu-common.mak |  1 -
>  default-configs/mips64-softmmu.mak  |  5 -
>  default-configs/mips64el-softmmu.mak|  6 --
>  hw/mips/Kconfig | 17 +
>  4 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/default-configs/mips-softmmu-common.mak 
> b/default-configs/mips-softmmu-common.mak
> index 8c5fdf5ee1..caebafd416 100644
> --- a/default-configs/mips-softmmu-common.mak
> +++ b/default-configs/mips-softmmu-common.mak
> @@ -3,7 +3,6 @@
>  CONFIG_ISA_BUS=y
>  CONFIG_PCI=y
>  CONFIG_PCI_DEVICES=y
> -CONFIG_ESP=y
>  CONFIG_VGA_ISA=y
>  CONFIG_VGA_ISA_MM=y
>  CONFIG_VGA_CIRRUS=y
> diff --git a/default-configs/mips64-softmmu.mak 
> b/default-configs/mips64-softmmu.mak
> index bad7496672..a169738635 100644
> --- a/default-configs/mips64-softmmu.mak
> +++ b/default-configs/mips64-softmmu.mak
> @@ -1,9 +1,4 @@
>  # Default configuration for mips64-softmmu
>  
>  include mips-softmmu-common.mak
> -CONFIG_RC4030=y
> -CONFIG_DP8393X=y
> -CONFIG_DS1225Y=y
>  CONFIG_JAZZ=y
> -CONFIG_G364FB=y
> -CONFIG_JAZZ_LED=y
> diff --git a/default-configs/mips64el-softmmu.mak 
> b/default-configs/mips64el-softmmu.mak
> index 8b255efc54..23445cfcf9 100644
> --- a/default-configs/mips64el-softmmu.mak
> +++ b/default-configs/mips64el-softmmu.mak
> @@ -2,13 +2,7 @@
>  
>  include mips-softmmu-common.mak
>  CONFIG_IDE_VIA=y
> -CONFIG_RC4030=y
> -CONFIG_DP8393X=y
> -CONFIG_DS1225Y=y
>  CONFIG_FULONG=y
> -CONFIG_JAZZ=y

Please keep the CONFIG_JAZZ line here.

 Thomas



[Qemu-devel] [PULL 7/8] block/nbd-client: don't check ioc

2019-02-04 Thread Eric Blake
From: Vladimir Sementsov-Ogievskiy 

We have several paranoid checks for ioc != NULL. But ioc may become
NULL only on close, which should not happen during requests handling.
Also, we check ioc only sometimes, not after each yield, which is
inconsistent. Let's drop these checks. However, for safety, let's leave
asserts instead.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Eric Blake 
Message-Id: <20190201130138.94525-6-vsement...@virtuozzo.com>
Signed-off-by: Eric Blake 
---
 block/nbd-client.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index 65e56000681..386c3feb14f 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -53,9 +53,7 @@ static void nbd_teardown_connection(BlockDriverState *bs)
 {
 NBDClientSession *client = nbd_get_client_session(bs);

-if (!client->ioc) { /* Already closed */
-return;
-}
+assert(client->ioc);

 /* finish any pending coroutines */
 qio_channel_shutdown(client->ioc,
@@ -154,10 +152,7 @@ static int nbd_co_send_request(BlockDriverState *bs,
 rc = -EIO;
 goto err;
 }
-if (!s->ioc) {
-rc = -EPIPE;
-goto err;
-}
+assert(s->ioc);

 if (qiov) {
 qio_channel_set_cork(s->ioc, true);
@@ -429,10 +424,11 @@ static coroutine_fn int nbd_co_do_receive_one_chunk(
 s->requests[i].receiving = true;
 qemu_coroutine_yield();
 s->requests[i].receiving = false;
-if (!s->ioc || s->quit) {
+if (s->quit) {
 error_setg(errp, "Connection closed");
 return -EIO;
 }
+assert(s->ioc);

 assert(s->reply.handle == handle);

@@ -982,9 +978,7 @@ void nbd_client_close(BlockDriverState *bs)
 NBDClientSession *client = nbd_get_client_session(bs);
 NBDRequest request = { .type = NBD_CMD_DISC };

-if (client->ioc == NULL) {
-return;
-}
+assert(client->ioc);

 nbd_send_request(client->ioc, );

-- 
2.20.1




[Qemu-devel] [PULL 8/8] block/nbd-client: rename read_reply_co to connection_co

2019-02-04 Thread Eric Blake
From: Vladimir Sementsov-Ogievskiy 

This coroutine will serve nbd reconnects, so, rename it to be something
more generic.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Eric Blake 
Message-Id: <20190201130138.94525-7-vsement...@virtuozzo.com>
Signed-off-by: Eric Blake 
---
 block/nbd-client.h |  4 ++--
 block/nbd-client.c | 24 
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/block/nbd-client.h b/block/nbd-client.h
index 2f047ba6142..d990207a5cb 100644
--- a/block/nbd-client.h
+++ b/block/nbd-client.h
@@ -20,7 +20,7 @@
 typedef struct {
 Coroutine *coroutine;
 uint64_t offset;/* original offset of the request */
-bool receiving; /* waiting for read_reply_co? */
+bool receiving; /* waiting for connection_co? */
 } NBDClientRequest;

 typedef struct NBDClientSession {
@@ -30,7 +30,7 @@ typedef struct NBDClientSession {

 CoMutex send_mutex;
 CoQueue free_sema;
-Coroutine *read_reply_co;
+Coroutine *connection_co;
 int in_flight;

 NBDClientRequest requests[MAX_NBD_REQUESTS];
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 386c3feb14f..f0ad54ce21d 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -59,7 +59,7 @@ static void nbd_teardown_connection(BlockDriverState *bs)
 qio_channel_shutdown(client->ioc,
  QIO_CHANNEL_SHUTDOWN_BOTH,
  NULL);
-BDRV_POLL_WHILE(bs, client->read_reply_co);
+BDRV_POLL_WHILE(bs, client->connection_co);

 nbd_client_detach_aio_context(bs);
 object_unref(OBJECT(client->sioc));
@@ -68,7 +68,7 @@ static void nbd_teardown_connection(BlockDriverState *bs)
 client->ioc = NULL;
 }

-static coroutine_fn void nbd_read_reply_entry(void *opaque)
+static coroutine_fn void nbd_connection_entry(void *opaque)
 {
 NBDClientSession *s = opaque;
 uint64_t i;
@@ -100,14 +100,14 @@ static coroutine_fn void nbd_read_reply_entry(void 
*opaque)
 }

 /* We're woken up again by the request itself.  Note that there
- * is no race between yielding and reentering read_reply_co.  This
+ * is no race between yielding and reentering connection_co.  This
  * is because:
  *
  * - if the request runs on the same AioContext, it is only
  *   entered after we yield
  *
  * - if the request runs on a different AioContext, reentering
- *   read_reply_co happens through a bottom half, which can only
+ *   connection_co happens through a bottom half, which can only
  *   run after we yield.
  */
 aio_co_wake(s->requests[i].coroutine);
@@ -116,7 +116,7 @@ static coroutine_fn void nbd_read_reply_entry(void *opaque)

 s->quit = true;
 nbd_recv_coroutines_wake_all(s);
-s->read_reply_co = NULL;
+s->connection_co = NULL;
 aio_wait_kick();
 }

@@ -420,7 +420,7 @@ static coroutine_fn int nbd_co_do_receive_one_chunk(
 }
 *request_ret = 0;

-/* Wait until we're woken up by nbd_read_reply_entry.  */
+/* Wait until we're woken up by nbd_connection_entry.  */
 s->requests[i].receiving = true;
 qemu_coroutine_yield();
 s->requests[i].receiving = false;
@@ -495,7 +495,7 @@ static coroutine_fn int nbd_co_do_receive_one_chunk(
 }

 /* nbd_co_receive_one_chunk
- * Read reply, wake up read_reply_co and set s->quit if needed.
+ * Read reply, wake up connection_co and set s->quit if needed.
  * Return value is a fatal error code or normal nbd reply error code
  */
 static coroutine_fn int nbd_co_receive_one_chunk(
@@ -509,15 +509,15 @@ static coroutine_fn int nbd_co_receive_one_chunk(
 if (ret < 0) {
 s->quit = true;
 } else {
-/* For assert at loop start in nbd_read_reply_entry */
+/* For assert at loop start in nbd_connection_entry */
 if (reply) {
 *reply = s->reply;
 }
 s->reply.handle = 0;
 }

-if (s->read_reply_co) {
-aio_co_wake(s->read_reply_co);
+if (s->connection_co) {
+aio_co_wake(s->connection_co);
 }

 return ret;
@@ -970,7 +970,7 @@ void nbd_client_attach_aio_context(BlockDriverState *bs,
 {
 NBDClientSession *client = nbd_get_client_session(bs);
 qio_channel_attach_aio_context(QIO_CHANNEL(client->ioc), new_context);
-aio_co_schedule(new_context, client->read_reply_co);
+aio_co_schedule(new_context, client->connection_co);
 }

 void nbd_client_close(BlockDriverState *bs)
@@ -1075,7 +1075,7 @@ static int nbd_client_connect(BlockDriverState *bs,
 /* Now that we're connected, set the socket to be non-blocking and
  * kick the reply mechanism.  */
 qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
-client->read_reply_co = qemu_coroutine_create(nbd_read_reply_entry, 
client);
+client->connection_co = qemu_coroutine_create(nbd_connection_entry, 
client);
 nbd_client_attach_aio_context(bs, 

[Qemu-devel] [PULL 4/8] block/nbd: move connection code from block/nbd to block/nbd-client

2019-02-04 Thread Eric Blake
From: Vladimir Sementsov-Ogievskiy 

Keep all connection code in one file, to be able to implement reconnect
in further patches.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Message-Id: <20190201130138.94525-3-vsement...@virtuozzo.com>
Reviewed-by: Eric Blake 
[eblake: format tweak]
Signed-off-by: Eric Blake 
---
 block/nbd-client.h |  2 +-
 block/nbd-client.c | 38 --
 block/nbd.c| 40 ++--
 3 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/block/nbd-client.h b/block/nbd-client.h
index cfc90550b99..2f047ba6142 100644
--- a/block/nbd-client.h
+++ b/block/nbd-client.h
@@ -41,7 +41,7 @@ typedef struct NBDClientSession {
 NBDClientSession *nbd_get_client_session(BlockDriverState *bs);

 int nbd_client_init(BlockDriverState *bs,
-QIOChannelSocket *sock,
+SocketAddress *saddr,
 const char *export_name,
 QCryptoTLSCreds *tlscreds,
 const char *hostname,
diff --git a/block/nbd-client.c b/block/nbd-client.c
index fd58cda2f17..80dc8cff473 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -991,8 +991,29 @@ void nbd_client_close(BlockDriverState *bs)
 nbd_teardown_connection(bs);
 }

+static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
+  Error **errp)
+{
+QIOChannelSocket *sioc;
+Error *local_err = NULL;
+
+sioc = qio_channel_socket_new();
+qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
+
+qio_channel_socket_connect_sync(sioc, saddr, _err);
+if (local_err) {
+object_unref(OBJECT(sioc));
+error_propagate(errp, local_err);
+return NULL;
+}
+
+qio_channel_set_delay(QIO_CHANNEL(sioc), false);
+
+return sioc;
+}
+
 int nbd_client_init(BlockDriverState *bs,
-QIOChannelSocket *sioc,
+SocketAddress *saddr,
 const char *export,
 QCryptoTLSCreds *tlscreds,
 const char *hostname,
@@ -1002,6 +1023,16 @@ int nbd_client_init(BlockDriverState *bs,
 NBDClientSession *client = nbd_get_client_session(bs);
 int ret;

+/*
+ * establish TCP connection, return error if it fails
+ * TODO: Configurable retry-until-timeout behaviour.
+ */
+QIOChannelSocket *sioc = nbd_establish_connection(saddr, errp);
+
+if (!sioc) {
+return -ECONNREFUSED;
+}
+
 /* NBD handshake */
 logout("session init %s\n", export);
 qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL);
@@ -1017,6 +1048,7 @@ int nbd_client_init(BlockDriverState *bs,
 g_free(client->info.name);
 if (ret < 0) {
 logout("Failed to negotiate with the NBD server\n");
+object_unref(OBJECT(sioc));
 return ret;
 }
 if (x_dirty_bitmap && !client->info.base_allocation) {
@@ -1042,7 +1074,6 @@ int nbd_client_init(BlockDriverState *bs,
 qemu_co_mutex_init(>send_mutex);
 qemu_co_queue_init(>free_sema);
 client->sioc = sioc;
-object_ref(OBJECT(client->sioc));

 if (!client->ioc) {
 client->ioc = QIO_CHANNEL(sioc);
@@ -1068,6 +1099,9 @@ int nbd_client_init(BlockDriverState *bs,
 NBDRequest request = { .type = NBD_CMD_DISC };

 nbd_send_request(client->ioc ?: QIO_CHANNEL(sioc), );
+
+object_unref(OBJECT(sioc));
+
 return ret;
 }
 }
diff --git a/block/nbd.c b/block/nbd.c
index e87699fb73b..9db5eded892 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -295,30 +295,6 @@ NBDClientSession *nbd_get_client_session(BlockDriverState 
*bs)
 return >client;
 }

-static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
-  Error **errp)
-{
-QIOChannelSocket *sioc;
-Error *local_err = NULL;
-
-sioc = qio_channel_socket_new();
-qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
-
-qio_channel_socket_connect_sync(sioc,
-saddr,
-_err);
-if (local_err) {
-object_unref(OBJECT(sioc));
-error_propagate(errp, local_err);
-return NULL;
-}
-
-qio_channel_set_delay(QIO_CHANNEL(sioc), false);
-
-return sioc;
-}
-
-
 static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, Error **errp)
 {
 Object *obj;
@@ -394,7 +370,6 @@ static int nbd_open(BlockDriverState *bs, QDict *options, 
int flags,
 BDRVNBDState *s = bs->opaque;
 QemuOpts *opts = NULL;
 Error *local_err = NULL;
-QIOChannelSocket *sioc = NULL;
 QCryptoTLSCreds *tlscreds = NULL;
 const char *hostname = NULL;
 int ret = -EINVAL;
@@ -434,22 +409,11 @@ static int nbd_open(BlockDriverState *bs, QDict *options, 
int flags,
 hostname = s->saddr->u.inet.host;
 }

-/* establish TCP connection, return error if it fails
- * TODO: 

[Qemu-devel] [PULL 2/8] nbd: generalize usage of nbd_read

2019-02-04 Thread Eric Blake
From: Vladimir Sementsov-Ogievskiy 

We generally do very similar things around nbd_read: error_prepend
specifying what we have tried to read, and be_to_cpu conversion of
integers.

So, it seems reasonable to move common things to helper functions,
which:
1. simplify code a bit
2. generalize nbd_read error descriptions, all starting with
   "Failed to read"
3. make it more difficult to forget to convert things from BE

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Eric Blake 
Message-Id: <20190128165830.165170-1-vsement...@virtuozzo.com>
[eblake: rename macro to DEF_NBD_READ_N and formatting tweaks;
checkpatch has false positive complaint]
Signed-off-by: Eric Blake 
---
 include/block/nbd.h | 32 +++--
 block/nbd-client.c  |  5 ++-
 nbd/client.c| 88 +++--
 nbd/common.c|  2 +-
 nbd/server.c| 27 +-
 5 files changed, 71 insertions(+), 83 deletions(-)

diff --git a/include/block/nbd.h b/include/block/nbd.h
index 4faf394e346..96cfb1d7d5d 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -23,6 +23,7 @@
 #include "qapi/qapi-types-block.h"
 #include "io/channel-socket.h"
 #include "crypto/tlscreds.h"
+#include "qapi/error.h"

 /* Handshake phase structs - this struct is passed on the wire */

@@ -336,11 +337,38 @@ void nbd_server_start(SocketAddress *addr, const char 
*tls_creds,
  * Reads @size bytes from @ioc. Returns 0 on success.
  */
 static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,
-   Error **errp)
+   const char *desc, Error **errp)
 {
-return qio_channel_read_all(ioc, buffer, size, errp) < 0 ? -EIO : 0;
+int ret = qio_channel_read_all(ioc, buffer, size, errp) < 0 ? -EIO : 0;
+
+if (ret < 0) {
+if (desc) {
+error_prepend(errp, "Failed to read %s: ", desc);
+}
+return -1;
+}
+
+return 0;
 }

+#define DEF_NBD_READ_N(bits)\
+static inline int nbd_read##bits(QIOChannel *ioc,   \
+ uint##bits##_t *val,   \
+ const char *desc, Error **errp)\
+{   \
+if (nbd_read(ioc, val, sizeof(*val), desc, errp) < 0) { \
+return -1;  \
+}   \
+*val = be##bits##_to_cpu(*val); \
+return 0;   \
+}
+
+DEF_NBD_READ_N(16) /* Defines nbd_read16(). */
+DEF_NBD_READ_N(32) /* Defines nbd_read32(). */
+DEF_NBD_READ_N(64) /* Defines nbd_read64(). */
+
+#undef DEF_NBD_READ_N
+
 static inline bool nbd_reply_is_simple(NBDReply *reply)
 {
 return reply->magic == NBD_SIMPLE_REPLY_MAGIC;
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 50a8dadd852..57f679ad4d0 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -338,10 +338,9 @@ static int 
nbd_co_receive_offset_data_payload(NBDClientSession *s,
 return -EINVAL;
 }

-if (nbd_read(s->ioc, , sizeof(offset), errp) < 0) {
+if (nbd_read64(s->ioc, , "OFFSET_DATA offset", errp) < 0) {
 return -EIO;
 }
-be64_to_cpus();

 data_size = chunk->length - sizeof(offset);
 assert(data_size);
@@ -388,7 +387,7 @@ static coroutine_fn int nbd_co_receive_structured_payload(
 }

 *payload = g_new(char, len);
-ret = nbd_read(s->ioc, *payload, len, errp);
+ret = nbd_read(s->ioc, *payload, len, "structured payload", errp);
 if (ret < 0) {
 g_free(*payload);
 *payload = NULL;
diff --git a/nbd/client.c b/nbd/client.c
index 8a083c2f42c..10a52ad7d0c 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -113,8 +113,7 @@ static int nbd_receive_option_reply(QIOChannel *ioc, 
uint32_t opt,
 NBDOptionReply *reply, Error **errp)
 {
 QEMU_BUILD_BUG_ON(sizeof(*reply) != 20);
-if (nbd_read(ioc, reply, sizeof(*reply), errp) < 0) {
-error_prepend(errp, "failed to read option reply: ");
+if (nbd_read(ioc, reply, sizeof(*reply), "option reply", errp) < 0) {
 nbd_send_opt_abort(ioc);
 return -1;
 }
@@ -166,8 +165,8 @@ static int nbd_handle_reply_err(QIOChannel *ioc, 
NBDOptionReply *reply,
 goto cleanup;
 }
 msg = g_malloc(reply->length + 1);
-if (nbd_read(ioc, msg, reply->length, errp) < 0) {
-error_prepend(errp, "failed to read option error %" PRIu32
+if (nbd_read(ioc, msg, reply->length, NULL, errp) < 0) {
+error_prepend(errp, "Failed to read option error %" PRIu32
   " (%s) message: ",
   reply->type, nbd_rep_lookup(reply->type));
 goto cleanup;
@@ 

[Qemu-devel] [PULL 3/8] block/nbd-client: split channel errors from export errors

2019-02-04 Thread Eric Blake
From: Vladimir Sementsov-Ogievskiy 

To implement nbd reconnect in further patches, we need to distinguish
error codes, returned by nbd server, from channel errors, to reconnect
only in the latter case.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Eric Blake 
Message-Id: <20190201130138.94525-2-vsement...@virtuozzo.com>
Signed-off-by: Eric Blake 
---
 block/nbd-client.c | 83 ++
 1 file changed, 47 insertions(+), 36 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index 57f679ad4d0..fd58cda2f17 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -504,11 +504,11 @@ static coroutine_fn int nbd_co_do_receive_one_chunk(
  */
 static coroutine_fn int nbd_co_receive_one_chunk(
 NBDClientSession *s, uint64_t handle, bool only_structured,
-QEMUIOVector *qiov, NBDReply *reply, void **payload, Error **errp)
+int *request_ret, QEMUIOVector *qiov, NBDReply *reply, void **payload,
+Error **errp)
 {
-int request_ret;
 int ret = nbd_co_do_receive_one_chunk(s, handle, only_structured,
-  _ret, qiov, payload, errp);
+  request_ret, qiov, payload, errp);

 if (ret < 0) {
 s->quit = true;
@@ -518,7 +518,6 @@ static coroutine_fn int nbd_co_receive_one_chunk(
 *reply = s->reply;
 }
 s->reply.handle = 0;
-ret = request_ret;
 }

 if (s->read_reply_co) {
@@ -530,22 +529,17 @@ static coroutine_fn int nbd_co_receive_one_chunk(

 typedef struct NBDReplyChunkIter {
 int ret;
-bool fatal;
+int request_ret;
 Error *err;
 bool done, only_structured;
 } NBDReplyChunkIter;

-static void nbd_iter_error(NBDReplyChunkIter *iter, bool fatal,
-   int ret, Error **local_err)
+static void nbd_iter_channel_error(NBDReplyChunkIter *iter,
+   int ret, Error **local_err)
 {
 assert(ret < 0);

-if ((fatal && !iter->fatal) || iter->ret == 0) {
-if (iter->ret != 0) {
-error_free(iter->err);
-iter->err = NULL;
-}
-iter->fatal = fatal;
+if (!iter->ret) {
 iter->ret = ret;
 error_propagate(>err, *local_err);
 } else {
@@ -555,6 +549,15 @@ static void nbd_iter_error(NBDReplyChunkIter *iter, bool 
fatal,
 *local_err = NULL;
 }

+static void nbd_iter_request_error(NBDReplyChunkIter *iter, int ret)
+{
+assert(ret < 0);
+
+if (!iter->request_ret) {
+iter->request_ret = ret;
+}
+}
+
 /* NBD_FOREACH_REPLY_CHUNK
  */
 #define NBD_FOREACH_REPLY_CHUNK(s, iter, handle, structured, \
@@ -570,13 +573,13 @@ static bool nbd_reply_chunk_iter_receive(NBDClientSession 
*s,
  QEMUIOVector *qiov, NBDReply *reply,
  void **payload)
 {
-int ret;
+int ret, request_ret;
 NBDReply local_reply;
 NBDStructuredReplyChunk *chunk;
 Error *local_err = NULL;
 if (s->quit) {
 error_setg(_err, "Connection closed");
-nbd_iter_error(iter, true, -EIO, _err);
+nbd_iter_channel_error(iter, -EIO, _err);
 goto break_loop;
 }

@@ -590,10 +593,12 @@ static bool nbd_reply_chunk_iter_receive(NBDClientSession 
*s,
 }

 ret = nbd_co_receive_one_chunk(s, handle, iter->only_structured,
-   qiov, reply, payload, _err);
+   _ret, qiov, reply, payload,
+   _err);
 if (ret < 0) {
-/* If it is a fatal error s->quit is set by nbd_co_receive_one_chunk */
-nbd_iter_error(iter, s->quit, ret, _err);
+nbd_iter_channel_error(iter, ret, _err);
+} else if (request_ret < 0) {
+nbd_iter_request_error(iter, request_ret);
 }

 /* Do not execute the body of NBD_FOREACH_REPLY_CHUNK for simple reply. */
@@ -630,7 +635,7 @@ break_loop:
 }

 static int nbd_co_receive_return_code(NBDClientSession *s, uint64_t handle,
-  Error **errp)
+  int *request_ret, Error **errp)
 {
 NBDReplyChunkIter iter;

@@ -639,12 +644,13 @@ static int nbd_co_receive_return_code(NBDClientSession 
*s, uint64_t handle,
 }

 error_propagate(errp, iter.err);
+*request_ret = iter.request_ret;
 return iter.ret;
 }

 static int nbd_co_receive_cmdread_reply(NBDClientSession *s, uint64_t handle,
 uint64_t offset, QEMUIOVector *qiov,
-Error **errp)
+int *request_ret, Error **errp)
 {
 NBDReplyChunkIter iter;
 NBDReply reply;
@@ -669,7 +675,7 @@ static int nbd_co_receive_cmdread_reply(NBDClientSession 
*s, uint64_t handle,
 offset, qiov, _err);
 if (ret < 0) {
 

[Qemu-devel] [PULL 5/8] block/nbd-client: split connection from initialization

2019-02-04 Thread Eric Blake
From: Vladimir Sementsov-Ogievskiy 

Split connection code to reuse it for reconnect.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Eric Blake 
Message-Id: <20190201130138.94525-4-vsement...@virtuozzo.com>
Signed-off-by: Eric Blake 
---
 block/nbd-client.c | 33 -
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index 80dc8cff473..d7d88297698 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -1012,13 +1012,13 @@ static QIOChannelSocket 
*nbd_establish_connection(SocketAddress *saddr,
 return sioc;
 }

-int nbd_client_init(BlockDriverState *bs,
-SocketAddress *saddr,
-const char *export,
-QCryptoTLSCreds *tlscreds,
-const char *hostname,
-const char *x_dirty_bitmap,
-Error **errp)
+static int nbd_client_connect(BlockDriverState *bs,
+  SocketAddress *saddr,
+  const char *export,
+  QCryptoTLSCreds *tlscreds,
+  const char *hostname,
+  const char *x_dirty_bitmap,
+  Error **errp)
 {
 NBDClientSession *client = nbd_get_client_session(bs);
 int ret;
@@ -1071,8 +1071,6 @@ int nbd_client_init(BlockDriverState *bs,
 bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP;
 }

-qemu_co_mutex_init(>send_mutex);
-qemu_co_queue_init(>free_sema);
 client->sioc = sioc;

 if (!client->ioc) {
@@ -1105,3 +1103,20 @@ int nbd_client_init(BlockDriverState *bs,
 return ret;
 }
 }
+
+int nbd_client_init(BlockDriverState *bs,
+SocketAddress *saddr,
+const char *export,
+QCryptoTLSCreds *tlscreds,
+const char *hostname,
+const char *x_dirty_bitmap,
+Error **errp)
+{
+NBDClientSession *client = nbd_get_client_session(bs);
+
+qemu_co_mutex_init(>send_mutex);
+qemu_co_queue_init(>free_sema);
+
+return nbd_client_connect(bs, saddr, export, tlscreds, hostname,
+  x_dirty_bitmap, errp);
+}
-- 
2.20.1




[Qemu-devel] [PULL 6/8] block/nbd-client: fix nbd_reply_chunk_iter_receive

2019-02-04 Thread Eric Blake
From: Vladimir Sementsov-Ogievskiy 

Use exported report, not the variable to be reused (should not really
matter).

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Eric Blake 
Message-Id: <20190201130138.94525-5-vsement...@virtuozzo.com>
Signed-off-by: Eric Blake 
---
 block/nbd-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index d7d88297698..65e56000681 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -602,7 +602,7 @@ static bool nbd_reply_chunk_iter_receive(NBDClientSession 
*s,
 }

 /* Do not execute the body of NBD_FOREACH_REPLY_CHUNK for simple reply. */
-if (nbd_reply_is_simple(>reply) || s->quit) {
+if (nbd_reply_is_simple(reply) || s->quit) {
 goto break_loop;
 }

-- 
2.20.1




[Qemu-devel] [PULL 0/8] NBD patches for 2019-02-04

2019-02-04 Thread Eric Blake
The following changes since commit 773c4a6228fd910556cee2d477ee56c591a3:

  test-filter-mirror: pass UNIX domain socket through fd (2019-02-04 16:03:20 
+)

are available in the Git repository at:

  https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2019-02-04

for you to fetch changes up to bc5a03350c220698229e7d6929dd242d5d358345:

  block/nbd-client: rename read_reply_co to connection_co (2019-02-04 15:11:27 
-0600)


nbd patches for 2019-02-04

- deprecate 'qemu-nbd --partition'
- preparation for NBD reconnect, including better logging of read errors


Eric Blake (1):
  qemu-nbd: Deprecate qemu-nbd --partition

Vladimir Sementsov-Ogievskiy (7):
  nbd: generalize usage of nbd_read
  block/nbd-client: split channel errors from export errors
  block/nbd: move connection code from block/nbd to block/nbd-client
  block/nbd-client: split connection from initialization
  block/nbd-client: fix nbd_reply_chunk_iter_receive
  block/nbd-client: don't check ioc
  block/nbd-client: rename read_reply_co to connection_co

 qemu-deprecated.texi |  33 +
 qemu-nbd.texi|   6 +-
 block/nbd-client.h   |   6 +-
 include/block/nbd.h  |  32 -
 block/nbd-client.c   | 199 ---
 block/nbd.c  |  40 +--
 nbd/client.c |  88 ---
 nbd/common.c |   2 +-
 nbd/server.c |  27 +++
 qemu-nbd.c   |   2 +
 10 files changed, 239 insertions(+), 196 deletions(-)

-- 
2.20.1




[Qemu-devel] [PULL 1/8] qemu-nbd: Deprecate qemu-nbd --partition

2019-02-04 Thread Eric Blake
The existing qemu-nbd --partition code claims to handle logical
partitions up to 8, since its introduction in 2008 (commit 7a5ca86).
However, the implementation is bogus (actual MBR logical partitions
form a sort of linked list, with one partition per extended table
entry, rather than four logical partitions in a single extended
table), making the code unlikely to work for anything beyond -P5 on
actual guest images. What's more, the code does not support GPT
partitions, which are becoming more popular, and maintaining device
subsetting in both NBD and the raw device is unnecessary duplication
of effort (even if it is not too difficult).

Note that obtaining the offsets of a partition (MBR or GPT) can be
learned by using 'qemu-nbd -c /dev/nbd0 file.qcow2 && sfdisk --dump
/dev/nbd0', but by the time you've done that, you might as well
just mount /dev/nbd0p1 that the kernel creates for you instead of
bothering with qemu exporting a subset.  Or, keeping to just
user-space code, use nbdkit's partition filter, which has already
known both GPT and primary MBR partitions for a while, and was
just recently enhanced to support arbitrary logical MBR parititions.

Start the clock on the deprecation cycle, with examples of how
to accomplish device subsetting without using -P.

Signed-off-by: Eric Blake 
Message-Id: <20190125234837.2272-1-ebl...@redhat.com>
Reviewed-by: Richard W.M. Jones 
Reviewed-by: Stefano Garzarella 
---
 qemu-deprecated.texi | 33 +
 qemu-nbd.texi|  6 --
 qemu-nbd.c   |  2 ++
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 9cc20b365c5..8a6174df0c1 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -160,3 +160,36 @@ Example of legacy encoding:
 The above, converted to the current supported format:

 @code{json:@{"file.driver":"rbd", "file.pool":"rbd", "file.image":"name"@}}
+
+@section Related binaries
+
+@subsection qemu-nbd --partition (since 4.0.0)
+
+The ``qemu-nbd --partition $digit'' code (also spelled @option{-P})
+can only handle MBR partitions, and has never correctly handled
+logical partitions beyond partition 5.  If you know the offset and
+length of the partition (perhaps by using @code{sfdisk} within the
+guest), you can achieve the effect of exporting just that subset of
+the disk by use of the @option{--image-opts} option with a raw
+blockdev using the @code{offset} and @code{size} parameters layered on
+top of any other existing blockdev. For example, if partition 1 is
+100MiB long starting at 1MiB, the old command:
+
+@code{qemu-nbd -t -P 1 -f qcow2 file.qcow2}
+
+can be rewritten as:
+
+@code{qemu-nbd -t --image-opts 
driver=raw,offset=1M,size=100M,file.driver=qcow2,file.backing.driver=file,file.backing.filename=file.qcow2}
+
+Alternatively, the @code{nbdkit} project provides a more powerful
+partition filter on top of its nbd plugin, which can be used to select
+an arbitrary MBR or GPT partition on top of any other full-image NBD
+export.  Using this to rewrite the above example results in:
+
+@code{qemu-nbd -t -k /tmp/sock -f qcow2 file.qcow2 &}
+@code{nbdkit -f --filter=partition nbd socket=/tmp/sock partition=1}
+
+Note that if you are exposing the export via /dev/nbd0, it is easier
+to just export the entire image and then mount only /dev/nbd0p1 than
+it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a
+subset of the image.
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 386bece4680..d0c51828149 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -56,8 +56,10 @@ auto-detecting.
 @item -r, --read-only
 Export the disk as read-only.
 @item -P, --partition=@var{num}
-Only expose MBR partition @var{num}.  Understands physical partitions
-1-4 and logical partitions 5-8.
+Deprecated: Only expose MBR partition @var{num}.  Understands physical
+partitions 1-4 and logical partition 5. New code should instead use
+@option{--image-opts} with the raw driver wrapping a subset of the
+original image.
 @item -B, --bitmap=@var{name}
 If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
 that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 1f7b2a03f5d..00c07fd27ea 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -787,6 +787,8 @@ int main(int argc, char **argv)
 flags &= ~BDRV_O_RDWR;
 break;
 case 'P':
+warn_report("The '-P' option is deprecated; use --image-opts with "
+"a raw device wrapper for subset exports instead");
 if (qemu_strtoi(optarg, NULL, 0, ) < 0 ||
 partition < 1 || partition > 8) {
 error_report("Invalid partition '%s'", optarg);
-- 
2.20.1




Re: [Qemu-devel] [PATCH 0/2] Clean up the SDL audio code

2019-02-04 Thread no-reply
Patchew URL: 
https://patchew.org/QEMU/1549336101-17623-1-git-send-email-th...@redhat.com/



Hi,

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

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




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

Re: [Qemu-devel] [PATCH v2 1/6] mips: Express dependencies of the MIPSsim machine with kconfig

2019-02-04 Thread Thomas Huth
On 2019-02-04 21:26, Philippe Mathieu-Daudé wrote:
> The MIPSsim machine only emulates an 8250 UART and a simple network
> controller, connected via an ISA bus.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  default-configs/mips-softmmu-common.mak | 1 -
>  hw/mips/Kconfig | 3 +++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/default-configs/mips-softmmu-common.mak 
> b/default-configs/mips-softmmu-common.mak
> index 0795d522db..8c5fdf5ee1 100644
> --- a/default-configs/mips-softmmu-common.mak
> +++ b/default-configs/mips-softmmu-common.mak
> @@ -26,7 +26,6 @@ CONFIG_PIIX4=y
>  CONFIG_IDE_ISA=y
>  CONFIG_IDE_PIIX=y
>  CONFIG_NE2000_ISA=y
> -CONFIG_MIPSNET=y
>  CONFIG_PFLASH_CFI01=y
>  CONFIG_I8259=y
>  CONFIG_MC146818RTC=y
> diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig
> index cdc07e59b6..3433e97e1a 100644
> --- a/hw/mips/Kconfig
> +++ b/hw/mips/Kconfig
> @@ -6,6 +6,9 @@ config MALTA
>  
>  config MIPSSIM
>  bool
> +select ISA_BUS
> +select SERIAL_ISA
> +select MIPSNET

Reviewed-by: Thomas Huth 



Re: [Qemu-devel] [PATCH] hw/input/tsc210x: Fix building with no verbosity

2019-02-04 Thread Thomas Huth
On 2019-02-04 21:45, Philippe Mathieu-Daudé wrote:
> When building with TSC_VERBOSE not defined, we get:
>   CC  arm-softmmu/hw/input/tsc210x.o
> hw/input/tsc210x.c: In function ‘tsc2102_data_register_write’:
> hw/input/tsc210x.c:554:5: error: label at end of compound statement
>  default:
>  ^~~
> hw/input/tsc210x.c: In function ‘tsc2102_control_register_write’:
> hw/input/tsc210x.c:638:5: error: label at end of compound statement
>  bad_reg:
>  ^~~
> hw/input/tsc210x.c: In function ‘tsc2102_audio_register_write’:
> hw/input/tsc210x.c:766:5: error: label at end of compound statement
>  default:
>  ^~~
> make[1]: *** [rules.mak:69: hw/input/tsc210x.o] Error 1
> 
> Fix this by replacing the culprit fprintf(stderr) calls by a more
> recent API: qemu_log_mask(LOG_GUEST_ERROR). Other fprintf() calls
> are left untouched.
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/input/tsc210x.c | 18 ++
>  1 file changed, 6 insertions(+), 12 deletions(-)

Reviewed-by: Thomas Huth 



[Qemu-devel] [PATCH 0/2] Clean up the SDL audio code

2019-02-04 Thread Thomas Huth
Now that support for SDL 1.2 has been removed, we can clean up
the sdlaudio code a little bit, too.

Thomas Huth (2):
  audio/sdlaudio: Remove the semaphore code
  audio/sdlaudio: Simplify the sdl_callback function

 audio/sdlaudio.c | 188 +++
 1 file changed, 23 insertions(+), 165 deletions(-)

-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v2 02/18] configure: Disable W^X on OpenBSD

2019-02-04 Thread Eric Blake
On 1/30/19 1:17 AM, Thomas Huth wrote:

>> test ... -a ...
>>
>> is not portable (POSIX permits non-XSI systems to omit support for these
>> operators, but even where they are supported, there are some inherently
>> ambiguous inputs where you CANNOT predict whether the shell will parse
>> -a as a binary operator or as an argument to some other operator).
>> Instead, you should ALWAYS break dual tests into:
>>
>> test ... && test ...
>>
>> instead.  (Same for '-o' vs '|| test')
> 
> $ grep 'test.* -a ' configure | wc -l
> 21
> $ grep 'test.* && ' configure | wc -l
> 16
> 
> Looks like we do not really care?

Well, I care. Enough to propose a patch :)

https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg00960.html

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH 1/2] audio/sdlaudio: Remove the semaphore code

2019-02-04 Thread Thomas Huth
The semaphore code was only working with SDL1.2 - with SDL2, it causes
a deadlock. Since we've removed support for SDL1.2 recently, we can
now completely remove the semaphore code from sdlaudio.c.

Signed-off-by: Thomas Huth 
---
 audio/sdlaudio.c | 145 ++-
 1 file changed, 5 insertions(+), 140 deletions(-)

diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index 9db5ac9..53bfdbf 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -38,14 +38,9 @@
 #define AUDIO_CAP "sdl"
 #include "audio_int.h"
 
-#define USE_SEMAPHORE (SDL_MAJOR_VERSION < 2)
-
 typedef struct SDLVoiceOut {
 HWVoiceOut hw;
 int live;
-#if USE_SEMAPHORE
-int rpos;
-#endif
 int decr;
 } SDLVoiceOut;
 
@@ -57,10 +52,6 @@ static struct {
 
 static struct SDLAudioState {
 int exit;
-#if USE_SEMAPHORE
-SDL_mutex *mutex;
-SDL_sem *sem;
-#endif
 int initialized;
 bool driver_created;
 } glob_sdl;
@@ -77,66 +68,6 @@ static void GCC_FMT_ATTR (1, 2) sdl_logerr (const char *fmt, 
...)
 AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ());
 }
 
-static int sdl_lock (SDLAudioState *s, const char *forfn)
-{
-#if USE_SEMAPHORE
-if (SDL_LockMutex (s->mutex)) {
-sdl_logerr ("SDL_LockMutex for %s failed\n", forfn);
-return -1;
-}
-#else
-SDL_LockAudio();
-#endif
-
-return 0;
-}
-
-static int sdl_unlock (SDLAudioState *s, const char *forfn)
-{
-#if USE_SEMAPHORE
-if (SDL_UnlockMutex (s->mutex)) {
-sdl_logerr ("SDL_UnlockMutex for %s failed\n", forfn);
-return -1;
-}
-#else
-SDL_UnlockAudio();
-#endif
-
-return 0;
-}
-
-static int sdl_post (SDLAudioState *s, const char *forfn)
-{
-#if USE_SEMAPHORE
-if (SDL_SemPost (s->sem)) {
-sdl_logerr ("SDL_SemPost for %s failed\n", forfn);
-return -1;
-}
-#endif
-
-return 0;
-}
-
-#if USE_SEMAPHORE
-static int sdl_wait (SDLAudioState *s, const char *forfn)
-{
-if (SDL_SemWait (s->sem)) {
-sdl_logerr ("SDL_SemWait for %s failed\n", forfn);
-return -1;
-}
-return 0;
-}
-#endif
-
-static int sdl_unlock_and_post (SDLAudioState *s, const char *forfn)
-{
-if (sdl_unlock (s, forfn)) {
-return -1;
-}
-
-return sdl_post (s, forfn);
-}
-
 static int aud_to_sdlfmt (audfmt_e fmt)
 {
 switch (fmt) {
@@ -243,9 +174,9 @@ static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt)
 static void sdl_close (SDLAudioState *s)
 {
 if (s->initialized) {
-sdl_lock (s, "sdl_close");
+SDL_LockAudio();
 s->exit = 1;
-sdl_unlock_and_post (s, "sdl_close");
+SDL_UnlockAudio();
 SDL_PauseAudio (1);
 SDL_CloseAudio ();
 s->initialized = 0;
@@ -267,30 +198,10 @@ static void sdl_callback (void *opaque, Uint8 *buf, int 
len)
 int to_mix, decr;
 
 /* dolog ("in callback samples=%d\n", samples); */
-#if USE_SEMAPHORE
-sdl_wait (s, "sdl_callback");
-if (s->exit) {
-return;
-}
-
-if (sdl_lock (s, "sdl_callback")) {
-return;
-}
-
-if (audio_bug(__func__, sdl->live < 0 || sdl->live > hw->samples)) {
-dolog ("sdl->live=%d hw->samples=%d\n",
-   sdl->live, hw->samples);
-return;
-}
 
-if (!sdl->live) {
-goto again;
-}
-#else
 if (s->exit || !sdl->live) {
 break;
 }
-#endif
 
 /* dolog ("in callback live=%d\n", live); */
 to_mix = audio_MIN (samples, sdl->live);
@@ -301,33 +212,20 @@ static void sdl_callback (void *opaque, Uint8 *buf, int 
len)
 
 /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */
 hw->clip (buf, src, chunk);
-#if USE_SEMAPHORE
-sdl->rpos = (sdl->rpos + chunk) % hw->samples;
-#else
 hw->rpos = (hw->rpos + chunk) % hw->samples;
-#endif
 to_mix -= chunk;
 buf += chunk << hw->info.shift;
 }
 samples -= decr;
 sdl->live -= decr;
 sdl->decr += decr;
-
-#if USE_SEMAPHORE
-again:
-if (sdl_unlock (s, "sdl_callback")) {
-return;
-}
-#endif
 }
 /* dolog ("done len=%d\n", len); */
 
-#if (SDL_MAJOR_VERSION >= 2)
 /* SDL2 does not clear the remaining buffer for us, so do it on our own */
 if (samples) {
 memset(buf, 0, samples << hw->info.shift);
 }
-#endif
 }
 
 static int sdl_write_out (SWVoiceOut *sw, void *buf, int len)
@@ -339,11 +237,8 @@ static int sdl_run_out (HWVoiceOut *hw, int live)
 {
 int decr;
 SDLVoiceOut *sdl = (SDLVoiceOut *) hw;
-SDLAudioState *s = _sdl;
 
-if (sdl_lock (s, "sdl_run_out")) {
-return 0;
-}
+SDL_LockAudio();
 
 if (sdl->decr > live) {
 ldebug ("sdl->decr %d live %d sdl->live %d\n",
@@ -355,19 +250,10 @@ static int sdl_run_out (HWVoiceOut *hw, int live)
 decr = audio_MIN (sdl->decr, live);
 

[Qemu-devel] [PATCH 2/2] audio/sdlaudio: Simplify the sdl_callback function

2019-02-04 Thread Thomas Huth
At the end of the while-loop, either "samples" or "sdl->live" is zero, so
now that we've removed the semaphore code, the content of the while-loop
is always only executed once. Thus we can remove the while-loop now to
get rid of one indentation level here.

Signed-off-by: Thomas Huth 
---
 audio/sdlaudio.c | 45 +++--
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index 53bfdbf..f7ee70b 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -189,37 +189,30 @@ static void sdl_callback (void *opaque, Uint8 *buf, int 
len)
 SDLAudioState *s = _sdl;
 HWVoiceOut *hw = >hw;
 int samples = len >> hw->info.shift;
+int to_mix, decr;
 
-if (s->exit) {
+if (s->exit || !sdl->live) {
 return;
 }
 
-while (samples) {
-int to_mix, decr;
-
-/* dolog ("in callback samples=%d\n", samples); */
-
-if (s->exit || !sdl->live) {
-break;
-}
-
-/* dolog ("in callback live=%d\n", live); */
-to_mix = audio_MIN (samples, sdl->live);
-decr = to_mix;
-while (to_mix) {
-int chunk = audio_MIN (to_mix, hw->samples - hw->rpos);
-struct st_sample *src = hw->mix_buf + hw->rpos;
-
-/* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */
-hw->clip (buf, src, chunk);
-hw->rpos = (hw->rpos + chunk) % hw->samples;
-to_mix -= chunk;
-buf += chunk << hw->info.shift;
-}
-samples -= decr;
-sdl->live -= decr;
-sdl->decr += decr;
+/* dolog ("in callback samples=%d live=%d\n", samples, sdl->live); */
+
+to_mix = audio_MIN(samples, sdl->live);
+decr = to_mix;
+while (to_mix) {
+int chunk = audio_MIN(to_mix, hw->samples - hw->rpos);
+struct st_sample *src = hw->mix_buf + hw->rpos;
+
+/* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */
+hw->clip(buf, src, chunk);
+hw->rpos = (hw->rpos + chunk) % hw->samples;
+to_mix -= chunk;
+buf += chunk << hw->info.shift;
 }
+samples -= decr;
+sdl->live -= decr;
+sdl->decr += decr;
+
 /* dolog ("done len=%d\n", len); */
 
 /* SDL2 does not clear the remaining buffer for us, so do it on our own */
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v3] checkpatch: Flag suspicious attribution lines

2019-02-04 Thread Eric Blake
On 2/4/19 8:25 PM, Eric Blake wrote:
> Flag commit attribution tags that are unusual (often because they
> were a typo), but only as a warning (because sometimes a humorous
> or otherwise useful tag is intentionally supplied).
> 
> This picks the 6 most popular tags, each with 700 or more uses (well,
> S-o-b was already checked for case-sensitivity and typos, leaving
> only 5 new tags being checked), as determined by:
> $ git log | sed -n 's/^ *\([A-Za-z-]*-[bB][yY]:\).*/\1/p' | \
>   sort | uniq -c | sort -k1,1n | tail

[-_][bB][yY] finds an additional:

  2 Reviewed_by:

Should I try to flag those as well, in v4 (note - the current
Signed-off-by tests do not flag Signed_off_by as invalid, so the patch
does get a bit bigger if we want to catch it)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 02/11] hw: Remove unused 'hw/devices.h' include

2019-02-04 Thread David Gibson
On Tue, Feb 05, 2019 at 12:18:06AM +0100, Philippe Mathieu-Daudé wrote:
> Reviewed-by: BALATON Zoltan 
> Tested-by: Thomas Huth 
> Signed-off-by: Philippe Mathieu-Daudé 

ppc parts
Acked-by: David Gibson 

> ---
>  hw/alpha/typhoon.c   | 1 -
>  hw/arm/allwinner-a10.c   | 1 -
>  hw/arm/collie.c  | 1 -
>  hw/arm/cubieboard.c  | 1 -
>  hw/arm/highbank.c| 1 -
>  hw/arm/mps2-tz.c | 1 -
>  hw/arm/musicpal.c| 1 -
>  hw/arm/nrf51_soc.c   | 1 -
>  hw/arm/spitz.c   | 1 -
>  hw/arm/virt.c| 1 -
>  hw/arm/z2.c  | 1 -
>  hw/display/sm501.c   | 1 -
>  hw/hppa/dino.c   | 1 -
>  hw/intc/allwinner-a10-pic.c  | 1 -
>  hw/lm32/lm32_boards.c| 1 -
>  hw/lm32/milkymist.c  | 1 -
>  hw/microblaze/petalogix_ml605_mmu.c  | 1 -
>  hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 -
>  hw/net/dp8393x.c | 1 -
>  hw/ppc/virtex_ml507.c| 1 -
>  hw/sh4/r2d.c | 1 -
>  hw/tricore/tricore_testboard.c   | 1 -
>  hw/usb/tusb6010.c| 1 -
>  23 files changed, 23 deletions(-)
> 
> diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c
> index 397e2dcdc7..9d57361c67 100644
> --- a/hw/alpha/typhoon.c
> +++ b/hw/alpha/typhoon.c
> @@ -11,7 +11,6 @@
>  #include "qapi/error.h"
>  #include "cpu.h"
>  #include "hw/hw.h"
> -#include "hw/devices.h"
>  #include "sysemu/sysemu.h"
>  #include "alpha_sys.h"
>  #include "exec/address-spaces.h"
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index df0d079ad0..06ec6f4dc8 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -20,7 +20,6 @@
>  #include "qemu-common.h"
>  #include "cpu.h"
>  #include "hw/sysbus.h"
> -#include "hw/devices.h"
>  #include "hw/arm/allwinner-a10.h"
>  #include "hw/misc/unimp.h"
>  
> diff --git a/hw/arm/collie.c b/hw/arm/collie.c
> index 48b732c176..3ca4e078fe 100644
> --- a/hw/arm/collie.c
> +++ b/hw/arm/collie.c
> @@ -12,7 +12,6 @@
>  #include "hw/hw.h"
>  #include "hw/sysbus.h"
>  #include "hw/boards.h"
> -#include "hw/devices.h"
>  #include "strongarm.h"
>  #include "hw/arm/arm.h"
>  #include "hw/block/flash.h"
> diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
> index 32f1edd2fa..84187d3916 100644
> --- a/hw/arm/cubieboard.c
> +++ b/hw/arm/cubieboard.c
> @@ -20,7 +20,6 @@
>  #include "qemu-common.h"
>  #include "cpu.h"
>  #include "hw/sysbus.h"
> -#include "hw/devices.h"
>  #include "hw/boards.h"
>  #include "hw/arm/allwinner-a10.h"
>  
> diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
> index fb9efa02c3..96ccf18d86 100644
> --- a/hw/arm/highbank.c
> +++ b/hw/arm/highbank.c
> @@ -21,7 +21,6 @@
>  #include "qapi/error.h"
>  #include "hw/sysbus.h"
>  #include "hw/arm/arm.h"
> -#include "hw/devices.h"
>  #include "hw/loader.h"
>  #include "net/net.h"
>  #include "sysemu/kvm.h"
> diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
> index f5f0b0e0fa..f79f090a4a 100644
> --- a/hw/arm/mps2-tz.c
> +++ b/hw/arm/mps2-tz.c
> @@ -56,7 +56,6 @@
>  #include "hw/arm/armsse.h"
>  #include "hw/dma/pl080.h"
>  #include "hw/ssi/pl022.h"
> -#include "hw/devices.h"
>  #include "net/net.h"
>  #include "hw/core/split-irq.h"
>  
> diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
> index d22532a11c..de4a12e496 100644
> --- a/hw/arm/musicpal.c
> +++ b/hw/arm/musicpal.c
> @@ -15,7 +15,6 @@
>  #include "cpu.h"
>  #include "hw/sysbus.h"
>  #include "hw/arm/arm.h"
> -#include "hw/devices.h"
>  #include "net/net.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/boards.h"
> diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
> index bbaf050103..3e633d160e 100644
> --- a/hw/arm/nrf51_soc.c
> +++ b/hw/arm/nrf51_soc.c
> @@ -14,7 +14,6 @@
>  #include "hw/arm/arm.h"
>  #include "hw/sysbus.h"
>  #include "hw/boards.h"
> -#include "hw/devices.h"
>  #include "hw/misc/unimp.h"
>  #include "exec/address-spaces.h"
>  #include "sysemu/sysemu.h"
> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
> index c4bc3deedf..22f5958b9d 100644
> --- a/hw/arm/spitz.c
> +++ b/hw/arm/spitz.c
> @@ -21,7 +21,6 @@
>  #include "hw/ssi/ssi.h"
>  #include "hw/block/flash.h"
>  #include "qemu/timer.h"
> -#include "hw/devices.h"
>  #include "hw/arm/sharpsl.h"
>  #include "ui/console.h"
>  #include "hw/audio/wm8750.h"
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 99c2b6e60d..396804f0e5 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -37,7 +37,6 @@
>  #include "hw/vfio/vfio-calxeda-xgmac.h"
>  #include "hw/vfio/vfio-amd-xgbe.h"
>  #include "hw/display/ramfb.h"
> -#include "hw/devices.h"
>  #include "net/net.h"
>  #include "sysemu/device_tree.h"
>  #include "sysemu/numa.h"
> diff --git a/hw/arm/z2.c b/hw/arm/z2.c
> index 697a822f1e..7afa352a96 100644
> --- 

Re: [Qemu-devel] [PATCH 3/3] hw/ppc/prep: Drop useless inclusion of "hw/i386/pc.h"

2019-02-04 Thread David Gibson
On Mon, Feb 04, 2019 at 10:11:07PM +0100, Hervé Poussineau wrote:
> Le 04/02/2019 à 22:04, Philippe Mathieu-Daudé a écrit :
> > In 47973a2dbf we split the last generic chipset out of the PC
> > board, but forgot to remove the include of "hw/i386/pc.h".
> > Since it is now unused, remove it.
> > 
> > Signed-off-by: Philippe Mathieu-Daudé 
> 
> Reviewed-by: Hervé Poussineau 

Applied to ppc-for-4.0, thanks.

-- 
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


[Qemu-devel] [PATCH] configure: Avoid non-portable 'test -o/-a'

2019-02-04 Thread Eric Blake
POSIX says that it is better to use &&/|| and two separate test
invocations than it is to try and use -a and -o (in fact, there
are some tests that are inherently ambiguous to parse if the
user passes in corner-case input like "(").

Since we cannot guarantee which shell runs configure, we cannot
rely on -o/-a always following bash's parser rules.

Signed-off-by: Eric Blake 
---
 configure | 63 +--
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/configure b/configure
index 3d89870d996..61bc70708e4 100755
--- a/configure
+++ b/configure
@@ -1834,8 +1834,8 @@ fi
 # Consult white-list to determine whether to enable werror
 # by default.  Only enable by default for git builds
 if test -z "$werror" ; then
-if test -d "$source_path/.git" -a \
-\( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
+if test -d "$source_path/.git" && \
+{ test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
 werror="yes"
 else
 werror="no"
@@ -2940,7 +2940,7 @@ EOF
 sdl=yes

 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
-if test "$sdl" = "yes" -a "$static" = "yes" ; then
+if test "$sdl" = "yes" && test "$static" = "yes" ; then
   if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
  sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
  sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
@@ -3082,7 +3082,7 @@ fi

 ##
 # VNC SASL detection
-if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
+if test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
   cat > $TMPC <
 #include 
@@ -3105,7 +3105,7 @@ fi

 ##
 # VNC JPEG detection
-if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
+if test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
 cat > $TMPC <
 #include 
@@ -3127,7 +3127,7 @@ fi

 ##
 # VNC PNG detection
-if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
+if test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
 cat > $TMPC <
 #include 
@@ -3491,7 +3491,7 @@ fi
 # This workaround is required due to a bug in pkg-config file for glib as it
 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static

-if test "$static" = yes -a "$mingw32" = yes; then
+if test "$static" = yes && test "$mingw32" = yes; then
 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
 fi

@@ -3584,7 +3584,7 @@ fi
 ##
 # pixman support probe

-if test "$want_tools" = "no" -a "$softmmu" = "no"; then
+if test "$want_tools" = "no" && test "$softmmu" = "no"; then
   pixman_cflags=
   pixman_libs=
 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
@@ -3699,7 +3699,7 @@ else
   done
 fi

-if test "$mingw32" != yes -a "$pthread" = no; then
+if test "$mingw32" != yes && test "$pthread" = no; then
   error_exit "pthread check failed" \
   "Make sure to have the pthread libs and headers installed."
 fi
@@ -3826,7 +3826,7 @@ fi
 ##
 # TPM passthrough is only on x86 Linux

-if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
+if test "$targetos" = Linux && { test "$cpu" = i386 || test "$cpu" = x86_64; 
}; then
   tpm_passthrough=$tpm
 else
   tpm_passthrough=no
@@ -3992,7 +3992,7 @@ EOF
   fi
 fi

-if test "$opengl" = "yes" -a "$have_x11" = "yes"; then
+if test "$opengl" = "yes" && test "$have_x11" = "yes"; then
   for target in $target_list; do
 case $target in
   lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
@@ -4612,8 +4612,8 @@ elif compile_prog "" "$pthread_lib -lrt" ; then
   libs_qga="$libs_qga -lrt"
 fi

-if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
-"$haiku" != "yes" ; then
+if test "$darwin" != "yes" && test "$mingw32" != "yes" && \
+test "$solaris" != yes && test "$haiku" != "yes" ; then
 libs_softmmu="-lutil $libs_softmmu"
 fi

@@ -4688,7 +4688,8 @@ fi
 ##
 # check if we have VSS SDK headers for win

-if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != 
"no" ; then
+if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
+test "$vss_win32_sdk" != "no" ; then
   case "$vss_win32_sdk" in
 "")   vss_win32_include="-isystem $source_path" ;;
 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
@@ -4727,7 +4728,8 @@ fi
 # VSS provider from the source. It is usually unnecessary because the
 # pre-compiled .tlb file is included.

-if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a 
"$guest_agent_with_vss" = "yes" ; then
+if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
+test "$guest_agent_with_vss" = "yes" ; then
   if test -z "$win_sdk"; then
 programfiles="$PROGRAMFILES"
 test -n 

[Qemu-devel] [PATCH v3] checkpatch: Flag suspicious attribution lines

2019-02-04 Thread Eric Blake
Flag commit attribution tags that are unusual (often because they
were a typo), but only as a warning (because sometimes a humorous
or otherwise useful tag is intentionally supplied).

This picks the 6 most popular tags, each with 700 or more uses (well,
S-o-b was already checked for case-sensitivity and typos, leaving
only 5 new tags being checked), as determined by:
$ git log | sed -n 's/^ *\([A-Za-z-]*-[bB][yY]:\).*/\1/p' | \
  sort | uniq -c | sort -k1,1n | tail

Most of the rejected lines were unusual case (48 Reviewed-By), or
obvious typos (among others, we've had 4 cases of someone being
burnt, based on Singed-off-by; and 2 cases of list-reading via an
e-reader, based on eviewed-by); there are also lines forgetting a
space after the ':') or otherwise tongue-in-check (my favorite:
3 Approximately-suggested-by). A few lines not whitelisted here
may be legitimate, but as they are orders of magnitude rarer, it
is therefore not worth worrying about (7 Requested-by,
3 Co-authored-by, 1 Inspired-by, etc.).

Signed-off-by: Eric Blake 

---
v3: also flag *-By [Philippe]
v2: fix regex
---
 scripts/checkpatch.pl | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88682cb0a9f..e1aef5ba897 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1456,7 +1456,7 @@ sub process {
ERROR("Author email address is mangled by the mailing 
list\n" . $herecurr);
}

-#check the patch for a signoff:
+#check the patch for a signoff, and that other attribution lines are typical:
if ($line =~ /^\s*signed-off-by:/i) {
# This is a signoff, if ugly, so do not double report.
$signoff++;
@@ -1470,6 +1470,10 @@ sub process {
ERROR("space required after Signed-off-by:\n" .
$herecurr);
}
+   } elsif($line =~ /^\s*([a-z-]*)-by:/i &&
+   ($1 !~ /(Suggest|Report|Test|Ack|Review)ed/ ||
+$line !~ /^\s*[A-Za-z-]*-by:\s/)) {
+   WARN("suspicious attribution tag:\n" . $herecurr);
}

 # Check if MAINTAINERS is being updated.  If so, there's probably no need to
-- 
2.20.1




Re: [Qemu-devel] [PATCH v2] checkpatch: Flag suspicious attribution lines

2019-02-04 Thread Eric Blake
On 2/4/19 5:29 PM, Philippe Mathieu-Daudé wrote:
> On 2/4/19 11:55 PM, Eric Blake wrote:
>> Flag commit attribution tags that are unusual (often because they
>> were a typo), but only as a warning (because sometimes a humorous
>> or otherwise useful tag is intentionally supplied).
>>
>> This picks the 6-most popular tags, each with 700 or more uses (well,
>> S-o-b was already checked for case-sensitivity and typos, leaving
>> only 5 new tags being checked), as determined by:
>> $ git log | sed -n 's/^ *\([A-Za-z-]*-by:\).*/\1/p' | \
>>   sort | uniq -c | sort -k1,1n | tail

Use of [bB][yY] finds a few more interesting spellings...

>>
>> Most of the rejected lines were obvious typos (among others, we've
>> had 4 cases of someone being burnt, based on Singed-off-by; and 2
>> cases of list-reading via an e-reader, based on eviewed-by; there
>> are also lines forgetting a space after the ':') or otherwise
>> tongue-in-check (3 Approximately-suggested-by). A few lines not
>> whitelisted here may be legitimate, but as they are orders of
>> magnitude rarer, it is therefore not worth worrying about
>> (7 Requested-by, 3 Co-authored-by, 1 Inspired-by, etc.).

Among others, 48 Reviewed-By.


>> @@ -1470,6 +1470,10 @@ sub process {
>>  ERROR("space required after Signed-off-by:\n" .
>>  $herecurr);
>>  }
>> +} elsif($line =~ /^\s*([A-Za-z-]*)-by:/ &&
> 
> I guess we don't mind about angry typewriters who Ack-BY ;)

I can send a v3 that makes this line case-insensitive,

> 
>> +($1 !~ /(Suggest|Report|Test|Ack|Review)ed/ ||
>> + $line !~ /^\s*[a-z-]*-by:\s/i)) {

although making this line require lower-case '-by' gets a bit trickier.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PULL 00/25] pci, pc, virtio: fixes, cleanups, features

2019-02-04 Thread Michael S. Tsirkin
On Mon, Feb 04, 2019 at 05:59:16PM +, Peter Maydell wrote:
> On Mon, 4 Feb 2019 at 14:43, Michael S. Tsirkin  wrote:
> >
> > The following changes since commit b3fc0af1ff5e922d4dd7c875394dbd26dc7313b4:
> >
> >   Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into 
> > staging (2019-02-01 17:58:27 +)
> >
> > are available in the Git repository at:
> >
> >   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
> >
> > for you to fetch changes up to 5feab30ea98e30446361d184331b7b5ff94b4116:
> >
> >   contrib/libvhost-user: cleanup casts (2019-02-04 09:23:56 -0500)
> >
> > 
> > pci, pc, virtio: fixes, cleanups, features
> >
> > vhost user blk discard/write zeroes features
> > misc cleanups and fixes all over the place
> >
> > Signed-off-by: Michael S. Tsirkin 
> 
> Hi; I'm afraid this failed build/test on various platforms.
> 
> 
> Format string issues on ppc64 host:
> 
> /home/pm215/qemu/contrib/libvhost-user/libvhost-user.c: In function
> ‘vu_set_mem_table_exec_postcopy’:
> /home/pm215/qemu/contrib/libvhost-user/libvhost-user.c:636:9: error:
> format ‘%llx’ expects argument of type ‘long long unsigned int’, but
> argument 5 has type ‘__u64’ [-Werror=format=]
>  DPRINT("%s: region %d: Registered userfault for %llx + %llx\n",
>  ^
> /home/pm215/qemu/contrib/libvhost-user/libvhost-user.c:636:9: error:
> format ‘%llx’ expects argument of type ‘long long unsigned int’, but
> argument 6 has type ‘__u64’ [-Werror=format=]

So I think I fixed the build errors. And who knows maybe
that will fix the runtime ones somehow ..
Could you try pls? Re-pushed to same tag.

-- 
MST



Re: [Qemu-devel] [PULL 00/25] pci, pc, virtio: fixes, cleanups, features

2019-02-04 Thread Michael S. Tsirkin
On Mon, Feb 04, 2019 at 05:59:16PM +, Peter Maydell wrote:
> On Mon, 4 Feb 2019 at 14:43, Michael S. Tsirkin  wrote:
> >
> > The following changes since commit b3fc0af1ff5e922d4dd7c875394dbd26dc7313b4:
> >
> >   Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into 
> > staging (2019-02-01 17:58:27 +)
> >
> > are available in the Git repository at:
> >
> >   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
> >
> > for you to fetch changes up to 5feab30ea98e30446361d184331b7b5ff94b4116:
> >
> >   contrib/libvhost-user: cleanup casts (2019-02-04 09:23:56 -0500)
> >
> > 
> > pci, pc, virtio: fixes, cleanups, features
> >
> > vhost user blk discard/write zeroes features
> > misc cleanups and fixes all over the place
> >
> > Signed-off-by: Michael S. Tsirkin 
> 
> Hi; I'm afraid this failed build/test on various platforms.
> 


...


> 
> Test failures on sparc host due to an assert:
> 
> ERROR:/home/pm215/qemu/tests/vhost-user-test.c:243:wait_for_fds:
> assertion failed: (s->fds_num)
> Aborted
> 
> and the same on s390x, with a bit more detail:
> 
> MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}
> QTEST_QEMU_BINARY=i386-softmmu/qemu-system-i386
> QTEST_QEMU_IMG=qemu-img tests/vhost-user-test -m=quick -k --tap <
> /dev/null | ./scripts/tap-driver.pl --test-name="vhost-user-test"
> qemu-system-i386: backend does not support LE vnet headers; falling
> back on userspace virtio
> qemu-system-i386: backend does not support LE vnet headers; falling
> back on userspace virtio
> **
> ERROR:/home/linux1/qemu/tests/vhost-user-test.c:243:wait_for_fds:
> assertion failed: (s->fds_num)
> Aborted (core dumped)
> ERROR - too few tests run (expected 4, got 0)
> /home/linux1/qemu/tests/Makefile.include:858: recipe for target
> 'check-qtest-i386' failed


Cornelia do you happen to have a system where you can help
me debug this?

-- 
MST



Re: [Qemu-devel] [PULL 15/25] contrib: compile vhost-user-blk tool by default

2019-02-04 Thread Michael S. Tsirkin
On Mon, Feb 04, 2019 at 03:29:21PM +, Daniel P. Berrangé wrote:
> On Mon, Feb 04, 2019 at 10:19:42AM -0500, Michael S. Tsirkin wrote:
> > Hmm I do think we want to build the contrib tools,
> > otherwise they bitrot too quickly, witness follow-up
> > patches that fix the compilation.
> > 
> > And I think we need tests that actually use them.
> > 
> > However I agree adding them to tools and installing
> > is probably rushing things, e.g. there's no
> > manpage even.
> 
> Yes, if we build, but do not install, the binary that would be ok
> 
> 
> Regards,
> Daniel

OK I reverted this for now.

> -- 
> |: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o-https://fstop138.berrange.com :|
> |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



Re: [Qemu-devel] [PATCH v5 3/6] libvhost-user: Support tracking inflight I/O in shared memory

2019-02-04 Thread Yongji Xie
On Fri, 1 Feb 2019 at 10:28, Jason Wang  wrote:
>
>
> On 2019/1/30 下午1:48, Yongji Xie wrote:
> > On Wed, 30 Jan 2019 at 10:32, Jason Wang  wrote:
> >>
> >> On 2019/1/22 下午4:31, elohi...@gmail.com wrote:
> >>> +static int
> >>> +vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx)
> >>> +{
> >>> +if (!has_feature(dev->protocol_features,
> >>> +VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
> >>> +return 0;
> >>> +}
> >>> +
> >>> +if (unlikely(!vq->inflight)) {
> >>> +return -1;
> >>> +}
> >>> +
> >>> +vq->inflight->desc[desc_idx].inuse = 1;
> >>> +
> >>> +vq->inflight->desc[desc_idx].avail_idx = vq->last_avail_idx;
> >>> +
> >>> +return 0;
> >>> +}
> >>> +
> >>> +static int
> >>> +vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx)
> >>> +{
> >>> +if (!has_feature(dev->protocol_features,
> >>> +VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) {
> >>> +return 0;
> >>> +}
> >>> +
> >>> +if (unlikely(!vq->inflight)) {
> >>> +return -1;
> >>> +}
> >>> +
> >>> +vq->inflight->desc[desc_idx].used_idx = vq->used_idx;
> >>> +
> >>> +barrier();
> >>> +
> >>> +vq->inflight->desc[desc_idx].version++;
> >>> +
> >>> +return 0;
> >>> +}
> >>
> >> You probably need WRITE_ONCE() semantic (e.g volatile) to make sure the
> >> value reach memory.
> >>
> > The cache line should have been flushed during crash. So we can see
> > the correct value when backend reconnecting. If so, compile barrier
> > should be enough here, right?
>
>
> Maybe I worry too much but it's not about flushing cache, but about
> whether or not compiler can generate mov to memory instead of mov to
> registers.
>

OK, I see. I will declare those variables as volatile in v6. Thank you.

Thanks,
Yongji



Re: [Qemu-devel] [PATCH v3 8/8] RFC iotests: Disable 236 and 238 on OpenBSD

2019-02-04 Thread John Snow



On 2/4/19 7:18 PM, Philippe Mathieu-Daudé wrote:
> These tests explode on OpenBSD:
> 
>   $ gmake check-block
>   [...]
>   238[17:16:09] [17:16:09] [failed, exit status 1] - output 
> mismatch (see 238.out.bad)
>   --- /tmp/qemu-test.VKNS07/tests/qemu-iotests/238.outTue Jan 29 17:09:03 
> 2019
>   +++ /tmp/qemu-test.VKNS07/tests/qemu-iotests/238.out.badTue Jan 29 
> 17:16:09 2019
>   @@ -1,6 +1,14 @@
>   -{"return": {}}
>   -{"return": {}}
>   -{"return": {}}
>   -{"return": {}}
>   -{"return": {}}
>   -{"return": {}}
>   +Traceback (most recent call last):
>   +  File "238", line 37, in 
>   +vm.launch()
>   +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qemu.py", 
> line 295, in launch
>   +self._launch()
>   +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qemu.py", 
> line 321, in _launch
>   +self._post_launch()
>   +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qemu.py", 
> line 266, in _post_launch
>   +self._qmp.accept()
>   +  File 
> "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 
> 157, in accept
>   +return self.__negotiate_capabilities()
>   +  File 
> "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qmp/qmp.py", line 73, 
> in __negotiate_capabilities
>   +raise QMPConnectError
>   +qmp.qmp.QMPConnectError
> 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> This might be due to these tests requiring KVM?...
> Maybe we need a has_kvm argument to iotests.verify_platform()?

Uhhh, 236 shouldn't be doing anything fancy. It does boot a VM, but so
does 237, 222, 219, 218, 216, ...

I actually don't know what this would be failing. Any chance to look at
the core dump QEMU is leaving behind?

> ---
>  tests/qemu-iotests/236 | 1 +
>  tests/qemu-iotests/238 | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/tests/qemu-iotests/236 b/tests/qemu-iotests/236
> index 79a6381f8e..b98df35ca4 100755
> --- a/tests/qemu-iotests/236
> +++ b/tests/qemu-iotests/236
> @@ -23,6 +23,7 @@ import iotests
>  from iotests import log
>  
>  iotests.verify_image_format(supported_fmts=['generic'])
> +iotests.verify_platform(unsupported_oses=['openbsd']) # FIXME
>  size = 64 * 1024 * 1024
>  granularity = 64 * 1024
>  
> diff --git a/tests/qemu-iotests/238 b/tests/qemu-iotests/238
> index f81ee1112f..c62ff9a6dc 100755
> --- a/tests/qemu-iotests/238
> +++ b/tests/qemu-iotests/238
> @@ -23,6 +23,8 @@ import os
>  import iotests
>  from iotests import log
>  
> +iotests.verify_platform(unsupported_oses=['openbsd']) # FIXME
> +
>  sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 
> 'scripts'))
>  
>  from qemu import QEMUMachine
> 



Re: [Qemu-devel] [PATCH v3 0/8] OpenBSD: Block layer fixes (was 'Enable qtesting')

2019-02-04 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20190205001835.25660-1-phi...@redhat.com/



Hi,

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

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




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

[Qemu-devel] [PATCH v3 1/8] ahci-test: Add dependency to qemu-img tool

2019-02-04 Thread Philippe Mathieu-Daudé
Since the ahci-test uses qemu-img, add a dependency to build it
before using it.
This fixes:

  $ gmake check-qtest V=1
  QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img 
tests/ahci-test
  Failed to execute child process "/tmp/qemu-test.19tMRF/qemu-img" (No such 
file or directory)
  ERROR:tests/libqos/libqos.c:192:mkimg: assertion failed: (ret && !err)

Reviewed-by: John Snow 
Signed-off-by: Philippe Mathieu-Daudé 
---
Slighly related is when vm-tests expect qemu-img available:
https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg08415.html

  $ make vm-build-ubuntu.i386
  Traceback (most recent call last):
File "source/qemu/tests/vm/basevm.py", line 236, in main
  return vm.build_image(args.image)
File "tests/vm/ubuntu.i386", line 67, in build_image
  subprocess.check_call(["qemu-img", "resize", img_tmp, "50G"])
  OSError: [Errno 2] No such file or directory
  tests/vm/Makefile.include:23: recipe for target 'tests/vm/ubuntu.i386.img' 
failed
  make: *** [tests/vm/ubuntu.i386.img] Error 2

A better fix would be checking those tools via ./configure...
---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 75ad9c0dd3..679656b64a 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -708,7 +708,7 @@ tests/prom-env-test$(EXESUF): tests/prom-env-test.o 
$(libqos-obj-y)
 tests/rtas-test$(EXESUF): tests/rtas-test.o $(libqos-spapr-obj-y)
 tests/fdc-test$(EXESUF): tests/fdc-test.o
 tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y)
-tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y)
+tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y) 
qemu-img$(EXESUF)
 tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o
 tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o
 tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
-- 
2.20.1




[Qemu-devel] [PATCH v3 6/8] RFC iotests: Disable 208 on OpenBSD

2019-02-04 Thread Philippe Mathieu-Daudé
This test explodes on OpenBSD:

  $ gmake check-block
  [...]
  208[14:46:03] [14:46:03] [failed, exit status 1] - output 
mismatch (see 208.out.bad)
  --- /tmp/qemu-test.9cUFe0/tests/qemu-iotests/208.outTue Jan 29 13:33:43 
2019
  +++ /tmp/qemu-test.9cUFe0/tests/qemu-iotests/208.out.badTue Jan 29 
14:46:03 2019
  @@ -1,9 +1,23 @@
  +WARNING:qemu:qemu received signal 9: 
/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../x86_64-softmmu/qemu-system-x86_64
 -chardev 
socket,id=mon,path=/tmp/qemu-iotests-quick-38268/tmpjdovgo/qemu-66480-monitor.sock
 -mon chardev=mon,mode=control -display none -vga none -qtest 
unix:path=/tmp/qemu-iotests-quick-38268/qemu-66480-qtest.sock -machine 
accel=qtest -nodefaults -machine accel=qtest -drive 
if=none,id=drive0,file=/tmp/qemu-iotests-quick-38268/66480-disk.img,format=qcow2,cache=writeback,node-name=drive0-node
  +WARNING:qemu:qemu received signal 9: 
/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../x86_64-softmmu/qemu-system-x86_64
 -chardev 
socket,id=mon,path=/tmp/qemu-iotests-quick-38268/tmpjdovgo/qemu-66480-monitor.sock
 -mon chardev=mon,mode=control -display none -vga none -qtest 
unix:path=/tmp/qemu-iotests-quick-38268/qemu-66480-qtest.sock -machine 
accel=qtest -nodefaults -machine accel=qtest -drive 
if=none,id=drive0,file=/tmp/qemu-iotests-quick-38268/66480-disk.img,format=qcow2,cache=writeback,node-name=drive0-node
   Launching VM...
  -Starting NBD server...
  -{"return": {}}
  -Adding NBD export...
  -{"return": {}}
  -Creating external snapshot...
  -{"return": {}}
  -Stopping NBD server...
  -{"return": {}}
  +Traceback (most recent call last):
  +  File "208", line 36, in 
  +(vm.add_drive(disk_img_path, 'node-name=drive0-node', interface='none')
  +  File "/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../scripts/qemu.py", 
line 295, in launch
  +self._launch()
  +  File "/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../scripts/qemu.py", 
line 321, in _launch
  +self._post_launch()
  +  File "/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../scripts/qtest.py", 
line 100, in _post_launch
  +super(QEMUQtestMachine, self)._post_launch()
  +  File "/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../scripts/qemu.py", 
line 266, in _post_launch
  +self._qmp.accept()
  +  File "/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../scripts/qmp/qmp.py", 
line 157, in accept
  +return self.__negotiate_capabilities()
  +  File "/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../scripts/qmp/qmp.py", 
line 71, in __negotiate_capabilities
  +greeting = self.__json_read()
  +  File "/tmp/qemu-test.9cUFe0/tests/qemu-iotests/../../scripts/qmp/qmp.py", 
line 82, in __json_read
  +data = self.__sockfile.readline()
  +  File "/usr/local/lib/python2.7/socket.py", line 451, in readline
  +data = self._sock.recv(self._rbufsize)
  +socket.error: [Errno 35] Resource temporarily unavailable

Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/qemu-iotests/208 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qemu-iotests/208 b/tests/qemu-iotests/208
index 1e202388dc..2a13259fe4 100755
--- a/tests/qemu-iotests/208
+++ b/tests/qemu-iotests/208
@@ -23,6 +23,7 @@
 import iotests
 
 iotests.verify_image_format(supported_fmts=['generic'])
+iotests.verify_platform(unsupported_oses=['openbsd']) # FIXME
 
 with iotests.FilePath('disk.img') as disk_img_path, \
  iotests.FilePath('disk-snapshot.img') as disk_snapshot_img_path, \
-- 
2.20.1




[Qemu-devel] [PATCH v3 5/8] iotests: Let verify_platform() check for unsupported platforms

2019-02-04 Thread Philippe Mathieu-Daudé
Instead of checking for a supported platforms, it might be useful
to test for the opposite.

Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/qemu-iotests/iotests.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index b461f53abf..2ed34da9f5 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -712,9 +712,11 @@ def verify_protocol(supported=[], unsupported=[]):
 if not_sup or (imgproto in unsupported):
 notrun('not suitable for this protocol: %s' % imgproto)
 
-def verify_platform(supported_oses=['linux']):
+def verify_platform(supported_oses=['linux'], unsupported_oses=[]):
 if True not in [sys.platform.startswith(x) for x in supported_oses]:
 notrun('not suitable for this OS: %s' % sys.platform)
+if True in [sys.platform.startswith(x) for x in unsupported_oses]:
+notrun('not suitable for this OS: %s' % sys.platform)
 
 def verify_cache_mode(supported_cache_modes=[]):
 if supported_cache_modes and (cachemode not in supported_cache_modes):
-- 
2.20.1




Re: [Qemu-devel] [PATCH v3 4/5] tests/uefi-test-tools: add build scripts

2019-02-04 Thread Philippe Mathieu-Daudé
On 2/4/19 10:55 PM, Michael S. Tsirkin wrote:
> On Mon, Feb 04, 2019 at 08:46:33PM +0100, Philippe Mathieu-Daudé wrote:
>> On 2/4/19 8:32 PM,  Michael S. Tsirkin wrote:
>>> On Mon, Feb 04, 2019 at 07:41:38PM +0100, Laszlo Ersek wrote:
 On 02/04/19 18:47, Michael S. Tsirkin wrote:
> On Mon, Feb 04, 2019 at 05:03:24PM +0100, Laszlo Ersek wrote:
>> Introduce the following build scripts under "tests/uefi-test-tools":
[...]>> +# In turn, the "build" utility of edk2 BaseTools invokes
another "make".
>> +# Although the outer "make" process advertizes its job server to all 
>> child
>> +# processes via MAKEFLAGS in the environment, the outer "make" closes 
>> the job
>> +# server file descriptors (exposed in MAKEFLAGS) before executing a 
>> recipe --
>> +# unless the recipe is recognized as a recursive "make" recipe. Recipes 
>> that
>> +# call $(MAKE) are classified automatically as recursive; for 
>> "build.sh" below,
>> +# we must mark the recipe manually as recursive, by using the "+" 
>> indicator.
>> +# This way, when the inner "make" starts a parallel build of the target 
>> edk2
>> +# module, it can communicate with the outer "make"'s job server.
>> +Build/bios-tables-test.%.efi: build-edk2-tools
>> ++./build.sh $(edk2_dir) BiosTablesTest $* $@
>
> Does this actually work with an out of tree build?

 It's not supposed to.

 Again, it's not something that a normal QEMU build includes. It is only
 for maintainers to rebuild when there is a reason to do so. The output
 binaries are tracked by git, and will be used as-is (in binary form) by
 the ACPI test suite. If there are updates to the UEFI source code, the
 binaries will have to be rebuilt by a maintainer (or by me, if I submit
 the UEFI code changes), and the refreshed blobs are to be checked into
 git. Think iPXE oproms for an analogy.

> Shouldn't this be SRC_PATH/tests/uefi-test-tools/ ?

 No; nothing under roms/ is built like that, and the same applies to this
 patch as well.

 *Conceptually*, this patch is for roms/. However, in earlier discussion,
 it was suggested that roms/ be kept dedicated to external git submodules
 only, and that we not add such ROM source to roms/ whose master repo is
 genuinely the QEMU repo. Please see the sub-thread at:

   Re: [PATCH 10/14] tests: acpi: ignore SMBIOS tests when UEFI firmware is 
 used
   
 http://mid.mail-archive.com/20190116115217.jduhqrwbjhuibmoq@sirius.home.kraxel.org

 The last idea was that the UEFI source code should be kept in a direct
 subdirectory of tests/ (rather than in roms/). And the binaries should
 go under tests/data/uefi-boot-images/ (rather than pc-bios/).

 Thanks
 Laszlo
>>>
>>> Hmm I see. You see rebuild-expected-aml.sh does not work
>>> like this at all. It works fine with an out of tree build:
>>> check it out.
>>
>> But rebuild-expected-aml.sh does not depend of roms/.
> 
> It absolutely depends on pc-bios/bios.bin

Oh you are right!

I'm taking notes for an eventual future cleanup.

Regards,

Phil.



[Qemu-devel] [PATCH v3 8/8] RFC iotests: Disable 236 and 238 on OpenBSD

2019-02-04 Thread Philippe Mathieu-Daudé
These tests explode on OpenBSD:

  $ gmake check-block
  [...]
  238[17:16:09] [17:16:09] [failed, exit status 1] - output 
mismatch (see 238.out.bad)
  --- /tmp/qemu-test.VKNS07/tests/qemu-iotests/238.outTue Jan 29 17:09:03 
2019
  +++ /tmp/qemu-test.VKNS07/tests/qemu-iotests/238.out.badTue Jan 29 
17:16:09 2019
  @@ -1,6 +1,14 @@
  -{"return": {}}
  -{"return": {}}
  -{"return": {}}
  -{"return": {}}
  -{"return": {}}
  -{"return": {}}
  +Traceback (most recent call last):
  +  File "238", line 37, in 
  +vm.launch()
  +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qemu.py", 
line 295, in launch
  +self._launch()
  +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qemu.py", 
line 321, in _launch
  +self._post_launch()
  +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qemu.py", 
line 266, in _post_launch
  +self._qmp.accept()
  +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qmp/qmp.py", 
line 157, in accept
  +return self.__negotiate_capabilities()
  +  File "/tmp/qemu-test.VKNS07/tests/qemu-iotests/../../scripts/qmp/qmp.py", 
line 73, in __negotiate_capabilities
  +raise QMPConnectError
  +qmp.qmp.QMPConnectError

Signed-off-by: Philippe Mathieu-Daudé 
---
This might be due to these tests requiring KVM?...
Maybe we need a has_kvm argument to iotests.verify_platform()?
---
 tests/qemu-iotests/236 | 1 +
 tests/qemu-iotests/238 | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/tests/qemu-iotests/236 b/tests/qemu-iotests/236
index 79a6381f8e..b98df35ca4 100755
--- a/tests/qemu-iotests/236
+++ b/tests/qemu-iotests/236
@@ -23,6 +23,7 @@ import iotests
 from iotests import log
 
 iotests.verify_image_format(supported_fmts=['generic'])
+iotests.verify_platform(unsupported_oses=['openbsd']) # FIXME
 size = 64 * 1024 * 1024
 granularity = 64 * 1024
 
diff --git a/tests/qemu-iotests/238 b/tests/qemu-iotests/238
index f81ee1112f..c62ff9a6dc 100755
--- a/tests/qemu-iotests/238
+++ b/tests/qemu-iotests/238
@@ -23,6 +23,8 @@ import os
 import iotests
 from iotests import log
 
+iotests.verify_platform(unsupported_oses=['openbsd']) # FIXME
+
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'scripts'))
 
 from qemu import QEMUMachine
-- 
2.20.1




[Qemu-devel] [PATCH v3 0/8] OpenBSD: Block layer fixes (was 'Enable qtesting')

2019-02-04 Thread Philippe Mathieu-Daudé
Various fixes I encountered while trying to run QEMU test suite on OpenBSD.

This is the 'block' part of the v2.
Most non-RFC patches are reviewed and could be applied.

Since v2:
- Added R-b tags
- Addressed Eric's comments (in code and commit descriptions)

Since v1:
- various qemu-block fixes and notes.

Regards,

Phil.

v2: https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg07513.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg06676.html

Philippe Mathieu-Daudé (8):
  ahci-test: Add dependency to qemu-img tool
  qemu-iotests: Add dependency to qemu-nbd tool
  qemu-iotests: Improve portability by searching bash in the $PATH
  qemu-iotests: Ensure GNU sed is used
  iotests: Let verify_platform() check for unsupported platforms
  RFC iotests: Disable 208 on OpenBSD
  RFC iotests: Disable 209 on OpenBSD
  RFC iotests: Disable 236 and 238 on OpenBSD

 tests/Makefile.include|  4 ++--
 tests/qemu-iotests/001|  2 +-
 tests/qemu-iotests/002|  2 +-
 tests/qemu-iotests/003|  2 +-
 tests/qemu-iotests/004|  2 +-
 tests/qemu-iotests/005|  2 +-
 tests/qemu-iotests/007|  2 +-
 tests/qemu-iotests/008|  2 +-
 tests/qemu-iotests/009|  2 +-
 tests/qemu-iotests/010|  2 +-
 tests/qemu-iotests/011|  2 +-
 tests/qemu-iotests/012|  2 +-
 tests/qemu-iotests/013|  2 +-
 tests/qemu-iotests/014|  2 +-
 tests/qemu-iotests/015|  2 +-
 tests/qemu-iotests/017|  2 +-
 tests/qemu-iotests/018|  2 +-
 tests/qemu-iotests/019|  2 +-
 tests/qemu-iotests/020|  2 +-
 tests/qemu-iotests/021|  2 +-
 tests/qemu-iotests/022|  2 +-
 tests/qemu-iotests/023|  2 +-
 tests/qemu-iotests/024|  2 +-
 tests/qemu-iotests/025|  2 +-
 tests/qemu-iotests/026|  2 +-
 tests/qemu-iotests/027|  2 +-
 tests/qemu-iotests/028|  2 +-
 tests/qemu-iotests/029|  2 +-
 tests/qemu-iotests/031|  2 +-
 tests/qemu-iotests/032|  2 +-
 tests/qemu-iotests/033|  2 +-
 tests/qemu-iotests/034|  2 +-
 tests/qemu-iotests/035|  2 +-
 tests/qemu-iotests/036|  2 +-
 tests/qemu-iotests/037|  2 +-
 tests/qemu-iotests/038|  2 +-
 tests/qemu-iotests/039|  2 +-
 tests/qemu-iotests/042|  2 +-
 tests/qemu-iotests/043|  2 +-
 tests/qemu-iotests/046|  2 +-
 tests/qemu-iotests/047|  2 +-
 tests/qemu-iotests/048|  2 +-
 tests/qemu-iotests/049|  2 +-
 tests/qemu-iotests/050|  2 +-
 tests/qemu-iotests/051|  2 +-
 tests/qemu-iotests/052|  2 +-
 tests/qemu-iotests/053|  2 +-
 tests/qemu-iotests/054|  2 +-
 tests/qemu-iotests/058|  2 +-
 tests/qemu-iotests/059|  2 +-
 tests/qemu-iotests/060|  2 +-
 tests/qemu-iotests/061|  2 +-
 tests/qemu-iotests/062|  2 +-
 tests/qemu-iotests/063|  2 +-
 tests/qemu-iotests/064|  2 +-
 tests/qemu-iotests/066|  2 +-
 tests/qemu-iotests/067|  2 +-
 tests/qemu-iotests/068|  2 +-
 tests/qemu-iotests/069|  2 +-
 tests/qemu-iotests/070|  2 +-
 tests/qemu-iotests/071|  2 +-
 tests/qemu-iotests/072|  2 +-
 tests/qemu-iotests/073|  2 +-
 tests/qemu-iotests/074|  2 +-
 tests/qemu-iotests/075|  2 +-
 tests/qemu-iotests/076|  2 +-
 tests/qemu-iotests/077|  2 +-
 tests/qemu-iotests/078|  2 +-
 tests/qemu-iotests/079|  2 +-
 tests/qemu-iotests/080|  2 +-
 tests/qemu-iotests/081|  2 +-
 tests/qemu-iotests/082|  2 +-
 tests/qemu-iotests/083|  2 +-
 tests/qemu-iotests/084|  2 +-
 tests/qemu-iotests/085|  2 +-
 tests/qemu-iotests/086|  2 +-
 tests/qemu-iotests/087|  2 +-
 tests/qemu-iotests/088|  2 +-
 tests/qemu-iotests/089|  2 +-
 tests/qemu-iotests/090|  2 +-
 tests/qemu-iotests/091|  2 +-
 tests/qemu-iotests/092|  2 +-
 tests/qemu-iotests/094|  2 +-
 tests/qemu-iotests/095|  2 +-
 tests/qemu-iotests/097|  2 +-
 tests/qemu-iotests/098|  2 +-
 tests/qemu-iotests/099|  2 +-
 tests/qemu-iotests/101|  2 +-
 tests/qemu-iotests/102|  2 +-
 tests/qemu-iotests/103|  2 +-
 tests/qemu-iotests/104|  2 +-
 tests/qemu-iotests/105|  2 +-
 tests/qemu-iotests/106|  2 +-
 tests/qemu-iotests/107|  2 +-
 tests/qemu-iotests/108|  2 +-
 tests/qemu-iotests/109   

[Qemu-devel] [PATCH v3 4/8] qemu-iotests: Ensure GNU sed is used

2019-02-04 Thread Philippe Mathieu-Daudé
Various sed regexp from common.filter use sed GNU extensions.
Instead of spending time to write these regex to be POSIX compliant,
verify the GNU sed is available and use it.

Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/qemu-iotests/common.filter | 36 
 tests/qemu-iotests/common.rc | 13 
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index c282bc24f0..35fddc746f 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -23,37 +23,37 @@
 #
 _filter_date()
 {
-sed \
+$SED \
 -e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z]  *[0-9][0-9]* 
[0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
 }
 
 _filter_generated_node_ids()
 {
- sed -re 's/\#block[0-9]{3,}/NODE_NAME/'
+$SED -re 's/\#block[0-9]{3,}/NODE_NAME/'
 }
 
 _filter_qom_path()
 {
-sed -e 's#\(Attached to: *\) /.*#\1 PATH#'
+$SED -e 's#\(Attached to: *\) /.*#\1 PATH#'
 }
 
 # replace occurrences of the actual TEST_DIR value with TEST_DIR
 _filter_testdir()
 {
-sed -e "s#$TEST_DIR/#TEST_DIR/#g"
+$SED -e "s#$TEST_DIR/#TEST_DIR/#g"
 }
 
 # replace occurrences of the actual IMGFMT value with IMGFMT
 _filter_imgfmt()
 {
-sed -e "s#$IMGFMT#IMGFMT#g"
+$SED -e "s#$IMGFMT#IMGFMT#g"
 }
 
 # Replace error message when the format is not supported and delete
 # the output lines after the first one
 _filter_qemu_img_check()
 {
-sed -e '/allocated.*fragmented.*compressed clusters/d' \
+$SED -e '/allocated.*fragmented.*compressed clusters/d' \
 -e 's/qemu-img: This image format does not support checks/No errors 
were found on the image./' \
 -e '/Image end offset: [0-9]\+/d'
 }
@@ -61,13 +61,13 @@ _filter_qemu_img_check()
 # Removes \r from messages
 _filter_win32()
 {
-sed -e 's/\r//g'
+$SED -e 's/\r//g'
 }
 
 # sanitize qemu-io output
 _filter_qemu_io()
 {
-_filter_win32 | sed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* 
[EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX 
YYY\/sec and XXX ops\/sec)/" \
+_filter_win32 | $SED -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* 
[EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX 
YYY\/sec and XXX ops\/sec)/" \
 -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\| Killed\)/:\1/" \
 -e "s/qemu-io> //g"
 }
@@ -75,7 +75,7 @@ _filter_qemu_io()
 # replace occurrences of QEMU_PROG with "qemu"
 _filter_qemu()
 {
-sed -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
+$SED -e "s#\\(^\\|(qemu) \\)$(basename $QEMU_PROG):#\1QEMU_PROG:#" \
 -e 's#^QEMU [0-9]\+\.[0-9]\+\.[0-9]\+ monitor#QEMU X.Y.Z monitor#' \
 -e $'s#\r##' # QEMU monitor uses \r\n line endings
 }
@@ -84,7 +84,7 @@ _filter_qemu()
 _filter_qmp()
 {
 _filter_win32 | \
-sed -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
+$SED -e 's#\("\(micro\)\?seconds": \)[0-9]\+#\1 TIMESTAMP#g' \
 -e 's#^{"QMP":.*}$#QMP_VERSION#' \
 -e '/^"QMP": {\s*$/, /^}\s*$/ c\' \
 -e 'QMP_VERSION'
@@ -93,32 +93,32 @@ _filter_qmp()
 # readline makes HMP command strings so long that git complains
 _filter_hmp()
 {
-sed -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
+$SED -e $'s/^\\((qemu) \\)\\?.*\e\\[D/\\1/g' \
 -e $'s/\e\\[K//g'
 }
 
 # replace block job offset
 _filter_block_job_offset()
 {
-sed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
+$SED -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
 }
 
 # replace block job len
 _filter_block_job_len()
 {
-sed -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
+$SED -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
 }
 
 # replace actual image size (depends on the host filesystem)
 _filter_actual_image_size()
 {
-sed -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
+$SED -s 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
 }
 
 # replace driver-specific options in the "Formatting..." line
 _filter_img_create()
 {
-sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
+$SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
 -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
 -e "s#$TEST_DIR#TEST_DIR#g" \
 -e "s#$IMGFMT#IMGFMT#g" \
@@ -154,7 +154,7 @@ _filter_img_info()
 
 discard=0
 regex_json_spec_start='^ *"format-specific": \{'
-sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
+$SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \
 -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
 -e "s#$TEST_DIR#TEST_DIR#g" \
 -e "s#$IMGFMT#IMGFMT#g" \
@@ -201,7 +201,7 @@ _filter_img_info()
 # human and json output
 _filter_qemu_img_map()
 {
-sed -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
+$SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \
 -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \
 -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt
 }
@@ -213,7 +213,7 @@ _filter_nbd()
 # receive callbacks 

[Qemu-devel] [PATCH v3 7/8] RFC iotests: Disable 209 on OpenBSD

2019-02-04 Thread Philippe Mathieu-Daudé
This test simply hangs with no information on OpenBSD.

Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/qemu-iotests/209 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qemu-iotests/209 b/tests/qemu-iotests/209
index 259e991ec6..7eb41e4363 100755
--- a/tests/qemu-iotests/209
+++ b/tests/qemu-iotests/209
@@ -23,6 +23,7 @@ from iotests import qemu_img_create, qemu_io, 
qemu_img_verbose, qemu_nbd, \
 file_path
 
 iotests.verify_image_format(supported_fmts=['qcow2'])
+iotests.verify_platform(unsupported_oses=['openbsd']) # FIXME
 
 disk, nbd_sock = file_path('disk', 'nbd-sock')
 nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock
-- 
2.20.1




[Qemu-devel] [PATCH v3 3/8] qemu-iotests: Improve portability by searching bash in the $PATH

2019-02-04 Thread Philippe Mathieu-Daudé
Bash is not always installed as /bin/bash. In particular on OpenBSD,
the package installs it in /usr/local/bin.
Use the 'env' shebang to search bash in the $PATH.

Patch created mechanically by running:

  $ git grep -lE '#! ?/bin/bash' -- tests/qemu-iotests \
| while read f; do \
  sed -i 's|^#!.\?/bin/bash$|#!/usr/bin/env bash|' $f; \
done

Reviewed-by: Eric Blake 
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/qemu-iotests/001| 2 +-
 tests/qemu-iotests/002| 2 +-
 tests/qemu-iotests/003| 2 +-
 tests/qemu-iotests/004| 2 +-
 tests/qemu-iotests/005| 2 +-
 tests/qemu-iotests/007| 2 +-
 tests/qemu-iotests/008| 2 +-
 tests/qemu-iotests/009| 2 +-
 tests/qemu-iotests/010| 2 +-
 tests/qemu-iotests/011| 2 +-
 tests/qemu-iotests/012| 2 +-
 tests/qemu-iotests/013| 2 +-
 tests/qemu-iotests/014| 2 +-
 tests/qemu-iotests/015| 2 +-
 tests/qemu-iotests/017| 2 +-
 tests/qemu-iotests/018| 2 +-
 tests/qemu-iotests/019| 2 +-
 tests/qemu-iotests/020| 2 +-
 tests/qemu-iotests/021| 2 +-
 tests/qemu-iotests/022| 2 +-
 tests/qemu-iotests/023| 2 +-
 tests/qemu-iotests/024| 2 +-
 tests/qemu-iotests/025| 2 +-
 tests/qemu-iotests/026| 2 +-
 tests/qemu-iotests/027| 2 +-
 tests/qemu-iotests/028| 2 +-
 tests/qemu-iotests/029| 2 +-
 tests/qemu-iotests/031| 2 +-
 tests/qemu-iotests/032| 2 +-
 tests/qemu-iotests/033| 2 +-
 tests/qemu-iotests/034| 2 +-
 tests/qemu-iotests/035| 2 +-
 tests/qemu-iotests/036| 2 +-
 tests/qemu-iotests/037| 2 +-
 tests/qemu-iotests/038| 2 +-
 tests/qemu-iotests/039| 2 +-
 tests/qemu-iotests/042| 2 +-
 tests/qemu-iotests/043| 2 +-
 tests/qemu-iotests/046| 2 +-
 tests/qemu-iotests/047| 2 +-
 tests/qemu-iotests/048| 2 +-
 tests/qemu-iotests/049| 2 +-
 tests/qemu-iotests/050| 2 +-
 tests/qemu-iotests/051| 2 +-
 tests/qemu-iotests/052| 2 +-
 tests/qemu-iotests/053| 2 +-
 tests/qemu-iotests/054| 2 +-
 tests/qemu-iotests/058| 2 +-
 tests/qemu-iotests/059| 2 +-
 tests/qemu-iotests/060| 2 +-
 tests/qemu-iotests/061| 2 +-
 tests/qemu-iotests/062| 2 +-
 tests/qemu-iotests/063| 2 +-
 tests/qemu-iotests/064| 2 +-
 tests/qemu-iotests/066| 2 +-
 tests/qemu-iotests/067| 2 +-
 tests/qemu-iotests/068| 2 +-
 tests/qemu-iotests/069| 2 +-
 tests/qemu-iotests/070| 2 +-
 tests/qemu-iotests/071| 2 +-
 tests/qemu-iotests/072| 2 +-
 tests/qemu-iotests/073| 2 +-
 tests/qemu-iotests/074| 2 +-
 tests/qemu-iotests/075| 2 +-
 tests/qemu-iotests/076| 2 +-
 tests/qemu-iotests/077| 2 +-
 tests/qemu-iotests/078| 2 +-
 tests/qemu-iotests/079| 2 +-
 tests/qemu-iotests/080| 2 +-
 tests/qemu-iotests/081| 2 +-
 tests/qemu-iotests/082| 2 +-
 tests/qemu-iotests/083| 2 +-
 tests/qemu-iotests/084| 2 +-
 tests/qemu-iotests/085| 2 +-
 tests/qemu-iotests/086| 2 +-
 tests/qemu-iotests/087| 2 +-
 tests/qemu-iotests/088| 2 +-
 tests/qemu-iotests/089| 2 +-
 tests/qemu-iotests/090| 2 +-
 tests/qemu-iotests/091| 2 +-
 tests/qemu-iotests/092| 2 +-
 tests/qemu-iotests/094| 2 +-
 tests/qemu-iotests/095| 2 +-
 tests/qemu-iotests/097| 2 +-
 tests/qemu-iotests/098| 2 +-
 tests/qemu-iotests/099| 2 +-
 tests/qemu-iotests/101| 2 +-
 tests/qemu-iotests/102| 2 +-
 tests/qemu-iotests/103| 2 +-
 tests/qemu-iotests/104| 2 +-
 tests/qemu-iotests/105| 2 +-
 tests/qemu-iotests/106| 2 +-
 tests/qemu-iotests/107| 2 +-
 tests/qemu-iotests/108| 2 +-
 tests/qemu-iotests/109| 2 +-
 tests/qemu-iotests/110| 2 +-
 tests/qemu-iotests/111| 2 +-
 tests/qemu-iotests/112| 2 +-
 tests/qemu-iotests/113| 2 +-
 tests/qemu-iotests/114| 2 +-
 tests/qemu-iotests/115| 2 +-
 tests/qemu-iotests/116| 2 +-
 tests/qemu-iotests/117| 2 +-
 tests/qemu-iotests/119| 2 +-
 tests/qemu-iotests/120| 2 +-
 tests/qemu-iotests/121| 2 +-
 tests/qemu-iotests/122| 2 +-
 tests/qemu-iotests/123| 2 +-
 tests/qemu-iotests/125| 

[Qemu-devel] [PATCH v3 2/8] qemu-iotests: Add dependency to qemu-nbd tool

2019-02-04 Thread Philippe Mathieu-Daudé
Since a9660664fde, some iotests use qemu-nbd.
Add a dependency to build it before using it.
This fixes:

  $ make check-block
GEN qemu-img-cmds.h
CC  qemu-img.o
LINKqemu-img
CC  qemu-io.o
LINKqemu-io
CC  tests/qemu-iotests/socket_scm_helper.o
LINKtests/qemu-iotests/socket_scm_helper
  tests/qemu-iotests-quick.sh
  check: qemu-nbd not found
  make: *** [tests/Makefile.include:1059: check-tests/qemu-iotests-quick.sh] 
Error 1

Reviewed-by: Eric Blake 
Signed-off-by: Philippe Mathieu-Daudé 
---
 tests/Makefile.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 679656b64a..c31b87a41f 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1057,7 +1057,7 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES)
 QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = 
tests/qemu-iotests/socket_scm_helper$(EXESUF)
 
 .PHONY: check-tests/qemu-iotests-quick.sh
-check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh 
qemu-img$(EXESUF) qemu-io$(EXESUF) $(QEMU_IOTESTS_HELPERS-y)
+check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh 
qemu-img$(EXESUF) qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y)
$<
 
 .PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
-- 
2.20.1




Re: [Qemu-devel] [Qemu-block] [PATCH v3] drive-mirror: add incremental mode

2019-02-04 Thread John Snow



On 1/31/19 7:17 AM, mahaocong wrote:
> From: mahaocong 
> 

Please use "git send-email" where possible, it will help keep the
formatting right. Use "RESEND" or "v4" when sending out a cover letter
revision, so the tools can see it as a new thread properly.

Sorry for the hassle!

> This patch adds possibility to start mirroring with user-created-bitmap.
> On full mode, mirror create a non-named-bitmap by scanning whole block-chain,
> and on top mode, mirror create a bitmap by scanning the top block layer. So I
> think I can copy a user-created-bitmap and use it as the initial state of the
> mirror, the same as incremental mode drive-backup, and I call this new mode
> as incremental mode drive-mirror.
> 

It makes sense by extension, yes.

> A possible usage scene of incremental mode mirror is live migration. For 
> maintain
> the block data and recover after a malfunction, someone may backup data to 
> ceph
> or other distributed storage. On qemu incremental backup, we need to create a 
> new
> bitmap and attach to block device before the first backup job. Then the bitmap
> records the change after the backup job. If we want to migration this vm, we 
> can
> migrate block data between source and destionation by using drive-mirror 
> directly,
> or use backup data and backup-bitmap to reduce the data should be synchronize.
> To do this, we should first create a new image in destination and set backing 
> file
> as backup image, then set backup-bitmap as the initial state of incremental 
> mode
> drive-mirror, and synchronize dirty block starting with the state set by the 
> last
> incremental backup job. When the mirror complete, we get an active layer on 
> destination,
> and its backing file is backup image on ceph. Then we can do live copy data 
> from
> backing files into overlay images by using block-stream, or do backup 
> continually.
> 
> In this scene, It seems that If the guest os doesn't write too many data 
> after the
> last backup, the incremental mode may transmit less data than full mode or top
> mode. However, if the write data is too many, there is no advantage on 
> incremental
> mode compare with other mode.
> 

It does seem very situational. I suppose there's no real harm in
allowing people to try it, though.

> This scene can be described as following steps:
> 1.create rbd image in ceph, and map nbd device with rbd image.
> 2.create a new bitmap and attach to block device.
> 3.do full mode backup on nbd device and thus sync it to the rbd image.
> 4.severl times incremental mode backup.
> 5.create new image in destination and set its backing file as backup image.
> 6.do live-migration, and migrate block data by incremental mode drive-mirror
>   with bitmap created from step 2.
> 
> Signed-off-by: Ma Haocong 
> ---
>  compare with old version, there are following changes:
>  1.replace the copy bitmap function by bdrv_merge_dirty_bitmap
>  2.remove checking for cancelled after mirror_dirty_init_incremental for 
> bitmap
>copyimg don't have yield point.
>  3.adjuest input parameters on mirror_start_job and mirror_start, and so It is
>no need to find bitmap on mirror_dirty_init_incremental again.
>  4.assert the bitmap name is NULL on blockdev_mirror_common.
>  5.change the parameter's name in qmp command 'drive-mirror' from 
> 'bitmap_name'
>to 'bitmap'.
>  6.change the discribe of parameter 'bitmap' in block-core.json.
> 
>  block/mirror.c| 46 ++
>  blockdev.c| 41 -
>  include/block/block_int.h |  3 ++-
>  qapi/block-core.json  |  7 ++-
>  4 files changed, 78 insertions(+), 19 deletions(-)
> 
> diff --git a/block/mirror.c b/block/mirror.c
> index ab59ad77e8..c59aefe9f0 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -50,6 +50,7 @@ typedef struct MirrorBlockJob {
>  /* Used to block operations on the drive-mirror-replace target */
>  Error *replace_blocker;
>  bool is_none_mode;
> +BdrvDirtyBitmap *src_bitmap;
>  BlockMirrorBackingMode backing_mode;
>  MirrorCopyMode copy_mode;
>  BlockdevOnError on_source_error, on_target_error;
> @@ -814,6 +815,15 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob 
> *s)
>  return 0;
>  }
>  
> +/*
> + * init dirty bitmap by using user bitmap. usr->hbitmap will be copy to
> + * mirror bitmap->hbitmap instead of reuse it.
> + */
> +static void coroutine_fn mirror_dirty_init_incremental(MirrorBlockJob *s, 
> Error **errp)
> +{
> +bdrv_merge_dirty_bitmap(s->dirty_bitmap, s->src_bitmap, NULL, errp);
> +}
> +
>  /* Called when going out of the streaming phase to flush the bulk of the
>   * data to the medium, or just before completing.
>   */
> @@ -839,6 +849,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
>  char backing_filename[2]; /* we only need 2 characters because we are 
> only
>   checking for a NULL string */
> 

Re: [Qemu-devel] [RFC PATCH v2 10/18] qemu-iotests: Ensure GNU sed is used

2019-02-04 Thread Philippe Mathieu-Daudé
On 1/29/19 11:21 PM, Eric Blake wrote:
> On 1/29/19 11:53 AM, Philippe Mathieu-Daudé wrote:
>> Various sed regexp from common.filter use sed GNU extensions.
>> Instead of spending time to write these regex to be POSIX compliant,
>> verify the GNU sed is available and use it.
>>
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>> I think the test isn't well placed in common.filter and should be in
>> common.rc, but couldn't get that working.
>> ---
> 
>> +++ b/tests/qemu-iotests/common.filter
>> @@ -23,37 +23,37 @@
>>  #
>>  _filter_date()
>>  {
>> -sed \
>> +${SED} \
> 
> I might have written $SED instead of ${SED}, but that's merely
> aesthetics and not a correctness issue.
> 
> 
>> +++ b/tests/qemu-iotests/common.rc
>> @@ -17,6 +17,18 @@
>>  # along with this program.  If not, see .
>>  #
>>  
> 
> If SED is inherited in the environment prior to this point,...
> 
>> +for sed in sed gsed; do
>> +(command $sed --version | grep 'GNU sed') > /dev/null 2>&1
> 
> Why do you need command here? (It doesn't hurt, but I also don't see how
> it helps).

I copy/pasted the 'dd' use in the same file :/

> 
>> +if [ "$?" -eq 0 ]; then
>> +SED=$sed
>> +break
>> +fi
>> +done
> 
> ...but neither sed nor gsed are GNU sed,
> 
>> +if [ -z "$SED" ]; then
>> +echo "$0: GNU sed not found"
>> +exit 1
>> +fi
> 
> ...then you fail to diagnose that. Fix it by adding SED= prior to the loop.

Good point, thanks!

Regards,

Phil.



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [qemu-s390x] [PATCH v2 2/6] s390x/pci: Fix hotplugging of PCI bridges

2019-02-04 Thread David Hildenbrand
On 04.02.19 23:48, Collin Walling wrote:
> On 1/30/19 10:57 AM, David Hildenbrand wrote:
>> When hotplugging a PCI bridge right now to the root port, we resolve
>> pci_get_bus(pdev)->parent_dev, which results in a SEGFAULT. Hotplugging
>> really only works right now when hotplugging to another bridge.
>>
>> Instead, we have to properly check if we are already at the root.
>>
>> Let's cleanup the code while at it a bit and factor out updating the
>> subordiante bus number into a separate function. The check for
> 
> s/subordiante/subordinate
> 
>> "old_nr < nr" is right now not strictly necessary, but makes it more
>> obvious what is actually going on.
>>
>> Most probably fixing up the topology is not our responsibility when
>> hotplugging. The guest has to sort this out. But let's keep it for now
>> and only fix current code to not crash.
>>
>> Reviewed-by: Thomas Huth 
>> Signed-off-by: David Hildenbrand 
>> ---
>>   hw/s390x/s390-pci-bus.c | 28 +++-
>>   1 file changed, 19 insertions(+), 9 deletions(-)
>>
>> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
>> index b7c4613fde..9b5c5fff60 100644
>> --- a/hw/s390x/s390-pci-bus.c
>> +++ b/hw/s390x/s390-pci-bus.c
>> @@ -843,6 +843,21 @@ static void s390_pcihost_pre_plug(HotplugHandler 
>> *hotplug_dev, DeviceState *dev,
>>   }
>>   }
>>   
>> +static void s390_pci_update_subordinate(PCIDevice *dev, uint32_t nr)
>> +{
>> +uint32_t old_nr;
>> +
>> +pci_default_write_config(dev, PCI_SUBORDINATE_BUS, nr, 1);
>> +while (!pci_bus_is_root(pci_get_bus(dev))) {
>> +dev = pci_get_bus(dev)->parent_dev;
>> +
>> +old_nr = pci_default_read_config(dev, PCI_SUBORDINATE_BUS, 1);
>> +if (old_nr < nr) {
>> +pci_default_write_config(dev, PCI_SUBORDINATE_BUS, nr, 1);
>> +}
>> +}
>> +} > +
>>   static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState 
>> *dev,
>> Error **errp)
>>   {
>> @@ -851,26 +866,21 @@ static void s390_pcihost_plug(HotplugHandler 
>> *hotplug_dev, DeviceState *dev,
>>   S390PCIBusDevice *pbdev = NULL;
>>   
>>   if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) {
>> -BusState *bus;
>>   PCIBridge *pb = PCI_BRIDGE(dev);
>> -PCIDevice *pdev = PCI_DEVICE(dev);
>>   
>> +pdev = PCI_DEVICE(dev);
>>   pci_bridge_map_irq(pb, dev->id, s390_pci_map_irq);
>>   pci_setup_iommu(>sec_bus, s390_pci_dma_iommu, s);
>>   
>> -bus = BUS(>sec_bus);
>> -qbus_set_hotplug_handler(bus, DEVICE(s), errp);
>> +qbus_set_hotplug_handler(BUS(>sec_bus), DEVICE(s), errp);
>>   
>>   if (dev->hotplugged) {
>>   pci_default_write_config(pdev, PCI_PRIMARY_BUS,
>>pci_dev_bus_num(pdev), 1);
>>   s->bus_no += 1;
>>   pci_default_write_config(pdev, PCI_SECONDARY_BUS, s->bus_no, 
>> 1);
>> -do {
>> -pdev = pci_get_bus(pdev)->parent_dev;
>> -pci_default_write_config(pdev, PCI_SUBORDINATE_BUS,
>> - s->bus_no, 1);
>> -} while (pci_get_bus(pdev) && pci_dev_bus_num(pdev));
>> +
>> +s390_pci_update_subordinate(pdev, s->bus_no);
>>   }
>>   } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
>>   pdev = PCI_DEVICE(dev);
>>
> 
> Looks good to me...
> 

Thanks for the review!!

> Reviewed-by: Collin Walling 
> 
> Side note: unrelated to the changes here -- and if you can clarify for
> me -- any idea why we do s->bus_no += 1? This throws me off a bit and
> begs me to ask what exactly is the S390pciState object suppose to
> represent? (My guess is that it is representative of the entire PCI
> topology, and we increment the bus_no to denote the subordinate bus
> number?)
On x86, the bios builds the topology. On spapr and s390x, the firmware
builds the topology. The topology is constructed in a way that all buses
can be found ("tree traversed") from the root.

In a clean topology, each bridge has it's dedicated number.

primary: The bus the bridge is attached to
secondary: The bus the bridge spans up
subordinate: The highest bus number that can be found from this bridge

So when we add a new bridge, we have to assign a new "global" bus number
for the topology. This is what we do here. So we denote actually the
"seconardy" bus nr here, which we propagate as "subordinate" up to the root.

But this is the interesting point: When hotplugging on x86 and on power,
the _guest_ is responsible for rebuilding the topology. Not the bios,
not the firmware. No numbers are assigned. Code like we have here does
not exist for them.


And most probably this is also broken on s390x: When hotplugging a
bridge, we should not mess with the topology (because as Thomas noted,
we can easily break the topology so the search does no longer work
reliably).

But this is your task to 

Re: [Qemu-devel] [PATCH] hw/input/tsc210x: Fix building with no verbosity

2019-02-04 Thread Philippe Mathieu-Daudé
On 2/4/19 9:49 PM, no-re...@patchew.org wrote:
> Patchew URL: 
> https://patchew.org/QEMU/20190204204517.23698-1-phi...@redhat.com/
> 
> This series failed the docker-mingw@fedora build test. Please find the 
> testing commands and
> their output below. If you have Docker installed, you can probably reproduce 
> it
> locally.
> 
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> time make docker-test-mingw@fedora SHOW_ENV=1 J=14
> === TEST SCRIPT END ===
> 
> The full log is available at
> http://patchew.org/logs/20190204204517.23698-1-phi...@redhat.com/testing.docker-mingw@fedora/?type=message.
> ---

Full log is weird:

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
>From https://github.com/patchew-project/qemu
 - [tag update]
patchew/20190117215300.29694-1-brijesh.si...@amd.com ->
patchew/20190117215300.29694-1-brijesh.si...@amd.com
fatal: Unable to create
'/home/patchew/.cache/patchew-git-cache/httpsgithubcompatchewprojectqemu-3c8cf5a9c21ff8782164d1def7f44bd888713384/refs/tags/patchew/20190204204517.23698-1-phi...@redhat.com.lock':
File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
Unexpected end of command stream
error: Could not fetch 3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
  File "patchew-tester/src/patchew-cli", line 521, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf, True)
  File "patchew-tester/src/patchew-cli", line 48, in git_clone_repo
stdout=logf, stderr=logf)
  File "/usr/lib64/python3.4/subprocess.py", line 558, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'remote', 'add', '-f',
'--mirror=fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384',
'https://github.com/patchew-project/qemu']' returned non-zero exit status 1



Re: [Qemu-devel] [PATCH v2] checkpatch: Flag suspicious attribution lines

2019-02-04 Thread Philippe Mathieu-Daudé
On 2/4/19 11:55 PM, Eric Blake wrote:
> Flag commit attribution tags that are unusual (often because they
> were a typo), but only as a warning (because sometimes a humorous
> or otherwise useful tag is intentionally supplied).
> 
> This picks the 6-most popular tags, each with 700 or more uses (well,
> S-o-b was already checked for case-sensitivity and typos, leaving
> only 5 new tags being checked), as determined by:
> $ git log | sed -n 's/^ *\([A-Za-z-]*-by:\).*/\1/p' | \
>   sort | uniq -c | sort -k1,1n | tail
> 
> Most of the rejected lines were obvious typos (among others, we've
> had 4 cases of someone being burnt, based on Singed-off-by; and 2
> cases of list-reading via an e-reader, based on eviewed-by; there
> are also lines forgetting a space after the ':') or otherwise
> tongue-in-check (3 Approximately-suggested-by). A few lines not
> whitelisted here may be legitimate, but as they are orders of
> magnitude rarer, it is therefore not worth worrying about
> (7 Requested-by, 3 Co-authored-by, 1 Inspired-by, etc.).

'Inspired-by' is kinda Zen :) And is from Peter!

> Signed-off-by: Eric Blake 
> ---
> 
> v2: fix regex
> 
>  scripts/checkpatch.pl | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 88682cb0a9f..4962f74eec1 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1456,7 +1456,7 @@ sub process {
>   ERROR("Author email address is mangled by the mailing 
> list\n" . $herecurr);
>   }
> 
> -#check the patch for a signoff:
> +#check the patch for a signoff, and that other attribution lines are typical:
>   if ($line =~ /^\s*signed-off-by:/i) {
>   # This is a signoff, if ugly, so do not double report.
>   $signoff++;
> @@ -1470,6 +1470,10 @@ sub process {
>   ERROR("space required after Signed-off-by:\n" .
>   $herecurr);
>   }
> + } elsif($line =~ /^\s*([A-Za-z-]*)-by:/ &&

I guess we don't mind about angry typewriters who Ack-BY ;)

> + ($1 !~ /(Suggest|Report|Test|Ack|Review)ed/ ||
> +  $line !~ /^\s*[a-z-]*-by:\s/i)) {

Reviewed-by: Philippe Mathieu-Daudé 

> + WARN("suspicious attribution tag:\n" . $herecurr);
>   }
> 
>  # Check if MAINTAINERS is being updated.  If so, there's probably no need to
> 



[Qemu-devel] [PATCH v2 07/11] hw/devices: Move TI touchscreen declarations into a new header

2019-02-04 Thread Philippe Mathieu-Daudé
Since uWireSlave is only used in this new header, there is no
need to expose it via "qemu/typedefs.h".

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS|  2 ++
 hw/arm/nseries.c   |  2 +-
 hw/arm/palm.c  |  2 +-
 hw/input/tsc2005.c |  2 +-
 hw/input/tsc210x.c |  4 ++--
 include/hw/arm/omap.h  |  6 +-
 include/hw/devices.h   | 15 ---
 include/hw/input/tsc2xxx.h | 38 ++
 include/qemu/typedefs.h|  1 -
 9 files changed, 46 insertions(+), 26 deletions(-)
 create mode 100644 include/hw/input/tsc2xxx.h

diff --git a/MAINTAINERS b/MAINTAINERS
index a38086f767..6b0b5ccb41 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -654,6 +654,7 @@ F: hw/input/tsc2005.c
 F: hw/misc/cbus.c
 F: hw/timer/twl92230.c
 F: include/hw/display/blizzard.h
+F: include/hw/input/tsc2xxx.h
 F: include/hw/misc/cbus.h
 
 Palm
@@ -663,6 +664,7 @@ L: qemu-...@nongnu.org
 S: Odd Fixes
 F: hw/arm/palm.c
 F: hw/input/tsc210x.c
+F: include/hw/input/tsc2xxx.h
 
 Raspberry Pi
 M: Peter Maydell 
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index ac876b5878..5ac2ca0877 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -30,8 +30,8 @@
 #include "ui/console.h"
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
-#include "hw/devices.h"
 #include "hw/display/blizzard.h"
+#include "hw/input/tsc2xxx.h"
 #include "hw/misc/cbus.h"
 #include "hw/block/flash.h"
 #include "hw/hw.h"
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
index 285f43709d..139d27d1cc 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -26,7 +26,7 @@
 #include "hw/arm/omap.h"
 #include "hw/boards.h"
 #include "hw/arm/arm.h"
-#include "hw/devices.h"
+#include "hw/input/tsc2xxx.h"
 #include "hw/loader.h"
 #include "exec/address-spaces.h"
 #include "cpu.h"
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
index 2b9108a193..f82771e7a7 100644
--- a/hw/input/tsc2005.c
+++ b/hw/input/tsc2005.c
@@ -23,7 +23,7 @@
 #include "hw/hw.h"
 #include "qemu/timer.h"
 #include "ui/console.h"
-#include "hw/devices.h"
+#include "hw/input/tsc2xxx.h"
 #include "trace.h"
 
 #define TSC_CUT_RESOLUTION(value, p)   ((value) >> (16 - (p ? 12 : 10)))
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
index ded0db9351..542a9188be 100644
--- a/hw/input/tsc210x.c
+++ b/hw/input/tsc210x.c
@@ -24,8 +24,8 @@
 #include "audio/audio.h"
 #include "qemu/timer.h"
 #include "ui/console.h"
-#include "hw/arm/omap.h"   /* For I2SCodec and uWireSlave */
-#include "hw/devices.h"
+#include "hw/arm/omap.h"/* For I2SCodec */
+#include "hw/input/tsc2xxx.h"
 
 #define TSC_DATA_REGISTERS_PAGE0x0
 #define TSC_CONTROL_REGISTERS_PAGE 0x1
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
index e7fbd340f3..9de867daa4 100644
--- a/include/hw/arm/omap.h
+++ b/include/hw/arm/omap.h
@@ -20,6 +20,7 @@
 #include "exec/memory.h"
 # define hw_omap_h "omap.h"
 #include "hw/irq.h"
+#include "hw/input/tsc2xxx.h"
 #include "target/arm/cpu-qom.h"
 #include "qemu/log.h"
 
@@ -679,11 +680,6 @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s);
 void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler);
 void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down);
 
-struct uWireSlave {
-uint16_t (*receive)(void *opaque);
-void (*send)(void *opaque, uint16_t data);
-void *opaque;
-};
 struct omap_uwire_s;
 void omap_uwire_attach(struct omap_uwire_s *s,
 uWireSlave *slave, int chipselect);
diff --git a/include/hw/devices.h b/include/hw/devices.h
index 7a630da47f..ba9034050b 100644
--- a/include/hw/devices.h
+++ b/include/hw/devices.h
@@ -4,7 +4,6 @@
 /* Devices that have nowhere better to go.  */
 
 #include "hw/hw.h"
-#include "ui/console.h"
 
 /* smc91c111.c */
 void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
@@ -12,18 +11,4 @@ void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
 /* lan9118.c */
 void lan9118_init(NICInfo *, uint32_t, qemu_irq);
 
-/* tsc210x.c */
-uWireSlave *tsc2102_init(qemu_irq pint);
-uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
-I2SCodec *tsc210x_codec(uWireSlave *chip);
-uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
-void tsc210x_set_transform(uWireSlave *chip,
-MouseTransformInfo *info);
-void tsc210x_key_event(uWireSlave *chip, int key, int down);
-
-/* tsc2005.c */
-void *tsc2005_init(qemu_irq pintdav);
-uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
-void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
-
 #endif
diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h
new file mode 100644
index 00..f23f00cde9
--- /dev/null
+++ b/include/hw/input/tsc2xxx.h
@@ -0,0 +1,38 @@
+/*
+ * TI touchscreen controller
+ *
+ * Copyright (c) 2006 Andrzej Zaborowski
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the 

[Qemu-devel] [PATCH v2 10/11] hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string

2019-02-04 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/arm/exynos4_boards.c  | 3 ++-
 hw/arm/mps2-tz.c | 3 ++-
 hw/net/lan9118.c | 1 -
 include/hw/net/lan9118.h | 2 ++
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index 750162cc95..ea8100f65a 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -32,6 +32,7 @@
 #include "hw/arm/arm.h"
 #include "exec/address-spaces.h"
 #include "hw/arm/exynos4210.h"
+#include "hw/net/lan9118.h"
 #include "hw/boards.h"
 
 #undef DEBUG
@@ -92,7 +93,7 @@ static void lan9215_init(uint32_t base, qemu_irq irq)
 /* This should be a 9215 but the 9118 is close enough */
 if (nd_table[0].used) {
 qemu_check_nic_model(_table[0], "lan9118");
-dev = qdev_create(NULL, "lan9118");
+dev = qdev_create(NULL, TYPE_LAN9118);
 qdev_set_nic_properties(dev, _table[0]);
 qdev_prop_set_uint32(dev, "mode_16bit", 1);
 qdev_init_nofail(dev);
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
index f79f090a4a..7832408bb7 100644
--- a/hw/arm/mps2-tz.c
+++ b/hw/arm/mps2-tz.c
@@ -56,6 +56,7 @@
 #include "hw/arm/armsse.h"
 #include "hw/dma/pl080.h"
 #include "hw/ssi/pl022.h"
+#include "hw/net/lan9118.h"
 #include "net/net.h"
 #include "hw/core/split-irq.h"
 
@@ -244,7 +245,7 @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, 
void *opaque,
  * except that it doesn't support the checksum-offload feature.
  */
 qemu_check_nic_model(nd, "lan9118");
-mms->lan9118 = qdev_create(NULL, "lan9118");
+mms->lan9118 = qdev_create(NULL, TYPE_LAN9118);
 qdev_set_nic_properties(mms->lan9118, nd);
 qdev_init_nofail(mms->lan9118);
 
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index a428b16eda..b29e3fee49 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -175,7 +175,6 @@ static const VMStateDescription vmstate_lan9118_packet = {
 }
 };
 
-#define TYPE_LAN9118 "lan9118"
 #define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118)
 
 typedef struct {
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
index d13d8cd3d2..500acb4c14 100644
--- a/include/hw/net/lan9118.h
+++ b/include/hw/net/lan9118.h
@@ -14,6 +14,8 @@
 #include "hw/irq.h"
 #include "net/net.h"
 
+#define TYPE_LAN9118 "lan9118"
+
 void lan9118_init(NICInfo *, uint32_t, qemu_irq);
 
 #endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 09/11] hw/net/ne2000-isa: Add guards to the header

2019-02-04 Thread Philippe Mathieu-Daudé
Reviewed-by: Thomas Huth 
Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/net/ne2000-isa.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
index ff2bed9c95..527337c454 100644
--- a/include/hw/net/ne2000-isa.h
+++ b/include/hw/net/ne2000-isa.h
@@ -6,6 +6,10 @@
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
+
+#ifndef HW_NET_NE2K_ISA_H
+#define HW_NET_NE2K_ISA_H
+
 #include "hw/hw.h"
 #include "hw/qdev.h"
 #include "hw/isa/isa.h"
@@ -31,3 +35,5 @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int 
base, int irq,
 }
 return d;
 }
+
+#endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 04/11] hw/devices: Move Blizzard declarations into a new header

2019-02-04 Thread Philippe Mathieu-Daudé
Add an entries the Blizzard device in MAINTAINERS.

Reviewed-by: Thomas Huth 
Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS   |  2 ++
 hw/arm/nseries.c  |  1 +
 hw/display/blizzard.c |  2 +-
 include/hw/devices.h  |  7 ---
 include/hw/display/blizzard.h | 22 ++
 5 files changed, 26 insertions(+), 8 deletions(-)
 create mode 100644 include/hw/display/blizzard.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 52058a8983..a21e7b546b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -648,10 +648,12 @@ M: Peter Maydell 
 L: qemu-...@nongnu.org
 S: Odd Fixes
 F: hw/arm/nseries.c
+F: hw/display/blizzard.c
 F: hw/input/lm832x.c
 F: hw/input/tsc2005.c
 F: hw/misc/cbus.c
 F: hw/timer/twl92230.c
+F: include/hw/display/blizzard.h
 
 Palm
 M: Andrzej Zaborowski 
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 906b7ca22d..9521be1cef 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -31,6 +31,7 @@
 #include "hw/boards.h"
 #include "hw/i2c/i2c.h"
 #include "hw/devices.h"
+#include "hw/display/blizzard.h"
 #include "hw/block/flash.h"
 #include "hw/hw.h"
 #include "hw/bt.h"
diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c
index 291abe6fca..471bd0ed99 100644
--- a/hw/display/blizzard.c
+++ b/hw/display/blizzard.c
@@ -21,7 +21,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "ui/console.h"
-#include "hw/devices.h"
+#include "hw/display/blizzard.h"
 #include "ui/pixel_ops.h"
 
 typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
diff --git a/include/hw/devices.h b/include/hw/devices.h
index 1e2141caad..77d6611302 100644
--- a/include/hw/devices.h
+++ b/include/hw/devices.h
@@ -29,13 +29,6 @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo 
*info);
 /* stellaris_input.c */
 void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
 
-/* blizzard.c */
-void *s1d13745_init(qemu_irq gpio_int);
-void s1d13745_write(void *opaque, int dc, uint16_t value);
-void s1d13745_write_block(void *opaque, int dc,
-void *buf, size_t len, int pitch);
-uint16_t s1d13745_read(void *opaque, int dc);
-
 /* cbus.c */
 typedef struct {
 qemu_irq clk;
diff --git a/include/hw/display/blizzard.h b/include/hw/display/blizzard.h
new file mode 100644
index 00..ef72bbc186
--- /dev/null
+++ b/include/hw/display/blizzard.h
@@ -0,0 +1,22 @@
+/*
+ * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller.
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Written by Andrzej Zaborowski
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_DISPLAY_BLIZZARD_H
+#define HW_DISPLAY_BLIZZARD_H
+
+#include "hw/irq.h"
+
+void *s1d13745_init(qemu_irq gpio_int);
+void s1d13745_write(void *opaque, int dc, uint16_t value);
+void s1d13745_write_block(void *opaque, int dc,
+  void *buf, size_t len, int pitch);
+uint16_t s1d13745_read(void *opaque, int dc);
+
+#endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 11/11] hw/devices: Move SMSC 91C111 declaration into a new header

2019-02-04 Thread Philippe Mathieu-Daudé
This commit finally deletes "hw/devices.h".

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/arm/gumstix.c   |  2 +-
 hw/arm/integratorcp.c  |  2 +-
 hw/arm/mainstone.c |  2 +-
 hw/arm/realview.c  |  2 +-
 hw/arm/versatilepb.c   |  2 +-
 hw/net/smc91c111.c |  2 +-
 include/hw/devices.h   | 11 ---
 include/hw/net/smc91c111.h | 19 +++
 8 files changed, 25 insertions(+), 17 deletions(-)
 delete mode 100644 include/hw/devices.h
 create mode 100644 include/hw/net/smc91c111.h

diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index 56cb763c4e..98c3e6d41c 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -40,7 +40,7 @@
 #include "hw/arm/pxa.h"
 #include "net/net.h"
 #include "hw/block/flash.h"
-#include "hw/devices.h"
+#include "hw/net/smc91c111.h"
 #include "hw/boards.h"
 #include "exec/address-spaces.h"
 #include "sysemu/qtest.h"
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 4eceebb9ea..0b6f24465e 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -12,10 +12,10 @@
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
-#include "hw/devices.h"
 #include "hw/boards.h"
 #include "hw/arm/arm.h"
 #include "hw/misc/arm_integrator_debug.h"
+#include "hw/net/smc91c111.h"
 #include "net/net.h"
 #include "exec/address-spaces.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index 0beb5c426b..fbe8d5cbd4 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -18,7 +18,7 @@
 #include "hw/arm/pxa.h"
 #include "hw/arm/arm.h"
 #include "net/net.h"
-#include "hw/devices.h"
+#include "hw/net/smc91c111.h"
 #include "hw/boards.h"
 #include "hw/block/flash.h"
 #include "hw/sysbus.h"
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index e9983c8763..05a244df25 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -14,8 +14,8 @@
 #include "hw/sysbus.h"
 #include "hw/arm/arm.h"
 #include "hw/arm/primecell.h"
-#include "hw/devices.h"
 #include "hw/net/lan9118.h"
+#include "hw/net/smc91c111.h"
 #include "hw/pci/pci.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 22b09a1e61..70b5fda737 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -13,7 +13,7 @@
 #include "cpu.h"
 #include "hw/sysbus.h"
 #include "hw/arm/arm.h"
-#include "hw/devices.h"
+#include "hw/net/smc91c111.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
index 99da2d9297..d19ea0750d 100644
--- a/hw/net/smc91c111.c
+++ b/hw/net/smc91c111.c
@@ -10,7 +10,7 @@
 #include "qemu/osdep.h"
 #include "hw/sysbus.h"
 #include "net/net.h"
-#include "hw/devices.h"
+#include "hw/net/smc91c111.h"
 #include "qemu/log.h"
 /* For crc32 */
 #include 
diff --git a/include/hw/devices.h b/include/hw/devices.h
deleted file mode 100644
index ebc45c8799..00
--- a/include/hw/devices.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef QEMU_DEVICES_H
-#define QEMU_DEVICES_H
-
-/* Devices that have nowhere better to go.  */
-
-#include "hw/hw.h"
-
-/* smc91c111.c */
-void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
-
-#endif
diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h
new file mode 100644
index 00..a66ba4112f
--- /dev/null
+++ b/include/hw/net/smc91c111.h
@@ -0,0 +1,19 @@
+/*
+ * SMSC 91C111 Ethernet interface emulation
+ *
+ * Copyright (c) 2005 CodeSourcery, LLC.
+ * Written by Paul Brook
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_NET_SMC91C111_H
+#define HW_NET_SMC91C111_H
+
+#include "hw/irq.h"
+#include "net/net.h"
+
+void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
+
+#endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 05/11] hw/devices: Move CBus declarations into a new header

2019-02-04 Thread Philippe Mathieu-Daudé
Reviewed-by: Thomas Huth 
Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS|  1 +
 hw/arm/nseries.c   |  1 +
 hw/misc/cbus.c |  2 +-
 include/hw/devices.h   | 14 --
 include/hw/misc/cbus.h | 32 
 5 files changed, 35 insertions(+), 15 deletions(-)
 create mode 100644 include/hw/misc/cbus.h

diff --git a/MAINTAINERS b/MAINTAINERS
index a21e7b546b..daae4a3beb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -654,6 +654,7 @@ F: hw/input/tsc2005.c
 F: hw/misc/cbus.c
 F: hw/timer/twl92230.c
 F: include/hw/display/blizzard.h
+F: include/hw/misc/cbus.h
 
 Palm
 M: Andrzej Zaborowski 
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 9521be1cef..ac876b5878 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -32,6 +32,7 @@
 #include "hw/i2c/i2c.h"
 #include "hw/devices.h"
 #include "hw/display/blizzard.h"
+#include "hw/misc/cbus.h"
 #include "hw/block/flash.h"
 #include "hw/hw.h"
 #include "hw/bt.h"
diff --git a/hw/misc/cbus.c b/hw/misc/cbus.c
index 25e337ea77..16ee704bca 100644
--- a/hw/misc/cbus.c
+++ b/hw/misc/cbus.c
@@ -23,7 +23,7 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
-#include "hw/devices.h"
+#include "hw/misc/cbus.h"
 #include "sysemu/sysemu.h"
 
 //#define DEBUG
diff --git a/include/hw/devices.h b/include/hw/devices.h
index 77d6611302..e400f9eac0 100644
--- a/include/hw/devices.h
+++ b/include/hw/devices.h
@@ -29,18 +29,4 @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo 
*info);
 /* stellaris_input.c */
 void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
 
-/* cbus.c */
-typedef struct {
-qemu_irq clk;
-qemu_irq dat;
-qemu_irq sel;
-} CBus;
-CBus *cbus_init(qemu_irq dat_out);
-void cbus_attach(CBus *bus, void *slave_opaque);
-
-void *retu_init(qemu_irq irq, int vilma);
-void *tahvo_init(qemu_irq irq, int betty);
-
-void retu_key_event(void *retu, int state);
-
 #endif
diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h
new file mode 100644
index 00..c899943e03
--- /dev/null
+++ b/include/hw/misc/cbus.h
@@ -0,0 +1,32 @@
+/*
+ * CBUS three-pin bus and the Retu / Betty / Tahvo / Vilma / Avilma /
+ * Hinku / Vinku / Ahne / Pihi chips used in various Nokia platforms.
+ * Based on reverse-engineering of a linux driver.
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Written by Andrzej Zaborowski
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_MISC_CBUS_H
+#define HW_MISC_CBUS_H
+
+#include "hw/irq.h"
+
+typedef struct {
+qemu_irq clk;
+qemu_irq dat;
+qemu_irq sel;
+} CBus;
+
+CBus *cbus_init(qemu_irq dat_out);
+void cbus_attach(CBus *bus, void *slave_opaque);
+
+void *retu_init(qemu_irq irq, int vilma);
+void *tahvo_init(qemu_irq irq, int betty);
+
+void retu_key_event(void *retu, int state);
+
+#endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 08/11] hw/devices: Move LAN9118 declarations into a new header

2019-02-04 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/arm/kzm.c |  2 +-
 hw/arm/mps2.c|  2 +-
 hw/arm/realview.c|  1 +
 hw/arm/vexpress.c|  2 +-
 hw/net/lan9118.c |  2 +-
 include/hw/devices.h |  3 ---
 include/hw/net/lan9118.h | 19 +++
 7 files changed, 24 insertions(+), 7 deletions(-)
 create mode 100644 include/hw/net/lan9118.h

diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c
index 864c7bd411..139934c4ec 100644
--- a/hw/arm/kzm.c
+++ b/hw/arm/kzm.c
@@ -22,7 +22,7 @@
 #include "qemu/error-report.h"
 #include "exec/address-spaces.h"
 #include "net/net.h"
-#include "hw/devices.h"
+#include "hw/net/lan9118.h"
 #include "hw/char/serial.h"
 #include "sysemu/qtest.h"
 
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
index e3d698ba6c..54b7395849 100644
--- a/hw/arm/mps2.c
+++ b/hw/arm/mps2.c
@@ -36,7 +36,7 @@
 #include "hw/timer/cmsdk-apb-timer.h"
 #include "hw/timer/cmsdk-apb-dualtimer.h"
 #include "hw/misc/mps2-scc.h"
-#include "hw/devices.h"
+#include "hw/net/lan9118.h"
 #include "net/net.h"
 
 typedef enum MPS2FPGAType {
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 242f5a87b6..e9983c8763 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -15,6 +15,7 @@
 #include "hw/arm/arm.h"
 #include "hw/arm/primecell.h"
 #include "hw/devices.h"
+#include "hw/net/lan9118.h"
 #include "hw/pci/pci.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index c02d18ee61..12e2c3986f 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -28,7 +28,7 @@
 #include "hw/sysbus.h"
 #include "hw/arm/arm.h"
 #include "hw/arm/primecell.h"
-#include "hw/devices.h"
+#include "hw/net/lan9118.h"
 #include "hw/i2c/i2c.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index a6269d9463..a428b16eda 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -14,7 +14,7 @@
 #include "hw/sysbus.h"
 #include "net/net.h"
 #include "net/eth.h"
-#include "hw/devices.h"
+#include "hw/net/lan9118.h"
 #include "sysemu/sysemu.h"
 #include "hw/ptimer.h"
 #include "qemu/log.h"
diff --git a/include/hw/devices.h b/include/hw/devices.h
index ba9034050b..ebc45c8799 100644
--- a/include/hw/devices.h
+++ b/include/hw/devices.h
@@ -8,7 +8,4 @@
 /* smc91c111.c */
 void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
 
-/* lan9118.c */
-void lan9118_init(NICInfo *, uint32_t, qemu_irq);
-
 #endif
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
new file mode 100644
index 00..d13d8cd3d2
--- /dev/null
+++ b/include/hw/net/lan9118.h
@@ -0,0 +1,19 @@
+/*
+ * SMSC LAN9118 Ethernet interface emulation
+ *
+ * Copyright (c) 2009 CodeSourcery, LLC.
+ * Written by Paul Brook
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_NET_LAN9118_H
+#define HW_NET_LAN9118_H
+
+#include "hw/irq.h"
+#include "net/net.h"
+
+void lan9118_init(NICInfo *, uint32_t, qemu_irq);
+
+#endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 03/11] hw/devices: Move TC6393XB declarations into a new header

2019-02-04 Thread Philippe Mathieu-Daudé
The TC6393XB_RAM definition introduced in 64b40bc54a9 is no
more used since a0b753dfd39. Remove it.

Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS   |  1 +
 hw/arm/tosa.c |  2 +-
 hw/display/tc6393xb.c |  2 +-
 include/hw/devices.h  | 10 --
 include/hw/display/tc6393xb.h | 26 ++
 5 files changed, 29 insertions(+), 12 deletions(-)
 create mode 100644 include/hw/display/tc6393xb.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 9a76845581..52058a8983 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -699,6 +699,7 @@ F: hw/misc/mst_fpga.c
 F: hw/misc/max111x.c
 F: include/hw/arm/pxa.h
 F: include/hw/arm/sharpsl.h
+F: include/hw/display/tc6393xb.h
 
 SABRELITE / i.MX6
 M: Peter Maydell 
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index 7a925fa5e6..b6d464ab16 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -16,10 +16,10 @@
 #include "hw/hw.h"
 #include "hw/arm/pxa.h"
 #include "hw/arm/arm.h"
-#include "hw/devices.h"
 #include "hw/arm/sharpsl.h"
 #include "hw/pcmcia.h"
 #include "hw/boards.h"
+#include "hw/display/tc6393xb.h"
 #include "hw/i2c/i2c.h"
 #include "hw/ssi/ssi.h"
 #include "hw/sysbus.h"
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
index e1b1e302f2..5305c06816 100644
--- a/hw/display/tc6393xb.c
+++ b/hw/display/tc6393xb.c
@@ -14,7 +14,7 @@
 #include "qapi/error.h"
 #include "qemu/host-utils.h"
 #include "hw/hw.h"
-#include "hw/devices.h"
+#include "hw/display/tc6393xb.h"
 #include "hw/block/flash.h"
 #include "ui/console.h"
 #include "ui/pixel_ops.h"
diff --git a/include/hw/devices.h b/include/hw/devices.h
index b5f1662225..1e2141caad 100644
--- a/include/hw/devices.h
+++ b/include/hw/devices.h
@@ -50,14 +50,4 @@ void *tahvo_init(qemu_irq irq, int betty);
 
 void retu_key_event(void *retu, int state);
 
-/* tc6393xb.c */
-typedef struct TC6393xbState TC6393xbState;
-#define TC6393XB_RAM   0x11 /* amount of ram for Video and USB */
-TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
- uint32_t base, qemu_irq irq);
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
-qemu_irq handler);
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s);
-qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
-
 #endif
diff --git a/include/hw/display/tc6393xb.h b/include/hw/display/tc6393xb.h
new file mode 100644
index 00..387c143b44
--- /dev/null
+++ b/include/hw/display/tc6393xb.h
@@ -0,0 +1,26 @@
+/*
+ * Toshiba TC6393XB I/O Controller.
+ * Found in Sharp Zaurus SL-6000 (tosa) or some
+ * Toshiba e-Series PDAs.
+ *
+ * Copyright (c) 2007 Hervé Poussineau
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_DISPLAY_TC6393XB_H
+#define HW_DISPLAY_TC6393XB_H
+
+#include "exec/memory.h"
+#include "hw/irq.h"
+
+typedef struct TC6393xbState TC6393xbState;
+
+TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
+ uint32_t base, qemu_irq irq);
+void tc6393xb_gpio_out_set(TC6393xbState *s, int line, qemu_irq handler);
+qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s);
+qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
+
+#endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 06/11] hw/devices: Move Gamepad declarations into a new header

2019-02-04 Thread Philippe Mathieu-Daudé
Signed-off-by: Philippe Mathieu-Daudé 
---
 MAINTAINERS|  1 +
 hw/arm/stellaris.c |  2 +-
 hw/input/stellaris_input.c |  2 +-
 include/hw/devices.h   |  3 ---
 include/hw/input/gamepad.h | 21 +
 5 files changed, 24 insertions(+), 5 deletions(-)
 create mode 100644 include/hw/input/gamepad.h

diff --git a/MAINTAINERS b/MAINTAINERS
index daae4a3beb..a38086f767 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -729,6 +729,7 @@ M: Peter Maydell 
 L: qemu-...@nongnu.org
 S: Maintained
 F: hw/*/stellaris*
+F: include/hw/input/gamepad.h
 
 Versatile Express
 M: Peter Maydell 
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 442529cc65..24c20bf612 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -12,7 +12,6 @@
 #include "hw/sysbus.h"
 #include "hw/ssi/ssi.h"
 #include "hw/arm/arm.h"
-#include "hw/devices.h"
 #include "qemu/timer.h"
 #include "hw/i2c/i2c.h"
 #include "net/net.h"
@@ -22,6 +21,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/arm/armv7m.h"
 #include "hw/char/pl011.h"
+#include "hw/input/gamepad.h"
 #include "hw/misc/unimp.h"
 #include "cpu.h"
 
diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
index 99168bfeef..20c87d86f4 100644
--- a/hw/input/stellaris_input.c
+++ b/hw/input/stellaris_input.c
@@ -8,7 +8,7 @@
  */
 #include "qemu/osdep.h"
 #include "hw/hw.h"
-#include "hw/devices.h"
+#include "hw/input/gamepad.h"
 #include "ui/console.h"
 
 typedef struct {
diff --git a/include/hw/devices.h b/include/hw/devices.h
index e400f9eac0..7a630da47f 100644
--- a/include/hw/devices.h
+++ b/include/hw/devices.h
@@ -26,7 +26,4 @@ void *tsc2005_init(qemu_irq pintdav);
 uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
 void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
 
-/* stellaris_input.c */
-void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
-
 #endif
diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h
new file mode 100644
index 00..112bad5e4c
--- /dev/null
+++ b/include/hw/input/gamepad.h
@@ -0,0 +1,21 @@
+/*
+ * Gamepad style buttons connected to IRQ/GPIO lines
+ *
+ * Copyright (c) 2007 CodeSourcery.
+ * Written by Paul Brook
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef HW_INPUT_GAMEPAD_H
+#define HW_INPUT_GAMEPAD_H
+
+/* Gamepad devices that have nowhere better to go.  */
+
+#include "hw/irq.h"
+
+/* stellaris_input.c */
+void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
+
+#endif
-- 
2.20.1




[Qemu-devel] [PATCH v2 02/11] hw: Remove unused 'hw/devices.h' include

2019-02-04 Thread Philippe Mathieu-Daudé
Reviewed-by: BALATON Zoltan 
Tested-by: Thomas Huth 
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/alpha/typhoon.c   | 1 -
 hw/arm/allwinner-a10.c   | 1 -
 hw/arm/collie.c  | 1 -
 hw/arm/cubieboard.c  | 1 -
 hw/arm/highbank.c| 1 -
 hw/arm/mps2-tz.c | 1 -
 hw/arm/musicpal.c| 1 -
 hw/arm/nrf51_soc.c   | 1 -
 hw/arm/spitz.c   | 1 -
 hw/arm/virt.c| 1 -
 hw/arm/z2.c  | 1 -
 hw/display/sm501.c   | 1 -
 hw/hppa/dino.c   | 1 -
 hw/intc/allwinner-a10-pic.c  | 1 -
 hw/lm32/lm32_boards.c| 1 -
 hw/lm32/milkymist.c  | 1 -
 hw/microblaze/petalogix_ml605_mmu.c  | 1 -
 hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 -
 hw/net/dp8393x.c | 1 -
 hw/ppc/virtex_ml507.c| 1 -
 hw/sh4/r2d.c | 1 -
 hw/tricore/tricore_testboard.c   | 1 -
 hw/usb/tusb6010.c| 1 -
 23 files changed, 23 deletions(-)

diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c
index 397e2dcdc7..9d57361c67 100644
--- a/hw/alpha/typhoon.c
+++ b/hw/alpha/typhoon.c
@@ -11,7 +11,6 @@
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/hw.h"
-#include "hw/devices.h"
 #include "sysemu/sysemu.h"
 #include "alpha_sys.h"
 #include "exec/address-spaces.h"
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index df0d079ad0..06ec6f4dc8 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -20,7 +20,6 @@
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
-#include "hw/devices.h"
 #include "hw/arm/allwinner-a10.h"
 #include "hw/misc/unimp.h"
 
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
index 48b732c176..3ca4e078fe 100644
--- a/hw/arm/collie.c
+++ b/hw/arm/collie.c
@@ -12,7 +12,6 @@
 #include "hw/hw.h"
 #include "hw/sysbus.h"
 #include "hw/boards.h"
-#include "hw/devices.h"
 #include "strongarm.h"
 #include "hw/arm/arm.h"
 #include "hw/block/flash.h"
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index 32f1edd2fa..84187d3916 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -20,7 +20,6 @@
 #include "qemu-common.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
-#include "hw/devices.h"
 #include "hw/boards.h"
 #include "hw/arm/allwinner-a10.h"
 
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index fb9efa02c3..96ccf18d86 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -21,7 +21,6 @@
 #include "qapi/error.h"
 #include "hw/sysbus.h"
 #include "hw/arm/arm.h"
-#include "hw/devices.h"
 #include "hw/loader.h"
 #include "net/net.h"
 #include "sysemu/kvm.h"
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
index f5f0b0e0fa..f79f090a4a 100644
--- a/hw/arm/mps2-tz.c
+++ b/hw/arm/mps2-tz.c
@@ -56,7 +56,6 @@
 #include "hw/arm/armsse.h"
 #include "hw/dma/pl080.h"
 #include "hw/ssi/pl022.h"
-#include "hw/devices.h"
 #include "net/net.h"
 #include "hw/core/split-irq.h"
 
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index d22532a11c..de4a12e496 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -15,7 +15,6 @@
 #include "cpu.h"
 #include "hw/sysbus.h"
 #include "hw/arm/arm.h"
-#include "hw/devices.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
 #include "hw/boards.h"
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index bbaf050103..3e633d160e 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -14,7 +14,6 @@
 #include "hw/arm/arm.h"
 #include "hw/sysbus.h"
 #include "hw/boards.h"
-#include "hw/devices.h"
 #include "hw/misc/unimp.h"
 #include "exec/address-spaces.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index c4bc3deedf..22f5958b9d 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -21,7 +21,6 @@
 #include "hw/ssi/ssi.h"
 #include "hw/block/flash.h"
 #include "qemu/timer.h"
-#include "hw/devices.h"
 #include "hw/arm/sharpsl.h"
 #include "ui/console.h"
 #include "hw/audio/wm8750.h"
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 99c2b6e60d..396804f0e5 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -37,7 +37,6 @@
 #include "hw/vfio/vfio-calxeda-xgmac.h"
 #include "hw/vfio/vfio-amd-xgbe.h"
 #include "hw/display/ramfb.h"
-#include "hw/devices.h"
 #include "net/net.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/numa.h"
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 697a822f1e..7afa352a96 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -15,7 +15,6 @@
 #include "hw/hw.h"
 #include "hw/arm/pxa.h"
 #include "hw/arm/arm.h"
-#include "hw/devices.h"
 #include "hw/i2c/i2c.h"
 #include "hw/ssi/ssi.h"
 #include "hw/boards.h"
diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 4a8686f0f5..2122291308 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -32,7 +32,6 @@
 #include "hw/hw.h"
 #include 

[Qemu-devel] [PATCH v2 00/11] hw: Remove "hw/devices.h"

2019-02-04 Thread Philippe Mathieu-Daudé
Hi,

As his first comment describes itself, the "hw/devices.h" contains
declarations for "Devices that have nowhere better to go."
This series remove it, creating new headers for devices covered there.
MAINTAINERS is updated.
I also included 2 cleanups while working on this, in "qemu/typedefs.h"
and "hw/net/ne2000-isa.h" header guard.

v2:
- added R-b, T-b tags
- addressed many review comments from Thomas

v1: https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00611.html

Phil.

Philippe Mathieu-Daudé (11):
  hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded
string
  hw: Remove unused 'hw/devices.h' include
  hw/devices: Move TC6393XB declarations into a new header
  hw/devices: Move Blizzard declarations into a new header
  hw/devices: Move CBus declarations into a new header
  hw/devices: Move Gamepad declarations into a new header
  hw/devices: Move TI touchscreen declarations into a new header
  hw/devices: Move LAN9118 declarations into a new header
  hw/net/ne2000-isa: Add guards to the header
  hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded
string
  hw/devices: Move SMSC 91C111 declaration into a new header

 MAINTAINERS  |  7 +++
 hw/alpha/typhoon.c   |  1 -
 hw/arm/allwinner-a10.c   |  1 -
 hw/arm/aspeed.c  | 13 +++--
 hw/arm/collie.c  |  1 -
 hw/arm/cubieboard.c  |  1 -
 hw/arm/exynos4_boards.c  |  3 +-
 hw/arm/gumstix.c |  2 +-
 hw/arm/highbank.c|  1 -
 hw/arm/integratorcp.c|  2 +-
 hw/arm/kzm.c |  2 +-
 hw/arm/mainstone.c   |  2 +-
 hw/arm/mps2-tz.c |  4 +-
 hw/arm/mps2.c|  2 +-
 hw/arm/musicpal.c|  1 -
 hw/arm/nrf51_soc.c   |  1 -
 hw/arm/nseries.c |  4 +-
 hw/arm/palm.c|  2 +-
 hw/arm/realview.c|  3 +-
 hw/arm/spitz.c   |  1 -
 hw/arm/stellaris.c   |  2 +-
 hw/arm/tosa.c|  2 +-
 hw/arm/versatilepb.c |  2 +-
 hw/arm/vexpress.c|  2 +-
 hw/arm/virt.c|  1 -
 hw/arm/z2.c  |  1 -
 hw/display/blizzard.c|  2 +-
 hw/display/sm501.c   |  1 -
 hw/display/tc6393xb.c|  2 +-
 hw/hppa/dino.c   |  1 -
 hw/input/stellaris_input.c   |  2 +-
 hw/input/tsc2005.c   |  2 +-
 hw/input/tsc210x.c   |  4 +-
 hw/intc/allwinner-a10-pic.c  |  1 -
 hw/lm32/lm32_boards.c|  1 -
 hw/lm32/milkymist.c  |  1 -
 hw/microblaze/petalogix_ml605_mmu.c  |  1 -
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  1 -
 hw/misc/cbus.c   |  2 +-
 hw/net/dp8393x.c |  1 -
 hw/net/lan9118.c |  3 +-
 hw/net/smc91c111.c   |  2 +-
 hw/ppc/virtex_ml507.c|  1 -
 hw/sh4/r2d.c |  1 -
 hw/tricore/tricore_testboard.c   |  1 -
 hw/usb/tusb6010.c|  1 -
 include/hw/arm/omap.h|  6 +--
 include/hw/devices.h | 63 
 include/hw/display/blizzard.h| 22 +
 include/hw/display/tc6393xb.h| 26 ++
 include/hw/input/gamepad.h   | 21 
 include/hw/input/tsc2xxx.h   | 38 ++
 include/hw/misc/cbus.h   | 32 
 include/hw/net/lan9118.h | 21 
 include/hw/net/ne2000-isa.h  |  6 +++
 include/hw/net/smc91c111.h   | 19 +++
 include/qemu/typedefs.h  |  1 -
 57 files changed, 230 insertions(+), 120 deletions(-)
 delete mode 100644 include/hw/devices.h
 create mode 100644 include/hw/display/blizzard.h
 create mode 100644 include/hw/display/tc6393xb.h
 create mode 100644 include/hw/input/gamepad.h
 create mode 100644 include/hw/input/tsc2xxx.h
 create mode 100644 include/hw/misc/cbus.h
 create mode 100644 include/hw/net/lan9118.h
 create mode 100644 include/hw/net/smc91c111.h

-- 
2.20.1




[Qemu-devel] [PATCH v2 01/11] hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string

2019-02-04 Thread Philippe Mathieu-Daudé
Reviewed-by: Thomas Huth 
Reviewed-by: Cédric Le Goater 
Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/arm/aspeed.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 5158985482..e98ede5a86 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -19,6 +19,8 @@
 #include "hw/arm/aspeed_soc.h"
 #include "hw/boards.h"
 #include "hw/i2c/smbus.h"
+#include "hw/misc/pca9552.h"
+#include "hw/misc/tmp105.h"
 #include "qemu/log.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
@@ -267,7 +269,8 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
   eeprom_buf);
 
 /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
-i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 7), "tmp105", 0x4d);
+i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 7),
+ TYPE_TMP105, 0x4d);
 
 /* The AST2500 EVB does not have an RTC. Let's pretend that one is
  * plugged on the I2C bus header */
@@ -288,13 +291,15 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState 
*bmc)
 AspeedSoCState *soc = >soc;
 uint8_t *eeprom_buf = g_malloc0(8 * 1024);
 
-i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 3), "pca9552", 
0x60);
+i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 3), TYPE_PCA9552,
+ 0x60);
 
 i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 4), "tmp423", 0x4c);
 i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 5), "tmp423", 0x4c);
 
 /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
-i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 9), "tmp105", 0x4a);
+i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 9), TYPE_TMP105,
+ 0x4a);
 
 /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
  * good enough */
@@ -302,7 +307,7 @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
 
 smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(>i2c), 11), 0x51,
   eeprom_buf);
-i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 11), "pca9552",
+i2c_create_slave(aspeed_i2c_get_bus(DEVICE(>i2c), 11), TYPE_PCA9552,
  0x60);
 }
 
-- 
2.20.1




Re: [Qemu-devel] [PATCH 16/16] RFC hw/net/smc91c111: Convert init helper into an inline function

2019-02-04 Thread Philippe Mathieu-Daudé
On 1/4/19 8:35 PM, Thomas Huth wrote:
> On 2019-01-04 18:58, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé 
>> ---
>> As init helper in "hw/char/pl011.h"
>> ---
>>  hw/net/smc91c111.c | 17 -
>>  include/hw/net/smc91c111.h | 25 -
>>  2 files changed, 24 insertions(+), 18 deletions(-)
> 
> Why? If you move code around like this, you should mention the reason in
> the patch description.

Oops this one wasn't supposed to be sent, I planned to drop it before
sending but probably forgot because it was late friday :/



Re: [Qemu-devel] [PATCH v2 1/6] s390x/pci: Fix primary bus number for PCI bridges

2019-02-04 Thread Collin Walling

On 1/30/19 10:57 AM, David Hildenbrand wrote:

The primary bus number corresponds always to the bus number of the
bus the bridge is attached to.

Right now, if we have two bridges attached to the same bus (e.g. root
bus) this is however not the case. The first bridge will have primary
bus 0, the second bridge primary bus 1, which is wrong. Fix the assignment.

While at it, drop setting the PCI_SUBORDINATE_BUS temporarily to 0xff.
Setting it temporarily to that value (as discussed e.g. in [1]), is
only relevant for a running system that probes the buses. The value is
effectively unused for us just doing a DFS.

Also add a comment why we have to reassign during every reset (which I
found to be surprising.

Please note that hotplugging of bridges is in general still broken, will
be fixed next.

[1] http://www.science.unitn.it/~fiorella/guidelinux/tlk/node76.html

Reviewed-by: Thomas Huth 
Signed-off-by: David Hildenbrand 
---


Reviewed-by: Collin Walling 




[Qemu-devel] security implications of caching with virtio pmem (was Re: [PATCH v3 0/5] kvm "virtio pmem" device)

2019-02-04 Thread Michael S. Tsirkin


On Wed, Jan 09, 2019 at 08:17:31PM +0530, Pankaj Gupta wrote:
>  This patch series has implementation for "virtio pmem". 
>  "virtio pmem" is fake persistent memory(nvdimm) in guest 
>  which allows to bypass the guest page cache. This also
>  implements a VIRTIO based asynchronous flush mechanism.  


At Pankaj's request I looked at information leak implications of virtio
pmem in light of the recent page cache side channels paper
(https://arxiv.org/pdf/1901.01161.pdf) - to see what
kind of side channels it might create if any.  TLDR - I think that
depending on the host side implementation there could be some, but this
might be addressable by better documentation in both code and spec.
The fake dax approach backing the guest memory by a host page cache
does seem to have potential issues.

For clarity: we are talking about leaking information either to a VM, or
within a VM (I did not look into leaks to hypervisor in configurations
such as SEV) through host page cache.

Leaks into a VM: It seems clear that while pmem allows memory accesses
versus read/write with e.g. a block device, from host page cache point
of view this doesn't matter much: reads populate cache in the same way
as memory faults.  Thus ignoring presence of information leaks (which is
an interesting question e.g. in light of recent discard support) pmem
doesn't seem to be any better or worse for leaking information into a
VM.

Leaks within VM: Right now pmem seems to bypass the guest page cache
completely.  Whether pmem memory is then resident in a page cache would
be up to the device/host. Assuming that it is, the "Preventing
Efficient Eviction while Increasing the System Performance"
countermeasure for the page cache side channel attack would appear to
become ineffective with pmem. What is suggested is a per-process
management of the page cache, and host does not have visibility of
processes within a VM. Another possible countermeasure - not discussed
in the paper - could be modify the applications to lock the security
relevant pages in memory.  Again this becomes impractical with pmem as
host does not have visibility into that. However note that as long
as the only countermeasure linux uses is "Privileged Access"
(i.e. blocking mincore) nothing can be done as guest page cache
remains as vulnerable as host page cache.


Countermeasures: which host-side countermeasures can be designed would
depend on which countermeasures are used guest-side - we would need to
make sure they are not broken by pmem.  For "Preventing Efficient
Eviction while Increasing the System Performance" modifying the host
implementation to ensure that pmem device bypasses the host page cache
would seem to address the security problem.Similarly, ensuring that a
real memory device (e.g. DAX, RAM such as hugetlbfs, pmem for nested
virt) is used for pmem would make the memory locking countermeasure
work.  Whether with such limitations the device is still useful
performance wise is an open question.  These questions probably should
be addressed in the documentation, spec and possible qemu code.



Severity of the security implications: some people argue that the
security implications of the page cache leaks are minor.  I do not have
an opinion on this: the severity would seem to depend on the specific
configuration.


Other security implications: recent discussion seems to suggest there
are other concerns around e.g. resource management and thus DOS
potential. If that's so, it's a matter for a separate discussion
as I didn't look into that in depth.

Some or all of the above might be based on a misunderstanding of the
current pmem code, the whitepaper and linux page cache in general.
If so I apologise, do not hesitate to call out any mistakes.

Thanks!

-- 
MST



Re: [Qemu-devel] [qemu-s390x] [PATCH v2 3/6] s390x/pci: Warn when adding PCI devices without the 'zpci' feature

2019-02-04 Thread Collin Walling

On 2/4/19 4:54 PM, David Hildenbrand wrote:

On 04.02.19 21:19, Collin Walling wrote:

On 1/30/19 10:57 AM, David Hildenbrand wrote:

We decided to always create the PCI host bridge, even if 'zpci' is not
enabled (due to migration compatibility). This however right now allows
to add zPCI/PCI devices to a VM although the guest will never actually see
them, confusing people that are using a simple CPU model that has no
'zpci' enabled - "Why isn't this working" (David Hildenbrand)

Let's check for 'zpci' and at least print a warning that this will not
work as expected. We could also bail out, however that might break
existing QEMU commandlines.

Reviewed-by: Thomas Huth 
Signed-off-by: David Hildenbrand 
---
   hw/s390x/s390-pci-bus.c | 5 +
   1 file changed, 5 insertions(+)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 9b5c5fff60..2efd9186c2 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -826,6 +826,11 @@ static void s390_pcihost_pre_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
   {
   S390pciState *s = S390_PCI_HOST_BRIDGE(hotplug_dev);
   
+if (!s390_has_feat(S390_FEAT_ZPCI)) {

+warn_report("PCI/zPCI device without the 'zpci' CPU feature."
+" The guest will not be able to see/use this device");
+}
+
   if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
   PCIDevice *pdev = PCI_DEVICE(dev);
   



I wonder if someone might misconstrue this as "the _PCI device_ needs
the zpci feature." I think "'zpci' CPU feature required to support
PCI/zPCI devices." reads better. The last sentence is fine to me.



Well, the guest needs the 'zpci' feature to see the device. And that's
what that message says in my opinion. Not that a device needs to have a
feature (I added "CPU feature" for this reason).

"required to support" does it not make very clear what we actually want
to say.

Thanks!



I see your point. We can still plug in the device without the CPU
feature, but the device will ultimately be useless to the guest. Thanks
for clearing that up.

Still, the wording reads strangely to me. I read it as the PCI device
itself requires a "zpci CPU feature" which of course does not make sense
(and I fully understand that's not what you mean here).

What do you think about:

"PCI/zPCI device plugging without 'zpci' CPU feature enabled." along
with your second sentence, of course.

Either way you decide, it's still a good idea to have this warning in
here. I'm really just debating syntax and not semantics, so it's not
really important. I won't impede this patch over a differing opinion of
a small rewording. :)

Reviewed-by: Collin Walling 




Re: [Qemu-devel] [PATCH] checkpatch: Flag suspicious attribution lines

2019-02-04 Thread Eric Blake
On 2/4/19 3:56 PM, Eric Blake wrote:
> Flag commit attribution tags that are unusual (often because they
> were a typo), but only as a warning (because sometimes a humorous
> or otherwise useful tag is intentionally supplied).
> 
> This picks the 6-most popular tags, each with 700 or more uses (well,
> S-o-b was already checked for case-sensitivity and typos, leaving
> only 5 new tags being checked), as determined by:
> $ git log | sed -n 's/^ *\([A-Za-z-]*-by:\).*/\1/p' | \
>   sort | uniq -c | sort -k1,1n | tail
> 
> Most of the rejected lines were obvious typos (among others, we've
> had 4 cases of someone being burnt, based on Singed-off-by; and 2
> cases of list-reading via an e-reader, based on eviewed-by; there
> are also lines forgetting a space after the ':') or otherwise
> tongue-in-check (3 Approximately-suggested-by). A few lines not
> whitelisted here may be legitimate, but as they are orders of
> magnitude rarer, it is therefore not worth worrying about
> (7 Requested-by, 3 Co-authored-by, 1 Inspired-by, etc.).
> 
> Signed-off-by: Eric Blake 
> ---

>   }
> + } elsif($line =~ /^\s*([A-Za-z-])*-by:/ &&
> + ($1 !~ /(Suggest|Report|Test|Ack|Review)ed/ ||
> +  $line !~ /^\s[a-z-]*-by:\S/i)) {

Oops, that last one is supposed to be =~, to flag lines that forget the
space between *-by: and the email address.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2] dirty-bitmap: Expose persistent flag to 'query-block'

2019-02-04 Thread John Snow



On 2/4/19 4:05 PM, Eric Blake wrote:
> Since qemu currently doesn't flush persistent bitmaps to disk until
> shutdown (which might be MUCH later), it's useful if 'query-block'
> at least shows WHICH bitmaps will (eventually) make it to persistent
> storage.  Update affected iotests.
> 
> Signed-off-by: Eric Blake 
> Reviewed-by: Vladimir Sementsov-Ogievskiy 
> Reviewed-by: John Snow 

staged, thanks!



[Qemu-devel] [PATCH v2] checkpatch: Flag suspicious attribution lines

2019-02-04 Thread Eric Blake
Flag commit attribution tags that are unusual (often because they
were a typo), but only as a warning (because sometimes a humorous
or otherwise useful tag is intentionally supplied).

This picks the 6-most popular tags, each with 700 or more uses (well,
S-o-b was already checked for case-sensitivity and typos, leaving
only 5 new tags being checked), as determined by:
$ git log | sed -n 's/^ *\([A-Za-z-]*-by:\).*/\1/p' | \
  sort | uniq -c | sort -k1,1n | tail

Most of the rejected lines were obvious typos (among others, we've
had 4 cases of someone being burnt, based on Singed-off-by; and 2
cases of list-reading via an e-reader, based on eviewed-by; there
are also lines forgetting a space after the ':') or otherwise
tongue-in-check (3 Approximately-suggested-by). A few lines not
whitelisted here may be legitimate, but as they are orders of
magnitude rarer, it is therefore not worth worrying about
(7 Requested-by, 3 Co-authored-by, 1 Inspired-by, etc.).

Signed-off-by: Eric Blake 
---

v2: fix regex

 scripts/checkpatch.pl | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88682cb0a9f..4962f74eec1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1456,7 +1456,7 @@ sub process {
ERROR("Author email address is mangled by the mailing 
list\n" . $herecurr);
}

-#check the patch for a signoff:
+#check the patch for a signoff, and that other attribution lines are typical:
if ($line =~ /^\s*signed-off-by:/i) {
# This is a signoff, if ugly, so do not double report.
$signoff++;
@@ -1470,6 +1470,10 @@ sub process {
ERROR("space required after Signed-off-by:\n" .
$herecurr);
}
+   } elsif($line =~ /^\s*([A-Za-z-]*)-by:/ &&
+   ($1 !~ /(Suggest|Report|Test|Ack|Review)ed/ ||
+$line !~ /^\s*[a-z-]*-by:\s/i)) {
+   WARN("suspicious attribution tag:\n" . $herecurr);
}

 # Check if MAINTAINERS is being updated.  If so, there's probably no need to
-- 
2.20.1




Re: [Qemu-devel] [qemu-s390x] [PATCH v2 3/6] s390x/pci: Warn when adding PCI devices without the 'zpci' feature

2019-02-04 Thread David Hildenbrand
On 04.02.19 23:42, Collin Walling wrote:
> On 2/4/19 4:54 PM, David Hildenbrand wrote:
>> On 04.02.19 21:19, Collin Walling wrote:
>>> On 1/30/19 10:57 AM, David Hildenbrand wrote:
 We decided to always create the PCI host bridge, even if 'zpci' is not
 enabled (due to migration compatibility). This however right now allows
 to add zPCI/PCI devices to a VM although the guest will never actually see
 them, confusing people that are using a simple CPU model that has no
 'zpci' enabled - "Why isn't this working" (David Hildenbrand)

 Let's check for 'zpci' and at least print a warning that this will not
 work as expected. We could also bail out, however that might break
 existing QEMU commandlines.

 Reviewed-by: Thomas Huth 
 Signed-off-by: David Hildenbrand 
 ---
hw/s390x/s390-pci-bus.c | 5 +
1 file changed, 5 insertions(+)

 diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
 index 9b5c5fff60..2efd9186c2 100644
 --- a/hw/s390x/s390-pci-bus.c
 +++ b/hw/s390x/s390-pci-bus.c
 @@ -826,6 +826,11 @@ static void s390_pcihost_pre_plug(HotplugHandler 
 *hotplug_dev, DeviceState *dev,
{
S390pciState *s = S390_PCI_HOST_BRIDGE(hotplug_dev);

 +if (!s390_has_feat(S390_FEAT_ZPCI)) {
 +warn_report("PCI/zPCI device without the 'zpci' CPU feature."
 +" The guest will not be able to see/use this device");
 +}
 +
if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
PCIDevice *pdev = PCI_DEVICE(dev);


>>>
>>> I wonder if someone might misconstrue this as "the _PCI device_ needs
>>> the zpci feature." I think "'zpci' CPU feature required to support
>>> PCI/zPCI devices." reads better. The last sentence is fine to me.
>>>
>>
>> Well, the guest needs the 'zpci' feature to see the device. And that's
>> what that message says in my opinion. Not that a device needs to have a
>> feature (I added "CPU feature" for this reason).
>>
>> "required to support" does it not make very clear what we actually want
>> to say.
>>
>> Thanks!
>>
> 
> I see your point. We can still plug in the device without the CPU
> feature, but the device will ultimately be useless to the guest. Thanks
> for clearing that up.
> 
> Still, the wording reads strangely to me. I read it as the PCI device
> itself requires a "zpci CPU feature" which of course does not make sense
> (and I fully understand that's not what you mean here).
> 
> What do you think about:
> 
> "PCI/zPCI device plugging without 'zpci' CPU feature enabled." along
> with your second sentence, of course.

"Plugging a PCI/zPCI device without the 'zpci' CPU feature enabled. The
guest will not be able to see/use this device."

would make sense to me!

> 
> Either way you decide, it's still a good idea to have this warning in
> here. I'm really just debating syntax and not semantics, so it's not
> really important. I won't impede this patch over a differing opinion of
> a small rewording. :)
> 
> Reviewed-by: Collin Walling 
> 

Thanks!

-- 

Thanks,

David / dhildenb



Re: [Qemu-devel] [qemu-s390x] [PATCH v2 2/6] s390x/pci: Fix hotplugging of PCI bridges

2019-02-04 Thread Collin Walling

On 1/30/19 10:57 AM, David Hildenbrand wrote:

When hotplugging a PCI bridge right now to the root port, we resolve
pci_get_bus(pdev)->parent_dev, which results in a SEGFAULT. Hotplugging
really only works right now when hotplugging to another bridge.

Instead, we have to properly check if we are already at the root.

Let's cleanup the code while at it a bit and factor out updating the
subordiante bus number into a separate function. The check for


s/subordiante/subordinate


"old_nr < nr" is right now not strictly necessary, but makes it more
obvious what is actually going on.

Most probably fixing up the topology is not our responsibility when
hotplugging. The guest has to sort this out. But let's keep it for now
and only fix current code to not crash.

Reviewed-by: Thomas Huth 
Signed-off-by: David Hildenbrand 
---
  hw/s390x/s390-pci-bus.c | 28 +++-
  1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index b7c4613fde..9b5c5fff60 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -843,6 +843,21 @@ static void s390_pcihost_pre_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
  }
  }
  
+static void s390_pci_update_subordinate(PCIDevice *dev, uint32_t nr)

+{
+uint32_t old_nr;
+
+pci_default_write_config(dev, PCI_SUBORDINATE_BUS, nr, 1);
+while (!pci_bus_is_root(pci_get_bus(dev))) {
+dev = pci_get_bus(dev)->parent_dev;
+
+old_nr = pci_default_read_config(dev, PCI_SUBORDINATE_BUS, 1);
+if (old_nr < nr) {
+pci_default_write_config(dev, PCI_SUBORDINATE_BUS, nr, 1);
+}
+}
+} > +
  static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
  {
@@ -851,26 +866,21 @@ static void s390_pcihost_plug(HotplugHandler 
*hotplug_dev, DeviceState *dev,
  S390PCIBusDevice *pbdev = NULL;
  
  if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) {

-BusState *bus;
  PCIBridge *pb = PCI_BRIDGE(dev);
-PCIDevice *pdev = PCI_DEVICE(dev);
  
+pdev = PCI_DEVICE(dev);

  pci_bridge_map_irq(pb, dev->id, s390_pci_map_irq);
  pci_setup_iommu(>sec_bus, s390_pci_dma_iommu, s);
  
-bus = BUS(>sec_bus);

-qbus_set_hotplug_handler(bus, DEVICE(s), errp);
+qbus_set_hotplug_handler(BUS(>sec_bus), DEVICE(s), errp);
  
  if (dev->hotplugged) {

  pci_default_write_config(pdev, PCI_PRIMARY_BUS,
   pci_dev_bus_num(pdev), 1);
  s->bus_no += 1;
  pci_default_write_config(pdev, PCI_SECONDARY_BUS, s->bus_no, 1);
-do {
-pdev = pci_get_bus(pdev)->parent_dev;
-pci_default_write_config(pdev, PCI_SUBORDINATE_BUS,
- s->bus_no, 1);
-} while (pci_get_bus(pdev) && pci_dev_bus_num(pdev));
+
+s390_pci_update_subordinate(pdev, s->bus_no);
  }
  } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
  pdev = PCI_DEVICE(dev);



Looks good to me...

Reviewed-by: Collin Walling 

Side note: unrelated to the changes here -- and if you can clarify for
me -- any idea why we do s->bus_no += 1? This throws me off a bit and
begs me to ask what exactly is the S390pciState object suppose to
represent? (My guess is that it is representative of the entire PCI
topology, and we increment the bus_no to denote the subordinate bus
number?)

(let me know if these kind of discussions are too noisy and deemed
inappropriate for the mailing list, and I'll start pestering you off-
list instead)




Re: [Qemu-devel] [PATCH v2 2/2] target/i386: sev: Do not pin the ram device memory region

2019-02-04 Thread Alex Williamson
On Mon, 4 Feb 2019 22:23:40 +
"Singh, Brijesh"  wrote:

> The RAM device presents a memory region that should be handled
> as an IO region and should not be pinned.
> 
> In the case of the vfio-pci, RAM device represents a MMIO BAR
> and the memory region is not backed by pages hence
> KVM_MEMORY_ENCRYPT_REG_REGION fails to lock the memory range.
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
> Cc: Alex Williamson 
> Cc: Paolo Bonzini 
> Signed-off-by: Brijesh Singh 
> ---
>  target/i386/sev.c | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 20b2d325d8..cd77f6b5d4 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -131,6 +131,17 @@ sev_ram_block_added(RAMBlockNotifier *n, void *host, 
> size_t size)
>  {
>  int r;
>  struct kvm_enc_region range;
> +ram_addr_t offset;
> +MemoryRegion *mr;
> +
> +/*
> + * The RAM device presents a memory region that should be treated
> + * as IO region and should not be pinned.
> + */
> +mr = memory_region_from_host(host, );
> +if (mr && memory_region_is_ram_device(mr)) {
> +return;
> +}
>  
>  range.addr = (__u64)(unsigned long)host;
>  range.size = size;

Reviewed-by: Alex Williamson 



Re: [Qemu-devel] [PATCH] configure: Don't add Xen's libs to LDFLAGS

2019-02-04 Thread Eric Blake
On 1/24/19 12:29 PM, Peter Maydell wrote:
> On Thu, 24 Jan 2019 at 17:40, Eric Blake  wrote:
>>
>> On 1/24/19 2:45 AM, Markus Armbruster wrote:
>>
 Signed-off-by: Michael Tokarev 
 Revieved-by: Michael Tokarev 
>>>
>>> Typo in Reviewed-by.
>>
>> Should we tighten checkpatch.pl to flag suspicious-looking 'xxx-by:'
>> tags, to catch instances of typos?
> 
> Yes, I would vote for having it whitelist the half a dozen
> expected ones and complain about the rest. I think we
> kind of discussed this in the past...

I submitted a patch along those lines:
https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg00910.html

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH v2 1/2] memory: Fix the memory region type assignment order

2019-02-04 Thread Singh, Brijesh
Currently, a callback registered through the RAMBlock notifier
is not able to get the memory region type (i.e callback is not
able to use memory_region_is_ram_device function). This is
because mr->ram assignment happens _after_ the memory is allocated
whereas the callback is executed during allocation.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
Suggested-by: Alex Williamson 
Cc: Paolo Bonzini 
Reviewed-by: Alex Williamson 
Signed-off-by: Brijesh Singh 
---
 memory.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/memory.c b/memory.c
index 61d66e4441..9ec15349dd 100644
--- a/memory.c
+++ b/memory.c
@@ -1652,10 +1652,17 @@ void memory_region_init_ram_device_ptr(MemoryRegion *mr,
uint64_t size,
void *ptr)
 {
-memory_region_init_ram_ptr(mr, owner, name, size, ptr);
+memory_region_init(mr, owner, name, size);
+mr->ram = true;
+mr->terminates = true;
 mr->ram_device = true;
 mr->ops = _device_mem_ops;
 mr->opaque = mr;
+mr->destructor = memory_region_destructor_ram;
+mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
+/* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL.  */
+assert(ptr != NULL);
+mr->ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, _fatal);
 }
 
 void memory_region_init_alias(MemoryRegion *mr,
-- 
2.17.1




[Qemu-devel] [PATCH v2 0/2] Fix SEV VM device assignment

2019-02-04 Thread Singh, Brijesh
Fix: https://bugzilla.redhat.com/show_bug.cgi?id=1667249

Since v1:
 * check the error code from memory_region_from_host() before
   accessing the mr.

Brijesh Singh (2):
  memory: Fix the memory region type assignment order
  target/i386: sev: Do not pin the ram device memory region

 memory.c  |  9 -
 target/i386/sev.c | 11 +++
 2 files changed, 19 insertions(+), 1 deletion(-)

-- 
2.17.1




[Qemu-devel] [PATCH v2 2/2] target/i386: sev: Do not pin the ram device memory region

2019-02-04 Thread Singh, Brijesh
The RAM device presents a memory region that should be handled
as an IO region and should not be pinned.

In the case of the vfio-pci, RAM device represents a MMIO BAR
and the memory region is not backed by pages hence
KVM_MEMORY_ENCRYPT_REG_REGION fails to lock the memory range.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
Cc: Alex Williamson 
Cc: Paolo Bonzini 
Signed-off-by: Brijesh Singh 
---
 target/i386/sev.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/target/i386/sev.c b/target/i386/sev.c
index 20b2d325d8..cd77f6b5d4 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -131,6 +131,17 @@ sev_ram_block_added(RAMBlockNotifier *n, void *host, 
size_t size)
 {
 int r;
 struct kvm_enc_region range;
+ram_addr_t offset;
+MemoryRegion *mr;
+
+/*
+ * The RAM device presents a memory region that should be treated
+ * as IO region and should not be pinned.
+ */
+mr = memory_region_from_host(host, );
+if (mr && memory_region_is_ram_device(mr)) {
+return;
+}
 
 range.addr = (__u64)(unsigned long)host;
 range.size = size;
-- 
2.17.1




[Qemu-devel] [PATCH] checkpatch: Flag suspicious attribution lines

2019-02-04 Thread Eric Blake
Flag commit attribution tags that are unusual (often because they
were a typo), but only as a warning (because sometimes a humorous
or otherwise useful tag is intentionally supplied).

This picks the 6-most popular tags, each with 700 or more uses (well,
S-o-b was already checked for case-sensitivity and typos, leaving
only 5 new tags being checked), as determined by:
$ git log | sed -n 's/^ *\([A-Za-z-]*-by:\).*/\1/p' | \
  sort | uniq -c | sort -k1,1n | tail

Most of the rejected lines were obvious typos (among others, we've
had 4 cases of someone being burnt, based on Singed-off-by; and 2
cases of list-reading via an e-reader, based on eviewed-by; there
are also lines forgetting a space after the ':') or otherwise
tongue-in-check (3 Approximately-suggested-by). A few lines not
whitelisted here may be legitimate, but as they are orders of
magnitude rarer, it is therefore not worth worrying about
(7 Requested-by, 3 Co-authored-by, 1 Inspired-by, etc.).

Signed-off-by: Eric Blake 
---
 scripts/checkpatch.pl | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 88682cb0a9f..51d55f80621 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1456,7 +1456,7 @@ sub process {
ERROR("Author email address is mangled by the mailing 
list\n" . $herecurr);
}

-#check the patch for a signoff:
+#check the patch for a signoff, and that other attribution lines are typical:
if ($line =~ /^\s*signed-off-by:/i) {
# This is a signoff, if ugly, so do not double report.
$signoff++;
@@ -1470,6 +1470,10 @@ sub process {
ERROR("space required after Signed-off-by:\n" .
$herecurr);
}
+   } elsif($line =~ /^\s*([A-Za-z-])*-by:/ &&
+   ($1 !~ /(Suggest|Report|Test|Ack|Review)ed/ ||
+$line !~ /^\s[a-z-]*-by:\S/i)) {
+   WARN("suspicious attribution tag:\n" . $herecurr);
}

 # Check if MAINTAINERS is being updated.  If so, there's probably no need to
-- 
2.20.1




Re: [Qemu-devel] [PATCH v3 4/5] tests/uefi-test-tools: add build scripts

2019-02-04 Thread Michael S. Tsirkin
On Mon, Feb 04, 2019 at 08:46:33PM +0100, Philippe Mathieu-Daudé wrote:
> Hi Michael,
> 
> On 2/4/19 8:32 PM,  Michael S. Tsirkin wrote:
> > On Mon, Feb 04, 2019 at 07:41:38PM +0100, Laszlo Ersek wrote:
> >> On 02/04/19 18:47, Michael S. Tsirkin wrote:
> >>> On Mon, Feb 04, 2019 at 05:03:24PM +0100, Laszlo Ersek wrote:
>  Introduce the following build scripts under "tests/uefi-test-tools":
> 
>  * "build.sh" builds a single module (a UEFI application) from
>    UefiTestToolsPkg, for a single QEMU emulation target.
> 
>    "build.sh" relies on cross-compilers when the emulation target and the
>    build host architecture don't match. The cross-compiler prefix is
>    computed according to a fixed, Linux-specific pattern. No attempt is
>    made to copy or reimplement the GNU Make magic from 
>  "qemu/roms/Makefile"
>    for cross-compiler prefix determination. The reason is that the build
>    host OSes that are officially supported by edk2, and those that are
>    supported by QEMU, intersect only in Linux. (Note that the UNIXGCC
>    toolchain is being removed from edk2,
>    .)
> 
>  * "Makefile" currently builds the "UefiTestToolsPkg/BiosTablesTest"
>    application, for arm, aarch64, i386, and x86_64, with the help of
>    "build.sh".
> 
>    "Makefile" turns each resultant UEFI executable into a UEFI-bootable,
>    qcow2-compressed ISO image. The ISO images are output as
>    "tests/data/uefi-boot-images/bios-tables-test..iso.qcow2".
> 
>    Each ISO image should be passed to QEMU as follows:
> 
>  -drive id=boot-cd,if=none,readonly,format=qcow2,file=$ISO \
>  -device virtio-scsi-pci,id=scsi0 \
>  -device scsi-cd,drive=boot-cd,bus=scsi0.0,bootindex=0 \
> 
>    "Makefile" assumes that "mkdosfs", "mtools", and "genisoimage" are
>    present.
> 
>  Cc: "Michael S. Tsirkin" 
>  Cc: Ard Biesheuvel 
>  Cc: Gerd Hoffmann 
>  Cc: Igor Mammedov 
>  Cc: Philippe Mathieu-Daudé 
>  Cc: Shannon Zhao 
>  Signed-off-by: Laszlo Ersek 
>  Reviewed-by: Philippe Mathieu-Daudé 
>  Tested-by: Philippe Mathieu-Daudé 
>  ---
> 
>  Notes:
>  v3:
>  - explicitly mark the "./build.sh" recipe as recursive, with the "+"
>    indicator; document it in a comment [Phil]
>  - pick up R-b, T-b [Phil]
> 
>  v2:
>  - add the .NOTPARALLEL target [Phil, help-make, edk2-devel]
> 
>   tests/uefi-test-tools/Makefile   | 106 ++
>   tests/uefi-test-tools/.gitignore |   3 +
>   tests/uefi-test-tools/build.sh   | 145 
>   3 files changed, 254 insertions(+)
> 
>  diff --git a/tests/uefi-test-tools/Makefile 
>  b/tests/uefi-test-tools/Makefile
>  new file mode 100644
>  index ..1d78bc14d51a
>  --- /dev/null
>  +++ b/tests/uefi-test-tools/Makefile
>  @@ -0,0 +1,106 @@
>  +# Makefile for the test helper UEFI applications that run in guests.
>  +#
>  +# Copyright (C) 2019, Red Hat, Inc.
>  +#
>  +# This program and the accompanying materials are licensed and made 
>  available
>  +# under the terms and conditions of the BSD License that accompanies 
>  this
>  +# distribution. The full text of the license may be found at
>  +# .
>  +#
>  +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
>  WITHOUT
>  +# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
>  +
>  +edk2_dir  := ../../roms/edk2
>  +images_dir:= ../data/uefi-boot-images
>  +emulation_targets := arm aarch64 i386 x86_64
>  +uefi_binaries := bios-tables-test
>  +intermediate_suffixes := .efi .fat .iso.raw
>  +
>  +images: $(foreach binary,$(uefi_binaries), \
>  +$(foreach target,$(emulation_targets), \
>  +$(images_dir)/$(binary).$(target).iso.qcow2))
>  +
>  +# Preserve all intermediate targets if the build succeeds.
>  +# - Intermediate targets help with development & debugging.
>  +# - Preserving intermediate targets also keeps spurious changes out of 
>  the
>  +#   final build products, in case the user re-runs "make" without any 
>  changes
>  +#   to the UEFI source code. Normally, the intermediate files would 
>  have been
>  +#   removed by the last "make" invocation, hence the re-run would 
>  rebuild them
>  +#   from the unchanged UEFI sources. Unfortunately, the "mkdosfs" and
>  +#   "genisoimage" utilities embed timestamp-based information in their 
>  outputs,
>  +#   which causes git to report differences for the tracked qcow2 ISO 
>  images.
>  +.SECONDARY: 

Re: [Qemu-devel] [qemu-s390x] [PATCH v2 3/6] s390x/pci: Warn when adding PCI devices without the 'zpci' feature

2019-02-04 Thread David Hildenbrand
On 04.02.19 21:19, Collin Walling wrote:
> On 1/30/19 10:57 AM, David Hildenbrand wrote:
>> We decided to always create the PCI host bridge, even if 'zpci' is not
>> enabled (due to migration compatibility). This however right now allows
>> to add zPCI/PCI devices to a VM although the guest will never actually see
>> them, confusing people that are using a simple CPU model that has no
>> 'zpci' enabled - "Why isn't this working" (David Hildenbrand)
>>
>> Let's check for 'zpci' and at least print a warning that this will not
>> work as expected. We could also bail out, however that might break
>> existing QEMU commandlines.
>>
>> Reviewed-by: Thomas Huth 
>> Signed-off-by: David Hildenbrand 
>> ---
>>   hw/s390x/s390-pci-bus.c | 5 +
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
>> index 9b5c5fff60..2efd9186c2 100644
>> --- a/hw/s390x/s390-pci-bus.c
>> +++ b/hw/s390x/s390-pci-bus.c
>> @@ -826,6 +826,11 @@ static void s390_pcihost_pre_plug(HotplugHandler 
>> *hotplug_dev, DeviceState *dev,
>>   {
>>   S390pciState *s = S390_PCI_HOST_BRIDGE(hotplug_dev);
>>   
>> +if (!s390_has_feat(S390_FEAT_ZPCI)) {
>> +warn_report("PCI/zPCI device without the 'zpci' CPU feature."
>> +" The guest will not be able to see/use this device");
>> +}
>> +
>>   if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
>>   PCIDevice *pdev = PCI_DEVICE(dev);
>>   
>>
> 
> I wonder if someone might misconstrue this as "the _PCI device_ needs
> the zpci feature." I think "'zpci' CPU feature required to support
> PCI/zPCI devices." reads better. The last sentence is fine to me.
> 

Well, the guest needs the 'zpci' feature to see the device. And that's
what that message says in my opinion. Not that a device needs to have a
feature (I added "CPU feature" for this reason).

"required to support" does it not make very clear what we actually want
to say.

Thanks!

-- 

Thanks,

David / dhildenb



Re: [Qemu-devel] [PATCH v3 2/6] vfio-ccw: rework ssch state handling

2019-02-04 Thread Eric Farman




On 01/30/2019 08:22 AM, Cornelia Huck wrote:

The flow for processing ssch requests can be improved by splitting
the BUSY state:

- CP_PROCESSING: We reject any user space requests while we are in
   the process of translating a channel program and submitting it to
   the hardware. Use -EAGAIN to signal user space that it should
   retry the request.
- CP_PENDING: We have successfully submitted a request with ssch and
   are now expecting an interrupt. As we can't handle more than one
   channel program being processed, reject any further requests with
   -EBUSY. A final interrupt will move us out of this state; this also
   fixes a latent bug where a non-final interrupt might have freed up
   a channel program that still was in progress.
   By making this a separate state, we make it possible to issue a
   halt or a clear while we're still waiting for the final interrupt
   for the ssch (in a follow-on patch).

It also makes a lot of sense not to preemptively filter out writes to
the io_region if we're in an incorrect state: the state machine will
handle this correctly.

Signed-off-by: Cornelia Huck 
---
  drivers/s390/cio/vfio_ccw_drv.c |  8 ++--
  drivers/s390/cio/vfio_ccw_fsm.c | 19 ++-
  drivers/s390/cio/vfio_ccw_ops.c |  2 --
  drivers/s390/cio/vfio_ccw_private.h |  3 ++-
  4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
index a10cec0e86eb..0b3b9de45c60 100644
--- a/drivers/s390/cio/vfio_ccw_drv.c
+++ b/drivers/s390/cio/vfio_ccw_drv.c
@@ -72,20 +72,24 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
  {
struct vfio_ccw_private *private;
struct irb *irb;
+   bool is_final;
  
  	private = container_of(work, struct vfio_ccw_private, io_work);

irb = >irb;
  
+	is_final = !(scsw_actl(>scsw) &

+(SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT));
if (scsw_is_solicited(>scsw)) {
cp_update_scsw(>cp, >scsw);
-   cp_free(>cp);
+   if (is_final)
+   cp_free(>cp);
}
memcpy(private->io_region->irb_area, irb, sizeof(*irb));
  
  	if (private->io_trigger)

eventfd_signal(private->io_trigger, 1);
  
-	if (private->mdev)

+   if (private->mdev && is_final)
private->state = VFIO_CCW_STATE_IDLE;
  }
  
diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c

index e7c9877c9f1e..b4a141fbd1a8 100644
--- a/drivers/s390/cio/vfio_ccw_fsm.c
+++ b/drivers/s390/cio/vfio_ccw_fsm.c
@@ -28,7 +28,6 @@ static int fsm_io_helper(struct vfio_ccw_private *private)
sch = private->sch;
  
  	spin_lock_irqsave(sch->lock, flags);

-   private->state = VFIO_CCW_STATE_BUSY;
  
  	orb = cp_get_orb(>cp, (u32)(addr_t)sch, sch->lpm);

if (!orb) {
@@ -46,6 +45,7 @@ static int fsm_io_helper(struct vfio_ccw_private *private)
 */
sch->schib.scsw.cmd.actl |= SCSW_ACTL_START_PEND;
ret = 0;
+   private->state = VFIO_CCW_STATE_CP_PENDING;


[1]


break;
case 1: /* Status pending */
case 2: /* Busy */
@@ -107,6 +107,12 @@ static void fsm_io_busy(struct vfio_ccw_private *private,
private->io_region->ret_code = -EBUSY;
  }
  
+static void fsm_io_retry(struct vfio_ccw_private *private,

+enum vfio_ccw_event event)
+{
+   private->io_region->ret_code = -EAGAIN;
+}
+
  static void fsm_disabled_irq(struct vfio_ccw_private *private,
 enum vfio_ccw_event event)
  {
@@ -135,8 +141,7 @@ static void fsm_io_request(struct vfio_ccw_private *private,
struct mdev_device *mdev = private->mdev;
char *errstr = "request";
  
-	private->state = VFIO_CCW_STATE_BUSY;

-
+   private->state = VFIO_CCW_STATE_CP_PROCESSING;


[1]


memcpy(scsw, io_region->scsw_area, sizeof(*scsw));
  
  	if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) {

@@ -181,7 +186,6 @@ static void fsm_io_request(struct vfio_ccw_private *private,
}
  
  err_out:

-   private->state = VFIO_CCW_STATE_IDLE;


[1] Revisiting these locations as from an earlier discussion [2]... 
These go IDLE->CP_PROCESSING->CP_PENDING if we get a cc=0 on the SSCH, 
but we stop in CP_PROCESSING if the SSCH gets a nonzero cc.  Shouldn't 
we cleanup and go back to IDLE in this scenario, rather than forcing 
userspace to escalate to CSCH/HSCH after some number of retries (via FSM)?


[2] https://patchwork.kernel.org/patch/10773611/#22447997

Besides that, I think this looks good to me.

 - Eric


trace_vfio_ccw_io_fctl(scsw->cmd.fctl, get_schid(private),
   io_region->ret_code, errstr);
  }
@@ -221,7 +225,12 @@ fsm_func_t 
*vfio_ccw_jumptable[NR_VFIO_CCW_STATES][NR_VFIO_CCW_EVENTS] = {
[VFIO_CCW_EVENT_IO_REQ] = fsm_io_request,

[Qemu-devel] [PATCH v3 2/3] util/cutils: Move ctype macros to "cutils.h"

2019-02-04 Thread Philippe Mathieu-Daudé
Introduced in cd390083ad1, these macros don't need to be in
a generic header.
Add documentation to justify their use.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Stefano Garzarella 
Reviewed-by: David Gibson 
---
v2: Fixed checkpatch warnings (tabs)
---
 hw/core/bus.c  |  2 +-
 hw/core/qdev-properties.c  |  1 +
 hw/s390x/s390-virtio-ccw.c |  1 +
 hw/scsi/scsi-generic.c |  2 +-
 include/qemu-common.h  | 16 
 include/qemu/cutils.h  | 25 +
 qapi/qapi-util.c   |  2 +-
 qobject/json-parser.c  |  1 -
 target/ppc/monitor.c   |  1 +
 target/riscv/cpu.c |  1 +
 ui/keymaps.c   |  1 +
 util/id.c  |  2 +-
 util/readline.c|  1 -
 13 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/hw/core/bus.c b/hw/core/bus.c
index 4651f24486..dceb144075 100644
--- a/hw/core/bus.c
+++ b/hw/core/bus.c
@@ -18,7 +18,7 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
+#include "qemu/cutils.h"
 #include "hw/qdev.h"
 #include "qapi/error.h"
 
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 5da1439a8b..f36006bfce 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1,4 +1,5 @@
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "net/net.h"
 #include "hw/qdev.h"
 #include "qapi/error.h"
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 811fdf913d..3ef42dfaf9 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/boards.h"
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 7237b4162e..86f65fd474 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -12,8 +12,8 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/cutils.h"
 #include "qapi/error.h"
-#include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "hw/scsi/scsi.h"
 #include "hw/scsi/emulation.h"
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 760527294f..ed43ae286d 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -33,22 +33,6 @@ int qemu_main(int argc, char **argv, char **envp);
 void qemu_get_timedate(struct tm *tm, int offset);
 int qemu_timedate_diff(struct tm *tm);
 
-#define qemu_isalnum(c)isalnum((unsigned char)(c))
-#define qemu_isalpha(c)isalpha((unsigned char)(c))
-#define qemu_iscntrl(c)iscntrl((unsigned char)(c))
-#define qemu_isdigit(c)isdigit((unsigned char)(c))
-#define qemu_isgraph(c)isgraph((unsigned char)(c))
-#define qemu_islower(c)islower((unsigned char)(c))
-#define qemu_isprint(c)isprint((unsigned char)(c))
-#define qemu_ispunct(c)ispunct((unsigned char)(c))
-#define qemu_isspace(c)isspace((unsigned char)(c))
-#define qemu_isupper(c)isupper((unsigned char)(c))
-#define qemu_isxdigit(c)   isxdigit((unsigned char)(c))
-#define qemu_tolower(c)tolower((unsigned char)(c))
-#define qemu_toupper(c)toupper((unsigned char)(c))
-#define qemu_isascii(c)isascii((unsigned char)(c))
-#define qemu_toascii(c)toascii((unsigned char)(c))
-
 void *qemu_oom_check(void *ptr);
 
 ssize_t qemu_write_full(int fd, const void *buf, size_t count)
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 9ee40470e3..644f2d75bd 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -3,6 +3,31 @@
 
 #include "qemu/fprintf-fn.h"
 
+/**
+ * unsigned ctype macros:
+ *
+ * The standards require that the argument for these functions
+ * is either EOF or a value that is representable in the type
+ * unsigned char. If the argument is of type char, it must be
+ * cast to unsigned char. This is what these macros do,
+ * avoiding 'signed to unsigned' conversion warnings.
+ */
+#define qemu_isalnum(c) isalnum((unsigned char)(c))
+#define qemu_isalpha(c) isalpha((unsigned char)(c))
+#define qemu_iscntrl(c) iscntrl((unsigned char)(c))
+#define qemu_isdigit(c) isdigit((unsigned char)(c))
+#define qemu_isgraph(c) isgraph((unsigned char)(c))
+#define qemu_islower(c) islower((unsigned char)(c))
+#define qemu_isprint(c) isprint((unsigned char)(c))
+#define qemu_ispunct(c) ispunct((unsigned char)(c))
+#define qemu_isspace(c) isspace((unsigned char)(c))
+#define qemu_isupper(c) isupper((unsigned char)(c))
+#define qemu_isxdigit(c)isxdigit((unsigned char)(c))
+#define qemu_tolower(c) tolower((unsigned char)(c))
+#define qemu_toupper(c) toupper((unsigned char)(c))
+#define qemu_isascii(c) isascii((unsigned char)(c))
+#define qemu_toascii(c) toascii((unsigned char)(c))
+
 /**
  * pstrcpy:
  * @buf: buffer to copy string into
diff --git a/qapi/qapi-util.c 

[Qemu-devel] [PATCH v3 1/3] util/cutils: Move size_to_str() from "qemu-common.h" to "cutils.h"

2019-02-04 Thread Philippe Mathieu-Daudé
The size_to_str() function doesn't need to be in a generic header.

It makes also sense to find this function in the same header as
the opposite string to size functions: qemu_strtosz*().
Note that this function is already implemented in util/cutils.c.

Since we introduce a new function in a header, we document it,
using the previous comment from the source file.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: Eric Blake 
Reviewed-by: David Gibson 
Reviewed-by: Stefano Garzarella 
Reviewed-by: Cornelia Huck 
---
 include/qemu-common.h|  1 -
 include/qemu/cutils.h| 13 +
 qapi/string-output-visitor.c |  2 +-
 util/cutils.c|  6 --
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index ed60ba251d..760527294f 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -153,7 +153,6 @@ void qemu_hexdump(const char *buf, FILE *fp, const char 
*prefix, size_t size);
 int parse_debug_env(const char *name, int max, int initial);
 
 const char *qemu_ether_ntoa(const MACAddr *mac);
-char *size_to_str(uint64_t val);
 void page_size_init(void);
 
 /* returns non-zero if dump is in progress, otherwise zero is
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index d2dad3057c..9ee40470e3 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -157,6 +157,19 @@ int qemu_strtosz(const char *nptr, const char **end, 
uint64_t *result);
 int qemu_strtosz_MiB(const char *nptr, const char **end, uint64_t *result);
 int qemu_strtosz_metric(const char *nptr, const char **end, uint64_t *result);
 
+/**
+ * size_to_str:
+ *
+ * Return human readable string for size @val.
+ * Use IEC binary units like KiB, MiB, and so forth.
+ *
+ * @val: The value to format.
+ *   Can be anything that uint64_t allows (no more than "16 EiB").
+ *
+ * Caller is responsible for passing it to g_free().
+ */
+char *size_to_str(uint64_t val);
+
 /* used to print char* safely */
 #define STR_OR_NULL(str) ((str) ? (str) : "null")
 
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 7ab64468d9..edf268b373 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -11,9 +11,9 @@
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "qapi/string-output-visitor.h"
 #include "qapi/visitor-impl.h"
+#include "qemu/cutils.h"
 #include "qemu/host-utils.h"
 #include 
 #include "qemu/range.h"
diff --git a/util/cutils.c b/util/cutils.c
index e098debdc0..a8a3a3ba3b 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -816,12 +816,6 @@ const char *qemu_ether_ntoa(const MACAddr *mac)
 return ret;
 }
 
-/*
- * Return human readable string for size @val.
- * @val can be anything that uint64_t allows (no more than "16 EiB").
- * Use IEC binary units like KiB, MiB, and so forth.
- * Caller is responsible for passing it to g_free().
- */
 char *size_to_str(uint64_t val)
 {
 static const char *suffixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" };
-- 
2.20.1




[Qemu-devel] [PATCH 2/3] hw/unicore32/puv3: Drop useless inclusion of "hw/i386/pc.h"

2019-02-04 Thread Philippe Mathieu-Daudé
In 47973a2dbf we split the last generic chipset out of the PC
board, but forgot to remove the include of "hw/i386/pc.h".
Since it is now unused, remove it.

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

diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c
index 830fe3face..b42e600f74 100644
--- a/hw/unicore32/puv3.c
+++ b/hw/unicore32/puv3.c
@@ -15,7 +15,6 @@
 #include "ui/console.h"
 #include "hw/boards.h"
 #include "hw/loader.h"
-#include "hw/i386/pc.h"
 #include "sysemu/qtest.h"
 
 #undef DEBUG_PUV3
-- 
2.20.1




[Qemu-devel] [PATCH v3 0/3] cutils: Cleanup, improve documentation

2019-02-04 Thread Philippe Mathieu-Daudé
This series is a fairly trivial cleanup of "cutils.h"
(size_to_str() and ctype macros moved into it), and
some documentation improvements.

Since v2:
- Fixed RISC-V (Laurent)

Since v1:
- Fixed checkpatch errors (patchew)
- Added Stefano R-b

$ git backport-diff -u v2
[] : patches are identical
[] : number of functional differences between upstream/downstream patch
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/3:[] [--] 'util/cutils: Move size_to_str() from "qemu-common.h" to 
"cutils.h"'
002/3:[0001] [FC] 'util/cutils: Move ctype macros to "cutils.h"'
003/3:[] [--] 'util/cutils: Move function documentations to the header'

v2: https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00629.html
v1: https://lists.gnu.org/archive/html/qemu-devel/2018-12/msg05927.html

Regards,

Phil.

Philippe Mathieu-Daudé (3):
  util/cutils: Move size_to_str() from "qemu-common.h" to "cutils.h"
  util/cutils: Move ctype macros to "cutils.h"
  util/cutils: Move function documentations to the header

 hw/core/bus.c|   2 +-
 hw/core/qdev-properties.c|   1 +
 hw/s390x/s390-virtio-ccw.c   |   1 +
 hw/scsi/scsi-generic.c   |   2 +-
 include/qemu-common.h|  17 ---
 include/qemu/cutils.h| 262 +++
 qapi/qapi-util.c |   2 +-
 qapi/string-output-visitor.c |   2 +-
 qobject/json-parser.c|   1 -
 target/ppc/monitor.c |   1 +
 target/riscv/cpu.c   |   1 +
 ui/keymaps.c |   1 +
 util/cutils.c| 191 -
 util/id.c|   2 +-
 util/readline.c  |   1 -
 15 files changed, 272 insertions(+), 215 deletions(-)

-- 
2.20.1




Re: [Qemu-devel] [PATCH 2/2] target/i386: sev: Do not pin the ram device memory region

2019-02-04 Thread Singh, Brijesh


On 2/4/19 11:59 AM, Alex Williamson wrote:
> On Thu, 17 Jan 2019 21:53:16 +
> "Singh, Brijesh"  wrote:
> 
>> The RAM device presents a memory region that should be handled
>> as an IO region and should not be pinned.
>>
>> In the case of the vfio-pci, RAM device represents a MMIO BAR
>> and the memory region is not backed by pages hence
>> KVM_MEMORY_ENCRYPT_REG_REGION fails to lock the memory range.
>>
>> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
>> Cc: Alex Williamson 
>> Cc: Paolo Bonzini 
>> Signed-off-by: Brijesh Singh 
>> ---
>>   target/i386/sev.c | 11 +++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/target/i386/sev.c b/target/i386/sev.c
>> index 20b2d325d8..3e9d5c02fa 100644
>> --- a/target/i386/sev.c
>> +++ b/target/i386/sev.c
>> @@ -131,6 +131,17 @@ sev_ram_block_added(RAMBlockNotifier *n, void *host, 
>> size_t size)
>>   {
>>   int r;
>>   struct kvm_enc_region range;
>> +ram_addr_t offset;
>> +MemoryRegion *mr;
>> +
>> +mr = memory_region_from_host(host, );
>> +/*
>> + * The RAM device presents a memory region that should be treated
>> + * as IO region and should not be pinned.
>> + */
>> +if (memory_region_is_ram_device(mr)) {
>> +return;
>> +}
>>   
>>   range.addr = (__u64)(unsigned long)host;
>>   range.size = size;
> 
> 
> memory_region_from_host() can return NULL, which would give you a
> segfault at memory_region_is_ram_device(), so you might want to test mr
> on it's own first and decide which path that would take.  Thanks,
> 


Ah, thanks for catching it. I will fix in v2.



[Qemu-devel] [PATCH v3 3/3] util/cutils: Move function documentations to the header

2019-02-04 Thread Philippe Mathieu-Daudé
Many functions have documentation before the implementation in
cutils.c. Since we expect documentation around the prototype
declaration in headers, move the comments in cutils.h.

Signed-off-by: Philippe Mathieu-Daudé 
Reviewed-by: David Gibson 
Reviewed-by: Stefano Garzarella 
---
 include/qemu/cutils.h | 224 ++
 util/cutils.c | 185 --
 2 files changed, 224 insertions(+), 185 deletions(-)

diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 644f2d75bd..f41b00ad37 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -47,6 +47,7 @@
  *bytes and then add a NUL
  */
 void pstrcpy(char *buf, int buf_size, const char *str);
+
 /**
  * strpadcpy:
  * @buf: buffer to copy string into
@@ -60,6 +61,7 @@ void pstrcpy(char *buf, int buf_size, const char *str);
  * first @buf_size characters of @str, with no terminator.
  */
 void strpadcpy(char *buf, int buf_size, const char *str, char pad);
+
 /**
  * pstrcat:
  * @buf: buffer containing existing string
@@ -77,6 +79,7 @@ void strpadcpy(char *buf, int buf_size, const char *str, char 
pad);
  * Returns: @buf.
  */
 char *pstrcat(char *buf, int buf_size, const char *s);
+
 /**
  * strstart:
  * @str: string to test
@@ -94,6 +97,7 @@ char *pstrcat(char *buf, int buf_size, const char *s);
  * Returns: true if @str starts with prefix @val, false otherwise.
  */
 int strstart(const char *str, const char *val, const char **ptr);
+
 /**
  * stristart:
  * @str: string to test
@@ -110,6 +114,7 @@ int strstart(const char *str, const char *val, const char 
**ptr);
  *  false otherwise.
  */
 int stristart(const char *str, const char *val, const char **ptr);
+
 /**
  * qemu_strnlen:
  * @s: string
@@ -126,6 +131,7 @@ int stristart(const char *str, const char *val, const char 
**ptr);
  * Returns: length of @s in bytes, or @max_len, whichever is smaller.
  */
 int qemu_strnlen(const char *s, int max_len);
+
 /**
  * qemu_strsep:
  * @input: pointer to string to parse
@@ -147,6 +153,16 @@ int qemu_strnlen(const char *s, int max_len);
  * Returns: the pointer originally in @input.
  */
 char *qemu_strsep(char **input, const char *delim);
+
+/**
+ * qemu_strchrnul:
+ *
+ * @s: String to parse.
+ * @c: Character to find.
+ *
+ * Searches for the first occurrence of @c in @s, and returns a pointer
+ * to the trailing null byte if none was found.
+ */
 #ifdef HAVE_STRCHRNUL
 static inline const char *qemu_strchrnul(const char *s, int c)
 {
@@ -155,27 +171,235 @@ static inline const char *qemu_strchrnul(const char *s, 
int c)
 #else
 const char *qemu_strchrnul(const char *s, int c);
 #endif
+
 time_t mktimegm(struct tm *tm);
 int qemu_fdatasync(int fd);
 int fcntl_setfl(int fd, int flag);
 int qemu_parse_fd(const char *param);
+
+/**
+ * qemu_strtoi:
+ *
+ * Convert string @nptr to an integer, and store it in @result.
+ *
+ * This is a wrapper around strtol() that is harder to misuse.
+ * Semantics of @nptr, @endptr, @base match strtol() with differences
+ * noted below.
+ *
+ * @nptr may be null, and no conversion is performed then.
+ *
+ * If no conversion is performed, store @nptr in *@endptr and return
+ * -EINVAL.
+ *
+ * If @endptr is null, and the string isn't fully converted, return
+ * -EINVAL.  This is the case when the pointer that would be stored in
+ * a non-null @endptr points to a character other than '\0'.
+ *
+ * If the conversion overflows @result, store INT_MAX in @result,
+ * and return -ERANGE.
+ *
+ * If the conversion underflows @result, store INT_MIN in @result,
+ * and return -ERANGE.
+ *
+ * Else store the converted value in @result, and return zero.
+ */
 int qemu_strtoi(const char *nptr, const char **endptr, int base,
 int *result);
+
+/**
+ * qemu_strtoui:
+ *
+ * Convert string @nptr to an unsigned integer, and store it in @result.
+ *
+ * This is a wrapper around strtoul() that is harder to misuse.
+ * Semantics of @nptr, @endptr, @base match strtoul() with differences
+ * noted below.
+ *
+ * @nptr may be null, and no conversion is performed then.
+ *
+ * If no conversion is performed, store @nptr in *@endptr and return
+ * -EINVAL.
+ *
+ * If @endptr is null, and the string isn't fully converted, return
+ * -EINVAL.  This is the case when the pointer that would be stored in
+ * a non-null @endptr points to a character other than '\0'.
+ *
+ * If the conversion overflows @result, store UINT_MAX in @result,
+ * and return -ERANGE.
+ *
+ * Else store the converted value in @result, and return zero.
+ *
+ * Note that a number with a leading minus sign gets converted without
+ * the minus sign, checked for overflow (see above), then negated (in
+ * @result's type).  This is exactly how strtoul() works.
+ */
 int qemu_strtoui(const char *nptr, const char **endptr, int base,
  unsigned int *result);
+
+/**
+ * qemu_strtol:
+ *
+ * Convert string @nptr to a long integer, and store it in @result.
+ *
+ * This is a 

[Qemu-devel] [PATCH 3/3] hw/ppc/prep: Drop useless inclusion of "hw/i386/pc.h"

2019-02-04 Thread Philippe Mathieu-Daudé
In 47973a2dbf we split the last generic chipset out of the PC
board, but forgot to remove the include of "hw/i386/pc.h".
Since it is now unused, remove it.

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

diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 7bda86a7d0..847d320465 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -26,7 +26,6 @@
 #include "cpu.h"
 #include "hw/hw.h"
 #include "hw/timer/m48t59.h"
-#include "hw/i386/pc.h"
 #include "hw/char/serial.h"
 #include "hw/block/fdc.h"
 #include "net/net.h"
-- 
2.20.1




Re: [Qemu-devel] [PATCH 3/3] hw/ppc/prep: Drop useless inclusion of "hw/i386/pc.h"

2019-02-04 Thread Hervé Poussineau

Le 04/02/2019 à 22:04, Philippe Mathieu-Daudé a écrit :

In 47973a2dbf we split the last generic chipset out of the PC
board, but forgot to remove the include of "hw/i386/pc.h".
Since it is now unused, remove it.

Signed-off-by: Philippe Mathieu-Daudé 


Reviewed-by: Hervé Poussineau 



[Qemu-devel] [PATCH 0/3] hw: Drop useless inclusion of hw/i386/pc.h

2019-02-04 Thread Philippe Mathieu-Daudé
Since 47973a2dbf, it is useless to include "hw/i386/pc.h"
on the ppc/unicore32/sparc64 boards.

The last non-x86 targets still requiring it are alpha/hppa/mips,
because the I8259 intc is still deeply mixed with the PC board.

Philippe Mathieu-Daudé (3):
  hw/sparc64/sun4u: Drop useless inclusion of "hw/i386/pc.h"
  hw/unicore32/puv3: Drop useless inclusion of "hw/i386/pc.h"
  hw/ppc/prep: Drop useless inclusion of "hw/i386/pc.h"

 hw/ppc/prep.c   | 1 -
 hw/sparc64/sun4u.c  | 1 -
 hw/unicore32/puv3.c | 1 -
 3 files changed, 3 deletions(-)

-- 
2.20.1




[Qemu-devel] [PATCH 1/3] hw/sparc64/sun4u: Drop useless inclusion of "hw/i386/pc.h"

2019-02-04 Thread Philippe Mathieu-Daudé
In 47973a2dbf we split the last generic chipset out of the PC
board, but forgot to remove the include of "hw/i386/pc.h".
Since it is now unused, remove it.

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

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index f76b19e4e9..fdf3f14a29 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -33,7 +33,6 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pci_host.h"
 #include "hw/pci-host/sabre.h"
-#include "hw/i386/pc.h"
 #include "hw/char/serial.h"
 #include "hw/char/parallel.h"
 #include "hw/timer/m48t59.h"
-- 
2.20.1




  1   2   3   4   5   >