Skip to content

Commit 8f6d628

Browse files
store QEMU spec version generated
1 parent 754a62c commit 8f6d628

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

internal/qmp-gen/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ func Generate() error {
4242

4343
// Write out the concatenated spec.
4444
var spec bytes.Buffer
45+
46+
// First add a comment with the best guess of version
47+
spec.WriteString("\n##QEMU SPECIFICATION VERSION: ")
48+
spec.WriteString(tryGetVersionFromSpecPath(*inputSpec))
49+
spec.WriteString("\n\n")
50+
4551
for _, def := range defs {
4652
spec.WriteString(def.Docstring)
4753
spec.WriteByte('\n')

internal/qmp-gen/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,18 @@ func pyToJSON(py []byte) []byte {
585585
return ret
586586
}
587587

588+
func tryGetVersionFromSpecPath(specPath string) string {
589+
retVersion := "UNKNOWN"
590+
verPath, err := resolvePath(specPath, "VERSION")
591+
if err == nil {
592+
verBuf, err := getQAPI(verPath)
593+
if err == nil {
594+
return string(verBuf)
595+
}
596+
}
597+
return retVersion
598+
}
599+
588600
func resolvePath(orig, new string) (string, error) {
589601
u, err := url.Parse(orig)
590602
if err != nil {

qmp/raw/spec.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
##QEMU SPECIFICATION VERSION: 2.10.50
3+
4+
15
# Whitelists to permit QAPI rule violations; think twice before you
26
# add to them!
37
{

0 commit comments

Comments
 (0)