diff --git a/src/client/qemu_driver.c b/src/client/qemu_driver.c index 4c5f3633..67ea9d3a 100644 --- a/src/client/qemu_driver.c +++ b/src/client/qemu_driver.c @@ -568,6 +568,7 @@ static int vitastor_file_open(BlockDriverState *bs, QDict *options, int flags, E static void vitastor_close(BlockDriverState *bs) { VitastorClient *client = bs->opaque; + qemu_mutex_lock(&client->mutex); vitastor_c_destroy(client->proxy); if (client->fds) { @@ -575,7 +576,6 @@ static void vitastor_close(BlockDriverState *bs) client->fds = NULL; client->fd_alloc = client->fd_count = 0; } - qemu_mutex_destroy(&client->mutex); if (client->config_path) g_free(client->config_path); if (client->etcd_host) @@ -586,6 +586,8 @@ static void vitastor_close(BlockDriverState *bs) g_free(client->image); free(client->last_bitmap); client->last_bitmap = NULL; + qemu_mutex_unlock(&client->mutex); + qemu_mutex_destroy(&client->mutex); } #if QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR > 2