sdk/emulator/qemu.git
11 years agoexec: assert that RAMBlock size is non-zero
Stefan Hajnoczi [Mon, 11 Mar 2013 09:20:21 +0000 (10:20 +0100)]
exec: assert that RAMBlock size is non-zero

find_ram_offset() does not handle size=0 gracefully.  It hands out the
same RAMBlock offset multiple times, leading to obscure failures later
on.

Add an assert to warn early if something is incorrectly allocating a
zero size RAMBlock.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci: refuse empty ROM files
Stefan Hajnoczi [Mon, 11 Mar 2013 09:20:20 +0000 (10:20 +0100)]
pci: refuse empty ROM files

A zero size ROM file is invalid and should produce a warning.
Attempting to use a zero size file ends up hitting an assertion
qemu_ram_set_idstr() because RAMBlocks with duplicate addresses are
allocated - due to zero size the allocator doesn't increment the next
available RAMBlock offset.

Also convert __FUNCTION__ to __func__ while we're touching this code.
There are no other __FUNCTION__ instances in pci.c anymore.

Reported-by: Milos Ivanovic <milosivanovic@orcon.net.nz>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci_bridge: Remove duplicate IRQ swizzle function
Alex Williamson [Thu, 7 Mar 2013 23:17:00 +0000 (16:17 -0700)]
pci_bridge: Remove duplicate IRQ swizzle function

pci_bridge_dev_map_irq_fn() is identical to pci_swizzle_map_irq_fn(),
which is now the default for all PCI bridges.  We can therefore remove
this function and the pci_bridge_map_irq() call that used it.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci_bridge: Use a default map_irq function
Alex Williamson [Thu, 7 Mar 2013 23:16:54 +0000 (16:16 -0700)]
pci_bridge: Use a default map_irq function

The PCI bridge spec defines a default swizzle for translating INTx
IRQs from secondary bus to primary.  Use this by default for any
bridge that doesn't set a function.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci: Fix INTx routing notifier recursion
Alex Williamson [Thu, 7 Mar 2013 18:29:19 +0000 (11:29 -0700)]
pci: Fix INTx routing notifier recursion

For some reason we recurse to fire the INTx routing notifier for each
child of a bus, for each possible device of a bus.  That means that if
we add a root port, the notifier gets called for that bridge 256
times.  If we add an upstream switch behind that root port, 256^2.  But
of course we need a downstream switch, 256^3.  This starts to be
noticeable.  Stop the insanity.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci_bridge: drop formatting from source
Michael S. Tsirkin [Mon, 4 Mar 2013 09:31:21 +0000 (11:31 +0200)]
pci_bridge: drop formatting from source

We use the same formatting for all files, it
doesn't make sense to have formatting directives only
in pci bridge header.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci_bridge: factor out common code
Michael S. Tsirkin [Mon, 4 Mar 2013 09:23:49 +0000 (11:23 +0200)]
pci_bridge: factor out common code

Reuse common code in pcie_port, override the hardwired-to-0
bits per PCI Express spec.
No functional change but makes the code easier to follow.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci: Teach PCI Bridges about VGA routing
Alex Williamson [Sun, 3 Mar 2013 17:21:32 +0000 (10:21 -0700)]
pci: Teach PCI Bridges about VGA routing

Each PCI Bridge has a set of implied VGA regions that are enabled when
the VGA bit is set in the bridge control register.  This allows VGA
devices behind bridges.  Unfortunately with VGA Enable, which we
formerly allowed but didn't back, comes along some required VGA
baggage.  VGA Palette Snooping is required, along with VGA 16-bit
decoding.  We don't yet have support for palette snooping.
We also don't have support for 10-bit VGA aliases, the default mode, but
we enable the register, even on root ports, to avoid confusing guests.
Fortunately there's likely nothing from this century that requires these
features, so the missing bits are noted with TODOs.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agopci: Add PCI VGA helpers
Alex Williamson [Sun, 3 Mar 2013 17:21:26 +0000 (10:21 -0700)]
pci: Add PCI VGA helpers

Allow devices to register VGA memory regions for handling PCI spec
defined VGA I/O port and MMIO areas.  PCI will attach these to the
bus address spaces and enable them according to the device command
register value.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agovirtio-pci: guest notifier mask without non-irqfd
Michael S. Tsirkin [Wed, 13 Mar 2013 19:37:08 +0000 (21:37 +0200)]
virtio-pci: guest notifier mask without non-irqfd

non-irqfd setups are currently broken with vhost:
we start up masked and nothing unmasks the interrupts.
Fix by using mask notifiers, same as the irqfd path.

Sharing irqchip/non irqchip code is always a good thing,
in this case it will help non irqchip benefit
from backend masking optimization.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agovirtio-net: remove layout assumptions for mq ctrl
Jason Wang [Wed, 6 Mar 2013 05:50:27 +0000 (13:50 +0800)]
virtio-net: remove layout assumptions for mq ctrl

Following commit 921ac5d0f3a0df869db5ce4edf752f51d8b1596a (virtio-net:
remove layout assumptions for ctrl vq), this patch makes multiqueue ctrl
handling not rely on the layout of descriptors.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agoqmp: add path to device_deleted event
Michael S. Tsirkin [Mon, 11 Mar 2013 13:11:04 +0000 (15:11 +0200)]
qmp: add path to device_deleted event

Add QOM path to device deleted event.  It now becomes useful to report
it for devices which don't have an ID assigned.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agoqom: call class destructor before unparent
Michael S. Tsirkin [Mon, 18 Mar 2013 19:01:37 +0000 (21:01 +0200)]
qom: call class destructor before unparent

It seems more logical to have destruction flow start with the subclass
and move up to the base class.  This ensures object has a valid
canonical path when destructor is called.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agoqdev: DEVICE_DELETED event
Michael S. Tsirkin [Wed, 6 Mar 2013 12:58:59 +0000 (14:58 +0200)]
qdev: DEVICE_DELETED event

libvirt has a long-standing bug: when removing the device,
it can request removal but does not know when the
removal completes. Add an event so we can fix this in a robust way.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
11 years agoFix TAGS creation
David Gibson [Tue, 12 Mar 2013 02:57:28 +0000 (13:57 +1100)]
Fix TAGS creation

