]> Git Repo - qemu.git/log
qemu.git
8 years agoMerge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging
Peter Maydell [Thu, 2 Feb 2017 14:00:10 +0000 (14:00 +0000)]
Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging

# gpg: Signature made Wed 01 Feb 2017 05:32:23 GMT
# gpg:                using RSA key 0xBDBE7B27C0DE3057
# gpg: Good signature from "Jeffrey Cody <[email protected]>"
# gpg:                 aka "Jeffrey Cody <[email protected]>"
# gpg:                 aka "Jeffrey Cody <[email protected]>"
# Primary key fingerprint: 9957 4B4D 3474 90E7 9D98  D624 BDBE 7B27 C0DE 3057

* remotes/cody/tags/block-pull-request:
  sheepdog: reorganize check for overlapping requests
  sheepdog: simplify inflight_aio_head management
  sheepdog: do not use BlockAIOCB
  sheepdog: reorganize coroutine flow
  sheepdog: remove unused cancellation support

Signed-off-by: Peter Maydell <[email protected]>
8 years agoMerge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
Peter Maydell [Thu, 2 Feb 2017 11:03:37 +0000 (11:03 +0000)]
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

virtio, vhost, pci: fixes, features

generic pci root port support
disable shpc by default
safer version of ARRAY_SIZE and QEMU_BUILD_BUG_ON
fixes and cleanups all over the place

Signed-off-by: Michael S. Tsirkin <[email protected]>
# gpg: Signature made Wed 01 Feb 2017 01:38:34 GMT
# gpg:                using RSA key 0x281F0DB8D28D5469
# gpg: Good signature from "Michael S. Tsirkin <[email protected]>"
# gpg:                 aka "Michael S. Tsirkin <[email protected]>"
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream: (22 commits)
  arm: add trailing ; after MISMATCH_CHECK
  arm: better stub version for MISMATCH_CHECK
  hw/pci: disable pci-bridge's shpc by default
  vhost-user: delete chardev on cleanup
  vhost: skip ROM sections
  virtio: make virtio_should_notify static
  pci: Convert msix_init() to Error and fix callers
  hcd-xhci: check & correct param before using it
  msix: Follow CODING_STYLE
  hw/i386: check if nvdimm is enabled before plugging
  hw/pcie: Introduce Generic PCI Express Root Port
  hw/ioh3420: derive from PCI Express Root Port base class
  hw/pcie: Introduce a base class for PCI Express Root Ports
  intel_iommu: fix and simplify size calculation in process_device_iotlb_desc()
  pci: mark ROMs read-only
  ARRAY_SIZE: check that argument is an array
  compiler: expression version of QEMU_BUILD_BUG_ON
  compiler: rework BUG_ON using a struct
  QEMU_BUILD_BUG_ON: use __COUNTER__
  ppc: switch to constants within BUILD_BUG_ON
  ...

Signed-off-by: Peter Maydell <[email protected]>
8 years agoMerge remote-tracking branch 'remotes/elmarco/tags/chr-split-pull-request' into staging
Peter Maydell [Thu, 2 Feb 2017 09:50:21 +0000 (09:50 +0000)]
Merge remote-tracking branch 'remotes/elmarco/tags/chr-split-pull-request' into staging

# gpg: Signature made Tue 31 Jan 2017 19:32:40 GMT
# gpg:                using RSA key 0xDAE8E10975969CE5
# gpg: Good signature from "Marc-André Lureau <[email protected]>"
# gpg:                 aka "Marc-André Lureau <[email protected]>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* remotes/elmarco/tags/chr-split-pull-request: (41 commits)
  char: headers clean-up
  char: move parallel chardev in its own file
  char: move serial chardev to its own file
  char: move pty chardev in its own file
  char: move pipe chardev in its own file
  char: move console in its own file
  char: move stdio in its own file
  char: move file chardev in its own file
  char: move udp chardev in its own file
  char: move socket chardev to its own file
  char: move win-stdio into its own file
  char: move win chardev base class in its own file
  char: move fd chardev in its own file
  char: move QIOChannel-related stuff to char-io.h
  char: remove unused READ_RETRIES
  char: rename and move to header CHR_READ_BUF_LEN
  char: move ringbuf/memory to its own file
  char: move mux to its own file
  char: move null chardev to its own file
  char: make null_chr_write() the default method
  ...

Signed-off-by: Peter Maydell <[email protected]>
8 years agosheepdog: reorganize check for overlapping requests
Paolo Bonzini [Tue, 29 Nov 2016 11:32:45 +0000 (12:32 +0100)]
sheepdog: reorganize check for overlapping requests

Wrap the code that was copied repeatedly in the two functions,
sd_aio_setup and sd_aio_complete.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-id: 20161129113245[email protected]
Signed-off-by: Jeff Cody <[email protected]>
8 years agosheepdog: simplify inflight_aio_head management
Paolo Bonzini [Tue, 29 Nov 2016 11:32:44 +0000 (12:32 +0100)]
sheepdog: simplify inflight_aio_head management

Add to the list in add_aio_request and, indirectly, resend_aioreq.  Inline
free_aio_req in the caller, it does not simply undo alloc_aio_req's job.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-id: 20161129113245[email protected]
Signed-off-by: Jeff Cody <[email protected]>
8 years agosheepdog: do not use BlockAIOCB
Paolo Bonzini [Tue, 29 Nov 2016 11:32:43 +0000 (12:32 +0100)]
sheepdog: do not use BlockAIOCB

Sheepdog's AIOCB are completely internal entities for a group of
requests and do not need dynamic allocation.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-id: 20161129113245[email protected]
Signed-off-by: Jeff Cody <[email protected]>
8 years agosheepdog: reorganize coroutine flow
Paolo Bonzini [Tue, 29 Nov 2016 11:32:42 +0000 (12:32 +0100)]
sheepdog: reorganize coroutine flow

Delimit co_recv's lifetime clearly in aio_read_response.

Do a simple qemu_coroutine_enter in aio_read_response, letting
sd_co_writev call sd_write_done.

Handle nr_pending in the same way in sd_co_rw_vector,
sd_write_done and sd_co_flush_to_disk.

Remove sd_co_rw_vector's return value; just leave with no
pending requests.

[Jeff: added missing 'return' back, spotted by Paolo after
       series was applied.]

Signed-off-by: Jeff Cody <[email protected]>
8 years agosheepdog: remove unused cancellation support
Paolo Bonzini [Tue, 29 Nov 2016 11:32:41 +0000 (12:32 +0100)]
sheepdog: remove unused cancellation support

SheepdogAIOCB is internal to sheepdog.c, hence it is never canceled.

Signed-off-by: Paolo Bonzini <[email protected]>
Message-id: 20161129113245[email protected]
Signed-off-by: Jeff Cody <[email protected]>
8 years agoarm: add trailing ; after MISMATCH_CHECK
Michael S. Tsirkin [Fri, 27 Jan 2017 16:20:07 +0000 (18:20 +0200)]
arm: add trailing ; after MISMATCH_CHECK

Macro calls without a trailing ; look weird in C, this works as a side
effect of how QEMU_BUILD_BUG_ON is implemented. Fix this up.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
8 years agoarm: better stub version for MISMATCH_CHECK
Michael S. Tsirkin [Fri, 27 Jan 2017 16:17:25 +0000 (18:17 +0200)]
arm: better stub version for MISMATCH_CHECK

stub version of MISMATCH_CHECK is empty so it's easy to misuse for
people not building kvm on arm.  Use QEMU_BUILD_BUG_ON similar to the
non-stub version to make it easier to catch bugs.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
8 years agohw/pci: disable pci-bridge's shpc by default
Marcel Apfelbaum [Wed, 25 Jan 2017 08:44:46 +0000 (10:44 +0200)]
hw/pci: disable pci-bridge's shpc by default

The shpc component is optional while  ACPI hotplug is used
for hot-plugging PCI devices into a PCI-PCI bridge.
Disabling the shpc by default will make slot 0 usable at boot time
and not only for hot-plug, without loosing any functionality.
Older machines will have shpc enabled for compatibility reasons.

Signed-off-by: Marcel Apfelbaum <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
8 years agovhost-user: delete chardev on cleanup
Marc-André Lureau [Tue, 24 Jan 2017 19:02:58 +0000 (23:02 +0400)]
vhost-user: delete chardev on cleanup

Remove the chardev implicitly when cleaning up the netdev. This
prevents from reusing the chardev since it would be in an incorrect
state with the slave.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1256618

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agovhost: skip ROM sections
Michael S. Tsirkin [Tue, 24 Jan 2017 17:03:40 +0000 (19:03 +0200)]
vhost: skip ROM sections

vhost does not support RO protections on memory at the moment - adding
ROMs would mean that e.g. a buggy guest might change them in-memory - a
condition from which guest reset does not recover. Not nice.

We also definitely don't want to try logging writes into ROMs -
in particular guests set very high addresses for ROM BARs
so logging these writes would waste a lot of memory.

Maybe ROMs could be supported with the iotlb variant -
not sure, but there seems to be no good reason for virtio
to try to do DMA from ROM. So let's just skip ROM memory.

Suggested-by: Laurent Vivier <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Tested-by: Laurent Vivier <[email protected]>
8 years agovirtio: make virtio_should_notify static
Paolo Bonzini [Fri, 20 Jan 2017 17:07:51 +0000 (18:07 +0100)]
virtio: make virtio_should_notify static

Signed-off-by: Paolo Bonzini <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
8 years agopci: Convert msix_init() to Error and fix callers
Cao jin [Tue, 17 Jan 2017 06:18:48 +0000 (14:18 +0800)]
pci: Convert msix_init() to Error and fix callers

msix_init() reports errors with error_report(), which is wrong when
it's used in realize().  The same issue was fixed for msi_init() in
commit 1108b2f. In order to make the API change as small as possible,
leave the return value check to later patch.

For some devices(like e1000e, vmxnet3, nvme) who won't fail because of
msix_init's failure, suppress the error report by passing NULL error
object.

Bonus: add comment for msix_init.

CC: Jiri Pirko <[email protected]>
CC: Gerd Hoffmann <[email protected]>
CC: Dmitry Fleytman <[email protected]>
CC: Jason Wang <[email protected]>
CC: Michael S. Tsirkin <[email protected]>
CC: Hannes Reinecke <[email protected]>
CC: Paolo Bonzini <[email protected]>
CC: Alex Williamson <[email protected]>
CC: Markus Armbruster <[email protected]>
CC: Marcel Apfelbaum <[email protected]>
Signed-off-by: Cao jin <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
8 years agohcd-xhci: check & correct param before using it
Cao jin [Tue, 17 Jan 2017 06:18:47 +0000 (14:18 +0800)]
hcd-xhci: check & correct param before using it

