OSDN Git Service

qmiga/qemu.git
11 years agoMerge branch 'master' of git://git.qemu.org/qemu into prep-up
Andreas Färber [Thu, 10 Jan 2013 20:52:28 +0000 (21:52 +0100)]
Merge branch 'master' of git://git.qemu.org/qemu into prep-up

Conflicts:
hw/Makefile.objs
hw/ppc_prep.c

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
11 years agoMerge remote-tracking branch 'kraxel/build.1' into staging
Anthony Liguori [Thu, 10 Jan 2013 19:26:31 +0000 (13:26 -0600)]
Merge remote-tracking branch 'kraxel/build.1' into staging

* kraxel/build.1:
  m48t59-test: don't touch watchdog
  rtc-test: skip year-2038 overflow check in case time_t is 32bit only

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'awilliam/tags/qemu-1.4-vfio-20130109.0' into staging
Anthony Liguori [Thu, 10 Jan 2013 19:26:12 +0000 (13:26 -0600)]
Merge remote-tracking branch 'awilliam/tags/qemu-1.4-vfio-20130109.0' into staging

vfio-pci: Fixes for qemu 1.4 & stable

* awilliam/tags/qemu-1.4-vfio-20130109.0:
  vfio-pci: Loosen sanity checks to allow future features
  vfio-pci: Make host MSI-X enable track guest

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agom48t59-test: don't touch watchdog
Gerd Hoffmann [Fri, 4 Jan 2013 16:12:18 +0000 (17:12 +0100)]
m48t59-test: don't touch watchdog

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agortc-test: skip year-2038 overflow check in case time_t is 32bit only
Gerd Hoffmann [Fri, 4 Jan 2013 09:37:50 +0000 (10:37 +0100)]
rtc-test: skip year-2038 overflow check in case time_t is 32bit only

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoCheck return values from g_poll and select
Fabien Chouteau [Tue, 8 Jan 2013 15:30:56 +0000 (16:30 +0100)]
Check return values from g_poll and select

The current implementation of os_host_main_loop_wait() on Windows,
returns 1 only when a g_poll() event occurs because the return value of
select() is overridden. This is wrong as we may skip a socket event, as
shown in this example:

1. select() returns 0
2. g_poll() returns 1  (socket event occurs)
3. os_host_main_loop_wait() returns 1
4. qemu_iohandler_poll() sees no socket event because select() has
   return before the event occurs
5. select() returns 1
6. g_poll() returns 0 (g_poll overrides select's return value)
7. os_host_main_loop_wait() returns 0
8. qemu_iohandler_poll() doesn't check for socket events because the
   return value of os_host_main_loop_wait() is zero.
9. goto 5

This patch use one variable for each of these return values, so we don't
miss a select() event anymore.

Also move the call to select() after g_poll(), this will improve latency
as we don't have to go through two os_host_main_loop_wait() calls to
detect a socket event.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'mdroth/qga-pull-1-8-2013' into staging
Anthony Liguori [Wed, 9 Jan 2013 15:55:51 +0000 (09:55 -0600)]
Merge remote-tracking branch 'mdroth/qga-pull-1-8-2013' into staging

* mdroth/qga-pull-1-8-2013:
  qemu-ga: sample fsfreeze hooks
  qemu-ga: execute hook to quiesce the guest on fsfreeze-freeze/thaw
  qemu-ga: guest_suspend(): improve error reporting
  qemu-ga: bios_supports_mode(): improve error reporting
  qemu-ga: qmp_guest_network_get_interfaces(): get rid of snprintf() + error_set()
  qemu-ga: qmp_guest_fstrim(): get rid of sprintf() + error_set()
  qemu-ga: qmp_guest_fsfreeze_*(): get rid of sprintf() + error_set()
  qemu-ga: build_fs_mount_list(): take an Error argument
  qemu-ga: qmp_guest_shutdown(): improve error reporting
  qemu-ga: qmp_guest_file_*: improve error reporting
  qemu-ga: qmp_guest_file_close(): fix fclose() error check
  qemu-ga: guest_file_handle_find(): take an Error argument

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoqemu-ga: sample fsfreeze hooks
Tomoki Sekiyama [Wed, 12 Dec 2012 03:55:57 +0000 (12:55 +0900)]
qemu-ga: sample fsfreeze hooks

Adds sample hook scripts for --fsfreeze-hook option of qemu-ga.
  - fsfreeze-hook : execute scripts in fsfreeze-hook.d/
  - fsfreeze-hook.d/mysql-flush.sh.sample : quiesce MySQL before snapshot

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: execute hook to quiesce the guest on fsfreeze-freeze/thaw
Tomoki Sekiyama [Wed, 12 Dec 2012 03:55:55 +0000 (12:55 +0900)]
qemu-ga: execute hook to quiesce the guest on fsfreeze-freeze/thaw

To use the online disk snapshot for online-backup, application-level
consistency of the snapshot image is required. However, currently the
guest agent can provide only filesystem-level consistency, and the
snapshot may contain dirty data, for example, incomplete transactions.
This patch provides the opportunity to quiesce applications before
snapshot is taken.

If --fsfreeze-hook option is specified, the hook is executed with
"freeze" argument before the filesystem is frozen by fsfreeze-freeze
command. As for fsfreeze-thaw command, the hook is executed with "thaw"
argument after the filesystem is thawed.

This patch depends on patchset to improve error reporting by Luiz Capitulino:
  http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg03016.html

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama.qu@hitachi.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
*clarified usage in help output

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: guest_suspend(): improve error reporting
Luiz Capitulino [Tue, 27 Nov 2012 13:02:04 +0000 (11:02 -0200)]
qemu-ga: guest_suspend(): improve error reporting

Most errors are QERR_UNDEFINED_ERROR today.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: bios_supports_mode(): improve error reporting
Luiz Capitulino [Tue, 27 Nov 2012 13:02:03 +0000 (11:02 -0200)]
qemu-ga: bios_supports_mode(): improve error reporting

Most errors are QERR_UNDEFINED_ERROR today.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: qmp_guest_network_get_interfaces(): get rid of snprintf() + error_set()
Luiz Capitulino [Tue, 27 Nov 2012 13:02:02 +0000 (11:02 -0200)]
qemu-ga: qmp_guest_network_get_interfaces(): get rid of snprintf() + error_set()

Convert them to error_setg_errno().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: qmp_guest_fstrim(): get rid of sprintf() + error_set()
Luiz Capitulino [Tue, 27 Nov 2012 13:02:01 +0000 (11:02 -0200)]
qemu-ga: qmp_guest_fstrim(): get rid of sprintf() + error_set()

Convert them to error_setg_errno().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: qmp_guest_fsfreeze_*(): get rid of sprintf() + error_set()
Luiz Capitulino [Tue, 27 Nov 2012 13:02:00 +0000 (11:02 -0200)]
qemu-ga: qmp_guest_fsfreeze_*(): get rid of sprintf() + error_set()

Convert them to error_setg_errno().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: build_fs_mount_list(): take an Error argument
Luiz Capitulino [Thu, 29 Nov 2012 17:29:11 +0000 (15:29 -0200)]
qemu-ga: build_fs_mount_list(): take an Error argument

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: qmp_guest_shutdown(): improve error reporting
Luiz Capitulino [Tue, 27 Nov 2012 13:01:58 +0000 (11:01 -0200)]
qemu-ga: qmp_guest_shutdown(): improve error reporting

Most errors are QERR_UNDEFINED_ERROR. Also, adds ga_wait_child() as
a future commit will use it too.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: qmp_guest_file_*: improve error reporting
Luiz Capitulino [Tue, 27 Nov 2012 13:01:57 +0000 (11:01 -0200)]
qemu-ga: qmp_guest_file_*: improve error reporting

Use error_setg_errno() when possible with an improved error description.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: qmp_guest_file_close(): fix fclose() error check
Luiz Capitulino [Tue, 27 Nov 2012 13:01:56 +0000 (11:01 -0200)]
qemu-ga: qmp_guest_file_close(): fix fclose() error check

fclose() returns EOF on error.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: guest_file_handle_find(): take an Error argument
Luiz Capitulino [Tue, 27 Nov 2012 13:01:55 +0000 (11:01 -0200)]
qemu-ga: guest_file_handle_find(): take an Error argument

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
*Fixed missing space character in error message

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoMerge remote-tracking branch 'afaerber/qom-cpu' into staging
Anthony Liguori [Tue, 8 Jan 2013 21:15:57 +0000 (15:15 -0600)]
Merge remote-tracking branch 'afaerber/qom-cpu' into staging

* afaerber/qom-cpu:
  target-i386: Explicitly set vendor for each built-in cpudef
  target-i386: Sanitize AMD's ext2_features at realize time
  target-i386: Filter out unsupported features at realize time
  qemu-common.h: Make qemu_init_vcpu() stub static inline
  target-i386: check/enforce: Eliminate check_feat field
  target-i386: check/enforce: Check SVM flag support as well
  target-i386: check/enforce: Check all CPUID.80000001H.EDX bits
  target-i386: check/enforce: Do not ignore "hypervisor" flag
  target-i386: check/enforce: Fix CPUID leaf numbers on error messages
  target-i386: kvm: Enable all supported KVM features for -cpu host
  target-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features
  cpu: Change parent type to Device
  qdev: Don't assume existence of parent bus on unparenting
  qdev: Include qdev code into *-user, too
  libqemustub: sysbus_get_default() stub
  libqemustub: vmstate register/unregister stubs
  libqemustub: Add qemu_[un]register_reset() stubs

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovfio-pci: Loosen sanity checks to allow future features
Alex Williamson [Tue, 8 Jan 2013 21:10:03 +0000 (14:10 -0700)]
vfio-pci: Loosen sanity checks to allow future features

VFIO_PCI_NUM_REGIONS and VFIO_PCI_NUM_IRQS should never have been
used in this manner as it locks a specific kernel implementation.
Future features may introduce new regions or interrupt entries
(VGA may add legacy ranges, AER might add an IRQ for error
signalling).  Fix this before it gets us into trouble.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-stable@nongnu.org
11 years agovfio-pci: Make host MSI-X enable track guest
Alex Williamson [Tue, 8 Jan 2013 21:09:03 +0000 (14:09 -0700)]
vfio-pci: Make host MSI-X enable track guest

Guests typically enable MSI-X with all of the vectors in the MSI-X
vector table masked.  Only when the vector is enabled does the vector
get unmasked, resulting in a vector_use callback.  These two points,
enable and unmask, correspond to pci_enable_msix() and request_irq()
for Linux guests.  Some drivers rely on VF/PF or PF/fw communication
channels that expect the physical state of the device to match the
guest visible state of the device.  They don't appreciate lazily
enabling MSI-X on the physical device.

To solve this, enable MSI-X with a single vector when the MSI-X
capability is enabled and immediate disable the vector.  This leaves
the physical device in exactly the same state between host and guest.
Furthermore, the brief gap where we enable vector 0, it fires into
userspace, not KVM, so the guest doesn't get spurious interrupts.
Ideally we could call VFIO_DEVICE_SET_IRQS with the right parameters
to enable MSI-X with zero vectors, but this will currently return an
error as the Linux MSI-X interfaces do not allow it.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-stable@nongnu.org
11 years agotarget-i386: Explicitly set vendor for each built-in cpudef
Igor Mammedov [Fri, 28 Dec 2012 20:01:18 +0000 (21:01 +0100)]
target-i386: Explicitly set vendor for each built-in cpudef

Since cpudef config is not supported anymore and all remaining sources
now always set x86_def_t.vendor[123] fields, remove setting default
vendor to simplify future re-factoring.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Sanitize AMD's ext2_features at realize time
Igor Mammedov [Fri, 28 Dec 2012 20:01:17 +0000 (21:01 +0100)]
target-i386: Sanitize AMD's ext2_features at realize time

When CPU properties are implemented, ext2_features may change
between object_new(CPU) and cpu_realize_fn(). Sanitizing
ext2_features for AMD based CPU at realize() time will keep
current behavior after CPU features are converted to properties.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Filter out unsupported features at realize time
Igor Mammedov [Fri, 28 Dec 2012 20:01:16 +0000 (21:01 +0100)]
target-i386: Filter out unsupported features at realize time

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqemu-common.h: Make qemu_init_vcpu() stub static inline
Andreas Färber [Sat, 5 Jan 2013 13:44:08 +0000 (14:44 +0100)]
qemu-common.h: Make qemu_init_vcpu() stub static inline

Turn the *-user macro into a no-op inline function to avoid
unused-variable warnings and band-aiding #ifdef'ery.

This allows to drop an #ifdef for alpha and avoids more for unicore32
and other upcoming trivial realizefn implementations.

Suggested-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
11 years agotarget-i386: check/enforce: Eliminate check_feat field
Eduardo Habkost [Fri, 4 Jan 2013 22:01:10 +0000 (20:01 -0200)]
target-i386: check/enforce: Eliminate check_feat field

Now that all entries have check_feat=~0 in
kvm_check_features_against_host(), we can eliminate check_feat entirely
and make the code check all bits.

This patch shouldn't introduce any behavior change, as check_feat is set
to ~0 on all entries.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: check/enforce: Check SVM flag support as well
Eduardo Habkost [Fri, 4 Jan 2013 22:01:09 +0000 (20:01 -0200)]
target-i386: check/enforce: Check SVM flag support as well

When nested SVM is supported, the kernel returns the SVM flag on
GET_SUPPORTED_CPUID[1], so we can check the SVM flag safely in
kvm_check_features_against_host().

I don't know why the original code ignored the SVM flag. Maybe it was
because kvm_cpu_fill_host() used the CPUID instruction directly instead
of GET_SUPPORTED_CPUID

[1] Older kernels (before v2.6.37) returned the SVM flag even if nested
    SVM was _not_ supported. So the only cases where this patch should
    change behavior is when SVM is being requested by the user or the
    CPU model, but not supported by the host. And on these cases we
    really want QEMU to abort if the "enforce" option is set.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: check/enforce: Check all CPUID.80000001H.EDX bits
Eduardo Habkost [Fri, 4 Jan 2013 22:01:08 +0000 (20:01 -0200)]
target-i386: check/enforce: Check all CPUID.80000001H.EDX bits

I have no idea why PPRO_FEATURES was being ignored on the check of the
CPUID.80000001H.EDX bits. I believe it was a mistake, and it was
supposed to be ~(PPRO_FEATURES & CPUID_EXT2_AMD_ALIASES) or just
~CPUID_EXT2_AMD_ALIASES, because some time ago kvm_cpu_fill_host() used
the CPUID instruction directly (instead of
kvm_arch_get_supported_cpuid()).

But now kvm_cpu_fill_host() uses kvm_arch_get_supported_cpuid(), and
kvm_arch_get_supported_cpuid() returns all supported bits for
CPUID.80000001H.EDX, even the AMD aliases (that are explicitly copied
from CPUID.01H.EDX), so we can make the code check/enforce all the
CPUID.80000001H.EDX bits.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: check/enforce: Do not ignore "hypervisor" flag
Eduardo Habkost [Fri, 4 Jan 2013 22:01:07 +0000 (20:01 -0200)]
target-i386: check/enforce: Do not ignore "hypervisor" flag

We don't need any hack to ignore CPUID_EXT_HYPERVISOR anymore, because
kvm_arch_get_supported_cpuid() now sets CPUID_EXT_HYPERVISOR properly.
So, this shouldn't introduce any behavior change, but it makes the code
simpler.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: check/enforce: Fix CPUID leaf numbers on error messages
Eduardo Habkost [Fri, 4 Jan 2013 22:01:06 +0000 (20:01 -0200)]
target-i386: check/enforce: Fix CPUID leaf numbers on error messages

The -cpu check/enforce warnings are printing incorrect information about the
missing flags. There are no feature flags on CPUID leaves 0 and 0x80000000, but
there were references to 0 and 0x80000000 in the table at
kvm_check_features_against_host().

This changes the model_features_t struct to contain the register number as
well, so the error messages print the correct CPUID leaf+register information,
instead of wrong CPUID leaf numbers.

This also changes the format of the error messages, so they follow the
"CPUID.<leaf>.<register>.<name> [bit <offset>]" convention used in Intel
documentation. Example output:

    $ qemu-system-x86_64 -machine pc-1.0,accel=kvm -cpu Opteron_G4,+ia64,enforce
    warning: host doesn't support requested feature: CPUID.01H:EDX.ia64 [bit 30]
    warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]
    warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
    warning: host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
    warning: host doesn't support requested feature: CPUID.80000001H:ECX.sse4a [bit 6]
    warning: host doesn't support requested feature: CPUID.80000001H:ECX.misalignsse [bit 7]
    warning: host doesn't support requested feature: CPUID.80000001H:ECX.3dnowprefetch [bit 8]
    warning: host doesn't support requested feature: CPUID.80000001H:ECX.xop [bit 11]
    warning: host doesn't support requested feature: CPUID.80000001H:ECX.fma4 [bit 16]
    Unable to find x86 CPU definition
    $

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: kvm: Enable all supported KVM features for -cpu host
Eduardo Habkost [Fri, 4 Jan 2013 22:01:05 +0000 (20:01 -0200)]
target-i386: kvm: Enable all supported KVM features for -cpu host

When using -cpu host, we don't need to use the kvm_default_features
variable, as the user is explicitly asking QEMU to enable all feature
supported by the host.

This changes the kvm_cpu_fill_host() code to use GET_SUPPORTED_CPUID to
initialize the kvm_features field, so we get all host KVM features
enabled.

This will also allow us to properly check/enforce KVM features inside
kvm_check_features_against_host() later. For example, we will be able to
make this:

  $ qemu-system-x86_64 -cpu ...,+kvm_pv_eoi,enforce

refuse to start if kvm_pv_eoi is not supported by the host (after we fix
kvm_check_features_against_host() to check KVM flags as well).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features
Eduardo Habkost [Fri, 4 Jan 2013 22:01:04 +0000 (20:01 -0200)]
target-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features

The existing -cpu host code simply sets every bit inside svm_features
(initializing it to -1), and that makes it impossible to make the
enforce/check options work properly when the user asks for SVM features
explicitly in the command-line.

So, instead of initializing svm_features to -1, use GET_SUPPORTED_CPUID
to fill only the bits that are supported by the host (just like we do
for all other CPUID feature words inside kvm_cpu_fill_host()).

This will keep the existing behavior (as filter_features_for_kvm()
already uses GET_SUPPORTED_CPUID to filter svm_features), but will allow
us to properly check for KVM features inside
kvm_check_features_against_host() later.