Currently the Makefile creates TAGS for emacs with the command:
    find "$(SRC_PATH)" -name '*.[hc]' -print0 | xargs -0 etags
That works only if xargs ends up invoking etags just once.  If xargs runs
etags several times, as it will if there are enough files, then the later
invocations will overwrite the output from the earlier invocations.  This
patch uses the etags --append option to fix the bug.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Message-id: 1363057048-21534-1-git-send-email-david@gibson.dropbear.id.au
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'stefanha/block' into staging
Anthony Liguori [Fri, 15 Mar 2013 15:47:21 +0000 (10:47 -0500)]
Merge remote-tracking branch 'stefanha/block' into staging

# By Stefan Hajnoczi (14) and others
# Via Stefan Hajnoczi
* stefanha/block: (28 commits)
  blockdev: Fix up copyright and permission notice
  qemu-iotests: use -nographic in test case 007
  qemu-iotests: add tests for rebasing zero clusters
  dataplane: fix hang introduced by AioContext transition
  coroutine: use AioContext for CoQueue BH
  threadpool: drop global thread pool
  block: add bdrv_get_aio_context()
  aio: add a ThreadPool instance to AioContext
  threadpool: add thread_pool_new() and thread_pool_free()
  threadpool: move globals into struct ThreadPool
  main-loop: add qemu_get_aio_context()
  sheepdog: set io_flush handler in do_co_req
  sheepdog: use non-blocking fd in coroutine context
  qcow2: make is_allocated return true for zero clusters
  qcow2: drop unnecessary flush in qcow2_update_snapshot_refcount()
  qcow2: drop flush in update_cluster_refcount()
  qcow2: flush in qcow2_update_snapshot_refcount()
  qcow2: set L2 cache dependency in qcow2_alloc_bytes()
  qcow2: flush refcount cache correctly in qcow2_write_snapshots()
  qcow2: flush refcount cache correctly in alloc_refcount_block()
  ...

11 years agoMerge remote-tracking branch 'cohuck/virtio-ccw-upstr' into staging
Anthony Liguori [Fri, 15 Mar 2013 15:47:00 +0000 (10:47 -0500)]
Merge remote-tracking branch 'cohuck/virtio-ccw-upstr' into staging

# By Christian Borntraeger (1) and Cornelia Huck (1)
# Via Cornelia Huck
* cohuck/virtio-ccw-upstr:
  virtio-ccw: Wire up virtio-rng.
  virtio-ccw: remove qdev_unparent in unplug routing

11 years agoblockdev: Fix up copyright and permission notice
Markus Armbruster [Thu, 14 Mar 2013 12:59:53 +0000 (13:59 +0100)]
blockdev: Fix up copyright and permission notice

Screwed up in commit 666daa68.  Thanks to Kevin Wolf for reminding me
to fix this.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoqemu-iotests: use -nographic in test case 007
Stefan Hajnoczi [Thu, 14 Mar 2013 16:06:55 +0000 (17:06 +0100)]
qemu-iotests: use -nographic in test case 007

A comment explains that -nographic hangs test case 007.  This is no
longer the case so add -nographic.  This makes the test suite faster and
more pleasant to run since no windows pop up.

I am not sure exactly when -nographic starting working for this case but
there is no fundamental reason why graphics are needed here.  Make sure
the serial port is not on stdio, it would conflict with the monitor.

Also remove unnecessary trailing whitespace on these lines.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-iotests: add tests for rebasing zero clusters
Paolo Bonzini [Wed, 13 Mar 2013 14:58:13 +0000 (15:58 +0100)]
qemu-iotests: add tests for rebasing zero clusters

If zero clusters are erroneously treated as unallocated, "qemu-img rebase"
will copy the backing file's contents onto the cluster.

The bug existed also in image streaming, but since the root cause was in
qcow2's is_allocated implementation it is enough to test it with qemu-img.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agodataplane: fix hang introduced by AioContext transition
Paolo Bonzini [Wed, 13 Mar 2013 14:14:15 +0000 (15:14 +0100)]
dataplane: fix hang introduced by AioContext transition

The bug is that the EventNotifiers do have a NULL io_flush callback.
Because _none_ of the callbacks on the dataplane AioContext have such a
callback, aio_poll will simply do nothing.  Fixed by adding the callbacks:
the ioeventfd will always be polled (this can change in the future to
pause/resume the processing during live snapshots or similar operations);
the ioqueue will be polled if there are outstanding requests.

I must admit I have screwed up my testing somehow, because commit
2c20e71 does not work even if cherry-picked on top of 1.4.0, and this
patch fixes it there as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agocoroutine: use AioContext for CoQueue BH
Stefan Hajnoczi [Thu, 7 Mar 2013 12:41:50 +0000 (13:41 +0100)]
coroutine: use AioContext for CoQueue BH

CoQueue uses a BH to awake coroutines that were made ready to run again
using qemu_co_queue_next() or qemu_co_queue_restart_all().  The BH
currently runs in the iothread AioContext and would break coroutines
that run in a different AioContext.

This is a slightly tricky problem because the lifetime of the BH exceeds
that of the CoQueue.  This means coroutines can be awoken after CoQueue
itself has been freed.  Also, there is no qemu_co_queue_destroy()
function which we could use to handle freeing resources.

Introducing qemu_co_queue_destroy() has a ripple effect of requiring us
to also add qemu_co_mutex_destroy() and qemu_co_rwlock_destroy(), as
well as updating all callers.  Avoid doing that.

We also cannot switch from BH to GIdle function because aio_poll() does
not dispatch GIdle functions.  (GIdle functions make memory management
slightly easier because they free themselves.)

Finally, I don't want to move unlock_queue and unlock_bh into
AioContext.  That would break encapsulation - AioContext isn't supposed
to know about CoQueue.

This patch implements a different solution: each qemu_co_queue_next() or
qemu_co_queue_restart_all() call creates a new BH and list of coroutines
to wake up.  Callers tend to invoke qemu_co_queue_next() and
qemu_co_queue_restart_all() occasionally after blocking I/O, so creating
a new BH for each call shouldn't be massively inefficient.

Note that this patch does not add an interface for specifying the
AioContext.  That is left to future patches which will convert CoQueue,
CoMutex, and CoRwlock to expose AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agothreadpool: drop global thread pool
Stefan Hajnoczi [Thu, 7 Mar 2013 12:41:49 +0000 (13:41 +0100)]
threadpool: drop global thread pool

Now that each AioContext has a ThreadPool and the main loop AioContext
can be fetched with bdrv_get_aio_context(), we can eliminate the concept
of a global thread pool from thread-pool.c.

The submit functions must take a ThreadPool* argument.

block/raw-posix.c and block/raw-win32.c use
aio_get_thread_pool(bdrv_get_aio_context(bs)) to fetch the main loop's
ThreadPool.

tests/test-thread-pool.c must be updated to reflect the new
thread_pool_submit() function prototypes.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoblock: add bdrv_get_aio_context()
Stefan Hajnoczi [Thu, 7 Mar 2013 12:41:48 +0000 (13:41 +0100)]
block: add bdrv_get_aio_context()

For now bdrv_get_aio_context() is just a stub that calls
qemu_aio_get_context() since the block layer is currently tied to the
main loop AioContext.

Add the stub now so that the block layer can begin accessing its
AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agoaio: add a ThreadPool instance to AioContext
Stefan Hajnoczi [Thu, 7 Mar 2013 12:41:47 +0000 (13:41 +0100)]
aio: add a ThreadPool instance to AioContext

This patch adds a ThreadPool to AioContext.  It's possible that some
AioContext instances will never use the ThreadPool, so defer creation
until aio_get_thread_pool().

The reason why AioContext should have the ThreadPool is because the
ThreadPool is bound to a AioContext instance where the work item's
callback function is invoked.  It doesn't make sense to keep the
ThreadPool pointer anywhere other than AioContext.  For example,
block/raw-posix.c can get its AioContext's ThreadPool and submit work.

Special note about headers: I used struct ThreadPool in aio.h because
there is a circular dependency if aio.h includes thread-pool.h.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agothreadpool: add thread_pool_new() and thread_pool_free()
Stefan Hajnoczi [Thu, 7 Mar 2013 12:41:46 +0000 (13:41 +0100)]
threadpool: add thread_pool_new() and thread_pool_free()

ThreadPool is tied to an AioContext through its event notifier, which
dictates in which AioContext the work item's callback function will be
invoked.

In order to support multiple AioContexts we need to support multiple
ThreadPool instances.

This patch adds the new/free functions.  The free function deserves
special attention because it quiesces remaining worker threads.  This
requires a new condition variable and a "stopping" flag to let workers
know they should terminate once idle.

We never needed to do this before since the global threadpool was not
explicitly destroyed until process termination.

Also stash the AioContext pointer in ThreadPool so that we can call
aio_set_event_notifier() in thread_pool_free().  We didn't need to hold
onto AioContext previously since there was no free function.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agothreadpool: move globals into struct ThreadPool
Stefan Hajnoczi [Thu, 7 Mar 2013 12:41:45 +0000 (13:41 +0100)]
threadpool: move globals into struct ThreadPool

Move global variables into a struct so multiple thread pools can be
supported in the future.

This patch does not change thread-pool.h interfaces.  There is still a
global thread pool and it is not yet possible to create/destroy
individual thread pools.  Moving the variables into a struct first makes
later patches easier to review.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agomain-loop: add qemu_get_aio_context()
Stefan Hajnoczi [Thu, 7 Mar 2013 12:41:44 +0000 (13:41 +0100)]
main-loop: add qemu_get_aio_context()

It is very useful to get the main loop AioContext, which is a static
variable in main-loop.c.

I'm not sure whether qemu_get_aio_context() will be necessary in the
future once devices focus on using their own AioContext instead of the
main loop AioContext, but for now it allows us to refactor code to
support multiple AioContext while actually passing the main loop
AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
11 years agosheepdog: set io_flush handler in do_co_req
MORITA Kazutaka [Tue, 12 Mar 2013 07:05:43 +0000 (16:05 +0900)]
sheepdog: set io_flush handler in do_co_req

If an io_flush handler is not set, qemu_aio_wait doesn't invoke
callbacks.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agosheepdog: use non-blocking fd in coroutine context
MORITA Kazutaka [Tue, 12 Mar 2013 07:05:42 +0000 (16:05 +0900)]
sheepdog: use non-blocking fd in coroutine context

Using a blocking socket in the coroutine context reduces the chance of
switching to other work.  This patch makes the sheepdog driver use a
non-blocking fd always.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoqcow2: make is_allocated return true for zero clusters
Paolo Bonzini [Wed, 6 Mar 2013 17:02:01 +0000 (18:02 +0100)]
qcow2: make is_allocated return true for zero clusters

Otherwise, live migration of the top layer will miss zero clusters and
let the backing file show through.  This also matches what is done in qed.

QCOW2_CLUSTER_ZERO clusters are invalid in v2 image files.  Check this
directly in qcow2_get_cluster_offset instead of replicating the test
everywhere.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoqcow2: drop unnecessary flush in qcow2_update_snapshot_refcount()
Stefan Hajnoczi [Mon, 4 Mar 2013 14:02:35 +0000 (15:02 +0100)]
qcow2: drop unnecessary flush in qcow2_update_snapshot_refcount()

We already flush when the function completes.  There is no need to flush
after every compressed cluster.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: drop flush in update_cluster_refcount()
Stefan Hajnoczi [Mon, 4 Mar 2013 14:02:34 +0000 (15:02 +0100)]
qcow2: drop flush in update_cluster_refcount()

The update_cluster_refcount() function increments/decrements a cluster's
refcount and then returns the new refcount value.

There is no need to flush since both update_cluster_refcount() callers
already take care of this:

1. qcow2_alloc_bytes() calls update_cluster_refcount() when compressed
   sectors will be appended to an existing cluster with enough free
   space.  qcow2_alloc_bytes() already flushes so there is no need to do
   so in update_cluster_refcount().

2. qcow2_update_snapshot_refcount() sets a cache dependency on refcounts
   if it needs to update L2 entries.  It also flushes before completing.

Removing this flush significantly speeds up qcow2 snapshot creation:

  $ qemu-img create -f qcow2 test.qcow2 -o size=50G,preallocation=metadata
  $ time qemu-img snapshot -c new test.qcow2

