Pull request
-----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmW5b1IACgkQnKSrs4Gr c8geoQf8DU8Z8jlvy1luuBZLq3R7hnC7c3Wzje0atLGP++pX6QUXfAgGDsTTIQeh XWmkFhbOBurhToH8YpgPyNG8ZWYd9+NIvLnIJiWDklNDZg2zC00aOi8yBEbsgyFb 50HJA30AAHq8PuctCzhGhENLxvBvNDNME74SwYH7FSIK5x/nA1XBHDZsjst1/Hk2 1loLbVWElbU28Xll7hI862SAb8RULC/sRQomkQAhpydxq4TApNuRwvpRfPNFwFJ0 +dCquCJEfV6wfD62xg2CBGA5DrD9T7ADxmCYl4DQyp3HIRKXAptjgLsx3aZaIr1z KAnCRNUXRuLgRZf7b9I+HhxGISoNng== =/bBL -----END PGP SIGNATURE----- Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging Pull request # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmW5b1IACgkQnKSrs4Gr # c8geoQf8DU8Z8jlvy1luuBZLq3R7hnC7c3Wzje0atLGP++pX6QUXfAgGDsTTIQeh # XWmkFhbOBurhToH8YpgPyNG8ZWYd9+NIvLnIJiWDklNDZg2zC00aOi8yBEbsgyFb # 50HJA30AAHq8PuctCzhGhENLxvBvNDNME74SwYH7FSIK5x/nA1XBHDZsjst1/Hk2 # 1loLbVWElbU28Xll7hI862SAb8RULC/sRQomkQAhpydxq4TApNuRwvpRfPNFwFJ0 # +dCquCJEfV6wfD62xg2CBGA5DrD9T7ADxmCYl4DQyp3HIRKXAptjgLsx3aZaIr1z # KAnCRNUXRuLgRZf7b9I+HhxGISoNng== # =/bBL # -----END PGP SIGNATURE----- # gpg: Signature made Tue 30 Jan 2024 21:51:14 GMT # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full] # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * tag 'block-pull-request' of https://gitlab.com/stefanha/qemu: hw/block/block.c: improve confusing blk_check_size_and_read_all() error hw/core/qdev.c: add qdev_get_human_name() pflash: fix sectors vs bytes confusion in blk_pread_nonzeroes() block/blkio: Make s->mem_region_alignment be 64 bits block/io_uring: improve error message when init fails Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
24f920ad5a
|
@ -68,7 +68,7 @@ typedef struct {
|
||||||
CoQueue bounce_available;
|
CoQueue bounce_available;
|
||||||
|
|
||||||
/* The value of the "mem-region-alignment" property */
|
/* The value of the "mem-region-alignment" property */
|
||||||
size_t mem_region_alignment;
|
uint64_t mem_region_alignment;
|
||||||
|
|
||||||
/* Can we skip adding/deleting blkio_mem_regions? */
|
/* Can we skip adding/deleting blkio_mem_regions? */
|
||||||
bool needs_mem_regions;
|
bool needs_mem_regions;
|
||||||
|
|
|
@ -432,7 +432,7 @@ LuringState *luring_init(Error **errp)
|
||||||
|
|
||||||
rc = io_uring_queue_init(MAX_ENTRIES, ring, 0);
|
rc = io_uring_queue_init(MAX_ENTRIES, ring, 0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
error_setg_errno(errp, errno, "failed to init linux io_uring ring");
|
error_setg_errno(errp, -rc, "failed to init linux io_uring ring");
|
||||||
g_free(s);
|
g_free(s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ static int blk_pread_nonzeroes(BlockBackend *blk, hwaddr size, void *buf)
|
||||||
BlockDriverState *bs = blk_bs(blk);
|
BlockDriverState *bs = blk_bs(blk);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
bytes = MIN(size - offset, BDRV_REQUEST_MAX_SECTORS);
|
bytes = MIN(size - offset, BDRV_REQUEST_MAX_BYTES);
|
||||||
if (bytes <= 0) {
|
if (bytes <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -54,29 +54,30 @@ static int blk_pread_nonzeroes(BlockBackend *blk, hwaddr size, void *buf)
|
||||||
* BDRV_REQUEST_MAX_BYTES.
|
* BDRV_REQUEST_MAX_BYTES.
|
||||||
* On success, return true.
|
* On success, return true.
|
||||||
* On failure, store an error through @errp and return false.
|
* On failure, store an error through @errp and return false.
|
||||||
* Note that the error messages do not identify the block backend.
|
*
|
||||||
* TODO Since callers don't either, this can result in confusing
|
|
||||||
* errors.
|
|
||||||
* This function not intended for actual block devices, which read on
|
* This function not intended for actual block devices, which read on
|
||||||
* demand. It's for things like memory devices that (ab)use a block
|
* demand. It's for things like memory devices that (ab)use a block
|
||||||
* backend to provide persistence.
|
* backend to provide persistence.
|
||||||
*/
|
*/
|
||||||
bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
|
bool blk_check_size_and_read_all(BlockBackend *blk, DeviceState *dev,
|
||||||
Error **errp)
|
void *buf, hwaddr size, Error **errp)
|
||||||
{
|
{
|
||||||
int64_t blk_len;
|
int64_t blk_len;
|
||||||
int ret;
|
int ret;
|
||||||
|
g_autofree char *dev_id = NULL;
|
||||||
|
|
||||||
blk_len = blk_getlength(blk);
|
blk_len = blk_getlength(blk);
|
||||||
if (blk_len < 0) {
|
if (blk_len < 0) {
|
||||||
error_setg_errno(errp, -blk_len,
|
error_setg_errno(errp, -blk_len,
|
||||||
"can't get size of block backend");
|
"can't get size of %s block backend", blk_name(blk));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (blk_len != size) {
|
if (blk_len != size) {
|
||||||
error_setg(errp, "device requires %" HWADDR_PRIu " bytes, "
|
dev_id = qdev_get_human_name(dev);
|
||||||
"block backend provides %" PRIu64 " bytes",
|
error_setg(errp, "%s device '%s' requires %" HWADDR_PRIu
|
||||||
size, blk_len);
|
" bytes, %s block backend provides %" PRIu64 " bytes",
|
||||||
|
object_get_typename(OBJECT(dev)), dev_id, size,
|
||||||
|
blk_name(blk), blk_len);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +90,11 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
|
||||||
assert(size <= BDRV_REQUEST_MAX_BYTES);
|
assert(size <= BDRV_REQUEST_MAX_BYTES);
|
||||||
ret = blk_pread_nonzeroes(blk, size, buf);
|
ret = blk_pread_nonzeroes(blk, size, buf);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_setg_errno(errp, -ret, "can't read block backend");
|
dev_id = qdev_get_human_name(dev);
|
||||||
|
error_setg_errno(errp, -ret, "can't read %s block backend"
|
||||||
|
" for %s device '%s'",
|
||||||
|
blk_name(blk), object_get_typename(OBJECT(dev)),
|
||||||
|
dev_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1617,7 +1617,8 @@ static void m25p80_realize(SSIPeripheral *ss, Error **errp)
|
||||||
trace_m25p80_binding(s);
|
trace_m25p80_binding(s);
|
||||||
s->storage = blk_blockalign(s->blk, s->size);
|
s->storage = blk_blockalign(s->blk, s->size);
|
||||||
|
|
||||||
if (!blk_check_size_and_read_all(s->blk, s->storage, s->size, errp)) {
|
if (!blk_check_size_and_read_all(s->blk, DEVICE(s),
|
||||||
|
s->storage, s->size, errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -848,8 +848,8 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pfl->blk) {
|
if (pfl->blk) {
|
||||||
if (!blk_check_size_and_read_all(pfl->blk, pfl->storage, total_len,
|
if (!blk_check_size_and_read_all(pfl->blk, dev, pfl->storage,
|
||||||
errp)) {
|
total_len, errp)) {
|
||||||
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
|
vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -902,7 +902,7 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pfl->blk) {
|
if (pfl->blk) {
|
||||||
if (!blk_check_size_and_read_all(pfl->blk, pfl->storage,
|
if (!blk_check_size_and_read_all(pfl->blk, dev, pfl->storage,
|
||||||
pfl->chip_len, errp)) {
|
pfl->chip_len, errp)) {
|
||||||
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
|
vmstate_unregister_ram(&pfl->orig_mem, DEVICE(pfl));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -879,6 +879,14 @@ Object *qdev_get_machine(void)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *qdev_get_human_name(DeviceState *dev)
|
||||||
|
{
|
||||||
|
g_assert(dev != NULL);
|
||||||
|
|
||||||
|
return dev->id ?
|
||||||
|
g_strdup(dev->id) : object_get_canonical_path(OBJECT(dev));
|
||||||
|
}
|
||||||
|
|
||||||
static MachineInitPhase machine_phase;
|
static MachineInitPhase machine_phase;
|
||||||
|
|
||||||
bool phase_check(MachineInitPhase phase)
|
bool phase_check(MachineInitPhase phase)
|
||||||
|
|
|
@ -88,8 +88,8 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
|
||||||
|
|
||||||
/* Backend access helpers */
|
/* Backend access helpers */
|
||||||
|
|
||||||
bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
|
bool blk_check_size_and_read_all(BlockBackend *blk, DeviceState *dev,
|
||||||
Error **errp);
|
void *buf, hwaddr size, Error **errp);
|
||||||
|
|
||||||
/* Configuration helpers */
|
/* Configuration helpers */
|
||||||
|
|
||||||
|
|
|
@ -993,6 +993,20 @@ const char *qdev_fw_name(DeviceState *dev);
|
||||||
void qdev_assert_realized_properly(void);
|
void qdev_assert_realized_properly(void);
|
||||||
Object *qdev_get_machine(void);
|
Object *qdev_get_machine(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qdev_get_human_name() - Return a human-readable name for a device
|
||||||
|
* @dev: The device. Must be a valid and non-NULL pointer.
|
||||||
|
*
|
||||||
|
* .. note::
|
||||||
|
* This function is intended for user friendly error messages.
|
||||||
|
*
|
||||||
|
* Returns: A newly allocated string containing the device id if not null,
|
||||||
|
* else the object canonical path.
|
||||||
|
*
|
||||||
|
* Use g_free() to free it.
|
||||||
|
*/
|
||||||
|
char *qdev_get_human_name(DeviceState *dev);
|
||||||
|
|
||||||
/* FIXME: make this a link<> */
|
/* FIXME: make this a link<> */
|
||||||
bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp);
|
bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue