]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
10 years agocpu: Introduce CPUClass::parse_features() hook
Andreas Färber [Mon, 3 Mar 2014 22:19:19 +0000 (23:19 +0100)]
cpu: Introduce CPUClass::parse_features() hook

Adapt the X86CPU implementation to suit the generic hook.
This involves a cleanup of error handling to cope with NULL errp.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: X86CPU model subclasses
Eduardo Habkost [Mon, 10 Feb 2014 10:21:30 +0000 (08:21 -0200)]
target-i386: X86CPU model subclasses

Register separate QOM types for each x86 CPU model.

This will allow management code to more easily probe what each CPU model
provides, by simply creating objects using the appropriate class name,
without having to restart QEMU.

This also allows us to eliminate the qdev_prop_set_globals_for_type()
hack to set CPU-model-specific global properties.

Instead of creating separate class_init functions for each class, I just
used class_data to store a pointer to the X86CPUDefinition struct for
each CPU model. This should make the patch shorter and easier to review.
Later we can gradually convert each X86CPUDefinition field to lists of
per-class property defaults.

The "host" CPU model is special, as the feature flags depend on KVM
being initialized. So it has its own class_init and instance_init
function, and feature flags are set on instance_init instead of
class_init.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Eduardo Habkost <ehabkost@redhat.com>
[AF: Limit the host CPU type to CONFIG_KVM as build fix]
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Prepare CPUClass::class_by_name for X86CPU
Andreas Färber [Mon, 10 Feb 2014 21:02:44 +0000 (22:02 +0100)]
target-i386: Prepare CPUClass::class_by_name for X86CPU

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Enable x2apic by default on KVM
Eduardo Habkost [Wed, 19 Feb 2014 14:58:12 +0000 (11:58 -0300)]
target-i386: Enable x2apic by default on KVM

When on KVM mode, enable x2apic by default on all CPU models.

Normally we try to keep the CPU model definitions as close as the real
CPUs as possible, but x2apic can be emulated by KVM without host CPU
support for x2apic, and it improves performance by reducing APIC access
overhead. x2apic emulation is available on KVM since 2009 (Linux
2.6.32-rc1), there's no reason for not enabling x2apic by default when
running KVM.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Introduce x86_cpu_compat_disable_kvm_features()
Eduardo Habkost [Wed, 19 Feb 2014 14:58:11 +0000 (11:58 -0300)]
target-i386: Introduce x86_cpu_compat_disable_kvm_features()

Instead of the feature-specific disable_kvm_pv_eoi() function, create a
more general function that can be used to disable other feature bits in
machine-type compat code.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Make kvm_default_features an array
Eduardo Habkost [Wed, 19 Feb 2014 14:58:10 +0000 (11:58 -0300)]
target-i386: Make kvm_default_features an array

We will later make the KVM-specific code affect other feature words,
too.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Don't declare variables in the middle of blocks
Eduardo Habkost [Wed, 19 Feb 2014 19:39:21 +0000 (16:39 -0300)]
target-i386: Don't declare variables in the middle of blocks

Some of my recent changes introduced variable declarations in the middle
of code blocks.

Fix the code so that it compiles without warnings when using
-Wdeclaration-after-statement.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Rename x86_def_t to X86CPUDefinition
Eduardo Habkost [Thu, 30 Jan 2014 19:48:58 +0000 (17:48 -0200)]
target-i386: Rename x86_def_t to X86CPUDefinition

As the new X86CPU subclass code is going to change lots of the code
invoving x86_def_t, let's rename the struct to match coding style first.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Call x86_cpu_load_def() earlier
Eduardo Habkost [Thu, 30 Jan 2014 19:48:57 +0000 (17:48 -0200)]
target-i386: Call x86_cpu_load_def() earlier

As we will initialize the X86CPU fields on instance_init eventually,
move the code that initializes the X86CPU data based on the CPU model
name closer to the object_new() call.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Rename cpu_x86_register() to x86_cpu_load_def()
Eduardo Habkost [Thu, 30 Jan 2014 19:48:56 +0000 (17:48 -0200)]
target-i386: Rename cpu_x86_register() to x86_cpu_load_def()

There isn't any kind of "registration" involved in cpu_x86_register()
anymore: it is simply looking up a CPU model name and loading the model
definition data into the X86CPU object. Rename it to x86_cpu_load_def()
to reflect what it does.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Turn cpu_has_work() into a CPUClass hook
Andreas Färber [Sun, 25 Aug 2013 16:53:55 +0000 (18:53 +0200)]
cpu: Turn cpu_has_work() into a CPUClass hook

Default to false.

Tidy variable naming and inline cast uses while at it.

Tested-by: Jia Liu <proljc@gmail.com> (or32)
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-xtensa: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 19:02:29 +0000 (20:02 +0100)]
target-xtensa: Clean up ENV_GET_CPU() usage

Commits a00817cc4c18b7872e92765a4736fb2227cc237b and
fdfba1a298ae26dd44bcfdb0429314139a0bc55a added usages of ENV_GET_CPU()
macro in target-specific code.

Use xtensa_env_get_cpu() instead.

Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-unicore32: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 18:58:13 +0000 (19:58 +0100)]
target-unicore32: Clean up ENV_GET_CPU() usage

Commit fdfba1a298ae26dd44bcfdb0429314139a0bc55a added a usage of
ENV_GET_CPU() macro in target-specific code.

Use uc32_env_get_cpu() instead.

Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-sparc: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 18:51:00 +0000 (19:51 +0100)]
target-sparc: Clean up ENV_GET_CPU() usage

Commits fdfba1a298ae26dd44bcfdb0429314139a0bc55a,
2c17449b3022ca9623c4a7e2a504a4150ac4ad30 and
f606604f1c10b60ef294f1b9b229426521a365e3 added usages of ENV_GET_CPU()
macro in target-specific code.

Use sparc_env_get_cpu() instead and reuse the variables.

Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-s390x: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 18:40:08 +0000 (19:40 +0100)]
target-s390x: Clean up ENV_GET_CPU() usage

Commits f606604f1c10b60ef294f1b9b229426521a365e3,
2c17449b3022ca9623c4a7e2a504a4150ac4ad30 and
5ce5944dc0ffdc43c11b5cad11e526f699aabe4c added usages of ENV_GET_CPU()
macro in target-specific code.

Use s390_env_get_cpu() instead.

Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-ppc: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 18:29:41 +0000 (19:29 +0100)]
target-ppc: Clean up ENV_GET_CPU() usage

Commits fdfba1a298ae26dd44bcfdb0429314139a0bc55a,
ab1da85791340e504d10487e1add81b9988afa98,
f606604f1c10b60ef294f1b9b229426521a365e3 and
2c17449b3022ca9623c4a7e2a504a4150ac4ad30 added usages of ENV_GET_CPU()
macro in target-specific code.

Use ppc_env_get_cpu() instead.

Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-i386: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 18:15:27 +0000 (19:15 +0100)]
target-i386: Clean up ENV_GET_CPU() usage

Commits fdfba1a298ae26dd44bcfdb0429314139a0bc55a,
f606604f1c10b60ef294f1b9b229426521a365e3 and
2c17449b3022ca9623c4a7e2a504a4150ac4ad30 added usages of ENV_GET_CPU()
macro in target-specific code.

Use x86_env_get_cpu() or reuse existing X86CPU variable instead.

Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-arm: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 18:10:29 +0000 (19:10 +0100)]
target-arm: Clean up ENV_GET_CPU() usage

Commits ab1da85791340e504d10487e1add81b9988afa98,
fdfba1a298ae26dd44bcfdb0429314139a0bc55a,
2c17449b3022ca9623c4a7e2a504a4150ac4ad30 added usages of ENV_GET_CPU()
macro to target-specific code.

Use arm_env_get_cpu() instead and enforce separating variable
declarations.

Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotarget-alpha: Clean up ENV_GET_CPU() usage
Andreas Färber [Sun, 9 Mar 2014 17:58:57 +0000 (18:58 +0100)]
target-alpha: Clean up ENV_GET_CPU() usage

Commits 2c17449b3022ca9623c4a7e2a504a4150ac4ad30,
fdfba1a298ae26dd44bcfdb0429314139a0bc55a,
ab1da85791340e504d10487e1add81b9988afa98 and
f606604f1c10b60ef294f1b9b229426521a365e3 added usages of ENV_GET_CPU()
macro in target-specific code.

Use alpha_env_get_cpu() instead.

Cc: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agocpu: Don't clear cpu->exit_request on reset
Edgar E. Iglesias [Thu, 13 Feb 2014 05:07:14 +0000 (15:07 +1000)]
cpu: Don't clear cpu->exit_request on reset

cpu->exit_request is part of the execution environment and should
not be cleared when a CPU resets.

Otherwise, we might deadlock QEMU if a CPU resets while there is
I/O going on.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Thu, 13 Mar 2014 15:33:04 +0000 (15:33 +0000)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

Block pull request

# gpg: Signature made Thu 13 Mar 2014 13:50:49 GMT using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request: (24 commits)
  block/raw-win32: bdrv_parse_filename() for hdev
  block/raw-posix: Strip protocol prefix on creation
  block/raw-posix: bdrv_parse_filename() for cdrom
  block/raw-posix: bdrv_parse_filename() for floppy
  block/raw-posix: bdrv_parse_filename() for hdev
  qemu-io: Fix warnings from static code analysis
  block: Unlink temporary file
  qcow2: Don't write with BDRV_O_INCOMING
  qcow2: Keep option in qcow2_invalidate_cache()
  qmp: add query-iothreads command
  iothread: stash thread ID away
  dataplane: replace internal thread with IOThread
  iothread: add "iothread" qdev property type
  qdev: make get_pointer() handle temporary strings
  iothread: add I/O thread object
  aio: add aio_context_acquire() and aio_context_release()
  rfifolock: add recursive FIFO lock
  object: add object_get_canonical_path_component()
  block: Rewrite the snapshot authorization mechanism for block filters.
  iotests: Test corruption during COW request
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agooslib-posix: Fix build on FreeBSD
Andreas Färber [Thu, 13 Mar 2014 13:27:59 +0000 (14:27 +0100)]
oslib-posix: Fix build on FreeBSD

Commit 10f5bff622cad71645e22c027b77ac31e51008ef (util: Split out
exec_dir from os_find_datadir) moved code from os-posix.c to
util/oslib-posix.c but forgot to move a FreeBSD #include alongside,
needed for CTL_KERN among others.

Cc: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Message-id: 1394717279-23406-1-git-send-email-andreas.faerber@web.de
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoblock/raw-win32: bdrv_parse_filename() for hdev
Max Reitz [Fri, 7 Mar 2014 23:39:45 +0000 (00:39 +0100)]
block/raw-win32: bdrv_parse_filename() for hdev

The "host_device" protocol driver should strip the "host_device:" prefix
from filenames if present.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock/raw-posix: Strip protocol prefix on creation
Max Reitz [Fri, 7 Mar 2014 23:39:44 +0000 (00:39 +0100)]
block/raw-posix: Strip protocol prefix on creation

The hdev_create() implementation in block/raw-posix.c is used by the
"host_device", "host_cdrom" and "host_floppy" protocol block drivers
together. Thus, any of the associated prefixes may occur and exactly one
should should be stripped, if it does (thus,
"host_device:host_cdrom:/dev/cdrom" is not shortened to "/dev/cdrom").

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock/raw-posix: bdrv_parse_filename() for cdrom
Max Reitz [Fri, 7 Mar 2014 23:39:43 +0000 (00:39 +0100)]
block/raw-posix: bdrv_parse_filename() for cdrom

The "host_cdrom" protocol drivers should strip the "host_cdrom:" prefix
from filenames if present.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock/raw-posix: bdrv_parse_filename() for floppy
Max Reitz [Fri, 7 Mar 2014 23:39:42 +0000 (00:39 +0100)]
block/raw-posix: bdrv_parse_filename() for floppy

The "host_floppy" protocol driver should strip the "host_floppy:" prefix
from filenames if present.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock/raw-posix: bdrv_parse_filename() for hdev
Max Reitz [Fri, 7 Mar 2014 23:39:41 +0000 (00:39 +0100)]
block/raw-posix: bdrv_parse_filename() for hdev

