]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
12 years agoscsi: push request restart to SCSIDevice
Paolo Bonzini [Tue, 25 Oct 2011 10:53:36 +0000 (12:53 +0200)]
scsi: push request restart to SCSIDevice

The request restart mechanism is generic and could be reused for
scsi-generic.  In the meanwhile, pushing it to SCSIDevice avoids
that scsi_dma_restart_bh looks at SCSIGenericReqs when working on
a scsi-block device.

The code is the same that is already in hw/scsi-disk.c, with
the type flags replaced by req->cmd.mode and a more generic way to
requeue SCSI_XFER_NONE commands.

I also added a missing call to qemu_del_vm_change_state_handler.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: bump SCSIRequest reference count until aio completion runs
Paolo Bonzini [Tue, 25 Oct 2011 10:53:35 +0000 (12:53 +0200)]
scsi-generic: bump SCSIRequest reference count until aio completion runs

Same as before, but for scsi-generic.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: bump SCSIRequest reference count until aio completion runs
Paolo Bonzini [Tue, 25 Oct 2011 10:53:34 +0000 (12:53 +0200)]
scsi-disk: bump SCSIRequest reference count until aio completion runs

In some cases a request may be canceled before the completion callback
runs.  Keep a reference to the request between starting an AIO operation
and the corresponding scsi_req_cancel or scsi_*_complete.

When a request has to be retried, the request can be dropped because
scsi_dma_restart_bh only looks at requests that are enqueued.  As such,
they always have at least a reference.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: do not call transfer_data after canceling a request
Paolo Bonzini [Tue, 25 Oct 2011 10:53:33 +0000 (12:53 +0200)]
scsi: do not call transfer_data after canceling a request

Otherwise, if cancellation is "faked" by the AIO layer and goes
through qemu_aio_flush, the whole request is completed synchronously
during scsi_req_cancel.

Using the enqueued flag would work here, but not in the next patches,
so I'm introducing a new io_canceled flag.  That's because scsi_req_data
is a synchronous callback and the enqueued flag might be reset by the
time it returns.  scsi-disk cannot unref the request until after calling
scsi_req_data.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: pass cdb to alloc_req
Paolo Bonzini [Wed, 12 Oct 2011 10:58:31 +0000 (12:58 +0200)]
scsi: pass cdb to alloc_req

This will let scsi-block choose between passthrough and emulation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: export scsi_generic_reqops
Paolo Bonzini [Wed, 12 Oct 2011 10:54:31 +0000 (12:54 +0200)]
scsi: export scsi_generic_reqops

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: make reqops const
Paolo Bonzini [Wed, 12 Oct 2011 10:57:59 +0000 (12:57 +0200)]
scsi: make reqops const

Also delete a stale occurrence of SCSIReqOps inside SCSIDeviceInfo.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: move max_lba to SCSIDevice
Paolo Bonzini [Thu, 13 Oct 2011 08:39:50 +0000 (10:39 +0200)]
scsi: move max_lba to SCSIDevice

The field is only in scsi-disk for now.  Moving it up to SCSIDevice makes
it easier to reuse the scsi-generic reqops elsewhere.

At the same time, make scsi-generic get max_lba from snooped READ CAPACITY
commands as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: small clean up to INQUIRY
Paolo Bonzini [Wed, 12 Oct 2011 12:27:40 +0000 (14:27 +0200)]
scsi-disk: small clean up to INQUIRY

Set s->removable, s->qdev.blocksize and s->qdev.type in the callers
of scsi_initfn.

With this in place, s->qdev.type is allowed, and we can just reuse it
as the first byte in VPD data (just like we do in standard INQUIRY data).
Also set s->removable is set consistently and we can use it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: remove cluster_size
Paolo Bonzini [Thu, 13 Oct 2011 08:35:46 +0000 (10:35 +0200)]
scsi-disk: remove cluster_size

This field is redundant, and having it makes it more complicated
to share reqops between the upcoming scsi-block and scsi-generic.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: do not duplicate BlockDriverState member
Paolo Bonzini [Wed, 12 Oct 2011 10:54:16 +0000 (12:54 +0200)]
scsi-disk: do not duplicate BlockDriverState member

Same as for scsi-generic, avoid duplication even if it causes longer
lines.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: snoop READ CAPACITY commands to get block size
Paolo Bonzini [Thu, 13 Oct 2011 08:36:27 +0000 (10:36 +0200)]
scsi-generic: snoop READ CAPACITY commands to get block size

Instead of "guessing" the block size when there is no medium in the
drive, wait for the guest to send a READ CAPACITY command and snoop
it from there.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: look at host status
Paolo Bonzini [Wed, 12 Oct 2011 12:53:43 +0000 (14:53 +0200)]
scsi-generic: look at host status

Pass down the host status so that failing transport can be detected
by the guest.  Similar treatment of host status could be done in
virtio-blk, too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: check ioctl statuses when SG_IO succeeds
Paolo Bonzini [Wed, 12 Oct 2011 12:49:48 +0000 (14:49 +0200)]
scsi-generic: check ioctl statuses when SG_IO succeeds

A succeeding ioctl does not imply that the SCSI command succeeded.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: remove scsi_req_fixup
Paolo Bonzini [Wed, 12 Oct 2011 09:54:59 +0000 (11:54 +0200)]
scsi-generic: remove scsi_req_fixup

This is not needed anymore, since asynchronous ioctls were introduced
by commit 221f715 (new scsi-generic abstraction, use SG_IO, 2009-03-28).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-generic: drop SCSIGenericState
Paolo Bonzini [Wed, 12 Oct 2011 10:49:35 +0000 (12:49 +0200)]
scsi-generic: drop SCSIGenericState

It is not needed, because s->bs is already stored in SCSIDevice, and
can be reached from the conf.bs member.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: fix retrying a flush
Paolo Bonzini [Tue, 4 Oct 2011 13:36:05 +0000 (15:36 +0200)]
scsi-disk: fix retrying a flush

Flush does not go anymore through scsi_disk_emulate_command.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0
Paolo Bonzini [Mon, 3 Oct 2011 11:57:06 +0000 (13:57 +0200)]
scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0

Tested by the Windows Logo Kit SCSI Compliance test. From SBC-3, paragraph
5.25: "The LOGICAL BLOCK ADDRESS field shall be set to zero if the PMI
bit is set to zero. If the PMI bit is set to zero and the LOGICAL BLOCK
ADDRESS field is not set to zero, then the device server shall terminate
the command with CHECK CONDITION status with the sense key set to ILLEGAL
REQUEST and the additional sense code set to INVALID FIELD IN CDB".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: add channel to addressing
Paolo Bonzini [Wed, 27 Jul 2011 21:24:50 +0000 (23:24 +0200)]
scsi: add channel to addressing

This also requires little more than adding the new argument to
scsi_device_find, and the qdev property.  All devices by default
end up on channel 0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: allow arbitrary LUNs
Paolo Bonzini [Sat, 13 Aug 2011 16:55:17 +0000 (18:55 +0200)]
scsi: allow arbitrary LUNs

This only requires changes in two places: in SCSIBus, we need to look
for a free LUN if somebody creates a device with a pre-existing scsi-id
but the default LUN (-1, meaning "search for a free spot"); in vSCSI,
we need to actually parse the LUN according to the SCSI spec.

For vSCSI, max_target/max_lun are set according to the logical unit
addressing format in SAM.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: implement REPORT LUNS for arbitrary LUNs
Paolo Bonzini [Wed, 14 Sep 2011 18:39:36 +0000 (20:39 +0200)]
scsi: implement REPORT LUNS for arbitrary LUNs

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: remove devs array from SCSIBus
Paolo Bonzini [Thu, 28 Jul 2011 16:02:13 +0000 (18:02 +0200)]
scsi: remove devs array from SCSIBus

Change the devs array into a linked list, and add a scsi_device_find
function to navigate the children list instead.  This lets the SCSI
bus use more complex addressing, and HBAs can talk to the correct device
when there are multiple LUNs per target.

scsi_device_find may return another LUN on the same target if none is
found that matches exactly.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqdev: switch children device list to QTAILQ
Paolo Bonzini [Wed, 14 Sep 2011 07:28:06 +0000 (09:28 +0200)]
qdev: switch children device list to QTAILQ

SCSI buses will need to read the children list first-to-last.  This
requires using a QTAILQ, because hell breaks loose if you just try
inserting at the tail (thus reversing the order of all existing
visits from last-to-first to first-to-tail).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)
Paolo Bonzini [Sat, 13 Aug 2011 13:44:45 +0000 (15:44 +0200)]
scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: report media changed via GET EVENT STATUS NOTIFICATION
Paolo Bonzini [Tue, 13 Sep 2011 14:26:51 +0000 (16:26 +0200)]
scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION

This adds support for media change notification via the GET EVENT STATUS
NOTIFICATION command, used by Linux versions 2.6.38 and newer.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: support READ DVD STRUCTURE
Paolo Bonzini [Tue, 13 Sep 2011 13:57:15 +0000 (15:57 +0200)]
scsi-disk: support READ DVD STRUCTURE

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: support DVD profile in GET CONFIGURATION
Paolo Bonzini [Tue, 13 Sep 2011 13:22:31 +0000 (15:22 +0200)]
scsi-disk: support DVD profile in GET CONFIGURATION

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoatapi/scsi-disk: make mode page values coherent between the two
Paolo Bonzini [Tue, 13 Sep 2011 13:08:22 +0000 (15:08 +0200)]
atapi/scsi-disk: make mode page values coherent between the two

This patch adds to scsi-disk the missing mode page 0x01 for both disk
and CD-ROM drives, and mode page 0x0e for CD drives only.

A few offsets were wrong in atapi.c.  Also change the 2Ah mode page to
expose DVD media read capabilities in the IDE cdrom.  This lets you run
dvd+rw-mediainfo on the virtual DVD drives.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: store valid mode pages in a table
Paolo Bonzini [Tue, 13 Sep 2011 12:50:15 +0000 (14:50 +0200)]
scsi-disk: store valid mode pages in a table

A small refactoring of the MODE SENSE implementation in scsi-disk.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: add stubs for more MMC commands
Paolo Bonzini [Tue, 13 Sep 2011 12:33:47 +0000 (14:33 +0200)]
scsi-disk: add stubs for more MMC commands

This patch adds a few stub implementations for MMC commands to
scsi-disk, to be filled in later in the series.  It also adds to
scsi-defs.h constants for commands implemented by ide/atapi.c,
when missing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: fix coding style issues (braces)
Paolo Bonzini [Mon, 17 Oct 2011 14:39:27 +0000 (16:39 +0200)]
scsi-disk: fix coding style issues (braces)

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi-disk: report media changed via unit attention sense codes
Paolo Bonzini [Tue, 13 Sep 2011 14:26:06 +0000 (16:26 +0200)]
scsi-disk: report media changed via unit attention sense codes

Building on the previous patch, this one adds a media change callback
to scsi-disk.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: notify the device when unit attention is reported
Paolo Bonzini [Tue, 13 Sep 2011 14:19:53 +0000 (16:19 +0200)]
scsi: notify the device when unit attention is reported

Reporting media change events via unit attention sense codes requires
a small state machine: first report "NO MEDIUM", then report "MEDIUM MAY
HAVE CHANGED".  Unfortunately there is no good hooking point for the
device to notice that its pending unit attention condition has been
reported.  This patch reworks the generic machinery to add one.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoatapi: cleanup/fix mode sense results
Paolo Bonzini [Mon, 17 Oct 2011 14:34:59 +0000 (16:34 +0200)]
atapi: cleanup/fix mode sense results

The first two bytes (after the 8-byte ATAPI header) are the mode page
number and the number of bytes after the length field itself.  Make
this clear in the code.

The AUDIO_CTL page was filled with wrong values.  It is not anymore in
MMC, but at least keep the values sane.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoatapi: move GESN definitions to scsi-defs.h
Paolo Bonzini [Tue, 13 Sep 2011 14:00:52 +0000 (16:00 +0200)]
atapi: move GESN definitions to scsi-defs.h

As a complement to the previous patch, move definitions for GET EVENT
STATUS NOTIFICATION from the two functions to scsi-defs.h.

The NCR_* constants are just bit values corresponding to the ENC_*
values, with no offsets even, so keep just one copy.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoatapi/scsi: unify definitions for MMC
Paolo Bonzini [Tue, 13 Sep 2011 12:41:56 +0000 (14:41 +0200)]
atapi/scsi: unify definitions for MMC

The definitions in ide/internal.h are duplicates, since ATAPI commands
actually come from SCSI.  Use the ones in scsi-defs.h and move the
missing ones there.  Two exceptions:

- MODE_PAGE_WRITE_PARMS conflicts with the "flexible disk geometry"
page in scsi-disk.c.  It is unused, so pick the latter.

