mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
nbd: use BlockDriverState refcnt
Previously, nbd calls drive_get_ref() on the drive of bs. A BDS doesn't always have associated dinfo, which nbd doesn't care either. We already have BDS ref count, so use it to make it safe for a BDS w/o blockdev. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
c0777fe18b
commit
38b54b6dc1
2 changed files with 6 additions and 9 deletions
5
nbd.c
5
nbd.c
|
@ -882,6 +882,7 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset,
|
|||
exp->nbdflags = nbdflags;
|
||||
exp->size = size == -1 ? bdrv_getlength(bs) : size;
|
||||
exp->close = close;
|
||||
bdrv_ref(bs);
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
@ -928,6 +929,10 @@ void nbd_export_close(NBDExport *exp)
|
|||
}
|
||||
nbd_export_set_name(exp, NULL);
|
||||
nbd_export_put(exp);
|
||||
if (exp->bs) {
|
||||
bdrv_unref(exp->bs);
|
||||
exp->bs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void nbd_export_get(NBDExport *exp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue