]> git.proxmox.com Git - qemu.git/log
qemu.git
11 years agochardev: add file chardev support to chardev-add (qmp)
Gerd Hoffmann [Wed, 19 Dec 2012 12:13:57 +0000 (13:13 +0100)]
chardev: add file chardev support to chardev-add (qmp)

Add support for file chardevs.  Output file is mandatory,
input file is optional.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add hmp hotplug commands
Gerd Hoffmann [Wed, 19 Dec 2012 09:33:40 +0000 (10:33 +0100)]
chardev: add hmp hotplug commands

Add chardev-add and chardev-remove commands to the human monitor.
chardev-add accepts the same syntax as -chardev, chardev-remove
expects a chardev id.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add qmp hotplug commands, with null chardev support
Gerd Hoffmann [Wed, 19 Dec 2012 09:33:56 +0000 (10:33 +0100)]
chardev: add qmp hotplug commands, with null chardev support

Add chardev-add and chardev-remove qmp commands.  Hotplugging
a null chardev is supported for now, more will be added later.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: reduce chardev ifdef mess a bit
Gerd Hoffmann [Wed, 19 Dec 2012 15:35:42 +0000 (16:35 +0100)]
chardev: reduce chardev ifdef mess a bit

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: fix QemuOpts lifecycle
Gerd Hoffmann [Mon, 15 Oct 2012 07:30:59 +0000 (09:30 +0200)]
chardev: fix QemuOpts lifecycle

qemu_chr_new_from_opts handles QemuOpts release now, so callers don't
have to worry.  It will either be saved in CharDriverState, then
released in qemu_chr_delete, or in the error case released instantly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agochardev: add error reporting for qemu_chr_new_from_opts
Gerd Hoffmann [Mon, 15 Oct 2012 07:28:05 +0000 (09:28 +0200)]
chardev: add error reporting for qemu_chr_new_from_opts

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoqdev: Prepare "realized" property
Andreas Färber [Wed, 9 Jan 2013 02:58:11 +0000 (03:58 +0100)]
qdev: Prepare "realized" property

Introduce the QOM realizefn suggested by Anthony.
Detailed documentation is supplied in the qdev header.

For now this implements a default DeviceClass::realize callback that
just wraps DeviceClass::init, which it deprecates.
Once all devices have been converted to DeviceClass::realize,
DeviceClass::init is to be removed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoqdev: Fold state enum into bool realized
Andreas Färber [Wed, 9 Jan 2013 02:58:10 +0000 (03:58 +0100)]
qdev: Fold state enum into bool realized

Whether the device was initialized or not is QOM-level information and
currently unused. Drop it from device. This leaves the boolean state of
whether or not DeviceClass::init was called or not, a.k.a. "realized".

Suggested-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopseries: set no default boot order
Avik Sil [Tue, 8 Jan 2013 07:06:31 +0000 (12:36 +0530)]
pseries: set no default boot order

This patch removes the default boot order for pseries machine. This allows
the machine to handle a NULL boot order in case no -boot option is provided.
Thus it helps SLOF firmware to verify if boot order is specified in command
line or not. If no boot order is provided SLOF tries to boot from the
device set in the nvram.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMake default boot order machine specific
Avik Sil [Tue, 8 Jan 2013 07:06:30 +0000 (12:36 +0530)]
Make default boot order machine specific

This patch makes default boot order machine specific instead of
set globally. The default boot order can be set per machine in
QEMUMachine boot_order. This also allows a machine to receive a
NULL boot order when -boot isn't used and take an appropriate action
accordingly. This helps machine boots from the devices as set in
guest's non-volatile memory location in case no boot order is
provided by the user.

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoacl: Free memory allocated with g_malloc() with g_free()
Markus Armbruster [Tue, 15 Jan 2013 14:24:16 +0000 (15:24 +0100)]
acl: Free memory allocated with g_malloc() with g_free()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoacl: Fix acl_remove not to mess up the ACL
Markus Armbruster [Tue, 15 Jan 2013 14:24:15 +0000 (15:24 +0100)]
acl: Fix acl_remove not to mess up the ACL

It leaks memory and fails to adjust qemu_acl member nentries.  Future
acl_add become confused: can misreport the position, and can silently
fail to add.

Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agosdl: Fix heap smash in sdl_zoom_rgb{16,32} for int > 32 bits
Markus Armbruster [Tue, 15 Jan 2013 14:42:32 +0000 (15:42 +0100)]
sdl: Fix heap smash in sdl_zoom_rgb{16,32} for int > 32 bits

Careless use of malloc(): allocate Uint32[N], assign to int *, use
int[N].

Fix by converting to g_new().

Functions can't fail anymore, so make them return void.  Caller
ignored the value anyway.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agokvm: add stub for kvm_irqchip_update_msi_route
Michael S. Tsirkin [Tue, 15 Jan 2013 17:50:13 +0000 (19:50 +0200)]
kvm: add stub for kvm_irqchip_update_msi_route

ppc64 build needs this stub to build with virtio enabled.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'afaerber/memory-ioport' into staging
Anthony Liguori [Tue, 15 Jan 2013 22:54:41 +0000 (16:54 -0600)]
Merge remote-tracking branch 'afaerber/memory-ioport' into staging

* afaerber/memory-ioport:
  acpi_piix4: Do not use old_portio-style callbacks
  xen_platform: Do not use old_portio-style callbacks
  hw/dma.c: Fix conversion of ioport_register* to MemoryRegion

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

* stefanha/trivial-patches:
  configure: try pkg-config for curses
  qom: Make object_resolve_path_component() path argument const
  Add libcacard/trace/generated-tracers.c to .gitignore

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'stefanha/block' into staging
Anthony Liguori [Tue, 15 Jan 2013 22:52:56 +0000 (16:52 -0600)]
Merge remote-tracking branch 'stefanha/block' into staging

