summary refs log tree commit diff
path: root/src/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugin')
-rw-r--r--src/plugin/mod.rs4
-rw-r--r--src/plugin/process.rs30
2 files changed, 29 insertions, 5 deletions
diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs
index 44cba39..4d164a4 100644
--- a/src/plugin/mod.rs
+++ b/src/plugin/mod.rs
@@ -405,7 +405,7 @@ pub fn run_config(cfg: Config) -> Result<()> {
     let kvm = Kvm::new().map_err(Error::CreateKvm)?;
     let mut vm = Vm::new(&kvm, mem).map_err(Error::CreateVm)?;
     vm.create_irq_chip().map_err(Error::CreateIrqChip)?;
-    let mut plugin = Process::new(vcpu_count, &mut vm, plugin_path, &plugin_args, jail)?;
+    let mut plugin = Process::new(vcpu_count, &kvm, &mut vm, plugin_path, &plugin_args, jail)?;
 
     let mut res = Ok(());
     // If Some, we will exit after enough time is passed to shutdown cleanly.
@@ -530,7 +530,7 @@ pub fn run_config(cfg: Config) -> Result<()> {
                 }
                 t if t >= PLUGIN_BASE && t < PLUGIN_BASE + (plugin.sockets().len() as u32) => {
                     let socket_index = (t - PLUGIN_BASE) as usize;
-                    match plugin.handle_socket(socket_index, &mut vm, &vcpu_handles) {
+                    match plugin.handle_socket(socket_index, &kvm, &mut vm, &vcpu_handles) {
                         Ok(_) => {}
                         // A HUP is an expected event for a socket, so don't bother warning about
                         // it.
diff --git a/src/plugin/process.rs b/src/plugin/process.rs
index aa4a907..89c201c 100644
--- a/src/plugin/process.rs
+++ b/src/plugin/process.rs
@@ -73,6 +73,7 @@ impl Process {
     /// Due to an API limitation in libminijail necessitating that this function set an environment
     /// variable, this function is not thread-safe.
     pub fn new(cpu_count: u32,
+               kvm: &Kvm,
                vm: &mut Vm,
                cmd: &Path,
                args: &[&str],
@@ -125,13 +126,13 @@ impl Process {
             response_buffer: Vec::new(),
         };
 
-        plugin.run_until_started(vm)?;
+        plugin.run_until_started(kvm, vm)?;
 
         Ok(plugin)
     }
 
 
-    fn run_until_started(&mut self, vm: &mut Vm) -> Result<()> {
+    fn run_until_started(&mut self, kvm: &Kvm, vm: &mut Vm) -> Result<()> {
         let mut sockets_to_drop = Vec::new();
         let mut poller = Poller::new(1);
         while !self.started {
@@ -150,7 +151,7 @@ impl Process {
             };
 
             for &token in tokens {
-                match self.handle_socket(token as usize, vm, &[]) {
+                match self.handle_socket(token as usize, kvm, vm, &[]) {
                     Ok(_) => {}
                     Err(Error::PluginSocketHup) => sockets_to_drop.push(token as usize),
                     r => return r,
@@ -388,6 +389,7 @@ impl Process {
     /// interrupt a VCPU thread currently running in the VM if the socket request it.
     pub fn handle_socket(&mut self,
                          index: usize,
+                         kvm: &Kvm,
                          vm: &mut Vm,
                          vcpu_handles: &[JoinHandle<()>])
                          -> Result<()> {
@@ -533,6 +535,28 @@ impl Process {
                 }
                 _ => Err(SysError::new(-ENOENT)),
             }
+        } else if request.has_get_supported_cpuid() {
+            let cpuid_response = &mut response.mut_get_supported_cpuid().entries;
+            match kvm.get_supported_cpuid() {
+                Ok(mut cpuid) => {
+                    for entry in cpuid.mut_entries_slice() {
+                        cpuid_response.push(cpuid_kvm_to_proto(entry));
+                    }
+                    Ok(())
+                }
+                Err(e) => Err(e)
+            }
+        } else if request.has_get_emulated_cpuid() {
+            let cpuid_response = &mut response.mut_get_emulated_cpuid().entries;
+            match kvm.get_emulated_cpuid() {
+                Ok(mut cpuid) => {
+                    for entry in cpuid.mut_entries_slice() {
+                        cpuid_response.push(cpuid_kvm_to_proto(entry));
+                    }
+                    Ok(())
+                }
+                Err(e) => Err(e)
+            }
         } else {
             Err(SysError::new(-ENOTTY))
         };