diff options
Diffstat (limited to 'src/linux.rs')
-rw-r--r-- | src/linux.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/linux.rs b/src/linux.rs index 40f32a1..44c2aef 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -28,12 +28,13 @@ use byteorder::{ByteOrder, LittleEndian}; use devices::{self, PciDevice, VirtioPciDevice}; use io_jail::{self, Minijail}; use kvm::*; +use msg_socket::{MsgReceiver, MsgSender, UnlinkMsgSocket}; use net_util::Tap; use qcow::{self, ImageType, QcowFile}; use sys_util; use sys_util::*; use vhost; -use vm_control::VmRequest; +use vm_control::{VmRequest, VmResponse}; use Config; @@ -788,11 +789,15 @@ pub fn run_config(cfg: Config) -> Result<()> { if let Some(ref path_string) = cfg.socket_path { let path = Path::new(path_string); let dgram = UnixDatagram::bind(path).map_err(Error::CreateSocket)?; - control_sockets.push(UnlinkUnixDatagram(dgram)); + control_sockets.push(UnlinkMsgSocket::<VmResponse, VmRequest>::new( + UnlinkUnixDatagram(dgram), + )); }; let (wayland_host_socket, wayland_device_socket) = UnixDatagram::pair().map_err(Error::CreateSocket)?; - control_sockets.push(UnlinkUnixDatagram(wayland_host_socket)); + control_sockets.push(UnlinkMsgSocket::<VmResponse, VmRequest>::new( + UnlinkUnixDatagram(wayland_host_socket), + )); // Balloon gets a special socket so balloon requests can be forwarded from the main process. let (balloon_host_socket, balloon_device_socket) = UnixDatagram::pair().map_err(Error::CreateSocket)?; @@ -805,7 +810,7 @@ pub fn run_config(cfg: Config) -> Result<()> { fn run_control( mut linux: RunnableLinuxVm, - control_sockets: Vec<UnlinkUnixDatagram>, + control_sockets: Vec<UnlinkMsgSocket<VmResponse, VmRequest>>, balloon_host_socket: UnixDatagram, sigchld_fd: SignalFd, ) -> Result<()> { @@ -1045,7 +1050,7 @@ fn run_control( } Token::VmControl { index } => { if let Some(socket) = control_sockets.get(index as usize) { - match VmRequest::recv(socket.as_ref()) { + match socket.recv() { Ok(request) => { let mut running = true; let response = request.execute( @@ -1054,7 +1059,7 @@ fn run_control( &mut running, &balloon_host_socket, ); - if let Err(e) = response.send(socket.as_ref()) { + if let Err(e) = socket.send(&response) { error!("failed to send VmResponse: {:?}", e); } if !running { |