sdk/emulator/qemu.git
12 years agoqmp: emit the WAKEUP event when the guest is put to run
Luiz Capitulino [Thu, 9 Aug 2012 14:27:30 +0000 (11:27 -0300)]
qmp: emit the WAKEUP event when the guest is put to run

Today, the WAKEUP event is emitted when a wakeup _request_ is made.
This could be the system_wakeup command, for example.

A better semantic would be to emit the event when the guest is
already running, as that's what matters in the end. This commit does
that change.

In theory, this could break compatibility. In practice, it shouldn't
happen though, as clients shouldn't rely on timing characteristics of
the events. That is, a client relying that the guest is not running
when the event arrives may break if the event arrives after the guest
is already running.

This commit also adds the missing documentation for the WAKEUP event.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoqmp: don't emit the RESET event on wakeup from S3
Luiz Capitulino [Wed, 8 Aug 2012 20:29:17 +0000 (17:29 -0300)]
qmp: don't emit the RESET event on wakeup from S3

QEMU is basically using reset logic when waking up from S3. This
causes the QMP RESET event to be emitted, which is wrong. Also,
the runstate checks done in reset are not necessary for S3 wakeup.

Fix this by untangling wakeup from reset logic and passing
VMRESET_SILENT to qemu_system_reset() to avoid emitting the RESET
event.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
12 years agoscripts: qapi-commands.py: qmp-commands.h: include qdict.h
Luiz Capitulino [Mon, 6 Aug 2012 14:35:22 +0000 (11:35 -0300)]
scripts: qapi-commands.py: qmp-commands.h: include qdict.h

qmp-commands.h declares several functions that have arguments of
type QDict. However, qdict.h is not included. This will cause a
build breakage when a file includes qmp-commands.h but doesn't
include qdict.h.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agodocs: writing-qmp-commands.txt: update error section
Luiz Capitulino [Mon, 6 Aug 2012 14:35:22 +0000 (11:35 -0300)]
docs: writing-qmp-commands.txt: update error section

Add information about the new error format and improve the text a bit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoerror, qerror: drop QDict member
Luiz Capitulino [Wed, 1 Aug 2012 21:06:44 +0000 (18:06 -0300)]
error, qerror: drop QDict member

Used to store error information, but it's unused now.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: drop qerror_table and qerror_format()
Luiz Capitulino [Fri, 27 Jul 2012 21:11:16 +0000 (18:11 -0300)]
qerror: drop qerror_table and qerror_format()

They are unused since last commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoerror, qerror: pass desc string to error calls
Luiz Capitulino [Fri, 27 Jul 2012 20:51:03 +0000 (17:51 -0300)]
error, qerror: pass desc string to error calls

This commit changes all QERR_ macros to contain a human message (ie.
the desc string found in qerr_table[]) instead of a json dictionary
in string format.

Before this commit, error_set() and qerror_report() would receive
a json dictionary in string format and build a qobject from it. Now,
both function receive a human message instead and the qobject is
not built anymore.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoerror: drop error_get_qobject()/error_set_qobject()
Luiz Capitulino [Wed, 1 Aug 2012 20:59:59 +0000 (17:59 -0300)]
error: drop error_get_qobject()/error_set_qobject()

error_get_qobject() is unused since last commit, error_set_qobject()
has never been used. Also drops error_int.h.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqemu-ga: switch to the new error format on the wire
Luiz Capitulino [Wed, 1 Aug 2012 19:30:13 +0000 (16:30 -0300)]
qemu-ga: switch to the new error format on the wire

IMPORTANT: this BREAKS qemu-ga compatibility for the error response.

Instead of returning something like:

{ "error": { "class": "InvalidParameterValue",
             "data": {"name": "mode", "expected": "halt|powerdown|reboot" } } }

qemu-ga now returns:

 { "error": { "class": "GenericError",
              "desc": "Parameter 'mode' expects halt|powerdown|reboot" } }

Notice that this is also a bug fix, as qemu-ga wasn't returning the
human message.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqmp: switch to the new error format on the wire
Luiz Capitulino [Fri, 27 Jul 2012 19:18:16 +0000 (16:18 -0300)]
qmp: switch to the new error format on the wire

IMPORTANT: this BREAKS QMP's compatibility for the error response.

This commit changes QMP's wire protocol to make use of the simpler
error format introduced by previous commits.

There are two important (and mostly incompatible) changes:

 1. Almost all error classes have been replaced by GenericError. The
    only classes that are still supported for compatibility with
    libvirt are: CommandNotFound, DeviceNotActive, KVMMissingCap,
    DeviceNotFound and MigrationExpected

 2. The 'data' field of the error dictionary is gone

As an example, an error response like:

  { "error": { "class": "DeviceNotRemovable",
               "data": { "device": "virtio0" },
               "desc": "Device 'virtio0' is not removable" } }

Will now be emitted as:

  { "error": { "class": "GenericError",
               "desc": "Device 'virtio0' is not removable" } }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoerror: drop unused functions
Luiz Capitulino [Fri, 27 Jul 2012 00:30:40 +0000 (21:30 -0300)]
error: drop unused functions

Besides being unused, they operate on the current error format,
which is going to be replaced soon.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agohmp: hmp_change(): use error_get_class()
Luiz Capitulino [Mon, 6 Aug 2012 18:55:22 +0000 (15:55 -0300)]
hmp: hmp_change(): use error_get_class()

