crosvm: Suppress useless error messages when creating serial device

When creating a serial device of type UnixSocket crosvm will race with
vmlog_forwarder to bind a socket to the address. This is expected to
fail in most cases, so don't log an error message if it does unless
the reason was unexpected.

BUG=none
TEST=Booted termina and checked for logs about failing to bind sockets

Disallow-Recycled-Builds: test-failures
Change-Id: I446dd803662de57221b501a6f87957035c4593de
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2494321
Tested-by: Fergus Dall <sidereal@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Fergus Dall <sidereal@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
diff --git a/arch/src/serial.rs b/arch/src/serial.rs
index b59ac12..3ebb84b 100644
--- a/arch/src/serial.rs
+++ b/arch/src/serial.rs
@@ -275,11 +275,20 @@
             },
             SerialType::UnixSocket => match &self.path {
                 Some(path) => {
-                    let sock = match UnixDatagram::bind(path).map_err(Error::FileError) {
+                    let sock = match UnixDatagram::bind(path) {
                         Ok(sock) => sock,
                         Err(e) => {
-                            error!("Couldn't bind: {:?}", e);
-                            UnixDatagram::unbound().map_err(Error::FileError)?
+                            if e.kind() == ErrorKind::AddrInUse {
+                                // In most cases vmlog_forwarder will
+                                // have already bound this address and
+                                // this error is expected. This
+                                // unbound socket will be connected on
+                                // first write.
+                                UnixDatagram::unbound().map_err(Error::FileError)?
+                            } else {
+                                error!("Couldn't bind: {:?}", e);
+                                return Err(Error::FileError(e));
+                            }
                         }
                     };
                     keep_fds.push(sock.as_raw_fd());