* stefanha/block:
  block: Fix how mirror_run() frees its buffer
  win32-aio: Fix how win32_aio_process_completion() frees buffer
  scsi-disk: qemu_vfree(NULL) is fine, simplify
  w32: Make qemu_vfree() accept NULL like the POSIX implementation
  sheepdog: clean up sd_aio_setup()
  sheepdog: multiplex the rw FD to flush cache
  block: clear dirty bitmap when discarding
  ide: issue discard asynchronously but serialize the pieces
  ide: fix TRIM with empty range entry
  block: make discard asynchronous
  raw: support discard on block devices
  raw-posix: remember whether discard failed
  raw-posix: support discard on more filesystems
  block: fix initialization in bdrv_io_limits_enable()
  qcow2: Fix segfault on zero-length write

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'afaerber/qom-cpu' into staging
Anthony Liguori [Tue, 15 Jan 2013 22:52:39 +0000 (16:52 -0600)]
Merge remote-tracking branch 'afaerber/qom-cpu' into staging

* afaerber/qom-cpu:
  target-i386: Use switch in check_hw_breakpoints()
  target-i386: Avoid goto in hw_breakpoint_insert()
  target-i386: Introduce hw_{local,global}_breakpoint_enabled()
  target-i386: Define DR7 bit field constants
  target-i386: Move kvm_check_features_against_host() check to realize time
  target-i386: cpu_x86_register() consolidate freeing resources
  target-i386: Move setting defaults out of cpu_x86_parse_featurestr()
  target-i386: check/enforce: Check all feature words
  target-i386/cpu.c: Add feature name array for ext4_features
  target-i386: kvm_check_features_against_host(): Use feature_word_info
  target-i386/cpu: Introduce FeatureWord typedefs
  target-i386: Disable kvm_mmu by default
  kvm: Add fake KVM constants to avoid #ifdefs on KVM-specific code
  exec: Return CPUState from qemu_get_cpu()
  xen: Simplify halting of first CPU
  kvm: Pass CPUState to kvm_init_vcpu()
  cpu: Move cpu_index field to CPUState
  cpu: Move numa_node field to CPUState
  target-mips: Clean up mips_cpu_map_tc() documentation
  cpu: Move nr_{cores,threads} fields to CPUState

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'afaerber-or/prep-up' into staging
Anthony Liguori [Tue, 15 Jan 2013 22:52:10 +0000 (16:52 -0600)]
Merge remote-tracking branch 'afaerber-or/prep-up' into staging

* afaerber-or/prep-up:
  pc87312: Avoid define conflict on mingw32
  pc87312: Replace register_ioport_*() with MemoryRegion

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'mdroth/qga-pull-1-14-2013-2' into staging
Anthony Liguori [Tue, 15 Jan 2013 22:50:04 +0000 (16:50 -0600)]
Merge remote-tracking branch 'mdroth/qga-pull-1-14-2013-2' into staging

* mdroth/qga-pull-1-14-2013-2:
  qga: add missing commas in json docs

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'mdroth/qga-pull-1-14-2013' into staging
Anthony Liguori [Tue, 15 Jan 2013 22:49:48 +0000 (16:49 -0600)]
Merge remote-tracking branch 'mdroth/qga-pull-1-14-2013' into staging

* mdroth/qga-pull-1-14-2013:
  qemu-ga: Handle errors uniformely in ga_channel_open()
  qemu-ga: Plug fd leak on ga_channel_open() error paths
  qemu-ga: Plug fd leak on ga_channel_listen_accept() error path
  qemu-ga: Plug file descriptor leak on ga_open_pidfile() error path
  qemu-ga: Drop pointless lseek() from ga_open_pidfile()
  qemu-ga: Document intentional fall through in channel_event_cb()
  qemu-ga: add ga_open_logfile()
  qemu-ga: ga_open_pidfile(): use qemu_open()

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'sstabellini/xen-2013-01-14' into staging
Anthony Liguori [Tue, 15 Jan 2013 22:49:18 +0000 (16:49 -0600)]
Merge remote-tracking branch 'sstabellini/xen-2013-01-14' into staging

* sstabellini/xen-2013-01-14:
  xen_disk: implement BLKIF_OP_FLUSH_DISKCACHE, remove BLKIF_OP_WRITE_BARRIER
  xen_disk: add persistent grant support to xen_disk backend
  xen_disk: fix memory leak

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoacpi_piix4: Do not use old_portio-style callbacks
Hervé Poussineau [Fri, 4 Jan 2013 21:29:41 +0000 (22:29 +0100)]
acpi_piix4: Do not use old_portio-style callbacks

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
[AF: Used HWADDR_PRIx for hwaddr PIIX4_DPRINTF()]
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoxen_platform: Do not use old_portio-style callbacks
Hervé Poussineau [Fri, 4 Jan 2013 21:29:40 +0000 (22:29 +0100)]
xen_platform: Do not use old_portio-style callbacks

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agohw/dma.c: Fix conversion of ioport_register* to MemoryRegion
Julien Grall [Wed, 19 Dec 2012 12:09:21 +0000 (12:09 +0000)]
hw/dma.c: Fix conversion of ioport_register* to MemoryRegion

The commit 582299336879504353e60c7937fbc70fea93f3da introduced a 1-shift for
some offset in DMA emulation.

Before the previous commit, which converted ioport_register_* to
MemoryRegion, the DMA controller registered 8 ioports with the following
formula:
base + ((8 + i) << d->shift) where 0 <= i < 8
When an IO occured within a Memory Region, DMA callback receives an
offset relative to the start address. Here the start address is:
base + (8 << d->shift).
The offset should be: (i << d->shift). After the shift is reverted, the
offsets are 0..7 not 1..8.

Fixes LP#1089996.

Reported-by: Andreas Gustafsson <gson@gson.org>
Signed-off-by: Julien Grall <julien.grall@citrix.com>
Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoconfigure: try pkg-config for curses
Vadim Evard [Tue, 15 Jan 2013 12:17:24 +0000 (16:17 +0400)]
configure: try pkg-config for curses

