Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions include/libkrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ int32_t krun_add_disk(uint32_t ctx_id, const char *block_id, const char *disk_pa
/* Supported disk image formats */
#define KRUN_DISK_FORMAT_RAW 0
#define KRUN_DISK_FORMAT_QCOW2 1
/* Note: Only supports FLAT/ZERO formats without delta links */
#define KRUN_DISK_FORMAT_VMDK 2

/**
* Adds a disk image to be used as a general partition for the microVM. The supported
* image formats are: "raw" and "qcow2".
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ arch = { path = "../arch" }
utils = { path = "../utils" }
polly = { path = "../polly" }
rutabaga_gfx = { path = "../rutabaga_gfx", features = ["virgl_renderer", "virgl_renderer_next"], optional = true }
imago = { version = "0.1.6", features = ["sync-wrappers", "vm-memory"] }
imago = { version = "0.2.1", features = ["sync-wrappers", "vm-memory"] }

[target.'cfg(target_os = "macos")'.dependencies]
hvf = { path = "../hvf" }
Expand Down
11 changes: 9 additions & 2 deletions src/devices/src/virtio/block/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use std::sync::{Arc, Mutex};
use std::thread::JoinHandle;

use imago::{
file::File as ImagoFile, qcow2::Qcow2, raw::Raw, DynStorage, Storage, StorageOpenOptions,
SyncFormatAccess,
file::File as ImagoFile, qcow2::Qcow2, raw::Raw, vmdk::Vmdk, DynStorage, FormatDriverBuilder,
PermissiveImplicitOpenGate, Storage, StorageOpenOptions, SyncFormatAccess,
};
use log::{error, warn};
use utils::eventfd::{EventFd, EFD_NONBLOCK};
Expand Down Expand Up @@ -266,6 +266,13 @@ impl Block {
)?;
SyncFormatAccess::new(raw)?
}
ImageType::Vmdk => {
let vmdk = Vmdk::<Box<dyn DynStorage>, Arc<imago::FormatAccess<_>>>::builder(
Box::new(file),
)
.open_sync(PermissiveImplicitOpenGate::default())?;
SyncFormatAccess::new(vmdk)?
}
};

let disk_image = Arc::new(Mutex::new(disk_image));
Expand Down
1 change: 1 addition & 0 deletions src/devices/src/virtio/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ pub enum Error {
pub enum ImageType {
Raw,
Qcow2,
Vmdk,
}
1 change: 1 addition & 0 deletions src/libkrun/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ pub unsafe extern "C" fn krun_add_disk2(
let format = match disk_format {
0 => ImageType::Raw,
1 => ImageType::Qcow2,
2 => ImageType::Vmdk,
_ => {
// Do not continue if the user cannot specify a valid disk format
return -libc::EINVAL;
Expand Down
Loading