mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
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>
This commit is contained in:
parent
7898b80860
commit
521cf5d6d3
2 changed files with 2 additions and 63 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue