[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 19/36] pflash: Add "lock-mode" property
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH v8 19/36] pflash: Add "lock-mode" property |
Date: |
Fri, 30 Sep 2016 20:09:49 +0800 |
Signed-off-by: Fam Zheng <address@hidden>
---
hw/block/pflash_cfi01.c | 10 ++++++++++
hw/block/pflash_cfi02.c | 9 +++++++++
2 files changed, 19 insertions(+)
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 62d7a56..df82471 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -76,6 +76,7 @@ struct pflash_t {
/*< public >*/
BlockBackend *blk;
+ ImageLockMode lock_mode;
uint32_t nb_blocs;
uint64_t sector_len;
uint8_t bank_width;
@@ -738,6 +739,14 @@ static void pflash_cfi01_realize(DeviceState *dev, Error
**errp)
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &pfl->mem);
if (pfl->blk) {
+ Error *local_err = NULL;
+
+ blk_lock_image(pfl->blk, pfl->lock_mode, &local_err);
+ if (local_err) {
+ vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
+ error_propagate(errp, local_err);
+ return;
+ }
/* read the initial flash content */
ret = blk_pread(pfl->blk, 0, pfl->storage, total_len);
@@ -852,6 +861,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Error
**errp)
static Property pflash_cfi01_properties[] = {
DEFINE_PROP_DRIVE("drive", struct pflash_t, blk),
+ DEFINE_PROP_LOCK_MODE("lock-mode", struct pflash_t, lock_mode),
/* num-blocks is the number of blocks actually visible to the guest,
* ie the total size of the device divided by the sector length.
* If we're emulating flash devices wired in parallel the actual
diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 4f6105c..ff6a9fb 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -620,6 +620,14 @@ static void pflash_cfi02_realize(DeviceState *dev, Error
**errp)
pfl->storage = memory_region_get_ram_ptr(&pfl->orig_mem);
pfl->chip_len = chip_len;
if (pfl->blk) {
+ Error *local_err = NULL;
+
+ blk_lock_image(pfl->blk, pfl->lock_mode, &local_err);
+ if (local_err) {
+ vmstate_unregister_ram(&pfl->mem, DEVICE(pfl));
+ error_propagate(errp, local_err);
+ return;
+ }
/* read the initial flash content */
ret = blk_pread(pfl->blk, 0, pfl->storage, chip_len);
if (ret < 0) {
@@ -724,6 +732,7 @@ static void pflash_cfi02_realize(DeviceState *dev, Error
**errp)
static Property pflash_cfi02_properties[] = {
DEFINE_PROP_DRIVE("drive", struct pflash_t, blk),
+ DEFINE_PROP_LOCK_MODE("lock-mode", struct pflash_t, lock_mode),
DEFINE_PROP_UINT32("num-blocks", struct pflash_t, nb_blocs, 0),
DEFINE_PROP_UINT32("sector-length", struct pflash_t, sector_len, 0),
DEFINE_PROP_UINT8("width", struct pflash_t, width, 0),
--
2.7.4
- [Qemu-devel] [PATCH v8 10/36] block: Don't lock drive-backup target image in none mode, (continued)
- [Qemu-devel] [PATCH v8 10/36] block: Don't lock drive-backup target image in none mode, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 09/36] qemu-nbd: Add "--no-lock/-L" option, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 11/36] block: Add blk_lock_image, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 12/36] virtio-blk: Apply lock-mode when realize, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 13/36] scsi-disk: Apply lock-mode when realize, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 14/36] scsi-generic: Apply lock-mode when realize, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 15/36] qdev: Add "lock-mode" to block device options, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 16/36] ide: Apply lock-mode when initialize, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 17/36] nvme: Apply lock-mode when initialize, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 18/36] usb-storage: Apply lock-mode when realize, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 19/36] pflash: Add "lock-mode" property,
Fam Zheng <=
- [Qemu-devel] [PATCH v8 20/36] qemu-iotests: 046: Move version detection out from verify_io, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 21/36] qemu-iotests: 091: Prepare for image lock, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 22/36] qemu-iotests: 030: Disable image locking when checking test image, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 23/36] iotests: 087: Disable image locking in cases where file is shared, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 24/36] iotests: 087: Disable image locking in cases where file is shared, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 25/36] iotests: 130: Check image info locklessly, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 26/36] iotests: Disable image locking in 085, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 27/36] tests: Use null-co:// instead of /dev/null, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 28/36] qemu-iotests: Add test case 153 for image locking, Fam Zheng, 2016/09/30
- [Qemu-devel] [PATCH v8 29/36] ahci: Use shared lock for shared storage migration, Fam Zheng, 2016/09/30