fn as_cmd(&'a self) -> Vec<String> {
        // Figure out log-level
        let log_level = match std::env::var("RUST_LOG") {
            Ok(lvl) if lvl == "debug" => "debug",
            Ok(lvl) if lvl == "trace" => "trace",
            Ok(lvl) if lvl == "warn" => "warn",
            Ok(lvl) if lvl == "error" => "error",
            Ok(lvl) if lvl == "info" => "info",
            _ => "info",
        };

        // Start with cmdline from build
        let mut cmd = self.build_args.as_cmd();

        cmd.push(String::from("--cmd"));
        cmd.push(format!(
            "log={} test={} {}",
            log_level,
            self.kernel_test,
            self.cmd.unwrap_or("")
        ));
        cmd.push(String::from("--nic"));
        cmd.push(String::from(self.nic));

        match &self.machine {
            Machine::Qemu => {
                cmd.push(String::from("--qemu-cores"));
                cmd.push(format!("{}", self.cores));

                cmd.push(String::from("--qemu-nodes"));
                cmd.push(format!("{}", self.nodes));

                cmd.push(String::from("--qemu-memory"));
                cmd.push(format!("{}", self.memory));

                if self.pmem > 0 {
                    cmd.push(String::from("--qemu-pmem"));
                    cmd.push(format!("{}", self.pmem));
                }

                if self.ivshmem > 0 {
                    cmd.push(String::from("--qemu-ivshmem"));
                    cmd.push(format!("{}", self.ivshmem));
                }

                if !self.shmem_path.is_empty() {
                    cmd.push(String::from("--qemu-shmem-path"));
                    cmd.push(format!("{}", self.shmem_path));
                }

                if self.setaffinity {
                    cmd.push(String::from("--qemu-affinity"));
                }

                if self.prealloc {
                    cmd.push(String::from("--qemu-prealloc"));
                }

                if self.large_pages {
                    // TODO: Also register some?
                    // let pages = (self.memory+2) / 2;
                    // sudo bash -c "echo $pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
                    // and when done
                    // sudo bash -c "echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
                    cmd.push(String::from("--qemu-large-pages"));
                }

                // Form arguments for QEMU
                let mut qemu_args: Vec<String> =
                    self.qemu_args.iter().map(|arg| arg.to_string()).collect();
                if !qemu_args.is_empty() {
                    cmd.push(format!("--qemu-settings={}", qemu_args.join(" ")));
                }
            }
            Machine::Baremetal(mname) => {
                cmd.push(format!("--machine={}", mname));
            }
        }

        if self.kgdb {
            cmd.push(String::from("--kgdb"));
        }

        // Don't run qemu, just build?
        if self.norun {
            cmd.push(String::from("--norun"));
        }

        cmd
    }
/// Converts the RunnerArgs to a run.py command line invocation.
Converts the RunnerArgs to a run.py command line invocation.
Converts the RunnerArgs to a run . py command line invocation .
fn as_cmd(&'a self) -> Vec<String> {
        // Figure out log-level
        let log_level = match std::env::var("RUST_LOG") {
            Ok(lvl) if lvl == "debug" => "debug",
            Ok(lvl) if lvl == "trace" => "trace",
            Ok(lvl) if lvl == "warn" => "warn",
            Ok(lvl) if lvl == "error" => "error",
            Ok(lvl) if lvl == "info" => "info",
            _ => "info",
        };
        // Start with cmdline from build
        let mut cmd = self.build_args.as_cmd();
        cmd.push(String::from("--cmd"));
        cmd.push(format!(
            "log={} test={} {}",
            log_level,
            self.kernel_test,
            self.cmd.unwrap_or("")
        ));
        cmd.push(String::from("--nic"));
        cmd.push(String::from(self.nic));
        match &self.machine {
            Machine::Qemu => {
                cmd.push(String::from("--qemu-cores"));
                cmd.push(format!("{}", self.cores));
                cmd.push(String::from("--qemu-nodes"));
                cmd.push(format!("{}", self.nodes));
                cmd.push(String::from("--qemu-memory"));
                cmd.push(format!("{}", self.memory));
                if self.pmem > 0 {
                    cmd.push(String::from("--qemu-pmem"));
                    cmd.push(format!("{}", self.pmem));
                }
                if self.ivshmem > 0 {
                    cmd.push(String::from("--qemu-ivshmem"));
                    cmd.push(format!("{}", self.ivshmem));
                }
                if !self.shmem_path.is_empty() {
                    cmd.push(String::from("--qemu-shmem-path"));
                    cmd.push(format!("{}", self.shmem_path));
                }
                if self.setaffinity {
                    cmd.push(String::from("--qemu-affinity"));
                }
                if self.prealloc {
                    cmd.push(String::from("--qemu-prealloc"));
                }
                if self.large_pages {
                    // TODO: Also register some?
                    // let pages = (self.memory+2) / 2;
                    // sudo bash -c "echo $pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
                    // and when done
                    // sudo bash -c "echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages"
                    cmd.push(String::from("--qemu-large-pages"));
                }
                // Form arguments for QEMU
                let mut qemu_args: Vec<String> =
                    self.qemu_args.iter().map(|arg| arg.to_string()).collect();
                if !qemu_args.is_empty() {
                    cmd.push(format!("--qemu-settings={}", qemu_args.join(" ")));
                }
            }
            Machine::Baremetal(mname) => {
                cmd.push(format!("--machine={}", mname));
            }
        }
        if self.kgdb {
            cmd.push(String::from("--kgdb"));
        }
        // Don't run qemu, just build?
        if self.norun {
            cmd.push(String::from("--norun"));
        }
        cmd
    }
