mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-10-28 14:04:39 +08:00
Commita362b19a39("hw/sd/sdcard: Fix size check for backing block image") accidentally moved the blk_set_dev_ops() call into the new 'if (blk_size >= 0)' block in sd_realize(). Because of that, if a drive is attached without a medium then the condition is false (blk_size == -ENOMEDIUM) and blk_set_dev_ops() is never called, so the drive is registered as having non-removable media: $QEMU -device sd-card,drive=sdcard0 -drive if=none,id=sdcard0 (qemu) change sdcard0 sd-card.qcow2 Error: Device 'sdcard0' is not removable This patch moves the blk_set_perm() and blk_set_dev_ops() calls outside of the 'if (blk_size >= 0)' block so the device ops and permissions are registered when a drive is attached. Cc: qemu-stable@nongnu.org Fixes:a362b19a39("hw/sd/sdcard: Fix size check for backing block image") Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Message-ID: <20260723205847.137001-1-berto@igalia.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>