Skip to content
Open
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
5 changes: 2 additions & 3 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.5", features = ["sync-wrappers", "vm-memory"] }
imago = { features = ["sync-wrappers", "vm-memory"], git = "https://gitlab.com/hreitz/imago.git", branch = "main" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can only consume dependencies published on crates.io. The stable branch of imago doesn't have vmdk support, so we need to wait a bit for 0.2.0 to be released.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently nerdbox will directly rely on this but libkrun doesn't support virtio-pci so the total number of virtio-blk device is much limited (even support it still ineffencient compared to this way.

BTW, vmdk support is much seperate from the main raw and qcow2 support, I wonder if it might be fine for 0.1.x? or is there some timeline to release 0.2.0? Cc @XanClic

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m working on 0.2.0, it should be doable by next week. If I can’t get it done, I’ll make at least an 0.1.7 with it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is awesome, Thank you all!


[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;
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 @@ -240,6 +240,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(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