@@ -18,12 +18,12 @@
typedef struct BlockConf {
BlockBackend *blk;
- uint16_t physical_block_size;
- uint16_t logical_block_size;
- uint16_t min_io_size;
- uint32_t opt_io_size;
+ uint64_t physical_block_size;
+ uint64_t logical_block_size;
+ uint64_t min_io_size;
+ uint64_t opt_io_size;
int32_t bootindex;
- uint32_t discard_granularity;
+ uint64_t discard_granularity;
/* geometry, not all devices use this */
uint32_t cyls, heads, secs;
uint32_t lcyls, lheads, lsecs;
@@ -51,9 +51,9 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
_conf.logical_block_size), \
DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \
_conf.physical_block_size), \
- DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \
- DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \
- DEFINE_PROP_UINT32("discard_granularity", _state, \
+ DEFINE_PROP_SIZE("min_io_size", _state, _conf.min_io_size, 0), \
+ DEFINE_PROP_SIZE("opt_io_size", _state, _conf.opt_io_size, 0), \
+ DEFINE_PROP_SIZE("discard_granularity", _state, \
_conf.discard_granularity, -1), \
DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \
ON_OFF_AUTO_AUTO), \
@@ -197,7 +197,7 @@ extern const PropertyInfo qdev_prop_pcie_link_width;
#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \
- DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t)
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, 0, qdev_prop_blocksize, uint64_t)
#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
#define DEFINE_PROP_OFF_AUTO_PCIBAR(_n, _s, _f, _d) \
@@ -96,12 +96,34 @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp)
return false;
}
+ /*
+ * all devices which support min_io_size (scsi and virtio-blk) expose it to
+ * the guest as a uint16_t in units of logical blocks
+ */
+ if (conf->min_io_size > conf->logical_block_size * UINT16_MAX) {
+ error_setg(errp,
+ "min_io_size must not exceed " stringify(UINT16_MAX)
+ " logical blocks");
+ return false;
+ }
+
if (!QEMU_IS_ALIGNED(conf->opt_io_size, conf->logical_block_size)) {
error_setg(errp,
"opt_io_size must be a multiple of logical_block_size");
return false;
}
+ /*
+ * all devices which support opt_io_size (scsi and virtio-blk) expose it to
+ * the guest as a uint32_t in units of logical blocks
+ */
+ if (conf->opt_io_size > conf->logical_block_size * UINT32_MAX) {
+ error_setg(errp,
+ "opt_io_size must not exceed " stringify(UINT32_MAX)
+ " logical blocks");
+ return false;
+ }
+
if (conf->discard_granularity != -1 &&
!QEMU_IS_ALIGNED(conf->discard_granularity,
conf->logical_block_size)) {
@@ -110,6 +132,18 @@ bool blkconf_blocksizes(BlockConf *conf, Error **errp)
return false;
}
+ /*
+ * all devices which support discard_granularity (scsi) expose it to the
+ * guest as a uint32_t in units of logical blocks
+ */
+ if (conf->discard_granularity != -1 &&
+ conf->discard_granularity > conf->logical_block_size * UINT32_MAX) {
+ error_setg(errp,
+ "discard_granularity must not exceed " stringify(UINT32_MAX)
+ " logical blocks");
+ return false;
+ }
+
return true;
}
@@ -14,6 +14,7 @@
#include "qapi/visitor.h"
#include "chardev/char.h"
#include "qemu/uuid.h"
+#include "qemu/units.h"
void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
Error **errp)
@@ -727,63 +728,6 @@ const PropertyInfo qdev_prop_pci_devfn = {
.set_default_value = set_default_value_int,
};
-/* --- blocksize --- */
-
-/* lower limit is sector size */
-#define MIN_BLOCK_SIZE 512
-#define MIN_BLOCK_SIZE_STR stringify(MIN_BLOCK_SIZE)
-/* upper limit is the max power of 2 that fits in uint16_t */
-#define MAX_BLOCK_SIZE 32768
-#define MAX_BLOCK_SIZE_STR stringify(MAX_BLOCK_SIZE)
-
-static void set_blocksize(Object *obj, Visitor *v, const char *name,
- void *opaque, Error **errp)
-{
- DeviceState *dev = DEVICE(obj);
- Property *prop = opaque;
- uint16_t value, *ptr = qdev_get_prop_ptr(dev, prop);
- Error *local_err = NULL;
-
- if (dev->realized) {
- qdev_prop_set_after_realize(dev, name, errp);
- return;
- }
-
- visit_type_uint16(v, name, &value, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
- /* value of 0 means "unset" */
- if (value && (value < MIN_BLOCK_SIZE || value > MAX_BLOCK_SIZE)) {
- error_setg(errp,
- "Property %s.%s doesn't take value %" PRIu16
- " (minimum: " MIN_BLOCK_SIZE_STR
- ", maximum: " MAX_BLOCK_SIZE_STR ")",
- dev->id ? : "", name, value);
- return;
- }
-
- /* We rely on power-of-2 blocksizes for bitmasks */
- if ((value & (value - 1)) != 0) {
- error_setg(errp,
- "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2",
- dev->id ?: "", name, (int64_t)value);
- return;
- }
-
- *ptr = value;
-}
-
-const PropertyInfo qdev_prop_blocksize = {
- .name = "uint16",
- .description = "A power of two between " MIN_BLOCK_SIZE_STR
- " and " MAX_BLOCK_SIZE_STR,
- .get = get_uint16,
- .set = set_blocksize,
- .set_default_value = set_default_value_uint,
-};
-
/* --- pci host address --- */
static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name,
@@ -1257,6 +1201,63 @@ const PropertyInfo qdev_prop_size = {
.set_default_value = set_default_value_uint,
};
+/* --- blocksize --- */
+
+/* lower limit is sector size */
+#define MIN_BLOCK_SIZE 512
+#define MIN_BLOCK_SIZE_STR "512 B"
+/* upper limit is the max power of 2 that fits in uint16_t */
+#define MAX_BLOCK_SIZE (32 * KiB)
+#define MAX_BLOCK_SIZE_STR "32 KiB"
+
+static void set_blocksize(Object *obj, Visitor *v, const char *name,
+ void *opaque, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ uint64_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+ Error *local_err = NULL;
+
+ if (dev->realized) {
+ qdev_prop_set_after_realize(dev, name, errp);
+ return;
+ }
+
+ visit_type_size(v, name, &value, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+ /* value of 0 means "unset" */
+ if (value && (value < MIN_BLOCK_SIZE || value > MAX_BLOCK_SIZE)) {
+ error_setg(errp,
+ "Property %s.%s doesn't take value %" PRIu64
+ " (minimum: " MIN_BLOCK_SIZE_STR
+ ", maximum: " MAX_BLOCK_SIZE_STR ")",
+ dev->id ? : "", name, value);
+ return;
+ }
+
+ /* We rely on power-of-2 blocksizes for bitmasks */
+ if ((value & (value - 1)) != 0) {
+ error_setg(errp,
+ "Property %s.%s doesn't take value '%" PRId64 "', it's not a power of 2",
+ dev->id ?: "", name, (int64_t)value);
+ return;
+ }
+
+ *ptr = value;
+}
+
+const PropertyInfo qdev_prop_blocksize = {
+ .name = "size",
+ .description = "A power of two between " MIN_BLOCK_SIZE_STR
+ " and " MAX_BLOCK_SIZE_STR,
+ .get = get_size,
+ .set = set_blocksize,
+ .set_default_value = set_default_value_uint,
+};
+
/* --- object link property --- */
static void create_link_property(ObjectClass *oc, Property *prop)
@@ -24,11 +24,11 @@ Testing:
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "288"
@@ -54,11 +54,11 @@ Testing: -fda TEST_DIR/t.qcow2
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -81,22 +81,22 @@ Testing: -fdb TEST_DIR/t.qcow2
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "288"
@@ -119,22 +119,22 @@ Testing: -fda TEST_DIR/t.qcow2 -fdb TEST_DIR/t.qcow2.2
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -160,11 +160,11 @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -187,22 +187,22 @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2,index=1
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "288"
@@ -225,22 +225,22 @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=floppy,file=TEST_DIR/t
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -266,11 +266,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -global isa-fdc.driveA=none0
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -293,11 +293,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -global isa-fdc.driveB=none0
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -320,22 +320,22 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
dev: floppy, id ""
unit = 1 (0x1)
drive = "none1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -361,11 +361,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -388,11 +388,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,unit=1
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -415,22 +415,22 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
dev: floppy, id ""
unit = 1 (0x1)
drive = "none1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -456,22 +456,22 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global is
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -494,22 +494,22 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global is
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -532,11 +532,11 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global is
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -559,11 +559,11 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -global is
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -589,22 +589,22 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -627,22 +627,22 @@ Testing: -fda TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -665,22 +665,22 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -703,22 +703,22 @@ Testing: -fdb TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qcow2.2 -device fl
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 1 (0x1)
drive = "floppy1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -750,22 +750,22 @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -788,22 +788,22 @@ Testing: -drive if=floppy,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.q
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "floppy0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -832,22 +832,22 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
dev: floppy, id ""
unit = 1 (0x1)
drive = "none1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -870,22 +870,22 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
dev: floppy, id ""
unit = 1 (0x1)
drive = "none1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -908,22 +908,22 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
dev: floppy, id ""
unit = 0 (0x0)
drive = "none1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -946,22 +946,22 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -drive if=none,file=TEST_DIR/t.qco
dev: floppy, id ""
unit = 0 (0x0)
drive = "none1"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
dev: floppy, id ""
unit = 1 (0x1)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -999,11 +999,11 @@ Testing: -device floppy
dev: floppy, id ""
unit = 0 (0x0)
drive = ""
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "288"
@@ -1026,11 +1026,11 @@ Testing: -device floppy,drive-type=120
dev: floppy, id ""
unit = 0 (0x0)
drive = ""
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "120"
@@ -1053,11 +1053,11 @@ Testing: -device floppy,drive-type=144
dev: floppy, id ""
unit = 0 (0x0)
drive = ""
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -1080,11 +1080,11 @@ Testing: -device floppy,drive-type=288
dev: floppy, id ""
unit = 0 (0x0)
drive = ""
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "288"
@@ -1110,11 +1110,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "120"
@@ -1137,11 +1137,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,drive-t
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "288"
@@ -1167,11 +1167,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,logical
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
@@ -1194,11 +1194,11 @@ Testing: -drive if=none,file=TEST_DIR/t.qcow2 -device floppy,drive=none0,physica
dev: floppy, id ""
unit = 0 (0x0)
drive = "none0"
- logical_block_size = 512 (0x200)
- physical_block_size = 512 (0x200)
- min_io_size = 0 (0x0)
- opt_io_size = 0 (0x0)
- discard_granularity = 4294967295 (0xffffffff)
+ logical_block_size = 512 (512 B)
+ physical_block_size = 512 (512 B)
+ min_io_size = 0 (0 B)
+ opt_io_size = 0 (0 B)
+ discard_granularity = 18446744073709551615 (16 EiB)
write-cache = "auto"
share-rw = false
drive-type = "144"
Several BlockConf properties represent respective sizes in bytes so it makes sense to accept size suffixes for them. Turn them into uint64_t and use size-suffix-capable setters/getters on them. Also, as some of them are exposed to the guest by scsi and virtio-blk devices as an integer of a specific width (uint16_t for min_io_size and uint32_t for opt_io_size and discard_granularity) in units of logical blocks, introduce extra checks in blkconf_blocksizes to prevent their silent truncation. Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru> --- v4 -> v5: - make all BlockConf size props support suffixes - move qdev_prop_blocksize after qdev_prop_size, to reuse get_size - reword error messages [Kevin] include/hw/block/block.h | 16 +- include/hw/qdev-properties.h | 2 +- hw/block/block.c | 34 +++ hw/core/qdev-properties.c | 115 ++++---- tests/qemu-iotests/172.out | 530 +++++++++++++++++------------------ 5 files changed, 366 insertions(+), 331 deletions(-)