Static linkikng against ncurses may require explicit -ltinfo.
In case -lcurses and -lncurses both didn't work give pkg-config a
chance.

Fixes #1094786 for me.

Signed-off-by: Vadim Evard <v.e.evard@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: Fix how mirror_run() frees its buffer
Markus Armbruster [Tue, 15 Jan 2013 14:29:10 +0000 (15:29 +0100)]
block: Fix how mirror_run() frees its buffer

It allocates with qemu_blockalign(), therefore it must free with
qemu_vfree(), not g_free().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agowin32-aio: Fix how win32_aio_process_completion() frees buffer
Markus Armbruster [Tue, 15 Jan 2013 13:23:39 +0000 (14:23 +0100)]
win32-aio: Fix how win32_aio_process_completion() frees buffer

win32_aio_submit() allocates it with qemu_blockalign(), therefore it
must be freed with qemu_vfree(), not g_free().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoscsi-disk: qemu_vfree(NULL) is fine, simplify
Markus Armbruster [Tue, 15 Jan 2013 13:23:38 +0000 (14:23 +0100)]
scsi-disk: qemu_vfree(NULL) is fine, simplify

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agow32: Make qemu_vfree() accept NULL like the POSIX implementation
Markus Armbruster [Tue, 15 Jan 2013 13:23:37 +0000 (14:23 +0100)]
w32: Make qemu_vfree() accept NULL like the POSIX implementation

On POSIX, qemu_vfree() accepts NULL, because it's merely wrapper
around free().  As far as I can tell, the Windows implementation
doesn't.  Breeds bugs that bite only under Windows.

Make the Windows implementation behave like the POSIX implementation.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agosheepdog: clean up sd_aio_setup()
Liu Yuan [Mon, 14 Jan 2013 06:01:03 +0000 (14:01 +0800)]
sheepdog: clean up sd_aio_setup()

The last two parameters of sd_aio_setup() are never used, so remove them.

Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agosheepdog: multiplex the rw FD to flush cache
Liu Yuan [Tue, 15 Jan 2013 08:28:55 +0000 (16:28 +0800)]
sheepdog: multiplex the rw FD to flush cache

This will reduce sockfds connected to the sheep server to one, which simply the
future hacks.

Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoqom: Make object_resolve_path_component() path argument const
Andreas Färber [Tue, 15 Jan 2013 01:55:10 +0000 (02:55 +0100)]
qom: Make object_resolve_path_component() path argument const

A usage with a hardcoded partial path such as

  object_resolve_path_component(obj, "foo")

is totally valid but currently leads to a compilation error. Fix this.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoAdd libcacard/trace/generated-tracers.c to .gitignore
Alex Rozenman [Mon, 7 Jan 2013 23:28:02 +0000 (01:28 +0200)]
Add libcacard/trace/generated-tracers.c to .gitignore

Signed-off-by: Alex Rozenman <Alex_Rozenman@mentor.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: clear dirty bitmap when discarding
Paolo Bonzini [Mon, 14 Jan 2013 15:26:58 +0000 (16:26 +0100)]
block: clear dirty bitmap when discarding

Note that resetting bits in the dirty bitmap is done _before_ actually
processing the request.  Writes, instead, set bits after the request
is completed.

This way, when there are concurrent write and discard requests, the
outcome will always be that the blocks are marked dirty.  This scenario
should never happen, but it is safer to do it this way.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoide: issue discard asynchronously but serialize the pieces
Paolo Bonzini [Mon, 14 Jan 2013 15:26:57 +0000 (16:26 +0100)]
ide: issue discard asynchronously but serialize the pieces

Now that discard can take a long time, make it asynchronous.
Each LBA range entry is processed separately because discard
can be an expensive operation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoide: fix TRIM with empty range entry
Paolo Bonzini [Mon, 14 Jan 2013 15:26:56 +0000 (16:26 +0100)]
ide: fix TRIM with empty range entry

ATA-ACS-3 says "If the two byte range length is zero, then the LBA
Range Entry shall be discarded as padding."  iovecs are used as if
they are linearized, so it is incorrect to discard the rest of
this iovec.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: make discard asynchronous
Paolo Bonzini [Mon, 14 Jan 2013 15:26:55 +0000 (16:26 +0100)]
block: make discard asynchronous

This is easy with the thread pool, because we can use s->is_xfs and
s->has_discard from the worker function.

QEMU has a widespread assumption that each I/O operation writes less
than 2^32 bytes.  This patch doesn't fix it throughout of course,
but it starts correcting struct RawPosixAIOData so that there is
no regression with respect to the synchronous discard implementation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoraw: support discard on block devices
Paolo Bonzini [Mon, 14 Jan 2013 15:26:54 +0000 (16:26 +0100)]
raw: support discard on block devices

Block devices use a ioctl instead of fallocate, so add a separate
implementation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoraw-posix: remember whether discard failed
Paolo Bonzini [Mon, 14 Jan 2013 15:26:53 +0000 (16:26 +0100)]
raw-posix: remember whether discard failed

Avoid sending system calls repeatedly if they shall fail.  This
does not apply to XFS: if the filesystem-specific ioctl fails,
something weird is happening.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoraw-posix: support discard on more filesystems
Kusanagi Kouichi [Mon, 14 Jan 2013 15:26:52 +0000 (16:26 +0100)]
raw-posix: support discard on more filesystems

Linux 2.6.38 introduced the filesystem independent interface to
deallocate part of a file. As of Linux 3.7, btrfs, ext4, ocfs2,
tmpfs and xfs support it.

