crosvm: add cmdline flags for configuring serial outputs in guest machine

This change allows an output to be set for each serial device for a
guest machine (stdout, syslog, or sink).

BUG=chromium:953983
TEST=FEATURES=test emerge-sarien crosvm; cd sys_util; cargo test;
./build_test; manual testing on x86_64 and aarch_64

Change-Id: I9e7fcb0b296c0f8a5aa8d54b1a74ae801f6badc8
Reviewed-on: https://chromium-review.googlesource.com/1572813
Commit-Ready: Trent Begin <tbegin@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Trent Begin <tbegin@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
diff --git a/src/linux.rs b/src/linux.rs
index 803a82e..979666e 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -789,7 +789,7 @@
 }
 
 fn create_devices(
-    cfg: Config,
+    cfg: &Config,
     mem: &GuestMemory,
     exit_evt: &EventFd,
     wayland_device_socket: WlControlRequestSocket,
@@ -1180,17 +1180,22 @@
     }
 
     let sandbox = cfg.sandbox;
-    let linux = Arch::build_vm(components, cfg.split_irqchip, |m, e| {
-        create_devices(
-            cfg,
-            m,
-            e,
-            wayland_device_socket,
-            balloon_device_socket,
-            &mut disk_device_sockets,
-            usb_provider,
-        )
-    })
+    let linux = Arch::build_vm(
+        components,
+        cfg.split_irqchip,
+        &cfg.serial_parameters,
+        |m, e| {
+            create_devices(
+                &cfg,
+                m,
+                e,
+                wayland_device_socket,
+                balloon_device_socket,
+                &mut disk_device_sockets,
+                usb_provider,
+            )
+        },
+    )
     .map_err(Error::BuildVm)?;
 
     let _render_node_host = ();
@@ -1401,13 +1406,15 @@
                             warn!("error while reading stdin: {}", e);
                             let _ = poll_ctx.delete(&stdin_handle);
                         }
-                        Ok(count) => {
-                            linux
-                                .stdio_serial
-                                .lock()
-                                .queue_input_bytes(&out[..count])
-                                .expect("failed to queue bytes into serial port");
-                        }
+                        Ok(count) => match linux.stdio_serial {
+                            Some(ref stdio_serial) => {
+                                stdio_serial
+                                    .lock()
+                                    .queue_input_bytes(&out[..count])
+                                    .expect("failed to queue bytes into serial port");
+                            }
+                            None => {}
+                        },
                     }
                 }
                 Token::ChildSignal => {