From 5d9d31b61fef68c75fcddf358dcfae00a09cdd92 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Fri, 12 Aug 2011 15:38:09 +0200 Subject: [PATCH 01/15] Add flag to indicate external users to block device RH-Author: Anthony Liguori Message-id: <1313163503-2523-2-git-send-email-aliguori@redhat.com> Patchwork-id: 31323 O-Subject: [RHEL6.2 qemu PATCH 01/15] Add flag to indicate external users to block device Bugzilla: 633370 RH-Acked-by: Marcelo Tosatti RH-Acked-by: Kevin Wolf RH-Acked-by: Orit Wasserman RH-Acked-by: Christoph Hellwig From: Marcelo Tosatti Certain operations such as drive_del or resize cannot be performed while external users (eg. block migration) reference the block device. Add a flag to indicate that. Signed-off-by: Marcelo Tosatti Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori Bugzilla: 633370 (cherry picked from commit db593f2565dc12442d6bac9e8eaefa027dfcada9) --- block.c | 11 +++++++++++ block.h | 2 ++ block_int.h | 1 + 3 files changed, 14 insertions(+), 0 deletions(-) Signed-off-by: Michal Novotny --- block.c | 11 +++++++++++ block.h | 2 ++ block_int.h | 1 + 3 files changed, 14 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 32bd13d..0d57e13 100644 --- a/block.c +++ b/block.c @@ -2690,6 +2690,17 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie) bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns; } +void bdrv_set_in_use(BlockDriverState *bs, int in_use) +{ + assert(bs->in_use != in_use); + bs->in_use = in_use; +} + +int bdrv_in_use(BlockDriverState *bs) +{ + return bs->in_use; +} + int bdrv_img_create(const char *filename, const char *fmt, const char *base_filename, const char *base_fmt, char *options, uint64_t img_size, int flags) diff --git a/block.h b/block.h index 59300d6..216b496 100644 --- a/block.h +++ b/block.h @@ -240,6 +240,8 @@ int bdrv_get_dirty(BlockDriverState *bs, int64_t sector); void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors); +void bdrv_set_in_use(BlockDriverState *bs, int in_use); +int bdrv_in_use(BlockDriverState *bs); enum BlockAcctType { BDRV_ACCT_READ, diff --git a/block_int.h b/block_int.h index aece608..ef162b9 100644 --- a/block_int.h +++ b/block_int.h @@ -196,6 +196,7 @@ struct BlockDriverState { BlockErrorAction on_read_error, on_write_error; char device_name[32]; unsigned long *dirty_bitmap; + int in_use; /* users other than guest access, eg. block migration */ QTAILQ_ENTRY(BlockDriverState) list; void *private; }; -- 1.7.4.4