The error_is_type() function is going to be dropped.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoerror: add error_get_class()
Luiz Capitulino [Wed, 1 Aug 2012 19:29:38 +0000 (16:29 -0300)]
error: add error_get_class()

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: add proper ErrorClass value for QERR_ macros
Luiz Capitulino [Fri, 27 Jul 2012 18:50:19 +0000 (15:50 -0300)]
qerror: add proper ErrorClass value for QERR_ macros

This commit replaces the place holder value for the ErrorClass
argument with a proper ErrorClass value for all QERR_ macros.

All current errors are mapped to GenericError, except for errors
CommandNotFound, DeviceEncrypted, DeviceNotActive, DeviceNotFound,
KVMMissingCap and MigrationExpected, which are maintained as they
are today.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoerror, qerror: add ErrorClass argument to error functions
Luiz Capitulino [Fri, 27 Jul 2012 17:09:29 +0000 (14:09 -0300)]
error, qerror: add ErrorClass argument to error functions

The new argument is added to functions qerror_report() and error_set().
It's stored in Error and QError. qerror_report_err() is also updated to
take care of it.

The QERR_ macros are changed to contain a place holder value for the
new argument, so that the value is used on all current calls to
qerror_report() and error_set() (and also to initialize qerror_table[]).

Next commit will update the QERR_ macros with a proper ErrorClass
value.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: qerror_table: don't use C99 struct initializers
Luiz Capitulino [Fri, 27 Jul 2012 16:58:30 +0000 (13:58 -0300)]
qerror: qerror_table: don't use C99 struct initializers

This allows for changing QERR_ macros to initialize two struct members
at the same time. See next commit for more details.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqapi-schema: add ErrorClass enum
Luiz Capitulino [Fri, 27 Jul 2012 12:34:50 +0000 (09:34 -0300)]
qapi-schema: add ErrorClass enum

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqapi: don't convert enum strings to lowercase
Luiz Capitulino [Fri, 27 Jul 2012 12:38:05 +0000 (09:38 -0300)]
qapi: don't convert enum strings to lowercase

Next commit will introduce enum strings in camel case.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqapi: generate correct enum names for camel case enums
Luiz Capitulino [Fri, 27 Jul 2012 18:44:25 +0000 (15:44 -0300)]
qapi: generate correct enum names for camel case enums

An enum like GenericError in the schema, should generate
GENERIC_ERROR and not GENERICERROR.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqapi: qapi-types.h: don't include qapi/qapi-types-core.h
Luiz Capitulino [Fri, 27 Jul 2012 13:56:33 +0000 (10:56 -0300)]
qapi: qapi-types.h: don't include qapi/qapi-types-core.h

qapi-types.h needs only qemu-common.h. Including qapi-types-core.h
causes problems when qerror.h or error.h includes qapi-types.h.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agohmp: hmp.h: include qdict.h
Luiz Capitulino [Fri, 27 Jul 2012 13:55:29 +0000 (10:55 -0300)]
hmp: hmp.h: include qdict.h

hmp.h is relying on qdict.h being provided by qapi-types.h. Fix this,
as a future commit will change qapi-types.h not to provide qdict.h.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoblock: block_int: include qerror.h
Luiz Capitulino [Fri, 27 Jul 2012 13:52:18 +0000 (10:52 -0300)]
block: block_int: include qerror.h

Several block/ files are relying on qerror.h being provided by
qapi-types.h. Fix this, as a future commit will change qapi-types.h
not to provide qerror.h.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: drop QERR_SOCKET_CONNECT_IN_PROGRESS
Luiz Capitulino [Wed, 1 Aug 2012 17:26:53 +0000 (14:26 -0300)]
qerror: drop QERR_SOCKET_CONNECT_IN_PROGRESS

Unused since last commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agomigration: don't rely on any QERR_SOCKET_*
Luiz Capitulino [Mon, 6 Aug 2012 19:26:47 +0000 (16:26 -0300)]
migration: don't rely on any QERR_SOCKET_*

Use the in_progress argument for QERR_SOCKET_CONNECT_IN_PROGRESS. The
other errors are handled the same by checking if the error is set and
then calling migrate_fd_error() if it's.

It's also necessary to change inet_connect_opts() not to set
QERR_SOCKET_CONNECT_IN_PROGRESS. This error is only used by
tcp_start_outgoing_migration() and not changing it along with the
usage of in_progress would break migration.

Furthermore this commit fixes a bug. Today, there's a spurious error
report when migration succeeds:

(qemu) migrate tcp:0:4444
migrate: Connection can not be completed immediately
(qemu)

After this commit no spurious error is reported anymore.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agonet: inet_connect(), inet_connect_opts(): add in_progress argument
Luiz Capitulino [Wed, 1 Aug 2012 16:42:47 +0000 (13:42 -0300)]
net: inet_connect(), inet_connect_opts(): add in_progress argument

It's used to indicate the special case where a valid file-descriptor
is returned (ie. success) but the connection can't be completed
w/o blocking.

This is needed because QERR_SOCKET_CONNECT_IN_PROGRESS is not
treated like an error and a future commit will drop it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agohmp_change(): don't access DeviceEncrypted's data
Luiz Capitulino [Mon, 6 Aug 2012 18:49:34 +0000 (15:49 -0300)]
hmp_change(): don't access DeviceEncrypted's data

It's not needed. As the device name is already known, we can replace
the duplicated password prompting code by monitor_read_block_device_key().

This overly simplifies hmp_change().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agohmp: hmp_cont(): don't rely on QERR_DEVICE_ENCRYPTED
Luiz Capitulino [Thu, 26 Jul 2012 23:41:53 +0000 (20:41 -0300)]
hmp: hmp_cont(): don't rely on QERR_DEVICE_ENCRYPTED

