diff options
author | Dylan Reid <dgreid@chromium.org> | 2019-10-22 18:30:36 +0300 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-10 05:16:06 +0000 |
commit | bb30b2f7cf2721b32da71adfa7f7482bfce7b915 (patch) | |
tree | e364b4b3d1e605ec1aa7ba032e1d3211cd12ca18 /src/plugin | |
parent | 7434c0002022541f34a929d9a8e3bfaaf4dfc2d9 (diff) | |
download | crosvm-bb30b2f7cf2721b32da71adfa7f7482bfce7b915.tar crosvm-bb30b2f7cf2721b32da71adfa7f7482bfce7b915.tar.gz crosvm-bb30b2f7cf2721b32da71adfa7f7482bfce7b915.tar.bz2 crosvm-bb30b2f7cf2721b32da71adfa7f7482bfce7b915.tar.lz crosvm-bb30b2f7cf2721b32da71adfa7f7482bfce7b915.tar.xz crosvm-bb30b2f7cf2721b32da71adfa7f7482bfce7b915.tar.zst crosvm-bb30b2f7cf2721b32da71adfa7f7482bfce7b915.zip |
Add runnable vcpu
Add a new type `RunnableVcpu` for a vcpu that is bound to a thread. This adds type safety to ensure that vcpus are only ever run on one thread because RunnableVcpu can't `Send`. It also ensures multiple vcpus can't run on the same thread. Change-Id: Ia50dc127bc7a4ea4ce3ca99ef1062edbcaa912d0 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898909 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'src/plugin')
-rw-r--r-- | src/plugin/mod.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index f0d6932..5f9a5db 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -420,7 +420,7 @@ pub fn run_vcpus( let vcpu_thread_barrier = vcpu_thread_barrier.clone(); let vcpu_exit_evt = exit_evt.try_clone().map_err(Error::CloneEventFd)?; let vcpu_plugin = plugin.create_vcpu(cpu_id)?; - let mut vcpu = Vcpu::new(cpu_id as c_ulong, kvm, vm).map_err(Error::CreateVcpu)?; + let vcpu = Vcpu::new(cpu_id as c_ulong, kvm, vm).map_err(Error::CreateVcpu)?; vcpu_handles.push( thread::Builder::new() @@ -431,10 +431,12 @@ pub fn run_vcpus( // because we will be using first RT signal to kick the VCPU. vcpu.set_signal_mask(&[]) .expect("failed to set up KVM VCPU signal mask"); - } else { - vcpu.set_thread_id(SIGRTMIN() + 0); } + let vcpu = vcpu + .to_runnable(Some(SIGRTMIN() + 0)) + .expect("Failed to set thread id"); + let res = vcpu_plugin.init(&vcpu); vcpu_thread_barrier.wait(); if let Err(e) = res { |