sim-card
/
qemu
Archived
10
0
Fork 0
Commit Graph

464 Commits

Author SHA1 Message Date
Kevin Wolf e3f652b332 qcow2: Fix error path in qcow2_snapshot_load_tmp
If the bdrv_read() of the snapshot's L1 table fails, return the right
error code and make sure that the old L1 table is still loaded and we
don't break the BlockDriverState completely.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:36 +01:00
Kevin Wolf 9a4767809f qcow2: Fix order in qcow2_snapshot_delete
First the snapshot must be deleted and only then the refcounts can be
decreased.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:36 +01:00
Kevin Wolf 43a0cac465 qcow2: Fix order of refcount updates in qcow2_snapshot_goto
The refcount updates must be moved so that in the worst case we can get
cluster leaks, but refcounts may never be too low.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:36 +01:00
Kevin Wolf 589f284b76 qcow2: Return real error in qcow2_snapshot_goto
Besides fixing the return code, this adds some comments that make clear
how the code works and that it potentially breaks images if we fail in
the wrong place. Actually fixing this is left for the next patch.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:36 +01:00
Kevin Wolf d1ea98d56d qcow2: Rework qcow2_snapshot_create error handling
Increase refcounts only after allocating a new L1 table has succeeded in
order to make leaks less likely. If writing the snapshot table fails,
revert in-memory state to be consistent with that on disk.

While at it, make it return the real error codes instead of -1.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:36 +01:00
Kevin Wolf 03343166f7 qcow2: Cleanups and memleak fix in qcow2_snapshot_create
sn->id_str could be leaked before this. The rest of this patch changes
comments, fixes coding style or removes checks that are unnecessary with
g_malloc.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:36 +01:00
Kevin Wolf d69969c404 qcow2: Update snapshot table information at once
Failing in the middle wouldn't help with the integrity of the image, so
doing everything in a single request seems better.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:36 +01:00
Kevin Wolf 07fd877900 qcow2: Return real error code in qcow2_write_snapshots
Doesn't immediately fix anything as the callers don't use the return
value, but they will be fixed next.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:35 +01:00
Kevin Wolf 42deb29fed qcow2: Return real error code in qcow2_read_snapshots
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-05 14:51:35 +01:00
Dong Xu Wang a968168c58 block: Add coroutine_fn marker to coroutine functions
Looks better when reviewing these source files.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-05 14:51:35 +01:00
Li Zhi Hui 3535a9c6be block: Use bdrv functions to replace file operation in cow.c
Since common file operation functions lack of error detection,
so change them to bdrv series functions.

Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-05 14:51:35 +01:00
Zhi Yong Wu 23e9a39e7d qed: adjust the way to get nb_sectors
This patch is only to refactor some lines of codes to get better and more robust codes.

As you have seen, in qed_read_table_cb() it's nice to
use qiov->size because that function doesn't obviously use a single
struct iovec.

In other two functions, if qiov use more than one struct iovec, the existing way will get wrong nb_sectors.
To make the code more robust, it will be nicer to refactor the existing way as below.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-05 14:51:34 +01:00
Stefan Hajnoczi aef4acb661 qcow2: avoid reentrant bdrv_read() in copy_sectors()
A BlockDriverState should not issue requests on itself through the
public block layer interface.  Nested, or reentrant, requests are
problematic because they do I/O throttling and request tracking twice.

Features like block layer copy-on-read use request tracking to avoid
race conditions between concurrent requests.  The reentrant request will
have to "wait" for its parent request to complete.  But the parent is
waiting for the reentrant request to make progress so we have reached
deadlock.

The solution is for block drivers to avoid the public block layer
interfaces for reentrant requests.   Instead they should call their own
internal functions if they wish to perform reentrant requests.

This is also a good opportunity to make copy_sectors() a true
coroutine_fn.  That means calling bdrv_co_writev() instead of
bdrv_write().  Behavior is unchanged but we're being explicit that this
executes in coroutine context.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-05 14:49:47 +01:00
Kevin Wolf 1b9f1491f8 qcow2: Unlock during COW
Unlocking during COW allows for more parallelism. One change it requires is
that buffers are dynamically allocated instead of just using a per-image
buffer.

