sdk/emulator/qemu.git
10 years agoMerge remote-tracking branch 'remotes/kvm/uq/master' into staging
Peter Maydell [Thu, 15 May 2014 14:38:39 +0000 (15:38 +0100)]
Merge remote-tracking branch 'remotes/kvm/uq/master' into staging

* remotes/kvm/uq/master:
  pc: port 92 reset requires a low->high transition
  cpu: make CPU_INTERRUPT_RESET available on all targets
  apic: do not accept SIPI on the bootstrap processor
  target-i386: preserve FPU and MSR state on INIT
  target-i386: fix set of registers zeroed on reset
  kvm: forward INIT signals coming from the chipset
  kvm: reset state from the CPU's reset method
  target-i386: the x86 CPL is stored in CS.selector - auto update hflags accordingly.
  target-i386: set eflags prior to calling cpu_x86_load_seg_cache() in seg_helper.c
  target-i386: set eflags and cr0 prior to calling cpu_x86_load_seg_cache() in smm_helper.c
  target-i386: set eflags prior to calling svm_load_seg_cache() in svm_helper.c
  pci-assign: limit # of msix vectors
  pci-assign: Fix a bug when map MSI-X table memory failed
  kvm: make one_reg helpers available for everyone
  target-i386: Remove unused data from local array

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tgt-i386-20140512' into staging
Peter Maydell [Thu, 15 May 2014 13:38:53 +0000 (14:38 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tgt-i386-20140512' into staging

Fix BT zero flag for new Intel manuals

# gpg: Signature made Mon 12 May 2014 22:26:01 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/pull-tgt-i386-20140512:
  target-i386: Preserve the Z bit for bt/bts/btr/btc

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoRevert "iotests: Use configured python"
Peter Maydell [Thu, 15 May 2014 11:34:36 +0000 (12:34 +0100)]
Revert "iotests: Use configured python"

This reverts commit f915db07ef9c368ea6db6430256de064fdd1525f.

This commit is broken because it does not account for the
build tree and the source tree being different, and can cause
build failures for out-of-tree builds. Revert it until we can
identify a better solution to the problem.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1400153676-30180-1-git-send-email-peter.maydell@linaro.org
Acked-by: Kevin Wolf <kwolf@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/rth/fix-i386' into staging
Peter Maydell [Tue, 13 May 2014 17:36:18 +0000 (18:36 +0100)]
Merge remote-tracking branch 'remotes/rth/fix-i386' into staging

* remotes/rth/fix-i386:
  exec-all.h: Use stl_le_p instead of stl_p patching x86

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoexec-all.h: Use stl_le_p instead of stl_p patching x86
Richard Henderson [Tue, 13 May 2014 17:16:07 +0000 (10:16 -0700)]
exec-all.h: Use stl_le_p instead of stl_p patching x86

We got the wrong version of stl_p, the one that bswaps as appropriate
for the target.  Since x86 is always little-endian, the "_le_" routine
will resolve to what we want.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20140512' into staging
Peter Maydell [Tue, 13 May 2014 12:16:37 +0000 (13:16 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20140512' into staging

tcg updates for 20140512

# gpg: Signature made Tue 13 May 2014 00:19:56 BST using RSA key ID 4DD0279B
# gpg: Can't check signature: public key not found

* remotes/rth/tags/pull-tcg-20140512: (26 commits)
  tcg: Remove unreachable code in tcg_out_op and op_defs
  tcg: Use tcg_target_available_regs in tcg_reg_alloc_mov
  tcg: Make call address a constant parameter
  tci: Create tcg_out_call
  tcg-mips: Split out tcg_out_call
  tcg-sparc: Create tcg_out_call
  tcg-ppc64: Rename tcg_out_calli to tcg_out_call
  tcg-ppc: Split out tcg_out_call
  tcg-s390: Rename tgen_calli to tcg_out_call
  tcg-i386: Rename tcg_out_calli to tcg_out_call
  tcg: Require TCG_TARGET_INSN_UNIT_SIZE
  tci: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-mips: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-ia64: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-aarch64: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-arm: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-sparc: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-ppc: Define TCG_TARGET_INSN_UNIT_SIZE
  tcg-ppc64: Define TCG_TARGET_INSN_UNIT_SIZE
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agobsd-user: Remove reference to CONFIG_UNAME_RELEASE
Peter Maydell [Fri, 9 May 2014 15:06:41 +0000 (16:06 +0100)]
bsd-user: Remove reference to CONFIG_UNAME_RELEASE

Commit e586822a5 broke the bsd-user build when it removed the
CONFIG_UNAME_RELEASE define but forgot to remove the use of it
in bsd-user. Fix this in the simplest possible way (bsd-user
doesn't make any use at all of the qemu_uname_release variable
except to allow it to be pointlessly set by the user, so this
is all we need to do.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1399648001-20980-1-git-send-email-peter.maydell@linaro.org

10 years agopc: port 92 reset requires a low->high transition
Paolo Bonzini [Tue, 5 Mar 2013 14:04:36 +0000 (15:04 +0100)]
pc: port 92 reset requires a low->high transition

The PIIX datasheet says that "before another INIT pulse can be
generated via [port 92h], [bit 0] must be written back to a
zero.

This bug is masked right now because a full reset will clear the
value of port 92h.  But once we implement soft reset correctly,
the next attempt to enable the A20 line by setting bit 1 (and
leaving the others untouched) will cause another reset.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agocpu: make CPU_INTERRUPT_RESET available on all targets
Paolo Bonzini [Tue, 5 Mar 2013 14:35:17 +0000 (15:35 +0100)]
cpu: make CPU_INTERRUPT_RESET available on all targets

On the x86, some devices need access to the CPU reset pin (INIT#).
Provide a generic service to do this, using one of the internal
cpu_interrupt targets.  Generalize the PPC-specific code for
CPU_INTERRUPT_RESET to other targets.

Since PPC does not support migration across QEMU versions (its
machine types are not versioned yet), I picked the value that
is used on x86, CPU_INTERRUPT_TGT_INT_1.  Consequently, TGT_INT_2
and TGT_INT_3 are shifted down by one while keeping their value.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoapic: do not accept SIPI on the bootstrap processor
Paolo Bonzini [Tue, 19 Mar 2013 13:17:18 +0000 (14:17 +0100)]
apic: do not accept SIPI on the bootstrap processor

SIPI interrupts are ignored on the bootstrap.  Never accept one.

Cc: Andreas Faerber <afaerber@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-i386: preserve FPU and MSR state on INIT
Paolo Bonzini [Tue, 12 Mar 2013 12:16:28 +0000 (13:16 +0100)]
target-i386: preserve FPU and MSR state on INIT

Most MSRs, plus the FPU, MMX, MXCSR, XMM and YMM registers should not
be zeroed on INIT (Table 9-1 in the Intel SDM).  Copy them out of
CPUX86State and back in, instead of special casing env->pat.

The relevant fields are already consecutive except PAT and SMBASE.
However:

- KVM and Hyper-V MSRs should be reset because they include memory
locations written by the hypervisor.  These MSRs are moved together
at the end of the preserved area.

- SVM state can be moved out of the way since it is written by VMRUN.

Cc: Andreas Faerber <afaerber@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-i386: fix set of registers zeroed on reset
Paolo Bonzini [Tue, 29 Apr 2014 11:10:05 +0000 (13:10 +0200)]
target-i386: fix set of registers zeroed on reset

BND0-3, BNDCFGU, BNDCFGS, BNDSTATUS were not zeroed on reset, but they
should be (Intel Instruction Set Extensions Programming Reference
319433-015, pages 9-4 and 9-6).  Same for YMM.

XCR0 should be reset to 1.

TSC and TSC_RESET were zeroed already by the memset, remove the explicit
assignments.

Cc: Andreas Faerber <afaerber@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agokvm: forward INIT signals coming from the chipset
Paolo Bonzini [Fri, 8 Mar 2013 18:21:50 +0000 (19:21 +0100)]
kvm: forward INIT signals coming from the chipset

Reviewed-by: Gleb Natapov <gnatapov@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agokvm: reset state from the CPU's reset method
Paolo Bonzini [Wed, 20 Mar 2013 12:11:56 +0000 (13:11 +0100)]
kvm: reset state from the CPU's reset method

Now that we have a CPU object with a reset method, it is better to
keep the KVM reset close to the CPU reset.  Using qemu_register_reset
as we do now keeps them far apart.

With this patch, PPC no longer calls the kvm_arch_ function, so
it can get removed there.  Other arches call it from their CPU
reset handler, and the function gets an ARMCPU/X86CPU/S390CPU.

Note that ARM- and s390-specific functions are called kvm_arm_*
and kvm_s390_*, while x86-specific functions are called kvm_arch_*.
That follows the convention used by the different architectures.
Changing that is the topic of a separate patch.

Reviewed-by: Gleb Natapov <gnatapov@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-i386: the x86 CPL is stored in CS.selector - auto update hflags accordingly.
Kevin O'Connor [Tue, 29 Apr 2014 20:38:59 +0000 (16:38 -0400)]
target-i386: the x86 CPL is stored in CS.selector - auto update hflags accordingly.

Instead of manually calling cpu_x86_set_cpl() when the CPL changes,
check for CPL changes on calls to cpu_x86_load_seg_cache(R_CS).  Every
location that called cpu_x86_set_cpl() also called
cpu_x86_load_seg_cache(R_CS), so cpu_x86_set_cpl() is no longer
required.

This fixes the SMM handler code as it was not setting/restoring the
CPL level manually.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-i386: set eflags prior to calling cpu_x86_load_seg_cache() in seg_helper.c
Kevin O'Connor [Tue, 29 Apr 2014 20:38:31 +0000 (16:38 -0400)]
target-i386: set eflags prior to calling cpu_x86_load_seg_cache() in seg_helper.c

The cpu_x86_load_seg_cache() function inspects eflags, so make sure
all changes to eflags are done prior to loading the segment caches.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-i386: set eflags and cr0 prior to calling cpu_x86_load_seg_cache() in smm_helper.c
Kevin O'Connor [Tue, 29 Apr 2014 20:38:10 +0000 (16:38 -0400)]
target-i386: set eflags and cr0 prior to calling cpu_x86_load_seg_cache() in smm_helper.c

The cpu_x86_load_seg_cache() function inspects cr0 and eflags, so make
sure all changes to eflags and cr0 are done prior to loading the
segment caches.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-i386: set eflags prior to calling svm_load_seg_cache() in svm_helper.c
Kevin O'Connor [Tue, 29 Apr 2014 20:37:50 +0000 (16:37 -0400)]
target-i386: set eflags prior to calling svm_load_seg_cache() in svm_helper.c

The svm_load_seg_cache() function calls cpu_x86_load_seg_cache() which
inspects env->eflags.  So, make sure all changes to eflags are done
prior to loading the segment cache.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agopci-assign: limit # of msix vectors
Michael S. Tsirkin [Mon, 28 Apr 2014 14:02:21 +0000 (17:02 +0300)]
pci-assign: limit # of msix vectors

KVM only supports MSIX table size up to 256 vectors,
but some assigned devices support more vectors,
at the moment attempts to assign them fail with EINVAL.

Tweak the MSIX capability exposed to guest to limit table size
to a supported value.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Gonglei <arei.gonglei@huawei.com>
Cc: qemu-stable@nongnu.org
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agopci-assign: Fix a bug when map MSI-X table memory failed
Gonglei [Thu, 3 Apr 2014 05:18:23 +0000 (13:18 +0800)]
pci-assign: Fix a bug when map MSI-X table memory failed

When mmapping memory for the MSI-X table failsthe dev->msix_table is
not set to NULL and assigned_dev_unregister_msix_mmio() will cause
a segfault when trying to munmap it.

Signed-off-by: Gonglei Arei <arei.gonglei@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
10 years agokvm: make one_reg helpers available for everyone
Cornelia Huck [Fri, 9 May 2014 08:06:46 +0000 (10:06 +0200)]
kvm: make one_reg helpers available for everyone

s390x introduced helper functions for getting/setting one_regs with
commit 860643bc. However, nothing about these is s390-specific.

Alexey Kardashevskiy had already posted a general version, so let's
merge the two patches and massage the code a bit.

CC: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agotarget-i386: Remove unused data from local array
Stefan Weil [Thu, 20 Mar 2014 21:30:32 +0000 (22:30 +0100)]
target-i386: Remove unused data from local array

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoMerge remote-tracking branch 'remotes/bonzini/configure' into staging
Peter Maydell [Tue, 13 May 2014 10:30:07 +0000 (11:30 +0100)]
Merge remote-tracking branch 'remotes/bonzini/configure' into staging

* remotes/bonzini/configure:
  libcacard: remove libcacard-specific CFLAGS and LIBS from global vars
  build: simplify and fix fix-obj-vars
  build: convert some obj-specific CFLAGS to use new foo.o-cflags syntax
  build: add support for per-object -cflags and -libs to all rules
  Makefile: use $(INSTALL_LIB) for modules not $(INSTALL_PROG)
  Makefile.target: use $(INSTALL_PROG) for installing, not $(INSTALL)
  Makefile: strip tools and modules too
  build: simplify Makefile.target around unnest-vars invocations
  build: simplify Makefile.target a bit, use just one rule for softmmu
  build: Fix per-object variables for Makefile.target

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Tue, 13 May 2014 09:35:46 +0000 (10:35 +0100)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

Block pull request

# gpg: Signature made Fri 09 May 2014 19:57:53 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  glib: fix g_poll early timeout on windows
  block: qemu-iotests - test for live migration
  block: qemu-iotests - update 085 to use common.qemu
  block: qemu-iotests - add common.qemu, for bash-controlled qemu tests
  block/raw-posix: Try both FIEMAP and SEEK_HOLE
  gluster: Correctly propagate errors when volume isn't accessible
  vl.c: remove init_clocks call from main
  block: Fix open flags with BDRV_O_SNAPSHOT
  qemu-iotests: Test converting to streamOptimized from small cluster size
  vmdk: Implement .bdrv_get_info()
  vmdk: Implement .bdrv_write_compressed
  qemu-img: Convert by cluster size if target is compressed
  block/iscsi: bump year in copyright notice
  block/nfs: Check for NULL server part
  qemu-img: sort block formats in help message
  iotests: Use configured python
  qcow2: Fix alloc_clusters_noref() overflow detection

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agomicroblaze: boot: Don't hack the elf entry point
Peter Crosthwaite [Tue, 29 Apr 2014 00:12:58 +0000 (17:12 -0700)]
microblaze: boot: Don't hack the elf entry point

There was some modulo logic to ensure that Microblaze always booted into
physical RAM regardless of the elf entry. Removed it, as QEMU should fail
gracefully when given a bad elf, rather than attempt to run it.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
10 years agoxilinx_timer: Fix writes into TCSR register
Guenter Roeck [Fri, 25 Apr 2014 15:39:48 +0000 (08:39 -0700)]
xilinx_timer: Fix writes into TCSR register

The TCSR register has only 11 valid bits. This is now used by the
linux kernel to auto-detect endianness, and causes Linux 3.15-rc1
and later to hang when run under qemu-microblaze. Mask valid bits
before writing the register to solve the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agoxilinx_intc: Fix writes into MER register
Guenter Roeck [Fri, 25 Apr 2014 15:39:47 +0000 (08:39 -0700)]
xilinx_intc: Fix writes into MER register

The MER register only has two valid bits. This is now used by
the linux kernel to auto-detect endianness, and causes Linux 3.15-rc1
and later to hang when run under qemu-microblaze. Mask valid bits before
writing the register to solve the problem.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
[Edgar: Untabified]
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10 years agomicroblaze: Respect the reset vector
Edgar E. Iglesias [Tue, 28 May 2013 12:56:20 +0000 (14:56 +0200)]
microblaze: Respect the reset vector

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
10 years agomicroblaze: Support loading of u-boot initrd images
Edgar E. Iglesias [Fri, 3 May 2013 13:19:45 +0000 (15:19 +0200)]
microblaze: Support loading of u-boot initrd images

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
10 years agotarget-i386: Preserve the Z bit for bt/bts/btr/btc
Richard Henderson [Wed, 9 Apr 2014 20:51:41 +0000 (13:51 -0700)]
target-i386: Preserve the Z bit for bt/bts/btr/btc

Older Intel manuals (pre-2010) and current AMD manuals describe Z as
undefined, but newer Intel manuals describe Z as unchanged.

Cc: qemu-stable@nongnu.org
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Remove unreachable code in tcg_out_op and op_defs
Richard Henderson [Fri, 25 Apr 2014 19:19:33 +0000 (15:19 -0400)]
tcg: Remove unreachable code in tcg_out_op and op_defs

The INDEX_op_call case has just been obsoleted; the mov and movi
cases have not been reachable for years.  Attempt to document this
both in each tcg_out_op switch, and via TCG_OPF_NOT_PRESENT.

Because of the TCG_OPF_NOT_PRESENT change, this must be done for
all targets in a single commit.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Use tcg_target_available_regs in tcg_reg_alloc_mov
Richard Henderson [Tue, 29 Apr 2014 16:07:05 +0000 (09:07 -0700)]
tcg: Use tcg_target_available_regs in tcg_reg_alloc_mov

The move opcodes are special in that their constraints must cover
all available registers.  So instead of checking the constraints,
just use the available registers.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Make call address a constant parameter
Richard Henderson [Sun, 23 Mar 2014 03:06:52 +0000 (20:06 -0700)]
tcg: Make call address a constant parameter

Avoid allocating a tcg temporary to hold the constant address,
and instead place it directly into the op_call arguments.

At the same time, convert to the newly introduced tcg_out_call
backend function, rather than invoking tcg_out_op for the call.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotci: Create tcg_out_call
Richard Henderson [Mon, 28 Apr 2014 20:21:25 +0000 (13:21 -0700)]
tci: Create tcg_out_call

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-mips: Split out tcg_out_call
Richard Henderson [Mon, 28 Apr 2014 20:30:30 +0000 (13:30 -0700)]
tcg-mips: Split out tcg_out_call

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-sparc: Create tcg_out_call
Richard Henderson [Mon, 28 Apr 2014 16:21:26 +0000 (12:21 -0400)]
tcg-sparc: Create tcg_out_call

Rename the existing tcg_out_calli to tcg_out_call_nodelay.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc64: Rename tcg_out_calli to tcg_out_call
Richard Henderson [Mon, 28 Apr 2014 16:18:00 +0000 (12:18 -0400)]
tcg-ppc64: Rename tcg_out_calli to tcg_out_call

Merge the existing tcg_out_call into tcg_out_op.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc: Split out tcg_out_call
Richard Henderson [Mon, 28 Apr 2014 16:15:32 +0000 (12:15 -0400)]
tcg-ppc: Split out tcg_out_call

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-s390: Rename tgen_calli to tcg_out_call
Richard Henderson [Fri, 25 Apr 2014 14:49:44 +0000 (10:49 -0400)]
tcg-s390: Rename tgen_calli to tcg_out_call

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-i386: Rename tcg_out_calli to tcg_out_call
Richard Henderson [Fri, 25 Apr 2014 14:47:54 +0000 (07:47 -0700)]
tcg-i386: Rename tcg_out_calli to tcg_out_call

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Require TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Mon, 28 Apr 2014 19:01:23 +0000 (12:01 -0700)]
tcg: Require TCG_TARGET_INSN_UNIT_SIZE

Now that all backends do define TCG_TARGET_INSN_UNIT_SIZE,
remove the fallback definition.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotci: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Mon, 28 Apr 2014 18:58:30 +0000 (11:58 -0700)]
tci: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-mips: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Fri, 25 Apr 2014 19:22:44 +0000 (19:22 +0000)]
tcg-mips: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ia64: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Fri, 25 Apr 2014 17:24:23 +0000 (13:24 -0400)]
tcg-ia64: Define TCG_TARGET_INSN_UNIT_SIZE

Using a 16-byte aligned structure achieves best results, both for code
cleanliness and compiled code size.  However, this means that we can't
use the trick of encoding the slot number into the low 2 bits.

Thankfully, we only ever use slot2, so make that explicit in the names
of the relocation functions, and drop the code for other slots.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Fri, 25 Apr 2014 14:18:59 +0000 (10:18 -0400)]
tcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-aarch64: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Mon, 28 Apr 2014 19:02:31 +0000 (12:02 -0700)]
tcg-aarch64: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Acked-by: Claudio Fontana <claudio.fontana@huawei.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-arm: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Thu, 24 Apr 2014 21:23:40 +0000 (14:23 -0700)]
tcg-arm: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-sparc: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Sat, 29 Mar 2014 00:13:25 +0000 (17:13 -0700)]
tcg-sparc: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Fri, 28 Mar 2014 22:34:04 +0000 (15:34 -0700)]
tcg-ppc: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-ppc64: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Fri, 28 Mar 2014 21:58:38 +0000 (14:58 -0700)]
tcg-ppc64: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg-i386: Define TCG_TARGET_INSN_UNIT_SIZE
Richard Henderson [Tue, 1 Apr 2014 15:34:03 +0000 (08:34 -0700)]
tcg-i386: Define TCG_TARGET_INSN_UNIT_SIZE