Time drops from more than 3 minutes to under 1 second.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: flush in qcow2_update_snapshot_refcount()
Stefan Hajnoczi [Mon, 4 Mar 2013 14:02:33 +0000 (15:02 +0100)]
qcow2: flush in qcow2_update_snapshot_refcount()

Users of qcow2_update_snapshot_refcount() do not flush consistently.
qcow2_snapshot_create() flushes but qcow2_snapshot_goto() and
qcow2_snapshot_delete() do not.

Solve this by moving the bdrv_flush() into
qcow2_update_snapshot_refcount().

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: set L2 cache dependency in qcow2_alloc_bytes()
Stefan Hajnoczi [Mon, 4 Mar 2013 14:02:32 +0000 (15:02 +0100)]
qcow2: set L2 cache dependency in qcow2_alloc_bytes()

Compressed writes use qcow2_alloc_bytes() to allocate space with byte
granularity.  The affected clusters' refcounts will be incremented but
we do not need to flush yet.

Set a L2 cache dependency on the refcount block cache, so that the
refcounts get written out before the L2 updates.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: flush refcount cache correctly in qcow2_write_snapshots()
Stefan Hajnoczi [Mon, 4 Mar 2013 14:02:31 +0000 (15:02 +0100)]
qcow2: flush refcount cache correctly in qcow2_write_snapshots()

Since qcow2 metadata is cached we need to flush the caches, not just the
underlying file.  Use bdrv_flush(bs) instead of bdrv_flush(bs->file).

Also add the error return path when bdrv_flush() fails and move the
flush after checking for qcow2_alloc_clusters() failure so that the
qcow2_alloc_clusters() error return value takes precedence.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: flush refcount cache correctly in alloc_refcount_block()
Stefan Hajnoczi [Mon, 4 Mar 2013 14:02:30 +0000 (15:02 +0100)]
qcow2: flush refcount cache correctly in alloc_refcount_block()

update_refcount() affects the refcount cache, it does not write to disk.
Therefore bdrv_flush(bs->file) does nothing.  We need to flush the
refcount cache in order to write out the refcount updates!

While we're here also add error returns when qcow2_cache_flush() fails.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqcow2: Allow lazy refcounts to be enabled on the command line
Kevin Wolf [Fri, 15 Mar 2013 09:35:08 +0000 (10:35 +0100)]
qcow2: Allow lazy refcounts to be enabled on the command line

qcow2 images now accept a boolean lazy_refcounts options. Use it like
this:

  -drive file=test.qcow2,lazy_refcounts=on

If the option is specified on the command line, it overrides the default
specified by the qcow2 header flags that were set when creating the
image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: Support driver specific options in drive_init()
Kevin Wolf [Fri, 15 Mar 2013 09:35:07 +0000 (10:35 +0100)]
block: Support driver specific options in drive_init()

Any non-default -drive options are now passed down to the block drivers.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblockdev: Keep a copy of DriveInfo.serial
Kevin Wolf [Fri, 15 Mar 2013 09:35:06 +0000 (10:35 +0100)]
blockdev: Keep a copy of DriveInfo.serial

Pointing to a QemuOpts element is surprising and can lead to subtle
use-after-free errors when the QemuOpts is freed after all options are
parsed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoqemu-option: Add qemu_opts_absorb_qdict()
Kevin Wolf [Fri, 15 Mar 2013 09:35:05 +0000 (10:35 +0100)]
qemu-option: Add qemu_opts_absorb_qdict()

This adds a function that adds all entries of a QDict to a QemuOpts if
the keys are known, and leaves only the rest in the QDict.

This way a single QDict of -drive options can be processed in multiple
places (generic block layer, block driver, backing file block driver,
etc.), where each part picks the options it knows. If at the end of the
process the QDict isn't empty, the user specified an invalid option.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: Add options QDict to bdrv_open_common()
Kevin Wolf [Fri, 15 Mar 2013 09:35:04 +0000 (10:35 +0100)]
block: Add options QDict to bdrv_open_common()

The options are passed down to the block drivers, which are supposed to
remove all options they have processed. Anything that is left over in
the end is an unknown option and results in an error.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoAdd qdict_clone_shallow()
Kevin Wolf [Fri, 15 Mar 2013 09:35:03 +0000 (10:35 +0100)]
Add qdict_clone_shallow()

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: Add options QDict to bdrv_open() prototype
Kevin Wolf [Fri, 15 Mar 2013 09:35:02 +0000 (10:35 +0100)]
block: Add options QDict to bdrv_open() prototype

It doesn't do anything yet except storing the options QDict in the
BlockDriverState.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: Add options QDict to .bdrv_open()
Kevin Wolf [Fri, 15 Mar 2013 09:35:01 +0000 (10:35 +0100)]
block: Add options QDict to .bdrv_open()

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoqga/main.c: Don't use g_key_file_get/set_int64
Peter Crosthwaite [Fri, 15 Mar 2013 05:04:39 +0000 (15:04 +1000)]
qga/main.c: Don't use g_key_file_get/set_int64

These functions don't exist until glib version 2.26. QEMU is currently only
mandating glib 2.12.

This patch replaces the functions with g_key_file_get/set_integer.

Unbreaks the build on Ubuntu 10.04 and RHEL 5.6.

Regression was introduced by 39097daf15c42243742667607d2cad2c9dc4f764

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1363323879-682-1-git-send-email-peter.crosthwaite@xilinx.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/chardev.5' into staging
Anthony Liguori [Thu, 14 Mar 2013 19:54:37 +0000 (14:54 -0500)]
Merge remote-tracking branch 'kraxel/chardev.5' into staging

* kraxel/chardev.5:
  spice-qemu-char: Remove dead debugging code
  spice-qemu-char: Fix name parameter issues after qapi-ifying
  qemu-char.c: fix waiting for telnet connection message
  Revert "hmp: Disable chardev-add and chardev-remove"
  chardev: add udp support to qapi
  chardev: add memory (ringbuf) support to qapi
  chardev: add vc support to qapi
  chardev: add spice support to qapi
  chardev: add pipe support to qapi
  chardev: add console support to qapi
  chardev: switch pty init to qapi
  chardev: switch parallel init to qapi
  chardev: switch serial/tty init to qapi
  chardev: add stdio support to qapi
  chardev: switch file init to qapi
  chardev: add braille support to qapi
  chardev: add msmouse support to qapi
  chardev: switch null init to qapi
  chardev: add mux chardev support to qapi
  chardev: add support for qapi-based chardev initialization

Conflicts:
ui/console.c

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'afaerber/qom-cpu' into staging
Anthony Liguori [Thu, 14 Mar 2013 19:50:58 +0000 (14:50 -0500)]
Merge remote-tracking branch 'afaerber/qom-cpu' into staging

# By Andreas Färber (16) and Igor Mammedov (1)
# Via Andreas Färber
* afaerber/qom-cpu:
  target-lm32: Update VMStateDescription to LM32CPU
  target-arm: Override do_interrupt for ARMv7-M profile
  cpu: Replace do_interrupt() by CPUClass::do_interrupt method
  cpu: Pass CPUState to cpu_interrupt()
  exec: Pass CPUState to cpu_reset_interrupt()
  cpu: Move halted and interrupt_request fields to CPUState
  target-cris/helper.c: Update Coding Style
  target-i386: Update VMStateDescription to X86CPU
  cpu: Introduce cpu_class_set_vmsd()
  cpu: Register VMStateDescription through CPUState
  stubs: Add a vmstate_dummy struct for CONFIG_USER_ONLY
  vmstate: Make vmstate_register() static inline
  target-sh4: Move PVR/PRR/CVR into SuperHCPUClass
  target-sh4: Introduce SuperHCPU subclasses
  cpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu()
  monitor: Use qemu_get_cpu() in monitor_set_cpu()
  cpu: Fix qemu_get_cpu() to return NULL if CPU not found

11 years agoMerge remote-tracking branch 'mdroth/qga-pull-3-11-2013' into staging
Anthony Liguori [Thu, 14 Mar 2013 19:50:30 +0000 (14:50 -0500)]
Merge remote-tracking branch 'mdroth/qga-pull-3-11-2013' into staging

# By Laszlo Ersek (3) and others
# Via Michael Roth
* mdroth/qga-pull-3-11-2013:
  qga: implement qmp_guest_set_vcpus() for Linux with sysfs
  qga: implement qmp_guest_get_vcpus() for Linux with sysfs
  qga: introduce guest-get-vcpus / guest-set-vcpus with stubs
  qga: add guest-set-time command
  qga: add guest-get-time command
  qemu-ga: use key-value store to avoid recycling fd handles after restart
  qemu-ga: make guest-sync-delimited available during fsfreeze
  qemu-ga: fix confusing GAChannelMethod comparison
  qga: cast to int for DWORD type

11 years agoMerge remote-tracking branch 'riku/linux-user-for-upstream' into staging
Anthony Liguori [Thu, 14 Mar 2013 19:50:21 +0000 (14:50 -0500)]
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging

# By Peter Maydell (5) and others
# Via Riku Voipio
* riku/linux-user-for-upstream:
  linux-user/syscall.c: Don't warn about unimplemented get_robust_list
  linux-user: Implement accept4
  linux-user: Implement sendfile and sendfile64
  linux-user: make bogus negative iovec lengths fail EINVAL
  linux-user: Fix layout of usage table to account for option text
  linux-user: Add more sparc syscall numbers
  linux-user: Support setgroups syscall with no groups
  linux-user: fix futex strace of FUTEX_CLOCK_REALTIME
  linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex
  linux-user: improve print_fcntl()
  linux-user: Add Alpha socket constants

11 years agospice-qemu-char: Remove dead debugging code
Hans de Goede [Wed, 13 Mar 2013 13:59:44 +0000 (14:59 +0100)]
spice-qemu-char: Remove dead debugging code

Since commit d62e5f7036a018b2ad09f17ebd481bd28953d783
"chardev: add spice support to qapi"

It is impossible to set the debug parameter, so all the dprintf calls
are essentially nops. Since we've not needed the debug parameter in ages this
is not a problem, if it later turns out we do need some more debugging options
we can add more trace-points.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agospice-qemu-char: Fix name parameter issues after qapi-ifying
Hans de Goede [Wed, 13 Mar 2013 09:41:31 +0000 (10:41 +0100)]
spice-qemu-char: Fix name parameter issues after qapi-ifying

The strings passed in through the qapi calls are dynamic memory, since
we want to have them stick around longer then just the call to
qemu_chr_open_spice_* we need to strdup them.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agogtk: fix vc initialization
Anthony Liguori [Wed, 13 Mar 2013 17:21:04 +0000 (12:21 -0500)]
gtk: fix vc initialization

    commit 01f45d986fb0b7c2d4f0466efe3cde9708f325be
    Author: Anthony Liguori <aliguori@us.ibm.com>
    Date:   Tue Mar 5 23:21:32 2013 +0530

       qemu-char: move text console init to console.c

Broke vc initialization for GTK.  It's a simple typo.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoqemu-char.c: fix waiting for telnet connection message
Igor Mitsyanko [Sun, 10 Mar 2013 13:58:05 +0000 (17:58 +0400)]
qemu-char.c: fix waiting for telnet connection message

Current colon position in "waiting for telnet connection" message template
produces messages like:
QEMU waiting for connection on: telnet::127.0.0.16666,server

After moving a colon to the right, we will get a correct messages like:
QEMU waiting for connection on: telnet:127.0.0.1:6666,server

Signed-off-by: Igor Mitsyanko <i.mitsyanko@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoRevert "hmp: Disable chardev-add and chardev-remove"
Gerd Hoffmann [Thu, 28 Feb 2013 07:46:10 +0000 (08:46 +0100)]
Revert "hmp: Disable chardev-add and chardev-remove"

This reverts commit 8a14952c9d2f5fa2b3caa6dc286b62ed5d26bca7.

11 years agochardev: add udp support to qapi
Gerd Hoffmann [Wed, 27 Feb 2013 13:10:47 +0000 (14:10 +0100)]
chardev: add udp support to qapi