usb_xhci_realize() corrects invalid values of property "intrs"
automatically, but the uncorrected value is passed to msi_init(),
which chokes on invalid values.  Delay that until after the
correction.

Resources allocated by usb_xhci_init() are leaked when msi_init()
fails.  Fix by calling it after msi_init().

CC: Gerd Hoffmann <[email protected]>
CC: Markus Armbruster <[email protected]>
CC: Marcel Apfelbaum <[email protected]>
CC: Michael S. Tsirkin <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Acked-by: Marcel Apfelbaum <[email protected]>
Signed-off-by: Cao jin <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
8 years agomsix: Follow CODING_STYLE
Cao jin [Tue, 17 Jan 2017 06:18:46 +0000 (14:18 +0800)]
msix: Follow CODING_STYLE

CC: Markus Armbruster <[email protected]>
CC: Marcel Apfelbaum <[email protected]>
CC: Michael S. Tsirkin <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Acked-by: Marcel Apfelbaum <[email protected]>
Signed-off-by: Cao jin <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
8 years agohw/i386: check if nvdimm is enabled before plugging
Haozhong Zhang [Fri, 13 Jan 2017 11:56:51 +0000 (19:56 +0800)]
hw/i386: check if nvdimm is enabled before plugging

The missing of 'nvdimm' in the machine type option '-M' means NVDIMM
is disabled. QEMU should refuse to plug any NVDIMM device in this case
and report the misconfiguration.

The behavior of NVDIMM on unsupported platform (HW/FW) is vendor
specific. For some vendors, it's undefined and the platform may do
anything. Thus, I think QEMU is free to choose the implementation.
Aborting QEMU (i.e. refusing to boot) is the easiest one.

Reported-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Haozhong Zhang <[email protected]>
Message-Id: 20170112110928[email protected]
Message-Id: 20170111093630[email protected]
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Xiao Guangrong <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
8 years agohw/pcie: Introduce Generic PCI Express Root Port
Marcel Apfelbaum [Mon, 23 Jan 2017 19:20:20 +0000 (21:20 +0200)]
hw/pcie: Introduce Generic PCI Express Root Port

The Generic Root Port behaves almost the same as the
Intel's IOH device with id 3420, without having
Intel specific attributes.

The device has two purposes:
 (1) Can be used on both X86 and ARM machines.
 (2) It will allow us to tweak the behaviour
    (e.g add vendor-specific PCI capabilities)
     - something that obviously cannot be done
       on a known device.

Signed-off-by: Marcel Apfelbaum <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Tested-by: Andrea Bolognani <[email protected]>
8 years agohw/ioh3420: derive from PCI Express Root Port base class
Marcel Apfelbaum [Mon, 23 Jan 2017 19:20:19 +0000 (21:20 +0200)]
hw/ioh3420: derive from PCI Express Root Port base class

Preserve only Intel specific details.

Signed-off-by: Marcel Apfelbaum <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
8 years agohw/pcie: Introduce a base class for PCI Express Root Ports
Marcel Apfelbaum [Mon, 23 Jan 2017 19:20:18 +0000 (21:20 +0200)]
hw/pcie: Introduce a base class for PCI Express Root Ports

The 'base' PCI Express Root Port includes
the common code to be re-used for all
Root Ports implementations. Most of the code
was taken from the current implementation
of Intel's IOH 3420 Root Port.

Signed-off-by: Marcel Apfelbaum <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
8 years agointel_iommu: fix and simplify size calculation in process_device_iotlb_desc()
Jason Wang [Fri, 20 Jan 2017 06:35:28 +0000 (14:35 +0800)]
intel_iommu: fix and simplify size calculation in process_device_iotlb_desc()

We don't use 1ULL which is wrong during size calculation. Fix it, and
while at it, switch to use cto64() and adds a comments to make it
simpler and easier to be understood.

Reported-by: Paolo Bonzini <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
8 years agopci: mark ROMs read-only
Michael S. Tsirkin [Thu, 19 Jan 2017 19:34:28 +0000 (21:34 +0200)]
pci: mark ROMs read-only

Looks like we didn't mark PCI ROMs as RO allowing
mischief such as guests writing there.
Further, e.g. vhost gets confused trying to allocate
enough space to log writes there. Fix it up.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Marcel Apfelbaum <[email protected]>
Tested-by: Laurent Vivier <[email protected]>
8 years agoARRAY_SIZE: check that argument is an array
Michael S. Tsirkin [Wed, 18 Jan 2017 20:07:34 +0000 (22:07 +0200)]
ARRAY_SIZE: check that argument is an array

It's a familiar pattern: some code uses ARRAY_SIZE, then refactoring
changes the argument from an array to a pointer to a dynamically
allocated buffer.  Code keeps compiling but any ARRAY_SIZE calls now
return the size of the pointer divided by element size.

Let's add build time checks to ARRAY_SIZE before we allow more
of these in the code-base.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agocompiler: expression version of QEMU_BUILD_BUG_ON
Michael S. Tsirkin [Wed, 18 Jan 2017 20:05:15 +0000 (22:05 +0200)]
compiler: expression version of QEMU_BUILD_BUG_ON

QEMU_BUILD_BUG_ON uses a typedef in order to be safe
to use outside functions, but sometimes it's useful
to have a version that can be used within an expression.
Following what Linux does, introduce QEMU_BUILD_BUG_ON_ZERO
that return zero after checking condition at build time.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
8 years agocompiler: rework BUG_ON using a struct
Michael S. Tsirkin [Thu, 19 Jan 2017 20:56:14 +0000 (22:56 +0200)]
compiler: rework BUG_ON using a struct

There are theoretical concerns that some compilers might not trigger
build failures on attempts to define an array of size (x ? -1 : 1) where
x is a variable and make it a variable sized array instead. Let rewrite
using a struct with a negative bit field size instead as there are no
dynamic bit field sizes.  This is similar to what Linux does.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
8 years agoQEMU_BUILD_BUG_ON: use __COUNTER__
Michael S. Tsirkin [Tue, 31 Jan 2017 14:29:51 +0000 (16:29 +0200)]
QEMU_BUILD_BUG_ON: use __COUNTER__

Some headers use QEMU_BUILD_BUG_ON. This causes a problem
if the C file including that header happens to have
QEMU_BUILD_BUG_ON at the same line number.

Fix using a widely available extension: __COUNTER__.
If unavailable, provide a stub.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agoppc: switch to constants within BUILD_BUG_ON
Michael S. Tsirkin [Fri, 27 Jan 2017 16:24:55 +0000 (18:24 +0200)]
ppc: switch to constants within BUILD_BUG_ON

We are switching BUILD_BUG_ON to verify that it's parameter is a
compile-time constant, and it turns out that some gcc versions
(specifically gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609) are
not smart enough to figure it out for expressions involving local
variables. This is harmless but means that the check is ineffective for
these platforms.  To fix, replace the variable with macros.

Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
8 years agochar: headers clean-up
Marc-André Lureau [Mon, 12 Dec 2016 17:22:24 +0000 (20:22 +0300)]
char: headers clean-up

Those could probably be squashed with earlier patches, however I
couldn't easily identify them, test them or check if there are still
necessary on various platforms.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: move parallel chardev in its own file
Marc-André Lureau [Mon, 12 Dec 2016 17:13:11 +0000 (20:13 +0300)]
char: move parallel chardev in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move serial chardev to its own file
Marc-André Lureau [Mon, 12 Dec 2016 16:48:49 +0000 (19:48 +0300)]
char: move serial chardev to its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move pty chardev in its own file
Marc-André Lureau [Mon, 12 Dec 2016 16:12:14 +0000 (19:12 +0300)]
char: move pty chardev in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move pipe chardev in its own file
Marc-André Lureau [Mon, 12 Dec 2016 16:06:35 +0000 (19:06 +0300)]
char: move pipe chardev in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move console in its own file
Marc-André Lureau [Mon, 12 Dec 2016 16:03:09 +0000 (19:03 +0300)]
char: move console in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move stdio in its own file
Marc-André Lureau [Mon, 12 Dec 2016 15:59:04 +0000 (18:59 +0300)]
char: move stdio in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move file chardev in its own file
Marc-André Lureau [Mon, 12 Dec 2016 15:51:52 +0000 (18:51 +0300)]
char: move file chardev in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move udp chardev in its own file
Marc-André Lureau [Mon, 12 Dec 2016 15:48:09 +0000 (18:48 +0300)]
char: move udp chardev in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move socket chardev to its own file
Marc-André Lureau [Mon, 12 Dec 2016 15:41:00 +0000 (18:41 +0300)]
char: move socket chardev to its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move win-stdio into its own file
Marc-André Lureau [Mon, 12 Dec 2016 14:49:52 +0000 (17:49 +0300)]
char: move win-stdio into its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move win chardev base class in its own file
Marc-André Lureau [Mon, 12 Dec 2016 14:38:21 +0000 (17:38 +0300)]
char: move win chardev base class in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move fd chardev in its own file
Marc-André Lureau [Mon, 12 Dec 2016 14:08:59 +0000 (17:08 +0300)]
char: move fd chardev in its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Eric Blake <[email protected]>
8 years agochar: move QIOChannel-related stuff to char-io.h
Marc-André Lureau [Mon, 12 Dec 2016 14:07:52 +0000 (17:07 +0300)]
char: move QIOChannel-related stuff to char-io.h

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: remove unused READ_RETRIES
Marc-André Lureau [Mon, 12 Dec 2016 13:40:54 +0000 (16:40 +0300)]
char: remove unused READ_RETRIES

Curiously unused since its introduction in commit 7b0bfdf52d69.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: rename and move to header CHR_READ_BUF_LEN
Marc-André Lureau [Mon, 12 Dec 2016 13:39:35 +0000 (16:39 +0300)]
char: rename and move to header CHR_READ_BUF_LEN

This define is used by several character devices, place it in char
common header.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: move ringbuf/memory to its own file
Marc-André Lureau [Mon, 12 Dec 2016 13:32:18 +0000 (16:32 +0300)]
char: move ringbuf/memory to its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: move mux to its own file
Marc-André Lureau [Mon, 12 Dec 2016 12:06:14 +0000 (15:06 +0300)]
char: move mux to its own file

A mechanical move, except that qemu_chr_write_all() needs to be declared
in char.h header to be used from chardev unit files.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: move null chardev to its own file
Marc-André Lureau [Mon, 12 Dec 2016 11:43:10 +0000 (14:43 +0300)]
char: move null chardev to its own file

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: make null_chr_write() the default method
Marc-André Lureau [Mon, 12 Dec 2016 10:41:40 +0000 (13:41 +0300)]
char: make null_chr_write() the default method

All chardev must implement chr_write(), but parallel and null chardev
both use null_chr_write(). Move it to the base class, so we don't need
to export the function when splitting the chardev in respective files.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: create chardev-obj-y
Marc-André Lureau [Mon, 12 Dec 2016 12:49:01 +0000 (15:49 +0300)]
char: create chardev-obj-y

This will help to split char.c in several units without having to
reference them all everywhere. This is useful in particular for tests.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-ui-20170131-2' into staging
Peter Maydell [Tue, 31 Jan 2017 18:41:33 +0000 (18:41 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-ui-20170131-2' into staging

ui: bugfixes and small improvements all over the place.

# gpg: Signature made Tue 31 Jan 2017 15:48:20 GMT
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>"
# gpg:                 aka "Gerd Hoffmann <[email protected]>"
# gpg:                 aka "Gerd Hoffmann (private) <[email protected]>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/pull-ui-20170131-2:
  console: fix console resize
  gtk: Hardcode LC_CTYPE as C.utf-8
  vnc: fix overflow in vnc_update_stats
  spice: wakeup QXL worker to pick up mouse changes
  ui/gtk.c: add ctrl-alt-= support for zoom in acceleration
  ui: fix format specfier in vnc to avoid break in build.
  ui/gtk: Fix mouse wheel on 3.4.0 or later
  vnc: track LED state separately
  ui: add support for mice with extra/side buttons
  ps2: add support for mice with extra/side buttons
  qapi: add support for mice with extra/side buttons

Signed-off-by: Peter Maydell <[email protected]>
8 years agoconsole: fix console resize
Gerd Hoffmann [Tue, 24 Jan 2017 11:10:39 +0000 (12:10 +0100)]
console: fix console resize

Only skip surface reallocation in case the old surface was created using
qemu_alloc_display (via qemu_create_displaysurface) too, otherwise we
might end up with a DisplaySurface with the wrong backing storage.

Cc: [email protected]
Fixes: cd958edb1fae85d0c7d1e1acbff82d22724e8d64
Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Tested-by: Laszlo Ersek <[email protected]>
Message-id: 1485256239[email protected]

8 years agogtk: Hardcode LC_CTYPE as C.utf-8
Kevin Wolf [Tue, 31 Jan 2017 10:09:45 +0000 (11:09 +0100)]
gtk: Hardcode LC_CTYPE as C.utf-8

Commit 2cb5d2a4 removed setlocale() for everything except LC_MESSAGES in
order to avoid unwanted side effects such as using the wrong decimal
separator in generated JSON objects. However, the problem that unsetting
LC_CTYPE caused is that non-ASCII characters are considered
non-printable now and therefore the GTK menus display question marks for
accented letters, Chinese characters etc.

A first attempt to fix this [1] was rejected because even just setting
LC_CTYPE to the user's locale (and thereby modifying the semantics of
the ctype.h functions) could have unwanted effects that we're not aware
of yet.

Recently, however, glibc introduced a new locale "C.utf-8" that just
uses UTF-8 as its charset, but otherwise leaves the semantics alone.
Just setting the right character set is enough for our use case, so we
can just hardcode this one without having to be afraid of nasty side
effects.

Older systems that don't have the new locale will continue displaying
question marks, but this should fix the problem for most users.

[1] https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03591.html
    ('Re: gtk: use setlocale() for LC_MESSAGES only')

Signed-off-by: Kevin Wolf <[email protected]>
Message-id: 20170131100945[email protected]

[ kraxel: change C.utf-8 to C.UTF-8 ]

Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agoqxl: switch to constants within BUILD_BUG_ON
Michael S. Tsirkin [Wed, 25 Jan 2017 21:48:51 +0000 (23:48 +0200)]
qxl: switch to constants within BUILD_BUG_ON

We are switching BUILD_BUG_ON to verify that it's parameter is a
compile-time constant, and it turns out that some gcc versions
(specifically gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609) are
not smart enough to figure it out for expressions involving local
variables. This is harmless but means that the check is ineffective for
these platforms.  To fix, replace variables with macros.

Reported-by: Peter Maydell <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agocompiler: drop ; after BUILD_BUG_ON
Michael S. Tsirkin [Wed, 18 Jan 2017 20:02:53 +0000 (22:02 +0200)]
compiler: drop ; after BUILD_BUG_ON

All users include the trailing ; anyway, let's require that -
it seems cleaner.

Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
8 years agochar: move to chardev/
Marc-André Lureau [Fri, 9 Dec 2016 21:29:03 +0000 (00:29 +0300)]
char: move to chardev/

The following commits will split char.c in several files. Let's put them
in a subdirectory.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: remove class kind field
Marc-André Lureau [Fri, 9 Dec 2016 08:04:51 +0000 (11:04 +0300)]
char: remove class kind field

The class kind is necessary to lookup the chardev name in
qmp_chardev_add() after calling qemu_chr_new_from_opts() and to set
the appropriate ChardevBackend (mainly to free the right
fields).

qemu_chr_new_from_opts() can be changed to use a non-qmp function
using the chardev class typename. Introduce qemu_chardev_add() to be
called from qemu_chr_new_from_opts() and remove the class chardev kind
field. Set the backend->type in the parse callback (when non-common
fields are added).

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: rename remaining CharDriver to Chardev
Marc-André Lureau [Wed, 14 Dec 2016 10:27:58 +0000 (13:27 +0300)]
char: rename remaining CharDriver to Chardev

CharDriver no longer exists, it has been replaced with Chardev.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: get rid of CharDriver
Marc-André Lureau [Thu, 8 Dec 2016 21:50:12 +0000 (00:50 +0300)]
char: get rid of CharDriver

qemu_chr_new_from_opts() is modified to not need CharDriver backend[]
array, but uses instead objectified qmp_query_chardev_backends() and
char_get_class(). The alias field is moved outside in a ChardevAlias[],
similar to QDevAlias for devices.

"kind" and "parse" are moved to ChardevClass ("kind" is to be removed
next)

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar: remove chr_free
Marc-André Lureau [Thu, 8 Dec 2016 16:35:01 +0000 (19:35 +0300)]
char: remove chr_free

Now it uses Object instance_finalize instead.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-fd: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 16:32:57 +0000 (19:32 +0300)]
char-fd: convert to finalize

