Repository navigation
specs-go: fix JSON tag for VM hwConfig - #1331
Merged
tianon merged 1 commit intoNov 7, 2026
Merged
Conversation
RaphaelFakhri
requested review from
AkihiroSuda,
crosbymichael,
cyphar,
dqminh,
giuseppe,
hqhq,
kolyshkin,
mrunalp,
thaJeztah,
tianon and
utam0k
as code owners
November 5, 2026 06:51
AkihiroSuda
reviewed
Nov 5, 2026
Member
There was a problem hiding this comment.
The test doesn't seem useful.
We do not have tests for other JSON tags.
The spec (config-vm.md) and the JSON schema (schema/config-vm.json) name the VM hardware configuration property "hwConfig", but the Go struct tag used "hwconfig". Marshaling a VM config with the Go types therefore produced a key that does not match the spec, and is ignored by case-sensitive parsers. Decoding with encoding/json is case-insensitive, so existing documents using "hwconfig" still decode. Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
RaphaelFakhri
force-pushed
the
fix-vm-hwconfig-json-tag
branch
from
November 6, 2026 20:15
54cb697 to
9d63379
Compare
AkihiroSuda
approved these changes
Nov 7, 2026
tianon
approved these changes
Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The spec (config-vm.md) and the JSON schema (
schema/config-vm.json) name the VM hardware configuration propertyhwConfig. The Go struct tag onVM.HwConfigishwconfig, so marshaling a config with the Go types produces a key that does not match the spec or the schema. Case-sensitive consumers ignore it.Before:
{"hypervisor":{"path":""},"kernel":{"path":""},"image":{"path":"","format":""},"hwconfig":{"deviceTree":"/path/to/dt.dtb"}}After, the key is
hwConfig.Changes
specs-go/config.go: change the tag tojson:"hwConfig,omitempty".encoding/jsonmatches keys case-insensitively when decoding, so Go users that read existing documents withhwconfigare not affected.