And use tcg pointer differencing functions as appropriate.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Define tcg_insn_unit for code pointers
Richard Henderson [Fri, 28 Mar 2014 19:56:22 +0000 (12:56 -0700)]
tcg: Define tcg_insn_unit for code pointers

To be defined by the tcg backend based on the elemental unit of the ISA.
During the transition, allow TCG_TARGET_INSN_UNIT_SIZE to be undefined,
which allows us to default tcg_insn_unit to the current uint8_t.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Introduce byte pointer arithmetic helpers
Richard Henderson [Mon, 31 Mar 2014 21:27:27 +0000 (14:27 -0700)]
tcg: Introduce byte pointer arithmetic helpers

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Avoid undefined behaviour patching code at unaligned addresses
Peter Maydell [Fri, 28 Mar 2014 15:29:48 +0000 (15:29 +0000)]
tcg: Avoid undefined behaviour patching code at unaligned addresses

To avoid C undefined behaviour when patching generated code,
provide wrappers tcg_patch8/16/32/64 which use the usual memcpy
trick, and use them in the i386 backend.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agotcg: Avoid stores to unaligned addresses
Peter Maydell [Fri, 28 Mar 2014 15:29:47 +0000 (15:29 +0000)]
tcg: Avoid stores to unaligned addresses

Avoid stores to unaligned addresses in TCG code generation, by using the
usual memcpy() approach. (Using bswap.h would drag a lot of QEMU baggage
into TCG, so it's simpler just to do direct memcpy() here.)

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agoexec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps
Peter Maydell [Fri, 28 Mar 2014 15:29:46 +0000 (15:29 +0000)]
exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps

The code which patches x86 jump instructions assumes it can do an
unaligned write of a uint32_t. This is actually safe on x86, but it's
still undefined behaviour. We have infrastructure for doing efficient
unaligned accesses which doesn't engage in undefined behaviour, so
use it.

This is technically fractionally less efficient, at least with gcc 4.6;
instead of one instruction:
 7b2:   89 3e                   mov    %edi,(%rsi)
we get an extra spurious store to the stack slot:
 7b2:   89 7c 24 64             mov    %edi,0x64(%rsp)
 7b6:   89 3e                   mov    %edi,(%rsi)

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
10 years agolibcacard: remove libcacard-specific CFLAGS and LIBS from global vars
Michael Tokarev [Thu, 8 May 2014 12:48:27 +0000 (16:48 +0400)]
libcacard: remove libcacard-specific CFLAGS and LIBS from global vars

Currently all what's needed for single file libcacard/vcard_emul_nss.c
(libnss cflags) and hw/usb/ccid-card-emulated.c (libcacard includes)
together with the libs is added to global QEMU_CFLAGS and libs_softmmu.

Use the cflags only where really used (for two mentioned files), and
libs only where needed.

While at it, rename variables to better reflect reality: libcacard_*
is really nss_*.

This needs a bit more tweaking: $(NSS_LIBS) should not contain $glib_libs
(ditto for _cflags).  But in order to fix it, some more preparations
should be made first.  So add a FIXME comment.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agobuild: simplify and fix fix-obj-vars
Paolo Bonzini [Thu, 8 May 2014 13:02:48 +0000 (15:02 +0200)]
build: simplify and fix fix-obj-vars

fix-obj-vars has the undesired side effect of breaking -cflags
-objs and -libs variables in the toplevel Makefile.objs.  The
variables in the toplevel Makefile.objs do not need any fix,
so fix-obj-vars need not do anything.

Since we are touching it, remove the now unnecessary $(if)
in the callers.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 years agoglib: fix g_poll early timeout on windows
Sangho Park [Thu, 8 May 2014 08:47:10 +0000 (12:47 +0400)]
glib: fix g_poll early timeout on windows

g_poll has a problem on Windows when using
timeouts < 10ms, in glib/gpoll.c:

/* If not, and we have a significant timeout, poll again with
 * timeout then. Note that this will return indication for only
 * one event, or only for messages. We ignore timeouts less than
 * ten milliseconds as they are mostly pointless on Windows, the
 * MsgWaitForMultipleObjectsEx() call will timeout right away
 * anyway.
 */
if (retval == 0 && (timeout == INFINITE || timeout >= 10))
  retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, timeout);

so whenever g_poll is called with timeout < 10ms it does
a quick poll instead of wait, this causes significant performance
degradation of QEMU, thus we should use WaitForMultipleObjectsEx
directly

Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: qemu-iotests - test for live migration
Jeff Cody [Wed, 30 Apr 2014 14:55:10 +0000 (10:55 -0400)]
block: qemu-iotests - test for live migration

This is an initial, simple live migration test from one
running VM to another, using monitor commands.

This is also an example of using the new common.qemu functions
for controlling multiple running qemu instances, for tests that
need a live qemu vm.

Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: qemu-iotests - update 085 to use common.qemu
Jeff Cody [Wed, 30 Apr 2014 14:55:09 +0000 (10:55 -0400)]
block: qemu-iotests - update 085 to use common.qemu

The new functionality of common.qemu implements the QEMU control
and communication functionality that was originally in test 085.

This removes that now-duplicate functionality, and uses the
common.qemu functions.

The QEMU commandline changes slightly due to this; in addition to
monitor and qmp i/o options, the new QEMU commandline from inside
common.qemu now introduces -machine accel=qtest.

Reviewed-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: qemu-iotests - add common.qemu, for bash-controlled qemu tests
Jeff Cody [Wed, 30 Apr 2014 14:55:08 +0000 (10:55 -0400)]
block: qemu-iotests - add common.qemu, for bash-controlled qemu tests

This creates some common functions for bash language qemu-iotests
to control, and communicate with, a running QEMU process.

4 functions are introduced:

    1. _launch_qemu()
        This launches the QEMU process(es), and sets up the file
        descriptors and fifos for communication.  You can choose to
        launch each QEMU process listening for either QMP or HMP
        monitor.  You can call this function multiple times, and
        save the handle returned from each.  The returned handle is
        in $QEMU_HANDLE.  You must copy this value.

Commands 2 and 3 use the handle received from _launch_qemu(), to talk
to the appropriate process.

    2. _send_qemu_cmd()
        Sends a command string, specified by $2, to QEMU.  If $3 is
        non-NULL, _send_qemu_cmd() will wait to receive $3 as a
        required result string from QEMU.  Failure to receive $3 will
        cause the test to fail.  The command can optionally be retried
        $qemu_cmd_repeat number of times.  Set $qemu_error_no_exit
        to not force the test the fail on exit; in this case,
        $QEMU_STATUS[$1] will be set to -1 on failure.

    3. _timed_wait_for()
        Waits for a response, for up to a default of 10 seconds.  If
        $2 is not seen in that time (anywhere in the response), then
        the test fails.  Primarily used by _send_qemu_cmd, but could
        be useful standalone, as well.  To prevent automatic exit
        (and therefore test failure), set $qemu_error_no_exit to a
        non-NULL value.  If $silent is a non-NULL value, then output
        to stdout will be suppressed.

    4. _cleanup_qemu()
        Kills the running QEMU processes, and removes the fifos.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock/raw-posix: Try both FIEMAP and SEEK_HOLE
Max Reitz [Thu, 8 May 2014 18:57:55 +0000 (20:57 +0200)]
block/raw-posix: Try both FIEMAP and SEEK_HOLE

The current version of raw-posix always uses ioctl(FS_IOC_FIEMAP) if
FIEMAP is available; lseek with SEEK_HOLE/SEEK_DATA are not even
compiled in in this case. However, there may be implementations which
support the latter but not the former (e.g., NFSv4.2) as well as vice
versa.

To cover both cases, try FIEMAP first (as this will return -ENOTSUP if
not supported instead of returning a failsafe value (everything
allocated as a single extent)) and if that does not work, fall back to
SEEK_HOLE/SEEK_DATA.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agogluster: Correctly propagate errors when volume isn't accessible
Peter Krempa [Fri, 9 May 2014 10:08:10 +0000 (12:08 +0200)]
gluster: Correctly propagate errors when volume isn't accessible

The docs for glfs_init suggest that the function sets errno on every
failure. In fact it doesn't. As other functions such as
qemu_gluster_open() in the gluster block code report their errors based
on this fact we need to make sure that errno is set on each failure.

This fixes a crash of qemu-img/qemu when a gluster brick isn't
accessible from given host while the server serving the volume
description is.

Thread 1 (Thread 0x7ffff7fba740 (LWP 203880)):
 #0  0x00007ffff77673f8 in glfs_lseek () from /usr/lib64/libgfapi.so.0
 #1  0x0000555555574a68 in qemu_gluster_getlength ()
 #2  0x0000555555565742 in refresh_total_sectors ()
 #3  0x000055555556914f in bdrv_open_common ()
 #4  0x000055555556e8e8 in bdrv_open ()
 #5  0x000055555556f02f in bdrv_open_image ()
 #6  0x000055555556e5f6 in bdrv_open ()
 #7  0x00005555555c5775 in bdrv_new_open ()
 #8  0x00005555555c5b91 in img_info ()
 #9  0x00007ffff62c9c05 in __libc_start_main () from /lib64/libc.so.6
 #10 0x00005555555648ad in _start ()

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agovl.c: remove init_clocks call from main
Kirill Batuzov [Tue, 6 May 2014 12:59:53 +0000 (16:59 +0400)]
vl.c: remove init_clocks call from main

Clocks are initialized in qemu_init_main_loop. They are not needed before it.
Initializing them twice is not only unnecessary but is harmful: it results in
memory leak and potentially can lead to a situation where different parts of
QEMU use different sets of timers.

To avoid it remove init_clocks call from main and add an assertion to
qemu_clock_init that corresponding clock has not been initialized yet.

Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock: Fix open flags with BDRV_O_SNAPSHOT
Kevin Wolf [Tue, 6 May 2014 10:11:42 +0000 (12:11 +0200)]
block: Fix open flags with BDRV_O_SNAPSHOT

The immediately visible effect of this patch is that it fixes committing
a temporary snapshot to its backing file. Previously, it would fail with
a "permission denied" error because bdrv_inherited_flags() forced the
backing file to be read-only, ignoring the r/w reopen of bdrv_commit().

The bigger problem this revealed is that the original open flags must
actually only be applied to the temporary snapshot, and the original
image file must be treated as a backing file of the temporary snapshot
and get the right flags for that.

Reported-by: Jan Kiszka <jan.kiszka@web.de>
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 agoMerge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
Peter Maydell [Fri, 9 May 2014 14:46:34 +0000 (15:46 +0100)]
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging

* remotes/qmp-unstable/queue/qmp: (38 commits)
  Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()"
  qapi: Document optional arguments' backwards compatibility
  qmp: use valid JSON in transaction example
  qmp: Don't use error_is_set() to suppress additional errors
  dump: Drop pointless error_is_set(), DumpState member errp
  qemu-option: Clean up fragile use of error_is_set()
  qga: Drop superfluous error_is_set()
  qga: Clean up fragile use of error_is_set()
  qapi: Clean up fragile use of error_is_set()
  tests/qapi-schema: Drop superfluous error_is_set()
  qapi: Drop redundant, unclean error_is_set()
  hmp: Guard against misuse of hmp_handle_error()
  qga: Use return values instead of error_is_set(errp)
  error: Consistently name Error ** objects errp, and not err
  qmp: Consistently name Error ** objects errp, and not err
  qga: Consistently name Error ** objects errp, and not err
  qmp hmp: Consistently name Error * objects err, and not errp
  pci-assign: assigned_initfn(): set monitor error in common error handler
  pci-assign: propagate errors from assign_intx()
  pci-assign: propagate errors from assign_device()
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10 years agoRevert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()"
Peter Lieven [Thu, 8 May 2014 16:03:15 +0000 (18:03 +0200)]
Revert "qapi: Clean up superfluous null check in qapi_dealloc_type_str()"

This reverts commit 25a7017555f1b4aeb543b5d323ff4afb8f9c5437.

Turns out the argument *can* be null: QEMU now segfaults if it
receives an invalid parameter via a qmp command instead of throwing an
error.

For example:
{ "execute": "blockdev-add",
     "arguments": { "options" : { "driver": "invalid-driver" } } }

CC: qemu-stable@nongnu.org
Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqapi: Document optional arguments' backwards compatibility
Eric Blake [Wed, 7 May 2014 01:57:41 +0000 (09:57 +0800)]
qapi: Document optional arguments' backwards compatibility

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqmp: use valid JSON in transaction example
Eric Blake [Tue, 6 May 2014 15:39:03 +0000 (09:39 -0600)]
qmp: use valid JSON in transaction example

Our example should use the correct quotes to match what someone
could actually pass over the wire.

* qmp-commands.hx: Use correct JSON quotes.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqmp: Don't use error_is_set() to suppress additional errors
Markus Armbruster [Fri, 2 May 2014 11:26:42 +0000 (13:26 +0200)]
qmp: Don't use error_is_set() to suppress additional errors

Using error_is_set(errp) that way can sweep programming errors under
the carpet when we get called incorrectly with an error set.

encrypted_bdrv_it() does it, because there's no way to make
bdrv_iterate() break its loop.  Actually safe, because qmp_cont()
clears the error before the loop.  Clean it up anyway: replace
bdrv_iterate() by bdrv_next(), break the loop on error.

Replace both occurrences, for consistency.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agodump: Drop pointless error_is_set(), DumpState member errp
Markus Armbruster [Fri, 2 May 2014 11:26:41 +0000 (13:26 +0200)]
dump: Drop pointless error_is_set(), DumpState member errp

In qmp_dump_guest_memory(), the error must be clear on entry, and we
always bail out after setting it, directly or via dump_init().
Therefore, both error_is_set() are always false.  Drop them.

DumpState member errp is now write-only.  Drop it, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqemu-option: Clean up fragile use of error_is_set()
Markus Armbruster [Fri, 2 May 2014 11:26:40 +0000 (13:26 +0200)]
qemu-option: Clean up fragile use of error_is_set()

Using error_is_set(ERRP) to find out whether to bail out due to
previous error is either wrong, fragile, or unnecessarily opaque.
It's wrong when ERRP may be null, because errors go undetected when it
is.  It's fragile when proving ERRP non-null involves a non-local
argument.  Else, it's unnecessarily opaque (see commit 84d18f0).

The error_is_set(state->errp) in qemu_opts_from_qdict_1() is merely
fragile, because the callers never pass state argument with null
state->errp.

Make the code more robust and more obviously correct: test
*state->errp directly.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqga: Drop superfluous error_is_set()
Markus Armbruster [Fri, 2 May 2014 11:26:39 +0000 (13:26 +0200)]
qga: Drop superfluous error_is_set()

acquire_privilege(), execute_async() and check_suspend_mode() do
nothing when called with an error set.  Callers shouldn't do that, and
no caller does.  Drop the superfluous tests.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqga: Clean up fragile use of error_is_set()
Markus Armbruster [Fri, 2 May 2014 11:26:38 +0000 (13:26 +0200)]
qga: Clean up fragile use of error_is_set()

Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

The error_is_set(errp) in the guest agent command handler functions
are merely fragile, because all chall chains (do_qmp_dispatch() via
the generated marshalling functions) pass a non-null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqapi: Clean up fragile use of error_is_set()
Markus Armbruster [Fri, 2 May 2014 11:26:37 +0000 (13:26 +0200)]
qapi: Clean up fragile use of error_is_set()

Using error_is_set(ERRP) to find out whether a function failed is
either wrong, fragile, or unnecessarily opaque.  It's wrong when ERRP
may be null, because errors go undetected when it is.  It's fragile
when proving ERRP non-null involves a non-local argument.  Else, it's
unnecessarily opaque (see commit 84d18f0).

The error_is_set(errp) in do_qmp_dispatch() is merely fragile, because
the caller never passes a null errp argument.

Make the code more robust and more obviously correct: receive the
error in a local variable, then propagate it through the parameter.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agotests/qapi-schema: Drop superfluous error_is_set()
Markus Armbruster [Fri, 2 May 2014 11:26:36 +0000 (13:26 +0200)]
tests/qapi-schema: Drop superfluous error_is_set()

visit_type_TestStruct() does nothing when called with an error set.
Callers shouldn't do that, and no caller does.  Drop the superfluous
test.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqapi: Drop redundant, unclean error_is_set()
Markus Armbruster [Fri, 2 May 2014 11:26:35 +0000 (13:26 +0200)]
qapi: Drop redundant, unclean error_is_set()

do_qmp_dispatch()'s test for qmp_dispatch_check_obj() failure examines
both the return value and the error object.  The latter part is
unclean; it works only when do_qmp_dispatch()'s caller passes a
non-null errp argument.  That's the case, but it's not locally
obvious.  Unclean.

Cleanup would be easy enough, but since the unclean code is also
redundant, let's just drop it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agohmp: Guard against misuse of hmp_handle_error()
Markus Armbruster [Fri, 2 May 2014 11:26:34 +0000 (13:26 +0200)]
hmp: Guard against misuse of hmp_handle_error()

Null errp argument makes no sense.  Assert it's not null, to make this
explicit, and guard against misuse.  All current callers pass non-null
errp.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqga: Use return values instead of error_is_set(errp)
Markus Armbruster [Fri, 2 May 2014 11:26:33 +0000 (13:26 +0200)]
qga: Use return values instead of error_is_set(errp)

Using error_is_set(errp) to check whether a function call failed is
fragile: it breaks when errp is null.  ga_get_fd_handle() and
guest_file_handle_add() don't return a useful value when they fail,
but that's just stupid.  Fix that, and check them instead.  As far
as I can tell, errp can't be null there, but this is more robust and
more obviously correct.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoerror: Consistently name Error ** objects errp, and not err
Markus Armbruster [Fri, 2 May 2014 11:26:32 +0000 (13:26 +0200)]
error: Consistently name Error ** objects errp, and not err

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqmp: Consistently name Error ** objects errp, and not err
Markus Armbruster [Fri, 2 May 2014 11:26:31 +0000 (13:26 +0200)]
qmp: Consistently name Error ** objects errp, and not err

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqga: Consistently name Error ** objects errp, and not err
Markus Armbruster [Fri, 2 May 2014 11:26:30 +0000 (13:26 +0200)]
qga: Consistently name Error ** objects errp, and not err

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agoqemu-iotests: Test converting to streamOptimized from small cluster size
Fam Zheng [Tue, 6 May 2014 13:08:46 +0000 (21:08 +0800)]
qemu-iotests: Test converting to streamOptimized from small cluster size

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agovmdk: Implement .bdrv_get_info()
Fam Zheng [Tue, 6 May 2014 13:08:45 +0000 (21:08 +0800)]
vmdk: Implement .bdrv_get_info()