Even though the system calls here are in practice issued on Linux,
the code is structured to allow plugging in alternatives for other Unix
variants.  EOPNOTSUPP is used unconditionally in this patch, but it is
supported in both OpenBSD and Mac OS X since forever (see for example
http://lists.debian.org/debian-glibc/2006/02/msg00337.html).

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agoblock: fix initialization in bdrv_io_limits_enable()
Peter Lieven [Fri, 11 Jan 2013 12:29:55 +0000 (13:29 +0100)]
block: fix initialization in bdrv_io_limits_enable()

bdrv_io_limits_enable() starts a new slice, but does not set io_base
correctly for that slice.

Here is how io_base is used:

    bytes_base  = bs->nr_bytes[is_write] - bs->io_base.bytes[is_write];
    bytes_res   = (unsigned) nb_sectors * BDRV_SECTOR_SIZE;

    if (bytes_base + bytes_res <= bytes_limit) {
        /* no wait */
    } else {
        /* operation needs to be throttled */
    }

As a result, any I/O operations that are triggered between now and
bs->slice_end are incorrectly limited.  If 10 MB of data has been
written since the VM was started, QEMU thinks that 10 MB of data has
been written in this slice. This leads to a I/O lockup in the guest.

We fix this by delaying the start of a new slice to the next
call of bdrv_exceed_io_limits().

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agotarget-i386: Use switch in check_hw_breakpoints()
liguang [Tue, 15 Jan 2013 05:39:56 +0000 (13:39 +0800)]
target-i386: Use switch in check_hw_breakpoints()

Replace an if statement using magic numbers for breakpoint type with a
more explicit switch statement. This is to aid readability.

Change the return type and force_dr6_update argument type to bool.

While at it, fix Coding Style issues (missing braces).

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Avoid goto in hw_breakpoint_insert()
liguang [Tue, 15 Jan 2013 07:24:02 +0000 (08:24 +0100)]
target-i386: Avoid goto in hw_breakpoint_insert()

  "Go To Statement Considered Harmful" -- E. Dijkstra

To avoid an unnecessary goto within the switch statement, move
watchpoint insertion out of the switch statement. Improves readability.

While at it, fix Coding Style issues (missing braces, indentation).

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Introduce hw_{local,global}_breakpoint_enabled()
liguang [Tue, 15 Jan 2013 07:01:07 +0000 (08:01 +0100)]
target-i386: Introduce hw_{local,global}_breakpoint_enabled()

hw_breakpoint_enabled() returned a bit field indicating whether a local
breakpoint and/or global breakpoint was enabled. Avoid this number magic
by using explicit boolean helper functions hw_local_breakpoint_enabled()
and hw_global_breakpoint_enabled(), to aid readability.

Reuse them for the hw_breakpoint_enabled() implementation and change
its return type to bool.

While at it, fix Coding Style issues (missing braces).

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-i386: Define DR7 bit field constants
liguang [Tue, 15 Jan 2013 05:39:55 +0000 (13:39 +0800)]
target-i386: Define DR7 bit field constants

Implicit use of dr7 bit field is a little hard to understand,
so define constants for them and use them consistently.

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoqcow2: Fix segfault on zero-length write
Kevin Wolf [Mon, 14 Jan 2013 16:31:31 +0000 (17:31 +0100)]
qcow2: Fix segfault on zero-length write

One of the recent refactoring patches (commit f50f88b9) didn't take care
to initialise l2meta properly, so with zero-length writes, which don't
even enter the write loop, qemu just segfaulted.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11 years agotarget-i386: Move kvm_check_features_against_host() check to realize time
Igor Mammedov [Fri, 11 Jan 2013 02:10:17 +0000 (03:10 +0100)]
target-i386: Move kvm_check_features_against_host() check to realize time

kvm_check_features_against_host() should be called when features can't
be changed, and when features are converted to properties it would be
possible to change them until realize time, so correct way is to call
kvm_check_features_against_host() in x86_cpu_realize().

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: cpu_x86_register() consolidate freeing resources
Igor Mammedov [Fri, 11 Jan 2013 02:10:16 +0000 (03:10 +0100)]
target-i386: cpu_x86_register() consolidate freeing resources

Freeing resources in one place would require setting 'error'
to not NULL, so add some more error reporting before jumping to
exit branch.

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: Move setting defaults out of cpu_x86_parse_featurestr()
Igor Mammedov [Fri, 11 Jan 2013 02:10:15 +0000 (03:10 +0100)]
target-i386: Move setting defaults out of cpu_x86_parse_featurestr()

No functional change, needed for simplifying conversion 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: check/enforce: Check all feature words
Eduardo Habkost [Mon, 7 Jan 2013 18:20:48 +0000 (16:20 -0200)]
target-i386: check/enforce: Check all feature words

This adds the following feature words to the list of flags to be checked
by kvm_check_features_against_host():

 - cpuid_7_0_ebx_features
 - ext4_features
 - kvm_features
 - svm_features

This will ensure the "enforce" flag works as it should: it won't allow
QEMU to be started unless every flag that was requested by the user or
defined in the CPU model is supported by the host.

This patch may cause existing configurations where "enforce" wasn't
preventing QEMU from being started to abort QEMU. But that's exactly the
point of this patch: if a flag was not supported by the host and QEMU
wasn't aborting, it was a bug in the "enforce" code.

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/cpu.c: Add feature name array for ext4_features
Eduardo Habkost [Mon, 7 Jan 2013 18:20:47 +0000 (16:20 -0200)]
target-i386/cpu.c: Add feature name array for ext4_features

Feature names were taken from the X86_FEATURE_* constants in the Linux
kernel code.

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_check_features_against_host(): Use feature_word_info
Eduardo Habkost [Mon, 7 Jan 2013 18:20:46 +0000 (16:20 -0200)]
target-i386: kvm_check_features_against_host(): Use feature_word_info

Instead of carrying the CPUID leaf/register and feature name array on
the model_features_t struct, move that information into
feature_word_info so it can be reused by other functions.

The goal is to eventually kill model_features_t entirely, but to do that
we have to either convert x86_def_t.features to an array or use
offsetof() inside FeatureWordInfo (to replace the pointers inside
model_features_t). So by now just move most of the model_features_t
fields to FeatureWordInfo except for the two pointers to local
arguments.

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/cpu: Introduce FeatureWord typedefs
Eduardo Habkost [Mon, 7 Jan 2013 18:20:45 +0000 (16:20 -0200)]
target-i386/cpu: Introduce FeatureWord typedefs

This introduces a FeatureWord enum, FeatureWordInfo struct (with
generation information about a feature word), and a FeatureWordArray
typedef, and changes add_flagname_to_bitmaps() code and
cpu_x86_parse_featurestr() to use the new typedefs instead of separate
variables for each feature word.

This will help us keep the code at kvm_check_features_against_host(),
cpu_x86_parse_featurestr() and add_flagname_to_bitmaps() sane while
adding new feature name arrays.

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: Disable kvm_mmu by default
Eduardo Habkost [Mon, 7 Jan 2013 18:20:44 +0000 (16:20 -0200)]
target-i386: Disable kvm_mmu by default

KVM_CAP_PV_MMU capability reporting was removed from the kernel since
v2.6.33 (see commit a68a6a7282373), and was completely removed from the
kernel since v3.3 (see commit fb92045843). It doesn't make sense to keep
it enabled by default, as it would cause unnecessary hassle when using
the "enforce" flag.

This disables kvm_mmu on all machine-types. With this fix, the possible
scenarios when migrating from QEMU <= 1.3 to QEMU 1.4 are:

------------+----------+----------------------------------------------------
 src kernel | dst kern.| Result
------------+----------+----------------------------------------------------
 >= 2.6.33  | any      | kvm_mmu was already disabled and will stay disabled
 <= 2.6.32  | >= 3.3   | correct live migration is impossible
 <= 2.6.32  | <= 3.2   | kvm_mmu will be disabled on next guest reboot *
------------+----------+----------------------------------------------------

 * If they are running kernel <= 2.6.32 and want kvm_mmu to be kept
   enabled on guest reboot, they can explicitly add +kvm_mmu to the QEMU
   command-line. Using 2.6.33 and higher, it is not possible to enable
   kvm_mmu explicitly anymore.

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 agokvm: Add fake KVM constants to avoid #ifdefs on KVM-specific code
Eduardo Habkost [Mon, 7 Jan 2013 18:20:42 +0000 (16:20 -0200)]
kvm: Add fake KVM constants to avoid #ifdefs on KVM-specific code

Any KVM-specific code that use these constants must check if
kvm_enabled() is true before using them.

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 agoexec: Return CPUState from qemu_get_cpu()
Andreas Färber [Mon, 17 Dec 2012 18:47:15 +0000 (19:47 +0100)]
exec: Return CPUState from qemu_get_cpu()

Move the declaration to qemu/cpu.h and add documentation.
The implementation still depends on CPUArchState for CPU iteration.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agoxen: Simplify halting of first CPU
Andreas Färber [Mon, 17 Dec 2012 18:39:30 +0000 (19:39 +0100)]
xen: Simplify halting of first CPU

Use the global first_cpu variable to halt the CPU rather than using a
local first_cpu initialized from qemu_get_cpu(0).

This will allow to change qemu_get_cpu() return type to CPUState
despite use of the CPU_COMMON halted field in the reset handler.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agokvm: Pass CPUState to kvm_init_vcpu()
Andreas Färber [Mon, 17 Dec 2012 05:38:45 +0000 (06:38 +0100)]
kvm: Pass CPUState to kvm_init_vcpu()

CPUArchState is no longer needed, and it thereby no longer depends on
NEED_CPU_H.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Move cpu_index field to CPUState
Andreas Färber [Mon, 17 Dec 2012 05:18:02 +0000 (06:18 +0100)]
cpu: Move cpu_index field to CPUState

Note that target-alpha accesses this field from TCG, now using a
negative offset. Therefore the field is placed last in CPUState.

Pass PowerPCCPU to [kvm]ppc_fixup_cpu() to facilitate this change.

Move common parts of mips cpu_state_reset() to mips_cpu_reset().

Acked-by: Richard Henderson <rth@twiddle.net> (for alpha)
[AF: Rebased onto ppc CPU subclasses and openpic changes]
Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agocpu: Move numa_node field to CPUState
Andreas Färber [Mon, 17 Dec 2012 03:22:03 +0000 (04:22 +0100)]
cpu: Move numa_node field to CPUState

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agotarget-mips: Clean up mips_cpu_map_tc() documentation
Andreas Färber [Mon, 17 Dec 2012 19:36:30 +0000 (20:36 +0100)]
target-mips: Clean up mips_cpu_map_tc() documentation

This function will be touched again soon, so a good understanding of env
vs. other helps. Adopt gtk-doc style.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Eric Johnson <ericj@mips.com>
11 years agocpu: Move nr_{cores,threads} fields to CPUState
Andreas Färber [Mon, 17 Dec 2012 02:27:07 +0000 (03:27 +0100)]
cpu: Move nr_{cores,threads} fields to CPUState

To facilitate the field movements, pass MIPSCPU to malta_mips_config();
avoid that for mips_cpu_map_tc() since callers only access MIPS Thread
Contexts, inside TCG helpers.

Signed-off-by: Andreas Färber <afaerber@suse.de>
11 years agopc87312: Avoid define conflict on mingw32
Blue Swirl [Sun, 13 Jan 2013 08:12:45 +0000 (08:12 +0000)]
pc87312: Avoid define conflict on mingw32

Mingw32 headers define FAR, causing this warning:
/src/qemu/hw/pc87312.c:38:0: warning: "FAR" redefined [enabled by default]
In file included from /usr/local/lib/gcc/i686-mingw32msvc/4.7.0/../../../../i686-mingw32msvc/include/windows.h:48:0,
                 from /src/qemu/include/sysemu/os-win32.h:29,
                 from /src/qemu/include/qemu-common.h:46,
                 from /src/qemu/include/exec/ioport.h:27,
                 from /src/qemu/hw/isa.h:6,
                 from /src/qemu/hw/pc87312.h:28,
                 from /src/qemu/hw/pc87312.c:26:
/usr/local/lib/gcc/i686-mingw32msvc/4.7.0/../../../../i686-mingw32msvc/include/windef.h:34:0: note: this is the location of the previous definition

Avoid the warning by expanding the macros.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Acked-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
11 years agopc87312: Replace register_ioport_*() with MemoryRegion
Andreas Färber [Fri, 11 Jan 2013 20:11:20 +0000 (21:11 +0100)]
pc87312: Replace register_ioport_*() with MemoryRegion

Prepare an instance_init function for the MemoryRegion init.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Tested-by: Hervé Poussineau <hpoussin@reactos.org>
11 years agovirtio-9p: fix compilation error.
KONRAD Frederic [Mon, 14 Jan 2013 21:52:02 +0000 (22:52 +0100)]
virtio-9p: fix compilation error.

Fix the compilation error introduced by msg new field.

CC    hw/9pfs/virtio-9p.o
In file included from /home/konradf/Documents/safe/greensocs/virtio-project/x86-qemu/qemu/hw/9pfs/virtio-9p.c:17:0:
/home/konradf/Documents/safe/greensocs/virtio-project/x86-qemu/qemu/hw/virtio-pci.h:30:16: erreur: field ‘msg’ has incomplete type
make: *** [hw/9pfs/virtio-9p.o] Erreur 1

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
11 years agoqga: add missing commas in json docs
Eric Blake [Wed, 2 Jan 2013 16:15:11 +0000 (09:15 -0700)]
qga: add missing commas in json docs

* qga/qapi-schema.json: Use valid JSON.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agodataplane: fix build breakage on set_guest_notifiers()
Michael Roth [Mon, 14 Jan 2013 19:20:13 +0000 (13:20 -0600)]
dataplane: fix build breakage on set_guest_notifiers()

virtio_pci_set_guest_notifiers() now takes an additional argument to
specify the number of virtqueues to assign a guest notifier for. This
causes a build breakage for CONFIG_VIRTIO_BLK_DATA_PLANE builds:

/home/mdroth/w/qemu2.git/hw/dataplane/virtio-blk.c: In function
‘virtio_blk_data_plane_start’:
/home/mdroth/w/qemu2.git/hw/dataplane/virtio-blk.c:451:47: error: too
few arguments to function ‘s->vdev->binding->set_guest_notifiers’
/home/mdroth/w/qemu2.git/hw/dataplane/virtio-blk.c: In function
‘virtio_blk_data_plane_stop’:
/home/mdroth/w/qemu2.git/hw/dataplane/virtio-blk.c:511:5: error: too few
arguments to function ‘s->vdev->binding->set_guest_notifiers’
make[1]: *** [hw/dataplane/virtio-blk.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [subdir-x86_64-softmmu] Error 2

Fix this by passing 1 as the number of virtqueues to assign notifiers
for.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agovirtio-pci: build for uninitialized return value in vq_vector_unmask
Michael Roth [Mon, 14 Jan 2013 19:20:12 +0000 (13:20 -0600)]
virtio-pci: build for uninitialized return value in vq_vector_unmask

Fixes the following:

/home/mdroth/w/qemu2.git/hw/virtio-pci.c: In function
‘kvm_virtio_pci_vector_unmask’:
/home/mdroth/w/qemu2.git/hw/virtio-pci.c:673:12: error: ‘ret’ may be
used uninitialized in this function [-Werror=uninitialized]
cc1: all warnings being treated as errors
make: *** [hw/virtio-pci.o] Error 1
make: *** Waiting for unfinished jobs....

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoAdd GE IP-Octal 232 IndustryPack emulation
Alberto Garcia [Fri, 11 Jan 2013 17:25:30 +0000 (18:25 +0100)]
Add GE IP-Octal 232 IndustryPack emulation

The GE IP-Octal 232 is an IndustryPack module that implements eight
RS-232 serial ports, each one of which can be redirected to a
character device in the host.

Signed-off-by: Alberto Garcia <agarcia@igalia.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoAdd TEWS TPCI200 IndustryPack emulation
Alberto Garcia [Fri, 11 Jan 2013 17:25:29 +0000 (18:25 +0100)]
Add TEWS TPCI200 IndustryPack emulation

The TPCI200 is a PCI board that supports up to 4 IndustryPack modules.

A new bus type called 'IndustryPack' has been created so any
compatible module can be attached to this board.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alberto Garcia <agarcia@igalia.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoxen_disk: implement BLKIF_OP_FLUSH_DISKCACHE, remove BLKIF_OP_WRITE_BARRIER
Stefano Stabellini [Mon, 14 Jan 2013 18:30:30 +0000 (18:30 +0000)]
xen_disk: implement BLKIF_OP_FLUSH_DISKCACHE, remove BLKIF_OP_WRITE_BARRIER

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
11 years agoxen_disk: add persistent grant support to xen_disk backend
Roger Pau Monne [Mon, 14 Jan 2013 18:28:19 +0000 (18:28 +0000)]
xen_disk: add persistent grant support to xen_disk backend

This protocol extension reuses the same set of grant pages for all
transactions between the front/back drivers, avoiding expensive tlb
flushes, grant table lock contention and switches between userspace
and kernel space. The full description of the protocol can be found in
the public blkif.h header.

http://xenbits.xen.org/gitweb/?p=xen.git;a=blob_plain;f=xen/include/public/io/blkif.h

Speed improvement with 15 guests performing I/O is ~450%.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
11 years agoxen_disk: fix memory leak
Roger Pau Monne [Mon, 14 Jan 2013 18:26:53 +0000 (18:26 +0000)]
xen_disk: fix memory leak

On ioreq_release the full ioreq was memset to 0, loosing all the data
and memory allocations inside the QEMUIOVector, which leads to a
memory leak. Create a new function to specifically reset ioreq.

Reported-by: Maik Wessler <maik.wessler@yahoo.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
11 years agoqemu-ga: Handle errors uniformely in ga_channel_open()
Markus Armbruster [Fri, 11 Jan 2013 10:25:02 +0000 (11:25 +0100)]
qemu-ga: Handle errors uniformely in ga_channel_open()

We detect errors in several places.  One reports with g_error(), which
calls abort(), the others report with g_critical().  Three of them
exit(), three return false.

Always report with g_critical(), and return false.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
*minor fix-up of commit msg

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: Plug fd leak on ga_channel_open() error paths
Markus Armbruster [Fri, 11 Jan 2013 10:25:01 +0000 (11:25 +0100)]
qemu-ga: Plug fd leak on ga_channel_open() error paths

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: Plug fd leak on ga_channel_listen_accept() error path
Markus Armbruster [Fri, 11 Jan 2013 10:25:00 +0000 (11:25 +0100)]
qemu-ga: Plug fd leak on ga_channel_listen_accept() error path

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: Plug file descriptor leak on ga_open_pidfile() error path
Markus Armbruster [Fri, 11 Jan 2013 10:24:59 +0000 (11:24 +0100)]
qemu-ga: Plug file descriptor leak on ga_open_pidfile() error path

Spotted by Coverity.  Also document why we keep it open on success.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: Drop pointless lseek() from ga_open_pidfile()
Markus Armbruster [Fri, 11 Jan 2013 10:24:58 +0000 (11:24 +0100)]
qemu-ga: Drop pointless lseek() from ga_open_pidfile()

After open(), the file offset is already zero, and neither lockf() nor
ftruncate() change 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>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: Document intentional fall through in channel_event_cb()
Markus Armbruster [Fri, 11 Jan 2013 10:24:57 +0000 (11:24 +0100)]
qemu-ga: Document intentional fall through in channel_event_cb()

For clarity, and to hush up Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: add ga_open_logfile()
Luiz Capitulino [Tue, 8 Jan 2013 21:26:26 +0000 (19:26 -0200)]
qemu-ga: add ga_open_logfile()

This function sets O_CLOEXEC on the log file fd so that it isn't
leaked to executed processes.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Amos Kong <akong@redhat.com>
Tested-by: Amos Kong <akong@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoqemu-ga: ga_open_pidfile(): use qemu_open()
Luiz Capitulino [Tue, 8 Jan 2013 21:26:25 +0000 (19:26 -0200)]
qemu-ga: ga_open_pidfile(): use qemu_open()

This ensures that O_CLOEXEC is passed to open(), this way the
pid file fd is not leaked to executed processes.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Amos Kong <akong@redhat.com>
Tested-by: Amos Kong <akong@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/pixman.v6' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:27:41 +0000 (10:27 -0600)]
Merge remote-tracking branch 'kraxel/pixman.v6' into staging

* kraxel/pixman.v6:
  pixman: pass extra cflags and ldflags

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/usb.76' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:27:29 +0000 (10:27 -0600)]
Merge remote-tracking branch 'kraxel/usb.76' into staging

* kraxel/usb.76:
  usb-host: Initialize dev->port the obviously safe way
  usb-host: Drop superfluous null test from usb_host_auto_scan()
  ehci: Assert state machine is sane w.r.t. EHCIQueue
  xhci: nuke transfe5rs on detach
  xhci: call xhci_detach_slot on root port detach too
  xhci: create xhci_detach_slot helper function

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'spice/spice.v67' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:27:08 +0000 (10:27 -0600)]
Merge remote-tracking branch 'spice/spice.v67' into staging

* spice/spice.v67:
  qxl: Don't drop client capability bits
  qxl: Fix SPICE_RING_PROD_ITEM(), SPICE_RING_CONS_ITEM() sanity check

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kraxel/testdev.2' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:26:57 +0000 (10:26 -0600)]
Merge remote-tracking branch 'kraxel/testdev.2' into staging

* kraxel/testdev.2:
  pc-testdev: use typedefs

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:26:26 +0000 (10:26 -0600)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony:
  dataplane: handle misaligned virtio-blk requests
  dataplane: extract virtio-blk read/write processing into do_rdwr_cmd()
  block: make qiov_is_aligned() public
  raw-posix: fix bdrv_aio_ioctl
  sheepdog: implement direct write semantics
  block: do not probe zero-sized disks

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'mst/tags/for_anthony' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:23:50 +0000 (10:23 -0600)]
Merge remote-tracking branch 'mst/tags/for_anthony' into staging

pci,virtio

This further optimizes MSIX handling in virtio-pci.
Also included is pci cleanup by Paolo, and pci device
assignment fix by Alex.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* mst/tags/for_anthony:
  pci-assign: Enable MSIX on device to match guest
  pci: use constants for devices under the 1B36 device ID, document them
  ivshmem: use symbolic constant for PCI ID, add to pci-ids.txt
  virtio-9p: use symbolic constant, add to pci-ids.txt
  reorganize pci-ids.txt
  docs: move pci-ids.txt to docs/specs/
  vhost: backend masking support
  vhost: set started flag while start is in progress
  virtio-net: set/clear vhost_started in reverse order
  virtio: backend virtqueue notifier masking
  virtio-pci: cache msix messages
  kvm: add stub for update msi route
  msix: add api to access msix message
  virtio: don't waste irqfds on control vqs

11 years agoMerge remote-tracking branch 'bonzini/stub' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:23:25 +0000 (10:23 -0600)]
Merge remote-tracking branch 'bonzini/stub' into staging

* bonzini/stub: (27 commits)
  build: improve quiet output for .stp rules
  build: fold trace-obj-y into libqemuutil.a
  build: some simplifications for "trace/Makefile.objs"
  build: remove coroutine-obj-y
  build: move version-obj-y to the generic LINK rule
  build: move base QAPI files to libqemuutil.a
  build: move QAPI definitions for QEMU out of qapi-obj-y
  build: consolidate multiple variables into universal-obj-y
  build: move qobject files to qobject/ and libqemuutil.a
  build: move libqemuutil.a components to util/
  build: move files away from tools-obj-y, common-obj-y, user-obj-y
  build: move util-obj-y to libqemuutil.a
  build: rename oslib-obj-y to util-obj-y
  libcacard: list oslib-obj-y file explicitly
  libcacard: link vscclient to dynamic library
  libcacard: rewrite Makefile in non-recursive style
  libcacard: add list of exported symbols
  libcacard: use per-target variable definitions
  libcacard: prepare to use -y trick in the Makefile
  libcacard: require libtool to build it
  ...

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'qmp/queue/qmp' into staging
Anthony Liguori [Mon, 14 Jan 2013 16:22:31 +0000 (10:22 -0600)]
Merge remote-tracking branch 'qmp/queue/qmp' into staging

* qmp/queue/qmp:
  monitor: assert monitor_puts()'s loop invariant
  target-i386: fix bits 39:32 of the final physical address when using 4M page

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agopixman: pass extra cflags and ldflags
Gerd Hoffmann [Fri, 4 Jan 2013 09:15:53 +0000 (10:15 +0100)]
pixman: pass extra cflags and ldflags

Store --extra-cflags and --extra-ldflags in config-host.mak,
then pass them on to the pixman configure script.

Cc: Scott Wood <scottwood@freescale.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb-host: Initialize dev->port the obviously safe way
Markus Armbruster [Thu, 10 Jan 2013 13:33:25 +0000 (14:33 +0100)]
usb-host: Initialize dev->port the obviously safe way

Coverity worries the strcpy() could overrun the destination.  It
can't, because the source always points to usb_host_scan()'s auto
port[], which has the same size.  Use pstrcpy() anyway, to hush the
checker.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agousb-host: Drop superfluous null test from usb_host_auto_scan()
Markus Armbruster [Thu, 10 Jan 2013 13:33:24 +0000 (14:33 +0100)]
usb-host: Drop superfluous null test from usb_host_auto_scan()

Coverity points out that port is later passed to usb_host_open(),
which dereferences it.  It actually can't be null: it always points to
usb_host_scan()'s auto port[].  Drop the superfluous port == NULL
test.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agoehci: Assert state machine is sane w.r.t. EHCIQueue
Markus Armbruster [Thu, 10 Jan 2013 13:33:23 +0000 (14:33 +0100)]
ehci: Assert state machine is sane w.r.t. EHCIQueue

Coverity worries the EHCIQueue pointer could be null when we pass it
to functions that reference it.  The state machine ensures it can't be
null then.  Assert that, to hush the checker.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agodataplane: handle misaligned virtio-blk requests
Stefan Hajnoczi [Fri, 11 Jan 2013 15:41:29 +0000 (16:41 +0100)]
dataplane: handle misaligned virtio-blk requests

O_DIRECT on Linux has alignment requirements on I/O buffers and
misaligned requests result in -EINVAL.  The Linux virtio_blk guest
driver usually submits aligned requests so I forgot to handle misaligned
requests.

It turns out that virtio-win guest drivers submit misaligned requests.
Handle them using a bounce buffer that meets alignment requirements.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agodataplane: extract virtio-blk read/write processing into do_rdwr_cmd()
Stefan Hajnoczi [Fri, 11 Jan 2013 15:41:28 +0000 (16:41 +0100)]
dataplane: extract virtio-blk read/write processing into do_rdwr_cmd()

Extract code for read/write command processing into do_rdwr_cmd().  This
brings together pieces that are spread across process_request().

The real motivation is to set the stage for handling misaligned
requests, which the next patch tackles.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: make qiov_is_aligned() public
Stefan Hajnoczi [Fri, 11 Jan 2013 15:41:27 +0000 (16:41 +0100)]
block: make qiov_is_aligned() public

