From afcab324e1e4d68288dc301b1775a9d96fc32fa4 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 7 Mar 2025 00:18:03 +0300 Subject: [PATCH] Destroy qemu driver under lock (may fix crashes after attach/detach?) --- src/client/qemu_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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