• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

google / alioth / 17385983897

01 Sep 2025 07:41PM UTC coverage: 18.009% (-0.1%) from 18.149%
17385983897

Pull #281

github

web-flow
Merge 782c57b11 into 6ec9a6d6b
Pull Request #281: Port to Apple Hypervisor framework

0 of 154 new or added lines in 11 files covered. (0.0%)

1166 existing lines in 29 files now uncovered.

1362 of 7563 relevant lines covered (18.01%)

18.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/alioth/src/hv/kvm/sev/sev.rs
1
// Copyright 2024 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
#![allow(dead_code)]
16

17
pub mod bindings;
18

19
use std::fmt::Debug;
20
use std::fs::File;
21
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
22
use std::path::Path;
23

24
use snafu::ResultExt;
25

26
use crate::hv::Result;
27
use crate::hv::kvm::kvm_error;
28
use crate::ioctl_writeread;
29

30
use self::bindings::{SEV_RET_SUCCESS, SevIssueCmd};
31

32
const SEV_IOC_TYPE: u8 = b'S';
33

34
ioctl_writeread!(sev_issue_cmd, SEV_IOC_TYPE, 0x0, SevIssueCmd);
35

36
#[derive(Debug)]
37
pub struct SevFd {
38
    fd: OwnedFd,
39
}
40

41
impl AsFd for SevFd {
UNCOV
42
    fn as_fd(&self) -> BorrowedFd<'_> {
UNCOV
43
        self.fd.as_fd()
44
    }
45
}
46

47
pub const SEV_PLATFORM_STATUS: u32 = 1;
48

49
impl SevFd {
50
    pub fn new(path: impl AsRef<Path>) -> Result<Self> {
×
51
        let f = File::open(&path).context(kvm_error::OpenFile {
×
52
            path: path.as_ref(),
×
53
        })?;
54
        let sev_fd = Self { fd: f.into() };
×
55
        Ok(sev_fd)
×
56
    }
57

58
    pub fn issue_cmd<T>(&self, cmd: u32, data: &mut T) -> Result<()> {
×
59
        let mut req = SevIssueCmd {
60
            cmd,
61
            data: data as *mut T as _,
×
62
            error: 0,
63
        };
64
        unsafe { sev_issue_cmd(&self.fd, &mut req) }.context(kvm_error::SevCmd)?;
×
65
        if req.error != SEV_RET_SUCCESS {
×
66
            return kvm_error::SevErr { code: req.error }.fail()?;
×
67
        }
68
        Ok(())
×
69
    }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc