Block patch:

- Fix Coverity complaint in block/snapshot.c
 -----BEGIN PGP SIGNATURE-----
 
 iQFGBAABCAAwFiEEkb62CjDbPohX0Rgp9AfbAGHVz0AFAmDUb6QSHG1yZWl0ekBy
 ZWRoYXQuY29tAAoJEPQH2wBh1c9Aq8wH+gPeaasIOMQUmG5gBCbhSHmYgy+ul21D
 yhPR+KURZit8PwAhOkTBhvRiEmf0YvSfA8EOE+gmfVpM+PJxZ61ZTI4QhB52/j1X
 aDaebVWUFFsujdNO0B27gPe0IGF/PpJmKSuAd5625TNmfA1Yem3Z+LRmaRsxvk32
 2DrvCYhV0bQLY0lXubd/0yFkUx6t6VMO28hKWKPxi3TmmvHQelx2Vval09IL2bb3
 zQYWYrtHvrEIffDHd/NsdGeNAYaIuBaSvTcCCmYW8M3X3MTWkGTYikRODLBZw2pN
 IBY+VbPdvPRGGJ8vu0Mz3ARwTqXQmyDTEI1K3P2lsrxI9LCwDZ1YXmw=
 =HVRe
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2021-06-24' into staging

Block patch:
- Fix Coverity complaint in block/snapshot.c

# gpg: Signature made Thu 24 Jun 2021 12:42:28 BST
# gpg:                using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40
# gpg:                issuer "mreitz@redhat.com"
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2021-06-24:
  block/snapshot: Clarify goto fallback behavior

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-06-25 15:29:07 +01:00
commit 3593b8e0a2
1 changed files with 13 additions and 1 deletions

View File

@ -275,13 +275,16 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
qobject_unref(file_options);
g_free(subqdict_prefix);
/* Force .bdrv_open() below to re-attach fallback_bs on *fallback_ptr */
qdict_put_str(options, (*fallback_ptr)->name,
bdrv_get_node_name(fallback_bs));
/* Now close bs, apply the snapshot on fallback_bs, and re-open bs */
if (drv->bdrv_close) {
drv->bdrv_close(bs);
}
/* .bdrv_open() will re-attach it */
bdrv_unref_child(bs, *fallback_ptr);
*fallback_ptr = NULL;
@ -296,7 +299,16 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
return ret < 0 ? ret : open_ret;
}
assert(fallback_bs == (*fallback_ptr)->bs);
/*
* fallback_ptr is &bs->file or &bs->backing. *fallback_ptr
* was closed above and set to NULL, but the .bdrv_open() call
* has opened it again, because we set the respective option
* (with the qdict_put_str() call above).
* Assert that .bdrv_open() has attached some child on
* *fallback_ptr, and that it has attached the one we wanted
* it to (i.e., fallback_bs).
*/
assert(*fallback_ptr && fallback_bs == (*fallback_ptr)->bs);
bdrv_unref(fallback_bs);
return ret;
}