]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
7 years agoqemu-img: Use strerror() for generic resize error
Max Reitz [Wed, 15 Jun 2016 15:36:29 +0000 (17:36 +0200)]
qemu-img: Use strerror() for generic resize error

Emitting the plain error number is not very helpful. Use strerror()
instead.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20160615153630.2116-2-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
7 years agoblock: Remove BB options from blockdev-add
Kevin Wolf [Thu, 30 Jun 2016 13:52:37 +0000 (15:52 +0200)]
block: Remove BB options from blockdev-add

werror/rerror are now available as qdev options. The stats-* options are
removed without an existing replacement; they should probably be
configurable with a separate QMP command like I/O throttling settings.

Removing id is left for another day because this involves updating
qemu-iotests cases to use node-name for everything. Before we can do
that, however, all QMP commands must support node-name.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
7 years agoqemu-iotests: Test setting WCE with qdev
Kevin Wolf [Thu, 30 Jun 2016 13:29:35 +0000 (15:29 +0200)]
qemu-iotests: Test setting WCE with qdev

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
7 years agoblock/qdev: Allow configuring rerror/werror with qdev properties
Kevin Wolf [Wed, 29 Jun 2016 15:41:35 +0000 (17:41 +0200)]
block/qdev: Allow configuring rerror/werror with qdev properties

The rerror/werror policies are implemented in the devices, so that's
where they should be configured. In comparison to the old options in
-drive, the qdev properties are only added to those devices that
actually support them.

If the option isn't given (or "auto" is specified), the setting of the
BlockBackend is used for compatibility with the old options. For block
jobs, "auto" is the same as "enospc".

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
7 years agocommit: Fix use of error handling policy
Kevin Wolf [Wed, 29 Jun 2016 15:38:57 +0000 (17:38 +0200)]
commit: Fix use of error handling policy

Commit implemented the 'enospc' policy as 'ignore' if the error was not
ENOSPC. The QAPI documentation promises that it's treated as 'stop'.
Using the common block job error handling function fixes this and also
adds the missing QMP event.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
7 years agoblock/qdev: Allow configuring WCE with qdev properties
Kevin Wolf [Thu, 23 Jun 2016 13:12:35 +0000 (15:12 +0200)]
block/qdev: Allow configuring WCE with qdev properties

As cache.writeback is a BlockBackend property and as such more related
to the guest device than the BlockDriverState, we already removed it
from the blockdev-add interface. This patch adds the new way to set it,
as a qdev property of the corresponding guest device.

For example: -drive if=none,file=test.img,node-name=img
             -device ide-hd,drive=img,write-cache=off

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
7 years agoblock/qdev: Allow node name for drive properties
Kevin Wolf [Tue, 21 Jun 2016 18:46:05 +0000 (20:46 +0200)]
block/qdev: Allow node name for drive properties

If a node name instead of a BlockBackend name is specified as the driver
for a guest device, an anonymous BlockBackend is created now.

The order of operations in release_drive() must be reversed in order to
avoid a use-after-free bug because now blk_detach_dev() frees the last
reference if an anonymous BlockBackend is used.

usb-storage uses a hack where it forwards its BlockBackend as a property
to another device that it internally creates. This hack must be updated
so that it doesn't drop its original BB before it can be passed to the
other device. This used to work because we always had the monitor
reference around, but with node-names the device reference is the only
one now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
7 years agocoroutine: move entry argument to qemu_coroutine_create
Paolo Bonzini [Mon, 4 Jul 2016 17:10:01 +0000 (19:10 +0200)]
coroutine: move entry argument to qemu_coroutine_create

In practice the entry argument is always known at creation time, and
it is confusing that sometimes qemu_coroutine_enter is used with a
non-NULL argument to re-enter a coroutine (this happens in
block/sheepdog.c and tests/test-coroutine.c).  So pass the opaque value
at creation time, for consistency with e.g. aio_bh_new.

Mostly done with the following semantic patch:

@ entry1 @
expression entry, arg, co;
@@
- co = qemu_coroutine_create(entry);
+ co = qemu_coroutine_create(entry, arg);
  ...
- qemu_coroutine_enter(co, arg);
+ qemu_coroutine_enter(co);

@ entry2 @
expression entry, arg;
identifier co;
@@
- Coroutine *co = qemu_coroutine_create(entry);
+ Coroutine *co = qemu_coroutine_create(entry, arg);
  ...
- qemu_coroutine_enter(co, arg);
+ qemu_coroutine_enter(co);

@ entry3 @
expression entry, arg;
@@
- qemu_coroutine_enter(qemu_coroutine_create(entry), arg);
+ qemu_coroutine_enter(qemu_coroutine_create(entry, arg));

@ reentry @
expression co;
@@
- qemu_coroutine_enter(co, NULL);
+ qemu_coroutine_enter(co);

except for the aforementioned few places where the semantic patch
stumbled (as expected) and for test_co_queue, which would otherwise
produce an uninitialized variable warning.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agotest-coroutine: prepare for the next patch
Paolo Bonzini [Mon, 4 Jul 2016 17:10:00 +0000 (19:10 +0200)]
test-coroutine: prepare for the next patch

The next patch moves the coroutine argument from first-enter to
creation time.  In this case, coroutine has not been initialized
yet when the coroutine is created, so change to a pointer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agocoroutine: use QSIMPLEQ instead of QTAILQ
Paolo Bonzini [Mon, 4 Jul 2016 17:09:59 +0000 (19:09 +0200)]
coroutine: use QSIMPLEQ instead of QTAILQ

CoQueue do not need to remove any element but the head of the list;
processing is always strictly FIFO.  Therefore, the simpler singly-linked
QSIMPLEQ can be used instead.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoraw-posix: Use qemu_dup
Fam Zheng [Wed, 22 Jun 2016 12:53:20 +0000 (20:53 +0800)]
raw-posix: Use qemu_dup

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoosdep: Introduce qemu_dup
Fam Zheng [Wed, 22 Jun 2016 12:53:19 +0000 (20:53 +0800)]
osdep: Introduce qemu_dup

And use it in qemu_dup_flags.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblockjob: Update description of the 'device' field in the QMP API
Alberto Garcia [Tue, 5 Jul 2016 14:29:02 +0000 (17:29 +0300)]
blockjob: Update description of the 'device' field in the QMP API

The 'device' field in all BLOCK_JOB_* events and 'block-job-*' command
is no longer the device name, but the ID of the job. This patch
updates the documentation to clarify that.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoqemu-img: Set the ID of the block job in img_commit()
Alberto Garcia [Tue, 5 Jul 2016 14:29:01 +0000 (17:29 +0300)]
qemu-img: Set the ID of the block job in img_commit()

