patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [PATCH 2/2] host/rootfs: remove unnecessary modprobes
Date: Mon, 21 Mar 2022 14:01:07 +0000	[thread overview]
Message-ID: <20220321140107.1043654-2-hi@alyssa.is> (raw)
In-Reply-To: <20220321140107.1043654-1-hi@alyssa.is>

Now that we're using a proper modprobe implementation, some of these
weird modprobes we shouldn't have needed in the first place can
actually be removed.
---
 host/rootfs/etc/mdev/net/add |  5 +---
 host/start-vm/modprobe.rs    | 49 ------------------------------------
 host/start-vm/start-vm.rs    |  4 ---
 3 files changed, 1 insertion(+), 57 deletions(-)
 delete mode 100644 host/start-vm/modprobe.rs

diff --git a/host/rootfs/etc/mdev/net/add b/host/rootfs/etc/mdev/net/add
index 959d73a..7b282e7 100755
--- a/host/rootfs/etc/mdev/net/add
+++ b/host/rootfs/etc/mdev/net/add
@@ -5,10 +5,7 @@
 # Assign the whole IOMMU group containing this device to the network
 # VM.
 
-if {
-  forx -pE module { vfio-pci vfio_iommu_type1 }
-  modprobe $module
-}
+if { modprobe vfio-pci }
 
 importas -i devpath DEVPATH
 
diff --git a/host/start-vm/modprobe.rs b/host/start-vm/modprobe.rs
deleted file mode 100644
index 6186820..0000000
--- a/host/start-vm/modprobe.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: EUPL-1.2
-// SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
-
-use std::ffi::OsStr;
-use std::fmt::{self, Display, Formatter};
-use std::io;
-use std::os::unix::prelude::*;
-use std::process::{Command, ExitStatus};
-
-#[derive(Debug)]
-pub enum ModprobeError {
-    Spawn(io::Error),
-    Fail(ExitStatus),
-}
-
-impl Display for ModprobeError {
-    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
-        use ModprobeError::*;
-        match self {
-            Spawn(e) => write!(f, "failed to spawn modprobe: {}", e),
-            Fail(status) => {
-                if let Some(code) = status.code() {
-                    write!(f, "modprobe exited with status {}", code)
-                } else {
-                    write!(f, "modprobe killed by signal {}", status.signal().unwrap())
-                }
-            }
-        }
-    }
-}
-
-pub fn modprobe<I, S>(module_names: I) -> Result<(), ModprobeError>
-where
-    I: IntoIterator<Item = S>,
-    S: AsRef<OsStr>,
-{
-    let status = Command::new("modprobe")
-        .arg("-q")
-        .arg("--")
-        .args(module_names)
-        .status()
-        .map_err(ModprobeError::Spawn)?;
-
-    if status.success() {
-        Ok(())
-    } else {
-        Err(ModprobeError::Fail(status))
-    }
-}
diff --git a/host/start-vm/start-vm.rs b/host/start-vm/start-vm.rs
index becbe5c..0d08eaa 100644
--- a/host/start-vm/start-vm.rs
+++ b/host/start-vm/start-vm.rs
@@ -2,7 +2,6 @@
 // SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
 
 mod ch;
-mod modprobe;
 mod net;
 
 use std::env::{args, current_dir};
@@ -12,7 +11,6 @@ use std::os::unix::prelude::*;
 use std::path::PathBuf;
 use std::process::{exit, Command};
 
-use modprobe::modprobe;
 use net::{format_mac, net_setup, NetConfig};
 
 macro_rules! errx {
@@ -30,8 +28,6 @@ macro_rules! err {
 }
 
 fn main() {
-    modprobe(&["kvm-intel"]).unwrap_or_else(err!(1, "modprobe kvm-intel"));
-
     let mut command = Command::new("s6-notifyoncheck");
     command.args(&["-dc", "test -S env/cloud-hypervisor.sock"]);
     command.arg("cloud-hypervisor");
-- 
2.35.1


  reply	other threads:[~2022-03-21 14:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 14:01 [PATCH 1/2] Busybox modprobe is banned Alyssa Ross
2022-03-21 14:01 ` Alyssa Ross [this message]
2022-03-22  8:36   ` [PATCH 2/2] host/rootfs: remove unnecessary modprobes Alyssa Ross
2022-03-22  8:54 ` [PATCH 1/2] Busybox modprobe is banned Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220321140107.1043654-2-hi@alyssa.is \
    --to=hi@alyssa.is \
    --cc=devel@spectrum-os.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).