Skip to content

Commit

Permalink
fix(vfio): open the iommu device as read-only
Browse files Browse the repository at this point in the history
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
  • Loading branch information
Lencerf committed Oct 28, 2024
1 parent 7d15856 commit 3ef3eb0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions alioth/src/vfio/iommu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::fs::{File, OpenOptions};
use std::fs::File;
use std::mem::size_of;
use std::os::fd::AsRawFd;
use std::path::Path;
Expand All @@ -36,13 +36,9 @@ pub struct Iommu {

impl Iommu {
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
let fd = OpenOptions::new()
.read(true)
.write(true)
.open(&path)
.context(error::AccessDevice {
path: path.as_ref(),
})?;
let fd = File::open(&path).context(error::AccessDevice {
path: path.as_ref(),
})?;
Ok(Iommu { fd })
}
}
Expand Down

0 comments on commit 3ef3eb0

Please sign in to comment.