- GPCMD_* is left in ide/internal.h, at least for now.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoscsi: pass correct sense code for ENOMEDIUM
Paolo Bonzini [Mon, 19 Sep 2011 15:19:21 +0000 (17:19 +0200)]
scsi: pass correct sense code for ENOMEDIUM

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoDocumentation: Add syntax for using sheepdog devices
Ronnie Sahlberg [Fri, 28 Oct 2011 09:13:39 +0000 (20:13 +1100)]
Documentation: Add syntax for using sheepdog devices

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: reinitialize across bdrv_close()/bdrv_open()
Stefan Hajnoczi [Thu, 27 Oct 2011 09:54:28 +0000 (10:54 +0100)]
block: reinitialize across bdrv_close()/bdrv_open()

Several BlockDriverState fields are not being reinitialized across
bdrv_close()/bdrv_open().  Make sure they are reset to their default
values.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: set bs->read_only before .bdrv_open()
Stefan Hajnoczi [Thu, 27 Oct 2011 09:54:27 +0000 (10:54 +0100)]
block: set bs->read_only before .bdrv_open()

Several block drivers set bs->read_only in .bdrv_open() but
block.c:bdrv_open_common() clobbers its value.  Additionally, QED uses
bdrv_is_read_only() in .bdrv_open() to decide whether to perform
consistency checks.

The correct ordering is to initialize bs->read_only from the open flags
before calling .bdrv_open().  This way block drivers can override it if
necessary and can use bdrv_is_read_only() in .bdrv_open().

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqemu-io: delete bs instead of leaking it
Stefan Hajnoczi [Thu, 27 Oct 2011 09:54:26 +0000 (10:54 +0100)]
qemu-io: delete bs instead of leaking it

Using bdrv_close() is not enough to free a BlockDriverState.  Since we
explicitly create it with bdrv_new(), use bdrv_delete() to close and
delete it.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: fix qcow2_co_flush deadlock
Dong Xu Wang [Thu, 27 Oct 2011 09:22:28 +0000 (17:22 +0800)]
block: fix qcow2_co_flush deadlock

If qcow2_cache_flush failed, s->lock will not be unlock.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoDocumentation: Describe NBD URL syntax
Ronnie Sahlberg [Thu, 27 Oct 2011 09:33:21 +0000 (20:33 +1100)]
Documentation: Describe NBD URL syntax

This patch adds a short description of how to specify a NBD device
to QEMU.
Syntax for both TCP and Unix Domain Sockets are provided as well
as examples.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovmdk: Fix possible segfaults
Kevin Wolf [Wed, 26 Oct 2011 10:25:52 +0000 (12:25 +0200)]
vmdk: Fix possible segfaults

Data we read from the disk isn't necessarily null terminated and may not
contain the string we're looking for. The code needs to be a bit more careful
here.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovmdk: Improve error handling
Kevin Wolf [Wed, 26 Oct 2011 10:25:25 +0000 (12:25 +0200)]
vmdk: Improve error handling

Return the right error values in some more places.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agovmdk: Fix use of uninitialised value
Kevin Wolf [Wed, 26 Oct 2011 10:22:40 +0000 (12:22 +0200)]
vmdk: Fix use of uninitialised value

In error cases, cid is never set.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoide: Fix off-by-one error in array index check
Kevin Wolf [Wed, 26 Oct 2011 09:52:47 +0000 (11:52 +0200)]
ide: Fix off-by-one error in array index check

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoqcow: Fix bdrv_write_compressed error handling
Kevin Wolf [Wed, 26 Oct 2011 09:21:50 +0000 (11:21 +0200)]
qcow: Fix bdrv_write_compressed error handling

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
12 years agoblock: Fix bdrv_open use after free
Kevin Wolf [Wed, 26 Oct 2011 09:03:01 +0000 (11:03 +0200)]
block: Fix bdrv_open use after free

tmp_filename was used outside the block it was defined in, i.e. after it went
out of scope. Move its declaration to the top level.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoblock: Remove dead code
Kevin Wolf [Wed, 26 Oct 2011 09:02:11 +0000 (11:02 +0200)]
block: Remove dead code

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoqcow2: fix some errors and typo in qcow2.txt
Zhi Yong Wu [Thu, 27 Oct 2011 06:58:57 +0000 (14:58 +0800)]
qcow2: fix some errors and typo in qcow2.txt

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoTeach block/vdi about "discarded" (no longer allocated) blocks
Eric Sunshine [Wed, 26 Oct 2011 19:51:18 +0000 (15:51 -0400)]
Teach block/vdi about "discarded" (no longer allocated) blocks

An entry in the VDI block map will hold an offset to the actual block if
the block is allocated, or one of two specially-interpreted values if
not allocated. Using VirtualBox terminology, value VDI_IMAGE_BLOCK_FREE
(0xffffffff) represents a never-allocated block (semantically arbitrary
content).  VDI_IMAGE_BLOCK_ZERO (0xfffffffe) represents a "discarded"
block (semantically zero-filled).  block/vdi knows only about
VDI_IMAGE_BLOCK_FREE.  Teach it about VDI_IMAGE_BLOCK_ZERO.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoDocumentation: Add iSCSI section
Ronnie Sahlberg [Wed, 26 Oct 2011 12:51:37 +0000 (23:51 +1100)]
Documentation: Add iSCSI section

Add new section for device URL syntax for special files and describe the iSCSI
URL with examples

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoiSCSI block driver
Ronnie Sahlberg [Tue, 25 Oct 2011 08:24:24 +0000 (19:24 +1100)]
iSCSI block driver

This provides built-in support for iSCSI to QEMU.

This has the advantage that the iSCSI devices need not be made visible to the host, which is useful if you have very many virtual machines and very many iscsi devices.
It also has the benefit that non-root users of QEMU can access iSCSI devices across the network without requiring root privilege on the host.

This driver interfaces with the multiplatform posix library for iscsi initiator/client access to iscsi devices hosted at
    git://github.com/sahlberg/libiscsi.git

The patch adds the driver to interface with the iscsi library.
It also updated the configure script to
* by default, probe is libiscsi is available and if so, build
  qemu against libiscsi.
* --enable-libiscsi
  Force a build against libiscsi. If libiscsi is not available
  the build will fail.
* --disable-libiscsi
  Do not link against libiscsi, even if it is available.

When linked with libiscsi, qemu gains support to access iscsi resources such as disks and cdrom directly, without having to make the devices visible to the host.

You can specify devices using a iscsi url of the form :
iscsi://[<username>[:<password>@]]<host>[:<port]/<target-iqn-name>/<lun>
When using authentication, the password can optionally be set with
LIBISCSI_CHAP_PASSWORD="password" to avoid it showing up in the process list

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12 years agoMerge branch 'rth/vis2' of git://repo.or.cz/qemu/rth
Blue Swirl [Thu, 27 Oct 2011 20:27:07 +0000 (20:27 +0000)]
Merge branch 'rth/vis2' of git://repo.or.cz/qemu/rth

* 'rth/vis2' of git://repo.or.cz/qemu/rth:
  target-sparc: Implement FALIGNDATA inline.
  target-sparc: Implement BMASK/BSHUFFLE.
  target-sparc: Implement ALIGNADDR* inline.
  target-sparc: Implement EDGE* instructions.
  target-sparc: Implement fpack{16,32,fix}.
  target-sparc: Implement PDIST.
  target-sparc: Do exceptions management fully inside the helpers.
  target-sparc: Change fpr representation to doubles.
  target-sparc: Undo cpu_fpr rename.
  target-sparc: Extract float128 move to a function.
  target-sparc: Extract common code for floating-point operations.
  target-sparc: Make FPU/VIS helpers const when possible.
  target-sparc: Pass float64 parameters instead of dt0/1 temporaries.
  target-sparc: Add accessors for double-precision fpr access.
  target-sparc: Mark fprs dirty in store accessor.
  target-sparc: Add accessors for single-precision fpr access.

12 years agoDrop qemu-objects.h from modules that don't require it
Luiz Capitulino [Fri, 21 Oct 2011 18:05:43 +0000 (16:05 -0200)]
Drop qemu-objects.h from modules that don't require it

Previous commits dropped most qobjects usage from qemu modules
(now they are a low level interface used by the QAPI). However,
some modules still include the qemu-objects.h header file.

This commit drops qemu-objects.h from some of those modules
and includes qjson.h instead, which is what they actually need.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoMonitor: do_info(): Drop QMP command handling code
Luiz Capitulino [Fri, 21 Oct 2011 18:24:28 +0000 (16:24 -0200)]
Monitor: do_info(): Drop QMP command handling code

Previous commits converted all existing QMP commands to the QAPI,
now each info command does its own QMP call.

Let's then drop all QMP command handling code from do_info().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoQMP: Drop the query commands dispatch table
Luiz Capitulino [Fri, 21 Oct 2011 18:15:31 +0000 (16:15 -0200)]
QMP: Drop the query commands dispatch table

Because QMP development originated in the monitor, it has
inherited the monitor's distinction between query- and
non-query commands.

However, previous commits unified both commands and the
distinction is gone. This commit drops the query commands
dispatch table and does some simplifications along the way.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-pci
Luiz Capitulino [Fri, 21 Oct 2011 16:15:33 +0000 (14:15 -0200)]
qapi: Convert query-pci

This also fixes a bug with the old version: QMP would invert device id
and vendor id. This would look ok on HMP because it was printing
"device:vendor" instead of "vendor:device".

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-balloon
Luiz Capitulino [Fri, 21 Oct 2011 13:41:37 +0000 (11:41 -0200)]
qapi: Convert query-balloon

Please, note that some of the code supporting memory statistics is
still around (eg. virtio_balloon_receive_stats() and reset_stats()).

Also, the qmp_query_balloon() function is synchronous and thus doesn't
make any use of the (not fully working) monitor's asynchronous command
support (the old non-qapi implementation did).

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-spice
Luiz Capitulino [Thu, 20 Oct 2011 19:01:33 +0000 (17:01 -0200)]
qapi: Convert query-spice

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-vnc
Luiz Capitulino [Mon, 17 Oct 2011 18:41:22 +0000 (16:41 -0200)]
qapi: Convert query-vnc

There are three important remarks in relation to the non-qapi command:

 1. This commit also fixes the behavior of the 'query-vnc' and 'info vnc'
    commands to return an error when qemu is built without VNC support
    (ie. --disable-vnc). The non-qapi command would return the OK
    response in QMP and no response in HMP

 2. The qapi version explicitly marks the fields 'host', 'family',
    'service' and 'auth' as optional. Their are not documented as optional
    in the non-qapi command doc, but they would not be returned if
    vnc support is disabled. The qapi version maintains the same
    semantics, but documents those fields correctly

 3. The 'clients' field, which is a list, is marked as optional but is
    always returned. If there are no clients connected an empty list
    is returned. This is not the Right Way to this in the qapi but it's
    how the non-qapi command used to work

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqerror: Add a user string for QERR_FEATURE_DISABLED
Luiz Capitulino [Wed, 19 Oct 2011 17:15:57 +0000 (15:15 -0200)]
qerror: Add a user string for QERR_FEATURE_DISABLED

Missing from commit 821601ea5b.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-blockstats
Luiz Capitulino [Thu, 22 Sep 2011 18:56:36 +0000 (15:56 -0300)]
qapi: Convert query-blockstats

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-block
Luiz Capitulino [Wed, 21 Sep 2011 20:16:47 +0000 (17:16 -0300)]
qapi: Convert query-block

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoblock: Rename the BlockIOStatus enum values
Luiz Capitulino [Fri, 14 Oct 2011 20:22:24 +0000 (17:22 -0300)]
block: Rename the BlockIOStatus enum values

The biggest change is to rename its prefix from BDRV_IOS to
BLOCK_DEVICE_IO_STATUS.

Next commit will convert the query-block command to the QAPI
and that's how the enumeration is going to be generated.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoblock: iostatus: Drop BDRV_IOS_INVAL
Luiz Capitulino [Fri, 14 Oct 2011 20:11:23 +0000 (17:11 -0300)]
block: iostatus: Drop BDRV_IOS_INVAL

A future commit will convert bdrv_info() to the QAPI and it won't
provide IOS_INVAL.

Luckily all we have to do is to add a new 'iostatus_enabled'
member to BlockDriverState and use it instead.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-cpus
Luiz Capitulino [Wed, 21 Sep 2011 19:38:35 +0000 (16:38 -0300)]
qapi: Convert query-cpus

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert the cpu command
Luiz Capitulino [Thu, 6 Oct 2011 17:31:39 +0000 (14:31 -0300)]
qapi: Convert the cpu command

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoMonitor: Introduce monitor_get_cpu_index()
Luiz Capitulino [Mon, 24 Oct 2011 12:53:44 +0000 (10:53 -0200)]
Monitor: Introduce monitor_get_cpu_index()

Returns 'cur_mons's CPU index. A future commit will use it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoMonitor: Make mon_set_cpu() public
Luiz Capitulino [Thu, 6 Oct 2011 17:02:57 +0000 (14:02 -0300)]
Monitor: Make mon_set_cpu() public

