Signed-off-by: Fam Zheng <f...@redhat.com> --- hw/ide/core.c | 10 +++++++++- hw/ide/qdev.c | 2 +- include/hw/ide/internal.h | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/hw/ide/core.c b/hw/ide/core.c index b0e42a6..a426baf 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -28,6 +28,7 @@ #include "hw/pci/pci.h" #include "hw/isa/isa.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" #include "sysemu/dma.h" @@ -2394,17 +2395,24 @@ static const BlockDevOps ide_hd_block_ops = { .resize_cb = ide_resize_cb, }; -int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, +int ide_init_drive(IDEState *s, BlockBackend *blk, ImageLockMode lock_mode, + IDEDriveKind kind, const char *version, const char *serial, const char *model, uint64_t wwn, uint32_t cylinders, uint32_t heads, uint32_t secs, int chs_trans) { + Error *local_err = NULL; uint64_t nb_sectors; s->blk = blk; s->drive_kind = kind; + blk_lock_image(blk, lock_mode, &local_err); + if (local_err) { + error_report_err(local_err); + return -1; + } blk_get_geometry(blk, &nb_sectors); s->cylinders = cylinders; s->heads = heads; diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 2eb055a..c5b88fb 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -188,7 +188,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) } blkconf_apply_backend_options(&dev->conf); - if (ide_init_drive(s, dev->conf.blk, kind, + if (ide_init_drive(s, dev->conf.blk, dev->conf.lock_mode, kind, dev->version, dev->serial, dev->model, dev->wwn, dev->conf.cyls, dev->conf.heads, dev->conf.secs, dev->chs_trans) < 0) { diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index a6dd2c3..828f88c 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -600,7 +600,8 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr); void ide_data_writel(void *opaque, uint32_t addr, uint32_t val); uint32_t ide_data_readl(void *opaque, uint32_t addr); -int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind, +int ide_init_drive(IDEState *s, BlockBackend *blk, ImageLockMode lock_mode, + IDEDriveKind kind, const char *version, const char *serial, const char *model, uint64_t wwn, uint32_t cylinders, uint32_t heads, uint32_t secs, -- 2.7.4