Skip to content

Commit

Permalink
Merge pull request #157 from microsoft/sprt/fix-agent-check
Browse files Browse the repository at this point in the history
ci: Fix agent static checks
  • Loading branch information
sprt authored Jan 31, 2024
2 parents 17da19f + 7726090 commit 3f35717
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/static-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ jobs:
- name: Install musl-tools
if: ${{ matrix.component != 'runtime' }}
run: sudo apt-get -y install musl-tools
- name: Install devicemapper
if: ${{ matrix.command == 'make check' && matrix.component == 'agent' }}
run: sudo apt-get -y install libdevmapper-dev
- name: Install libseccomp
if: ${{ matrix.command != 'make vendor' && matrix.command != 'make check' && matrix.install-libseccomp == 'yes' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion src/agent/rustjail/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ lazy_static! {
gid: Some(0xffffffff),
},
];

let sev_guest_path = "/dev/sev-guest";
if let Ok(sev_guest_attr) = fs::metadata(sev_guest_path) {
let sev_guest_devid = sev_guest_attr.rdev();
Expand Down
2 changes: 1 addition & 1 deletion src/agent/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ where
pub fn pcipath_to_sysfs(root_bus_sysfs: &str, pcipath: &pci::Path) -> Result<String> {
// Support up to 10 PCI segments.
let mut bus = "000[0-9]:00".to_string();

let mut relpath = String::new();

for i in 0..pcipath.len() {
Expand Down
26 changes: 12 additions & 14 deletions src/agent/src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,36 +306,34 @@ pub fn find_dm_name(mount_point: &str) -> io::Result<Option<String>> {
let mapper = Path::new("/dev/mapper");
let target = Path::new(mount_point);

for mount in proc_mounts::MountIter::new()? {
if let Ok(m) = mount {
if m.dest != target {
continue;
}
for mount in (proc_mounts::MountIter::new()?).flatten() {
if mount.dest != target {
continue;
}

if let Some(p) = m.source.parent() {
if p == mapper {
if let Some(f) = m.source.file_name() {
return Ok(Some(f.to_string_lossy().into()));
}
if let Some(p) = mount.source.parent() {
if p == mapper {
if let Some(f) = mount.source.file_name() {
return Ok(Some(f.to_string_lossy().into()));
}
}

break;
}

break;
}
Ok(None)
}

#[instrument]
pub fn remove_mounts(mounts: &[String]) -> Result<()> {
for m in mounts.iter() {
let dm_target = find_dm_name(&m);
let dm_target = find_dm_name(m);
nix::mount::umount(m.as_str()).context(format!("failed to umount {:?}", m))?;
if let Some(dm_name) = dm_target? {
let dm = devicemapper::DM::new()?;
let name = devicemapper::DmName::new(&dm_name)?;
dm.device_remove(
&devicemapper::DevId::Name(&name),
&devicemapper::DevId::Name(name),
devicemapper::DmOptions::default(),
)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/agent/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ pub(crate) fn common_storage_handler(logger: &Logger, storage: &Storage) -> Resu
let dm = devicemapper::DM::new()?;
let name = devicemapper::DmName::new(fname)?;
let opts = devicemapper::DmOptions::default().set_flags(devicemapper::DmFlags::DM_READONLY);
dm.device_create(&name, None, opts)
dm.device_create(name, None, opts)
.context("Unable to create dm device")?;

let id = devicemapper::DevId::Name(name);
Expand Down

0 comments on commit 3f35717

Please sign in to comment.