Skip to content

Commit b6cc630

Browse files
committed
Be more lenient about isolated docstrings in the QMP spec.
Recent revisions of the spec have added more general documentation (good!), but those are tripping up the code generator as potential rogue datatype docstrings (bad!). In practice, we still have a safety in place for that, because we refuse to codegen a type definition that doesn't have a docstring. So, we can safely ignore orphan docstrings, as long as we don't ignore orphan definitions.
1 parent 6baa1ba commit b6cc630

File tree

3 files changed

+2754
-534
lines changed

3 files changed

+2754
-534
lines changed

internal/qmp-gen/types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ func readDefinitions(path string) ([]definition, error) {
5959
case 1:
6060
if len(fs) == 1 && part[0] == '{' {
6161
return nil, fmt.Errorf("found type definition without a docstring in %q: %s", path, string(part))
62-
} else if bytes.Contains(part, []byte("##")) {
63-
return nil, fmt.Errorf("part is missing type definition in %q, but looks like a docstring: %s", path, string(part))
6462
}
6563
// This part looks like a non-docstring comment, just skip it.
6664
case 2:

qmp/raw/autogen.go

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ type BlockdevOptionsGluster struct {
17611761
Volume string `json:"volume"`
17621762
Path string `json:"path"`
17631763
Server []GlusterServer `json:"server"`
1764-
DebugLevel *int64 `json:"debug-level,omitempty"`
1764+
Debug *int64 `json:"debug,omitempty"`
17651765
Logfile *string `json:"logfile,omitempty"`
17661766
}
17671767

@@ -1941,7 +1941,7 @@ type BlockdevOptionsNfs struct {
19411941
TCPSynCount *int64 `json:"tcp-syn-count,omitempty"`
19421942
ReadaheadSize *int64 `json:"readahead-size,omitempty"`
19431943
PageCacheSize *int64 `json:"page-cache-size,omitempty"`
1944-
DebugLevel *int64 `json:"debug-level,omitempty"`
1944+
Debug *int64 `json:"debug,omitempty"`
19451945
}
19461946

19471947
func (BlockdevOptionsNfs) isBlockdevOptions() {}
@@ -3355,6 +3355,7 @@ type CPUDefinitionInfo struct {
33553355
MigrationSafe *bool `json:"migration-safe,omitempty"`
33563356
Static bool `json:"static"`
33573357
UnavailableFeatures []string `json:"unavailable-features,omitempty"`
3358+
Typename string `json:"typename"`
33583359
}
33593360

33603361
// CpuInfo -> CPUInfo (flat union)
@@ -4149,11 +4150,12 @@ type GlusterServer interface {
41494150

41504151
// GlusterServerTCP is an implementation of GlusterServer.
41514152
type GlusterServerTCP struct {
4152-
Host string `json:"host"`
4153-
Port string `json:"port"`
4154-
To *uint16 `json:"to,omitempty"`
4155-
Ipv4 *bool `json:"ipv4,omitempty"`
4156-
Ipv6 *bool `json:"ipv6,omitempty"`
4153+
Host string `json:"host"`
4154+
Port string `json:"port"`
4155+
Numeric *bool `json:"numeric,omitempty"`
4156+
To *uint16 `json:"to,omitempty"`
4157+
Ipv4 *bool `json:"ipv4,omitempty"`
4158+
Ipv6 *bool `json:"ipv6,omitempty"`
41574159
}
41584160

41594161
func (GlusterServerTCP) isGlusterServer() {}
@@ -4572,11 +4574,12 @@ type ImageInfoSpecificVMDK struct {
45724574

45734575
// InetSocketAddress implements the "InetSocketAddress" QMP API type.
45744576
type InetSocketAddress struct {
4575-
Host string `json:"host"`
4576-
Port string `json:"port"`
4577-
To *uint16 `json:"to,omitempty"`
4578-
Ipv4 *bool `json:"ipv4,omitempty"`
4579-
Ipv6 *bool `json:"ipv6,omitempty"`
4577+
Host string `json:"host"`
4578+
Port string `json:"port"`
4579+
Numeric *bool `json:"numeric,omitempty"`
4580+
To *uint16 `json:"to,omitempty"`
4581+
Ipv4 *bool `json:"ipv4,omitempty"`
4582+
Ipv6 *bool `json:"ipv6,omitempty"`
45804583
}
45814584

45824585
// InputAxis -> InputAxis (enum)
@@ -5094,6 +5097,7 @@ type MachineInfo struct {
50945097

50955098
// Memdev implements the "Memdev" QMP API type.
50965099
type Memdev struct {
5100+
ID *string `json:"id,omitempty"`
50975101
Size uint64 `json:"size"`
50985102
Merge bool `json:"merge"`
50995103
Dump bool `json:"dump"`
@@ -5807,6 +5811,7 @@ const (
58075811
QCryptoCipherAlgorithmAes192
58085812
QCryptoCipherAlgorithmAes256
58095813
QCryptoCipherAlgorithmDesRfb
5814+
QCryptoCipherAlgorithm3Des
58105815
QCryptoCipherAlgorithmCast5128
58115816
QCryptoCipherAlgorithmSerpent128
58125817
QCryptoCipherAlgorithmSerpent192
@@ -5827,6 +5832,8 @@ func (e QCryptoCipherAlgorithm) String() string {
58275832
return "aes-256"
58285833
case QCryptoCipherAlgorithmDesRfb:
58295834
return "des-rfb"
5835+
case QCryptoCipherAlgorithm3Des:
5836+
return "3des"
58305837
case QCryptoCipherAlgorithmCast5128:
58315838
return "cast5-128"
58325839
case QCryptoCipherAlgorithmSerpent128:
@@ -5857,6 +5864,8 @@ func (e QCryptoCipherAlgorithm) MarshalJSON() ([]byte, error) {
58575864
return json.Marshal("aes-256")
58585865
case QCryptoCipherAlgorithmDesRfb:
58595866
return json.Marshal("des-rfb")
5867+
case QCryptoCipherAlgorithm3Des:
5868+
return json.Marshal("3des")
58605869
case QCryptoCipherAlgorithmCast5128:
58615870
return json.Marshal("cast5-128")
58625871
case QCryptoCipherAlgorithmSerpent128:
@@ -5891,6 +5900,8 @@ func (e *QCryptoCipherAlgorithm) UnmarshalJSON(bs []byte) error {
58915900
*e = QCryptoCipherAlgorithmAes256
58925901
case "des-rfb":
58935902
*e = QCryptoCipherAlgorithmDesRfb
5903+
case "3des":
5904+
*e = QCryptoCipherAlgorithm3Des
58945905
case "cast5-128":
58955906
*e = QCryptoCipherAlgorithmCast5128
58965907
case "serpent-128":
@@ -6254,6 +6265,9 @@ const (
62546265
QKeyCodeCompose
62556266
QKeyCodePause
62566267
QKeyCodeRo
6268+
QKeyCodeHiragana
6269+
QKeyCodeHenkan
6270+
QKeyCodeYen
62576271
QKeyCodeKpComma
62586272
QKeyCodeKpEquals
62596273
QKeyCodePower
@@ -6510,6 +6524,12 @@ func (e QKeyCode) String() string {
65106524
return "pause"
65116525
case QKeyCodeRo:
65126526
return "ro"
6527+
case QKeyCodeHiragana:
6528+
return "hiragana"
6529+
case QKeyCodeHenkan:
6530+
return "henkan"
6531+
case QKeyCodeYen:
6532+
return "yen"
65136533
case QKeyCodeKpComma:
65146534
return "kp_comma"
65156535
case QKeyCodeKpEquals:
@@ -6772,6 +6792,12 @@ func (e QKeyCode) MarshalJSON() ([]byte, error) {
67726792
return json.Marshal("pause")
67736793
case QKeyCodeRo:
67746794
return json.Marshal("ro")
6795+
case QKeyCodeHiragana:
6796+
return json.Marshal("hiragana")
6797+
case QKeyCodeHenkan:
6798+
return json.Marshal("henkan")
6799+
case QKeyCodeYen:
6800+
return json.Marshal("yen")
67756801
case QKeyCodeKpComma:
67766802
return json.Marshal("kp_comma")
67776803
case QKeyCodeKpEquals:
@@ -7038,6 +7064,12 @@ func (e *QKeyCode) UnmarshalJSON(bs []byte) error {
70387064
*e = QKeyCodePause
70397065
case "ro":
70407066
*e = QKeyCodeRo
7067+
case "hiragana":
7068+
*e = QKeyCodeHiragana
7069+
case "henkan":
7070+
*e = QKeyCodeHenkan
7071+
case "yen":
7072+
*e = QKeyCodeYen
70417073
case "kp_comma":
70427074
*e = QKeyCodeKpComma
70437075
case "kp_equals":
@@ -10201,12 +10233,14 @@ func (m *Monitor) DeviceListProperties(typename string) (ret []DevicePropertyInf
1020110233
// device_add -> DeviceAdd (command)
1020210234

1020310235
// DeviceAdd implements the "device_add" QMP API call.
10204-
func (m *Monitor) DeviceAdd(driver string, id string) (err error) {
10236+
func (m *Monitor) DeviceAdd(driver string, bus *string, id *string) (err error) {
1020510237
cmd := struct {
10206-
Driver string `json:"driver"`
10207-
ID string `json:"id"`
10238+
Driver string `json:"driver"`
10239+
Bus *string `json:"bus,omitempty"`
10240+
ID *string `json:"id,omitempty"`
1020810241
}{
1020910242
driver,
10243+
bus,
1021010244
id,
1021110245
}
1021210246
bs, err := json.Marshal(map[string]interface{}{

0 commit comments

Comments
 (0)