The "host_device" protocol driver should strip the "host_device:" prefix
from filenames if present.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqemu-io: Fix warnings from static code analysis
Stefan Weil [Wed, 5 Mar 2014 21:23:00 +0000 (22:23 +0100)]
qemu-io: Fix warnings from static code analysis

Smatch complains about several global symbols which should be local.

Add the missing 'static' attributes and move the 'extern' declaration
of variable qemuio_misalign to qemu-io.h. This variable also changes
the type from 'int' to 'bool' which better fits documents its use.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: Unlink temporary file
Max Reitz [Sat, 15 Feb 2014 17:03:21 +0000 (18:03 +0100)]
block: Unlink temporary file

If the image file cannot be opened and was created as a temporary file,
it should be deleted; thus, in this case, we should jump to the
"unlink_and_fail" label and not just to "fail".

Reported-by: Benoît Canet <benoit@irqsave.net>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2: Don't write with BDRV_O_INCOMING
Kevin Wolf [Tue, 11 Mar 2014 14:15:03 +0000 (15:15 +0100)]
qcow2: Don't write with BDRV_O_INCOMING

qcow2_open() causes writes when repairing an image with the dirty flag
set and when clearing autoclear flags. It shouldn't do this when another
qemu instance is still actively working on this image file.

One effect of the bug is that images may have a cleared dirty flag while
the migration source host still has it in use with lazy refcounts
enabled, so refcounts are not accurate and the dirty flag must remain
set.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2: Keep option in qcow2_invalidate_cache()
Kevin Wolf [Tue, 11 Mar 2014 16:42:41 +0000 (17:42 +0100)]
qcow2: Keep option in qcow2_invalidate_cache()

Instead of manually building a list of all options from BDRVQcowState
values just reuse the options that were used to open the image.
qcow2_open() won't fully use all of the options in the QDict, but that's
okay.

This fixes all of the driver-specific options in qcow2, except for
lazy-refcounts, which was special cased before.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqmp: add query-iothreads command
Stefan Hajnoczi [Thu, 27 Feb 2014 10:48:42 +0000 (11:48 +0100)]
qmp: add query-iothreads command

The "query-iothreads" command returns a list of information about
iothreads.  See the patch for API documentation.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoiothread: stash thread ID away
Stefan Hajnoczi [Thu, 27 Feb 2014 10:48:41 +0000 (11:48 +0100)]
iothread: stash thread ID away

Keep the thread ID around so we can report it via QMP.

There's only one problem: qemu_get_thread_id() (gettid() wrapper on
Linux) must be called from the thread itself.  There is no way to get
the thread ID outside the thread.

This patch uses a condvar to wait for iothread_run() to populate the
thread_id inside the thread.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agodataplane: replace internal thread with IOThread
Stefan Hajnoczi [Mon, 3 Mar 2014 10:30:08 +0000 (11:30 +0100)]
dataplane: replace internal thread with IOThread

Today virtio-blk dataplane uses a 1:1 device-per-thread model.  Now that
IOThreads have been introduced we can generalize this to N:M devices per
threads.

This patch drops thread code from dataplane in favor of running inside
an IOThread AioContext.

As a bonus we solve the case where a guest keeps submitting I/O requests
while dataplane is trying to stop.  Previously the dataplane thread
would continue to process requests until the request gave it a break.
Now we can shut down in bounded time thanks to
aio_context_acquire/release.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoiothread: add "iothread" qdev property type
Stefan Hajnoczi [Mon, 3 Mar 2014 10:30:07 +0000 (11:30 +0100)]
iothread: add "iothread" qdev property type

Add a "iothread" qdev property type so devices can be hooked up to an
IOThread from the comand-line:

  qemu -object iothread,id=iothread0 \
       -device some-device,x-iothread=iothread0

Note that Paolo Bonzini <pbonzini@redhat.com> has suggested using QOM
links instead.  This way the relationship between the objects is
reflected in QOM.  There are currently shortcomings of
object_property_add_link() which prevent this use case.  I will attempt
to fix them and move to QOM links in a separate series.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqdev: make get_pointer() handle temporary strings
Igor Mammedov [Mon, 3 Mar 2014 10:30:06 +0000 (11:30 +0100)]
qdev: make get_pointer() handle temporary strings

get_pointer()'s print() callback might return a heap allocated
string, to avoid adding dedicated get_pointer_foo for this case
convert current print() callbacks to return temporary heap
allocated string and make get_pointer() free it.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoiothread: add I/O thread object
Stefan Hajnoczi [Mon, 3 Mar 2014 10:30:05 +0000 (11:30 +0100)]
iothread: add I/O thread object

This is a stand-in for Michael Roth's QContext.  I expect this to be
replaced once QContext is completed.

The IOThread object is an AioContext event loop thread.  This patch adds
the concept of multiple event loop threads, allowing users to define
them.

When SMP guests run on SMP hosts it makes sense to instantiate multiple
IOThreads.  This spreads event loop processing across multiple cores.
Note that additional patches are required to actually bind a device to
an IOThread.

[Andreas Färber <afaerber@suse.de> pointed out that the embedded parent
object instance should be called "parent_obj" and have a newline
afterwards.  This patch has been changed to reflect this.
-- Stefan]

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoaio: add aio_context_acquire() and aio_context_release()
Stefan Hajnoczi [Mon, 3 Mar 2014 10:30:04 +0000 (11:30 +0100)]
aio: add aio_context_acquire() and aio_context_release()

It can be useful to run an AioContext from a thread which normally does
not "own" the AioContext.  For example, request draining can be
implemented by acquiring the AioContext and looping aio_poll() until all
requests have been completed.

The following pattern should work:

  /* Event loop thread */
  while (running) {
      aio_context_acquire(ctx);
      aio_poll(ctx, true);
      aio_context_release(ctx);
  }

  /* Another thread */
  aio_context_acquire(ctx);
  bdrv_read(bs, 0x1000, buf, 1);
  aio_context_release(ctx);

This patch implements aio_context_acquire() and aio_context_release().

Note that existing aio_poll() callers do not need to worry about
acquiring and releasing - it is only needed when multiple threads will
call aio_poll() on the same AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agorfifolock: add recursive FIFO lock
Stefan Hajnoczi [Mon, 3 Mar 2014 10:30:03 +0000 (11:30 +0100)]
rfifolock: add recursive FIFO lock

