δΊ 2013-1-29 20:37, Kevin Wolf ει:
Am 25.01.2013 19:11, schrieb Eric Blake:
On 01/23/2013 07:57 PM, Wenchao Xia wrote:
Compared to bdrv_can_snapshot(), this function return whether
bs* is ready to read snapshot info from instead of write. If yes,
caller can then query snapshot information, but taking snapshot
is not always possible for that *bs may be read only.
Signed-off-by: Wenchao Xia <xiaw...@linux.vnet.ibm.com>
---
block.c | 19 +++++++++++++++++++
include/block/block.h | 1 +
2 files changed, 20 insertions(+), 0 deletions(-)
+/* return whether internal snapshot can be read on @bs */
+int bdrv_can_read_snapshot(BlockDriverState *bs)
+{
+/* return whether internal snapshot can be write on @bs */
int bdrv_can_snapshot(BlockDriverState *bs)
I see you just copied existing code; but any reason why these functions
return int instead of bool? Would that be worth a separate cleanup patch?
More importantly, you shouldn't copy code. Make both of them small
wrappers around a static helper functions that contains the existing code.
Kevin
I tried that before, but found that hard to wrapper around a common
function, because both need to recusively check some condition.
--
Best Regards
Wenchao Xia