For example, we will be able to make this:

  $ qemu-system-x86_64 -cpu ...,+pfthreshold,enforce

refuse to start if the SVM "pfthreshold" feature is not supported by the
host (after we fix kvm_check_features_against_host() to check SVM flags
as well).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Change parent type to Device
Eduardo Habkost [Wed, 5 Dec 2012 16:49:13 +0000 (14:49 -0200)]
cpu: Change parent type to Device

This finally makes the CPU class a subclass of the Device class,
allowing us to start using DeviceState properties on CPU subclasses.

It has no_user=1, as creating CPUs using -device doesn't work yet.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqdev: Don't assume existence of parent bus on unparenting
Andreas Färber [Fri, 4 Jan 2013 17:13:00 +0000 (18:13 +0100)]
qdev: Don't assume existence of parent bus on unparenting

Commit 667d22d1ae59da46b4c1fbd094ca61145f19b8c3 (qdev: move bus removal
to object_unparent) made the assumption that at unparenting time
parent_bus is not NULL. This assumption is unjustified since
object_unparent() may well be called directly after object_initialize(),
without any qdev_set_parent_bus().

This did not cause any issues yet because qdev_[try_]create() does call
qdev_set_parent_bus(), falling back to SysBus if unsupplied.

While at it, ensure that this new function uses the device_ prefix and
make the name more neutral in light of this semantic change.

Reported-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Tested-by: Igor Mammedov <imammedo@redhat.com>
11 years agoqdev: Include qdev code into *-user, too
Eduardo Habkost [Wed, 5 Dec 2012 16:49:12 +0000 (14:49 -0200)]
qdev: Include qdev code into *-user, too

The code depends on some functions from qemu-option.o, so add
qemu-option.o to universal-obj-y to make sure it's included.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agolibqemustub: sysbus_get_default() stub
Eduardo Habkost [Wed, 5 Dec 2012 16:49:09 +0000 (14:49 -0200)]
libqemustub: sysbus_get_default() stub

The stub will be used on cases where sysbus.c is not compiled in (e.g.
*-user).

Note that code that uses NULL as the bus with qdev{_try,}_create()
implicitly uses sysbus_get_default() as the bus, and will still require
sysbus.c to be compiled in.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agolibqemustub: vmstate register/unregister stubs
Eduardo Habkost [Wed, 5 Dec 2012 16:49:08 +0000 (14:49 -0200)]
libqemustub: vmstate register/unregister stubs

Add vmstate stub functions, so that qdev.o can be used without savevm.o
when vmstate support is not necessary (i.e. by *-user).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agolibqemustub: Add qemu_[un]register_reset() stubs
Eduardo Habkost [Wed, 5 Dec 2012 16:49:07 +0000 (14:49 -0200)]
libqemustub: Add qemu_[un]register_reset() stubs

This will be useful for code that don't call qemu_devices_reset() (e.g.
*-user). If qemu_devices_reset() is never called, it means we don't need
to keep track of the reset handler list.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoMerge remote-tracking branch 'kraxel/usb.75' into staging
Anthony Liguori [Tue, 8 Jan 2013 16:36:20 +0000 (10:36 -0600)]
Merge remote-tracking branch 'kraxel/usb.75' into staging

* kraxel/usb.75: (32 commits)
  uhci: stop using portio lists
  usbredir: Add support for buffered bulk input (v2)
  exynos4210: Add EHCI support
  usb/ehci: Add SysBus EHCI device for Exynos4210
  usb/ehci: Move capsbase and opregbase into SysBus EHCI class
  usb/ehci: Clean up SysBus and PCI EHCI split
  xhci: call set-address with dummy usbpacket
  usb-redir: Add debugging to bufpq save / restore
  usbredir: Add usbredir_init_endpoints() helper
  usbredir: Verify we have 32 bits bulk length cap when redirecting to xhci
  usbredir: Add ep_stopped USBDevice method
  usbredir: Add USBEP2I and I2USBEP helper macros
  usbredir: Add an usbredir_stop_ep helper function
  usb: Add an usb_device_ep_stopped USBDevice method
  usb: Fix usb_ep_find_packet_by_id
  hid: Change idle handling to use a timer
  uhci: Maximize how many frames we catch up when behind
  uhci: Limit amount of frames processed in one go
  uhci: Add a QH_VALID define
  uhci: Fix pending interrupts getting lost on migration
  ...

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'stefanha/net' into staging
Anthony Liguori [Tue, 8 Jan 2013 16:36:13 +0000 (10:36 -0600)]
Merge remote-tracking branch 'stefanha/net' into staging

* stefanha/net:
  rtl8139: preserve link state across device reset
  e1000: no need auto-negotiation if link was down
  net: clean up network at qemu process termination
  e1000: Discard oversized packets based on SBP|LPE

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agotarget-mips: Fix helper and tests for dot/cross-dot product instructions
Petar Jovanovic [Wed, 2 Jan 2013 04:08:48 +0000 (05:08 +0100)]
target-mips: Fix helper and tests for dot/cross-dot product instructions

Helper function for dpa_w_ph, dpax_w_ph, dps_w_ph and dpsx_w_ph incorrectly
defines halfword vector elements as unsigned values. This results in wrong
output which is not triggered in the tests as they also follow this logic.