char-serial inherits from char-fd finalizer.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-win: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 16:32:42 +0000 (19:32 +0300)]
char-win: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-win: do not override chr_free
Marc-André Lureau [Thu, 8 Dec 2016 15:22:04 +0000 (18:22 +0300)]
char-win: do not override chr_free

For some unclear reason to me, char-file does not have chr_free on
win32. Since we want to switch to instance finalizer instead of class
chr_free, we should be able to run the base WinChardev class finalizer
in any case. Use a boolean to skip free to ease the transition to
instance finalizer.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-win-stdio: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 16:29:35 +0000 (19:29 +0300)]
char-win-stdio: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-stdio: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 16:31:45 +0000 (19:31 +0300)]
char-stdio: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-parallel: convert parallel to finalize
Marc-André Lureau [Thu, 8 Dec 2016 14:57:35 +0000 (17:57 +0300)]
char-parallel: convert parallel to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-ringbuf: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 14:47:17 +0000 (17:47 +0300)]
char-ringbuf: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-pty: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 13:52:38 +0000 (16:52 +0300)]
char-pty: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-socket: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 13:51:47 +0000 (16:51 +0300)]
char-socket: convert to finalize

Notice that finalize() will be run after a failure to open(), so cleanup
code must be adjusted.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agochar-udp: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 13:50:26 +0000 (16:50 +0300)]
char-udp: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agomux: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 13:48:15 +0000 (16:48 +0300)]
mux: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agomsmouse: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 13:34:44 +0000 (16:34 +0300)]
msmouse: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agobaum: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 13:34:33 +0000 (16:34 +0300)]
baum: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agospice-qemu-char: convert to finalize
Marc-André Lureau [Thu, 8 Dec 2016 13:34:16 +0000 (16:34 +0300)]
spice-qemu-char: convert to finalize

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
8 years agoMAINTAINERS: add myself to qemu-char.c
Marc-André Lureau [Mon, 30 Jan 2017 13:37:31 +0000 (17:37 +0400)]
MAINTAINERS: add myself to qemu-char.c

I consider to have enough experience with qemu-char to propose myself as
maintainer. This will allow me to send pull request without waiting for
Paolo.

Signed-off-by: Marc-André Lureau <[email protected]>
Acked-by: Paolo Bonzini <[email protected]>
8 years agovnc: fix overflow in vnc_update_stats
Gerd Hoffmann [Tue, 24 Jan 2017 09:00:28 +0000 (10:00 +0100)]
vnc: fix overflow in vnc_update_stats

Commit "bea60dd ui/vnc: fix potential memory corruption issues" is
incomplete.  vnc_update_stats must calculate width and height the same
way vnc_refresh_server_surface does it, to make sure we don't use width
and height values larger than the qemu vnc server can handle.

Commit "e22492d ui/vnc: disable adaptive update calculations if not
needed" masks the issue in the default configuration.  It triggers only
in case the "lossy" option is set to "on" (default is "off").

Cc: Marc-André Lureau <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-id: 1485248428[email protected]

8 years agospice: wakeup QXL worker to pick up mouse changes
Marc-André Lureau [Mon, 30 Jan 2017 10:45:40 +0000 (14:45 +0400)]
spice: wakeup QXL worker to pick up mouse changes

Without it, server-mode mouse is "slow" to update position: QXL will
wait until new display commands come. This is very visible with
virtio-gpu.

Signed-off-by: Marc-André Lureau <[email protected]>
Message-id: 20170130104540[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agoui/gtk.c: add ctrl-alt-= support for zoom in acceleration
Ziyue Yang [Tue, 31 Jan 2017 01:32:15 +0000 (09:32 +0800)]
ui/gtk.c: add ctrl-alt-= support for zoom in acceleration

Solving wishlist item at
https://bugs.launchpad.net/qemu/+bug/1656710
by accepting Ctrl-Alt-= as an additional zoom-in acceleration.

Using gtk_accel_group_connect to support multiple accelerations
triggering a single menu item since that gtk_accel_map_add_entry
seems to support only one acceleration. A wrapper function
gd_accel_zoom_in is added to support gtk_accel_group_connect's
callback activities.

Signed-off-by: Ziyue Yang <[email protected]>
Message-id: 1485826335[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agoui: fix format specfier in vnc to avoid break in build.
Rami Rosen [Tue, 10 Jan 2017 09:19:25 +0000 (11:19 +0200)]
ui: fix format specfier in vnc to avoid break in build.

When building qemu after setting _VNC_DEBUG to 1 (see ui/vnc.h),
we get the following error and the build breaks:
...
ui/vnc.c: In function ‘vnc_client_io_error’:
ui/vnc.c:1262:13: error: format ‘%d’ expects argument of type ‘int’, but
             VNC_DEBUG("Closing down client sock: ret %d (%s)\n",
             ^
cc1: all warnings being treated as errors
make: *** [ui/vnc.o] Error 1
...

This patch solves this issue by fixing the print format specifier
in vnc_client_io_error() to be %zd, which corresponds to the type
of the "ret" variable.

Signed-off-by: Rami Rosen <[email protected]>
Message-id: 1484039965[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agoui/gtk: Fix mouse wheel on 3.4.0 or later
OGAWA Hirofumi [Wed, 4 Jan 2017 20:41:16 +0000 (05:41 +0900)]
ui/gtk: Fix mouse wheel on 3.4.0 or later

On 3.4.0 or later, send GDK_SCROLL_SMOOTH event, instead of
GDK_SCROLL_UP/DOWN.

This fixes it by converting any smooth scroll to up/down.
(I.e. without smooth support)

Signed-off-by: OGAWA Hirofumi <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agovnc: track LED state separately
Pierre Ossman [Mon, 9 Jan 2017 16:14:02 +0000 (17:14 +0100)]
vnc: track LED state separately

Piggy-backing on the modifier state array made it difficult to send
out updates at the proper times.

Signed-off-by: Pierre Ossman <[email protected]>
Message-id: 5aa28297d665cee24ddab26bbf4633e4252f97b6.1483978442[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agoui: add support for mice with extra/side buttons
Fabian Lesniak [Tue, 6 Dec 2016 19:00:07 +0000 (20:00 +0100)]
ui: add support for mice with extra/side buttons

Adds input event generation for BTN_SIDE and BTN_EXTRA events to gtk and
input-linux methods.

Signed-off-by: Fabian Lesniak <[email protected]>
Message-id: 20161206190007[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agops2: add support for mice with extra/side buttons
Fabian Lesniak [Tue, 6 Dec 2016 19:00:06 +0000 (20:00 +0100)]
ps2: add support for mice with extra/side buttons

This enables the ps2 controller to process mouse events for buttons 4 and 5.
Additionally, distinct definitions for the ps2 mouse button state are
introduced. The legacy definitions from console.h are not used anymore.

Signed-off-by: Fabian Lesniak <[email protected]>
Message-id: 20161206190007[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agoqapi: add support for mice with extra/side buttons
Fabian Lesniak [Tue, 6 Dec 2016 19:00:05 +0000 (20:00 +0100)]
qapi: add support for mice with extra/side buttons

Adds "side" and "extra" values to enum InputButton. The naming was borrowed
from evdev since it is more descriptive than "button4" and "button5".

Signed-off-by: Fabian Lesniak <[email protected]>
Message-id: 20161206190007[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
8 years agoMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
Peter Maydell [Mon, 30 Jan 2017 10:23:20 +0000 (10:23 +0000)]
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging

* SCSI max_transfer support for scsi-generic (Eric)
* x86 SMI broadcast (Laszlo)
* Character device QOMification (Marc-André)
* Record/replay improvements (Pavel)
* iscsi fixes (Peter L.)
* "info mtree -f" command (Peter Xu)
* TSC clock rate reporting (Phil)
* DEVICE_CATEGORY_CPU (Thomas)
* Memory sign-extension fix (Ladi)

# gpg: Signature made Fri 27 Jan 2017 17:08:51 GMT
# gpg:                using RSA key 0xBFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <[email protected]>"
# gpg:                 aka "Paolo Bonzini <[email protected]>"
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini/tags/for-upstream: (41 commits)
  memory: don't sign-extend 32-bit writes
  chardev: qom-ify
  vc: use a common prefix for chr callbacks
  baum: use a common prefix for chr callbacks
  gtk: overwrite the console.c char driver
  char: use error_report()
  spice-char: improve error reporting
  char: rename TCPChardev and NetChardev
  char: rename CharDriverState Chardev
  bt: use qemu_chr_alloc()
  char: allocate CharDriverState as a single object
  char: use a feature bit for replay
  char: introduce generic qemu_chr_get_kind()
  char: fold single-user functions in caller
  char: move callbacks in CharDriver
  char: use a static array for backends
  char: use a const CharDriver
  doc: fix spelling
  char: add qemu_chr_fe_add_watch() Returns description
  qemu-options: stdio is available on win32
  ...

Signed-off-by: Peter Maydell <[email protected]>
8 years agomemory: don't sign-extend 32-bit writes
Ladi Prosek [Thu, 26 Jan 2017 14:22:37 +0000 (15:22 +0100)]
memory: don't sign-extend 32-bit writes

ldl_p has a signed return type so assigning it to uint64_t implicitly
sign-extends the value. This results in devices with min_access_size = 8
seeing unexpected values passed to their write handlers.

Example: guest performs a 32-bit write of 0x80000000 to an mmio region
and the handler receives 0xFFFFFFFF80000000 in its value argument.

Signed-off-by: Ladi Prosek <[email protected]>
Message-Id: <1485440557[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochardev: qom-ify
Marc-André Lureau [Wed, 7 Dec 2016 15:39:10 +0000 (18:39 +0300)]
chardev: qom-ify

Turn Chardev into Object.

qemu_chr_alloc() is replaced by the qemu_chardev_new() constructor. It
will call qemu_char_open() to open/intialize the chardev with the
ChardevCommon *backend settings.

The CharDriver::create() callback is turned into a ChardevClass::open()
which is called from the newly introduced qemu_chardev_open().

"chardev-gdb" and "chardev-hci" are internal chardev and aren't
creatable directly with -chardev. Use a new internal flag to disable
them. We may want to use TYPE_USER_CREATABLE interface instead, or
perhaps allow -chardev usage.

Although in general we keep typename and macros private, unless the type
is being used by some other file, in this patch, all types and common
helper macros for qemu-char.c are in char.h. This is to help transition
now (some types must be declared early, while some aren't shared) and
when splitting in several units. This is to be improved later.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agovc: use a common prefix for chr callbacks
Marc-André Lureau [Thu, 5 Jan 2017 16:30:29 +0000 (17:30 +0100)]
vc: use a common prefix for chr callbacks

vc_chr_write() is more appropriate than _puts() since no newline is
appended, even though it's not used only as a callback.

Keep "qemu_chr_parse" prefix, most chardev parse functions use this
prefix atm.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agobaum: use a common prefix for chr callbacks
Marc-André Lureau [Thu, 5 Jan 2017 14:29:48 +0000 (15:29 +0100)]
baum: use a common prefix for chr callbacks

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agogtk: overwrite the console.c char driver
Marc-André Lureau [Wed, 7 Dec 2016 12:13:50 +0000 (15:13 +0300)]
gtk: overwrite the console.c char driver

Instead of registering a vc handler to allocate the Gtk VC Chardev,
overwrite the console.c char driver.

A later patch, when switching to QOM, will register a default console vc
QOM class if none has been registered before.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: use error_report()
Marc-André Lureau [Wed, 30 Nov 2016 18:57:24 +0000 (22:57 +0400)]
char: use error_report()

Prefer error_report() over fprintf(stderr..)

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agospice-char: improve error reporting
Marc-André Lureau [Wed, 30 Nov 2016 13:55:20 +0000 (17:55 +0400)]
spice-char: improve error reporting

Set errp to report errors up to the right monitor.

Use error_append_hint() to give hints about parameters on !qmp monitors,
instead of a direct fprintf() call.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: rename TCPChardev and NetChardev
Marc-André Lureau [Thu, 8 Dec 2016 11:21:53 +0000 (14:21 +0300)]
char: rename TCPChardev and NetChardev

Rename the types to follow the name of the chardev kind.
- socket: TCPChardev -> SocketChardev
- udp: NetChardev -> UdpChardev

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: rename CharDriverState Chardev
Marc-André Lureau [Wed, 7 Dec 2016 13:20:22 +0000 (16:20 +0300)]
char: rename CharDriverState Chardev

Pick a uniform chardev type name.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agobt: use qemu_chr_alloc()
Marc-André Lureau [Sat, 22 Oct 2016 07:55:22 +0000 (10:55 +0300)]
bt: use qemu_chr_alloc()

Use common allocator for CharDriverState.

Rename the now untouched parent field.

The casts added are temporary, they are replaced with QOM type-safe
macros in a later patch in this series.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: allocate CharDriverState as a single object
Marc-André Lureau [Fri, 21 Oct 2016 20:44:44 +0000 (23:44 +0300)]
char: allocate CharDriverState as a single object

Use a single allocation for CharDriverState, this avoids extra
allocations & pointers, and is a step towards more object-oriented
CharDriver.

Gtk console is a bit peculiar, gd_vc_chr_set_echo() used to have a
temporary VirtualConsole to save the echo bit. Instead now, we consider
whether vcd->console is set or not, and restore the echo bit saved in
VCDriverState when calling gd_vc_vte_init().

The casts added are temporary, they are replaced with QOM type-safe
macros in a later patch in this series.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: use a feature bit for replay
Marc-André Lureau [Fri, 21 Oct 2016 19:58:45 +0000 (22:58 +0300)]
char: use a feature bit for replay

Use a feature flag rather than a structure field for "replay".

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: introduce generic qemu_chr_get_kind()
Marc-André Lureau [Fri, 21 Oct 2016 19:38:41 +0000 (22:38 +0300)]
char: introduce generic qemu_chr_get_kind()

This allows to remove the "is_mux" field from CharDriverState.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: fold single-user functions in caller
Marc-André Lureau [Fri, 21 Oct 2016 19:09:15 +0000 (22:09 +0300)]
char: fold single-user functions in caller

This shortens the code a bit.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: move callbacks in CharDriver
Marc-André Lureau [Fri, 21 Oct 2016 17:49:37 +0000 (20:49 +0300)]
char: move callbacks in CharDriver

This makes the code more declarative, and avoids duplicating the
information on all instances.

Signed-off-by: Marc-André Lureau <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
8 years agochar: use a static array for backends
Marc-André Lureau [Fri, 21 Oct 2016 13:30:29 +0000 (16:30 +0300)]
char: use a static array for backends

Number and kinds of backends is known at compile-time, use a fixed-sized
static array to simplify iterations & lookups.

Signed-off-by: Marc-André Lureau <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
This page took 0.081239 seconds and 4 git commands to generate.