New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime-rs: bringing virtio-fs device in device-manager #7932
Conversation
af6b8b4
to
2af1160
Compare
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @Apokleos, few comments.
src/runtime-rs/crates/hypervisor/src/device/driver/virtio_fs.rs
Outdated
Show resolved
Hide resolved
05f77d2
to
7e73bbf
Compare
aa8fbc4
to
dff8cf0
Compare
/test |
dff8cf0
to
a425d73
Compare
dc03a4b
to
1edd76f
Compare
/retest |
/test |
1edd76f
to
39ef7b4
Compare
/test |
@Apokleos This PR still has a very huge commit that I believe could have been broken down further but it is definitely an improvement over the previous tentative. Please address pending comments. I'll ask approvers to review again and we'll merge it. |
@@ -325,6 +330,21 @@ impl DeviceManager { | |||
// No need to do find device for hybrid vsock device. | |||
Arc::new(Mutex::new(HybridVsockDevice::new(&device_id, hvconfig))) | |||
} | |||
DeviceConfig::ShareFsCfg(config) => { | |||
// Try to find the sharefs device. If found, just return. | |||
if let Some(device_id_matched) = self.find_device(config.shared_path.clone()).await |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why find_device()
takes an owned string instead of a string slice, forcing all this clone()
ing... But that's a case for another PR, ignore me here. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,I will consider to refactor it future!
// update the mount_config. | ||
device.config.mount_config = config.mount_config.clone(); | ||
} | ||
Arc::new(Mutex::new(device.clone())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is clone()
necessary here? get_device_info()
returns DeviceType
by value and is commonly implemented by clone()
ing self
. So target_device
is a clone already and owned by this function. If that's the case it might make more sense to drop the clone()
call here. That would leave target_device
partially moved from but I don't see it referenced after this match
statement so it should be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
let result = h | ||
.add_device(DeviceType::ShareFsMount(virtio_fs)) | ||
// update virtio-fs device with ShareFsMountConfig | ||
do_update_device(d, &DeviceConfig::ShareFsCfg(sharefs_config.clone())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to clone()
sharefs_config
here? I don't see it referenced anymore after this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
h.add_device(DeviceType::ShareFsMount(virtio_fs)) | ||
|
||
// update virtio-fs device with ShareFsMountConfig | ||
do_update_device(d, &DeviceConfig::ShareFsCfg(sharefs_config.clone())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like a similar piece of code in setup_inline_virtiofs()
, is clone()
necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
8192c2a
to
b6a0445
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks @Apokleos for all the work you put into this PR!
@@ -472,6 +547,19 @@ pub async fn do_handle_device( | |||
Ok(device_info) | |||
} | |||
|
|||
pub async fn do_update_device( | |||
d: &RwLock<DeviceManager>, | |||
update_config: &DeviceConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated_config
here as well, as we want to avoid the use of verbs in the function params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Apokleos Can you make this small fix? Otherwise the PR looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amshinde Thx, sorry, I forget to correct this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
b6a0445
to
3080d3d
Compare
/test |
.await | ||
.try_update_device(updated_config) | ||
.await | ||
.context("failed to update deivce")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: s/deivce/device
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to address all the comments @Apokleos !
It mainly focus on the two parts: (1) redesign the ShareFsConfig with ShareFsMountConfig The device mount operation must depend on the fact that sharefs device exists, and re-design the structure of SharesFsConfig and move the ShareFsMountConfig into it with Option type, which is to describe the relation between ShareFsConfig and ShareFsMountConfig. (2) move virtiofs into device manager Currently, virtio-fs is still outside of the device manager. To do Enhancement of device manager, it will bring virtio-fs device in device-manager for unified management Fixes: kata-containers#7915 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
Fixes: kata-containers#7915 Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
3080d3d
to
fe62e65
Compare
/test |
/retest |
/test-s390x |
/retest-s390x |
/test-ubuntu |
/test-s390x |
Currently, virtio-fs is still outside of the device manager. This causes some management issues, such as the inability to unify PCI address management.
To do Enhancement of device manager, it will bring virtio-fs device in device-manager for unified management
Fixes: #7915