diff -Nru qemu-2.5+dfsg/debian/changelog qemu-2.5+dfsg/debian/changelog --- qemu-2.5+dfsg/debian/changelog 2016-06-03 13:24:33.000000000 -0700 +++ qemu-2.5+dfsg/debian/changelog 2016-07-14 11:30:50.000000000 -0700 @@ -1,3 +1,11 @@ +qemu (1:2.5+dfsg-5ubuntu10.3) xenial; urgency=medium + + * debian/patches/add_force_size_option.patch: block/vpc: give option + to force the current_size field in .bdrv_create. Closes LP: + #1490611. + + -- Nishanth Aravamudan Thu, 14 Jul 2016 11:27:47 -0700 + qemu (1:2.5+dfsg-5ubuntu10.2) xenial; urgency=medium * Cherrypick upstream patches to support the query-gic-version QMP command diff -Nru qemu-2.5+dfsg/debian/patches/add_force_size_option.patch qemu-2.5+dfsg/debian/patches/add_force_size_option.patch --- qemu-2.5+dfsg/debian/patches/add_force_size_option.patch 1969-12-31 16:00:00.000000000 -0800 +++ qemu-2.5+dfsg/debian/patches/add_force_size_option.patch 2016-07-14 11:27:11.000000000 -0700 @@ -0,0 +1,93 @@ +Description: block/vpc: give option to force the current_size field in .bdrv_create +Author: Nishanth Aravamudan +Origin: upstream, http://git.qemu.org/?p=qemu.git;a=commitdiff;h=fb9245c2610932d33ce14 +Bug-Ubuntu: https://launchpad.net/bugs/1490611 + +--- qemu-2.5+dfsg.orig/block/vpc.c ++++ qemu-2.5+dfsg/block/vpc.c +@@ -45,8 +45,14 @@ enum vhd_type { + // Seconds since Jan 1, 2000 0:00:00 (UTC) + #define VHD_TIMESTAMP_BASE 946684800 + ++#define VHD_CHS_MAX_C 65535LL ++#define VHD_CHS_MAX_H 16 ++#define VHD_CHS_MAX_S 255 ++ + #define VHD_MAX_SECTORS (65535LL * 255 * 255) +-#define VHD_MAX_GEOMETRY (65535LL * 16 * 255) ++#define VHD_MAX_GEOMETRY (VHD_CHS_MAX_C * VHD_CHS_MAX_H * VHD_CHS_MAX_S) ++ ++#define VPC_OPT_FORCE_SIZE "force_size" + + // always big-endian + typedef struct vhd_footer { +@@ -770,6 +776,7 @@ static int vpc_create(const char *filena + int64_t total_size; + int disk_type; + int ret = -EIO; ++ bool force_size; + Error *local_err = NULL; + BlockDriverState *bs = NULL; + +@@ -790,6 +797,8 @@ static int vpc_create(const char *filena + disk_type = VHD_DYNAMIC; + } + ++ force_size = qemu_opt_get_bool_del(opts, VPC_OPT_FORCE_SIZE, false); ++ + ret = bdrv_create_file(filename, opts, &local_err); + if (ret < 0) { + error_propagate(errp, local_err); +@@ -807,13 +816,20 @@ static int vpc_create(const char *filena + * sectors requested until we get enough (or fail). This ensures that + * qemu-img convert doesn't truncate images, but rather rounds up. + * +- * If the image size can't be represented by a spec conform CHS geometry, ++ * If the image size can't be represented by a spec conformant CHS geometry, + * we set the geometry to 65535 x 16 x 255 (CxHxS) sectors and use + * the image size from the VHD footer to calculate total_sectors. + */ +- total_sectors = MIN(VHD_MAX_GEOMETRY, total_size / BDRV_SECTOR_SIZE); +- for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) { +- calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl); ++ if (force_size) { ++ /* This will force the use of total_size for sector count, below */ ++ cyls = VHD_CHS_MAX_C; ++ heads = VHD_CHS_MAX_H; ++ secs_per_cyl = VHD_CHS_MAX_S; ++ } else { ++ total_sectors = MIN(VHD_MAX_GEOMETRY, total_size / BDRV_SECTOR_SIZE); ++ for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) { ++ calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl); ++ } + } + + if ((int64_t)cyls * heads * secs_per_cyl == VHD_MAX_GEOMETRY) { +@@ -832,8 +848,11 @@ static int vpc_create(const char *filena + memset(buf, 0, 1024); + + memcpy(footer->creator, "conectix", 8); +- /* TODO Check if "qemu" creator_app is ok for VPC */ +- memcpy(footer->creator_app, "qemu", 4); ++ if (force_size) { ++ memcpy(footer->creator_app, "qem2", 4); ++ } else { ++ memcpy(footer->creator_app, "qemu", 4); ++ } + memcpy(footer->creator_os, "Wi2k", 4); + + footer->features = cpu_to_be32(0x02); +@@ -914,6 +933,13 @@ static QemuOptsList vpc_create_opts = { + "Type of virtual hard disk format. Supported formats are " + "{dynamic (default) | fixed} " + }, ++ { ++ .name = VPC_OPT_FORCE_SIZE, ++ .type = QEMU_OPT_BOOL, ++ .help = "Force disk size calculation to use the actual size " ++ "specified, rather than using the nearest CHS-based " ++ "calculation" ++ }, + { /* end of list */ } + } + }; diff -Nru qemu-2.5+dfsg/debian/patches/series qemu-2.5+dfsg/debian/patches/series --- qemu-2.5+dfsg/debian/patches/series 2016-06-03 13:23:51.000000000 -0700 +++ qemu-2.5+dfsg/debian/patches/series 2016-07-14 11:27:32.000000000 -0700 @@ -44,3 +44,4 @@ ubuntu/arm-enhance-kvm_arm_create_scratch_host_vcpu.patch ubuntu/kvm-add-kvm_device_supported-helper-function.patch ubuntu/arm-implement-query-gic-capabilities.patch +add_force_size_option.patch