QemuMutex does not guarantee fairness and cannot be acquired
recursively:

Fairness means each locker gets a turn and the scheduler cannot cause
starvation.

Recursive locking is useful for composition, it allows a sequence of
locking operations to be invoked atomically by acquiring the lock around
them.

This patch adds RFifoLock, a recursive lock that guarantees FIFO order.
Its first user is added in the next patch.

RFifoLock has one additional feature: it can be initialized with an
optional contention callback.  The callback is invoked whenever a thread
must wait for the lock.  For example, it can be used to poke the current
owner so that they release the lock soon.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoobject: add object_get_canonical_path_component()
Stefan Hajnoczi [Mon, 3 Mar 2014 10:30:02 +0000 (11:30 +0100)]
object: add object_get_canonical_path_component()

It is often useful to find an object's child property name.  Also use
this new function to simplify the implementation of
object_get_canonical_path().

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: Rewrite the snapshot authorization mechanism for block filters.
Benoît Canet [Mon, 3 Mar 2014 18:11:34 +0000 (19:11 +0100)]
block: Rewrite the snapshot authorization mechanism for block filters.

This patch keep the recursive way of doing things but simplify it by giving
two responsabilities to all block filters implementors.

They will need to do two things:

-Set the is_filter field of their block driver to true.

-Implement the bdrv_recurse_is_first_non_filter method of their block driver like
it is done on the Quorum block driver. (block/quorum.c)

[Paolo Bonzini <pbonzini@redhat.com> pointed out that this patch changes
the semantics of blkverify, which now recurses down both bs->file and
s->test_file.
-- Stefan]

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoiotests: Test corruption during COW request
Max Reitz [Mon, 10 Mar 2014 22:44:09 +0000 (23:44 +0100)]
iotests: Test corruption during COW request

Extend test file 060 by a test case for corruption occuring concurrently
to a COW request. QEMU should not crash but rather return an appropriate
error message.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: bs->drv may be NULL in bdrv_debug_resume()
Max Reitz [Mon, 10 Mar 2014 22:44:08 +0000 (23:44 +0100)]
block: bs->drv may be NULL in bdrv_debug_resume()

Currently, bdrv_debug_resume() requires every bs->drv in the BDS stack
to be NULL until a bs->drv with an implementation of bdrv_debug_resume()
is found. For a normal function, this would be fine, but this is a
function for debugging purposes and should therefore allow intermediate
BDS not to have a driver (i.e., be "ejected"). Otherwise, it is hard to
debug such situations.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2: Check bs->drv in copy_sectors()
Max Reitz [Mon, 10 Mar 2014 22:44:07 +0000 (23:44 +0100)]
qcow2: Check bs->drv in copy_sectors()

Before dereferencing bs->drv for a call to its member bdrv_co_readv(),
copy_sectors() should check whether that pointer is indeed valid, since
it may have been set to NULL by e.g. a concurrent write triggering the
corruption prevention mechanism.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: Update image size in bdrv_invalidate_cache()
Kevin Wolf [Tue, 11 Mar 2014 09:58:39 +0000 (10:58 +0100)]
block: Update image size in bdrv_invalidate_cache()

After migration has completed, we call bdrv_invalidate_cache() so that
drivers which cache some data drop their stale copy of the data and
reread it from the image file to get a new version of data that the
source modified while the migration was running.

Reloading metadata from the image file is useless, though, if the size
of the image file stays stale (this is a value that is cached for all
image formats in block.c). Reads from (meta)data after the old EOF
return only zeroes, causing image corruption.

We need to update bs->total_sectors in all layers that could potentially
have changed their size (i.e. backing files are not a concern - if they
are changed, we're in bigger trouble)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2-refcount: Sanitize refcount table entry
Max Reitz [Fri, 7 Mar 2014 22:10:12 +0000 (23:10 +0100)]
qcow2-refcount: Sanitize refcount table entry

When reading the refcount table entry in get_refcount(), only bits which
are actually significant for the refcount block offset should be taken
into account.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/afaerber/tags/ppc-for-2.0' into staging
Peter Maydell [Thu, 13 Mar 2014 13:19:46 +0000 (13:19 +0000)]
Merge remote-tracking branch 'remotes/afaerber/tags/ppc-for-2.0' into staging

PowerPC queue for 2.0-rc0

* QEMUMachine include cleanup
* SLOF update
* XICS reset fix
* sPAPR PCI host bridge refactorings

# gpg: Signature made Thu 13 Mar 2014 02:50:51 GMT using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/ppc-for-2.0:
  spapr-pci: Convert fprintf() to error_report()
  spapr-pci: Convert to QOM realize
  xics-kvm: Fix reset function
  pseries: Update SLOF firmware image to qemu-slof-20140304
  Move QEMUMachine typedef to qemu/typedefs.h
  Revert "KVM: Split QEMUMachine typedef into separate header"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging
Peter Maydell [Thu, 13 Mar 2014 12:32:47 +0000 (12:32 +0000)]
Merge remote-tracking branch 'remotes/afaerber/tags/qom-devices-for-peter' into staging

QOM/QTest infrastructure fixes and device conversions

* QTest cleanups and test cases for some virtio devices
* QTest for sPAPR PCI host bridge
* qom-test now tests reading all properties beneath /machine
* QOM API leak fixes
* QOM cleanups for SSI devices
* QOM conversion of QEMUMachine
* QOM realize for buses
* sPAPR PCI bus name change

# gpg: Signature made Thu 13 Mar 2014 00:22:40 GMT using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/qom-devices-for-peter: (31 commits)
  libqtest: Fix possible deadlock in qtest initialization
  pci: Move VMState registration/unregistration to QOM realize/unrealize
  qdev: Realize buses on device realization
  qdev: Prepare realize/unrealize hooks for BusState
  tests: Add spapr-pci-host-bridge qtest
  virtio-serial-port: Convert to QOM realize/unrealize
  virtio-console: QOM cast cleanup for VirtConsole
  tests: Add virtio-console qtest
  tests: Add virtio-serial qtest
  tests: Add virtio-scsi qtest
  tests: Add virtio-rng qtest
  tests: Add virtio-balloon qtest
  tests: Add virtio-blk qtest
  tests: Clean up IndustryPack TPCI200 gcov paths
  qom-test: Test QOM properties
  hw/boards: Convert current_machine to MachineState
  vl: Use MachineClass instead of global QEMUMachine list
  hw/core: Introduce QEMU machine as QOM object
  qdev-monitor-test: Don't test human-readable error message
  qdev-monitor-test: Simplify using g_assert_cmpstr()
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agolibqtest: Avoid inline varargs functions
Peter Maydell [Thu, 13 Mar 2014 11:24:15 +0000 (11:24 +0000)]
libqtest: Avoid inline varargs functions

Older versions of gcc (eg 4.6) can't handle varargs functions declared
inline for anything other than completely trivial uses, and complain:

tests/qom-test.c: In function 'qmp': tests/libqtest.h:359:60: sorry,
unimplemented: function 'qmp' can never be inlined because it uses
variable argument lists

Avoid this problem by putting the functions into libqtest.c instead
of using inline definitions in libqtest.h.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Andreas Färber <afaerber@suse.de>
10 years agospapr-pci: Convert fprintf() to error_report()
Alexey Kardashevskiy [Thu, 21 Nov 2013 04:08:58 +0000 (15:08 +1100)]
spapr-pci: Convert fprintf() to error_report()

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agospapr-pci: Convert to QOM realize
Alexey Kardashevskiy [Thu, 21 Nov 2013 04:08:55 +0000 (15:08 +1100)]
spapr-pci: Convert to QOM realize

This converts the old-style SysBusDevice::init() callback to a new-style
DeviceClass::realize() callback.

As a part of conversion, this replaces fprintf(stderr) with error_setg()
as realize() does not "return" any value, instead it puts the extended
error into **errp.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoxics-kvm: Fix reset function
Alexey Kardashevskiy [Thu, 13 Feb 2014 01:08:35 +0000 (12:08 +1100)]
xics-kvm: Fix reset function

Currently interrupt priorities are set to 0 (highest) at the very
beginning of the guest execution which is not correct and makes the guest
produce random interrupt error messages such as:
"Interrupt 0x1001 (real) is invalid, disabling it".
This also prevents interrupt states from correct migration.

This initializes priority to 0xFF as the emulated XICS does.

Suggested-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agopseries: Update SLOF firmware image to qemu-slof-20140304
Alexey Kardashevskiy [Mon, 10 Mar 2014 12:07:58 +0000 (23:07 +1100)]
pseries: Update SLOF firmware image to qemu-slof-20140304

The changelog is:
  > version: update to 20140304
  > Introduce dummy console device
  > vio-vscsi: Fix CRQ allocation alignment
  > version: update to 20140204
  > virtio-9p: disable unused structure
  > Make "boot net:dhcp" boot from IPv4 only
  > Fix virtio device shutdown
  > Change shutdown method name for virtio-scsi
  > Add support for 64bit LE ABI v1 and v2 support
  > Change representation of string environment variable
  > cas: return error when unknown node found
  > version: update
  > Reset obp-tftp arguments before parsing
  > Enable seamless netboot on IPv6 network
  > Fix shutdown for virtio devices
  > Fix zero checksum in UDP header
  > Handle router advertisement message properly
  > [oex]hci_exit: Check before freeing/unmapping memory
  > Work around missing sc 1 traps on pHyp
  > fix print_version() to return where it came from
  > usb-xhci: memory freeing and using returns as bool uniformly
  > Output banner and initial display output in VNC window
  > use VERSION file to generate FW version
  > cas: remove warning
  > Add support for loading little endian ELF binaries.
  > Add bswap_{16,32,64}p
  > dhcpv6 and other minor net-snk fixes
  > Fix missing drop in virtio-fs setup-alias
  > Find next available alias name
  > SLOF does not exit if given 1KB disk
  > boot: enable support for bootindex
  > pci-properties: add properties to enable hotplug for spapr
  > e1000: remember node handle
  > Increase quiesce tokens array size
  > virtio: timeout after 5sec
  > Enable IPv6 support in dns
  > usb-ohci: fix warnings
  > Add ipv6 support in net-snk
  > ipv4: fix frame overwriting following arp_send_request
  > e1000: fix SLOF_dma_map_out arguments
  > Maintain single global packet buffer for tftp
  > Increase virtio-net receive queue size
  > Increase veth receive queue size
  > Fix dprintf macros at various points
  > usb-ohci: rewrite done_head processing code
  > boot: add net in default boot order
  > block 0 address in the allocator
  > scsi: make-media-alias fix
  > usb-xhci: add xhci host controller support
  > usb-xhci: add xhci support
  > Avoid veth read/write calls with zero length buffer
  > boot: include other aliases
  > usb-core: disable xhci

Cc: Andreas Färber <afaerber@suse.de>
Cc: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
10 years agoMove QEMUMachine typedef to qemu/typedefs.h
Andreas Färber [Thu, 13 Mar 2014 02:40:13 +0000 (03:40 +0100)]
Move QEMUMachine typedef to qemu/typedefs.h

As reported in commit 9c06a1f79f959fffd09bfb7efc3d76051a6cd2da, xen.h is
not self-contained with regards to its use of QEMUMachine. Fix this.

Reported-by: Alexander Graf <agraf@suse.de>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoRevert "KVM: Split QEMUMachine typedef into separate header"
Andreas Färber [Thu, 13 Mar 2014 02:29:51 +0000 (03:29 +0100)]
Revert "KVM: Split QEMUMachine typedef into separate header"

This reverts commit 9c06a1f79f959fffd09bfb7efc3d76051a6cd2da.
The new header sysemu/qemumachine.h is undesired.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agolibqtest: Fix possible deadlock in qtest initialization
Marcel Apfelbaum [Tue, 11 Mar 2014 13:00:34 +0000 (15:00 +0200)]
libqtest: Fix possible deadlock in qtest initialization

'socket_accept' waits for QEMU to init its unix socket.
If QEMU encounters an error during command line parsing,
it can exit before initializing the communication channel.

Using a timeout for sockets fixes the issue.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agopci: Move VMState registration/unregistration to QOM realize/unrealize
Bandan Das [Mon, 25 Nov 2013 22:48:42 +0000 (17:48 -0500)]
pci: Move VMState registration/unregistration to QOM realize/unrealize

Use the realize and unrealize hooks to register and unregister
vmstate_pcibus respectively.

Relocate some stuff to avoid forward declarations.

Signed-off-by: Bandan Das <bsd@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
[AF: Keep using PCI_BUS() cast macro]
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev: Realize buses on device realization
Bandan Das [Wed, 12 Mar 2014 20:02:12 +0000 (21:02 +0100)]
qdev: Realize buses on device realization

Integrate (un)realization of child buses with realization/unrealization
of the device hosting them. Code in device_unparent() is reordered for
unrealization of buses to work as part of device unrealization.

That way no changes need to be made to bus instantiation.

Signed-off-by: Bandan Das <bsd@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev: Prepare realize/unrealize hooks for BusState
Bandan Das [Mon, 25 Nov 2013 22:48:40 +0000 (17:48 -0500)]
qdev: Prepare realize/unrealize hooks for BusState

Add a "realized" property calling realize/unrealize hooks as for devices.

Signed-off-by: Bandan Das <bsd@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Add spapr-pci-host-bridge qtest
Alexey Kardashevskiy [Mon, 10 Feb 2014 03:52:56 +0000 (14:52 +1100)]
tests: Add spapr-pci-host-bridge qtest

This adds a test whether sPAPR PHB can be added via the command line.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agovirtio-serial-port: Convert to QOM realize/unrealize
Andreas Färber [Fri, 7 Jun 2013 17:02:12 +0000 (19:02 +0200)]
virtio-serial-port: Convert to QOM realize/unrealize

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agovirtio-console: QOM cast cleanup for VirtConsole
Andreas Färber [Fri, 7 Jun 2013 17:10:02 +0000 (19:10 +0200)]
virtio-console: QOM cast cleanup for VirtConsole

Introduce type constant, cast macro and rename parent field.

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Add virtio-console qtest
Andreas Färber [Fri, 21 Feb 2014 16:49:12 +0000 (17:49 +0100)]
tests: Add virtio-console qtest

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Add virtio-serial qtest
Andreas Färber [Fri, 21 Feb 2014 16:36:57 +0000 (17:36 +0100)]
tests: Add virtio-serial qtest

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Add virtio-scsi qtest
Andreas Färber [Fri, 21 Feb 2014 15:42:15 +0000 (16:42 +0100)]
tests: Add virtio-scsi qtest

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Add virtio-rng qtest
Andreas Färber [Sun, 9 Feb 2014 03:43:10 +0000 (04:43 +0100)]
tests: Add virtio-rng qtest

Cc: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Add virtio-balloon qtest
Andreas Färber [Sun, 9 Feb 2014 03:39:47 +0000 (04:39 +0100)]
tests: Add virtio-balloon qtest

Cc: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Add virtio-blk qtest
Andreas Färber [Sun, 9 Feb 2014 03:32:55 +0000 (04:32 +0100)]
tests: Add virtio-blk qtest

Cc: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agotests: Clean up IndustryPack TPCI200 gcov paths
Andreas Färber [Fri, 21 Feb 2014 15:29:17 +0000 (16:29 +0100)]
tests: Clean up IndustryPack TPCI200 gcov paths

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqom-test: Test QOM properties
Andreas Färber [Fri, 7 Feb 2014 14:36:16 +0000 (15:36 +0100)]
qom-test: Test QOM properties

Recursively walk all properties under /machine and try to retrieve their
value. This is a regression test for link<> properties and the
DeviceState::hotpluggable property.

Cf. be2f78b6b062eec5170e2612299fb8953046993f and
    1a37eca107cece3ed454bae29eef0bd1fac4a244

Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agohw/boards: Convert current_machine to MachineState
Marcel Apfelbaum [Wed, 5 Mar 2014 17:30:47 +0000 (19:30 +0200)]
hw/boards: Convert current_machine to MachineState

In order to allow attaching machine options to a machine instance,
current_machine is converted into MachineState.
As a first step of deprecating QEMUMachine, some of the functions
were modified to return MachineClass.

Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agovl: Use MachineClass instead of global QEMUMachine list
Marcel Apfelbaum [Wed, 5 Mar 2014 17:30:46 +0000 (19:30 +0200)]
vl: Use MachineClass instead of global QEMUMachine list

The machine registration flow is refactored to use the QOM functionality.
Instead of linking the machines into a list, each machine has a type
and the types can be traversed in the QOM way.

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agohw/core: Introduce QEMU machine as QOM object
Marcel Apfelbaum [Wed, 5 Mar 2014 17:30:45 +0000 (19:30 +0200)]
hw/core: Introduce QEMU machine as QOM object

The main functional change is to convert QEMUMachine into MachineClass
and QEMUMachineInitArgs into MachineState, instance of MachineClass.

As a first step, in order to make possible an incremental development,
both QEMUMachine and QEMUMachineInitArgs are being embedded into the
new types.

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev-monitor-test: Don't test human-readable error message
Markus Armbruster [Thu, 6 Mar 2014 09:12:53 +0000 (10:12 +0100)]
qdev-monitor-test: Don't test human-readable error message

Test the error class instead.  Expecting a specific message is
fragile.  In fact, it broke once already, in commit 75884af.  Restore
the test of error member "class" dropped there, and drop the test of
error member "desc".

There are no other tests of "desc" as far as I can tell.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev-monitor-test: Simplify using g_assert_cmpstr()
Stefan Hajnoczi [Thu, 6 Mar 2014 09:12:52 +0000 (10:12 +0100)]
qdev-monitor-test: Simplify using g_assert_cmpstr()

Use g_assert_cmpstr() instead of combining g_assert() and strcmp(3).
This simplifies the code since we no longer have to play games to
distinguish NULL from "" using "(null)".

gcc extension haters will also be happy that ?: was dropped.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agospapr-pci: Change the default PCI bus naming
Alexey Kardashevskiy [Thu, 6 Mar 2014 03:11:00 +0000 (14:11 +1100)]
spapr-pci: Change the default PCI bus naming

Previously libvirt required the first/default PCI bus to have name "pci".
Since QEMU can support multiple buses now, libvirt wants "pci.0" now.

This removes custom bus name and lets QEMU make up default names.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoblock/m25p80: Remove FROM_SSI_SLAVE() usages
Peter Crosthwaite [Wed, 12 Feb 2014 00:30:45 +0000 (16:30 -0800)]
block/m25p80: Remove FROM_SSI_SLAVE() usages

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Rename parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agossi: Remove SSI_SLAVE_FROM_QDEV() macro
Peter Crosthwaite [Wed, 12 Feb 2014 00:30:10 +0000 (16:30 -0800)]
ssi: Remove SSI_SLAVE_FROM_QDEV() macro

There are no usages left of this legacy cast. Delete.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Rename SSISlave parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
ssi: Rename parent field

10 years agomisc/max111x: QOM casting sweep
Peter Crosthwaite [Wed, 12 Feb 2014 00:29:35 +0000 (16:29 -0800)]
misc/max111x: QOM casting sweep

Define and use QOM cast macro. Removes some usages of legacy casting
systems.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Rename parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agomisc/max111x: Create abstract max111x type
Peter Crosthwaite [Wed, 12 Feb 2014 00:29:00 +0000 (16:29 -0800)]
misc/max111x: Create abstract max111x type

Create an abstract class that encompasses both max111x variants. This is
needed for QOM cast macro creation (and is the right thing to do
anyway). Macroify type-names in the process.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agossi: Convert legacy SSI_BUS -> BUS casts
Peter Crosthwaite [Wed, 12 Feb 2014 00:28:25 +0000 (16:28 -0800)]
ssi: Convert legacy SSI_BUS -> BUS casts

Remove two legacy ->qbus style casts from TYPE_SSI_BUS to TYPE_BUS in
ssi.c.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Convert one missing ->qbus and rename parent field]
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agossi: Convert legacy SSI_SLAVE -> DEVICE casts
Peter Crosthwaite [Wed, 12 Feb 2014 00:27:50 +0000 (16:27 -0800)]
ssi: Convert legacy SSI_SLAVE -> DEVICE casts

Convert legacy ->qdev style casts from TYPE_SSI_SLAVE to TYPE_DEVICE.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
[AF: Introduce local DeviceState variable for transition to QOM realize]
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqom: Avoid leaking str and bool properties on failure
Stefan Hajnoczi [Tue, 4 Mar 2014 14:28:18 +0000 (15:28 +0100)]
qom: Avoid leaking str and bool properties on failure

When object_property_add_str() and object_property_add_bool() fail, they
leak their internal StringProperty and BoolProperty structs.  Remember
to free the structs on error.

Luckily this is a low-impact memory leak since most QOM properties are
static qdev properties that will never take the error case.
object_property_add() only fails if the property name is already in use.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev-monitor: Set properties after parent is assigned in device_add
Amos Kong [Mon, 3 Mar 2014 07:57:55 +0000 (15:57 +0800)]
qdev-monitor: Set properties after parent is assigned in device_add

Test steps:
 (qemu) device_add e1000,addr=adsf
  Property 'e1000.addr' doesn't take value 'adsf'
 (qemu) info qtree
  Then qemu crashed.

Currently we set a link to the new device from its parent bus, but the
device hasn't been added to QOM tree yet. When it fails to set properties,
object_unparent() can't clean up the device.

Delay setting of device properties until the device has been added to
the QOM composition tree. This way, when setting a property fails,
object_unparent() can clean up the device properly.

Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev: Set DeviceClass::hotpluggable default in class_init()
Igor Mammedov [Tue, 18 Feb 2014 16:56:53 +0000 (17:56 +0100)]
qdev: Set DeviceClass::hotpluggable default in class_init()

