Message ID | 1375434137-4452-6-git-send-email-gesaint@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
On 08/02/2013 03:02 AM, Xu Wang wrote: > From: Xu Wang <cngesaint@gmail.com> > > Backing file loop should be checked before calling change_backing_ > file(). If loop appeared, this calling should be stopped and an Breaking a function name across a line break is awkward. > error was printed. s/was // > > Signed-off-by: Xu Wang <cngesaint@gmail.com> > --- > block.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > > + /* Check if loop exists in backing files chain after changed */ s/changed/change/ But isn't that a bit late? Don't you want to check that a backing loop will not be created, prior to making the change? > + if (bdrv_backing_file_loop_check(bs->filename, > + bs->drv ? bs->drv->format_name : NULL, > + backing_file, backing_fmt)) { > + return -EIO; > + } > + > if (drv->bdrv_change_backing_file != NULL) { > ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt); > } else { >
diff --git a/block.c b/block.c index 8bb63c2..a14488f 100644 --- a/block.c +++ b/block.c @@ -1963,6 +1963,13 @@ int bdrv_change_backing_file(BlockDriverState *bs, return -EINVAL; } + /* Check if loop exists in backing files chain after changed */ + if (bdrv_backing_file_loop_check(bs->filename, + bs->drv ? bs->drv->format_name : NULL, + backing_file, backing_fmt)) { + return -EIO; + } + if (drv->bdrv_change_backing_file != NULL) { ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt); } else {