From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpwfY-0007xy-8I for qemu-devel@nongnu.org; Fri, 30 Sep 2016 08:12:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpwfT-0006h7-2d for qemu-devel@nongnu.org; Fri, 30 Sep 2016 08:12:00 -0400 From: Fam Zheng Date: Fri, 30 Sep 2016 20:09:46 +0800 Message-Id: <1475237406-26917-17-git-send-email-famz@redhat.com> In-Reply-To: <1475237406-26917-1-git-send-email-famz@redhat.com> References: <1475237406-26917-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v8 16/36] ide: Apply lock-mode when initialize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: berrange@redhat.com, John Snow , qemu-block@nongnu.org, Kevin Wolf , rjones@redhat.com, Jeff Cody , Max Reitz , Markus Armbruster , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, eblake@redhat.com Signed-off-by: Fam Zheng --- 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