From 0757ba630a59a381a6dbd29ac3e0279bc4c31d69 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 23 Jan 2022 23:02:01 +0300 Subject: [PATCH] Do not happily NBD "map" non-existing images, do not try to benchmark them too --- src/fio_cluster.cpp | 6 ++++++ src/nbd_proxy.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/fio_cluster.cpp b/src/fio_cluster.cpp index edc82822..a8ca5455 100644 --- a/src/fio_cluster.cpp +++ b/src/fio_cluster.cpp @@ -247,6 +247,12 @@ static int sec_setup(struct thread_data *td) vitastor_c_uring_wait_events(bsd->cli); } td->files[0]->real_file_size = vitastor_c_inode_get_size(bsd->watch); + if (!vitastor_c_inode_get_num(bsd->watch) || + !td->files[0]->real_file_size) + { + td_verror(td, EINVAL, "image does not exist"); + return 1; + } } bsd->trace = o->trace ? true : false; diff --git a/src/nbd_proxy.cpp b/src/nbd_proxy.cpp index 6fbaf0e0..b8102a50 100644 --- a/src/nbd_proxy.cpp +++ b/src/nbd_proxy.cpp @@ -190,6 +190,12 @@ public: } watch = cli->st_cli.watch_inode(image_name); device_size = watch->cfg.size; + if (!watch->cfg.num || !device_size) + { + // Image does not exist + fprintf(stderr, "Image %s does not exist\n", image_name.c_str()); + exit(1); + } } // Initialize NBD int sockfd[2];