This patch adds 'udp' support to qapi.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add memory (ringbuf) support to qapi
Gerd Hoffmann [Tue, 26 Feb 2013 15:21:11 +0000 (16:21 +0100)]
chardev: add memory (ringbuf) support to qapi

This patch adds 'memory' support to qapi and also switches over
the memory chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add vc support to qapi
Gerd Hoffmann [Mon, 25 Feb 2013 14:52:32 +0000 (15:52 +0100)]
chardev: add vc support to qapi

This patch adds 'vc' support to qapi and also switches over the
vc chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add spice support to qapi
Gerd Hoffmann [Mon, 25 Feb 2013 11:39:06 +0000 (12:39 +0100)]
chardev: add spice support to qapi

This patch adds 'spicevmc' and 'spiceport' support to qapi and also
switches over the spice chardev initialization to the new qapi code
path.

11 years agochardev: add pipe support to qapi
Gerd Hoffmann [Mon, 25 Feb 2013 10:50:55 +0000 (11:50 +0100)]
chardev: add pipe support to qapi

This patch adds 'pipe' support to qapi and also switches over the
pipe chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add console support to qapi
Gerd Hoffmann [Mon, 25 Feb 2013 10:48:06 +0000 (11:48 +0100)]
chardev: add console support to qapi

This patch adds 'console' support to qapi and also switches over the
console chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: switch pty init to qapi
Gerd Hoffmann [Mon, 25 Feb 2013 09:16:46 +0000 (10:16 +0100)]
chardev: switch pty init to qapi

This patch switches over the pty chardev initialization
to the new qapi code path.

Bonus: Taking QemuOpts out of the loop allows some nice
cleanups along the way.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: switch parallel init to qapi
Gerd Hoffmann [Fri, 22 Feb 2013 15:17:01 +0000 (16:17 +0100)]
chardev: switch parallel init to qapi

This patch switches over the parallel chardev initialization
to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: switch serial/tty init to qapi
Gerd Hoffmann [Fri, 22 Feb 2013 14:48:05 +0000 (15:48 +0100)]
chardev: switch serial/tty init to qapi

This patch switches over the serial chardev initialization
to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add stdio support to qapi
Gerd Hoffmann [Thu, 21 Feb 2013 11:34:58 +0000 (12:34 +0100)]
chardev: add stdio support to qapi

This patch adds 'stdio' support to qapi and also switches over the
stdio chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: switch file init to qapi
Gerd Hoffmann [Thu, 21 Feb 2013 11:07:14 +0000 (12:07 +0100)]
chardev: switch file init to qapi

This patch switches over the 'file' chardev initialization
to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add braille support to qapi
Gerd Hoffmann [Thu, 21 Feb 2013 11:56:10 +0000 (12:56 +0100)]
chardev: add braille support to qapi

This patch adds 'braille' support to qapi and also switches over
the braille chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add msmouse support to qapi
Gerd Hoffmann [Thu, 21 Feb 2013 10:58:44 +0000 (11:58 +0100)]
chardev: add msmouse support to qapi

This patch adds 'msmouse' support to qapi and also switches over
the msmouse chardev initialization to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: switch null init to qapi
Gerd Hoffmann [Thu, 21 Feb 2013 10:41:26 +0000 (11:41 +0100)]
chardev: switch null init to qapi

This patch switches over the 'null' chardev initialization
to the new qapi code path.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add mux chardev support to qapi
Gerd Hoffmann [Thu, 21 Feb 2013 15:16:42 +0000 (16:16 +0100)]
chardev: add mux chardev support to qapi

This adds mux chardev support to the qapi and also makes the qapi-based
chardev creation path handle the "mux=on" option correctly.

11 years agochardev: add support for qapi-based chardev initialization
Gerd Hoffmann [Thu, 21 Feb 2013 10:39:12 +0000 (11:39 +0100)]
chardev: add support for qapi-based chardev initialization

This patch add support for a new way to initialize chardev devices.
Instead of calling a initialization function with a QemuOpts we will
now create a (qapi) ChardevBackend, optionally call a function to
fill ChardevBackend from QemuOpts, then go create the chardev using
the new qapi code path which is also used by chardev-add.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoexec: make -mem-path filenames deterministic
Peter Feiner [Mon, 4 Mar 2013 18:54:25 +0000 (13:54 -0500)]
exec: make -mem-path filenames deterministic

Adds ramblocks' names to their backing files when using -mem-path.  Eases
introspection and debugging.

Signed-off-by: Peter Feiner <peter@gridcentric.ca>
Message-id: 1362423265-15855-1-git-send-email-peter@gridcentric.ca
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoAdd search path support for qemu data files.
Gerd Hoffmann [Fri, 8 Mar 2013 10:42:24 +0000 (11:42 +0100)]
Add search path support for qemu data files.

This patch allows to specify multiple directories where qemu should look
for data files.  To implement that the behavior of the -L switch is
slightly different now:  Instead of replacing the data directory the
path specified will be appended to the data directory list.  So when
specifiying -L multiple times all directories specified will be checked,
in the order they are specified on the command line, instead of just the
last one.

Additionally the default paths are always appended to the directory
data list.  This allows to specify a incomplete directory (such as the
seabios out/ directory) via -L.  Anything not found there will be loaded
from the default paths, so you don't have to create a symlink farm for
all the rom blobs.

For trouble-shooting a tracepoint has been added, logging which blob
has been loaded from which location.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1362739344-8068-1-git-send-email-kraxel@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoBuild TPM passthrough for i386 and x86_64 targets
Stefan Berger [Wed, 27 Feb 2013 17:47:55 +0000 (12:47 -0500)]
Build TPM passthrough for i386 and x86_64 targets

Build the TPM passthrough driver only for i386 and x86_64 targets
using the default-configs files for those targets with softmmu.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-8-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoAdd support for cancelling of a TPM command
Stefan Berger [Wed, 27 Feb 2013 17:47:54 +0000 (12:47 -0500)]
Add support for cancelling of a TPM command

This patch adds support for cancelling an executing TPM command.
In Linux for example a user can cancel a command through the TPM's
sysfs 'cancel' entry using

echo "1" > /sysfs/class/misc/tpm0/device/cancel

This patch propagates the cancellation of a command inside a VM
to the host TPM's sysfs entry.
It also uses the possibility to cancel the command before QEMU VM
shutdown or reboot, which helps in preventing QEMU from hanging while
waiting for the completion of the command.
To relieve higher layers or users from having to determine the TPM's
cancel sysfs entry, the driver searches for the entry in well known
locations.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-7-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoAdd a TPM Passthrough backend driver implementation
Stefan Berger [Wed, 27 Feb 2013 17:47:53 +0000 (12:47 -0500)]
Add a TPM Passthrough backend driver implementation

This patch is based of off version 9 of Stefan Berger's patch series
  "QEMU Trusted Platform Module (TPM) integration"
and adds a new backend driver for it.

This patch adds a passthrough backend driver for passing commands sent to the
emulated TPM device directly to a TPM device opened on the host machine.
Thus it is possible to use a hardware TPM device in a system running on QEMU,
providing the ability to access a TPM in a special state (e.g. after a Trusted
Boot).

This functionality is being used in the acTvSM Trusted Virtualization Platform
which is available on [1].

Usage example:
  qemu-system-x86_64 -tpmdev passthrough,id=tpm0,path=/dev/tpm0 \
                     -device tpm-tis,tpmdev=tpm0 \
                     -cdrom test.iso -boot d

Some notes about the host TPM:
The TPM needs to be enabled and activated. If that's not the case one
has to go through the BIOS/UEFI and enable and activate that TPM for TPM
commands to work as expected.
It may be necessary to boot the kernel using tpm_tis.force=1 in the boot
command line or 'modprobe tpm_tis force=1' in case of using it as a module.

Regards,
Andreas Niederl, Stefan Berger

[1] http://trustedjava.sourceforge.net/

Signed-off-by: Andreas Niederl <andreas.niederl@iaik.tugraz.at>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-6-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoBuild the TPM frontend code
Stefan Berger [Wed, 27 Feb 2013 17:47:52 +0000 (12:47 -0500)]
Build the TPM frontend code

Build the TPM frontend code that has been added so far.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-5-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoAdd a debug register
Stefan Berger [Wed, 27 Feb 2013 17:47:51 +0000 (12:47 -0500)]
Add a debug register

