diff --git a/devices/src/virtio/net.rs b/devices/src/virtio/net.rs index 502d354367..fbe84e54bb 100644 --- a/devices/src/virtio/net.rs +++ b/devices/src/virtio/net.rs @@ -142,12 +142,11 @@ pub enum NetError { #[derive(Serialize, Deserialize, PartialEq, Debug)] #[serde(untagged, deny_unknown_fields)] pub enum NetParametersMode { - TapName { - tap_name: String, - }, - TapFd { - tap_fd: i32, - }, + #[serde(rename_all = "kebab-case")] + TapName { tap_name: String }, + #[serde(rename_all = "kebab-case")] + TapFd { tap_fd: i32 }, + #[serde(rename_all = "kebab-case")] RawConfig { #[serde(default)] vhost_net: bool, @@ -837,7 +836,7 @@ mod tests { let params = from_net_arg(""); assert!(params.is_err()); - let params = from_net_arg("tap_name=tap").unwrap(); + let params = from_net_arg("tap-name=tap").unwrap(); assert_eq!( params, NetParameters { @@ -847,7 +846,7 @@ mod tests { } ); - let params = from_net_arg("tap_fd=12").unwrap(); + let params = from_net_arg("tap-fd=12").unwrap(); assert_eq!( params, NetParameters { @@ -856,7 +855,7 @@ mod tests { ); let params = from_net_arg( - "host_ip=\"192.168.10.1\",netmask=\"255.255.255.0\",mac=\"3d:70:eb:61:1a:91\"", + "host-ip=\"192.168.10.1\",netmask=\"255.255.255.0\",mac=\"3d:70:eb:61:1a:91\"", ) .unwrap(); assert_eq!( @@ -872,8 +871,8 @@ mod tests { ); let params = from_net_arg( - "vhost_net=true,\ - host_ip=\"192.168.10.1\",\ + "vhost-net=true,\ + host-ip=\"192.168.10.1\",\ netmask=\"255.255.255.0\",\ mac=\"3d:70:eb:61:1a:91\"", ) @@ -892,18 +891,18 @@ mod tests { // mixed configs assert!(from_net_arg( - "tap_name=tap,\ - vhost_net=true,\ - host_ip=\"192.168.10.1\",\ + "tap-name=tap,\ + vhost-net=true,\ + host-ip=\"192.168.10.1\",\ netmask=\"255.255.255.0\",\ mac=\"3d:70:eb:61:1a:91\"", ) .is_err()); // missing netmask - assert!(from_net_arg("host_ip=\"192.168.10.1\",mac=\"3d:70:eb:61:1a:91\"").is_err()); + assert!(from_net_arg("host-ip=\"192.168.10.1\",mac=\"3d:70:eb:61:1a:91\"").is_err()); // invalid parameter - assert!(from_net_arg("tap_name=tap,foomatic=true").is_err()); + assert!(from_net_arg("tap-name=tap,foomatic=true").is_err()); } } diff --git a/src/crosvm/cmdline.rs b/src/crosvm/cmdline.rs index c3719a38f5..c237a96e3b 100644 --- a/src/crosvm/cmdline.rs +++ b/src/crosvm/cmdline.rs @@ -1017,10 +1017,10 @@ pub struct RunCommand { /// comma separated key=value pairs for setting /// up a vhost-user net device /// Possible key values: - /// tap_name=STRING - name of a configured persistent TAP + /// tap-name=STRING - name of a configured persistent TAP /// interface to use for networking. - /// tap_fd=INT - File descriptor for configured tap device. - /// host_ip=STRING - IP address to assign to + /// tap-fd=INT - File descriptor for configured tap device. + /// host-ip=STRING - IP address to assign to /// host tap interface. /// netmask=STRING - Netmask for VM subnet. /// mac=STRING - MAC address for VM.