]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: propagate rbd-wnbd errors
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 29 Jan 2021 13:38:19 +0000 (13:38 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 3 Feb 2021 07:21:12 +0000 (07:21 +0000)
This change updates the "rbd device" commands, propagating
rbd-wnbd.exe exit codes.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/common/win32/SubProcess.cc
src/tools/rbd/action/Wnbd.cc

index 565cb47f0faae6ad48a5d73d8a1a972412be59ed..ce6b851e029b19713a4e8d48a14f7539a669e2bc 100644 (file)
@@ -142,18 +142,20 @@ int SubProcess::join() {
   close(stdout_pipe_in_fd);
   close(stderr_pipe_in_fd);
 
-  DWORD status = 0;
+  int status = 0;
 
   if (WaitForSingleObject(proc_handle, INFINITE) != WAIT_FAILED) {
     if (!GetExitCodeProcess(proc_handle, &status)) {
       errstr << cmd << ": Could not get exit code: " << pid
              << ". Error code: " << GetLastError();
+      status = -ECHILD;
     } else if (status) {
       errstr << cmd << ": exit status: " << status;
     }
   } else {
     errstr << cmd << ": Waiting for child process failed: " << pid
            << ". Error code: " << GetLastError();
+    status = -ECHILD;
   }
 
   close_h(proc_handle);
index 41b331a9e3c04f37075b5216e0e363ed169187ef..4e5b20b61b03c88992500f564dfc51832cee27f4 100644 (file)
@@ -53,9 +53,11 @@ static int call_wnbd_cmd(const po::variables_map &vm,
   if (process.spawn()) {
     std::cerr << "rbd: failed to run rbd-wnbd: " << process.err() << std::endl;
     return -EINVAL;
-  } else if (process.join()) {
+  }
+  int exit_code = process.join();
+  if (exit_code) {
     std::cerr << "rbd: rbd-wnbd failed with error: " << process.err() << std::endl;
-    return -EINVAL;
+    return exit_code;
   }
 
   return 0;