While touching the code, drop the synchronous qcow2_read() function and replace
it by a bdrv_read() call.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-05 14:49:40 +01:00
Kevin Wolf 5bb1cbac4f vpc: Add missing error handling in alloc_block
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-23 17:04:06 +01:00
Kevin Wolf 6ac5f3881f vdi: Fix memory leak
The block map is allocated in vdi_open, but was never freed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23 17:04:05 +01:00
Kevin Wolf 3397f0cb48 vvfat: Add migration blocker
vvfat caches more or less everything when in writable mode. For migration
to work, it would have to be invalidated. Block migration for now when
in writable mode (default is readonly).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23 17:04:05 +01:00
Kevin Wolf 612ff3d887 vpc: Add migration blocker
vpc caches the BAT. For migration to work, it would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23 17:04:04 +01:00
Kevin Wolf 2bc3166c22 vmdk: Add migration blocker
VMDK caches L2 tables. For migration to work, they would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23 17:04:03 +01:00
Kevin Wolf fc9d106c8d vdi: Add migration blocker
vdi caches the block map. For migration to work, it would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23 17:04:02 +01:00
Kevin Wolf fd9f102c3e qcow: Add migration blocker
qcow caches L2 tables. For migration to work, they would have to be
invalidated. Block migration for now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-23 17:03:59 +01:00
Dong Xu Wang c3fecea50d sheepdog: Avoid deadlock in error path
s->lock should be unlocked before leaving add_aio_request.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-22 10:33:43 +01:00
Stefan Weil 2923d34fdc Include zlib.h using #include <>
zlib.h is not a local include file, therefore it should be included
using <> instead of "".

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-21 15:05:59 -06:00
Anthony Liguori 1ed520c66e qed: add migration blocker (v2)
Now when you try to migrate with qed, you get:

(qemu) migrate tcp:localhost:1025
Block format 'qed' used by device 'ide0-hd0' does not support feature 'live migration'
(qemu)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-21 14:58:48 -06:00
Anthony Liguori 06d9260ffa qcow2: implement bdrv_invalidate_cache (v2)
We don't reopen the actual file, but instead invoke the close and open routines.
We specifically ignore the backing file since it's contents are read-only and
therefore immutable.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-11-21 14:58:48 -06:00
Kevin Wolf eb489bb1ec block: Introduce bdrv_co_flush_to_os
qcow2 has a writeback metadata cache, so flushing a qcow2 image actually
consists of writing back that cache to the protocol and only then flushes the
protocol in order to get everything stable on disk.

This introduces a separate bdrv_co_flush_to_os to reflect the split.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-11 14:02:59 +01:00
Kevin Wolf c68b89acd6 block: Rename bdrv_co_flush to bdrv_co_flush_to_disk
There are two different types of flush that you can do: Flushing one level up
to the OS (i.e. writing data to the host page cache) or flushing it all the way
down to the disk. The existing functions flush to the disk, reflect this in the
function name.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-11 14:02:59 +01:00
Charles Arnold 78439f6af1 block: Fix vpc initialization of the Dynamic Disk Header
The Data Offset field in the Dynamic Disk Header is an 8 byte field.
Although the specification (2006-10-11) gives an example of initializing
only the first 4 bytes, images generated by Microsoft on Windows initialize
all 8 bytes.

Failure to initialize all 8 bytes results in errors from utilities
like Citrix's vhd-util which checks specifically for the proper Data
Offset field initialization.