Signed-off-by: Petar Jovanovic <petarj@mips.com>
Reviewed-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Replace macros by inline functions
Stefan Weil [Tue, 1 Jan 2013 18:44:31 +0000 (19:44 +0100)]
target-mips: Replace macros by inline functions

The macros RESTORE_ROUNDING_MODE and RESTORE_FLUSH_MODE silently used
variable env from their callers. Using inline functions with env passed
as a function argument is more transparent.

This modification was proposed by Peter Maydell.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Reviewed-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-mips: Allow DSP access to be disabled once enabled.
Eric Johnson [Tue, 8 Jan 2013 06:26:44 +0000 (22:26 -0800)]
target-mips: Allow DSP access to be disabled once enabled.

Clear the DSP hflags at the start of compute_hflags.  Otherwise access
is not properly disabled once enabled.

Signed-off-by: Eric Johnson <ericj@mips.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agolinux-user: fix mips 32-on-64 prealloc case
Alexander Graf [Thu, 3 Jan 2013 13:17:18 +0000 (14:17 +0100)]
linux-user: fix mips 32-on-64 prealloc case

MIPS only supports 31 bits of virtual address space for user space, so let's
make sure we stay within that limit with our preallocated memory block.

This fixes the MIPS user space targets when executed without command line
option.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agouhci: stop using portio lists
Gerd Hoffmann [Thu, 3 Jan 2013 11:29:41 +0000 (12:29 +0100)]
uhci: stop using portio lists

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousbredir: Add support for buffered bulk input (v2)
Hans de Goede [Wed, 19 Dec 2012 14:08:33 +0000 (15:08 +0100)]
usbredir: Add support for buffered bulk input (v2)

Buffered bulk mode is intended for bulk *input* endpoints, where the data is
of a streaming nature (not part of a command-response protocol). These
endpoints' input buffer may overflow if data is not read quickly enough.
So in buffered bulk mode the usb-host takes care of the submitting and
re-submitting of bulk transfers.

Buffered bulk mode is necessary for reliable operation with the bulk in
endpoints of usb to serial convertors. Unfortunatelty buffered bulk input
mode will only work with certain devices, therefor this patch also adds a
usb-id table to enable it for devices which need it, while leaving the
bulk ep handling for other devices unmodified.

Note that the bumping of the required usbredir from 0.5.3 to 0.6 does
not mean that we will now need a newer usbredir release then qemu-1.3,
.pc files reporting 0.5.3 have only ever existed in usbredir builds directly
from git, so qemu-1.3 needs the 0.6 release too.

Changes in v2:
-Split of quirk handling into quirks.c

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoexynos4210: Add EHCI support
Liming Wang [Sun, 16 Dec 2012 03:49:46 +0000 (04:49 +0100)]
exynos4210: Add EHCI support

Add EHCI USB host controller to exynos4210.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Reviewed-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb/ehci: Add SysBus EHCI device for Exynos4210
Andreas Färber [Sun, 16 Dec 2012 03:49:45 +0000 (04:49 +0100)]
usb/ehci: Add SysBus EHCI device for Exynos4210

It uses a different capsbase and opregbase than the Xilinx device.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Cc: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb/ehci: Move capsbase and opregbase into SysBus EHCI class
Andreas Färber [Sun, 16 Dec 2012 03:49:44 +0000 (04:49 +0100)]
usb/ehci: Move capsbase and opregbase into SysBus EHCI class

This allows specific derived models to use different values.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb/ehci: Clean up SysBus and PCI EHCI split
Andreas Färber [Sun, 16 Dec 2012 03:49:43 +0000 (04:49 +0100)]
usb/ehci: Clean up SysBus and PCI EHCI split

SysBus EHCI was introduced in a hurry before 1.3 Soft Freeze.
To use QOM casts in place of DO_UPCAST() / FROM_SYSBUS(), we need an
identifying type. Introduce generic abstract base types for PCI and
SysBus EHCI to allow multiple types to access the shared fields.

While at it, move the state structs being amended with macros to the
header file so that they can be embedded.

The VMSTATE_PCI_DEVICE() macro does not play nice with the QOM
parent_obj naming convention, so defer that cleanup.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoxhci: call set-address with dummy usbpacket
Gerd Hoffmann [Fri, 14 Dec 2012 12:10:39 +0000 (13:10 +0100)]
xhci: call set-address with dummy usbpacket

Due to the way devices are addressed with xhci (done by hardware, not
the guest os) there is no packet when invoking the set-address control
request.  Create a dummy packet in that case to avoid null pointer
dereferences.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb-redir: Add debugging to bufpq save / restore
Hans de Goede [Fri, 14 Dec 2012 13:35:46 +0000 (14:35 +0100)]
usb-redir: Add debugging to bufpq save / restore

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousbredir: Add usbredir_init_endpoints() helper
Hans de Goede [Fri, 14 Dec 2012 13:35:45 +0000 (14:35 +0100)]
usbredir: Add usbredir_init_endpoints() helper

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousbredir: Verify we have 32 bits bulk length cap when redirecting to xhci
Hans de Goede [Fri, 14 Dec 2012 13:35:44 +0000 (14:35 +0100)]
usbredir: Verify we have 32 bits bulk length cap when redirecting to xhci

The xhci-hcd may submit bulk transfers > 65535 bytes even when not using
bulk-in pipeling, so usbredir can only be used in combination with an xhci
hcd if the client has the 32 bits bulk length capability.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousbredir: Add ep_stopped USBDevice method
Hans de Goede [Fri, 14 Dec 2012 13:35:43 +0000 (14:35 +0100)]
usbredir: Add ep_stopped USBDevice method