Also rename it to monitor_set_cpu().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-migrate
Luiz Capitulino [Tue, 13 Sep 2011 20:37:16 +0000 (17:37 -0300)]
qapi: Convert query-migrate

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi: Convert query-mice
Luiz Capitulino [Wed, 21 Sep 2011 18:29:55 +0000 (15:29 -0300)]
qapi: Convert query-mice

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoqapi-commands.py: Don't call the output marshal on error
Luiz Capitulino [Wed, 19 Oct 2011 16:51:14 +0000 (14:51 -0200)]
qapi-commands.py: Don't call the output marshal on error

Today we generate something like this:

    int qmp_marshal_input_query_foo(...)

        ...

        retval = qmp_query_foo(errp);
        qmp_marshal_output_query_foo(retval, ret, errp);

        ...

However, if qmp_query_foo() fails 'retval' will probably be NULL,
which can cause a segfault as not all visitors check if 'retval'
is valid.

This commit fixes that by changing the code generator to only
call the output marshal if qmp_query_foo() succeeds, like this:

    retval = qmp_query_foo(errp);
    if (!error_is_set(errp)) {
        qmp_marshal_output_query_foo(retval, ret, errp);
    }

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
12 years agoppc64-linux-user: Fix syscall return type.
Richard Henderson [Wed, 26 Oct 2011 16:59:18 +0000 (09:59 -0700)]
ppc64-linux-user: Fix syscall return type.

Use target_ulong instead of hard-coded uint32_t.
Remove the disabled printf's that are redundant with -strace.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
12 years agoppc64-linux-user: Properly interpret the entry function descriptor.
Richard Henderson [Wed, 26 Oct 2011 16:59:17 +0000 (09:59 -0700)]
ppc64-linux-user: Properly interpret the entry function descriptor.

Don't confuse the load address with the load bias.  They're equal
for ET_DYN objects (i.e. ld.so) but different for ET_EXEC objects
(i.e. statically linked).

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
12 years agosparc-linux-user: Add some missing syscall numbers
Richard Henderson [Tue, 25 Oct 2011 17:34:08 +0000 (10:34 -0700)]
sparc-linux-user: Add some missing syscall numbers

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
12 years agosparc-linux-user: Fixup sending SIGSEGV
Richard Henderson [Tue, 25 Oct 2011 17:34:07 +0000 (10:34 -0700)]
sparc-linux-user: Fixup sending SIGSEGV

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
12 years agosparc-linux-user: Handle SIGILL.
Richard Henderson [Tue, 25 Oct 2011 17:34:06 +0000 (10:34 -0700)]
sparc-linux-user: Handle SIGILL.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
12 years agolinux-user: implement reboot syscall
Alexander Graf [Tue, 27 Sep 2011 12:39:42 +0000 (14:39 +0200)]
linux-user: implement reboot syscall

For OBS, we're running a full cross-guest inside of a VM. When a build
is done there, we reboot the guest as shutdown mechanism.

Unfortunately, reboot is not implemented in linux-user. So this mechanism
fails, spilling unpretty warnings. This patch implements sys_reboot()
emulation.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
12 years agolinux-user: fix openat
Alexander Graf [Sun, 25 Sep 2011 04:25:35 +0000 (06:25 +0200)]
linux-user: fix openat

When running openat using qemu-arm, we stumbled over invalid permissions
on the created files. The reason for this is that the mode parameter gets
treates as an O_... flag, which it isn't - it's a permission bitmask.

This patch removes the needless translation of the mode parameter,
rendering permission passing of openat() to work with linux-user.

Reported-by: Dirk Mueller <dmueller@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
12 years agolinux-user: fix abi_(u)long, target_ulong mismatch
Matthias Braun [Fri, 12 Aug 2011 17:57:41 +0000 (19:57 +0200)]
linux-user: fix abi_(u)long, target_ulong mismatch

abi_(u)long might be different from target_ulong, so don't use tswapl
but introduce a new tswapal

Signed-off-by: Matthias Braun <matze@braunis.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
12 years agolinux-user: fix rlimit syscalls on sparc(64)
Matthias Braun [Fri, 9 Sep 2011 17:30:25 +0000 (19:30 +0200)]
linux-user: fix rlimit syscalls on sparc(64)

Signed-off-by: Matthias Braun <matze@braunis.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
12 years agolinux-user: fix TARGET_RLIM_INFINITY declaration
Matthias Braun [Fri, 9 Sep 2011 17:31:17 +0000 (19:31 +0200)]
linux-user: fix TARGET_RLIM_INFINITY declaration

Signed-off-by: Matthias Braun <matze@braunis.de>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
12 years agoMerge branch 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm
Andrzej Zaborowski [Wed, 26 Oct 2011 23:02:46 +0000 (01:02 +0200)]
Merge branch 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm

12 years agotarget-sparc: Implement FALIGNDATA inline.
Richard Henderson [Tue, 18 Oct 2011 16:41:30 +0000 (09:41 -0700)]
target-sparc: Implement FALIGNDATA inline.

This is a relatively simple sequence of shifts.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Implement BMASK/BSHUFFLE.
Richard Henderson [Tue, 18 Oct 2011 16:24:43 +0000 (09:24 -0700)]
target-sparc: Implement BMASK/BSHUFFLE.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Implement ALIGNADDR* inline.
Richard Henderson [Tue, 18 Oct 2011 15:35:58 +0000 (08:35 -0700)]
target-sparc: Implement ALIGNADDR* inline.

While ALIGNADDR was implemented out-of-line, ALIGNADDRL was not
implemeneted at all.  However, this is a very simple operation
so we're better off doing this inline.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Implement EDGE* instructions.
Richard Henderson [Tue, 18 Oct 2011 02:57:23 +0000 (19:57 -0700)]
target-sparc: Implement EDGE* instructions.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Implement fpack{16,32,fix}.
Richard Henderson [Tue, 18 Oct 2011 01:03:47 +0000 (18:03 -0700)]
target-sparc: Implement fpack{16,32,fix}.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Implement PDIST.
Richard Henderson [Tue, 18 Oct 2011 00:32:26 +0000 (17:32 -0700)]
target-sparc: Implement PDIST.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Do exceptions management fully inside the helpers.
Richard Henderson [Mon, 17 Oct 2011 18:25:56 +0000 (11:25 -0700)]
target-sparc: Do exceptions management fully inside the helpers.

This reduces the size of the individual translation blocks, since
we only emit a single call for each FOP rather than three.  In
addition, clear_float_exceptions expands inline to a single byte store.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Change fpr representation to doubles.
Richard Henderson [Mon, 17 Oct 2011 17:42:49 +0000 (10:42 -0700)]
target-sparc: Change fpr representation to doubles.

This allows a more efficient representation for 64-bit hosts.
It should be about the same for 32-bit hosts, as we can still
access the individual pieces of the double.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Undo cpu_fpr rename.
Richard Henderson [Sat, 15 Oct 2011 19:12:02 +0000 (12:12 -0700)]
target-sparc: Undo cpu_fpr rename.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Extract float128 move to a function.
Richard Henderson [Sat, 15 Oct 2011 19:00:08 +0000 (12:00 -0700)]
target-sparc: Extract float128 move to a function.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Extract common code for floating-point operations.
Richard Henderson [Sat, 15 Oct 2011 18:52:00 +0000 (11:52 -0700)]
target-sparc: Extract common code for floating-point operations.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Make FPU/VIS helpers const when possible.
Richard Henderson [Wed, 19 Oct 2011 21:56:43 +0000 (14:56 -0700)]
target-sparc: Make FPU/VIS helpers const when possible.

This also removes the unused ENV parameter from these helpers.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Pass float64 parameters instead of dt0/1 temporaries.
Richard Henderson [Sat, 15 Oct 2011 17:20:20 +0000 (10:20 -0700)]
target-sparc: Pass float64 parameters instead of dt0/1 temporaries.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Add accessors for double-precision fpr access.
Richard Henderson [Fri, 14 Oct 2011 22:47:35 +0000 (15:47 -0700)]
target-sparc: Add accessors for double-precision fpr access.

Begin using i64 quantities to manipulate double-precision values.
On a 64-bit host this will, for the moment, generate less efficient
code; on a 32-bit host code quality should be largely unchanged.
Code quality for 64-bit will be adjusted with a subsequent patch.

Signed-off-by: Richard Henderson <rth@twiddle.net>
12 years agotarget-sparc: Mark fprs dirty in store accessor.
Richard Henderson [Fri, 14 Oct 2011 22:03:25 +0000 (15:03 -0700)]
target-sparc: Mark fprs dirty in store accessor.

Signed-off-by: Richard Henderson <rth@twiddle.net>