History | View | Annotate | Download (59.1 kB)
block drivers: expose requirement for write same alignment from formats
This will let misaligned but large requests use zero clusters. Thisis important because the cluster size is not guest visible.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Peter Lieven <pl@kamp.de>...
vmdk: Fix creating big description file
The buffer for description file was 4096 which only covers a fewhundred of extents. This changes the buffer to dynamic allocated withg_strdup_printf in order to support bigger cases.
Signed-off-by: Fam Zheng <famz@redhat.com>...
vmdk: Allow read only open of VMDK version 3
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Use BDRV_O_NO_BACKING where appropriate
If you open an image temporarily just because you want to check its sizeor get it flushed, there's no real reason to open the whole backing filechain.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Fam Zheng <famz@redhat.com>...
block: add flags to bdrv_*_write_zeroes
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vmdk: Implment bdrv_get_specific_info
Implement .bdrv_get_specific_info to return the extent information.
vmdk: fix VMFS extent parsing
The VMFS extent line in description file doesn't have start offset asFLAT lines does, and it should be defaulted to 0. The flat_offsetvariable is initialized to -1, so we need to set it in this case.
vmdk: Only read cid from image file when opening
Previously cid of parent is parsed from image file for every IO request.We already have L1/L2 cache and don't have assumption that parent imagecan be updated behind us, so remove this to get more efficiency....
vmdk: Fix vmdk_parse_extents
An extra 'p++' after while loop when *p == '\n' will move p to unknowndata position, risking parsing junk data or memory access violation.
Cc: qemu-stable@nongnu.orgSigned-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vmdk: convert error code to use errp
Convert "fprintf(stderr,..." and standardize error messages:
Remove a few local_error's and use errp.
Remove "VMDK:" or "Vmdk:" prefixes in error message and fix to uppercase.
vmdk: refuse enabling zeroed grain with flat images
This is a header flag and we needs sparse for the header.
vmdk: fix cluster size check for flat extents
We use the extent size as cluster size for flat extents (where no L1/L2table is allocated so it's safe) reuse sector calculating code withsparse extents.
Don't pass in the cluster size for adding flat extent, just set it to...
bdrv: Use "Error" for creating images
Add an Error ** parameter to BlockDriver.bdrv_create to allow morespecific error messages.
Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Error parameter for open functions
Add an Error ** parameter to bdrv_open, bdrv_file_open and associatedfunctions to allow more specific error messages.
bdrv: Use "Error" for opening images
Add an Error ** parameter to BlockDriver.bdrv_open andBlockDriver.bdrv_file_open to allow more specific error messages.
block: introduce bdrv_get_block_status API
For now, bdrv_get_block_status is just another name for bdrv_is_allocated.The next patches will add more flags.
This also touches all block drivers with a mostly mechanical rename. Thesole exception is cow; because it calls cow_co_is_allocated from the read...
block: return get_block_status data and flags for formats
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: make bdrv_delete() static
Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is nolonger public and should be called by bdrv_unref() if refcnt isdecreased to 0.
This is an identical change because effectively, there's no multiplereference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets...
vmdk: Move l1_size check into vmdk_add_extent()
This header check is common to VMDK3 and VMDK4, so move it intovmdk_add_extent().
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vmdk: fix L1 and L2 table size in vmdk3 open
VMDK3 header has the field l1dir_size, but vmdk_open_vmdk3 hardcoded thevalue. This patch honors the header field.
And the L2 table size is 4096 according to VMDK spec1, instead of1 << 9 (512).
[1]:http://www.vmware.com/support/developer/vddk/vmdk_50_technote.pdf?src=vmdk...
vmdk: support vmfsSparse files
VMware ESX hosts use a variant of the VMDK3 format, identified by thevmfsSparse create type ad the VMFSSPARSE extent type.
It has 16 KB grain tables (L2) and a variable-size grain directory (L1).In addition, the grain size is always 512, but that is not a problem...
vmdk: support vmfs files
VMware ESX hosts also use different create and extent types for flatfiles, respectively "vmfs" and "VMFS". This is not documented, but itcan be found at http://kb.vmware.com/kb/10002511 (Recreating a missingvirtual machine disk (VMDK) descriptor file)....
vmdk: Make VMDK3Header and VmdkGrainMarker QEMU_PACKED
It's best to make it consistent that all on disk structures areQEMU_PACKED.
vmdk: use unsigned values for on disk header fields
The size and offset fields are all non-negative values, use uint64_t forthem to avoid getting negative in memory value by int overflow.
vmdk: check granularity field in opening
Granularity is used to calculate the cluster size and allocate r/wbuffer. Check the value from image before using it, so we don't abort()for unbounded memory allocation.
vmdk: check l2 table size when opening
header.num_gtes_per_gte determines size for L2 table. Check for too bigvalue before using it. Limit to 512M entries (2GB per one L2 table).
vmdk: check l1 size before opening image
L1 table size is calculated from capacity, granularity and l2 tablesize. If capacity is too big or later two are too small, the L1 tablewill be too big to allocate in memory. Limit it to a reasonable range.
vmdk: use heap allocation for whole_grain
We should never grow the stack beyond 1 MB, otherwise we'll fall off theend. Thread stacks and coroutine stacks (1 MB) do not grow.get_cluster_offset() allocates a big stack offset, it will fail for bigcluster images, change to heap allocated buffer....
vmdk: rename num_gtes_per_gte to num_gtes_per_gt
num_gtes_per_gte is a historical typo, rename it to a more sensiblename. It means "number of GrainTableEntries per GrainTable".
vmdk: fix comment for vmdk_co_write_zeroes
The comment was truncated. Add the missing parts, especially explain whywe need zero_dry_run.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
vmdk: Implement .bdrv_has_zero_init
Depending on the subformat, has_zero_init queries underlying storage forflat extent. If it has a flat extent and its underlying storage doesn'thave zero init, return 0. Otherwise return 1.
Aligns the operator assignments....
vmdk: remove wrong calculation of relative path
When creating image with backing file, the driver tries to calculate therelative path from created image file to backing file, but the pathcomputation is incorrect. e.g.:
$ qemu-img create -f vmdk -b vmdk-data-disk.vmdk vmdk-data-snapshot1...
vmdk: refuse to open higher version than supported
Refuse to open higher version for safety.
Although we try to be compatible with published VMDK spec, VMware hasnewer version from ESXi 5.1 exported OVF/OVA, which we have no knowledgewhat's changed in it. And it is very likely to have more new versions in...
vmdk: byteswap VMDK4Header.desc_offset field
Remember to byteswap VMDK4Header.desc_offset on big-endian machines.
Cc: qemu-stable@nongnu.orgSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vmdk: Allow reading variable size descriptor files
the hard-coded 2k buffer on the stack won't allow reading big descriptorfiles which can be generated when storing big images. For example 500Gvmdk splitted to 2G chunks.
Signed-off-by: Evgeny Budilovsky <evgeny.budilovsky@ravellosystems.com>...
vmdk: add bdrv_co_write_zeroes
Use special offset to write zeroes efficiently, when zeroed-grain GTE isavailable. If zero-write an allocated cluster, cluster is leaked becauseits offset pointer is overwritten by "0x1".
vmdk: store fields of VmdkMetaData in cpu endian
Previously VmdkMetaData.offset is stored little endian while otherfields are cpu endian. This changes offset to cpu endian and convertbefore writing to image.Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vmdk: change magic number to macro
Two hard coded flag bits are changed to macros.Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vmdk: Add option to create zeroed-grain image
Add image create option "zeroed-grain" to enable zeroed-grain GTEfeature of vmdk sparse extents. When this option is on, header versionof newly created extent will be 2 and VMDK4_FLAG_ZERO_GRAIN flag bitwill be set....
vmdk: add support for “zeroed‐grain” GTE
Introduced support for zeroed-grain GTE, as specified in Virtual DiskFormat 5.01.
Recent VMware hosted platform products support a new “zeroed‐grain” grain table entry (GTE). The zeroed‐grain GTE returns all zeros on...
vmdk: named return code.
Internal routines in vmdk.c previously return -1 on error and 0 onsuccess. More return values are useful for future changes such aszeroed-grain GTE. Change all the magic `return 0` and `return -1` tomacro names:
block: Add options QDict to bdrv_file_open() prototypes
The new parameter is unused yet.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
block: Add options QDict to .bdrv_open()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: Add options QDict to bdrv_open() prototype
It doesn't do anything yet except storing the options QDict in theBlockDriverState.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>...
vmdk: Allow space in file name
The previous scanf() format string stopped parsing the file name on thefirst white white space, which seems to be allowed at least by VMwareWorkstation.
Change the format string to collect everything between the first and...
vmdk: Allow selecting SCSI adapter in image creation
Introduce a new option "adapter_type" when converting to vmdk images.It can be one of the following: ide (default), buslogic, lsilogicor legacyESX (according to the vmdk spec from vmware).
In case of a non-ide adapter, heads is set to 255 instead of the 16....
block: Use error code EMEDIUMTYPE for wrong format in some block drivers
This improves error reports for bochs, cow, qcow, qcow2, qed and vmdkwhen a file with the wrong format is selected.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Eric Blake <eblake@redhat.com>...
misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
migration: move include files to include/migration/
block: move include files to include/block/
vmdk: Fix data corruption bug in WRITE and READ handling
Fixed a MAJOR BUG in VMDK files on file boundaries on readsand ALSO ON WRITES WHICH MIGHT CORRUPT THE IMAGE AND DATA!!!!!!
Triggered for example with the following VMDK file (partly listed):RW 4193792 FLAT "XP-W1-f001.vmdk" 0...
vmdk: relative_path: use pstrcpy in place of strncpy
Avoid strncpy+manual-NUL-terminate. Use pstrcpy instead.
Acked-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: vmdk image file reopen
This patch supports reopen for VMDK image files. VMDK extents are addedto the existing reopen queue, so that the transactional model of reopenis maintained with multiple image files.
Signed-off-by: Jeff Cody <jcody@redhat.com>...
vmdk: Read footer for streamOptimized images
The footer takes precedence over the header when it exists. It containsthe real grain directory offset that is missing in the header. Withoutthis patch, streamOptimized images with a footer cannot be read.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
vmdk: Fix header structure
Commit bb45ded9 swapped gd_offset and rgd_offset. This is wrong.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Convert open calls to qemu_open
This patch converts all block layer open calls to qemu_open.
Note that this adds the O_CLOEXEC flag to the changed open pathswhen the O_CLOEXEC macro is defined.
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>...
block: Convert close calls to qemu_close
This patch converts all block layer close calls, that correspondto qemu_open calls, to qemu_close.
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: push recursive flushing up from drivers
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vmdk: Fix warning from splint (comparision of unsigned value)
l1_entry_sectors will never be less than 0.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
block: convert qcow2, qcow2, and vmdk to .bdrv_co_is_allocated()
The qcow2, qcow, and vmdk block drivers are based on coroutines. They have acoroutine mutex which protects internal state. We can convert the.bdrv_is_allocated() function to .bdrv_co_is_allocated() by holding the mutex...
vmdk: Add migration blocker
VMDK caches L2 tables. For migration to work, they would have to beinvalidated. Block migration for now.
Include zlib.h using #include <>
zlib.h is not a local include file, therefore it should be includedusing <> instead of "".
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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 upto the OS (i.e. writing data to the host page cache) or flushing it all the waydown to the disk. The existing functions flush to the disk, reflect this in the...
Merge remote-tracking branch 'kwolf/for-anthony' into staging
Conflicts: block/vmdk.c
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
vmdk: Fix use of uninitialised value
In error cases, cid is never set.
vmdk: Improve error handling
Return the right error values in some more places.
vmdk: Fix possible segfaults
Data we read from the disk isn't necessarily null terminated and may notcontain the string we're looking for. The code needs to be a bit more carefulhere.
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>
vmdk: vmdk_read_cid returns garbage if p_name is NULL
block: take lock around bdrv_read implementations
This does the first part of the conversion to coroutines, bywrapping bdrv_read implementations to take the mutex.
Drivers that implement bdrv_read rather than bdrv_co_readv canthen benefit from asynchronous operation (at least if the underlying...
block: take lock around bdrv_write implementations
This does the first part of the conversion to coroutines, bywrapping bdrv_write implementations to take the mutex.
Drivers that implement bdrv_write rather than bdrv_co_writev canthen benefit from asynchronous operation (at least if the underlying...
block: change flush to co_flush
Since coroutine operation is now mandatory, convert all bdrv_flushimplementations to coroutines. For qcow2, this means taking the lock.Other implementations are simpler and just forward bdrv_flush to theunderlying protocol, so they can avoid the lock....
vmdk: fix return values of vmdk_parent_open
While vmdk_open_desc_file (touched by the patch) correctly changed -1to -EINVAL, vmdk_open did not. Fix it directly in vmdk_parent_open.
vmdk: clean up open
Move vmdk_parent_open to vmdk_open. There's another path howvmdk_parent_open can be reached:
vmdk_parse_extents() -> vmdk_open_sparse() -> vmdk_open_vmdk4() -> vmdk_open_desc_file().
If that can happen, however, the code is bogus. vmdk_parent_open...
block: add a CoMutex to synchronous read drivers
The big conversion of bdrv_read/write to coroutines caused the twohomonymous callbacks in BlockDriver to become reentrant. It goeslike this:
1) bdrv_read is now called in a coroutine, and calls bdrv_read or...
VMDK: fix leak of extent_file
Release extent_file on error in vmdk_parse_extents. Added closing filesin freeing extents.
Signed-off-by: Fam Zheng <famcool@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
VMDK: bugfix, opening vSphere 4 exported image
The vSphere 4 exported image is streamOptimized extent, which is notquite correctly handled. Ignore rdgOffset when RGD flag bit not set.
Signed-off-by: Fam Zheng <famcool@gmail.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
VMDK: bugfix, open Haiku vmdk image
Haiku provides a specially formed vmdk image, which let qemu abort. It acombination of sparse header and flat data (i.e. with not l1/l2 table atall). The fix is turn to descriptor when sparse header is zero in field'capacity'....
VMDK: creating streamOptimized subformat
Creating streamOptimized subformat. Added subformat option'streamOptimized', to create a image with compression enabled and eachcluster with a GrainMarker.
VMDK: read/write compressed extent
Add support for reading/writing compressed extent.
Signed-off-by: Fam Zheng <famcool@gmail.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
VMDK: Opening compressed extent.
Added flags field for compressed/streamOptimized extents, open and saveimage configuration.
VMDK: separate vmdk_read_extent/vmdk_write_extent
Factor out read/write extent code, since there will be more things totake care of once reading/writing compressed clusters is introduced.
VMDK: add twoGbMaxExtentSparse support
Add twoGbMaxExtentSparse support. Introduce vmdk_free_last_extent.
VMDK: enable twoGbMaxExtentFlat
Enable the createType 'twoGbMaxExtentFlat'. The supporting code isalready in.
Use new macro QEMU_PACKED for packed structures
Most changes were made using these commands:
git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: add bdrv_get_allocated_file_size() operation
qemu-img.c wants to count allocated file size of image. Previously itcounts a single bs->file by 'stat' or Window API. As VMDK introducesmultiple file support, the operation becomes format specific with...
VMDK: move 'static' cid_update flag to bs field
Cid_update is the flag for updating CID on first write after opening theimage. This should be per image open rather than per program life cycle,so change it from static var of vmdk_write to a field in BDRVVmdkState....
VMDK: change get_cluster_offset return type
The return type of get_cluster_offset was an offset that use 0 to denote'not allocated', this will be no longer true for flat extents, as we seeflat extent file as a single huge cluster whose offset is 0 and length...
VMDK: open/read/write for monolithicFlat image
Parse vmdk decriptor file and open mono flat image.Read/write the flat extent.
VMDK: create different subformats
Add create option 'format', with enums: monolithicSparse monolithicFlat twoGbMaxExtentSparse twoGbMaxExtentFlatEach creates a subformat image file. The default is monolithicSparse.
Signed-off-by: Fam Zheng <famcool@gmail.com>...
VMDK: fix coding style
Conform coding style in vmdk.c to pass scripts/checkpatch.pl checks.
VMDK: bugfix, align offset to cluster in get_whole_cluster
In get_whole_cluster, the offset is not aligned to cluster when readingfrom backing_hd. When the first write to child is not at the clusterboundary, wrong address data from parent is copied to child....
VMDK: probe for monolithicFlat images
Probe as the same behavior as VMware does.Recognize image as monolithicFlat descriptor file when the file is textand the first effective line (not '#' leaded comment or space line) iseither 'version=1' or 'version=2'. No space or upper case charactors...
VMDK: separate vmdk_open by format version
VMDK: add field BDRVVmdkState.desc_offset
There are several occurrence of magic number 0x200 as the descriptoroffset within mono sparse image file. This is not the case for imageswith separate descriptor file. So a field is added to BDRVVmdkState tohold the correct value....
VMDK: flush multiple extents
Flush all the file that referenced by the image.
VMDK: introduce VmdkExtent
Introduced VmdkExtent array into BDRVVmdkState, enable holding multipleimage extents for multiple file image support.
vmdk: fix endianness bugs
The vmdk code is sloppy when handling the header descriptor duringcreation of an image. Fix all header accesses in the create path toeither store native endianness or convert it when appropriate.
Reported-by: Yury Tsarev <ytsarev@novell.com>...