fn as_cmd ( & ' a self ) -> Vec < String > { // Figure out log-level let log_level = match std :: env :: var ( " " ) { Ok ( lvl ) if lvl == " " => " " , Ok ( lvl ) if lvl == " " => " " , Ok ( lvl ) if lvl == " " => " " , Ok ( lvl ) if lvl == " " => " " , Ok ( lvl ) if lvl == " " => " " , _ => " " , } ; // Start with cmdline from build let mut cmd = self . build_args . as_cmd ( ) ; cmd . push ( String :: from ( " " ) ) ; cmd . push ( format ! ( " " log_level self kernel_test self cmd unwrap_or ( " " ) ) ) ; cmd . push ( String :: from ( " " ) ) ; cmd . push ( String :: from ( self . nic ) ) ; match & self . machine { Machine :: Qemu => { cmd . push ( String :: from ( " " ) ) ; cmd . push ( format ! ( " " self cores ) ) ; cmd . push ( String :: from ( " " ) ) ; cmd . push ( format ! ( " " self nodes ) ) ; cmd . push ( String :: from ( " " ) ) ; cmd . push ( format ! ( " " self memory ) ) ; if self . pmem > 0 { cmd . push ( String :: from ( " " ) ) ; cmd . push ( format ! ( " " self pmem ) ) ; } if self . ivshmem > 0 { cmd . push ( String :: from ( " " ) ) ; cmd . push ( format ! ( " " self ivshmem ) ) ; } if ! self . shmem_path . is_empty ( ) { cmd . push ( String :: from ( " " ) ) ; cmd . push ( format ! ( " " self shmem_path ) ) ; } if self . setaffinity { cmd . push ( String :: from ( " " ) ) ; } if self . prealloc { cmd . push ( String :: from ( " " ) ) ; } if self . large_pages { // TODO: Also register some? // let pages = (self.memory+2) / 2; // sudo bash -c "echo $pages > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" // and when done // sudo bash -c "echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" cmd . push ( String :: from ( " " ) ) ; } // Form arguments for QEMU let mut qemu_args : Vec < String > = self . qemu_args . iter ( ) . map ( | arg | arg . to_string ( ) ) . collect ( ) ; if ! qemu_args . is_empty ( ) { cmd . push ( format ! ( " " qemu_args join ( " " ) ) ) ; } } Machine :: Baremetal ( mname ) => { cmd . push ( format ! ( " " mname ) ) ; } } if self . kgdb { cmd . push ( String :: from ( " " ) ) ; } // Don't run qemu, just build? if self . norun { cmd . push ( String :: from ( " " ) ) ; } cmd }
Converts the RunnerArgs to a run.py command line invocation.
Converts the RunnerArgs to a run . py command line invocation .
&'a self
&'a self