diff options
Diffstat (limited to 'block')
53 files changed, 131 insertions, 71 deletions
diff --git a/block/accounting.c b/block/accounting.c index 185025ec1e..3f457c4e73 100644 --- a/block/accounting.c +++ b/block/accounting.c @@ -23,6 +23,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "block/accounting.h" #include "block/block_int.h" #include "qemu/timer.h" diff --git a/block/archipelago.c b/block/archipelago.c index 855655c6bd..0507589063 100644 --- a/block/archipelago.c +++ b/block/archipelago.c @@ -50,6 +50,7 @@ * */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/error-report.h" @@ -59,7 +60,6 @@ #include "qapi/qmp/qjson.h" #include "qemu/atomic.h" -#include <inttypes.h> #include <xseg/xseg.h> #include <xseg/protocol.h> diff --git a/block/backup.c b/block/backup.c index 705bb77661..00cafdbe2b 100644 --- a/block/backup.c +++ b/block/backup.c @@ -11,9 +11,7 @@ * */ -#include <stdio.h> -#include <errno.h> -#include <unistd.h> +#include "qemu/osdep.h" #include "trace.h" #include "block/block.h" diff --git a/block/blkdebug.c b/block/blkdebug.c index 86b143dc2d..f85c54bdc8 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/config-file.h" #include "block/block_int.h" diff --git a/block/blkverify.c b/block/blkverify.c index 1d754496bc..2a885cc08d 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -7,7 +7,7 @@ * See the COPYING file in the top-level directory. */ -#include <stdarg.h> +#include "qemu/osdep.h" #include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "block/block_int.h" #include "qapi/qmp/qdict.h" diff --git a/block/block-backend.c b/block/block-backend.c index e81375955f..efd61464da 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -10,6 +10,7 @@ * or later. See the COPYING.LIB file in the top-level directory. */ +#include "qemu/osdep.h" #include "sysemu/block-backend.h" #include "block/block_int.h" #include "block/blockjob.h" diff --git a/block/bochs.c b/block/bochs.c index 18949b9d4f..8b953bb44c 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -22,6 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" diff --git a/block/cloop.c b/block/cloop.c index 4190ae06d7..41bdee8d7f 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" diff --git a/block/commit.c b/block/commit.c index a5d02aa560..446a3aeadd 100644 --- a/block/commit.c +++ b/block/commit.c @@ -12,6 +12,7 @@ * */ +#include "qemu/osdep.h" #include "trace.h" #include "block/block_int.h" #include "block/blockjob.h" diff --git a/block/curl.c b/block/curl.c index 89941826ed..1507e0ac34 100644 --- a/block/curl.c +++ b/block/curl.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/error-report.h" #include "block/block_int.h" diff --git a/block/dmg.c b/block/dmg.c index 546a6f5330..1018fd158e 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/bswap.h" diff --git a/block/gluster.c b/block/gluster.c index 0857c14645..65077a0d0a 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -7,6 +7,7 @@ * See the COPYING file in the top-level directory. * */ +#include "qemu/osdep.h" #include <glusterfs/api/glfs.h> #include "block/block_int.h" #include "qemu/uri.h" diff --git a/block/io.c b/block/io.c index 63e3678036..5bb353a8ca 100644 --- a/block/io.c +++ b/block/io.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "trace.h" #include "sysemu/block-backend.h" #include "block/blockjob.h" @@ -1300,6 +1301,7 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs, if (bs->read_only) { return -EPERM; } + assert(!(bs->open_flags & BDRV_O_INACTIVE)); ret = bdrv_check_byte_request(bs, offset, bytes); if (ret < 0) { @@ -2461,6 +2463,7 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, } else if (bs->read_only) { return -EPERM; } + assert(!(bs->open_flags & BDRV_O_INACTIVE)); /* Do nothing if disabled. */ if (!(bs->open_flags & BDRV_O_UNMAP)) { diff --git a/block/iscsi.c b/block/iscsi.c index 3acb052b1f..bffd707b8b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -#include "config-host.h" +#include "qemu/osdep.h" #include <poll.h> #include <math.h> diff --git a/block/linux-aio.c b/block/linux-aio.c index 88b0520a8b..805757e02e 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -7,6 +7,7 @@ * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/aio.h" #include "qemu/queue.h" diff --git a/block/mirror.c b/block/mirror.c index f201f2b18a..e9e151c341 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -11,6 +11,7 @@ * */ +#include "qemu/osdep.h" #include "trace.h" #include "block/blockjob.h" #include "block/block_int.h" diff --git a/block/nbd-client.c b/block/nbd-client.c index b7fd17a115..568c56cbb6 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -26,6 +26,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "nbd-client.h" #include "qemu/sockets.h" diff --git a/block/nbd.c b/block/nbd.c index 416f42b903..1a90bc7855 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -26,6 +26,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "block/nbd-client.h" #include "qemu/uri.h" #include "block/block_int.h" @@ -36,8 +37,6 @@ #include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" -#include <sys/types.h> -#include <unistd.h> #define EN_OPTSTR ":exportname=" diff --git a/block/nfs.c b/block/nfs.c index fd79f89945..5eb8c133b9 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "config-host.h" +#include "qemu/osdep.h" #include <poll.h> #include "qemu-common.h" diff --git a/block/null.c b/block/null.c index 7d083233fb..d90165dea7 100644 --- a/block/null.c +++ b/block/null.c @@ -10,6 +10,7 @@ * See the COPYING file in the top-level directory. */ +#include "qemu/osdep.h" #include "block/block_int.h" #define NULL_OPT_LATENCY "latency-ns" diff --git a/block/parallels.c b/block/parallels.c index e4a56a5141..ee390815dc 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -27,6 +27,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" diff --git a/block/qapi.c b/block/qapi.c index 58d3975001..a49c118ba0 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "block/qapi.h" #include "block/block_int.h" #include "block/throttle-groups.h" diff --git a/block/qcow.c b/block/qcow.c index 635085e27b..afed18fe98 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c index 86dd7f2bd9..0fe8edae41 100644 --- a/block/qcow2-cache.c +++ b/block/qcow2-cache.c @@ -23,7 +23,7 @@ */ /* Needed for CONFIG_MADVISE */ -#include "config-host.h" +#include "qemu/osdep.h" #if defined(CONFIG_MADVISE) || defined(CONFIG_POSIX_MADVISE) #include <sys/mman.h> @@ -31,7 +31,6 @@ #include "block/block_int.h" #include "qemu-common.h" -#include "qemu/osdep.h" #include "qcow2.h" #include "trace.h" diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 34112c3abb..3e887e9ab0 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include <zlib.h> #include "qemu-common.h" diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index af493f8bfe..52a0a9ffc3 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "block/qcow2.h" diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index def720164d..13f88d1b8b 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "block/qcow2.h" diff --git a/block/qcow2.c b/block/qcow2.c index d992e7fac7..fd8436c5f8 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" @@ -1140,7 +1141,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } /* Clear unknown autoclear feature bits */ - if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) { + if (!bs->read_only && !(flags & BDRV_O_INACTIVE) && s->autoclear_features) { s->autoclear_features = 0; ret = qcow2_update_header(bs); if (ret < 0) { @@ -1153,7 +1154,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, qemu_co_mutex_init(&s->lock); /* Repair image if dirty */ - if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only && + if (!(flags & (BDRV_O_CHECK | BDRV_O_INACTIVE)) && !bs->read_only && (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) { BdrvCheckResult result = {0}; @@ -1685,6 +1686,32 @@ fail: return ret; } +static int qcow2_inactivate(BlockDriverState *bs) +{ + BDRVQcow2State *s = bs->opaque; + int ret, result = 0; + + ret = qcow2_cache_flush(bs, s->l2_table_cache); + if (ret) { + result = ret; + error_report("Failed to flush the L2 table cache: %s", + strerror(-ret)); + } + + ret = qcow2_cache_flush(bs, s->refcount_block_cache); + if (ret) { + result = ret; + error_report("Failed to flush the refcount block cache: %s", + strerror(-ret)); + } + + if (result == 0) { + qcow2_mark_clean(bs); + } + + return result; +} + static void qcow2_close(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; @@ -1692,24 +1719,8 @@ static void qcow2_close(BlockDriverState *bs) /* else pre-write overlap checks in cache_destroy may crash */ s->l1_table = NULL; - if (!(bs->open_flags & BDRV_O_INCOMING)) { - int ret1, ret2; - - ret1 = qcow2_cache_flush(bs, s->l2_table_cache); - ret2 = qcow2_cache_flush(bs, s->refcount_block_cache); - - if (ret1) { - error_report("Failed to flush the L2 table cache: %s", - strerror(-ret1)); - } - if (ret2) { - error_report("Failed to flush the refcount block cache: %s", - strerror(-ret2)); - } - - if (!ret1 && !ret2) { - qcow2_mark_clean(bs); - } + if (!(s->flags & BDRV_O_INACTIVE)) { + qcow2_inactivate(bs); } cache_clean_timer_del(bs); @@ -1753,20 +1764,24 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp) bdrv_invalidate_cache(bs->file->bs, &local_err); if (local_err) { error_propagate(errp, local_err); + bs->drv = NULL; return; } memset(s, 0, sizeof(BDRVQcow2State)); options = qdict_clone_shallow(bs->options); + flags &= ~BDRV_O_INACTIVE; ret = qcow2_open(bs, options, flags, &local_err); QDECREF(options); if (local_err) { error_propagate(errp, local_err); error_prepend(errp, "Could not reopen qcow2 layer: "); + bs->drv = NULL; return; } else if (ret < 0) { error_setg_errno(errp, -ret, "Could not reopen qcow2 layer"); + bs->drv = NULL; return; } @@ -1894,31 +1909,33 @@ int qcow2_update_header(BlockDriverState *bs) } /* Feature table */ - Qcow2Feature features[] = { - { - .type = QCOW2_FEAT_TYPE_INCOMPATIBLE, - .bit = QCOW2_INCOMPAT_DIRTY_BITNR, - .name = "dirty bit", - }, - { - .type = QCOW2_FEAT_TYPE_INCOMPATIBLE, - .bit = QCOW2_INCOMPAT_CORRUPT_BITNR, - .name = "corrupt bit", - }, - { - .type = QCOW2_FEAT_TYPE_COMPATIBLE, - .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, - .name = "lazy refcounts", - }, - }; + if (s->qcow_version >= 3) { + Qcow2Feature features[] = { + { + .type = QCOW2_FEAT_TYPE_INCOMPATIBLE, + .bit = QCOW2_INCOMPAT_DIRTY_BITNR, + .name = "dirty bit", + }, + { + .type = QCOW2_FEAT_TYPE_INCOMPATIBLE, + .bit = QCOW2_INCOMPAT_CORRUPT_BITNR, + .name = "corrupt bit", + }, + { + .type = QCOW2_FEAT_TYPE_COMPATIBLE, + .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, + .name = "lazy refcounts", + }, + }; - ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, - features, sizeof(features), buflen); - if (ret < 0) { - goto fail; + ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, + features, sizeof(features), buflen); + if (ret < 0) { + goto fail; + } + buf += ret; + buflen -= ret; } - buf += ret; - buflen -= ret; /* Keep unknown header extensions */ QLIST_FOREACH(uext, &s->unknown_header_ext, next) { @@ -2236,6 +2253,13 @@ static int qcow2_create2(const char *filename, int64_t total_size, abort(); } + /* Create a full header (including things like feature table) */ + ret = qcow2_update_header(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Could not update qcow2 header"); + goto out; + } + /* Okay, now that we have a valid image, let's give it the right size */ ret = bdrv_truncate(bs, total_size); if (ret < 0) { @@ -3330,6 +3354,7 @@ BlockDriver bdrv_qcow2 = { .bdrv_refresh_limits = qcow2_refresh_limits, .bdrv_invalidate_cache = qcow2_invalidate_cache, + .bdrv_inactivate = qcow2_inactivate, .create_opts = &qcow2_create_opts, .bdrv_check = qcow2_check, diff --git a/block/qed-check.c b/block/qed-check.c index 36ecd290d6..622f308976 100644 --- a/block/qed-check.c +++ b/block/qed-check.c @@ -11,6 +11,7 @@ * */ +#include "qemu/osdep.h" #include "qed.h" typedef struct { diff --git a/block/qed-cluster.c b/block/qed-cluster.c index f64b2af8f7..c24e75616a 100644 --- a/block/qed-cluster.c +++ b/block/qed-cluster.c @@ -12,6 +12,7 @@ * */ +#include "qemu/osdep.h" #include "qed.h" /** diff --git a/block/qed-gencb.c b/block/qed-gencb.c index b817a8bf50..faf8ecc840 100644 --- a/block/qed-gencb.c +++ b/block/qed-gencb.c @@ -11,6 +11,7 @@ * */ +#include "qemu/osdep.h" #include "qed.h" void *gencb_alloc(size_t len, BlockCompletionFunc *cb, void *opaque) diff --git a/block/qed-l2-cache.c b/block/qed-l2-cache.c index e9b2aae44d..5cba794650 100644 --- a/block/qed-l2-cache.c +++ b/block/qed-l2-cache.c @@ -50,6 +50,7 @@ * table will be deleted in favor of the existing cache entry. */ +#include "qemu/osdep.h" #include "trace.h" #include "qed.h" diff --git a/block/qed-table.c b/block/qed-table.c index f4219b8acc..802945f5e5 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -12,6 +12,7 @@ * */ +#include "qemu/osdep.h" #include "trace.h" #include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "qed.h" diff --git a/block/qed.c b/block/qed.c index 31f4cc9e60..0c870cd90f 100644 --- a/block/qed.c +++ b/block/qed.c @@ -12,6 +12,7 @@ * */ +#include "qemu/osdep.h" #include "qemu/timer.h" #include "trace.h" #include "qed.h" @@ -477,7 +478,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, * feature is no longer valid. */ if ((s->header.autoclear_features & ~QED_AUTOCLEAR_FEATURE_MASK) != 0 && - !bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INCOMING)) { + !bdrv_is_read_only(bs->file->bs) && !(flags & BDRV_O_INACTIVE)) { s->header.autoclear_features &= QED_AUTOCLEAR_FEATURE_MASK; ret = qed_write_header_sync(s); @@ -505,7 +506,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, * aid data recovery from an otherwise inconsistent image. */ if (!bdrv_is_read_only(bs->file->bs) && - !(flags & BDRV_O_INCOMING)) { + !(flags & BDRV_O_INACTIVE)) { BdrvCheckResult result = {0}; ret = qed_check(s, &result, true); diff --git a/block/quorum.c b/block/quorum.c index 6793f126c5..a5ae4b812b 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -13,6 +13,7 @@ * See the COPYING file in the top-level directory. */ +#include "qemu/osdep.h" #include "block/block_int.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" diff --git a/block/raw-posix.c b/block/raw-posix.c index 076d0708a7..6df3067ddf 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/error-report.h" #include "qemu/timer.h" @@ -51,8 +52,6 @@ #include <sys/dkio.h> #endif #ifdef __linux__ -#include <sys/types.h> -#include <sys/stat.h> #include <sys/ioctl.h> #include <sys/param.h> #include <linux/cdrom.h> @@ -779,7 +778,6 @@ static int hdev_probe_geometry(BlockDriverState *bs, HDGeometry *geo) { BDRVRawState *s = bs->opaque; struct hd_geometry ioctl_geo = {0}; - uint32_t blksize; /* If DASD, get its geometry */ if (check_for_dasd(s->fd) < 0) { @@ -799,12 +797,6 @@ static int hdev_probe_geometry(BlockDriverState *bs, HDGeometry *geo) } geo->heads = ioctl_geo.heads; geo->sectors = ioctl_geo.sectors; - if (!probe_physical_blocksize(s->fd, &blksize)) { - /* overwrite cyls: HDIO_GETGEO result is incorrect for big drives */ - geo->cylinders = bdrv_nb_sectors(bs) / (blksize / BDRV_SECTOR_SIZE) - / (geo->heads * geo->sectors); - return 0; - } geo->cylinders = ioctl_geo.cylinders; return 0; diff --git a/block/raw-win32.c b/block/raw-win32.c index 2d0907a822..21a6cb89d7 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/timer.h" #include "block/block_int.h" diff --git a/block/raw_bsd.c b/block/raw_bsd.c index 915d6fd0e6..bcaee115e1 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -26,6 +26,7 @@ * IN THE SOFTWARE. */ +#include "qemu/osdep.h" #include "block/block_int.h" #include "qemu/option.h" diff --git a/block/rbd.c b/block/rbd.c index a60a19d58d..51b64f3fed 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -11,7 +11,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include <inttypes.h> +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/error-report.h" diff --git a/block/sheepdog.c b/block/sheepdog.c index 6986be8151..ff89298b13 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -12,6 +12,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/uri.h" #include "qemu/error-report.h" diff --git a/block/snapshot.c b/block/snapshot.c index 2d86b88a28..17a27b57ad 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "block/snapshot.h" #include "block/block_int.h" #include "qapi/qmp/qerror.h" diff --git a/block/ssh.c b/block/ssh.c index af025c08a0..04deeba1ad 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -22,9 +22,7 @@ * THE SOFTWARE. */ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> +#include "qemu/osdep.h" #include <libssh2.h> #include <libssh2_sftp.h> diff --git a/block/stream.c b/block/stream.c index 25af7eff62..cafaa07a01 100644 --- a/block/stream.c +++ b/block/stream.c @@ -11,6 +11,7 @@ * */ +#include "qemu/osdep.h" #include "trace.h" #include "block/block_int.h" #include "block/blockjob.h" diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 13b5baa5d7..4920e09495 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -22,6 +22,7 @@ * along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu/osdep.h" #include "block/throttle-groups.h" #include "qemu/queue.h" #include "qemu/thread.h" diff --git a/block/vdi.c b/block/vdi.c index 17f435fad6..61bcd54575 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -49,6 +49,7 @@ * so this seems to be reasonable. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" diff --git a/block/vhdx-endian.c b/block/vhdx-endian.c index 0640d3f4a9..da33cd38ef 100644 --- a/block/vhdx-endian.c +++ b/block/vhdx-endian.c @@ -15,6 +15,7 @@ * */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "block/vhdx.h" diff --git a/block/vhdx-log.c b/block/vhdx-log.c index ab86416def..369076126e 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -17,6 +17,7 @@ * See the COPYING.LIB file in the top-level directory. * */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/error-report.h" diff --git a/block/vhdx.c b/block/vhdx.c index 2fe9a5e0cf..72042e9082 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -15,6 +15,7 @@ * */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" diff --git a/block/vmdk.c b/block/vmdk.c index 2b5cb00ef1..698679d12c 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -23,6 +23,7 @@ * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qapi/qmp/qerror.h" @@ -1662,7 +1663,13 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, } magic = cpu_to_be32(VMDK4_MAGIC); memset(&header, 0, sizeof(header)); - header.version = zeroed_grain ? 2 : 1; + if (compress) { + header.version = 3; + } else if (zeroed_grain) { + header.version = 2; + } else { + header.version = 1; + } header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT | (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0) | (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0); diff --git a/block/vpc.c b/block/vpc.c index 299d373092..d852f966a0 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -22,6 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "block/block_int.h" #include "qemu/module.h" diff --git a/block/vvfat.c b/block/vvfat.c index b184eca6fc..2ea5a4ab0b 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include <sys/stat.h> +#include "qemu/osdep.h" #include <dirent.h> #include "qemu-common.h" #include "block/block_int.h" diff --git a/block/win32-aio.c b/block/win32-aio.c index bbf2f01c12..2d509a9a7b 100644 --- a/block/win32-aio.c +++ b/block/win32-aio.c @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/timer.h" #include "block/block_int.h" diff --git a/block/write-threshold.c b/block/write-threshold.c index 0fe38917c5..cc2ca71835 100644 --- a/block/write-threshold.c +++ b/block/write-threshold.c @@ -10,6 +10,7 @@ * See the COPYING.LIB file in the top-level directory. */ +#include "qemu/osdep.h" #include "block/block_int.h" #include "qemu/coroutine.h" #include "block/write-threshold.h" |