Add socket_type to AC97Parameters

to allow testing ac97 with raw crosvm

BUG=b:195267672
TEST=Unit test, CQ

Change-Id: I49e2eefba76a5c3e9e1c6c213a00904162bcee08
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3146700
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
diff --git a/src/main.rs b/src/main.rs
index 3ecb80d..5c71afc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -546,6 +546,15 @@
                         expected: e.to_string(),
                     })?;
             }
+            #[cfg(feature = "audio_cras")]
+            "socket_type" => {
+                ac97_params
+                    .set_socket_type(v)
+                    .map_err(|e| argument::Error::InvalidValue {
+                        value: v.to_string(),
+                        expected: e.to_string(),
+                    })?;
+            }
             #[cfg(any(target_os = "linux", target_os = "android"))]
             "server" => {
                 ac97_params.vios_server_path =
@@ -2095,6 +2104,7 @@
                               capture - Enable audio capture
                               capture_effects - | separated effects to be enabled for recording. The only supported effect value now is EchoCancellation or aec.
                               client_type - Set specific client type for cras backend.
+                              socket_type - Set specific socket type for cras backend.
                               server - The to the VIOS server (unix socket)."),
           #[cfg(feature = "audio")]
           Argument::value("sound", "[PATH]", "Path to the VioS server socket for setting up virtio-snd devices."),
@@ -2955,6 +2965,13 @@
             .expect_err("parse should have failed");
     }
 
+    #[cfg(feature = "audio_cras")]
+    #[test]
+    fn parse_ac97_socket_type() {
+        parse_ac97_options("socket_type=unified").expect("parse should have succeded");
+        parse_ac97_options("socket_type=legacy").expect("parse should have succeded");
+    }
+
     #[cfg(feature = "audio")]
     #[test]
     fn parse_ac97_vios_valid() {