Skip to content
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

Merged
merged 3 commits into from Nov 21, 2023

Conversation

Apokleos
Copy link
Contributor

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

@katacontainersbot katacontainersbot added the size/large Task of significant size label Sep 13, 2023
@Apokleos Apokleos marked this pull request as ready for review September 18, 2023 02:22
@Apokleos Apokleos changed the title WIP runtime-rs: bringing virtio-fs device in device-manager runtime-rs: bringing virtio-fs device in device-manager Sep 18, 2023
@Apokleos
Copy link
Contributor Author

/test

Copy link
Contributor

@quanweiZhou quanweiZhou left a 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.

@Apokleos Apokleos force-pushed the wrap-virtiofs-in-dm branch 2 times, most recently from 05f77d2 to 7e73bbf Compare September 21, 2023 08:46
@katacontainersbot katacontainersbot added size/small Small and simple task size/large Task of significant size and removed size/large Task of significant size size/small Small and simple task labels Sep 21, 2023
@Apokleos
Copy link
Contributor Author

/test

@katacontainersbot katacontainersbot added size/small Small and simple task size/large Task of significant size and removed size/large Task of significant size size/small Small and simple task labels Sep 25, 2023
@Apokleos
Copy link
Contributor Author

/retest

@Apokleos
Copy link
Contributor Author

/test

@Apokleos
Copy link
Contributor Author

/test

@gkurz
Copy link
Member

gkurz commented Nov 15, 2023

@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
Copy link
Contributor

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. ;-)

Copy link
Contributor Author

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()))
Copy link
Contributor

@pmores pmores Nov 16, 2023

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.

Copy link
Contributor Author

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()))
Copy link
Contributor

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.

Copy link
Contributor Author

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()))
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@pmores pmores left a 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,
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@Apokleos
Copy link
Contributor Author

/test

.await
.try_update_device(updated_config)
.await
.context("failed to update deivce")?;
Copy link
Member

Choose a reason for hiding this comment

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

Typo: s/deivce/device

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

@gkurz gkurz left a 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>
@Apokleos
Copy link
Contributor Author

Thanks for taking the time to address all the comments @Apokleos !

Thx @gkurz very much !

@amshinde
Copy link
Member

/test

@Apokleos
Copy link
Contributor Author

/retest

@Apokleos
Copy link
Contributor Author

/test-s390x

@Apokleos
Copy link
Contributor Author

/retest-s390x

@Apokleos
Copy link
Contributor Author

/test-ubuntu

@BbolroC
Copy link
Member

BbolroC commented Nov 21, 2023

/test-s390x

@Apokleos Apokleos merged commit 4fd2914 into kata-containers:main Nov 21, 2023
158 of 164 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test runtime-rs size/huge Largest and most complex task (probably needs breaking into small pieces)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

runtime-rs: Enhancement of bringing virtio-fs device in device-manager for unified management
10 participants