summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKansho Nishida <kansho@google.com>2019-12-18 13:13:14 +0900
committerCommit Bot <commit-bot@chromium.org>2020-02-03 05:45:14 +0000
commit282115bcdb3842e507357ec131d1c3685551fb1b (patch)
treecdf9e5068b1b913cf8be1fd8189851c388ecefbe /src
parent95885316c25147ffe85700e4db5477aa8e516005 (diff)
downloadcrosvm-282115bcdb3842e507357ec131d1c3685551fb1b.tar
crosvm-282115bcdb3842e507357ec131d1c3685551fb1b.tar.gz
crosvm-282115bcdb3842e507357ec131d1c3685551fb1b.tar.bz2
crosvm-282115bcdb3842e507357ec131d1c3685551fb1b.tar.lz
crosvm-282115bcdb3842e507357ec131d1c3685551fb1b.tar.xz
crosvm-282115bcdb3842e507357ec131d1c3685551fb1b.tar.zst
crosvm-282115bcdb3842e507357ec131d1c3685551fb1b.zip
crosvm: pstore works for ARCVM on x86_64
Adds support for pstore on ARCVM on x86_64.
The backend file of the buffer will be passed via argument of the crosvm.

BUG=b:144962428
TEST=kernel crash on eve-arcvm, check /sys/fs/pstore/console-ramoops-0
     Launch crostini manually on eve-arcvm

Change-Id: I29492ac7a9067aa2ae23eb03fbb942ab7dd3aa8d
Signed-off-by: Kansho Nishida <kansho@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1973391
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kansho Nishida <kansho@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/crosvm.rs3
-rw-r--r--src/linux.rs1
-rw-r--r--src/main.rs43
3 files changed, 47 insertions, 0 deletions
diff --git a/src/crosvm.rs b/src/crosvm.rs
index ad3d4d1..082e43c 100644
--- a/src/crosvm.rs
+++ b/src/crosvm.rs
@@ -16,6 +16,7 @@ use std::os::unix::io::RawFd;
 use std::path::PathBuf;
 use std::str::FromStr;
 
+use arch::Pstore;
 use devices::virtio::fs::passthrough;
 #[cfg(feature = "gpu")]
 use devices::virtio::gpu::GpuParameters;
@@ -136,6 +137,7 @@ pub struct Config {
     pub plugin_gid_maps: Vec<GidMap>,
     pub disks: Vec<DiskOption>,
     pub pmem_devices: Vec<DiskOption>,
+    pub pstore: Option<Pstore>,
     pub host_ip: Option<net::Ipv4Addr>,
     pub netmask: Option<net::Ipv4Addr>,
     pub mac_address: Option<net_util::MacAddress>,
@@ -184,6 +186,7 @@ impl Default for Config {
             plugin_gid_maps: Vec::new(),
             disks: Vec::new(),
             pmem_devices: Vec::new(),
+            pstore: None,
             host_ip: None,
             netmask: None,
             mac_address: None,
diff --git a/src/linux.rs b/src/linux.rs
index 144345e..a26e7bb 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -1513,6 +1513,7 @@ pub fn run_config(cfg: Config) -> Result<()> {
             .as_ref()
             .map(|x| File::open(x).map_err(|e| Error::OpenAndroidFstab(x.to_path_buf(), e)))
             .map_or(Ok(None), |v| v.map(Some))?,
+        pstore: cfg.pstore.clone(),
         initrd_image,
         extra_kernel_params: cfg.params.clone(),
         wayland_dmabuf: cfg.wayland_dmabuf,
diff --git a/src/main.rs b/src/main.rs
index 45efc0f..e053082 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,6 +16,7 @@ use std::string::String;
 use std::thread::sleep;
 use std::time::Duration;
 
+use arch::Pstore;
 use crosvm::{
     argument::{self, print_help, set_arguments, Argument},
     linux, BindMount, Config, DiskOption, Executable, GidMap, SharedDir, TouchDeviceOption,
@@ -577,6 +578,47 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument::
                 block_size: sys_util::pagesize() as u32,
             });
         }
+        "pstore" => {
+            if cfg.pstore.is_some() {
+                return Err(argument::Error::TooManyArguments(
+                    "`pstore` already given".to_owned(),
+                ));
+            }
+
+            let value = value.unwrap();
+            let components: Vec<&str> = value.split(',').collect();
+            if components.len() != 2 {
+                return Err(argument::Error::InvalidValue {
+                    value: value.to_owned(),
+                    expected: "pstore must have exactly 2 components: path=<path>,size=<size>",
+                });
+            }
+            cfg.pstore = Some(Pstore {
+                path: {
+                    if components[0].len() <= 5 || !components[0].starts_with("path=") {
+                        return Err(argument::Error::InvalidValue {
+                            value: components[0].to_owned(),
+                            expected: "pstore path must follow with `path=`",
+                        });
+                    };
+                    PathBuf::from(&components[0][5..])
+                },
+                size: {
+                    if components[1].len() <= 5 || !components[1].starts_with("size=") {
+                        return Err(argument::Error::InvalidValue {
+                            value: components[1].to_owned(),
+                            expected: "pstore size must follow with `size=`",
+                        });
+                    };
+                    components[1][5..]
+                        .parse()
+                        .map_err(|_| argument::Error::InvalidValue {
+                            value: value.to_owned(),
+                            expected: "pstore size must be an integer",
+                        })?
+                },
+            });
+        }
         "host_ip" => {
             if cfg.host_ip.is_some() {
                 return Err(argument::Error::TooManyArguments(
@@ -1059,6 +1101,7 @@ fn run_vm(args: std::env::Args) -> std::result::Result<(), ()> {
           Argument::value("rwqcow", "PATH", "Path to a writable qcow2 disk image. (Deprecated; use --rwdisk instead.)"),
           Argument::value("rw-pmem-device", "PATH", "Path to a writable disk image."),
           Argument::value("pmem-device", "PATH", "Path to a disk image."),
+          Argument::value("pstore", "path=PATH,size=SIZE", "Path to pstore buffer backend file follewed by size."),
           Argument::value("host_ip",
                           "IP",
                           "IP address to assign to host tap interface."),