Signed-off-by: Charles Arnold <carnold@suse.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-11 14:02:58 +01:00
Kevin Wolf 7704df98b0 vvfat: Fix read-write mode
vvfat used to directly call into the qcow2 block driver instead of using the
block.c wrappers. With the coroutine conversion, this stopped working.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2011-11-11 14:02:57 +01:00
Paolo Bonzini 273e4e03b3 vvfat: reorganize computation of disk geometry
First determine FAT12/16/32, then compute geometry from that for both
FDD and HDD.  For 1.44MB floppies, and 2.88MB floppies using FAT16,
change to 1 sector/cluster.  The default remains 2.88MB with FAT12
and 2 sectors/cluster.  Both DOS and mkdosfs by default format a 2.88MB
floppy as FAT12.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 17:32:23 +01:00
Paolo Bonzini d71cff42e4 vvfat: do not hardcode sector counts in error message
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 16:36:25 +01:00
Paolo Bonzini 5a742b5557 vvfat: unify and correct computation of sector count
The sector count is stored in the partition and hence must not include the
sectors before its start.  At the same time, remove the useless special
casing for 1.44 MB floppies.  This fixes fsck on VVFAT hard disks,
which otherwise tries to seek past the end of the disk.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 16:27:07 +01:00
Paolo Bonzini aad37c06dd vvfat: need to use first_sectors_number to distinguish fdd/hdd
This is consistent with what "real" floppies have, so file(1)
now actually recognizes the VVFAT image as a 1.44 MB floppy.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 16:23:25 +01:00
Paolo Bonzini e654bfe4c1 vvfat: do not fail if the disk has spare sectors
If the number of "faked sectors" + the number of sectors that are
part of a cluster does not sum up to the total number of sectors,
qemu-img convert fails.  Read these spare sectors as all zeros.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 15:55:45 +01:00
Paolo Bonzini 2b6a43a835 vvfat: fix out of bounds array_get usage
When reading the address of the first free entry, you cannot
use array_get without first marking all entries as occupied.

This is visible if you change the sectors per cluster on a
floppy from 2 to 1.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 15:42:44 +01:00
Dong Xu Wang 756f51e408 block/cloop: Use g_free instead of free
Fix mismatching allocation and deallocation: g_free should be used to pair with
g_malloc.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed_by: Ray Wang <raywang@linux.vnet.ibm.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 14:24:12 +01:00
Dong Xu Wang 5b47b7c3d3 block/cloop: Fix coding style
Fix coding style in block/cloop.c.

Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed_by: Ray Wang <raywang@linux.vnet.ibm.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-11-04 14:24:08 +01:00
Anthony Liguori 8494a397b6 Merge remote-tracking branch 'kwolf/for-anthony' into staging
Conflicts:
	block/vmdk.c
2011-10-31 11:09:00 -05:00
Anthony Liguori 3a069ff11b Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-10-31 10:23:15 -05:00
Dong Xu Wang c95de7e2c4 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>
2011-10-28 19:25:49 +02:00
Kevin Wolf 93897b9fd4 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>
2011-10-28 19:25:49 +02:00
Kevin Wolf 99f1835d9b vmdk: Improve error handling
Return the right error values in some more places.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28 19:25:49 +02:00
Kevin Wolf bac8d7b45d vmdk: Fix use of uninitialised value
In error cases, cid is never set.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28 19:25:49 +02:00
Kevin Wolf 64ebe71aa0 qcow: Fix bdrv_write_compressed error handling
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2011-10-28 19:25:49 +02:00
Eric Sunshine c794b4e0fd 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>
2011-10-28 19:25:49 +02:00
Ronnie Sahlberg c589b24972 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>
2011-10-28 19:25:48 +02:00
Pavel Borzenkov 512a2cf8e9 qed: remove unneeded variable assignment
'ret' is unconditionally overwitten by qed_read_l1_table_sync()

Spotted by Clang Analyzer

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-26 13:36:35 +01:00
Pavel Borzenkov feba23b143 qed: don't pass NULL to memcpy
Spotted by Clang Analyzer

[Note this memcpy call has always been safe because the length will be 0
when the pointer is NULL]

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-26 13:36:35 +01:00
Pavel Borzenkov 8379e46d1f vmdk: vmdk_read_cid returns garbage if p_name is NULL
Spotted by Clang Analyzer

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-26 13:36:35 +01:00
Pavel Borzenkov c18a1c8805 vmdk: remove unneeded variable assignment
Spotted by Clang Analyzer

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-10-26 13:36:35 +01:00