Move setting DeviceClass::hotpluggable default from device's
class_base_init() to device's class_init().

Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoqdev: Fix bus dependency of DeviceState::hotpluggable getter
Andreas Färber [Fri, 7 Mar 2014 18:04:13 +0000 (19:04 +0100)]
qdev: Fix bus dependency of DeviceState::hotpluggable getter

Commit 1a37eca107cece3ed454bae29eef0bd1fac4a244 (qdev: add
"hotpluggable" property to Device) added a property "hotpluggable" to
each device, with its getter accessing parent_bus->allow_hotplug.

Add a NULL check.

Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
10 years agoMerge remote-tracking branch 'remotes/afaerber/tags/prep-for-upstream' into staging
Peter Maydell [Wed, 12 Mar 2014 17:53:37 +0000 (17:53 +0000)]
Merge remote-tracking branch 'remotes/afaerber/tags/prep-for-upstream' into staging

PReP machine and devices

* ppc_rom.bin update and submodule

# gpg: Signature made Wed 12 Mar 2014 17:32:40 GMT using RSA key ID 3E7E013F
# gpg: Good signature from "Andreas Färber <afaerber@suse.de>"
# gpg:                 aka "Andreas Färber <afaerber@suse.com>"

* remotes/afaerber/tags/prep-for-upstream:
  prep: Update ppc_rom.bin
  Add OpenHack'Ware submodule

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging
Peter Maydell [Wed, 12 Mar 2014 16:45:25 +0000 (16:45 +0000)]
Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging

Net patches

# gpg: Signature made Wed 12 Mar 2014 13:48:20 GMT using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/net-pull-request:
  tap: avoid deadlocking rx

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoprep: Update ppc_rom.bin
Andreas Färber [Sun, 2 Mar 2014 21:27:14 +0000 (22:27 +0100)]
prep: Update ppc_rom.bin

Functionally, this is a revert of Jocelyn's r3309 /
55aa45ddde3283cdd781326d001f7456bf02f684 (Quickly hack PowerPC BIOS
able to boot on CDROM again.), for which we do not have the sources.

Therefore the sources used are v0.4.1 plus pc-bios/ohw.diff plus a
workaround turning IDE errors into warnings.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
10 years agoAdd OpenHack'Ware submodule
Andreas Färber [Wed, 12 Mar 2014 16:16:56 +0000 (17:16 +0100)]
Add OpenHack'Ware submodule

This replaces the ohw.diff file on top of v0.4.1.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
10 years agoMerge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging
Peter Maydell [Wed, 12 Mar 2014 15:46:43 +0000 (15:46 +0000)]
Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging

Tracing pull request

# gpg: Signature made Wed 12 Mar 2014 13:20:10 GMT using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/tracing-pull-request:
  trace: Fix build warnings for Win32 build

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/kraxel/tags/pull-misc-1' into staging
Peter Maydell [Wed, 12 Mar 2014 15:03:42 +0000 (15:03 +0000)]
Merge remote-tracking branch 'remotes/kraxel/tags/pull-misc-1' into staging

Docs: Introduce multiport serial support in qemupciserial.inf.

# gpg: Signature made Wed 12 Mar 2014 09:35:55 GMT using RSA key ID D3E87138
# 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>"

* remotes/kraxel/tags/pull-misc-1:
  Docs: Introduce multiport serial support in qemupciserial.inf.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agotrace: Fix build warnings for Win32 build
Peter Maydell [Thu, 20 Feb 2014 19:44:25 +0000 (19:44 +0000)]
trace: Fix build warnings for Win32 build

The Win32 build warns about trace/control-internal.h:

warning: 'trace_event_count' declared inline after being called

Fix this by simply reordering trace_event_id() and
trace_event_count().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/kiszka/queues/slirp' into staging
Peter Maydell [Wed, 12 Mar 2014 12:47:26 +0000 (12:47 +0000)]
Merge remote-tracking branch 'remotes/kiszka/queues/slirp' into staging

* remotes/kiszka/queues/slirp:
  slirp smb with modern win guests when samba is also running on host
  qemu/slirp: Fix SMB security configuration on newer samba versions

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/mcayland/qemu-sparc' into staging
Peter Maydell [Wed, 12 Mar 2014 11:44:59 +0000 (11:44 +0000)]
Merge remote-tracking branch 'remotes/mcayland/qemu-sparc' into staging

* remotes/mcayland/qemu-sparc:
  target-sparc: Add and use CPU_FEATURE_CASA

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
Peter Maydell [Wed, 12 Mar 2014 10:47:07 +0000 (10:47 +0000)]
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging

* remotes/qmp-unstable/queue/qmp:
  tests: test-qmp-commands: Fix double free
  qapi script: do not add "_" for every capitalized char in enum
  qapi script: do not allow string discriminator
  qapi: convert BlockdevOptions to use enum discriminator
  qapi script: support enum type as discriminator in union
  qapi script: use same function to generate enum string
  qapi script: code move for generate_enum_name()
  qapi script: check correctness of union
  qapi script: remember line number in schema parsing
  qapi script: add check for duplicated key
  qapi script: remember explicitly defined enum values

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoDocs: Introduce multiport serial support in qemupciserial.inf.
Miki Mishael [Sun, 19 Jan 2014 16:43:05 +0000 (11:43 -0500)]
Docs: Introduce multiport serial support in qemupciserial.inf.

      Support for pci-serial-2x and pci-serial-4x
      was added to the inf file.
      Standard Windows driver mf.sys used to
      split single function device into per-port nodes.

Signed-off-by: Miki Mishael <mmishael@redhat.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
10 years agotap: avoid deadlocking rx
Stefan Hajnoczi [Sat, 8 Mar 2014 15:00:43 +0000 (16:00 +0100)]
tap: avoid deadlocking rx

The net subsystem has a control flow mechanism so peer NetClientStates
can tell each other to stop sending packets.  This is used to stop
monitoring the tap file descriptor for incoming packets if the guest rx
ring has no spare buffers.

There is a corner case when tap_can_send() is true at the beginning of
an event loop iteration but becomes false before the tap_send() fd
handler is invoked.

tap_send() will read the packet from the tap file descriptor and attempt
to send it.  The net queue will hold on to the packet and return 0,
indicating that further I/O is not possible.  tap then stops monitoring
the file descriptor for reads.

This is unlike the normal case where tap_can_send() is the same before
and during the event loop iteration.  The event loop would simply not
monitor the file descriptor if tap_can_send() returns true.  Upon next
iteration it would check tap_can_send() again and begin monitoring if we
can send.

The deadlock happens because tap_send() explicitly disabled read_poll.
This is done with the expectation that the peer will call
qemu_net_queue_flush().  But hw/net/virtio-net.c does not monitor
vm_running transitions and issue the flush.  Hence we're left with a
broken tap device.

Cc: qemu-stable@nongnu.org
Reported-by: Neil Skrypuch <neil@tembosocial.com>
Tested-by: Neil Skrypuch <neil@tembosocial.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoslirp smb with modern win guests when samba is also running on host
Michael Tokarev [Thu, 28 Nov 2013 19:32:55 +0000 (23:32 +0400)]
slirp smb with modern win guests when samba is also running on host

After numerous reports that -smb (or -netdev user,smb=foo) not working
with modern windows (win7 and vista are reported as non-working), I
started digging myself.  And found that indeed it doesn't work, and
why.

The thing is that modern win tries to connect to port 445 (microsoft-ds)
first, and if that fails, it falls back to old port 139 (netbios-ssn).

slirp code in qemu only redirects port 139, it does not touch port 445.

So the prob is that if samba is also running on the host, guest will try
to communicate using port 445, and that will succed, but ofcourse guest
will not talk with our samba but with samba running on the host.

If samba is not running on the host, guest will fall back to port 139,
and will reach the redirecting rule and qemu will spawn smbd correctly.

The solution is to redirect both ports (139 and 445), and the fix is
a one-liner, adding second call to slirp_add_exec() at the end of
net/slirp.c:slirp_smb() function (provided below).

But it looks like that is not a proper fix really, since in theory
we should redirect both ports to the SAME, single samba instance,
but I'm not sure this is possible with slirp.  Well, even if two
smbd processes will be run on the same config dir, it should not
be a problem.

The one-liner (not exactly 1 since it touches previous line too) is like
this:

Signed-off-By: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 years agoqemu/slirp: Fix SMB security configuration on newer samba versions
Michael Buesch [Fri, 1 Nov 2013 11:23:49 +0000 (12:23 +0100)]
qemu/slirp: Fix SMB security configuration on newer samba versions

The smb.conf automatically generated by qemu's -smb option fails on current
samba, because smbd rejects the security=share option with the following warning:

>   WARNING: Ignoring invalid value 'share' for parameter 'security'

Which makes it fall back to security=user without guest login.
This results in being unable to login to the samba server from the guest OS.

This fixes it by selecting 'user' explicitly and mapping
unknown users to guest logins.

Signed-off-by: Michael Buesch <m@bues.ch>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>