This commit changes hmp_cont() to loop through all block devices
and proactively set an encryption key for any encrypted device
missing a key.

This change is needed because QERR_DEVICE_ENCRYPTED is going to be
dropped by a future commit.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqmp: query-block: add 'encryption_key_missing' field
Luiz Capitulino [Thu, 26 Jul 2012 23:28:44 +0000 (20:28 -0300)]
qmp: query-block: add 'encryption_key_missing' field

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoerror: don't delay error message construction
Luiz Capitulino [Fri, 20 Jul 2012 16:43:37 +0000 (13:43 -0300)]
error: don't delay error message construction

Today, the error message is only constructed when it's used. This commit
changes that to construct the error message when the error object is
built (ie. when the error is reported).

This simplifies the Error object.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: don't delay error message construction
Luiz Capitulino [Fri, 20 Jul 2012 15:02:58 +0000 (12:02 -0300)]
qerror: don't delay error message construction

Today, the error message is only constructed when it's used. This commit
changes qerror to construct the error message when the error object is
built (ie. when the error is reported).

This eliminates the need of storing a pointer to qerror_table[], which
will be dropped soon, and also simplifies the code.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: qerror_format(): return an allocated string
Luiz Capitulino [Fri, 20 Jul 2012 16:30:18 +0000 (13:30 -0300)]
qerror: qerror_format(): return an allocated string

Simplifies current and future users.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: QError: drop file, linenr, func
Luiz Capitulino [Fri, 20 Jul 2012 14:08:17 +0000 (11:08 -0300)]
qerror: QError: drop file, linenr, func

They have never been fully used and conflict with future error
improvements.

Also makes qerror_report() a proper function, as there's no point
in having it as a macro anymore.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: avoid passing qerr pointer
Luiz Capitulino [Tue, 31 Jul 2012 18:41:13 +0000 (15:41 -0300)]
qerror: avoid passing qerr pointer

Helps dropping/modifying qerror functions.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: drop qerror_abort()
Luiz Capitulino [Fri, 20 Jul 2012 13:35:18 +0000 (10:35 -0300)]
qerror: drop qerror_abort()

qerror_abort() depends on the 'file', 'func' and 'linenr' members of
QError. However, these members are going to be dropped by the next
commit, so let's drop qerror_abort() in favor of printing an error
message to stderr plus a call to abort().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: reduce public exposure
Luiz Capitulino [Thu, 19 Jul 2012 20:29:34 +0000 (17:29 -0300)]
qerror: reduce public exposure

qerror will be dropped in a near future, let's reduce its public
exposure by making functions only used in qerror.c static.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: QERR_DEVICE_ENCRYPTED: change error message
Luiz Capitulino [Wed, 25 Jul 2012 16:16:53 +0000 (13:16 -0300)]
qerror: QERR_DEVICE_ENCRYPTED: change error message

Match what HMP commands print on DeviceEncrypted errors.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqerror: QERR_AMBIGUOUS_PATH: drop %(object) from human msg
Luiz Capitulino [Wed, 25 Jul 2012 16:18:41 +0000 (13:18 -0300)]
qerror: QERR_AMBIGUOUS_PATH: drop %(object) from human msg

Actually, renames it to 'object'. This must be what the original author
meant to write, as there's no 'object' in the error's data member.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agomonitor: drop unused monitor debug code
Luiz Capitulino [Thu, 19 Jul 2012 22:34:38 +0000 (19:34 -0300)]
monitor: drop unused monitor debug code

In the old QMP days, this code was used to find out QMP commands that
might be calling monitor_printf() down its call chain.

This is almost impossible to happen today, because the qapi converted
commands don't even have a monitor object. Besides, it's been more than
a year since I used this last time.

Let's just drop it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12 years agoqom: Reimplement Interfaces
Anthony Liguori [Fri, 10 Aug 2012 03:16:10 +0000 (13:16 +1000)]
qom: Reimplement Interfaces

The current implementation of Interfaces is poorly designed.  Each interface
that an object implements ends up being an object that's tracked by the
implementing object.  There's all sorts of gymnastics to deal with casting
between these objects.

But an interface shouldn't be associated with an Object.  Interfaces are global
to a class.  This patch moves all Interface knowledge to ObjectClass eliminating
the relationship between Object and Interfaces.

Interfaces are now abstract (as they should be) but this is okay.  Interfaces
essentially act as additional parents for the classes and are treated as such.

With this new implementation, we should fully support derived interfaces
including reimplementing an inherited interface.

PC: Rebased against qom-next merge Jun-2012.

PC: Removed replication of cast logic for interfaces, i.e. there is only
one cast function - object_dynamic_cast() (and object_dynamic_cast_assert())

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
12 years agoxilinx_axi*: Re-implemented interconnect
Peter A. G. Crosthwaite [Fri, 10 Aug 2012 03:16:11 +0000 (13:16 +1000)]
xilinx_axi*: Re-implemented interconnect

Re-implemented the interconnect between the Xilinx AXI ethernet and DMA
controllers. A QOM interface "stream" is created, for the two stream interfaces.

As per Edgars request, this is designed to be more generic than AXI-stream,
so in the future we may see more clients of this interface beyond AXI stream.

This is based primarily on Paolos original refactoring of the interconnect.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter A.G. Crosthwaite <peter.crosthwaite@petalogix.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
12 years agoMerge remote-tracking branch 'stefanha/trivial-patches' into staging
Anthony Liguori [Sun, 12 Aug 2012 00:49:03 +0000 (19:49 -0500)]
Merge remote-tracking branch 'stefanha/trivial-patches' into staging

