diff options
author | Steven Richman <srichman@google.com> | 2020-05-11 13:27:03 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-21 15:03:51 +0000 |
commit | 0aacc50fd25d61ae1274d6054550f45acaa50897 (patch) | |
tree | 131c2f4a3dfdf069cd9766f5b2eaa51de2472b60 /sys_util | |
parent | 1de5def170a96d8a5d6a50a1759128e4554e2bc2 (diff) | |
download | crosvm-0aacc50fd25d61ae1274d6054550f45acaa50897.tar crosvm-0aacc50fd25d61ae1274d6054550f45acaa50897.tar.gz crosvm-0aacc50fd25d61ae1274d6054550f45acaa50897.tar.bz2 crosvm-0aacc50fd25d61ae1274d6054550f45acaa50897.tar.lz crosvm-0aacc50fd25d61ae1274d6054550f45acaa50897.tar.xz crosvm-0aacc50fd25d61ae1274d6054550f45acaa50897.tar.zst crosvm-0aacc50fd25d61ae1274d6054550f45acaa50897.zip |
hypervisor: add KvmVm new and try_clone
Vms and Vcpus will be try_cloneable and Send, so we can configure on vcpu threads and so IrqChips can reference all Vcpus. To support cloning, collection fields in Vm have been moved into arc mutexes, and Vm and Vcpu are now Sized. Because this breaks object safety, all usage of the traits will be via static binding. Add impl AsRawFd for SafeDescriptor, to get the sys_util ioctl functions working with SafeDescriptor; eventually the functions will change to take SafeDescriptors. Copy set_user_memory_region helper from kvm crate. BUG=chromium:1077058 TEST=cargo test -p hypervisor Change-Id: I23de47c4472a77632006d0d45de9754394b400c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197337 Reviewed-by: Udam Saini <udam@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Steven Richman <srichman@google.com>
Diffstat (limited to 'sys_util')
-rw-r--r-- | sys_util/src/descriptor.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys_util/src/descriptor.rs b/sys_util/src/descriptor.rs index 1af72fc..9082394 100644 --- a/sys_util/src/descriptor.rs +++ b/sys_util/src/descriptor.rs @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use std::os::unix::io::RawFd; - -use crate::{errno_result, Result}; use std::mem; use std::ops::Drop; +use std::os::unix::io::{AsRawFd, RawFd}; + +use crate::{errno_result, Result}; pub type RawDescriptor = RawFd; @@ -60,6 +60,12 @@ impl FromRawDescriptor for SafeDescriptor { } } +impl AsRawFd for SafeDescriptor { + fn as_raw_fd(&self) -> RawFd { + self.as_raw_descriptor() + } +} + impl SafeDescriptor { /// Clones this descriptor, internally creating a new descriptor. The new SafeDescriptor will /// share the same underlying count within the kernel. |