This will return cluster_size and needs_compressed_writes to caller, if all the
extents have the same value (or there's only one extent). Otherwise return
-ENOTSUP.

cluster_size is only reported for sparse formats.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agovmdk: Implement .bdrv_write_compressed
Fam Zheng [Tue, 6 May 2014 13:08:44 +0000 (21:08 +0800)]
vmdk: Implement .bdrv_write_compressed

Add a wrapper function to support "compressed" path in qemu-img convert.
Only support streamOptimized subformat case for now (num_extents == 1
and extent compression is true).

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqemu-img: Convert by cluster size if target is compressed
Fam Zheng [Tue, 6 May 2014 13:08:43 +0000 (21:08 +0800)]
qemu-img: Convert by cluster size if target is compressed

If target block driver forces compression, qemu-img convert needs to
write by cluster size as well as "-c" option.

Particularly, this applies for converting to VMDK streamOptimized
format.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock/iscsi: bump year in copyright notice
Peter Lieven [Mon, 28 Apr 2014 11:16:30 +0000 (13:16 +0200)]
block/iscsi: bump year in copyright notice

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoblock/nfs: Check for NULL server part
Max Reitz [Mon, 5 May 2014 18:27:49 +0000 (20:27 +0200)]
block/nfs: Check for NULL server part

After the URL has been parsed make sure the server part is valid in
order to avoid a segmentation fault when calling nfs_mount().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqemu-img: sort block formats in help message
Mike Day [Mon, 5 May 2014 16:53:34 +0000 (12:53 -0400)]
qemu-img: sort block formats in help message

The help message for qemu-img lists the supported block formats, of
which there are 27 as of version 2.0.50. The formats are printed in
the order of their driver's position in a linked list, which appears
random. This patch prints the formats in sorted order, making it
easier to read and to find a specific format in the list.

[Added suggestions from Fam Zheng <famz@redhat.com> to declare variables
at the top of the scope in help() and to omit explicit cast for void*
opaque.
--Stefan]

Signed-off-by: Mike Day <ncmike@ncultra.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoiotests: Use configured python
Max Reitz [Sat, 3 May 2014 14:47:08 +0000 (16:47 +0200)]
iotests: Use configured python

Currently, QEMU's iotests rely on /usr/bin/env to start the correct
Python (that is, at least Python 2.4, but not 3). On systems where
Python 3 is the default, the user has no clean way of making the iotests
use the correct binary.

This commit makes the iotests use the Python selected by configure.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqcow2: Fix alloc_clusters_noref() overflow detection
Max Reitz [Sun, 4 May 2014 03:31:40 +0000 (05:31 +0200)]
qcow2: Fix alloc_clusters_noref() overflow detection

If the very first allocation has a length of 0, the free_cluster_index
is still 0 after the for loop, which means that subtracting one from it
will underflow and signal an invalid range of clusters by returning
-EFBIG. However, there is no such range, as its length is 0.

Fix this by preventing underflows on free_cluster_index during the
check.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
10 years agoqmp hmp: Consistently name Error * objects err, and not errp
Markus Armbruster [Fri, 2 May 2014 11:26:29 +0000 (13:26 +0200)]
qmp hmp: Consistently name Error * objects err, and not errp

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agopci-assign: assigned_initfn(): set monitor error in common error handler
Laszlo Ersek [Thu, 10 Apr 2014 08:24:45 +0000 (10:24 +0200)]
pci-assign: assigned_initfn(): set monitor error in common error handler

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agopci-assign: propagate errors from assign_intx()
Laszlo Ersek [Thu, 10 Apr 2014 08:24:44 +0000 (10:24 +0200)]
pci-assign: propagate errors from assign_intx()

Among the callers, only assigned_initfn() should set the  monitor's stored
error. Other callers may run in contexts where the monitor's stored error
makes no sense. For example:

assigned_dev_pci_write_config()
  assigned_dev_update_msix()
    assign_intx()

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agopci-assign: propagate errors from assign_device()
Laszlo Ersek [Thu, 10 Apr 2014 08:24:43 +0000 (10:24 +0200)]
pci-assign: propagate errors from assign_device()

Also, change the return type to "void"; the function is static (with a
sole caller) and the negative errno values are not distinguished from each
other.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agopci-assign: propagate errors from assigned_dev_register_regions()
Laszlo Ersek [Thu, 10 Apr 2014 08:24:42 +0000 (10:24 +0200)]
pci-assign: propagate errors from assigned_dev_register_regions()

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agopci-assign: propagate errors from assigned_dev_register_msix_mmio()
Laszlo Ersek [Thu, 10 Apr 2014 08:24:41 +0000 (10:24 +0200)]
pci-assign: propagate errors from assigned_dev_register_msix_mmio()

The return type is also changed from "int" to "void", because it was used
in a success vs. failure sense only (the caller didn't distinguish error
codes from each other, and even assigned_dev_register_msix_mmio() masked
mmap()'s errno values with a common -EFAULT).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agopci-assign: propagate errors from assigned_device_pci_cap_init()
Laszlo Ersek [Thu, 10 Apr 2014 08:24:40 +0000 (10:24 +0200)]
pci-assign: propagate errors from assigned_device_pci_cap_init()

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
10 years agopci-assign: propagate errors from get_real_device()
Laszlo Ersek [Thu, 10 Apr 2014 08:24:39 +0000 (10:24 +0200)]
pci-assign: propagate errors from get_real_device()

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>