Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/devices/src/virtio/block/sys/windows.rs
5394 views
1
// Copyright 2022 The ChromiumOS Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
use anyhow::Context;
6
use base::warn;
7
use cros_async::sys::windows::ExecutorKindSys;
8
use cros_async::Executor;
9
use cros_async::ExecutorKind;
10
11
use crate::virtio::block::DiskOption;
12
use crate::virtio::BlockAsync;
13
14
pub fn get_seg_max(_queue_size: u16) -> u32 {
15
// Allow a single segment per request, since vectored I/O is not implemented for Windows yet.
16
1
17
}
18
19
impl DiskOption {
20
/// Open the specified disk file.
21
pub fn open(&self) -> anyhow::Result<Box<dyn disk::DiskFile>> {
22
Ok(disk::open_disk_file(disk::DiskFileParams {
23
path: self.path.clone(),
24
is_read_only: self.read_only,
25
is_sparse_file: self.sparse,
26
is_overlapped: matches!(
27
self.async_executor.unwrap_or_default(),
28
ExecutorKind::SysVariants(ExecutorKindSys::Overlapped { .. })
29
),
30
is_direct: self.direct,
31
lock: self.lock,
32
depth: 0,
33
})?)
34
}
35
}
36
37
impl BlockAsync {
38
pub fn create_executor(&self) -> Executor {
39
let mut kind = self.executor_kind;
40
if let ExecutorKind::SysVariants(ExecutorKindSys::Overlapped { concurrency }) = &mut kind {
41
if concurrency.is_none() {
42
*concurrency = Some(self.io_concurrency);
43
}
44
}
45
Executor::with_executor_kind(kind).expect("Failed to create an executor")
46
}
47
}
48
49