From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-4.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.5 Received: by atuin.qyliss.net (Postfix, from userid 496) id 2662F2209F; Tue, 18 May 2021 08:37:08 +0000 (UTC) Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 7D57922035; Tue, 18 May 2021 08:36:57 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 7E4A721FFD; Tue, 18 May 2021 08:36:54 +0000 (UTC) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by atuin.qyliss.net (Postfix) with ESMTPS id 8ECFE21FFB for ; Tue, 18 May 2021 08:36:50 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 245015C01B1; Tue, 18 May 2021 04:36:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 18 May 2021 04:36:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm3; bh=Zo1lFC0XIe0zTRMoNXuZ/EQHQd YEhKED5/RLpQV/AEY=; b=pO/AUFaFgDWKYXXpfMOosvBM38TwI9F9HjCrALYoXM Dz4Zwx0nehjTFwDm38P/Y1a00Z9xoVrV4cEb5hdtb08YY9DH14LHJdn/nzWOPlYX OEGTdzQiwIdNBW6VI5+fcN9tx3lRRrFOdsOUZ5MhztlqTzaglWZFZ4x28F1NWEak vGw4qFmKvnbm3aGIJByDgmAuId/JAAJFHd+G5k/2/XZEqaZ9WWj/Ey3Y4XoTkDnZ SgfDS4O7hrOXnSGPPlhSVLNUtA4Zc7/GAV9AETfZBREM1IYL351Y2otSjnC/zDvG +jdgamMSiUkxYmpDJEgqUcJXCp+NA07GH/eiMskCGgYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Zo1lFC 0XIe0zTRMoNXuZ/EQHQdYEhKED5/RLpQV/AEY=; b=nLQh0VCo5ib5nou2MaMLF+ 9XC9tMqKxYzp70QIWRYHpcWI4sc2gPK9xVFRDsWp1sLtEOxtKaVRscBuobHfyhwh /1G4ONeG6X3iab1L/pv3REOjtqyqLwFs94Scha4GSb39PkcGvfwzFlOZhpCNy5L2 i8+DNbHvPZPdCXAZBo6/3de81Qo/6dKa/k/nPTDGhfP7pco1Ej4PZ/MrnH2VKzME SPrQ+WQ4ej5Ggmc3Y0xTtRtY+sMUUPc9ihM8TDLlzNKryOJ3zO0d+mjMgF29Y1Un BK2roZOiXtgVyh4u+PQlRuzVkda/CwkVevw+nq+qbkmwD9Vh2fui66zlYhKB1WeA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdeijedgtdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufgjfhffkfggtgesghdtreertddttdenucfhrhhomheptehlhihsshgr ucftohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhephefgle duvdeulefgudduveeihfeluefhheevheegjeejjeffvdfgheehgfetleegnecuffhomhgr ihhnpehunhifrhgrphdrthhopdhprghrshgvrdhmrghppdhgohhoghhlvghsohhurhgtvg drtghomhenucfkphepgeeirdektddrudefkedrjeefnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhephhhisegrlhihshhsrgdrihhs X-ME-Proxy: Received: from x220.qyliss.net (p2e508a49.dip0.t-ipconnect.de [46.80.138.73]) by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 May 2021 04:36:48 -0400 (EDT) Received: by x220.qyliss.net (Postfix, from userid 1000) id C9E0FA8B; Tue, 18 May 2021 08:36:46 +0000 (UTC) From: Alyssa Ross To: Cole Helbling Subject: Re: [PATCH crosvm v2] crosvm: support setting guest MAC from tap-fd In-Reply-To: References: Date: Tue, 18 May 2021 08:36:36 +0000 Message-ID: <87wnrwtp4b.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Message-ID-Hash: 6LVZQZJXVRGL2RJMWIMBEOLC2BMV43XJ X-Message-ID-Hash: 6LVZQZJXVRGL2RJMWIMBEOLC2BMV43XJ X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: devel@spectrum-os.org X-Mailman-Version: 3.3.4 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --=-=-= Content-Type: text/plain "Cole Helbling" writes: >> @@ -1319,17 +1319,52 @@ fn set_argument(cfg: &mut Config, name: &str, value: Option<&str>) -> argument:: >> } >> "vhost-net" => cfg.vhost_net = true, >> "tap-fd" => { >> - cfg.tap_fd.push( >> - value >> - .unwrap() >> - .parse() >> - .map_err(|_| argument::Error::InvalidValue { >> - value: value.unwrap().to_owned(), >> - expected: String::from( >> - "this value for `tap-fd` must be an unsigned integer", >> - ), >> - })?, >> - ); >> + let mut components = value.unwrap().split(','); >> + >> + let fd: RawDescriptor = components >> + .next() >> + .and_then(|x| x.parse().ok()) >> + .ok_or_else(|| argument::Error::InvalidValue { >> + value: value.unwrap().to_owned(), >> + expected: String::from("this value for `tap-fd` must be an unsigned integer"), >> + })?; >> + >> + let mut mac = None; >> + for c in components { >> + let mut kv = c.splitn(2, '='); >> + let (kind, value) = match (kv.next(), kv.next()) { >> + (Some(kind), Some(value)) => (kind, value), >> + _ => { >> + return Err(argument::Error::InvalidValue { >> + value: c.to_owned(), >> + expected: String::from("option must be of the form `kind=value`"), >> + }) >> + } >> + }; >> + match kind { >> + "mac" => { >> + mac = Some(value.parse().map_err(|_| argument::Error::InvalidValue { >> + value: value.to_owned(), >> + expected: String::from( >> + "`mac` needs to be in the form \"XX:XX:XX:XX:XX:XX\"", >> + ), >> + })?) >> + } >> + _ => { >> + return Err(argument::Error::InvalidValue { >> + value: kind.to_owned(), >> + expected: String::from("unrecognized option"), >> + }) >> + } >> + } >> + } >> + if cfg.tap_fd.contains_key(&fd) { >> + return Err(argument::Error::TooManyArguments(format!( > > Is there a better Error variant for this? `TooManyArguments` seems not- > completely-accurate when specifying an already-in-use FD. Here are all the variants. Do you think there's a better one? https://chromium.googlesource.com/chromiumos/platform/crosvm/+/f35d2c43ff19520855cffee761dc8899c5a439a1/src/argument.rs#49 The only other one I can see that might be applicable would be InvalidValue... --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEH9wgcxqlHM/ARR3h+dvtSFmyccAFAmCjfJUACgkQ+dvtSFmy ccAlZA/9F97b+gwU/Mr9rUtmT/IyjoWC3f/+yJM5R3YnV7J+k/5FHvijWvzSSBpp PcOrU3xGCcOlexwJa2PtjBmC7lpiCPS52pzNeRDdqdH43CfJ1ZLNm1tHcQmIA0r+ 29Wo/YN9iFdpMSk8MpL7l9VJErqdZn1CKhFsMD+ZkFEn3X44hHa71CJqIZhpMjSn pm7GbQcolcv5K43qnYP53US6RXkZhSF2AjYbg+jBouEaucrvmc2M3KjWXRkGto3w gbUPtx0W1YhMkXvACvrOxkpB2B08CQ/G2l0eNgwDhpicNP7niebNxsR3ivvMyiaH nggBdJ6CVlaXaGIEERoBPYgx1hgPlwH8R4nOgVwGuRcjfmy+un9njzVxxL40kWwS f6jftU5CPKqPPEbj1+8W31KzNV0FBpoD9IcWagcV4MQ0zQR1j2lIAc+1W01Kwe/j xeu4x2WEZUdlm0gu9nwTdvU1KwaVm9HmNazCl55xUmuBihrmWcfu/FHVm1NwxTUR G6puWX0YYjaosB5qemrjxOhYC10Sniwu0Im1r6I9ANMPZyB4RJAyHPEYBQw1GCwx P9rvRaT8V8lDaTOT4EPHwbN3ZlQlP+cjnEEcfnArzuYN6+iliothv1k8klZkJOWv 1yUyMxbmM+TyTYtXNXm4d3vr3U8HlC7tt5dSfNZK1GO5lMGPwtg= =2vLF -----END PGP SIGNATURE----- --=-=-=--