|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/4] xen-block: Fix inverted error check in xen_cdrom_realize()
xen_cdrom_realize() checks the return value of blk_attach_dev() with
if (!rc) {
error_setg_errno(errp, -rc, "failed to create drive");
return;
}
but blk_attach_dev() returns 0 on success and a negative errno on
failure. The condition is inverted: a successful attach (rc == 0) is
reported as an error and fails realize, while a real failure (rc < 0)
is silently ignored.
Here blk_attach_dev() is called on a BlockBackend just created by
blk_new(), so blk->dev is NULL and its only failure path (-EBUSY)
cannot be taken. Replace the bogus check with an assertion, matching
the other empty-drive realize paths (scsi-disk, ide, fdc, swim).
Signed-off-by: Mitsuru Kariya <Mitsuru.Kariya@xxxxxxxxxxxxxxx>
---
hw/block/xen-block.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c
index 474c12fe4a..abf9df2eee 100644
--- a/hw/block/xen-block.c
+++ b/hw/block/xen-block.c
@@ -762,10 +762,7 @@ static void xen_cdrom_realize(XenBlockDevice *blockdev,
Error **errp)
conf->blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
rc = blk_attach_dev(conf->blk, DEVICE(blockdev));
- if (!rc) {
- error_setg_errno(errp, -rc, "failed to create drive");
- return;
- }
+ assert(rc == 0);
}
blockdev->info = VDISK_READONLY | VDISK_CDROM;
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |