summary refs log tree commit diff
path: root/qcow_utils
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-12-17 16:14:52 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-06 21:26:37 +0000
commit521cf5d6d3faad12671ba0f7eb5d6ed85fc20693 (patch)
treef3db6ad42fcda4dfe2970b89db0690d2d78a3c06 /qcow_utils
parent7898b80860522f1aec799a26f2d68cac9f2d55c0 (diff)
downloadcrosvm-521cf5d6d3faad12671ba0f7eb5d6ed85fc20693.tar
crosvm-521cf5d6d3faad12671ba0f7eb5d6ed85fc20693.tar.gz
crosvm-521cf5d6d3faad12671ba0f7eb5d6ed85fc20693.tar.bz2
crosvm-521cf5d6d3faad12671ba0f7eb5d6ed85fc20693.tar.lz
crosvm-521cf5d6d3faad12671ba0f7eb5d6ed85fc20693.tar.xz
crosvm-521cf5d6d3faad12671ba0f7eb5d6ed85fc20693.tar.zst
crosvm-521cf5d6d3faad12671ba0f7eb5d6ed85fc20693.zip
qcow_utils: remove unused convert functions
The convert_to_qcow2 and convert_to_raw functions are no longer used
now that concierge's export operation exports the unmodified disk image
in a tarball instead of converting it to qcow2.  Remove the unused
functions to clean up unreachable code.

BUG=None
TEST=cargo build -p qcow_utils
TEST=emerge-nami crosvm vm_host_tools

Change-Id: I525a9123481bd8cb6ebf022a289ecdf6e7ceaff2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1972476
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'qcow_utils')
-rw-r--r--qcow_utils/src/qcow_utils.h8
-rw-r--r--qcow_utils/src/qcow_utils.rs57
2 files changed, 2 insertions, 63 deletions
diff --git a/qcow_utils/src/qcow_utils.h b/qcow_utils/src/qcow_utils.h
index 90aa23b..79326a3 100644
--- a/qcow_utils/src/qcow_utils.h
+++ b/qcow_utils/src/qcow_utils.h
@@ -17,14 +17,6 @@ int create_qcow_with_size(const char *path, uint64_t virtual_size);
 // the disk image is currently smaller than the requested size.
 int expand_disk_image(const char *path, uint64_t virtual_size);
 
-// Copy the source disk image from `src_fd` into `dst_fd` as a qcow2 image file.
-// Returns 0 on success or a negated errno value on failure.
-int convert_to_qcow2(int src_fd, int dst_fd);
-
-// Copy the source disk image from `src_fd` into `dst_fd` as a raw image file.
-// Returns 0 on success or a negated errno value on failure.
-int convert_to_raw(int src_fd, int dst_fd);
-
 #ifdef __cplusplus
 };
 #endif
diff --git a/qcow_utils/src/qcow_utils.rs b/qcow_utils/src/qcow_utils.rs
index 6f11c66..0d77816 100644
--- a/qcow_utils/src/qcow_utils.rs
+++ b/qcow_utils/src/qcow_utils.rs
@@ -4,14 +4,11 @@
 
 // Exported interface to basic qcow functionality to be used from C.
 
-use libc::{EBADFD, EINVAL, EIO, ENOSYS};
+use libc::{EINVAL, EIO, ENOSYS};
 use std::ffi::CStr;
-use std::fs::{File, OpenOptions};
+use std::fs::OpenOptions;
 use std::io::{Seek, SeekFrom};
-use std::mem::forget;
 use std::os::raw::{c_char, c_int};
-use std::os::unix::io::FromRawFd;
-use std::panic::catch_unwind;
 
 use disk::ImageType;
 use qcow::QcowFile;
@@ -106,53 +103,3 @@ pub unsafe extern "C" fn expand_disk_image(path: *const c_char, virtual_size: u6
         Err(_) => -ENOSYS,
     }
 }
-
-#[no_mangle]
-pub unsafe extern "C" fn convert_to_qcow2(src_fd: c_int, dst_fd: c_int) -> c_int {
-    // The caller is responsible for passing valid file descriptors.
-    // The caller retains ownership of the file descriptors.
-    let src_file = File::from_raw_fd(src_fd);
-    let src_file_owned = src_file.try_clone();
-    forget(src_file);
-
-    let dst_file = File::from_raw_fd(dst_fd);
-    let dst_file_owned = dst_file.try_clone();
-    forget(dst_file);
-
-    match (src_file_owned, dst_file_owned) {
-        (Ok(src_file), Ok(dst_file)) => {
-            catch_unwind(
-                || match disk::convert(src_file, dst_file, ImageType::Qcow2) {
-                    Ok(_) => 0,
-                    Err(_) => -EIO,
-                },
-            )
-            .unwrap_or(-EIO)
-        }
-        _ => -EBADFD,
-    }
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn convert_to_raw(src_fd: c_int, dst_fd: c_int) -> c_int {
-    // The caller is responsible for passing valid file descriptors.
-    // The caller retains ownership of the file descriptors.
-    let src_file = File::from_raw_fd(src_fd);
-    let src_file_owned = src_file.try_clone();
-    forget(src_file);
-
-    let dst_file = File::from_raw_fd(dst_fd);
-    let dst_file_owned = dst_file.try_clone();
-    forget(dst_file);
-
-    match (src_file_owned, dst_file_owned) {
-        (Ok(src_file), Ok(dst_file)) => {
-            catch_unwind(|| match disk::convert(src_file, dst_file, ImageType::Raw) {
-                Ok(_) => 0,
-                Err(_) => -EIO,
-            })
-            .unwrap_or(-EIO)
-        }
-        _ => -EBADFD,
-    }
-}