To ensure that interrupt receiving is properly stopped when the guest is
no longer interested in an interrupt endpoint.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousbredir: Add USBEP2I and I2USBEP helper macros
Hans de Goede [Fri, 14 Dec 2012 13:35:42 +0000 (14:35 +0100)]
usbredir: Add USBEP2I and I2USBEP helper macros

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousbredir: Add an usbredir_stop_ep helper function
Hans de Goede [Fri, 14 Dec 2012 13:35:41 +0000 (14:35 +0100)]
usbredir: Add an usbredir_stop_ep helper function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Add an usb_device_ep_stopped USBDevice method
Hans de Goede [Fri, 14 Dec 2012 13:35:40 +0000 (14:35 +0100)]
usb: Add an usb_device_ep_stopped USBDevice method

Some usb devices (host or network redirection) can benefit from knowing when
the guest stops using an endpoint. Redirection may involve submitting packets
independently from the guest (in combination with a fifo buffer between the
redirection code and the guest), to ensure that buffers of the real usb device
are timely emptied. This is done for example for isoc traffic and for interrupt
input endpoints. But when the (re)submission of packets is done by the device
code, then how does it know when to stop this?

For isoc endpoints this is handled by detecting a set interface (change alt
setting) command, which works well for isoc endpoints. But for interrupt
endpoints currently the redirection code never stops receiving data from
the device, which is less then ideal.

However the controller emulation is aware when a guest looses interest, as
then the qh for the endpoint gets unlinked (ehci, ohci, uhci) or the endpoint
is explicitly stopped (xhci). This patch adds a new ep_stopped USBDevice
method and modifies the hcd code to call this on queue unlink / ep stop.

This makes it possible for the redirection code to properly stop receiving
interrupt input (*) data when the guest no longer has interest in it.

*) And in the future also buffered bulk input.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb: Fix usb_ep_find_packet_by_id
Hans de Goede [Fri, 14 Dec 2012 13:35:39 +0000 (14:35 +0100)]
usb: Fix usb_ep_find_packet_by_id

usb_ep_find_packet_by_id mistakenly only checks the first packet and if that
is not a match, keeps trying the first packet! This patch fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agohid: Change idle handling to use a timer
Hans de Goede [Fri, 14 Dec 2012 13:35:38 +0000 (14:35 +0100)]
hid: Change idle handling to use a timer

This leads to cleaner code in usb-hid, and removes up to a 1000 calls / sec to
qemu_get_clock_ns(vm_clock) if idle-time is set to its default value of 0.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Maximize how many frames we catch up when behind
Hans de Goede [Fri, 14 Dec 2012 13:35:37 +0000 (14:35 +0100)]
uhci: Maximize how many frames we catch up when behind

If somehow we've gotten behind a lot, simply skip ahead, like the ehci code
does.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Limit amount of frames processed in one go
Hans de Goede [Fri, 14 Dec 2012 13:35:36 +0000 (14:35 +0100)]
uhci: Limit amount of frames processed in one go

Before this patch uhci would process an unlimited amount of frames when
behind on schedule, by setting the timer to a time already past, causing the
timer subsys to immediately recall the frame_timer function gain.

This would cause invalid cancellations of bulk queues when the catching up
processed more then 32 frames at a moment when the bulk qh was temporarily
unlinked (which the Linux uhci driver does).

This patch fixes this by processing maximum 16 frames in one go, and always
setting the timer one ms later, making the code behave more like the ehci
code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Add a QH_VALID define
Hans de Goede [Fri, 14 Dec 2012 13:35:35 +0000 (14:35 +0100)]
uhci: Add a QH_VALID define

Rather then using the magic 32 value in various places.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Fix pending interrupts getting lost on migration
Hans de Goede [Fri, 14 Dec 2012 13:35:34 +0000 (14:35 +0100)]
uhci: Fix pending interrupts getting lost on migration

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: Fix 1 ms delay in interrupt reporting to the guest
Hans de Goede [Fri, 14 Dec 2012 13:35:33 +0000 (14:35 +0100)]
uhci: Fix 1 ms delay in interrupt reporting to the guest

Re-arrange how we process frames / increase frnum / report pending interrupts,
to avoid a 1 ms delay in interrupt reporting to the guest. This increases
the packet throughput for cases where the guest submits a single packet,
then waits for its completion then re-submits from 500 pkts / sec to
1000 pkts / sec. This impacts for example the use of redirected / virtual
usb to serial convertors.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Don't call commit_irq after raising PCD
Hans de Goede [Fri, 14 Dec 2012 13:35:32 +0000 (14:35 +0100)]
ehci: Don't call commit_irq after raising PCD

ehci_raise_irq(s, USBSTS_PCD), gets applied immediately so there is no need
to call commit_irq after it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Further speedup rescanning if async schedule after raising an interrupt
Hans de Goede [Fri, 14 Dec 2012 13:35:31 +0000 (14:35 +0100)]
ehci: Further speedup rescanning if async schedule after raising an interrupt

I tried lowering the time between raising an interrupt and rescanning the
async schedule to see if the guest has queued a new transfer before, but
that did not have any positive effect. I now believe the cause for this is
that lowering this time made it more likely to hit the 1 ms interrupt
threshold penalty for the next packet, as described in my
"ehci: Use uframe precision for interrupt threshold checking" commit.

Now that we do interrupt threshold handling with uframe precision, futher
lowering this time from .5 to .25 ms gives an extra 15% improvement in speed
(MB/s) reading from a simple USB-2.0 thumb-drive.

While at it also properly set the int_req_by_async flag for short packet
completions.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Use uframe precision for interrupt threshold checking (v2)
Hans de Goede [Tue, 18 Dec 2012 13:17:02 +0000 (14:17 +0100)]
ehci: Use uframe precision for interrupt threshold checking (v2)

Before this patch, the following could happen:
1) Transfer completes, raises interrupt
2) .5 ms later we check if the guest has queued up any new transfers
3) We find and execute a new transfer
4) .2 ms later the new transfer completes
5) We re-run our frame_timer to write back the completion, but less then
   1 ms has passed since our last run, so frindex is not changed, so the
   interrupt threshold code delays the interrupt
6) 1 ms from the re-run our frame-timer runs again and finally delivers
   the interrupt

This leads to unnecessary large delays of interrupts, this code fixes this
by changing frindex to uframe precision and using that for interrupt threshold
control, making the interrupt fire at step 5 for guest which have low interrupt
threshold settings (like Linux).

Note that the guest still sees the frindex move in steps of 8 for migration
compatibility.

This boosts Linux read speed of a simple cheap USB thumb drive by 6 %.

Changes in v2:
-Make the guest see frindex move in steps of 8 by modifying ehci_opreg_read,
 rather then using a shadow variable

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Verify a queue's ep direction does not change
Hans de Goede [Fri, 14 Dec 2012 13:35:29 +0000 (14:35 +0100)]
ehci: Verify a queue's ep direction does not change

ehci_fill_queue assumes that there is a one on one relationship between an ep
and a qh, this patch adds a check to ensure this.

Note I don't expect this to ever trigger, this is just something I noticed
the guest might do while working on other stuff. The only way this check can
trigger is if a guest mixes in and out qtd-s in a single qh for a non
control ep.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Add an ehci_get_pid helper function
Hans de Goede [Fri, 14 Dec 2012 13:35:28 +0000 (14:35 +0100)]
ehci: Add an ehci_get_pid helper function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Verify qtd for async completed packets
Hans de Goede [Fri, 14 Dec 2012 13:35:27 +0000 (14:35 +0100)]
ehci: Verify qtd for async completed packets

Remove the short-circuiting of fetchqtd in fetchqh, so that the
qtd gets properly verified before completing the transaction.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: writeback_async_complete_packet: verify qh and qtd
Hans de Goede [Fri, 14 Dec 2012 13:35:26 +0000 (14:35 +0100)]
ehci: writeback_async_complete_packet: verify qh and qtd

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Move get / put_dwords upwards
Hans de Goede [Fri, 14 Dec 2012 13:35:25 +0000 (14:35 +0100)]
ehci: Move get / put_dwords upwards

No other changes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Verify guest does not change the token of inflight qtd-s
Hans de Goede [Fri, 14 Dec 2012 13:35:24 +0000 (14:35 +0100)]
ehci: Verify guest does not change the token of inflight qtd-s

This is not allowed, except for clearing active on cancellation, so don't
warn when the new token does not have its active bit set.

This unifies the cancellation path for modified qtd-s, and prepares
ehci_verify_qtd to be used ad an extra check inside
ehci_writeback_async_complete_packet().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Add ehci_verify_qh and ehci_verify_qtd helper functions
Hans de Goede [Fri, 14 Dec 2012 13:35:23 +0000 (14:35 +0100)]
ehci: Add ehci_verify_qh and ehci_verify_qtd helper functions

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Add a ehci_writeback_async_complete_packet helper function
Hans de Goede [Fri, 14 Dec 2012 13:35:22 +0000 (14:35 +0100)]
ehci: Add a ehci_writeback_async_complete_packet helper function

Also drop the warning printf, which was there mainly because this was an
untested code path (as the previous bug fixes to it show), but that no
longer is the case now :)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agortl8139: preserve link state across device reset
Amos Kong [Fri, 28 Dec 2012 09:29:11 +0000 (17:29 +0800)]
rtl8139: preserve link state across device reset

A device reset does not affect the link state, only set_link does.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoe1000: no need auto-negotiation if link was down
Amos Kong [Fri, 28 Dec 2012 09:29:10 +0000 (17:29 +0800)]
e1000: no need auto-negotiation if link was down

Commit b9d03e352cb6b31a66545763f6a1e20c9abf0c2c added link
auto-negotiation emulation, it would always set link up by
callback function. Problem exists if original link status
was down, link status should not be changed in auto-negotiation.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agonet: clean up network at qemu process termination
Amos Kong [Tue, 11 Dec 2012 14:20:15 +0000 (22:20 +0800)]
net: clean up network at qemu process termination

We don't clean up network if fails to parse "-device" parameters without
calling net_cleanup(). I touch a problem, the tap device which is
created by qemu-ifup script could not be removed by qemu-ifdown script.
Some similar problems also exist in vl.c

In this patch, if network initialization successes, a cleanup function
will be registered to be called at qemu process termination.

Signed-off-by: Amos Kong <akong@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoe1000: Discard oversized packets based on SBP|LPE
Michael Contreras [Wed, 5 Dec 2012 18:31:30 +0000 (13:31 -0500)]
e1000: Discard oversized packets based on SBP|LPE

Discard packets longer than 16384 when !SBP to match the hardware behavior.

Signed-off-by: Michael Contreras <michael@inetric.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoRevert "virtio-pci: replace byte swap hack"
Blue Swirl [Sun, 6 Jan 2013 18:30:17 +0000 (18:30 +0000)]
Revert "virtio-pci: replace byte swap hack"

This reverts commit 9807caccd605d09a72495637959568d690e10175.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agovirtio-pci: replace byte swap hack
Blue Swirl [Sat, 14 Apr 2012 20:39:14 +0000 (20:39 +0000)]
virtio-pci: replace byte swap hack

Remove byte swaps by declaring the config space
as native endian.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agotests: add gcov support
Blue Swirl [Tue, 1 May 2012 18:45:39 +0000 (18:45 +0000)]
tests: add gcov support

Add support for compiling for GCOV test coverage, enabled
with '--enable-gcov' during configure.

Test coverage will be reported after each test.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agohw/i386: Fix broken build for non POSIX hosts
Stefan Weil [Sat, 5 Jan 2013 08:33:43 +0000 (09:33 +0100)]
hw/i386: Fix broken build for non POSIX hosts

pc-testdev.c cannot be compiled with MinGW (and other non POSIX hosts):

  CC    i386-softmmu/hw/i386/../pc-testdev.o
qemu/hw/i386/../pc-testdev.c:38:22: warning: sys/mman.h: file not found
qemu/hw/i386/../pc-testdev.c: In function ‘test_flush_page’:
qemu/hw/i386/../pc-testdev.c:103: warning: implicit declaration of function ‘mprotect’
...

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agosoftfloat: Implement uint64_to_float128
Richard Henderson [Mon, 31 Dec 2012 18:09:04 +0000 (10:09 -0800)]
softfloat: Implement uint64_to_float128

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agosoftfloat: Fix uint64_to_float64
Richard Henderson [Mon, 31 Dec 2012 18:09:03 +0000 (10:09 -0800)]
softfloat: Fix uint64_to_float64

The interface to normalizeRoundAndPackFloat64 requires that the
high bit be clear.  Perform one shift-right-and-jam if needed.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Fri, 4 Jan 2013 19:25:20 +0000 (13:25 -0600)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

* stefanha/trivial-patches:
  spice: drop incorrect vm_change_state_handler() opaque
  linux-user/syscall.c: remove forward declarations
  hw/mcf5206: Reduce size of lookup table
  Remove --sparc_cpu option from the configure list
  pseries: Remove unneeded include statement (fixes MinGW builds)
  pc_sysfw: Check for qemu_find_file() failure

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/testdev.1' into staging
Anthony Liguori [Fri, 4 Jan 2013 19:25:07 +0000 (13:25 -0600)]
Merge remote-tracking branch 'kraxel/testdev.1' into staging

* kraxel/testdev.1:
  pc: remove bochs bios debug ports
  hw: Add test device for unittests execution
  add isa-debug-exit device.
  switch debugcon to memory api

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/acpi.2' into staging
Anthony Liguori [Fri, 4 Jan 2013 19:24:49 +0000 (13:24 -0600)]
Merge remote-tracking branch 'kraxel/acpi.2' into staging

* kraxel/acpi.2:
  apci: assign memory regions to ich9 lpc device
  apci: assign memory regions to piix4 acpi device
  acpi: autoload dsdt
  configure: also symlink *.aml files

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agospice: drop incorrect vm_change_state_handler() opaque
Stefan Hajnoczi [Wed, 19 Dec 2012 13:07:16 +0000 (14:07 +0100)]
spice: drop incorrect vm_change_state_handler() opaque

The spice_server pointer is a global variable and
vm_change_state_handler() therefore does not use its opaque parameter.

The vm change state handler is added with a pointer to the spice_server
pointer.  This is useless and we probably would not want 2 levels of
pointers.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Uri Lublin <uril@redhat.com>
11 years agolinux-user/syscall.c: remove forward declarations
John Spencer [Tue, 25 Dec 2012 23:49:49 +0000 (00:49 +0100)]
linux-user/syscall.c: remove forward declarations

instead use the correct headers that define these functions.

Requested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: John Spencer <maillist-qemu@barfooze.de>
Reviewed-by: Amos Kong <kongjianjun@gmail.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agohw/mcf5206: Reduce size of lookup table
Stefan Weil [Sat, 22 Dec 2012 12:59:22 +0000 (13:59 +0100)]
hw/mcf5206: Reduce size of lookup table

This typically reduces the size from 512 bytes to 128 bytes.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoRemove --sparc_cpu option from the configure list
陳韋任 (Wei-Ren Chen) [Thu, 20 Dec 2012 08:41:34 +0000 (16:41 +0800)]
Remove --sparc_cpu option from the configure list

  commit 9b9c37c36439ee0452632253dac7a31897f27f70 always assume sparcv9,
the others are no longer supported. Remove --sparc_cpu option from the
configure list.

Signed-off-by: Chen Wei-Ren <chenwj@iis.sinica.edu.tw>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agopseries: Remove unneeded include statement (fixes MinGW builds)
Stefan Weil [Thu, 20 Dec 2012 06:50:41 +0000 (07:50 +0100)]
pseries: Remove unneeded include statement (fixes MinGW builds)

sys/mman.h is not needed (tested on Linux) and unavailable for MinGW,
so remove it.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agopc_sysfw: Check for qemu_find_file() failure
Markus Armbruster [Wed, 5 Dec 2012 14:28:05 +0000 (15:28 +0100)]
pc_sysfw: Check for qemu_find_file() failure

pc_fw_add_pflash_drv() ignores qemu_find_file() failure, and happily
creates a drive without a medium.

When pc_system_flash_init() asks for its size, bdrv_getlength() fails
with -ENOMEDIUM, which isn't checked either.  It fails relatively
cleanly only because -ENOMEDIUM isn't a multiple of 4096:

    $ qemu-system-x86_64 -S -vnc :0 -bios nonexistant
    qemu: PC system firmware (pflash) must be a multiple of 0x1000
    [Exit 1 ]

Fix by handling the qemu_find_file() failure.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agopc: remove bochs bios debug ports
Gerd Hoffmann [Tue, 11 Dec 2012 08:59:55 +0000 (09:59 +0100)]
pc: remove bochs bios debug ports

Prehistoric leftover, zap it.  We poweroff via acpi these days.

And having a port (0x501,0x502) where any random guest write will make
qemu exit -- with no way to turn it off -- is a bad joke anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agohw: Add test device for unittests execution
Lucas Meneghel Rodrigues [Thu, 13 Dec 2012 14:48:53 +0000 (12:48 -0200)]
hw: Add test device for unittests execution

Add a test device which supports the kvmctl ioports,
so one can run the KVM unittest suite.

Intended Usage:

qemu-system-x86_64 -nographic \
    -device pc-testdev \
    -device isa-debug-exit,iobase=0xf4,iosize=0x04 \
    -kernel /path/to/kvm/unittests/msr.flat

Where msr.flat is one of the KVM unittests, present on a
separate repo,

git://git.kernel.org/pub/scm/virt/kvm/kvm-unit-tests.git

[ kraxel: more memory api + qom fixes ]

CC: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoadd isa-debug-exit device.
Gerd Hoffmann [Wed, 12 Dec 2012 14:54:59 +0000 (15:54 +0100)]
add isa-debug-exit device.

When present it makes qemu exit on any write.
Mapped to port 0x501 by default.

Without this patch Anthony doesn't allow me to
remove the bochs bios debug ports because his
test suite uses this.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoswitch debugcon to memory api
Gerd Hoffmann [Wed, 12 Dec 2012 14:43:35 +0000 (15:43 +0100)]
switch debugcon to memory api

Also some QOM glue while being at it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>