* stefanha/trivial-patches:
  target-arm: Fix typos in comments
  arm: translate: comment typo - s/middel/middle/
  vl.c: Exit QEMU early if no machine is found

12 years agoMerge remote-tracking branch 'kwolf/for-anthony' into staging
Anthony Liguori [Sun, 12 Aug 2012 00:48:50 +0000 (19:48 -0500)]
Merge remote-tracking branch 'kwolf/for-anthony' into staging

* kwolf/for-anthony:
  qemu-iotests: skip 039 with ./check -nocache
  block: add BLOCK_O_CHECK for qemu-img check
  qcow2: mark image clean after repair succeeds
  qed: mark image clean after repair succeeds
  blockdev: flip default cache mode from writethrough to writeback
  virtio-blk: disable write cache if not negotiated
  virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE
  qemu-iotests: Save some sed processes
  ahci: Fix sglist memleak in ahci_dma_rw_buf()
  ahci: Fix ahci cdrom read corruptions for reads > 128k
  virtio-blk: fix use-after-free while handling scsi commands

12 years agoMerge remote-tracking branch 'bonzini/scsi-next' into staging
Anthony Liguori [Sat, 11 Aug 2012 22:11:23 +0000 (17:11 -0500)]
Merge remote-tracking branch 'bonzini/scsi-next' into staging

* bonzini/scsi-next:
  scsi-disk: add support for the UNMAP command
  scsi-disk: improve out-of-range LBA detection for WRITE SAME
  scsi-disk: more assertions and resets for aiocb
  virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags
  iscsi: Pick default initiator-name based on the name of the VM
  iscsi: reorganize code for parse_initiator_name
  iscsi: do not leak initiator_name

12 years agoconfigure: fix double check tests with Clang
Blue Swirl [Thu, 9 Aug 2012 20:21:25 +0000 (20:21 +0000)]
configure: fix double check tests with Clang

Configuring with Clang compiler with -Werror would not work after
improved checks:
/tmp/qemu-conf--25992-.c:4:32: error: self-comparison always evaluates
to true [-Werror,-Wtautological-compare]
int main(void) { return preadv == preadv; }
/tmp/qemu-conf--25992-.c:13:26: error: self-comparison always
evaluates to true [-Werror,-Wtautological-compare]
    return epoll_create1 == epoll_create1;
/tmp/qemu-conf--25992-.c:3:13: error: explicitly assigning a variable
of type 'char **' to itself [-Werror,-Wself-assign]
    environ = environ;

Avoid the errors by adjusting the tests.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoconfigure: Check for -Werror causing failures when compiling tests
Peter Maydell [Wed, 18 Jul 2012 14:10:28 +0000 (15:10 +0100)]
configure: Check for -Werror causing failures when compiling tests

Add support for checking whether test case code can compile without
warnings, by recompiling each successful test with -Werror. If the
-Werror version doesn't pass, we bail out. This gives us the same
level of visibility of warnings in test code as --enable-werror
provides for the main compile.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoexec.c: fix dirty bitmap reallocation
Igor Mitsyanko [Fri, 10 Aug 2012 14:45:11 +0000 (18:45 +0400)]
exec.c: fix dirty bitmap reallocation

For each newly created RAM block, dirty bitmap is reallocated with g_realloc, which doesn't
make any promises on initial content of new extra data in returned buffer. In theory,
we initialize this new data with cpu_physical_memory_set_dirty_range() call. The
problem is, cpu_physical_memory_set_dirty_range() has a side effect of incrementing
ram_list.dirty_pages variable, but only for pages which are not already dirty. And
page "cleanliness" is determined using the same not yet uninitialized dirty bitmap
we've just reallocated. This results in inconsistency between real dirty page number
and value in ram_list.dirty_pages variable, which in turn could (and will) result
in errors during VM migration.
Zero initialize new dirty bitmap bytes to fix this problem.

Signed-off-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMakefile: add qapi.py dependencies
Stefan Hajnoczi [Fri, 10 Aug 2012 13:08:42 +0000 (14:08 +0100)]
Makefile: add qapi.py dependencies

Commit 427a1a2cb1d35b83b6302886f46289f6d617134d ("qapi: avoid reserved
keywords") modifies qapi.py, which is used by qapi-types.py and other
Python scripts.  Because Makefile has no dependencies for qapi.py the
qapi code generator will not be rerun and the following build error is
produced:

  net/slirp.c: In function ‘net_init_slirp’:
  net/slirp.c:721:50: error: ‘NetdevUserOptions’ has no member named ‘q_restrict’

Fix this issue by adding the missing qapi.py dependencies.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add a minimal curses screen support
Guan Xuetao [Fri, 10 Aug 2012 06:42:39 +0000 (14:42 +0800)]
unicore32-softmmu: Add a minimal curses screen support

This patch adds a minimal curses screen support for unicore32-softmmu.
We assume 80*30 screen size to minimize the implementation.
Two problems are not solved, but they are innocuous.
1. curses windows will be blank when switching to monitor screen and back
2. backspace is not handled yet

v1->v2: add extra handler for '\r'

Signed-off-by: Zhang Mengchi <zhangmengchi@mprc.pku.edu.cn>
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32: Close dump-option of cpu_dump_state_ucf64 function
Guan Xuetao [Fri, 10 Aug 2012 06:42:38 +0000 (14:42 +0800)]
unicore32: Close dump-option of cpu_dump_state_ucf64 function

Since of tedious output, we close dump-option of cpu_dump_state_ucf64 function.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32: Disintegrate cpu_dump_state_ucf64 function
Guan Xuetao [Fri, 10 Aug 2012 06:42:37 +0000 (14:42 +0800)]
unicore32: Disintegrate cpu_dump_state_ucf64 function

This patch disintegrates cpu_dump_state_ucf64 function from cpu_dump_state.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32: Split UniCore-F64 instruction helpers from helper.c
Guan Xuetao [Fri, 10 Aug 2012 06:42:36 +0000 (14:42 +0800)]
unicore32: Split UniCore-F64 instruction helpers from helper.c

This patch just splits ucf64 instruction simulation helpers from
helper.c.
Also, two checkpatch warnings are solved.

v1->v2: adjust copyright information for new ucf64_helper.c

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add is_default setting for puv3 machine
Guan Xuetao [Fri, 10 Aug 2012 06:42:35 +0000 (14:42 +0800)]
unicore32-softmmu: Add is_default setting for puv3 machine

This patch sets is_default to 1 for puv3 machine, so that
find_default_machine() returns puv3 machine.
Thanks Dunrong for pointing it out.

Cc: Dunrong Huang <riegamaths@gmail.com>
Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add maintainer information for UniCore32 machine
Guan Xuetao [Fri, 10 Aug 2012 06:42:34 +0000 (14:42 +0800)]
unicore32-softmmu: Add maintainer information for UniCore32 machine

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add ps2 support
Guan Xuetao [Fri, 10 Aug 2012 06:42:33 +0000 (14:42 +0800)]
unicore32-softmmu: Add ps2 support

This patch adds ps2/keyboard support, and enables CONFIG_PCKBD.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 dma support
Guan Xuetao [Fri, 10 Aug 2012 06:42:32 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 dma support

This patch adds puv3 dma (Direct Memory Access) support,
include dma device simulation for kernel booting.

v1->v2: Add initialization to ret in puv3_dma_read.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 pm support
Guan Xuetao [Fri, 10 Aug 2012 06:42:31 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 pm support

This patch adds puv3 pm (power management) support,
include pm device simulation for kernel booting.
Thank Blue Swirl for pointing out the missing "break".

v1->v2: Add initialization to ret in puv3_pm_read.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 gpio support
Guan Xuetao [Fri, 10 Aug 2012 06:42:30 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 gpio support

This patch adds puv3 gpio (General Purpose Input/Output) support,
include gpio device simulation and its interrupt support.

v1->v2: Add initialization to ret in puv3_gpio_read.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 ostimer support
Guan Xuetao [Fri, 10 Aug 2012 06:42:29 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 ostimer support

This patch adds puv3 ostimer support, include os timer
device simulation and ptimer support in puv3 machine.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 interrupt support
Guan Xuetao [Fri, 10 Aug 2012 06:42:28 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 interrupt support

This patch adds puv3 interrupt support, include interrupt controler
device simulation and interrupt handler in puv3 machine.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add puv3 soc/board support
Guan Xuetao [Fri, 10 Aug 2012 06:42:27 +0000 (14:42 +0800)]
unicore32-softmmu: Add puv3 soc/board support

This patch only add puv3 soc/board support, which introduces puv3
machine description, and specifies console type.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Make sure that kernel can access user space
Guan Xuetao [Fri, 10 Aug 2012 06:42:26 +0000 (14:42 +0800)]
unicore32-softmmu: Make sure that kernel can access user space

As a matter of course, we need to access user space in kernel code,
so we need to correct load/store decoders to indicate correct memory
region.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Implement softmmu specific functions
Guan Xuetao [Fri, 10 Aug 2012 06:42:25 +0000 (14:42 +0800)]
unicore32-softmmu: Implement softmmu specific functions

This patch implements softmmu specific functions, include tlb_fill,
switch_mode, do_interrupt and uc32_cpu_handle_mmu_fault.
So the full exception handlers and page table walking could work now.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-unicore32: Drop UC32_CPUID macros
Andreas Färber [Fri, 10 Aug 2012 06:42:24 +0000 (14:42 +0800)]
target-unicore32: Drop UC32_CPUID macros

Any code that depends on a particular CPU type can now go through
callbacks on the QOM UniCore32CPUClass.

Signed-off-by: Andreas Färber <afaerber@suse.de
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Make UniCore32 cpuid & exceptions correct and runable
Guan Xuetao [Fri, 10 Aug 2012 06:42:23 +0000 (14:42 +0800)]
unicore32-softmmu: Make UniCore32 cpuid & exceptions correct and runable

This patch initializes the cpuid to exactly correct value because
linux kernel will check it.
In addition, the exception types are specified in proper situations.
Then it could make exceptions generated correctly and timely.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add coprocessor 0(sysctrl) and 1(ocd) instruction support
Guan Xuetao [Fri, 10 Aug 2012 06:42:22 +0000 (14:42 +0800)]
unicore32-softmmu: Add coprocessor 0(sysctrl) and 1(ocd) instruction support

Coprocessor 0 is system control coprocessor, and we need get/set its contents.
Also, all cache/tlb ops shoule be implemented here, but just ignored with no harm.

Coprocessor 1 is OCD (on-chip-debugger), which is used for faked console,
so we could output chars to this console without graphic card.
TODO: curses display should be added lator for screen output.

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agounicore32-softmmu: Add unicore32-softmmu build support
Guan Xuetao [Fri, 10 Aug 2012 06:42:21 +0000 (14:42 +0800)]
unicore32-softmmu: Add unicore32-softmmu build support

This patch adds unicore32-softmmu build support, include configure,
makefile, arch_init, and all missing functions needed by softmmu.
Although all missing functions are empty, unicore32-softmmu could
be build successfully.
By 20120804: change QEMU_ARCH_UNICORE32 to 0x4000

Signed-off-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-arm: Fix typos in comments
Peter Maydell [Mon, 6 Aug 2012 16:42:18 +0000 (17:42 +0100)]
target-arm: Fix typos in comments

Fix a variety of typos in comments in target-arm files.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoarm: translate: comment typo - s/middel/middle/
Peter A. G. Crosthwaite [Mon, 6 Aug 2012 07:05:56 +0000 (17:05 +1000)]
arm: translate: comment typo - s/middel/middle/

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agovl.c: Exit QEMU early if no machine is found
Dunrong Huang [Mon, 23 Jul 2012 16:42:20 +0000 (00:42 +0800)]
vl.c: Exit QEMU early if no machine is found

We check whether the variable machine is NULL or not before accessing
it. If machine is NULL, exit QEMU with an error, this can avoids a
segfault error.

Markus Armbruster <armbru@redhat.com> adds that the segfault can be
reproduced as follows:

  $ qemu-system-xtensa -cpu help

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoqemu-iotests: skip 039 with ./check -nocache
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:57 +0000 (13:05 +0100)]
qemu-iotests: skip 039 with ./check -nocache

When the qemu-io --nocache option is used the 039 test case cannot abort
QEMU at a point where the image is dirty.  Skip the test case.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: add BLOCK_O_CHECK for qemu-img check
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:56 +0000 (13:05 +0100)]
block: add BLOCK_O_CHECK for qemu-img check

Image formats with a dirty bit, like qed and qcow2, repair dirty image
files upon open with BDRV_O_RDWR.  Performing automatic repair when
qemu-img check runs is not ideal because the bdrv_open() call repairs
the image before the actual bdrv_check() call from qemu-img.c.

Fix this "double repair" since it leads to confusing output from
qemu-img check.  Tell the block driver that this image is being opened
just for bdrv_check().  This skips automatic repair and qemu-img.c can
invoke it manually with bdrv_check().

Update the golden output for qemu-iotests 039 to reflect the new
qemu-img check output.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: mark image clean after repair succeeds
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:55 +0000 (13:05 +0100)]
qcow2: mark image clean after repair succeeds

The dirty bit is cleared after image repair succeeds in qcow2_open().
Move this into qcow2_check() so that all callers benefit from this
behavior when fix mode is enabled.

This is necessary so qemu-img check can call .bdrv_check() and mark the
image clean.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqed: mark image clean after repair succeeds
Stefan Hajnoczi [Thu, 9 Aug 2012 12:05:54 +0000 (13:05 +0100)]
qed: mark image clean after repair succeeds

The dirty bit is cleared after image repair succeeds in qed_open().
Move this into qed_check() so that all callers benefit from this
behavior when fix=true.

This is necessary so qemu-img check can call .bdrv_check() and mark the
image clean.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblockdev: flip default cache mode from writethrough to writeback
Paolo Bonzini [Thu, 9 Aug 2012 14:07:21 +0000 (16:07 +0200)]
blockdev: flip default cache mode from writethrough to writeback

Now all major device models (IDE, SCSI, virtio) can choose between
writethrough and writeback at run-time, and virtio will even revert
to writethrough if the guest is not capable of sending flushes.  So
we can change the default to writeback at last.

Tested, for lack of a better idea, with a breakpoint on bdrv_open
and all cache choices one by one.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio-blk: disable write cache if not negotiated
Paolo Bonzini [Thu, 9 Aug 2012 14:07:20 +0000 (16:07 +0200)]
virtio-blk: disable write cache if not negotiated

If the guest does not support flushes, we should run in writethrough mode.
The setting is temporary until the next reset, so that for example the
BIOS will run in writethrough mode while Linux will run with a writeback
cache.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio-blk: support VIRTIO_BLK_F_CONFIG_WCE
Paolo Bonzini [Thu, 9 Aug 2012 14:07:19 +0000 (16:07 +0200)]
virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE

Also rename VIRTIO_BLK_F_WCACHE to VIRTIO_BLK_F_WCE for consistency with
the spec.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-iotests: Save some sed processes
Kevin Wolf [Thu, 9 Aug 2012 11:17:14 +0000 (13:17 +0200)]
qemu-iotests: Save some sed processes

Instead of building a huge pipeline, just pass all expressions to a
single sed process.

Suggested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
12 years agoahci: Fix sglist memleak in ahci_dma_rw_buf()
Jason Baron [Fri, 3 Aug 2012 19:57:10 +0000 (15:57 -0400)]
ahci: Fix sglist memleak in ahci_dma_rw_buf()

I noticed that in hw/ide/ahci:ahci_dma_rw_buf() we do not free the sglist. Thus,
I've added a call to qemu_sglist_destroy() to fix this memory leak.

In addition, I've adeed a call in qemu_sglist_destroy() to 0 all of the sglist
fields, in case there is some other codepath that tries to free the sglist.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoahci: Fix ahci cdrom read corruptions for reads > 128k
Jason Baron [Fri, 3 Aug 2012 19:57:06 +0000 (15:57 -0400)]
ahci: Fix ahci cdrom read corruptions for reads > 128k

While testing q35, which has its cdrom attached to the ahci controller, I found
that the Fedora 17 install would panic on boot. The panic occurs while
squashfs is trying to read from the cdrom. The errors are:

[    8.622711] SQUASHFS error: xz_dec_run error, data probably corrupt
[    8.625180] SQUASHFS error: squashfs_read_data failed to read block
0x20be48a

I was also able to produce corrupt data reads using an installed piix based
qemu machine, using 'dd'. I found that the corruptions were only occuring when
then read size was greater than 128k. For example, the following command
results in corrupted reads:

dd if=/dev/sr0 of=/tmp/blah bs=256k iflag=direct

The > 128k size reads exercise a different code path than 128k and below. In
ide_atapi_cmd_read_dma_cb() s->io_buffer_size is capped at 128k. Thus,
ide_atapi_cmd_read_dma_cb() is called a second time when the read is > 128k.
However, ahci_dma_rw_buf() restart the read from offset 0, instead of at 128k.
Thus, resulting in a corrupted read.

To fix this, I've introduced 'io_buffer_offset' field in IDEState to keep
track of the offset. I've also modified ahci_populate_sglist() to take a new
3rd offset argument, so that the sglist is property initialized.

I've tested this patch using 'dd' testing, and Fedora 17 now correctly boots
and installs on q35 with the cdrom ahci controller.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Tested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovirtio-blk: fix use-after-free while handling scsi commands
Avi Kivity [Mon, 6 Aug 2012 12:49:03 +0000 (15:49 +0300)]
virtio-blk: fix use-after-free while handling scsi commands

The scsi passthrough handler falls through after completing a
request into the failure path, resulting in a use after free.

Reproducible by running a guest with aio=native on a block device.

Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agohandle device help before accelerator set up
Bruce Rogers [Thu, 9 Aug 2012 18:47:40 +0000 (12:47 -0600)]
handle device help before accelerator set up

A command line device probe using just -device "?" gets processed
after qemu-kvm initializes the accelerator. If /dev/kvm is not
present, the accelerator check will fail (kvm is defaulted to on),
which causes libvirt to not be set up to handle qemu guests.

Moving the device help handling before the accelerator set up allows
the device probe to work in this configuration and libvirt succeeds
in setting up for a qemu hypervisor mode.

Signed-off-by: Bruce Rogers <brogers@suse.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMerge branch 'x86cpu_qom_tcg_v2' of git://github.com/imammedo/qemu
Blue Swirl [Thu, 9 Aug 2012 18:44:49 +0000 (18:44 +0000)]
Merge branch 'x86cpu_qom_tcg_v2' of git://github.com/imammedo/qemu

* 'x86cpu_qom_tcg_v2' of git://github.com/imammedo/qemu:
  target-i386: move tcg initialization into x86_cpu_initfn()
  cleanup cpu_set_debug_excp_handler
  target-xtensa: drop usage of prev_debug_excp_handler
  target-i386: drop usage of prev_debug_excp_handler

12 years agoqemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX
Stefano Stabellini [Tue, 29 May 2012 03:35:24 +0000 (03:35 +0000)]
qemu_rearm_alarm_timer: do not call rearm if the next deadline is INT64_MAX

qemu_rearm_alarm_timer partially duplicates the code in
qemu_next_alarm_deadline to figure out if it needs to rearm the timer.
If it calls qemu_next_alarm_deadline, it always rearms the timer even if
the next deadline is INT64_MAX.

This patch simplifies the behavior of qemu_rearm_alarm_timer and removes
the duplicated code, always calling qemu_next_alarm_deadline and only
rearming the timer if the deadline is less than INT64_MAX.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Tested-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-xtensa: make 'sim' to be the default machine
Max Filippov [Wed, 8 Aug 2012 23:31:38 +0000 (03:31 +0400)]
target-xtensa: make 'sim' to be the default machine

This fixes the following error:

    $ qemu-system-xtensa -cpu help
    Segmentation fault

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agotarget-xtensa: make default CPU depend on target endianness
Max Filippov [Wed, 8 Aug 2012 10:07:14 +0000 (14:07 +0400)]
target-xtensa: make default CPU depend on target endianness

This makes usable default for -cpu option both for qemu-system-xtensa
and qemu-system-xtensaeb fixing the following error:

    $ qemu-system-xtensaeb -M sim
    Unable to find CPU definition

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoMIPS: Correct FCR0 initialization
Nathan Froyd [Thu, 7 Jun 2012 15:04:14 +0000 (15:04 +0000)]
MIPS: Correct FCR0 initialization

 This change addresses a problem where QEMU incorrectly traps on
floating-point MADD group instructions with SIGILL, at least while
emulating MIPS32r2 processors.  These instructions use the COP1X major
opcode and include ones like:

madd.d $f2,$f4,$f2,$f6

 Here's Nathan's original analysis of the problem:

"QEMU essentially does:

  d = find_cpu (cpu_string) // get CPU definition
  fpu_init (env, d) // initialize fpu state (init FCR0, basically)
  cpu_reset (env)

...and the cpu_reset call clears all interesting state that fpu_init
setup, then proceeds to reinitialize all the CP0 registers...but not
FCR0."

 I have verified this change with system emulation running the GDB test
suite for the mips-sde-elf target (o32, big endian, 24Kf CPU emulated),
there were 55 progressions and no regressions.

Signed-off-by: Maciej W. Rozycki <macro@codesourcery.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoscsi-bus: remove overlapping entry
Blue Swirl [Mon, 30 Jul 2012 17:46:06 +0000 (17:46 +0000)]
scsi-bus: remove overlapping entry

LOAD_UNLOAD and START_STOP have same value, so the table
entry is initialized twice. Spotted by Clang compiler.

Remove LOAD_UNLOAD entry since START_STOP entry already
represents both.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoxilinx_axienet: avoid useless self-assignment
Blue Swirl [Mon, 30 Jul 2012 17:28:04 +0000 (17:28 +0000)]
xilinx_axienet: avoid useless self-assignment

Statement s=s; makes little sense, remove it. Spotted by Clang
compiler.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agouser: fix accidental AREG0 use
Blue Swirl [Mon, 30 Jul 2012 15:51:17 +0000 (15:51 +0000)]
user: fix accidental AREG0 use

Global register AREG0 was always assumed to be usable in user-exec.c,
but this is incorrect for several targets.

Fix with #ifdeffery and by using other variables.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoqapi: avoid reserved keywords
Blue Swirl [Mon, 30 Jul 2012 15:46:55 +0000 (15:46 +0000)]
qapi: avoid reserved keywords

Clang compiler complained about use of reserved word 'restrict' in SLIRP
and QAPI.

Prefix C keywords with "q_", adjust SLIRP accordingly.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agosparc: fix expression with uninitialized initial value
Blue Swirl [Mon, 30 Jul 2012 15:29:11 +0000 (15:29 +0000)]
sparc: fix expression with uninitialized initial value

err was uninitialized, it's not OK to use |=. Spotted by Clang
compiler.

Fix by implementing the earlier statement which initializes the variable.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agosparc: fix floppy TC line setup
Blue Swirl [Mon, 30 Jul 2012 15:24:23 +0000 (15:24 +0000)]
sparc: fix floppy TC line setup

The qemu_irq for Terminal Count (TC) line between FDC and Slavio misc
device was created only after use, spotted by Clang compiler. Also,
it was not created if the FDC didn't exist.

Rearrange code to fix order. Always create the TC line.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoesp: add Tekram DC-390 emulation (PC SCSI adapter)
Hervé Poussineau [Sat, 4 Aug 2012 19:10:06 +0000 (21:10 +0200)]
esp: add Tekram DC-390 emulation (PC SCSI adapter)

Difference with AMD PCscsi is that DC-390 contains a EEPROM,
and that a romfile is available to add INT13 support.

This has been successfully tested on:
- MS DOS 6.22 (using DC390 ASPI driver)
- MS Windows 98 SE (using DC390 driver)
- MS Windows NT 3.1 (using DC390 driver)
- MS Windows NT 4.0 (using DC390 driver)
- hard disk and cdrom boot

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoRevert "pci: add some stubs"
Hervé Poussineau [Sat, 4 Aug 2012 19:10:05 +0000 (21:10 +0200)]
Revert "pci: add some stubs"

This reverts commit 0883c5159f1df05d8761014f65451c3c3b77ebcf.

Those stubs were only used by PCI ESP emulation, which is now
not compiled on architectures which have no PCI bus support.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoesp: move PCI emulation to a new file esp-pci.c
Hervé Poussineau [Sat, 4 Aug 2012 19:10:04 +0000 (21:10 +0200)]
esp: move PCI emulation to a new file esp-pci.c

sparc machines loose ability to instanciate PCI ESP SCSI adapter,
which is not a big loose as they don't have PCI bus support.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoesp: move some definitions to header file
Hervé Poussineau [Sat, 4 Aug 2012 19:10:03 +0000 (21:10 +0200)]
esp: move some definitions to header file

These will be used by next commits.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
12 years agoscsi-disk: add support for the UNMAP command
Paolo Bonzini [Thu, 9 Aug 2012 09:00:22 +0000 (11:00 +0200)]
scsi-disk: add support for the UNMAP command

The unmap command can reuse the same infrastructure as MODE SELECT
for reading the descriptor list into memory.  The descriptors are
processed sequentially.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: improve out-of-range LBA detection for WRITE SAME
Paolo Bonzini [Thu, 9 Aug 2012 11:34:53 +0000 (13:34 +0200)]
scsi-disk: improve out-of-range LBA detection for WRITE SAME

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoscsi-disk: more assertions and resets for aiocb
Paolo Bonzini [Thu, 9 Aug 2012 09:33:26 +0000 (11:33 +0200)]
scsi-disk: more assertions and resets for aiocb

Leaving the aiocb to a non-NULL value leads to an assertion failure when
rerror/werror are set to stop or enospc, and the operation is retried.
scsi-disk checks that the aiocb member is NULL before filling it.

This patch correctly resets the aiocb to NULL values everywhere,
and adds the dual assertion that the aiocb was non-NULL before
calling bdrv_acct_done.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agovirtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags
Paolo Bonzini [Wed, 8 Aug 2012 14:26:16 +0000 (16:26 +0200)]
virtio-scsi: do not compare 32-bit QEMU tags against 64-bit virtio-scsi tags

This patch fixes a problem in handling task management functions
in virtio-scsi.  The cause of the problem is a mismatch between
the size of the tag in QEMU (32-bit) and virtio-scsi (64-bit).
Changing the QEMU size is hard because the migration format
uses 32 bits to store the tag; so just don't use the QEMU tag
(virtio-scsi only uses the tag for task management functions
anyway) and look up the full 64-bit tag in the hba_private field.

The reproducer is a bit obscure.  If you cause an I/O timeout
(for example with rerror=stop and doing 'cont' on the monitor
continuously without fixing the error), sooner or later the
guest will try to abort the command and reissue it.  At this
point, QEMU will report _two_ errors instead of one when you
hit 'c', because the first error has not been canceled correctly.

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