img_commit() creates a block job without an ID. This is no longer
allowed now that we require it to be unique and well-formed. We were
solving this by having a fallback in block_job_create(), but now that
we extended the API of commit_active_start() we can finally set an
explicit ID and revert that change.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agocommit: Add 'job-id' parameter to 'block-commit'
Alberto Garcia [Tue, 5 Jul 2016 14:29:00 +0000 (17:29 +0300)]
commit: Add 'job-id' parameter to 'block-commit'

This patch adds a new optional 'job-id' parameter to 'block-commit',
allowing the user to specify the ID of the block job to be created.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agostream: Add 'job-id' parameter to 'block-stream'
Alberto Garcia [Tue, 5 Jul 2016 14:28:59 +0000 (17:28 +0300)]
stream: Add 'job-id' parameter to 'block-stream'

This patch adds a new optional 'job-id' parameter to 'block-stream',
allowing the user to specify the ID of the block job to be created.

The HMP 'block_stream' command remains unchanged.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agobackup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup'
Alberto Garcia [Tue, 5 Jul 2016 14:28:58 +0000 (17:28 +0300)]
backup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup'

This patch adds a new optional 'job-id' parameter to 'blockdev-backup'
and 'drive-backup', allowing the user to specify the ID of the block
job to be created.

The HMP 'drive_backup' command remains unchanged.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agomirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror'
Alberto Garcia [Tue, 5 Jul 2016 14:28:57 +0000 (17:28 +0300)]
mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror'

This patch adds a new optional 'job-id' parameter to 'blockdev-mirror'
and 'drive-mirror', allowing the user to specify the ID of the block
job to be created.

The HMP 'drive_mirror' command remains unchanged.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblockjob: Add 'job_id' parameter to block_job_create()
Alberto Garcia [Tue, 5 Jul 2016 14:28:56 +0000 (17:28 +0300)]
blockjob: Add 'job_id' parameter to block_job_create()

When a new job is created, the job ID is taken from the device name of
the BDS. This patch adds a new 'job_id' parameter to let the caller
provide one instead.

This patch also verifies that the ID is always unique and well-formed.
This causes problems in a couple of places where no ID is being set,
because the BDS does not have a device name.

In the case of test_block_job_start() (from test-blockjob-txn.c) we
can simply use this new 'job_id' parameter to set the missing ID.

In the case of img_commit() (from qemu-img.c) we still don't have the
API to make commit_active_start() set the job ID, so we solve it by
setting a default value. We'll get rid of this as soon as we extend
the API.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblock: Use block_job_get() in find_block_job()
Alberto Garcia [Tue, 5 Jul 2016 14:28:55 +0000 (17:28 +0300)]
block: Use block_job_get() in find_block_job()

find_block_job() looks for a block backend with a specified name,
checks whether it has a block job and acquires its AioContext.

We want to identify jobs by their ID and not by the block backend
they're attached to, so this patch ignores the backends altogether and
gets the job directly. Apart from making the code simpler, this will
allow us to find block jobs once they start having user-specified IDs.

To ensure backward compatibility we keep ERROR_CLASS_DEVICE_NOT_ACTIVE
as the error class if the job doesn't exist. In subsequent patches
we'll also need to keep the device name as the default job ID if the
user doesn't specify a different one.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblockjob: Add block_job_get()
Alberto Garcia [Tue, 5 Jul 2016 14:28:54 +0000 (17:28 +0300)]
blockjob: Add block_job_get()

Currently the way to look for a specific block job is to iterate the
list manually using block_job_next().

Since we want to be able to identify a job primarily by its ID it
makes sense to have a function that does just that.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoblockjob: Update description of the 'id' field
Alberto Garcia [Tue, 5 Jul 2016 14:28:53 +0000 (17:28 +0300)]
blockjob: Update description of the 'id' field

The 'id' field of the BlockJob structure will be able to hold any ID,
not only a device name. This patch updates the description of that
field and the error messages where it is being used.

Soon we'll add the ability to set an arbitrary ID when creating a
block job.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agostream: Fix prototype of stream_start()
Alberto Garcia [Tue, 5 Jul 2016 14:28:52 +0000 (17:28 +0300)]
stream: Fix prototype of stream_start()

'stream-start' has a parameter called 'backing-file', which is the
string to be written to bs->backing when the job finishes.

In the stream_start() implementation it is called 'backing_file_str',
but it the prototype in the header file it is called 'base_id'.

This patch fixes it so the name is the same in both cases and is
consistent with other cases (like commit_start()).

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-include-2016-07-12' into staging
Peter Maydell [Tue, 12 Jul 2016 15:04:35 +0000 (16:04 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-include-2016-07-12' into staging

Clean up #include "..." vs <...> and header guards

# gpg: Signature made Tue 12 Jul 2016 15:23:43 BST
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-include-2016-07-12:
  cris: Fix broken header guard in hw/cris/boot.h
  Clean up decorations and whitespace around header guards
  Clean up ill-advised or unusual header guards
  libdecnumber: Don't error out on decNumberLocal.h re-inclusion
  libdecnumber: Don't fool around with guards to avoid #include
  Clean up header guards that don't match their file name
  Drop Emacs local variables lists redundant with .dir-locals.el
  spapr_pci: Include spapr.h instead of playing games with #error
  tcg: Clean up tcg-target.h header guards
  linux-user: Fix broken header guard in syscall_defs.h
  linux-user: Clean up hostdep.h header guards
  linux-user: Clean up target_structs.h header guards
  linux-user: Clean up target_signal.h header guards
  linux-user: Clean up target_cpu.h header guards
  linux-user: Clean up target_syscall.h header guards
  target-*: Clean up cpu.h header guards
  scripts: New clean-header-guards.pl
  Use #include "..." for our own headers, <...> for others

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agocris: Fix broken header guard in hw/cris/boot.h
Markus Armbruster [Wed, 29 Jun 2016 13:51:29 +0000 (15:51 +0200)]
cris: Fix broken header guard in hw/cris/boot.h

Found with scripts/clean-header-guards.pl.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agoClean up decorations and whitespace around header guards
Markus Armbruster [Wed, 29 Jun 2016 13:29:06 +0000 (15:29 +0200)]
Clean up decorations and whitespace around header guards

Cleaned up with scripts/clean-header-guards.pl.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agoClean up ill-advised or unusual header guards
Markus Armbruster [Wed, 29 Jun 2016 11:47:03 +0000 (13:47 +0200)]
Clean up ill-advised or unusual header guards

Cleaned up with scripts/clean-header-guards.pl.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolibdecnumber: Don't error out on decNumberLocal.h re-inclusion
Markus Armbruster [Wed, 29 Jun 2016 09:49:19 +0000 (11:49 +0200)]
libdecnumber: Don't error out on decNumberLocal.h re-inclusion

decNumberLocal.h errors out when it's included with its header guard
defined.  This catches multiple inclusions.

Drop that.  Including it multiple times is safe, and the compiler can
do it efficiently.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolibdecnumber: Don't fool around with guards to avoid #include
Markus Armbruster [Wed, 29 Jun 2016 09:45:54 +0000 (11:45 +0200)]
libdecnumber: Don't fool around with guards to avoid #include

Some libdecnumber headers avoid including decNumber.h or decContext.h
again by checking their header guards.  Don't.  Including them
multiple times is safe, and the compiler can do it efficiently.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agoClean up header guards that don't match their file name
Markus Armbruster [Wed, 29 Jun 2016 08:12:57 +0000 (10:12 +0200)]
Clean up header guards that don't match their file name

Header guard symbols should match their file name to make guard
collisions less likely.  Offenders found with
scripts/clean-header-guards.pl -vn.

Cleaned up with scripts/clean-header-guards.pl, followed by some
renaming of new guard symbols picked by the script to better ones.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agoDrop Emacs local variables lists redundant with .dir-locals.el
Markus Armbruster [Tue, 28 Jun 2016 14:58:25 +0000 (16:58 +0200)]
Drop Emacs local variables lists redundant with .dir-locals.el

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agospapr_pci: Include spapr.h instead of playing games with #error
Markus Armbruster [Wed, 29 Jun 2016 09:31:09 +0000 (11:31 +0200)]
spapr_pci: Include spapr.h instead of playing games with #error

include/hw/pci-host/spapr.h needs hw/ppc/spapr.h.  It checks whether
its header guard is defined, and errors out if it isn't.

Playing games with some other header's guard symbol is not a good
idea.  Just include the frackin' header already.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agotcg: Clean up tcg-target.h header guards
Markus Armbruster [Wed, 29 Jun 2016 09:14:47 +0000 (11:14 +0200)]
tcg: Clean up tcg-target.h header guards

These use guard symbols like TCG_TARGET_$target.
scripts/clean-header-guards.pl doesn't like them because they don't
match their file name (they should, to make guard collisions less
likely).

Clean them up: use guard symbol $target_TCG_TARGET_H for
tcg/$target/tcg-target.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolinux-user: Fix broken header guard in syscall_defs.h
Markus Armbruster [Wed, 29 Jun 2016 13:54:17 +0000 (15:54 +0200)]
linux-user: Fix broken header guard in syscall_defs.h

Found with scripts/clean-header-guards.pl.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolinux-user: Clean up hostdep.h header guards
Markus Armbruster [Wed, 29 Jun 2016 14:22:46 +0000 (16:22 +0200)]
linux-user: Clean up hostdep.h header guards

These headers all use QEMU_HOSTDEP_H as header guard symbol.  Reuse of
the same guard symbol in multiple headers is okay as long as they
cannot be included together.

Since we can avoid guard symbol reuse easily, do so: use guard symbol
$target_HOSTDEP_H for linux-user/host/$target/hostdep.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolinux-user: Clean up target_structs.h header guards
Markus Armbruster [Wed, 29 Jun 2016 14:15:33 +0000 (16:15 +0200)]
linux-user: Clean up target_structs.h header guards

These headers all use TARGET_STRUCTS_H as header guard symbol.  Reuse
of the same guard symbol in multiple headers is okay as long as they
cannot be included together.

Since we can avoid guard symbol reuse easily, do so: use guard symbol
$target_TARGET_STRUCTS_H for linux-user/$target/target_structs.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolinux-user: Clean up target_signal.h header guards
Markus Armbruster [Wed, 29 Jun 2016 14:09:50 +0000 (16:09 +0200)]
linux-user: Clean up target_signal.h header guards

These headers all use TARGET_SIGNAL_H as header guard symbol.  Reuse
of the same guard symbol in multiple headers is okay as long as they
cannot be included together.

Since we can avoid guard symbol reuse easily, do so: use guard symbol
$target_TARGET_SIGNAL_H for linux-user/$target/target_signal.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolinux-user: Clean up target_cpu.h header guards
Markus Armbruster [Wed, 29 Jun 2016 14:05:18 +0000 (16:05 +0200)]
linux-user: Clean up target_cpu.h header guards

These headers all use TARGET_CPU_H as header guard symbol.  Reuse of
the same guard symbol in multiple headers is okay as long as they
cannot be included together.

Since we can avoid guard symbol reuse easily, do so: use guard symbol
$target_TARGET_CPU_H for linux-user/$target/target_cpu.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agolinux-user: Clean up target_syscall.h header guards
Markus Armbruster [Wed, 29 Jun 2016 08:47:26 +0000 (10:47 +0200)]
linux-user: Clean up target_syscall.h header guards

Some of them use guard symbol TARGET_SYSCALL_H, but we also have
CRIS_SYSCALL_H, MICROBLAZE_SYSCALLS_H, TILEGX_SYSCALLS_H and
__UC32_SYSCALL_H__.  They all upset scripts/clean-header-guards.pl.

Reuse of the same guard symbol TARGET_SYSCALL_H in multiple headers is
okay as long as they cannot be included together.  The script can't
tell, so it warns.

The script dislikes the other guard symbols, too.  They don't match
their file name (they should, to make guard collisions less likely),
and __UC32_SYSCALL_H__ is a reserved identifier.

Clean them all up: use guard symbol $target_TARGET_SYSCALL_H for
linux-user/$target/target_sycall.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agotarget-*: Clean up cpu.h header guards
Markus Armbruster [Wed, 29 Jun 2016 09:05:55 +0000 (11:05 +0200)]
target-*: Clean up cpu.h header guards

Most of them use guard symbols like CPU_$target_H, but we also have
__MIPS_CPU_H__ and __TRICORE_CPU_H__.  They all upset
scripts/clean-header-guards.pl.

The script dislikes CPU_$target_H because they don't match their file
name (they should, to make guard collisions less likely).  The others
are reserved identifiers.

Clean them all up: use guard symbol $target_CPU_H for
target-$target/cpu.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agoscripts: New clean-header-guards.pl
Markus Armbruster [Tue, 28 Jun 2016 11:07:36 +0000 (13:07 +0200)]
scripts: New clean-header-guards.pl

The conventional way to ensure a header can be included multiple times
is to bracket it like this:

    #ifndef HEADER_NAME_H
    #define HEADER_NAME_H
    ...
    #endif

where HEADER_NAME_H is a symbol unique to this header.

The endif may be optionally decorated like this:

    #endif /* HEADER_NAME_H */

Unconventional ways present in our code:

* Identifiers reserved for any use:
    #define _FILEOP_H

* Lowercase (bad idea for object-like macros):
    #define __linux_video_vga_h__

* Roundabout ways to say the same thing (and hide from grep):
    #if !defined(__PPC_MAC_H__)
    #endif /* !defined(__PPC_MAC_H__) */

* Redundant values:
    #define HW_ALPHA_H 1

* Funny redundant values:
    # define PXA_H                 "pxa.h"

* Decorations with bangs:

    #endif /* !QEMU_ARM_GIC_INTERNAL_H */

  The negation actually makes sense, but almost all our header guard
  #endif decorations don't negate.

* Useless decorations:

   #endif  /* audio.h */

Header guards are not the place to show off creativity.  This script
normalizes them to the conventional way, and cleans up whitespace
while there.  It warns when it renames guard symbols, and explains how
to find occurences of these symbols that may have to be updated
manually.

Another issue is use of the same guard symbol in multiple headers.
That's okay only for headers that cannot be used together, such as the
*-user/*/target_syscall.h.  This script can't tell, so it warns when
it sees a reuse.

The script also warns when preprocessing a header with its guard
symbol defined produces anything but whitespace.

The next commits will put the script to use.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agoUse #include "..." for our own headers, <...> for others
Markus Armbruster [Wed, 22 Jun 2016 17:11:19 +0000 (19:11 +0200)]
Use #include "..." for our own headers, <...> for others

Tracked down with an ugly, brittle and probably buggy Perl script.

Also move includes converted to <...> up so they get included before
ours where that's obviously okay.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
7 years agobswap.h: Document cpu_to_* and *_to_cpu conversion functions
Peter Maydell [Thu, 7 Jul 2016 16:21:00 +0000 (17:21 +0100)]
bswap.h: Document cpu_to_* and *_to_cpu conversion functions

Add a documentation comment describing the functions for
converting between the cpu and little or bigendian formats.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1467908460-27048-6-git-send-email-peter.maydell@linaro.org

7 years agobswap.h: Fix comment typo
Peter Maydell [Thu, 7 Jul 2016 16:20:59 +0000 (17:20 +0100)]
bswap.h: Fix comment typo

Fix a typo in a comment.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Message-id: 1467908460-27048-5-git-send-email-peter.maydell@linaro.org

7 years agobswap.h: Remove unused cpu_to_*w() and *_to_cpup()
Peter Maydell [Thu, 7 Jul 2016 16:20:58 +0000 (17:20 +0100)]
bswap.h: Remove unused cpu_to_*w() and *_to_cpup()

Now that all uses of cpu_to_*w() and *_to_cpup() have been replaced
with either ld*_p()/st*_p() or by doing direct dereferences and
using the cpu_to_*()/*_to_cpu() byteswap functions, we can remove
the unused implementations.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1467908460-27048-4-git-send-email-peter.maydell@linaro.org

7 years agohw/bt: Don't use cpu_to_*w() and *_to_cpup()
Peter Maydell [Thu, 7 Jul 2016 16:20:57 +0000 (17:20 +0100)]
hw/bt: Don't use cpu_to_*w() and *_to_cpup()

Don't use cpu_to_*w() and *_to_cpup() to do byte-swapped loads
and stores; instead use ld*_p() and st*_p() which correctly handle
misaligned accesses.

Bring the HNDL() macro into line with how we deal with
PARAMHANDLE(), by using cpu_to_le16() rather than an ifdef
HOST_WORDS_BIGENDIAN.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1467908460-27048-3-git-send-email-peter.maydell@linaro.org

7 years agofsdev/9p-iov-marshal.c: Don't use cpu_to_*w() functions
Peter Maydell [Thu, 7 Jul 2016 16:20:56 +0000 (17:20 +0100)]
fsdev/9p-iov-marshal.c: Don't use cpu_to_*w() functions

Don't use the cpu_to_*w() functions, which we are trying to deprecate.
Instead just use cpu_to_*() to do the byteswap, which brings the
code in the marshal function in line with that in the unmarshal.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1467908460-27048-2-git-send-email-peter.maydell@linaro.org

7 years agoFix confusing argument names in some common functions
Sergey Sorokin [Tue, 14 Jun 2016 12:26:17 +0000 (15:26 +0300)]
Fix confusing argument names in some common functions

There are functions tlb_fill(), cpu_unaligned_access() and
do_unaligned_access() that are called with access type and mmu index
arguments. But these arguments are named 'is_write' and 'is_user' in their
declarations. The patches fix the arguments to avoid a confusion.

Signed-off-by: Sergey Sorokin <afarallax@yandex.ru>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Message-id: 1465907177-1399402-1-git-send-email-afarallax@yandex.ru
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/lalrae/tags/mips-20160712' into staging
Peter Maydell [Tue, 12 Jul 2016 11:34:41 +0000 (12:34 +0100)]
Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160712' into staging

MIPS patches 2016-07-12

Changes:
* support 10-bit ASIDs
* MIPS64R6-generic renamed to I6400
* initial GIC support
* implement RESET_BASE register in CM GCR

# gpg: Signature made Tue 12 Jul 2016 11:49:50 BST
# gpg:                using RSA key 0x52118E3C0B29DA6B
# gpg: Good signature from "Leon Alrae <leon.alrae@imgtec.com>"
# Primary key fingerprint: 8DD3 2F98 5495 9D66 35D4  4FC0 5211 8E3C 0B29 DA6B

* remotes/lalrae/tags/mips-20160712:
  target-mips: enable 10-bit ASIDs in I6400 CPU
  target-mips: support CP0.Config4.AE bit
  target-mips: change ASID type to hold more than 8 bits
  target-mips: add ASID mask field and replace magic values
  target-mips: replace MIPS64R6-generic with the real I6400 CPU model
  hw/mips_cmgcr: implement RESET_BASE register in CM GCR
  hw/mips_cpc: make VP correctly start from the reset vector
  target-mips: add exception base to MIPS CPU
  hw/mips/cps: create GIC block inside CPS
  hw/mips: implement Global Interrupt Controller
  hw/mips: implement GIC Interval Timer

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20160712-1' into staging
Peter Maydell [Tue, 12 Jul 2016 11:03:29 +0000 (12:03 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-usb-20160712-1' into staging

usb: misc fixes.

# gpg: Signature made Tue 12 Jul 2016 09:47:21 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/pull-usb-20160712-1:
  xen-usb: Fix 32bit build
  usb: add storage hotplug documentation
  nec-usb-xhci: set the device state to USB_STATE_DEFAULT

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-input-20160712-1' into staging
Peter Maydell [Tue, 12 Jul 2016 09:58:14 +0000 (10:58 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-input-20160712-1' into staging

msmouse: fix misc issues, switch to new input interface.
input: add trace events for full queues.
input-linux: better capability checks and event handling.

# gpg: Signature made Tue 12 Jul 2016 09:20:36 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/pull-input-20160712-1:
  input-linux: better capability checks, merge input_linux_event_{mouse, keyboard}
  input-linux: factor out input_linux_handle_keyboard
  input-linux: factor out input_linux_handle_mouse
  input: add trace events for full queues
  msmouse: send short messages if possible.
  msmouse: switch to new input interface
  msmouse: fix buffer handling
  msmouse: add MouseState, unregister handler on close

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-vnc-20160712-1' into staging
Peter Maydell [Tue, 12 Jul 2016 08:49:04 +0000 (09:49 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-vnc-20160712-1' into staging

vnc: misc bugfixes.

# gpg: Signature made Tue 12 Jul 2016 08:22:40 BST
# gpg:                using RSA key 0x4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/pull-vnc-20160712-1:
  ui: avoid crash if vnc client disconnects with writes pending
  vnc-enc-tight: use thread local storage for palette
  vnc: fix incorrect checking condition when updating client

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoxen-usb: Fix 32bit build
Anthony PERARD [Thu, 23 Jun 2016 11:08:29 +0000 (12:08 +0100)]
xen-usb: Fix 32bit build

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Message-id: 20160623110829.22671-1-anthony.perard@citrix.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agousb: add storage hotplug documentation
Gerd Hoffmann [Thu, 23 Jun 2016 07:45:01 +0000 (09:45 +0200)]
usb: add storage hotplug documentation

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1466667901-1341-1-git-send-email-kraxel@redhat.com

7 years agonec-usb-xhci: set the device state to USB_STATE_DEFAULT
Zhang Shuaiyi [Thu, 30 Jun 2016 03:50:40 +0000 (23:50 -0400)]
nec-usb-xhci: set the device state to USB_STATE_DEFAULT

This patch is a rough fix to "hw/usb/core.c:401: usb_handle_packet:
 Assertion `dev->state == 3' failed.". Qemu will crash when a usb3
device redirect to Windows7 VM via nec-usb-xhci.

In extensible-host-controler-interface-usb-xhci.pdf P94(4.6.5
Address Device):
    â€¢ If the Block Set Address Request (BSR) flag = â€˜1’
        â€¢ If the slot is in the Enabled state:
            ...
            â€¢ Set the Slot State in the Output Slot Context to Default.

BSR = â€˜1’: Enabled state to Default state; BSR = â€˜0’: Default state
to Addressed state. Try to call usb_device_reset to set device state
to USB_STATE_DEFAULT in xhci_address_slot wether bsr is zero.

Signed-off-by: Zhang Shuaiyi <zhang_syi@massclouds.com>
Message-id: 1467258640-11921-1-git-send-email-zhang_syi@massclouds.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agotarget-mips: enable 10-bit ASIDs in I6400 CPU
Leon Alrae [Mon, 27 Jun 2016 15:19:12 +0000 (16:19 +0100)]
target-mips: enable 10-bit ASIDs in I6400 CPU

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agotarget-mips: support CP0.Config4.AE bit
Paul Burton [Mon, 27 Jun 2016 15:19:11 +0000 (16:19 +0100)]
target-mips: support CP0.Config4.AE bit

The read-only Config4.AE bit set denotes extended 10 bits ASID.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agotarget-mips: change ASID type to hold more than 8 bits
Paul Burton [Mon, 27 Jun 2016 15:19:10 +0000 (16:19 +0100)]
target-mips: change ASID type to hold more than 8 bits

ASID currently has uint8_t type which is too small since some processors
support more than 8 bits ASID. Therefore change its type to uint16_t.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agotarget-mips: add ASID mask field and replace magic values
Paul Burton [Mon, 27 Jun 2016 15:19:09 +0000 (16:19 +0100)]
target-mips: add ASID mask field and replace magic values

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agotarget-mips: replace MIPS64R6-generic with the real I6400 CPU model
Leon Alrae [Mon, 27 Jun 2016 10:11:39 +0000 (11:11 +0100)]
target-mips: replace MIPS64R6-generic with the real I6400 CPU model

MIPS64R6-generic gradually gets closer to I6400 CPU, feature-wise. Rename
it to make it clear which MIPS processor it is supposed to emulate.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agohw/mips_cmgcr: implement RESET_BASE register in CM GCR
Leon Alrae [Thu, 9 Jun 2016 09:46:52 +0000 (10:46 +0100)]
hw/mips_cmgcr: implement RESET_BASE register in CM GCR

Implement RESET_BASE register which is local to each VP and a write to
it changes VP's reset exception base. Also, add OTHER register to
allow a software running on one VP to access other VP's local registers.

Guest can use this mechanism to specify custom address from which a VP
will start execution.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agohw/mips_cpc: make VP correctly start from the reset vector
Leon Alrae [Thu, 9 Jun 2016 09:46:51 +0000 (10:46 +0100)]
hw/mips_cpc: make VP correctly start from the reset vector

When VP enters the Run state it starts execution from the reset vector.
Currently used CPU_INTERRUPT_WAKE does not do that if reset exception
base has been modified. Therefore fix that by simply resetting given VP.

Drop the usage of CPU_INTERRUPT_WAKE also in VP_STOP and instead raise
the CPU_INTERRUPT_HALT to halt a VP.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agotarget-mips: add exception base to MIPS CPU
Leon Alrae [Thu, 9 Jun 2016 09:46:50 +0000 (10:46 +0100)]
target-mips: add exception base to MIPS CPU

Replace hardcoded 0xbfc00000 with exception_base which is initialized with
this default address so there is no functional change here.
However, it is now exposed and consequently it will be possible to modify
it from outside of the CPU.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agohw/mips/cps: create GIC block inside CPS
Leon Alrae [Tue, 29 Mar 2016 02:35:52 +0000 (19:35 -0700)]
hw/mips/cps: create GIC block inside CPS

Add GIC to CPS and expose its interrupt pins instead of CPU's.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agohw/mips: implement Global Interrupt Controller
Yongbok Kim [Tue, 29 Mar 2016 02:35:51 +0000 (19:35 -0700)]
hw/mips: implement Global Interrupt Controller

The Global Interrupt Controller (GIC) is responsible for mapping each
internal and external interrupt to the correct location for servicing.

The internal representation of registers is different from the specification
in order to consolidate information for each GIC Interrupt Sources and Virtual
Processors with same functionalities. For example SH_MAP00_VP00 registers are
defined like each bit represents a VP but in this implementation the equivalent
map_vp contains VP number in integer form for ease accesses. When it is being
accessed via read write functions an internal data is converted back into the
original format as the specification.

Limitations:
Level triggering only
GIC CounterHi not implemented (Countbits = 32bits)
DINT not implemented
Local WatchDog, Fast Debug Channel, Perf Counter not implemented

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agohw/mips: implement GIC Interval Timer
Yongbok Kim [Tue, 29 Mar 2016 02:35:50 +0000 (19:35 -0700)]
hw/mips: implement GIC Interval Timer

The interval timer is similar to the CP0 Count/Compare timer within
each processor. The difference is the GIC_SH_COUNTER register is global
to the system so that all processors have the same time reference.

To ease implementation, all VPs are having its own QEMU timer but sharing
global settings and registers such as GIC_SH_CONFIG.COUTNSTOP and
GIC_SH_COUNTER.

MIPS GIC Interval Timer does support upto 64 bits of Count register but
in this implementation it is limited to 32 bits only.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
7 years agoinput-linux: better capability checks, merge input_linux_event_{mouse, keyboard}
Gerd Hoffmann [Thu, 16 Jun 2016 09:03:20 +0000 (11:03 +0200)]
input-linux: better capability checks, merge input_linux_event_{mouse, keyboard}

Improve capability checks (count keys and buttons), store results.

Merge the input_linux_event_mouse and input_linux_event_keyboard
functions into one, dispatch into input_linux_handle_mouse and
input_linux_handle_keyboard depending on device capabilities.

Allow calling both handle functions, so we can handle mice which
also send key events, by routing those key events to the keyboard.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1466067800-25434-4-git-send-email-kraxel@redhat.com

7 years agoinput-linux: factor out input_linux_handle_keyboard
Gerd Hoffmann [Thu, 16 Jun 2016 09:03:19 +0000 (11:03 +0200)]
input-linux: factor out input_linux_handle_keyboard

No functional change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1466067800-25434-3-git-send-email-kraxel@redhat.com

7 years agoinput-linux: factor out input_linux_handle_mouse
Gerd Hoffmann [Thu, 16 Jun 2016 09:03:18 +0000 (11:03 +0200)]
input-linux: factor out input_linux_handle_mouse

No functional change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1466067800-25434-2-git-send-email-kraxel@redhat.com

7 years agoinput: add trace events for full queues
Gerd Hoffmann [Thu, 23 Jun 2016 09:51:35 +0000 (11:51 +0200)]
input: add trace events for full queues

It isn't unusual to happen, for example during reboot when the guest
doesn't reveice events for a while.  So better don't flood stderr
with alarming messages.  Turn them into tracepoints instead so they
can be enabled in case they are needed for trouble-shooting.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1466675495-28797-1-git-send-email-kraxel@redhat.com

7 years agomsmouse: send short messages if possible.
Gerd Hoffmann [Mon, 4 Jul 2016 09:42:55 +0000 (11:42 +0200)]
msmouse: send short messages if possible.

Keep track of button changes.  Send the extended 4-byte messages for
three button mice only in case we have something to report for the
middle button.  Use the short 3-byte messages (original protocol for
two-button microsoft mouse) otherwise.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1467625375-31774-5-git-send-email-kraxel@redhat.com

7 years agomsmouse: switch to new input interface
Gerd Hoffmann [Mon, 4 Jul 2016 09:42:54 +0000 (11:42 +0200)]
msmouse: switch to new input interface

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1467625375-31774-4-git-send-email-kraxel@redhat.com

7 years agomsmouse: fix buffer handling
Gerd Hoffmann [Mon, 4 Jul 2016 09:42:53 +0000 (11:42 +0200)]
msmouse: fix buffer handling

The msmouse chardev backend writes data without checking whenever there
is enough space.

That happens to work with linux guests, probably by pure luck because
the linux driver enables the fifo and the serial port emulation accepts
more data than announced via qemu_chr_be_can_write() in that case.

Handle this properly by adding a buffer to MouseState.  Hook up a
CharDriverState->accept_input() handler which feeds the buffer to the
serial port.  msmouse_event() only fills the buffer now, and calls the
accept_input handler too to kick off the transmission.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1467625375-31774-3-git-send-email-kraxel@redhat.com

7 years agomsmouse: add MouseState, unregister handler on close
Gerd Hoffmann [Mon, 4 Jul 2016 09:42:52 +0000 (11:42 +0200)]
msmouse: add MouseState, unregister handler on close

Add struct to track serial mouse state.  Store mouse event handler
there.  Unregister properly on chardev close.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1467625375-31774-2-git-send-email-kraxel@redhat.com

7 years agoui: avoid crash if vnc client disconnects with writes pending
Daniel P. Berrange [Mon, 27 Jun 2016 15:48:49 +0000 (16:48 +0100)]
ui: avoid crash if vnc client disconnects with writes pending

The vnc_client_read() function is called from the vnc_client_io()
event handler callback when there is incoming data to process.
If it detects that the client has disconnected, then it will
trigger cleanup and free'ing of the VncState client struct at
a safe time.

Unfortunately, the vnc_client_io() event handler will also call
vnc_client_write() to handle any outgoing data writes. So if
vnc_client_io() was invoked with both G_IO_IN and G_IO_OUT
events set, and the client disconnects, we may try to write to
a client which has just been freed.

https://bugs.launchpad.net/qemu/+bug/1594861

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1467042529-3372-1-git-send-email-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agovnc-enc-tight: use thread local storage for palette
Peter Lieven [Thu, 30 Jun 2016 10:00:46 +0000 (12:00 +0200)]
vnc-enc-tight: use thread local storage for palette

currently the color counting palette is allocated from heap, used and destroyed
for each single subrect. Use a static palette per thread for this purpose and
avoid the malloc and free for each update.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1467280846-9674-1-git-send-email-pl@kamp.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agovnc: fix incorrect checking condition when updating client
Gonglei [Fri, 8 Jul 2016 03:37:36 +0000 (11:37 +0800)]
vnc: fix incorrect checking condition when updating client

vs->disconnecting is set to TRUE and vs->ioc is closed, but
vs->ioc isn't set to NULL, so that the vnc_disconnect_finish()
isn't invoked when you update client in vnc_update_client()
after vnc_disconnect_start invoked. Let's using change the checking
condition to avoid resource leak.

Signed-off-by: Haibin Wang <wanghaibin.wang@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1467949056-81208-1-git-send-email-arei.gonglei@huawei.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
7 years agoMerge remote-tracking branch 'remotes/cohuck/tags/s390x-20160711' into staging
Peter Maydell [Mon, 11 Jul 2016 17:46:38 +0000 (18:46 +0100)]
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20160711' into staging

Last round of s390x patches for 2.7:
- A large update of the s390x PCI code, bringing it in line with
  the architecture
- Fixes and improvements in the ipl (boot) code
- Refactoring in the css code

# gpg: Signature made Mon 11 Jul 2016 09:04:51 BST
# gpg:                using RSA key 0xDECF6B93C6F02FAF
# gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"
# Primary key fingerprint: C3D0 D66D C362 4FF6 A8C0  18CE DECF 6B93 C6F0 2FAF

* remotes/cohuck/tags/s390x-20160711: (25 commits)
  s390x/pci: make hot-unplug handler smoother
  s390x/pci: replace fid with idx in msg data of msix
  s390x/pci: fix stpcifc_service_call
  s390x/pci: refactor list_pci
  s390x/pci: refactor s390_pci_find_dev_by_idx
  s390x/pci: add checkings in CLP_SET_PCI_FN
  s390x/pci: enable zpci hot-plug/hot-unplug
  s390x/pci: enable uid-checking
  s390x/pci: introduce S390PCIBusDevice qdev
  s390x/pci: introduce S390PCIIOMMU
  s390x/pci: introduce S390PCIBus
  s390x/pci: enforce zPCI state checking
  s390x/pci: refactor s390_pci_find_dev_by_fh
  s390x/pci: unify FH_ macros
  s390x/pci: write fid in CLP_QUERY_PCI_FN
  s390x/pci: acceleration for getting S390pciState
  s390x/pci: fix failures of dma map/unmap
  s390x/css: Unplug handler of virtual css bridge
  s390x/css: Factor out virtual css bridge and bus
  s390x/css: use define for "virtual-css-bridge" literal
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20160708' into staging
Peter Maydell [Mon, 11 Jul 2016 16:17:02 +0000 (17:17 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20160708' into staging

two self-modifying code fixes

# gpg: Signature made Fri 08 Jul 2016 21:28:50 BST
# gpg:                using RSA key 0xAD1270CC4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"
# Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC  16A4 AD12 70CC 4DD0 279B

* remotes/rth/tags/pull-tcg-20160708:
  translate-all: Fix user-mode self-modifying code in 2 page long TB
  cputlb: Fix for self-modifying writes across page boundaries
  cputlb: Add address parameter to VICTIM_TLB_HIT
  cputlb: Move VICTIM_TLB_HIT out of line

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging
Peter Maydell [Mon, 11 Jul 2016 14:08:47 +0000 (15:08 +0100)]
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging

x86 and machine queue, 2016-07-07

Highlights:
* Improvements on global property error handling
* Translate -cpu options to global properties
* LMCE support

# gpg: Signature made Thu 07 Jul 2016 20:59:01 BST
# gpg:                using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/x86-pull-request:
  target-i386: Enable LMCE for '-cpu host' if supported by host
  target-i386: Publish advised value of MSR_IA32_FEATURE_CONTROL via fw_cfg
  target-i386: kvm: Add basic Intel LMCE support
  target-i386: Report hyperv feature words through qom
  target-i386: Show host and VM TSC frequencies on mismatch
  pc: Parse CPU features only once
  arm: virt: Parse cpu_model only once
  cpu: Use CPUClass->parse_features() as convertor to global properties
  target-i386: Avoid using locals outside their scope
  target-i386: TCG can support CPUID.07H:EBX.erms
  target-sparc: Use sparc_cpu_parse_features() directly
  vl: Set errp to &error_abort on machine compat_props
  machine: Add machine_register_compat_props() function
  qdev: GlobalProperty.errp field
  qdev: Eliminate qemu_add_globals() function
  qdev: Don't stop applying globals on first error

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-rth-20160710' into staging
Peter Maydell [Mon, 11 Jul 2016 13:10:09 +0000 (14:10 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-rth-20160710' into staging

build fix for travis

# gpg: Signature made Sun 10 Jul 2016 18:07:02 BST
# gpg:                using RSA key 0xAD1270CC4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"
# Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC  16A4 AD12 70CC 4DD0 279B

* remotes/rth/tags/pull-rth-20160710:
  build: Use $(AS) for optionrom explicitly
  linux-user: Fix i386 safe-syscall.S

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agogtk: fix build
Gerd Hoffmann [Thu, 7 Jul 2016 07:29:23 +0000 (09:29 +0200)]
gtk: fix build

Commit "9d8256e virgl: pass whole GL scanout dimensions" missed the
opengl code path for gtk versions >= 3.16.  Update that one too and
fix the build with recent gtk versions.

Reported-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1467876563-1351-1-git-send-email-kraxel@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agos390x/pci: make hot-unplug handler smoother
Yi Min Zhao [Wed, 27 Apr 2016 09:44:17 +0000 (17:44 +0800)]
s390x/pci: make hot-unplug handler smoother

The current implementation of hot-unplug handler is abrupt. Any pci
operation will be just rejected if pci device is unconfigured. Thus a
pci device can not be reset or destroyed in a right, smooth and safe
way.

Improve this as follows:
- Notify the guest via a HP_EVENT_DECONFIGURE_REQUEST(0x303) event in
  the unplug handler, giving it a chance to deconfigure the device via
  sclp and allowing us to continue hot-unplug afterwards.
- Set up a timer that will generate the HP_EVENT_CONFIGURE_TO_STBRES
  (0x304) event as before if the guest did not react after an adequate
  time.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: replace fid with idx in msg data of msix
Yi Min Zhao [Fri, 6 May 2016 10:44:40 +0000 (18:44 +0800)]
s390x/pci: replace fid with idx in msg data of msix

Present code uses fid as the part of message data of msix for looking
up the specific zpci device. However it limits the usable range of fid,
and the code looking up the zpci device may fail due to truncation of
the fid.

In addition, fh is composed of enabled bit, FH_VIRT and the array index.
So we can use the array index as the identifier to store in msg data.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: fix stpcifc_service_call
Yi Min Zhao [Wed, 15 Jun 2016 09:09:10 +0000 (17:09 +0800)]
s390x/pci: fix stpcifc_service_call

Firstly the function misses dmaas checking. This patch adds it.

Secondly the function uses s390_pci_find_dev_by_fh() to look up the
zpci device. This may fail if the guest provides a valid and disabled
fh but fh of the associated zpci device is enabled. Thus we use
s390_pci_find_dev_by_idx() instead.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: refactor list_pci
Yi Min Zhao [Fri, 3 Jun 2016 07:16:01 +0000 (15:16 +0800)]
s390x/pci: refactor list_pci

Because of the refactor of s390_pci_find_dev_by_idx(), list_pci()
should be updated. We introduce a new function to get the next
available zpci device. It simplifies the code of looking up zpci
devices.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: refactor s390_pci_find_dev_by_idx
Yi Min Zhao [Fri, 3 Jun 2016 06:17:59 +0000 (14:17 +0800)]
s390x/pci: refactor s390_pci_find_dev_by_idx

s390_find_dev_by_idx() only indexes usable zpci devices. It implies
that the index value of each zpci device is dynamic and may change if
a new zpci device is plugged. So we have to use a constant index to
look up the device.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: add checkings in CLP_SET_PCI_FN
Yi Min Zhao [Wed, 15 Jun 2016 09:02:36 +0000 (17:02 +0800)]
s390x/pci: add checkings in CLP_SET_PCI_FN

The code in CLP_SET_PCI_FN case misses some checkings. Let's add
them.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: enable zpci hot-plug/hot-unplug
Yi Min Zhao [Fri, 13 May 2016 04:50:09 +0000 (12:50 +0800)]
s390x/pci: enable zpci hot-plug/hot-unplug

We need to support hot-plug/hot-unplug for the new zpci devices as
well. This patch enables the present hot-plug/hot-unplug handlers
to support not only generic pci devices but also zpci devices.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: enable uid-checking
Yi Min Zhao [Wed, 11 May 2016 07:22:42 +0000 (15:22 +0800)]
s390x/pci: enable uid-checking

The uid-checking facility guarantees uniqueness of the uid within the
vm and exposes the real uid to the guest when listing pci devices.
Let's always enable it and present it to the guest in the response to
the list pci clp command.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: introduce S390PCIBusDevice qdev
Yi Min Zhao [Wed, 11 May 2016 07:10:06 +0000 (15:10 +0800)]
s390x/pci: introduce S390PCIBusDevice qdev

To support definitions of s390 pci attributes in Qemu cmdline, we have
to make current S390PCIBusDevice struct inherit DeviceState and add
three properties for it. Currently we only support definitions of uid
and fid.

'uid' is optionally defined by users, identifies a zpci device and
must be defined with a 16-bit and non-zero unique value.

'fid' ranges from 0x0 to 0xFFFFFFFF. For fid property, we introduce a
new PropertyInfo by the name of s390_pci_fid_propinfo with our special
setter and getter. As 'fid' is optional, introduce 'fid_defined' to
track whether the user specified a fid.

'target' field is to direct qemu to find the corresponding generic PCI
device. It is equal to the 'id' value of one of generic pci devices.
If the user doesn't specify 'id' parameter for a generic pci device,
its 'id' value will be generated automatically and use this value as
'target' to create an associated zpci device.

If the user did not specify 'uid' or 'fid', values are generated
automatically. 'target' is required.

In addition, if a pci device has no associated zpci device, the code
will generate a zpci device automatically for it.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: introduce S390PCIIOMMU
Yi Min Zhao [Wed, 11 May 2016 07:10:36 +0000 (15:10 +0800)]
s390x/pci: introduce S390PCIIOMMU

Currently each zpci device holds its own DMA address space and memory
region. At the same time, all instances of zpci device are stored in
S390pciState. So duirng the initialization of S390pciState, all zpci
devices are created and then all DMA address spaces are created. Thus,
when initializing pci devices, their corresponding DMA address spaces
could be found.

But zpci qdev will be introduced later. Zpci device may be initialized
and plugged afterwards generic pci device. So we should initialize all
DMA address spaces and memory regions before initializing zpci devices.

We introduce a new struct named S390PCIIOMMU. And a new field of
S390pciState, which is an array to store all instances of S390PCIIOMMU,
is added so that qemu pci code could find the corresponding DMA
address space when initializing a generic pci device. And this should
be done before the connection of a zpci device and a generic pci
device is built.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: introduce S390PCIBus
Yi Min Zhao [Thu, 14 Apr 2016 11:02:39 +0000 (19:02 +0800)]
s390x/pci: introduce S390PCIBus

To enable S390PCIBusDevice as qdev, there should be a new bus to
plug and manage all instances of S390PCIBusDevice. Due to this,
S390PCIBus is introduced.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: enforce zPCI state checking
Yi Min Zhao [Tue, 19 Apr 2016 07:03:13 +0000 (15:03 +0800)]
s390x/pci: enforce zPCI state checking

Current code uses some fields combinatorially to indicate the state of
a s390 pci device. This patch introduces device states in order to make
the code more readable and more logical.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: refactor s390_pci_find_dev_by_fh
Yi Min Zhao [Thu, 12 May 2016 06:27:25 +0000 (14:27 +0800)]
s390x/pci: refactor s390_pci_find_dev_by_fh

Because this function is called very frequently, we should use a more
effective way to find the zpci device. So we use the FH's index to get
the device directly.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: unify FH_ macros
Yi Min Zhao [Fri, 13 May 2016 08:16:30 +0000 (16:16 +0800)]
s390x/pci: unify FH_ macros

Present code uses some macros to structure PCI Function Handle. But
their names don't have a uniform format. Let's use FH_MASK_ as the
unified prefix.

While we're at it, differentiate the SHM bits: use different bits for
vfio and emulated devices.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: write fid in CLP_QUERY_PCI_FN
Yi Min Zhao [Mon, 13 Jun 2016 11:28:38 +0000 (19:28 +0800)]
s390x/pci: write fid in CLP_QUERY_PCI_FN

We forgot to write the fid; fix that.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: acceleration for getting S390pciState
Yi Min Zhao [Fri, 13 May 2016 06:58:14 +0000 (14:58 +0800)]
s390x/pci: acceleration for getting S390pciState

There are a number of places where the code needs to get the instance
of S390pciState. It calls object_resolve_path() every time. This
wastes a lot of time and leads to low performance. Thus we add
s390_get_phb() to improve it.

Because we always have a phb, we remove all return checkings in the
callers and add an assert in s390_get_phb() to make sure that phb is
getted successfully.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/pci: fix failures of dma map/unmap
Yi Min Zhao [Sun, 19 Jun 2016 11:20:46 +0000 (19:20 +0800)]
s390x/pci: fix failures of dma map/unmap

In commit d78c19b5cf4821d0c198f4132a085bdbf19dda4c, vfio code stores
the IOMMU's offset_within_address_space and adjusts the IOVA before
calling vfio_dma_map/vfio_dma_unmap. But s390_translate_iommu already
considers the base address of an IOMMU memory region.

Thus we use pal as the size and 0x0 as the base address to initialize
IOMMU memory subregion.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
7 years agos390x/css: Unplug handler of virtual css bridge
Jing Liu [Fri, 26 Feb 2016 05:46:12 +0000 (06:46 +0100)]
s390x/css: Unplug handler of virtual css bridge

The previous patch moved virtual css bridge and bus out from
virtio-ccw, but kept the direct reference of virtio-ccw specific
unplug function inside css-bridge.c.

To make the virtual css bus and bridge useful for non-virtio devices,
this introduces a common unplug function pointer "unplug" to call
specific virtio-ccw unplug parts. Thus, the tight coupling to
virtio-ccw can be removed.

This unplug pointer is a member of CCWDeviceClass, which is introduced
as an abstract device layer called "ccw-device". This layer is between
DeviceState and specific devices which are plugged in virtual css bus,
like virtio-ccw device. The specific unplug handlers should be assigned
to "unplug" during initialization.

Signed-off-by: Jing Liu <liujbjl@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Reviewed-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>