@@ -18,9 +18,9 @@
typedef struct BlockConf {
BlockBackend *blk;
- uint16_t physical_block_size;
- uint16_t logical_block_size;
- uint16_t min_io_size;
+ uint32_t physical_block_size;
+ uint32_t logical_block_size;
+ uint32_t min_io_size;
uint32_t opt_io_size;
int32_t bootindex;
uint32_t discard_granularity;
@@ -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_SIZE32("min_io_size", _state, _conf.min_io_size, 0), \
+ DEFINE_PROP_SIZE32("opt_io_size", _state, _conf.opt_io_size, 0), \
+ DEFINE_PROP_SIZE32("discard_granularity", _state, \
_conf.discard_granularity, -1), \
DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \
ON_OFF_AUTO_AUTO), \
@@ -29,6 +29,7 @@ extern const PropertyInfo qdev_prop_drive;
extern const PropertyInfo qdev_prop_drive_iothread;
extern const PropertyInfo qdev_prop_netdev;
extern const PropertyInfo qdev_prop_pci_devfn;
+extern const PropertyInfo qdev_prop_size32;
extern const PropertyInfo qdev_prop_blocksize;
extern const PropertyInfo qdev_prop_pci_host_devaddr;
extern const PropertyInfo qdev_prop_uuid;
@@ -196,8 +197,10 @@ extern const PropertyInfo qdev_prop_pcie_link_width;
BlockdevOnError)
#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_SIZE32(_n, _s, _f, _d) \
+ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size32, uint32_t)
#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, uint32_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,6 +96,17 @@ 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");
@@ -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,6 +728,57 @@ const PropertyInfo qdev_prop_pci_devfn = {
.set_default_value = set_default_value_int,
};
+/* --- 32bit unsigned int 'size' type --- */
+
+static void get_size32(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint64_t value = *ptr;
+
+ visit_type_size(v, name, &value, errp);
+}
+
+static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque,
+ Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint64_t value;
+ 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;
+ }
+
+ if (value > UINT32_MAX) {
+ error_setg(errp,
+ "Property %s.%s doesn't take value %" PRIu64
+ " (maximum: " stringify(UINT32_MAX) ")",
+ dev->id ? : "", name, value);
+ return;
+ }
+
+ *ptr = value;
+}
+
+const PropertyInfo qdev_prop_size32 = {
+ .name = "size",
+ .get = get_size32,
+ .set = set_size32,
+ .set_default_value = set_default_value_uint,
+};
+
/* --- blocksize --- */
/* lower limit is sector size */
@@ -741,7 +793,8 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
{
DeviceState *dev = DEVICE(obj);
Property *prop = opaque;
- uint16_t value, *ptr = qdev_get_prop_ptr(dev, prop);
+ uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
+ uint64_t value;
Error *local_err = NULL;
if (dev->realized) {
@@ -749,7 +802,7 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
return;
}
- visit_type_uint16(v, name, &value, &local_err);
+ visit_type_size(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -757,7 +810,7 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
/* 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
+ "Property %s.%s doesn't take value %" PRIu64
" (minimum: " MIN_BLOCK_SIZE_STR
", maximum: " MAX_BLOCK_SIZE_STR ")",
dev->id ? : "", name, value);
@@ -776,10 +829,10 @@ static void set_blocksize(Object *obj, Visitor *v, const char *name,
}
const PropertyInfo qdev_prop_blocksize = {
- .name = "uint16",
+ .name = "size",
.description = "A power of two between " MIN_BLOCK_SIZE_STR
" and " MAX_BLOCK_SIZE_STR,
- .get = get_uint16,
+ .get = get_size32,
.set = set_blocksize,
.set_default_value = set_default_value_uint,
};
@@ -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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 = 4294967295 (4 GiB)
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 all into uint32_t and use size-suffix-capable setters/getters on them; introduce DEFINE_PROP_SIZE32 and adjust DEFINE_PROP_BLOCKSIZE for that. (Making them uint64_t and reusing DEFINE_PROP_SIZE isn't justified because guests expect at most 32bit values.) Also, since min_io_size is exposed to the guest by scsi and virtio-blk devices as an uint16_t in units of logical blocks, introduce an additional check in blkconf_blocksizes to prevent its silent truncation. Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru> --- v5 -> v6: - add prop_size32 instead of going with 64bit 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 | 12 +- include/hw/qdev-properties.h | 5 +- hw/block/block.c | 11 + hw/core/qdev-properties.c | 63 ++++- tests/qemu-iotests/172.out | 530 +++++++++++++++++------------------ 5 files changed, 344 insertions(+), 277 deletions(-)