This patch uses the possibility to add a vendor-specific register and
adds a debug register useful for dumping the TIS's internal state. This
register is only active in a debug build (#define DEBUG_TIS).

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-4-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoAdd TPM (frontend) hardware interface (TPM TIS) to QEMU
Stefan Berger [Wed, 27 Feb 2013 17:47:50 +0000 (12:47 -0500)]
Add TPM (frontend) hardware interface (TPM TIS) to QEMU

This patch adds the main code of the TPM frontend driver, the TPM TIS
interface, to QEMU. The code is largely based on the previous implementation
for Xen but has been significantly extended to meet the standard's
requirements, such as the support for changing of localities and all the
functionality of the available flags.

Communication with the backend (i.e., for Xen or the libtpms-based one)
is cleanly separated through an interface which the backend driver needs
to implement.

Whenever the frontend has collected a complete packet, it will submit
a task to the backend, which then starts processing the command. Once
the result has been returned, the backend invokes a callback function
(tpm_tis_receive_cb()).

Testing the proper functioning of the different flags and localities
cannot be done from user space when running in Linux for example, since
access to the address space of the TPM TIS interface is not possible. Also
the Linux driver itself does not exercise all functionality. So, for
testing there is a fairly extensive test suite as part of the SeaBIOS patches
since from within the BIOS one can have full access to all the TPM's registers.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-3-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoSupport for TPM command line options
Stefan Berger [Wed, 27 Feb 2013 17:47:49 +0000 (12:47 -0500)]
Support for TPM command line options

This patch adds support for TPM command line options.
The command line options supported here are

./qemu-... -tpmdev passthrough,path=<path to TPM device>,id=<id>
           -device tpm-tis,tpmdev=<id>,id=<other id>

and

./qemu-... -tpmdev help

where the latter works similar to -soundhw help and shows a list of
available TPM backends (for example 'passthrough').

Using the type parameter, the backend is chosen, i.e., 'passthrough' for the
passthrough driver. The interpretation of the other parameters along
with determining whether enough parameters were provided is pushed into
the backend driver, which needs to implement the interface function
'create' and return a TPMDriverOpts structure if the VM can be started or
'NULL' if not enough or bad parameters were provided.

Monitor support for 'info tpm' has been added. It for example prints the
following:

(qemu) info tpm
TPM devices:
 tpm0: model=tpm-tis
  \ tpm0: type=passthrough,path=/dev/tpm0,cancel-path=/sys/devices/pnp0/00:09/cancel

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com>
Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-ccw: Wire up virtio-rng.
Cornelia Huck [Mon, 4 Mar 2013 12:06:56 +0000 (13:06 +0100)]
virtio-ccw: Wire up virtio-rng.

Make virtio-rng devices available for s390-ccw-virtio machines.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
11 years agovirtio-ccw: remove qdev_unparent in unplug routing
Christian Borntraeger [Wed, 20 Feb 2013 12:02:07 +0000 (13:02 +0100)]
virtio-ccw: remove qdev_unparent in unplug routing

This patch fixes unplugging a virtio-ccw device. We no
longer need to do that in virtio-ccw since common code does now
proper handling.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
11 years agotarget-lm32: Update VMStateDescription to LM32CPU
Andreas Färber [Sat, 2 Feb 2013 12:45:29 +0000 (13:45 +0100)]
target-lm32: Update VMStateDescription to LM32CPU

Add a vmstate_lm32_cpu referencing the previous VMStateDescription as a
sub-struct and hook it up to CPUClass::vmsd. Drop cpu_{save,load}().

Acked-by: Michael Walle <michael@walle.cc>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-arm: Override do_interrupt for ARMv7-M profile
Andreas Färber [Sat, 2 Feb 2013 11:33:14 +0000 (12:33 +0100)]
target-arm: Override do_interrupt for ARMv7-M profile

Enable ARMCPUInfo to specify a custom class_init functions.
Introduce arm_v7m_class_init() and use it for "cortex-m3" model.

Instead of forwarding from arm_cpu_do_interrupt() to do_interrupt_v7m(),
override CPUClass::do_interrupt with arm_v7m_cpu_do_interrupt()
in arm_v7m_class_init().

Acked-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Replace do_interrupt() by CPUClass::do_interrupt method
Andreas Färber [Sat, 2 Feb 2013 09:57:51 +0000 (10:57 +0100)]
cpu: Replace do_interrupt() by CPUClass::do_interrupt method

This removes a global per-target function and thus takes us one step
closer to compiling multiple targets into one executable.

It will also allow to override the interrupt handling for certain CPU
families.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Pass CPUState to cpu_interrupt()
Andreas Färber [Fri, 18 Jan 2013 14:03:43 +0000 (15:03 +0100)]
cpu: Pass CPUState to cpu_interrupt()

Move it to qom/cpu.h to avoid issues with include order.

Change pc_acpi_smi_interrupt() opaque to X86CPU.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoexec: Pass CPUState to cpu_reset_interrupt()
Andreas Färber [Thu, 17 Jan 2013 21:30:20 +0000 (22:30 +0100)]
exec: Pass CPUState to cpu_reset_interrupt()

Move it to qom/cpu.c to avoid build failures depending on include order
of cpu-qom.h and exec/cpu-all.h.

Change opaques of various ..._irq_handler() functions to the
appropriate CPU type to facilitate using cpu_reset_interrupt().

Fix Coding Style issues while at it (missing braces, indentation).

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Move halted and interrupt_request fields to CPUState
Andreas Färber [Thu, 17 Jan 2013 17:51:17 +0000 (18:51 +0100)]
cpu: Move halted and interrupt_request fields to CPUState

Both fields are used in VMState, thus need to be moved together.
Explicitly zero them on reset since they were located before
breakpoints.

Pass PowerPCCPU to kvmppc_handle_halt().

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-cris/helper.c: Update Coding Style
Andreas Färber [Fri, 25 Jan 2013 16:37:28 +0000 (17:37 +0100)]
target-cris/helper.c: Update Coding Style

Reindent, add missing braces and drop/adjust whitespace.

Prepares for CPUArchState-to-CPUState field movements in
cpu_cris_handle_mmu_fault(), do_interruptv10() and do_interrupt().
The remaining functions were so minor that they can be fixed in one go.

Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Update VMStateDescription to X86CPU
Andreas Färber [Sat, 2 Feb 2013 12:38:08 +0000 (13:38 +0100)]
target-i386: Update VMStateDescription to X86CPU

Expose vmstate_cpu as vmstate_x86_cpu and hook it up to CPUClass::vmsd.
Adapt opaques and VMState fields to X86CPU. Drop cpu_{save,load}().

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Introduce cpu_class_set_vmsd()
Andreas Färber [Fri, 22 Feb 2013 20:50:10 +0000 (21:50 +0100)]
cpu: Introduce cpu_class_set_vmsd()

This setter avoids redefining each VMStateDescription value to
vmstate_dummy by not referencing the value for CONFIG_USER_ONLY.

Suggested-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Register VMStateDescription through CPUState
Andreas Färber [Sun, 20 Jan 2013 19:23:22 +0000 (20:23 +0100)]
cpu: Register VMStateDescription through CPUState

In comparison to DeviceClass::vmsd, CPU VMState is split in two,
"cpu_common" and "cpu", and uses cpu_index as instance_id instead of -1.
Therefore add a CPU-specific CPUClass::vmsd field.

Unlike the legacy CPUArchState registration, rather register CPUState.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
11 years agostubs: Add a vmstate_dummy struct for CONFIG_USER_ONLY
Andreas Färber [Mon, 18 Feb 2013 16:56:20 +0000 (17:56 +0100)]
stubs: Add a vmstate_dummy struct for CONFIG_USER_ONLY

Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agovmstate: Make vmstate_register() static inline
Andreas Färber [Mon, 18 Feb 2013 20:41:59 +0000 (21:41 +0100)]
vmstate: Make vmstate_register() static inline

This avoids adding a duplicate stub for CONFIG_USER_ONLY.

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-sh4: Move PVR/PRR/CVR into SuperHCPUClass
Andreas Färber [Tue, 20 Nov 2012 15:15:47 +0000 (16:15 +0100)]
target-sh4: Move PVR/PRR/CVR into SuperHCPUClass

They are never changed once initialized, and moving them to the class
will allow to inspect them before instantiating.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-sh4: Introduce SuperHCPU subclasses
Andreas Färber [Mon, 19 Nov 2012 01:42:18 +0000 (02:42 +0100)]
target-sh4: Introduce SuperHCPU subclasses

Store legacy name in SuperHCPUClass for -cpu ? and for case-insensitive
class lookup.

List CPUs by iterating over TYPE_SUPERH_CPU subclasses.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu()
Andreas Färber [Fri, 15 Feb 2013 14:41:49 +0000 (15:41 +0100)]
cpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu()

No functional change, just less usages of first_cpu and next_cpu fields.

env is passed to cpu_memory_rw_debug(), which in turn passes it to
target-specific cpu_get_phys_page_debug(). Changing both would be a
larger refactoring, so defer that by using env_ptr for now.

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agomonitor: Use qemu_get_cpu() in monitor_set_cpu()
Andreas Färber [Fri, 15 Feb 2013 16:01:09 +0000 (17:01 +0100)]
monitor: Use qemu_get_cpu() in monitor_set_cpu()

No functional change, just a reduction of CPU loops.

The mon_cpu field is left untouched for now since changing that requires
a number of larger prerequisites, including cpu_synchronize_state() and
mon_get_cpu().

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Fix qemu_get_cpu() to return NULL if CPU not found
Igor Mammedov [Thu, 7 Mar 2013 18:12:43 +0000 (19:12 +0100)]
cpu: Fix qemu_get_cpu() to return NULL if CPU not found

Commit 55e5c2850 breaks CPU not found return value, and returns
CPU corresponding to the last non NULL env.
Fix it by returning CPU only if env is not NULL, otherwise CPU is
not found and function should return NULL.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqga: implement qmp_guest_set_vcpus() for Linux with sysfs
Laszlo Ersek [Wed, 6 Mar 2013 21:59:31 +0000 (22:59 +0100)]
qga: implement qmp_guest_set_vcpus() for Linux with sysfs

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>