block: Support passing NULL ops to blk_set_dev_ops()

This supports passing NULL ops to blk_set_dev_ops()
so that we can remove stale ops in some cases.

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20220523084611.91-2-xieyongji@bytedance.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Xie Yongji 2022-05-23 16:46:04 +08:00 committed by Kevin Wolf
parent 618af89e55
commit ac1fc3a3a9
1 changed files with 1 additions and 1 deletions

View File

@ -1058,7 +1058,7 @@ void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops,
blk->dev_opaque = opaque;
/* Are we currently quiesced? Should we enforce this right now? */
if (blk->quiesce_counter && ops->drained_begin) {
if (blk->quiesce_counter && ops && ops->drained_begin) {
ops->drained_begin(opaque);
}
}