The qiov_is_aligned() function checks whether a QEMUIOVector meets a
BlockDriverState's alignment requirements.  This is needed by
virtio-blk-data-plane so:

1. Move the function from block/raw-posix.c to block/block.c.
2. Make it public in block/block.h.
3. Rename to bdrv_qiov_is_aligned().
4. Change return type from int to bool.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoraw-posix: fix bdrv_aio_ioctl
Paolo Bonzini [Thu, 10 Jan 2013 14:28:35 +0000 (15:28 +0100)]
raw-posix: fix bdrv_aio_ioctl

When the raw-posix aio=thread code was moved from posix-aio-compat.c
to block/raw-posix.c, there was an unintended change to the ioctl code.
The code used to return the ioctl command, which posix_aio_read()
would later morph into a zero.  This hack is not necessary anymore,
and in fact breaks scsi-generic (which expects a zero return code).
Remove it.

Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agosheepdog: implement direct write semantics
Liu Yuan [Thu, 10 Jan 2013 08:03:47 +0000 (16:03 +0800)]
sheepdog: implement direct write semantics

Sheepdog supports both writeback/writethrough write but has not yet supported
DIRECTIO semantics which bypass the cache completely even if Sheepdog daemon is
set up with cache enabled.

Suppose cache is enabled on Sheepdog daemon size, the new cache control is

cache=writeback # enable the writeback semantics for write
cache=writethrough # enable the emulated writethrough semantics for write
cache=directsync # disable cache competely

Guest WCE toggling on the run time to toggle writeback/writethrough is also
supported.

Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoblock: do not probe zero-sized disks
Paolo Bonzini [Thu, 10 Jan 2013 14:39:27 +0000 (15:39 +0100)]
block: do not probe zero-sized disks

A blank CD or DVD is visible as a zero-sized disks.  Probing such
disks will lead to an EIO and a failure to start the VM.  Treating
them as raw is a better solution.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>