1 package qapi
2
3 import (
4 "encoding/json"
5 "errors"
6 "fmt"
7 "strings"
8 )
9
10
11
12
13
14
15
16
17 type SocketAddressLegacyBase struct {
18 Type SocketAddressType `json:"type"`
19 }
20
21
22
23
24
25
26
27
28 type SocketAddressLegacy struct {
29
30 SocketAddressLegacyBase
31
32
33
34
35
36 Value Any
37 }
38
39 func (s SocketAddressLegacy) MarshalJSON() ([]byte, error) {
40 base, err := json.Marshal(s.SocketAddressLegacyBase)
41 if err != nil {
42 return nil, err
43 }
44
45 typestr := fmt.Sprintf("%T", s.Value)
46 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
47
48
49
50 if typestr == "<nil>" {
51 return []byte(base), nil
52 }
53
54
55 if typestr != "StringWrapper" &&
56 typestr != "InetSocketAddressWrapper" &&
57 typestr != "UnixSocketAddressWrapper" &&
58 typestr != "VsockSocketAddressWrapper" {
59 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
60 }
61 value, err := json.Marshal(s.Value)
62 if err != nil {
63 return nil, err
64 }
65
66
67 if string(value) == "{}" {
68 return []byte(base), nil
69 }
70
71
72
73 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
74 return []byte(result), nil
75 }
76
77 func (s *SocketAddressLegacy) UnmarshalJSON(data []byte) error {
78
79 var base SocketAddressLegacyBase
80 if err := json.Unmarshal(data, &base); err != nil {
81 return err
82 }
83 s.SocketAddressLegacyBase = base
84
85 switch base.Type {
86 case SocketAddressTypeFd:
87 value := StringWrapper{}
88 if err := json.Unmarshal(data, &value); err != nil {
89 return err
90 }
91 s.Value = value
92 case SocketAddressTypeInet:
93 value := InetSocketAddressWrapper{}
94 if err := json.Unmarshal(data, &value); err != nil {
95 return err
96 }
97 s.Value = value
98 case SocketAddressTypeUnix:
99 value := UnixSocketAddressWrapper{}
100 if err := json.Unmarshal(data, &value); err != nil {
101 return err
102 }
103 s.Value = value
104 case SocketAddressTypeVsock:
105 value := VsockSocketAddressWrapper{}
106 if err := json.Unmarshal(data, &value); err != nil {
107 return err
108 }
109 s.Value = value
110
111 default:
112 fmt.Println("Failed to decode SocketAddressLegacy", base.Type)
113 }
114
115 return nil
116 }
117
118
119
120
121
122 type SocketAddressBase struct {
123 Type SocketAddressType `json:"type"`
124 }
125
126
127
128
129
130 type SocketAddress struct {
131
132 SocketAddressBase
133
134
135
136
137
138 Value Any
139 }
140
141 func (s SocketAddress) MarshalJSON() ([]byte, error) {
142 base, err := json.Marshal(s.SocketAddressBase)
143 if err != nil {
144 return nil, err
145 }
146
147 typestr := fmt.Sprintf("%T", s.Value)
148 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
149
150
151
152 if typestr == "<nil>" {
153 return []byte(base), nil
154 }
155
156
157 if typestr != "String" &&
158 typestr != "InetSocketAddress" &&
159 typestr != "UnixSocketAddress" &&
160 typestr != "VsockSocketAddress" {
161 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
162 }
163 value, err := json.Marshal(s.Value)
164 if err != nil {
165 return nil, err
166 }
167
168
169 if string(value) == "{}" {
170 return []byte(base), nil
171 }
172
173
174
175 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
176 return []byte(result), nil
177 }
178
179 func (s *SocketAddress) UnmarshalJSON(data []byte) error {
180
181 var base SocketAddressBase
182 if err := json.Unmarshal(data, &base); err != nil {
183 return err
184 }
185 s.SocketAddressBase = base
186
187 switch base.Type {
188 case SocketAddressTypeFd:
189 value := String{}
190 if err := json.Unmarshal(data, &value); err != nil {
191 return err
192 }
193 s.Value = value
194 case SocketAddressTypeInet:
195 value := InetSocketAddress{}
196 if err := json.Unmarshal(data, &value); err != nil {
197 return err
198 }
199 s.Value = value
200 case SocketAddressTypeUnix:
201 value := UnixSocketAddress{}
202 if err := json.Unmarshal(data, &value); err != nil {
203 return err
204 }
205 s.Value = value
206 case SocketAddressTypeVsock:
207 value := VsockSocketAddress{}
208 if err := json.Unmarshal(data, &value); err != nil {
209 return err
210 }
211 s.Value = value
212
213 default:
214 fmt.Println("Failed to decode SocketAddress", base.Type)
215 }
216
217 return nil
218 }
219
220
221
222
223 type GuestPanicInformationBase struct {
224 Type GuestPanicInformationType `json:"type"`
225 }
226
227
228
229
230 type GuestPanicInformation struct {
231
232 GuestPanicInformationBase
233
234
235
236 Value Any
237 }
238
239 func (s GuestPanicInformation) MarshalJSON() ([]byte, error) {
240 base, err := json.Marshal(s.GuestPanicInformationBase)
241 if err != nil {
242 return nil, err
243 }
244
245 typestr := fmt.Sprintf("%T", s.Value)
246 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
247
248
249
250 if typestr == "<nil>" {
251 return []byte(base), nil
252 }
253
254
255 if typestr != "GuestPanicInformationHyperV" &&
256 typestr != "GuestPanicInformationS390" {
257 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
258 }
259 value, err := json.Marshal(s.Value)
260 if err != nil {
261 return nil, err
262 }
263
264
265 if string(value) == "{}" {
266 return []byte(base), nil
267 }
268
269
270
271 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
272 return []byte(result), nil
273 }
274
275 func (s *GuestPanicInformation) UnmarshalJSON(data []byte) error {
276
277 var base GuestPanicInformationBase
278 if err := json.Unmarshal(data, &base); err != nil {
279 return err
280 }
281 s.GuestPanicInformationBase = base
282
283 switch base.Type {
284 case GuestPanicInformationTypeHyperV:
285 value := GuestPanicInformationHyperV{}
286 if err := json.Unmarshal(data, &value); err != nil {
287 return err
288 }
289 s.Value = value
290 case GuestPanicInformationTypeS390:
291 value := GuestPanicInformationS390{}
292 if err := json.Unmarshal(data, &value); err != nil {
293 return err
294 }
295 s.Value = value
296
297 default:
298 fmt.Println("Failed to decode GuestPanicInformation", base.Type)
299 }
300
301 return nil
302 }
303
304
305
306
307
308 type QCryptoBlockOpenOptions struct {
309
310 QCryptoBlockOptionsBase
311
312
313
314 Value Any
315 }
316
317 func (s QCryptoBlockOpenOptions) MarshalJSON() ([]byte, error) {
318 base, err := json.Marshal(s.QCryptoBlockOptionsBase)
319 if err != nil {
320 return nil, err
321 }
322
323 typestr := fmt.Sprintf("%T", s.Value)
324 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
325
326
327
328 if typestr == "<nil>" {
329 return []byte(base), nil
330 }
331
332
333 if typestr != "QCryptoBlockOptionsLUKS" &&
334 typestr != "QCryptoBlockOptionsQCow" {
335 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
336 }
337 value, err := json.Marshal(s.Value)
338 if err != nil {
339 return nil, err
340 }
341
342
343 if string(value) == "{}" {
344 return []byte(base), nil
345 }
346
347
348
349 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
350 return []byte(result), nil
351 }
352
353 func (s *QCryptoBlockOpenOptions) UnmarshalJSON(data []byte) error {
354
355 var base QCryptoBlockOptionsBase
356 if err := json.Unmarshal(data, &base); err != nil {
357 return err
358 }
359 s.QCryptoBlockOptionsBase = base
360
361 switch base.Format {
362 case QCryptoBlockFormatLuks:
363 value := QCryptoBlockOptionsLUKS{}
364 if err := json.Unmarshal(data, &value); err != nil {
365 return err
366 }
367 s.Value = value
368 case QCryptoBlockFormatQcow:
369 value := QCryptoBlockOptionsQCow{}
370 if err := json.Unmarshal(data, &value); err != nil {
371 return err
372 }
373 s.Value = value
374
375 default:
376 fmt.Println("Failed to decode QCryptoBlockOpenOptions", base.Format)
377 }
378
379 return nil
380 }
381
382
383
384
385
386 type QCryptoBlockCreateOptions struct {
387
388 QCryptoBlockOptionsBase
389
390
391
392 Value Any
393 }
394
395 func (s QCryptoBlockCreateOptions) MarshalJSON() ([]byte, error) {
396 base, err := json.Marshal(s.QCryptoBlockOptionsBase)
397 if err != nil {
398 return nil, err
399 }
400
401 typestr := fmt.Sprintf("%T", s.Value)
402 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
403
404
405
406 if typestr == "<nil>" {
407 return []byte(base), nil
408 }
409
410
411 if typestr != "QCryptoBlockCreateOptionsLUKS" &&
412 typestr != "QCryptoBlockOptionsQCow" {
413 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
414 }
415 value, err := json.Marshal(s.Value)
416 if err != nil {
417 return nil, err
418 }
419
420
421 if string(value) == "{}" {
422 return []byte(base), nil
423 }
424
425
426
427 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
428 return []byte(result), nil
429 }
430
431 func (s *QCryptoBlockCreateOptions) UnmarshalJSON(data []byte) error {
432
433 var base QCryptoBlockOptionsBase
434 if err := json.Unmarshal(data, &base); err != nil {
435 return err
436 }
437 s.QCryptoBlockOptionsBase = base
438
439 switch base.Format {
440 case QCryptoBlockFormatLuks:
441 value := QCryptoBlockCreateOptionsLUKS{}
442 if err := json.Unmarshal(data, &value); err != nil {
443 return err
444 }
445 s.Value = value
446 case QCryptoBlockFormatQcow:
447 value := QCryptoBlockOptionsQCow{}
448 if err := json.Unmarshal(data, &value); err != nil {
449 return err
450 }
451 s.Value = value
452
453 default:
454 fmt.Println("Failed to decode QCryptoBlockCreateOptions", base.Format)
455 }
456
457 return nil
458 }
459
460
461
462
463 type QCryptoBlockInfo struct {
464
465 QCryptoBlockInfoBase
466
467
468 Value Any
469 }
470
471 func (s QCryptoBlockInfo) MarshalJSON() ([]byte, error) {
472 base, err := json.Marshal(s.QCryptoBlockInfoBase)
473 if err != nil {
474 return nil, err
475 }
476
477 typestr := fmt.Sprintf("%T", s.Value)
478 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
479
480
481
482 if typestr == "<nil>" {
483 return []byte(base), nil
484 }
485
486
487 if typestr != "QCryptoBlockInfoLUKS" {
488 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
489 }
490 value, err := json.Marshal(s.Value)
491 if err != nil {
492 return nil, err
493 }
494
495
496 if string(value) == "{}" {
497 return []byte(base), nil
498 }
499
500
501
502 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
503 return []byte(result), nil
504 }
505
506 func (s *QCryptoBlockInfo) UnmarshalJSON(data []byte) error {
507
508 var base QCryptoBlockInfoBase
509 if err := json.Unmarshal(data, &base); err != nil {
510 return err
511 }
512 s.QCryptoBlockInfoBase = base
513
514 switch base.Format {
515 case QCryptoBlockFormatLuks:
516 value := QCryptoBlockInfoLUKS{}
517 if err := json.Unmarshal(data, &value); err != nil {
518 return err
519 }
520 s.Value = value
521
522 default:
523 fmt.Println("Failed to decode QCryptoBlockInfo", base.Format)
524 }
525
526 return nil
527 }
528
529
530
531
532
533 type QCryptoBlockAmendOptions struct {
534
535 QCryptoBlockOptionsBase
536
537
538 Value Any
539 }
540
541 func (s QCryptoBlockAmendOptions) MarshalJSON() ([]byte, error) {
542 base, err := json.Marshal(s.QCryptoBlockOptionsBase)
543 if err != nil {
544 return nil, err
545 }
546
547 typestr := fmt.Sprintf("%T", s.Value)
548 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
549
550
551
552 if typestr == "<nil>" {
553 return []byte(base), nil
554 }
555
556
557 if typestr != "QCryptoBlockAmendOptionsLUKS" {
558 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
559 }
560 value, err := json.Marshal(s.Value)
561 if err != nil {
562 return nil, err
563 }
564
565
566 if string(value) == "{}" {
567 return []byte(base), nil
568 }
569
570
571
572 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
573 return []byte(result), nil
574 }
575
576 func (s *QCryptoBlockAmendOptions) UnmarshalJSON(data []byte) error {
577
578 var base QCryptoBlockOptionsBase
579 if err := json.Unmarshal(data, &base); err != nil {
580 return err
581 }
582 s.QCryptoBlockOptionsBase = base
583
584 switch base.Format {
585 case QCryptoBlockFormatLuks:
586 value := QCryptoBlockAmendOptionsLUKS{}
587 if err := json.Unmarshal(data, &value); err != nil {
588 return err
589 }
590 s.Value = value
591
592 default:
593 fmt.Println("Failed to decode QCryptoBlockAmendOptions", base.Format)
594 }
595
596 return nil
597 }
598
599
600 type ImageInfoSpecificQCow2Encryption struct {
601
602 ImageInfoSpecificQCow2EncryptionBase
603
604
605 Value Any
606 }
607
608 func (s ImageInfoSpecificQCow2Encryption) MarshalJSON() ([]byte, error) {
609 base, err := json.Marshal(s.ImageInfoSpecificQCow2EncryptionBase)
610 if err != nil {
611 return nil, err
612 }
613
614 typestr := fmt.Sprintf("%T", s.Value)
615 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
616
617
618
619 if typestr == "<nil>" {
620 return []byte(base), nil
621 }
622
623
624 if typestr != "QCryptoBlockInfoLUKS" {
625 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
626 }
627 value, err := json.Marshal(s.Value)
628 if err != nil {
629 return nil, err
630 }
631
632
633 if string(value) == "{}" {
634 return []byte(base), nil
635 }
636
637
638
639 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
640 return []byte(result), nil
641 }
642
643 func (s *ImageInfoSpecificQCow2Encryption) UnmarshalJSON(data []byte) error {
644
645 var base ImageInfoSpecificQCow2EncryptionBase
646 if err := json.Unmarshal(data, &base); err != nil {
647 return err
648 }
649 s.ImageInfoSpecificQCow2EncryptionBase = base
650
651 switch base.Format {
652 case BlockdevQcow2EncryptionFormatLuks:
653 value := QCryptoBlockInfoLUKS{}
654 if err := json.Unmarshal(data, &value); err != nil {
655 return err
656 }
657 s.Value = value
658
659 default:
660 fmt.Println("Failed to decode ImageInfoSpecificQCow2Encryption", base.Format)
661 }
662
663 return nil
664 }
665
666
667
668
669 type ImageInfoSpecificBase struct {
670 Type ImageInfoSpecificKind `json:"type"`
671 }
672
673
674
675
676 type ImageInfoSpecific struct {
677
678 ImageInfoSpecificBase
679
680
681
682
683
684 Value Any
685 }
686
687 func (s ImageInfoSpecific) MarshalJSON() ([]byte, error) {
688 base, err := json.Marshal(s.ImageInfoSpecificBase)
689 if err != nil {
690 return nil, err
691 }
692
693 typestr := fmt.Sprintf("%T", s.Value)
694 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
695
696
697
698 if typestr == "<nil>" {
699 return []byte(base), nil
700 }
701
702
703 if typestr != "ImageInfoSpecificLUKSWrapper" &&
704 typestr != "ImageInfoSpecificQCow2Wrapper" &&
705 typestr != "ImageInfoSpecificRbdWrapper" &&
706 typestr != "ImageInfoSpecificVmdkWrapper" {
707 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
708 }
709 value, err := json.Marshal(s.Value)
710 if err != nil {
711 return nil, err
712 }
713
714
715 if string(value) == "{}" {
716 return []byte(base), nil
717 }
718
719
720
721 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
722 return []byte(result), nil
723 }
724
725 func (s *ImageInfoSpecific) UnmarshalJSON(data []byte) error {
726
727 var base ImageInfoSpecificBase
728 if err := json.Unmarshal(data, &base); err != nil {
729 return err
730 }
731 s.ImageInfoSpecificBase = base
732
733 switch base.Type {
734 case ImageInfoSpecificKindLuks:
735 value := ImageInfoSpecificLUKSWrapper{}
736 if err := json.Unmarshal(data, &value); err != nil {
737 return err
738 }
739 s.Value = value
740 case ImageInfoSpecificKindQcow2:
741 value := ImageInfoSpecificQCow2Wrapper{}
742 if err := json.Unmarshal(data, &value); err != nil {
743 return err
744 }
745 s.Value = value
746 case ImageInfoSpecificKindRbd:
747 value := ImageInfoSpecificRbdWrapper{}
748 if err := json.Unmarshal(data, &value); err != nil {
749 return err
750 }
751 s.Value = value
752 case ImageInfoSpecificKindVmdk:
753 value := ImageInfoSpecificVmdkWrapper{}
754 if err := json.Unmarshal(data, &value); err != nil {
755 return err
756 }
757 s.Value = value
758
759 default:
760 fmt.Println("Failed to decode ImageInfoSpecific", base.Type)
761 }
762
763 return nil
764 }
765
766
767
768
769 type BlockStatsSpecificBase struct {
770 Driver BlockdevDriver `json:"driver"`
771 }
772
773
774
775
776 type BlockStatsSpecific struct {
777
778 BlockStatsSpecificBase
779
780
781
782
783 Value Any
784 }
785
786 func (s BlockStatsSpecific) MarshalJSON() ([]byte, error) {
787 base, err := json.Marshal(s.BlockStatsSpecificBase)
788 if err != nil {
789 return nil, err
790 }
791
792 typestr := fmt.Sprintf("%T", s.Value)
793 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
794
795
796
797 if typestr == "<nil>" {
798 return []byte(base), nil
799 }
800
801
802 if typestr != "BlockStatsSpecificFile" &&
803 typestr != "BlockStatsSpecificNvme" {
804 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
805 }
806 value, err := json.Marshal(s.Value)
807 if err != nil {
808 return nil, err
809 }
810
811
812 if string(value) == "{}" {
813 return []byte(base), nil
814 }
815
816
817
818 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
819 return []byte(result), nil
820 }
821
822 func (s *BlockStatsSpecific) UnmarshalJSON(data []byte) error {
823
824 var base BlockStatsSpecificBase
825 if err := json.Unmarshal(data, &base); err != nil {
826 return err
827 }
828 s.BlockStatsSpecificBase = base
829
830 switch base.Driver {
831 case BlockdevDriverFile:
832 value := BlockStatsSpecificFile{}
833 if err := json.Unmarshal(data, &value); err != nil {
834 return err
835 }
836 s.Value = value
837 case BlockdevDriverHost_Device:
838 value := BlockStatsSpecificFile{}
839 if err := json.Unmarshal(data, &value); err != nil {
840 return err
841 }
842 s.Value = value
843 case BlockdevDriverNvme:
844 value := BlockStatsSpecificNvme{}
845 if err := json.Unmarshal(data, &value); err != nil {
846 return err
847 }
848 s.Value = value
849
850 default:
851 fmt.Println("Failed to decode BlockStatsSpecific", base.Driver)
852 }
853
854 return nil
855 }
856
857
858 type BlockdevQcowEncryptionBase struct {
859 Format BlockdevQcowEncryptionFormat `json:"format"`
860 }
861
862
863 type BlockdevQcowEncryption struct {
864
865 BlockdevQcowEncryptionBase
866
867
868 Value Any
869 }
870
871 func (s BlockdevQcowEncryption) MarshalJSON() ([]byte, error) {
872 base, err := json.Marshal(s.BlockdevQcowEncryptionBase)
873 if err != nil {
874 return nil, err
875 }
876
877 typestr := fmt.Sprintf("%T", s.Value)
878 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
879
880
881
882 if typestr == "<nil>" {
883 return []byte(base), nil
884 }
885
886
887 if typestr != "QCryptoBlockOptionsQCow" {
888 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
889 }
890 value, err := json.Marshal(s.Value)
891 if err != nil {
892 return nil, err
893 }
894
895
896 if string(value) == "{}" {
897 return []byte(base), nil
898 }
899
900
901
902 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
903 return []byte(result), nil
904 }
905
906 func (s *BlockdevQcowEncryption) UnmarshalJSON(data []byte) error {
907
908 var base BlockdevQcowEncryptionBase
909 if err := json.Unmarshal(data, &base); err != nil {
910 return err
911 }
912 s.BlockdevQcowEncryptionBase = base
913
914 switch base.Format {
915 case BlockdevQcowEncryptionFormatAes:
916 value := QCryptoBlockOptionsQCow{}
917 if err := json.Unmarshal(data, &value); err != nil {
918 return err
919 }
920 s.Value = value
921
922 default:
923 fmt.Println("Failed to decode BlockdevQcowEncryption", base.Format)
924 }
925
926 return nil
927 }
928
929
930 type BlockdevQcow2EncryptionBase struct {
931 Format BlockdevQcow2EncryptionFormat `json:"format"`
932 }
933
934
935 type BlockdevQcow2Encryption struct {
936
937 BlockdevQcow2EncryptionBase
938
939
940
941 Value Any
942 }
943
944 func (s BlockdevQcow2Encryption) MarshalJSON() ([]byte, error) {
945 base, err := json.Marshal(s.BlockdevQcow2EncryptionBase)
946 if err != nil {
947 return nil, err
948 }
949
950 typestr := fmt.Sprintf("%T", s.Value)
951 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
952
953
954
955 if typestr == "<nil>" {
956 return []byte(base), nil
957 }
958
959
960 if typestr != "QCryptoBlockOptionsQCow" &&
961 typestr != "QCryptoBlockOptionsLUKS" {
962 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
963 }
964 value, err := json.Marshal(s.Value)
965 if err != nil {
966 return nil, err
967 }
968
969
970 if string(value) == "{}" {
971 return []byte(base), nil
972 }
973
974
975
976 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
977 return []byte(result), nil
978 }
979
980 func (s *BlockdevQcow2Encryption) UnmarshalJSON(data []byte) error {
981
982 var base BlockdevQcow2EncryptionBase
983 if err := json.Unmarshal(data, &base); err != nil {
984 return err
985 }
986 s.BlockdevQcow2EncryptionBase = base
987
988 switch base.Format {
989 case BlockdevQcow2EncryptionFormatAes:
990 value := QCryptoBlockOptionsQCow{}
991 if err := json.Unmarshal(data, &value); err != nil {
992 return err
993 }
994 s.Value = value
995 case BlockdevQcow2EncryptionFormatLuks:
996 value := QCryptoBlockOptionsLUKS{}
997 if err := json.Unmarshal(data, &value); err != nil {
998 return err
999 }
1000 s.Value = value
1001
1002 default:
1003 fmt.Println("Failed to decode BlockdevQcow2Encryption", base.Format)
1004 }
1005
1006 return nil
1007 }
1008
1009
1010 type SshHostKeyCheckBase struct {
1011 Mode SshHostKeyCheckMode `json:"mode"`
1012 }
1013
1014
1015 type SshHostKeyCheck struct {
1016
1017 SshHostKeyCheckBase
1018
1019
1020 Value Any
1021 }
1022
1023 func (s SshHostKeyCheck) MarshalJSON() ([]byte, error) {
1024 base, err := json.Marshal(s.SshHostKeyCheckBase)
1025 if err != nil {
1026 return nil, err
1027 }
1028
1029 typestr := fmt.Sprintf("%T", s.Value)
1030 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
1031
1032
1033
1034 if typestr == "<nil>" {
1035 return []byte(base), nil
1036 }
1037
1038
1039 if typestr != "SshHostKeyHash" {
1040 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
1041 }
1042 value, err := json.Marshal(s.Value)
1043 if err != nil {
1044 return nil, err
1045 }
1046
1047
1048 if string(value) == "{}" {
1049 return []byte(base), nil
1050 }
1051
1052
1053
1054 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
1055 return []byte(result), nil
1056 }
1057
1058 func (s *SshHostKeyCheck) UnmarshalJSON(data []byte) error {
1059
1060 var base SshHostKeyCheckBase
1061 if err := json.Unmarshal(data, &base); err != nil {
1062 return err
1063 }
1064 s.SshHostKeyCheckBase = base
1065
1066 switch base.Mode {
1067 case SshHostKeyCheckModeHash:
1068 value := SshHostKeyHash{}
1069 if err := json.Unmarshal(data, &value); err != nil {
1070 return err
1071 }
1072 s.Value = value
1073
1074 default:
1075 fmt.Println("Failed to decode SshHostKeyCheck", base.Mode)
1076 }
1077
1078 return nil
1079 }
1080
1081
1082 type RbdEncryptionOptionsBase struct {
1083 Format RbdImageEncryptionFormat `json:"format"`
1084 }
1085
1086
1087 type RbdEncryptionOptions struct {
1088
1089 RbdEncryptionOptionsBase
1090
1091
1092
1093 Value Any
1094 }
1095
1096 func (s RbdEncryptionOptions) MarshalJSON() ([]byte, error) {
1097 base, err := json.Marshal(s.RbdEncryptionOptionsBase)
1098 if err != nil {
1099 return nil, err
1100 }
1101
1102 typestr := fmt.Sprintf("%T", s.Value)
1103 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
1104
1105
1106
1107 if typestr == "<nil>" {
1108 return []byte(base), nil
1109 }
1110
1111
1112 if typestr != "RbdEncryptionOptionsLUKS" &&
1113 typestr != "RbdEncryptionOptionsLUKS2" {
1114 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
1115 }
1116 value, err := json.Marshal(s.Value)
1117 if err != nil {
1118 return nil, err
1119 }
1120
1121
1122 if string(value) == "{}" {
1123 return []byte(base), nil
1124 }
1125
1126
1127
1128 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
1129 return []byte(result), nil
1130 }
1131
1132 func (s *RbdEncryptionOptions) UnmarshalJSON(data []byte) error {
1133
1134 var base RbdEncryptionOptionsBase
1135 if err := json.Unmarshal(data, &base); err != nil {
1136 return err
1137 }
1138 s.RbdEncryptionOptionsBase = base
1139
1140 switch base.Format {
1141 case RbdImageEncryptionFormatLuks:
1142 value := RbdEncryptionOptionsLUKS{}
1143 if err := json.Unmarshal(data, &value); err != nil {
1144 return err
1145 }
1146 s.Value = value
1147 case RbdImageEncryptionFormatLuks2:
1148 value := RbdEncryptionOptionsLUKS2{}
1149 if err := json.Unmarshal(data, &value); err != nil {
1150 return err
1151 }
1152 s.Value = value
1153
1154 default:
1155 fmt.Println("Failed to decode RbdEncryptionOptions", base.Format)
1156 }
1157
1158 return nil
1159 }
1160
1161
1162 type RbdEncryptionCreateOptionsBase struct {
1163 Format RbdImageEncryptionFormat `json:"format"`
1164 }
1165
1166
1167 type RbdEncryptionCreateOptions struct {
1168
1169 RbdEncryptionCreateOptionsBase
1170
1171
1172
1173 Value Any
1174 }
1175
1176 func (s RbdEncryptionCreateOptions) MarshalJSON() ([]byte, error) {
1177 base, err := json.Marshal(s.RbdEncryptionCreateOptionsBase)
1178 if err != nil {
1179 return nil, err
1180 }
1181
1182 typestr := fmt.Sprintf("%T", s.Value)
1183 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
1184
1185
1186
1187 if typestr == "<nil>" {
1188 return []byte(base), nil
1189 }
1190
1191
1192 if typestr != "RbdEncryptionCreateOptionsLUKS" &&
1193 typestr != "RbdEncryptionCreateOptionsLUKS2" {
1194 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
1195 }
1196 value, err := json.Marshal(s.Value)
1197 if err != nil {
1198 return nil, err
1199 }
1200
1201
1202 if string(value) == "{}" {
1203 return []byte(base), nil
1204 }
1205
1206
1207
1208 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
1209 return []byte(result), nil
1210 }
1211
1212 func (s *RbdEncryptionCreateOptions) UnmarshalJSON(data []byte) error {
1213
1214 var base RbdEncryptionCreateOptionsBase
1215 if err := json.Unmarshal(data, &base); err != nil {
1216 return err
1217 }
1218 s.RbdEncryptionCreateOptionsBase = base
1219
1220 switch base.Format {
1221 case RbdImageEncryptionFormatLuks:
1222 value := RbdEncryptionCreateOptionsLUKS{}
1223 if err := json.Unmarshal(data, &value); err != nil {
1224 return err
1225 }
1226 s.Value = value
1227 case RbdImageEncryptionFormatLuks2:
1228 value := RbdEncryptionCreateOptionsLUKS2{}
1229 if err := json.Unmarshal(data, &value); err != nil {
1230 return err
1231 }
1232 s.Value = value
1233
1234 default:
1235 fmt.Println("Failed to decode RbdEncryptionCreateOptions", base.Format)
1236 }
1237
1238 return nil
1239 }
1240
1241
1242
1243
1244
1245
1246
1247 type BlockdevOptionsBase struct {
1248 Driver BlockdevDriver `json:"driver"`
1249 NodeName *string `json:"node-name,omitempty"`
1250 Discard *BlockdevDiscardOptions `json:"discard,omitempty"`
1251 Cache *BlockdevCacheOptions `json:"cache,omitempty"`
1252 ReadOnly *bool `json:"read-only,omitempty"`
1253 AutoReadOnly *bool `json:"auto-read-only,omitempty"`
1254 ForceShare *bool `json:"force-share,omitempty"`
1255 DetectZeroes *BlockdevDetectZeroesOptions `json:"detect-zeroes,omitempty"`
1256 }
1257
1258
1259
1260
1261
1262
1263
1264 type BlockdevOptions struct {
1265
1266 BlockdevOptionsBase
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310 Value Any
1311 }
1312
1313 func (s BlockdevOptions) MarshalJSON() ([]byte, error) {
1314 base, err := json.Marshal(s.BlockdevOptionsBase)
1315 if err != nil {
1316 return nil, err
1317 }
1318
1319 typestr := fmt.Sprintf("%T", s.Value)
1320 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
1321
1322
1323
1324 if typestr == "<nil>" {
1325 return []byte(base), nil
1326 }
1327
1328
1329 if typestr != "BlockdevOptionsBlkdebug" &&
1330 typestr != "BlockdevOptionsBlklogwrites" &&
1331 typestr != "BlockdevOptionsBlkreplay" &&
1332 typestr != "BlockdevOptionsBlkverify" &&
1333 typestr != "BlockdevOptionsGenericFormat" &&
1334 typestr != "BlockdevOptionsCbw" &&
1335 typestr != "BlockdevOptionsCor" &&
1336 typestr != "BlockdevOptionsFile" &&
1337 typestr != "BlockdevOptionsCurlFtp" &&
1338 typestr != "BlockdevOptionsCurlFtps" &&
1339 typestr != "BlockdevOptionsGluster" &&
1340 typestr != "BlockdevOptionsCurlHttp" &&
1341 typestr != "BlockdevOptionsCurlHttps" &&
1342 typestr != "BlockdevOptionsIscsi" &&
1343 typestr != "BlockdevOptionsLUKS" &&
1344 typestr != "BlockdevOptionsNbd" &&
1345 typestr != "BlockdevOptionsNfs" &&
1346 typestr != "BlockdevOptionsNull" &&
1347 typestr != "BlockdevOptionsNVMe" &&
1348 typestr != "BlockdevOptionsPreallocate" &&
1349 typestr != "BlockdevOptionsQcow" &&
1350 typestr != "BlockdevOptionsQcow2" &&
1351 typestr != "BlockdevOptionsGenericCOWFormat" &&
1352 typestr != "BlockdevOptionsQuorum" &&
1353 typestr != "BlockdevOptionsRaw" &&
1354 typestr != "BlockdevOptionsRbd" &&
1355 typestr != "BlockdevOptionsReplication" &&
1356 typestr != "BlockdevOptionsSsh" &&
1357 typestr != "BlockdevOptionsThrottle" &&
1358 typestr != "BlockdevOptionsVVFAT" {
1359 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
1360 }
1361 value, err := json.Marshal(s.Value)
1362 if err != nil {
1363 return nil, err
1364 }
1365
1366
1367 if string(value) == "{}" {
1368 return []byte(base), nil
1369 }
1370
1371
1372
1373 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
1374 return []byte(result), nil
1375 }
1376
1377 func (s *BlockdevOptions) UnmarshalJSON(data []byte) error {
1378
1379 var base BlockdevOptionsBase
1380 if err := json.Unmarshal(data, &base); err != nil {
1381 return err
1382 }
1383 s.BlockdevOptionsBase = base
1384
1385 switch base.Driver {
1386 case BlockdevDriverBlkdebug:
1387 value := BlockdevOptionsBlkdebug{}
1388 if err := json.Unmarshal(data, &value); err != nil {
1389 return err
1390 }
1391 s.Value = value
1392 case BlockdevDriverBlklogwrites:
1393 value := BlockdevOptionsBlklogwrites{}
1394 if err := json.Unmarshal(data, &value); err != nil {
1395 return err
1396 }
1397 s.Value = value
1398 case BlockdevDriverBlkreplay:
1399 value := BlockdevOptionsBlkreplay{}
1400 if err := json.Unmarshal(data, &value); err != nil {
1401 return err
1402 }
1403 s.Value = value
1404 case BlockdevDriverBlkverify:
1405 value := BlockdevOptionsBlkverify{}
1406 if err := json.Unmarshal(data, &value); err != nil {
1407 return err
1408 }
1409 s.Value = value
1410 case BlockdevDriverBochs:
1411 value := BlockdevOptionsGenericFormat{}
1412 if err := json.Unmarshal(data, &value); err != nil {
1413 return err
1414 }
1415 s.Value = value
1416 case BlockdevDriverCloop:
1417 value := BlockdevOptionsGenericFormat{}
1418 if err := json.Unmarshal(data, &value); err != nil {
1419 return err
1420 }
1421 s.Value = value
1422 case BlockdevDriverCompress:
1423 value := BlockdevOptionsGenericFormat{}
1424 if err := json.Unmarshal(data, &value); err != nil {
1425 return err
1426 }
1427 s.Value = value
1428 case BlockdevDriverCopyBeforeWrite:
1429 value := BlockdevOptionsCbw{}
1430 if err := json.Unmarshal(data, &value); err != nil {
1431 return err
1432 }
1433 s.Value = value
1434 case BlockdevDriverCopyOnRead:
1435 value := BlockdevOptionsCor{}
1436 if err := json.Unmarshal(data, &value); err != nil {
1437 return err
1438 }
1439 s.Value = value
1440 case BlockdevDriverDmg:
1441 value := BlockdevOptionsGenericFormat{}
1442 if err := json.Unmarshal(data, &value); err != nil {
1443 return err
1444 }
1445 s.Value = value
1446 case BlockdevDriverFile:
1447 value := BlockdevOptionsFile{}
1448 if err := json.Unmarshal(data, &value); err != nil {
1449 return err
1450 }
1451 s.Value = value
1452 case BlockdevDriverFtp:
1453 value := BlockdevOptionsCurlFtp{}
1454 if err := json.Unmarshal(data, &value); err != nil {
1455 return err
1456 }
1457 s.Value = value
1458 case BlockdevDriverFtps:
1459 value := BlockdevOptionsCurlFtps{}
1460 if err := json.Unmarshal(data, &value); err != nil {
1461 return err
1462 }
1463 s.Value = value
1464 case BlockdevDriverGluster:
1465 value := BlockdevOptionsGluster{}
1466 if err := json.Unmarshal(data, &value); err != nil {
1467 return err
1468 }
1469 s.Value = value
1470 case BlockdevDriverHost_Cdrom:
1471 value := BlockdevOptionsFile{}
1472 if err := json.Unmarshal(data, &value); err != nil {
1473 return err
1474 }
1475 s.Value = value
1476 case BlockdevDriverHost_Device:
1477 value := BlockdevOptionsFile{}
1478 if err := json.Unmarshal(data, &value); err != nil {
1479 return err
1480 }
1481 s.Value = value
1482 case BlockdevDriverHttp:
1483 value := BlockdevOptionsCurlHttp{}
1484 if err := json.Unmarshal(data, &value); err != nil {
1485 return err
1486 }
1487 s.Value = value
1488 case BlockdevDriverHttps:
1489 value := BlockdevOptionsCurlHttps{}
1490 if err := json.Unmarshal(data, &value); err != nil {
1491 return err
1492 }
1493 s.Value = value
1494 case BlockdevDriverIscsi:
1495 value := BlockdevOptionsIscsi{}
1496 if err := json.Unmarshal(data, &value); err != nil {
1497 return err
1498 }
1499 s.Value = value
1500 case BlockdevDriverLuks:
1501 value := BlockdevOptionsLUKS{}
1502 if err := json.Unmarshal(data, &value); err != nil {
1503 return err
1504 }
1505 s.Value = value
1506 case BlockdevDriverNbd:
1507 value := BlockdevOptionsNbd{}
1508 if err := json.Unmarshal(data, &value); err != nil {
1509 return err
1510 }
1511 s.Value = value
1512 case BlockdevDriverNfs:
1513 value := BlockdevOptionsNfs{}
1514 if err := json.Unmarshal(data, &value); err != nil {
1515 return err
1516 }
1517 s.Value = value
1518 case BlockdevDriverNullAio:
1519 value := BlockdevOptionsNull{}
1520 if err := json.Unmarshal(data, &value); err != nil {
1521 return err
1522 }
1523 s.Value = value
1524 case BlockdevDriverNullCo:
1525 value := BlockdevOptionsNull{}
1526 if err := json.Unmarshal(data, &value); err != nil {
1527 return err
1528 }
1529 s.Value = value
1530 case BlockdevDriverNvme:
1531 value := BlockdevOptionsNVMe{}
1532 if err := json.Unmarshal(data, &value); err != nil {
1533 return err
1534 }
1535 s.Value = value
1536 case BlockdevDriverParallels:
1537 value := BlockdevOptionsGenericFormat{}
1538 if err := json.Unmarshal(data, &value); err != nil {
1539 return err
1540 }
1541 s.Value = value
1542 case BlockdevDriverPreallocate:
1543 value := BlockdevOptionsPreallocate{}
1544 if err := json.Unmarshal(data, &value); err != nil {
1545 return err
1546 }
1547 s.Value = value
1548 case BlockdevDriverQcow:
1549 value := BlockdevOptionsQcow{}
1550 if err := json.Unmarshal(data, &value); err != nil {
1551 return err
1552 }
1553 s.Value = value
1554 case BlockdevDriverQcow2:
1555 value := BlockdevOptionsQcow2{}
1556 if err := json.Unmarshal(data, &value); err != nil {
1557 return err
1558 }
1559 s.Value = value
1560 case BlockdevDriverQed:
1561 value := BlockdevOptionsGenericCOWFormat{}
1562 if err := json.Unmarshal(data, &value); err != nil {
1563 return err
1564 }
1565 s.Value = value
1566 case BlockdevDriverQuorum:
1567 value := BlockdevOptionsQuorum{}
1568 if err := json.Unmarshal(data, &value); err != nil {
1569 return err
1570 }
1571 s.Value = value
1572 case BlockdevDriverRaw:
1573 value := BlockdevOptionsRaw{}
1574 if err := json.Unmarshal(data, &value); err != nil {
1575 return err
1576 }
1577 s.Value = value
1578 case BlockdevDriverRbd:
1579 value := BlockdevOptionsRbd{}
1580 if err := json.Unmarshal(data, &value); err != nil {
1581 return err
1582 }
1583 s.Value = value
1584 case BlockdevDriverReplication:
1585 value := BlockdevOptionsReplication{}
1586 if err := json.Unmarshal(data, &value); err != nil {
1587 return err
1588 }
1589 s.Value = value
1590 case BlockdevDriverSnapshotAccess:
1591 value := BlockdevOptionsGenericFormat{}
1592 if err := json.Unmarshal(data, &value); err != nil {
1593 return err
1594 }
1595 s.Value = value
1596 case BlockdevDriverSsh:
1597 value := BlockdevOptionsSsh{}
1598 if err := json.Unmarshal(data, &value); err != nil {
1599 return err
1600 }
1601 s.Value = value
1602 case BlockdevDriverThrottle:
1603 value := BlockdevOptionsThrottle{}
1604 if err := json.Unmarshal(data, &value); err != nil {
1605 return err
1606 }
1607 s.Value = value
1608 case BlockdevDriverVdi:
1609 value := BlockdevOptionsGenericFormat{}
1610 if err := json.Unmarshal(data, &value); err != nil {
1611 return err
1612 }
1613 s.Value = value
1614 case BlockdevDriverVhdx:
1615 value := BlockdevOptionsGenericFormat{}
1616 if err := json.Unmarshal(data, &value); err != nil {
1617 return err
1618 }
1619 s.Value = value
1620 case BlockdevDriverVmdk:
1621 value := BlockdevOptionsGenericCOWFormat{}
1622 if err := json.Unmarshal(data, &value); err != nil {
1623 return err
1624 }
1625 s.Value = value
1626 case BlockdevDriverVpc:
1627 value := BlockdevOptionsGenericFormat{}
1628 if err := json.Unmarshal(data, &value); err != nil {
1629 return err
1630 }
1631 s.Value = value
1632 case BlockdevDriverVvfat:
1633 value := BlockdevOptionsVVFAT{}
1634 if err := json.Unmarshal(data, &value); err != nil {
1635 return err
1636 }
1637 s.Value = value
1638
1639 default:
1640 fmt.Println("Failed to decode BlockdevOptions", base.Driver)
1641 }
1642
1643 return nil
1644 }
1645
1646
1647
1648
1649 type BlockdevCreateOptionsBase struct {
1650 Driver BlockdevDriver `json:"driver"`
1651 }
1652
1653
1654
1655
1656 type BlockdevCreateOptions struct {
1657
1658 BlockdevCreateOptionsBase
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674 Value Any
1675 }
1676
1677 func (s BlockdevCreateOptions) MarshalJSON() ([]byte, error) {
1678 base, err := json.Marshal(s.BlockdevCreateOptionsBase)
1679 if err != nil {
1680 return nil, err
1681 }
1682
1683 typestr := fmt.Sprintf("%T", s.Value)
1684 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
1685
1686
1687
1688 if typestr == "<nil>" {
1689 return []byte(base), nil
1690 }
1691
1692
1693 if typestr != "BlockdevCreateOptionsFile" &&
1694 typestr != "BlockdevCreateOptionsGluster" &&
1695 typestr != "BlockdevCreateOptionsLUKS" &&
1696 typestr != "BlockdevCreateOptionsNfs" &&
1697 typestr != "BlockdevCreateOptionsParallels" &&
1698 typestr != "BlockdevCreateOptionsQcow" &&
1699 typestr != "BlockdevCreateOptionsQcow2" &&
1700 typestr != "BlockdevCreateOptionsQed" &&
1701 typestr != "BlockdevCreateOptionsRbd" &&
1702 typestr != "BlockdevCreateOptionsSsh" &&
1703 typestr != "BlockdevCreateOptionsVdi" &&
1704 typestr != "BlockdevCreateOptionsVhdx" &&
1705 typestr != "BlockdevCreateOptionsVmdk" &&
1706 typestr != "BlockdevCreateOptionsVpc" {
1707 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
1708 }
1709 value, err := json.Marshal(s.Value)
1710 if err != nil {
1711 return nil, err
1712 }
1713
1714
1715 if string(value) == "{}" {
1716 return []byte(base), nil
1717 }
1718
1719
1720
1721 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
1722 return []byte(result), nil
1723 }
1724
1725 func (s *BlockdevCreateOptions) UnmarshalJSON(data []byte) error {
1726
1727 var base BlockdevCreateOptionsBase
1728 if err := json.Unmarshal(data, &base); err != nil {
1729 return err
1730 }
1731 s.BlockdevCreateOptionsBase = base
1732
1733 switch base.Driver {
1734 case BlockdevDriverFile:
1735 value := BlockdevCreateOptionsFile{}
1736 if err := json.Unmarshal(data, &value); err != nil {
1737 return err
1738 }
1739 s.Value = value
1740 case BlockdevDriverGluster:
1741 value := BlockdevCreateOptionsGluster{}
1742 if err := json.Unmarshal(data, &value); err != nil {
1743 return err
1744 }
1745 s.Value = value
1746 case BlockdevDriverLuks:
1747 value := BlockdevCreateOptionsLUKS{}
1748 if err := json.Unmarshal(data, &value); err != nil {
1749 return err
1750 }
1751 s.Value = value
1752 case BlockdevDriverNfs:
1753 value := BlockdevCreateOptionsNfs{}
1754 if err := json.Unmarshal(data, &value); err != nil {
1755 return err
1756 }
1757 s.Value = value
1758 case BlockdevDriverParallels:
1759 value := BlockdevCreateOptionsParallels{}
1760 if err := json.Unmarshal(data, &value); err != nil {
1761 return err
1762 }
1763 s.Value = value
1764 case BlockdevDriverQcow:
1765 value := BlockdevCreateOptionsQcow{}
1766 if err := json.Unmarshal(data, &value); err != nil {
1767 return err
1768 }
1769 s.Value = value
1770 case BlockdevDriverQcow2:
1771 value := BlockdevCreateOptionsQcow2{}
1772 if err := json.Unmarshal(data, &value); err != nil {
1773 return err
1774 }
1775 s.Value = value
1776 case BlockdevDriverQed:
1777 value := BlockdevCreateOptionsQed{}
1778 if err := json.Unmarshal(data, &value); err != nil {
1779 return err
1780 }
1781 s.Value = value
1782 case BlockdevDriverRbd:
1783 value := BlockdevCreateOptionsRbd{}
1784 if err := json.Unmarshal(data, &value); err != nil {
1785 return err
1786 }
1787 s.Value = value
1788 case BlockdevDriverSsh:
1789 value := BlockdevCreateOptionsSsh{}
1790 if err := json.Unmarshal(data, &value); err != nil {
1791 return err
1792 }
1793 s.Value = value
1794 case BlockdevDriverVdi:
1795 value := BlockdevCreateOptionsVdi{}
1796 if err := json.Unmarshal(data, &value); err != nil {
1797 return err
1798 }
1799 s.Value = value
1800 case BlockdevDriverVhdx:
1801 value := BlockdevCreateOptionsVhdx{}
1802 if err := json.Unmarshal(data, &value); err != nil {
1803 return err
1804 }
1805 s.Value = value
1806 case BlockdevDriverVmdk:
1807 value := BlockdevCreateOptionsVmdk{}
1808 if err := json.Unmarshal(data, &value); err != nil {
1809 return err
1810 }
1811 s.Value = value
1812 case BlockdevDriverVpc:
1813 value := BlockdevCreateOptionsVpc{}
1814 if err := json.Unmarshal(data, &value); err != nil {
1815 return err
1816 }
1817 s.Value = value
1818
1819 default:
1820 fmt.Println("Failed to decode BlockdevCreateOptions", base.Driver)
1821 }
1822
1823 return nil
1824 }
1825
1826
1827
1828
1829 type BlockdevAmendOptionsBase struct {
1830 Driver BlockdevDriver `json:"driver"`
1831 }
1832
1833
1834
1835
1836 type BlockdevAmendOptions struct {
1837
1838 BlockdevAmendOptionsBase
1839
1840
1841
1842 Value Any
1843 }
1844
1845 func (s BlockdevAmendOptions) MarshalJSON() ([]byte, error) {
1846 base, err := json.Marshal(s.BlockdevAmendOptionsBase)
1847 if err != nil {
1848 return nil, err
1849 }
1850
1851 typestr := fmt.Sprintf("%T", s.Value)
1852 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
1853
1854
1855
1856 if typestr == "<nil>" {
1857 return []byte(base), nil
1858 }
1859
1860
1861 if typestr != "BlockdevAmendOptionsLUKS" &&
1862 typestr != "BlockdevAmendOptionsQcow2" {
1863 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
1864 }
1865 value, err := json.Marshal(s.Value)
1866 if err != nil {
1867 return nil, err
1868 }
1869
1870
1871 if string(value) == "{}" {
1872 return []byte(base), nil
1873 }
1874
1875
1876
1877 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
1878 return []byte(result), nil
1879 }
1880
1881 func (s *BlockdevAmendOptions) UnmarshalJSON(data []byte) error {
1882
1883 var base BlockdevAmendOptionsBase
1884 if err := json.Unmarshal(data, &base); err != nil {
1885 return err
1886 }
1887 s.BlockdevAmendOptionsBase = base
1888
1889 switch base.Driver {
1890 case BlockdevDriverLuks:
1891 value := BlockdevAmendOptionsLUKS{}
1892 if err := json.Unmarshal(data, &value); err != nil {
1893 return err
1894 }
1895 s.Value = value
1896 case BlockdevDriverQcow2:
1897 value := BlockdevAmendOptionsQcow2{}
1898 if err := json.Unmarshal(data, &value); err != nil {
1899 return err
1900 }
1901 s.Value = value
1902
1903 default:
1904 fmt.Println("Failed to decode BlockdevAmendOptions", base.Driver)
1905 }
1906
1907 return nil
1908 }
1909
1910
1911
1912
1913
1914 type BlockExportOptionsBase struct {
1915 Type BlockExportType `json:"type"`
1916 Id string `json:"id"`
1917 FixedIothread *bool `json:"fixed-iothread,omitempty"`
1918 Iothread *string `json:"iothread,omitempty"`
1919 NodeName string `json:"node-name"`
1920 Writable *bool `json:"writable,omitempty"`
1921 Writethrough *bool `json:"writethrough,omitempty"`
1922 }
1923
1924
1925
1926
1927
1928 type BlockExportOptions struct {
1929
1930 BlockExportOptionsBase
1931
1932
1933
1934
1935 Value Any
1936 }
1937
1938 func (s BlockExportOptions) MarshalJSON() ([]byte, error) {
1939 base, err := json.Marshal(s.BlockExportOptionsBase)
1940 if err != nil {
1941 return nil, err
1942 }
1943
1944 typestr := fmt.Sprintf("%T", s.Value)
1945 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
1946
1947
1948
1949 if typestr == "<nil>" {
1950 return []byte(base), nil
1951 }
1952
1953
1954 if typestr != "BlockExportOptionsFuse" &&
1955 typestr != "BlockExportOptionsNbd" &&
1956 typestr != "BlockExportOptionsVhostUserBlk" {
1957 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
1958 }
1959 value, err := json.Marshal(s.Value)
1960 if err != nil {
1961 return nil, err
1962 }
1963
1964
1965 if string(value) == "{}" {
1966 return []byte(base), nil
1967 }
1968
1969
1970
1971 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
1972 return []byte(result), nil
1973 }
1974
1975 func (s *BlockExportOptions) UnmarshalJSON(data []byte) error {
1976
1977 var base BlockExportOptionsBase
1978 if err := json.Unmarshal(data, &base); err != nil {
1979 return err
1980 }
1981 s.BlockExportOptionsBase = base
1982
1983 switch base.Type {
1984 case BlockExportTypeFuse:
1985 value := BlockExportOptionsFuse{}
1986 if err := json.Unmarshal(data, &value); err != nil {
1987 return err
1988 }
1989 s.Value = value
1990 case BlockExportTypeNbd:
1991 value := BlockExportOptionsNbd{}
1992 if err := json.Unmarshal(data, &value); err != nil {
1993 return err
1994 }
1995 s.Value = value
1996 case BlockExportTypeVhostUserBlk:
1997 value := BlockExportOptionsVhostUserBlk{}
1998 if err := json.Unmarshal(data, &value); err != nil {
1999 return err
2000 }
2001 s.Value = value
2002
2003 default:
2004 fmt.Println("Failed to decode BlockExportOptions", base.Type)
2005 }
2006
2007 return nil
2008 }
2009
2010
2011
2012
2013 type ChardevBackendBase struct {
2014 Type ChardevBackendKind `json:"type"`
2015 }
2016
2017
2018
2019
2020 type ChardevBackend struct {
2021
2022 ChardevBackendBase
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046 Value Any
2047 }
2048
2049 func (s ChardevBackend) MarshalJSON() ([]byte, error) {
2050 base, err := json.Marshal(s.ChardevBackendBase)
2051 if err != nil {
2052 return nil, err
2053 }
2054
2055 typestr := fmt.Sprintf("%T", s.Value)
2056 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2057
2058
2059
2060 if typestr == "<nil>" {
2061 return []byte(base), nil
2062 }
2063
2064
2065 if typestr != "ChardevCommonWrapper" &&
2066 typestr != "ChardevDBusWrapper" &&
2067 typestr != "ChardevFileWrapper" &&
2068 typestr != "ChardevRingbufWrapper" &&
2069 typestr != "ChardevMuxWrapper" &&
2070 typestr != "ChardevHostdevWrapper" &&
2071 typestr != "ChardevQemuVDAgentWrapper" &&
2072 typestr != "ChardevSocketWrapper" &&
2073 typestr != "ChardevSpicePortWrapper" &&
2074 typestr != "ChardevSpiceChannelWrapper" &&
2075 typestr != "ChardevStdioWrapper" &&
2076 typestr != "ChardevUdpWrapper" &&
2077 typestr != "ChardevVCWrapper" {
2078 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2079 }
2080 value, err := json.Marshal(s.Value)
2081 if err != nil {
2082 return nil, err
2083 }
2084
2085
2086 if string(value) == "{}" {
2087 return []byte(base), nil
2088 }
2089
2090
2091
2092 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2093 return []byte(result), nil
2094 }
2095
2096 func (s *ChardevBackend) UnmarshalJSON(data []byte) error {
2097
2098 var base ChardevBackendBase
2099 if err := json.Unmarshal(data, &base); err != nil {
2100 return err
2101 }
2102 s.ChardevBackendBase = base
2103
2104 switch base.Type {
2105 case ChardevBackendKindBraille:
2106 value := ChardevCommonWrapper{}
2107 if err := json.Unmarshal(data, &value); err != nil {
2108 return err
2109 }
2110 s.Value = value
2111 case ChardevBackendKindConsole:
2112 value := ChardevCommonWrapper{}
2113 if err := json.Unmarshal(data, &value); err != nil {
2114 return err
2115 }
2116 s.Value = value
2117 case ChardevBackendKindDbus:
2118 value := ChardevDBusWrapper{}
2119 if err := json.Unmarshal(data, &value); err != nil {
2120 return err
2121 }
2122 s.Value = value
2123 case ChardevBackendKindFile:
2124 value := ChardevFileWrapper{}
2125 if err := json.Unmarshal(data, &value); err != nil {
2126 return err
2127 }
2128 s.Value = value
2129 case ChardevBackendKindMemory:
2130 value := ChardevRingbufWrapper{}
2131 if err := json.Unmarshal(data, &value); err != nil {
2132 return err
2133 }
2134 s.Value = value
2135 case ChardevBackendKindMsmouse:
2136 value := ChardevCommonWrapper{}
2137 if err := json.Unmarshal(data, &value); err != nil {
2138 return err
2139 }
2140 s.Value = value
2141 case ChardevBackendKindMux:
2142 value := ChardevMuxWrapper{}
2143 if err := json.Unmarshal(data, &value); err != nil {
2144 return err
2145 }
2146 s.Value = value
2147 case ChardevBackendKindNull:
2148 value := ChardevCommonWrapper{}
2149 if err := json.Unmarshal(data, &value); err != nil {
2150 return err
2151 }
2152 s.Value = value
2153 case ChardevBackendKindParallel:
2154 value := ChardevHostdevWrapper{}
2155 if err := json.Unmarshal(data, &value); err != nil {
2156 return err
2157 }
2158 s.Value = value
2159 case ChardevBackendKindPipe:
2160 value := ChardevHostdevWrapper{}
2161 if err := json.Unmarshal(data, &value); err != nil {
2162 return err
2163 }
2164 s.Value = value
2165 case ChardevBackendKindPty:
2166 value := ChardevCommonWrapper{}
2167 if err := json.Unmarshal(data, &value); err != nil {
2168 return err
2169 }
2170 s.Value = value
2171 case ChardevBackendKindQemuVdagent:
2172 value := ChardevQemuVDAgentWrapper{}
2173 if err := json.Unmarshal(data, &value); err != nil {
2174 return err
2175 }
2176 s.Value = value
2177 case ChardevBackendKindRingbuf:
2178 value := ChardevRingbufWrapper{}
2179 if err := json.Unmarshal(data, &value); err != nil {
2180 return err
2181 }
2182 s.Value = value
2183 case ChardevBackendKindSerial:
2184 value := ChardevHostdevWrapper{}
2185 if err := json.Unmarshal(data, &value); err != nil {
2186 return err
2187 }
2188 s.Value = value
2189 case ChardevBackendKindSocket:
2190 value := ChardevSocketWrapper{}
2191 if err := json.Unmarshal(data, &value); err != nil {
2192 return err
2193 }
2194 s.Value = value
2195 case ChardevBackendKindSpiceport:
2196 value := ChardevSpicePortWrapper{}
2197 if err := json.Unmarshal(data, &value); err != nil {
2198 return err
2199 }
2200 s.Value = value
2201 case ChardevBackendKindSpicevmc:
2202 value := ChardevSpiceChannelWrapper{}
2203 if err := json.Unmarshal(data, &value); err != nil {
2204 return err
2205 }
2206 s.Value = value
2207 case ChardevBackendKindStdio:
2208 value := ChardevStdioWrapper{}
2209 if err := json.Unmarshal(data, &value); err != nil {
2210 return err
2211 }
2212 s.Value = value
2213 case ChardevBackendKindTestdev:
2214 value := ChardevCommonWrapper{}
2215 if err := json.Unmarshal(data, &value); err != nil {
2216 return err
2217 }
2218 s.Value = value
2219 case ChardevBackendKindUdp:
2220 value := ChardevUdpWrapper{}
2221 if err := json.Unmarshal(data, &value); err != nil {
2222 return err
2223 }
2224 s.Value = value
2225 case ChardevBackendKindVc:
2226 value := ChardevVCWrapper{}
2227 if err := json.Unmarshal(data, &value); err != nil {
2228 return err
2229 }
2230 s.Value = value
2231 case ChardevBackendKindWctablet:
2232 value := ChardevCommonWrapper{}
2233 if err := json.Unmarshal(data, &value); err != nil {
2234 return err
2235 }
2236 s.Value = value
2237
2238 default:
2239 fmt.Println("Failed to decode ChardevBackend", base.Type)
2240 }
2241
2242 return nil
2243 }
2244
2245
2246
2247
2248
2249
2250 type NetdevBase struct {
2251 Id string `json:"id"`
2252 Type NetClientDriver `json:"type"`
2253 }
2254
2255
2256
2257
2258
2259
2260 type Netdev struct {
2261
2262 NetdevBase
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275 Value Any
2276 }
2277
2278 func (s Netdev) MarshalJSON() ([]byte, error) {
2279 base, err := json.Marshal(s.NetdevBase)
2280 if err != nil {
2281 return nil, err
2282 }
2283
2284 typestr := fmt.Sprintf("%T", s.Value)
2285 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2286
2287
2288
2289 if typestr == "<nil>" {
2290 return []byte(base), nil
2291 }
2292
2293
2294 if typestr != "NetdevBridgeOptions" &&
2295 typestr != "NetdevHubPortOptions" &&
2296 typestr != "NetdevL2TPv3Options" &&
2297 typestr != "NetdevNetmapOptions" &&
2298 typestr != "NetLegacyNicOptions" &&
2299 typestr != "NetdevSocketOptions" &&
2300 typestr != "NetdevTapOptions" &&
2301 typestr != "NetdevUserOptions" &&
2302 typestr != "NetdevVdeOptions" &&
2303 typestr != "NetdevVhostUserOptions" &&
2304 typestr != "NetdevVhostVDPAOptions" {
2305 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2306 }
2307 value, err := json.Marshal(s.Value)
2308 if err != nil {
2309 return nil, err
2310 }
2311
2312
2313 if string(value) == "{}" {
2314 return []byte(base), nil
2315 }
2316
2317
2318
2319 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2320 return []byte(result), nil
2321 }
2322
2323 func (s *Netdev) UnmarshalJSON(data []byte) error {
2324
2325 var base NetdevBase
2326 if err := json.Unmarshal(data, &base); err != nil {
2327 return err
2328 }
2329 s.NetdevBase = base
2330
2331 switch base.Type {
2332 case NetClientDriverBridge:
2333 value := NetdevBridgeOptions{}
2334 if err := json.Unmarshal(data, &value); err != nil {
2335 return err
2336 }
2337 s.Value = value
2338 case NetClientDriverHubport:
2339 value := NetdevHubPortOptions{}
2340 if err := json.Unmarshal(data, &value); err != nil {
2341 return err
2342 }
2343 s.Value = value
2344 case NetClientDriverL2Tpv3:
2345 value := NetdevL2TPv3Options{}
2346 if err := json.Unmarshal(data, &value); err != nil {
2347 return err
2348 }
2349 s.Value = value
2350 case NetClientDriverNetmap:
2351 value := NetdevNetmapOptions{}
2352 if err := json.Unmarshal(data, &value); err != nil {
2353 return err
2354 }
2355 s.Value = value
2356 case NetClientDriverNic:
2357 value := NetLegacyNicOptions{}
2358 if err := json.Unmarshal(data, &value); err != nil {
2359 return err
2360 }
2361 s.Value = value
2362 case NetClientDriverSocket:
2363 value := NetdevSocketOptions{}
2364 if err := json.Unmarshal(data, &value); err != nil {
2365 return err
2366 }
2367 s.Value = value
2368 case NetClientDriverTap:
2369 value := NetdevTapOptions{}
2370 if err := json.Unmarshal(data, &value); err != nil {
2371 return err
2372 }
2373 s.Value = value
2374 case NetClientDriverUser:
2375 value := NetdevUserOptions{}
2376 if err := json.Unmarshal(data, &value); err != nil {
2377 return err
2378 }
2379 s.Value = value
2380 case NetClientDriverVde:
2381 value := NetdevVdeOptions{}
2382 if err := json.Unmarshal(data, &value); err != nil {
2383 return err
2384 }
2385 s.Value = value
2386 case NetClientDriverVhostUser:
2387 value := NetdevVhostUserOptions{}
2388 if err := json.Unmarshal(data, &value); err != nil {
2389 return err
2390 }
2391 s.Value = value
2392 case NetClientDriverVhostVdpa:
2393 value := NetdevVhostVDPAOptions{}
2394 if err := json.Unmarshal(data, &value); err != nil {
2395 return err
2396 }
2397 s.Value = value
2398
2399 default:
2400 fmt.Println("Failed to decode Netdev", base.Type)
2401 }
2402
2403 return nil
2404 }
2405
2406
2407
2408
2409 type TpmTypeOptionsBase struct {
2410 Type TpmType `json:"type"`
2411 }
2412
2413
2414
2415
2416 type TpmTypeOptions struct {
2417
2418 TpmTypeOptionsBase
2419
2420
2421
2422 Value Any
2423 }
2424
2425 func (s TpmTypeOptions) MarshalJSON() ([]byte, error) {
2426 base, err := json.Marshal(s.TpmTypeOptionsBase)
2427 if err != nil {
2428 return nil, err
2429 }
2430
2431 typestr := fmt.Sprintf("%T", s.Value)
2432 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2433
2434
2435
2436 if typestr == "<nil>" {
2437 return []byte(base), nil
2438 }
2439
2440
2441 if typestr != "TPMEmulatorOptionsWrapper" &&
2442 typestr != "TPMPassthroughOptionsWrapper" {
2443 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2444 }
2445 value, err := json.Marshal(s.Value)
2446 if err != nil {
2447 return nil, err
2448 }
2449
2450
2451 if string(value) == "{}" {
2452 return []byte(base), nil
2453 }
2454
2455
2456
2457 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2458 return []byte(result), nil
2459 }
2460
2461 func (s *TpmTypeOptions) UnmarshalJSON(data []byte) error {
2462
2463 var base TpmTypeOptionsBase
2464 if err := json.Unmarshal(data, &base); err != nil {
2465 return err
2466 }
2467 s.TpmTypeOptionsBase = base
2468
2469 switch base.Type {
2470 case TpmTypeEmulator:
2471 value := TPMEmulatorOptionsWrapper{}
2472 if err := json.Unmarshal(data, &value); err != nil {
2473 return err
2474 }
2475 s.Value = value
2476 case TpmTypePassthrough:
2477 value := TPMPassthroughOptionsWrapper{}
2478 if err := json.Unmarshal(data, &value); err != nil {
2479 return err
2480 }
2481 s.Value = value
2482
2483 default:
2484 fmt.Println("Failed to decode TpmTypeOptions", base.Type)
2485 }
2486
2487 return nil
2488 }
2489
2490
2491
2492
2493 type SetPasswordOptionsBase struct {
2494 Protocol DisplayProtocol `json:"protocol"`
2495 Password string `json:"password"`
2496 Connected *SetPasswordAction `json:"connected,omitempty"`
2497 }
2498
2499
2500
2501
2502 type SetPasswordOptions struct {
2503
2504 SetPasswordOptionsBase
2505
2506
2507 Value Any
2508 }
2509
2510 func (s SetPasswordOptions) MarshalJSON() ([]byte, error) {
2511 base, err := json.Marshal(s.SetPasswordOptionsBase)
2512 if err != nil {
2513 return nil, err
2514 }
2515
2516 typestr := fmt.Sprintf("%T", s.Value)
2517 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2518
2519
2520
2521 if typestr == "<nil>" {
2522 return []byte(base), nil
2523 }
2524
2525
2526 if typestr != "SetPasswordOptionsVnc" {
2527 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2528 }
2529 value, err := json.Marshal(s.Value)
2530 if err != nil {
2531 return nil, err
2532 }
2533
2534
2535 if string(value) == "{}" {
2536 return []byte(base), nil
2537 }
2538
2539
2540
2541 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2542 return []byte(result), nil
2543 }
2544
2545 func (s *SetPasswordOptions) UnmarshalJSON(data []byte) error {
2546
2547 var base SetPasswordOptionsBase
2548 if err := json.Unmarshal(data, &base); err != nil {
2549 return err
2550 }
2551 s.SetPasswordOptionsBase = base
2552
2553 switch base.Protocol {
2554 case DisplayProtocolVnc:
2555 value := SetPasswordOptionsVnc{}
2556 if err := json.Unmarshal(data, &value); err != nil {
2557 return err
2558 }
2559 s.Value = value
2560
2561 default:
2562 fmt.Println("Failed to decode SetPasswordOptions", base.Protocol)
2563 }
2564
2565 return nil
2566 }
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576 type ExpirePasswordOptionsBase struct {
2577 Protocol DisplayProtocol `json:"protocol"`
2578 Time string `json:"time"`
2579 }
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589 type ExpirePasswordOptions struct {
2590
2591 ExpirePasswordOptionsBase
2592
2593
2594 Value Any
2595 }
2596
2597 func (s ExpirePasswordOptions) MarshalJSON() ([]byte, error) {
2598 base, err := json.Marshal(s.ExpirePasswordOptionsBase)
2599 if err != nil {
2600 return nil, err
2601 }
2602
2603 typestr := fmt.Sprintf("%T", s.Value)
2604 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2605
2606
2607
2608 if typestr == "<nil>" {
2609 return []byte(base), nil
2610 }
2611
2612
2613 if typestr != "ExpirePasswordOptionsVnc" {
2614 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2615 }
2616 value, err := json.Marshal(s.Value)
2617 if err != nil {
2618 return nil, err
2619 }
2620
2621
2622 if string(value) == "{}" {
2623 return []byte(base), nil
2624 }
2625
2626
2627
2628 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2629 return []byte(result), nil
2630 }
2631
2632 func (s *ExpirePasswordOptions) UnmarshalJSON(data []byte) error {
2633
2634 var base ExpirePasswordOptionsBase
2635 if err := json.Unmarshal(data, &base); err != nil {
2636 return err
2637 }
2638 s.ExpirePasswordOptionsBase = base
2639
2640 switch base.Protocol {
2641 case DisplayProtocolVnc:
2642 value := ExpirePasswordOptionsVnc{}
2643 if err := json.Unmarshal(data, &value); err != nil {
2644 return err
2645 }
2646 s.Value = value
2647
2648 default:
2649 fmt.Println("Failed to decode ExpirePasswordOptions", base.Protocol)
2650 }
2651
2652 return nil
2653 }
2654
2655
2656
2657
2658 type KeyValueBase struct {
2659 Type KeyValueKind `json:"type"`
2660 }
2661
2662
2663
2664
2665 type KeyValue struct {
2666
2667 KeyValueBase
2668
2669
2670
2671 Value Any
2672 }
2673
2674 func (s KeyValue) MarshalJSON() ([]byte, error) {
2675 base, err := json.Marshal(s.KeyValueBase)
2676 if err != nil {
2677 return nil, err
2678 }
2679
2680 typestr := fmt.Sprintf("%T", s.Value)
2681 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2682
2683
2684
2685 if typestr == "<nil>" {
2686 return []byte(base), nil
2687 }
2688
2689
2690 if typestr != "IntWrapper" &&
2691 typestr != "QKeyCodeWrapper" {
2692 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2693 }
2694 value, err := json.Marshal(s.Value)
2695 if err != nil {
2696 return nil, err
2697 }
2698
2699
2700 if string(value) == "{}" {
2701 return []byte(base), nil
2702 }
2703
2704
2705
2706 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2707 return []byte(result), nil
2708 }
2709
2710 func (s *KeyValue) UnmarshalJSON(data []byte) error {
2711
2712 var base KeyValueBase
2713 if err := json.Unmarshal(data, &base); err != nil {
2714 return err
2715 }
2716 s.KeyValueBase = base
2717
2718 switch base.Type {
2719 case KeyValueKindNumber:
2720 value := IntWrapper{}
2721 if err := json.Unmarshal(data, &value); err != nil {
2722 return err
2723 }
2724 s.Value = value
2725 case KeyValueKindQcode:
2726 value := QKeyCodeWrapper{}
2727 if err := json.Unmarshal(data, &value); err != nil {
2728 return err
2729 }
2730 s.Value = value
2731
2732 default:
2733 fmt.Println("Failed to decode KeyValue", base.Type)
2734 }
2735
2736 return nil
2737 }
2738
2739
2740
2741
2742 type InputEventBase struct {
2743 Type InputEventKind `json:"type"`
2744 }
2745
2746
2747
2748
2749 type InputEvent struct {
2750
2751 InputEventBase
2752
2753
2754
2755
2756
2757 Value Any
2758 }
2759
2760 func (s InputEvent) MarshalJSON() ([]byte, error) {
2761 base, err := json.Marshal(s.InputEventBase)
2762 if err != nil {
2763 return nil, err
2764 }
2765
2766 typestr := fmt.Sprintf("%T", s.Value)
2767 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2768
2769
2770
2771 if typestr == "<nil>" {
2772 return []byte(base), nil
2773 }
2774
2775
2776 if typestr != "InputMoveEventWrapper" &&
2777 typestr != "InputBtnEventWrapper" &&
2778 typestr != "InputKeyEventWrapper" {
2779 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2780 }
2781 value, err := json.Marshal(s.Value)
2782 if err != nil {
2783 return nil, err
2784 }
2785
2786
2787 if string(value) == "{}" {
2788 return []byte(base), nil
2789 }
2790
2791
2792
2793 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2794 return []byte(result), nil
2795 }
2796
2797 func (s *InputEvent) UnmarshalJSON(data []byte) error {
2798
2799 var base InputEventBase
2800 if err := json.Unmarshal(data, &base); err != nil {
2801 return err
2802 }
2803 s.InputEventBase = base
2804
2805 switch base.Type {
2806 case InputEventKindAbs:
2807 value := InputMoveEventWrapper{}
2808 if err := json.Unmarshal(data, &value); err != nil {
2809 return err
2810 }
2811 s.Value = value
2812 case InputEventKindBtn:
2813 value := InputBtnEventWrapper{}
2814 if err := json.Unmarshal(data, &value); err != nil {
2815 return err
2816 }
2817 s.Value = value
2818 case InputEventKindKey:
2819 value := InputKeyEventWrapper{}
2820 if err := json.Unmarshal(data, &value); err != nil {
2821 return err
2822 }
2823 s.Value = value
2824 case InputEventKindRel:
2825 value := InputMoveEventWrapper{}
2826 if err := json.Unmarshal(data, &value); err != nil {
2827 return err
2828 }
2829 s.Value = value
2830
2831 default:
2832 fmt.Println("Failed to decode InputEvent", base.Type)
2833 }
2834
2835 return nil
2836 }
2837
2838
2839
2840
2841 type DisplayOptionsBase struct {
2842 Type DisplayType `json:"type"`
2843 FullScreen *bool `json:"full-screen,omitempty"`
2844 WindowClose *bool `json:"window-close,omitempty"`
2845 ShowCursor *bool `json:"show-cursor,omitempty"`
2846 Gl *DisplayGLMode `json:"gl,omitempty"`
2847 }
2848
2849
2850
2851
2852 type DisplayOptions struct {
2853
2854 DisplayOptionsBase
2855
2856
2857
2858
2859
2860
2861 Value Any
2862 }
2863
2864 func (s DisplayOptions) MarshalJSON() ([]byte, error) {
2865 base, err := json.Marshal(s.DisplayOptionsBase)
2866 if err != nil {
2867 return nil, err
2868 }
2869
2870 typestr := fmt.Sprintf("%T", s.Value)
2871 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2872
2873
2874
2875 if typestr == "<nil>" {
2876 return []byte(base), nil
2877 }
2878
2879
2880 if typestr != "DisplayCocoa" &&
2881 typestr != "DisplayCurses" &&
2882 typestr != "DisplayDBus" &&
2883 typestr != "DisplayEGLHeadless" &&
2884 typestr != "DisplayGTK" {
2885 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2886 }
2887 value, err := json.Marshal(s.Value)
2888 if err != nil {
2889 return nil, err
2890 }
2891
2892
2893 if string(value) == "{}" {
2894 return []byte(base), nil
2895 }
2896
2897
2898
2899 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
2900 return []byte(result), nil
2901 }
2902
2903 func (s *DisplayOptions) UnmarshalJSON(data []byte) error {
2904
2905 var base DisplayOptionsBase
2906 if err := json.Unmarshal(data, &base); err != nil {
2907 return err
2908 }
2909 s.DisplayOptionsBase = base
2910
2911 switch base.Type {
2912 case DisplayTypeCocoa:
2913 value := DisplayCocoa{}
2914 if err := json.Unmarshal(data, &value); err != nil {
2915 return err
2916 }
2917 s.Value = value
2918 case DisplayTypeCurses:
2919 value := DisplayCurses{}
2920 if err := json.Unmarshal(data, &value); err != nil {
2921 return err
2922 }
2923 s.Value = value
2924 case DisplayTypeDbus:
2925 value := DisplayDBus{}
2926 if err := json.Unmarshal(data, &value); err != nil {
2927 return err
2928 }
2929 s.Value = value
2930 case DisplayTypeEglHeadless:
2931 value := DisplayEGLHeadless{}
2932 if err := json.Unmarshal(data, &value); err != nil {
2933 return err
2934 }
2935 s.Value = value
2936 case DisplayTypeGtk:
2937 value := DisplayGTK{}
2938 if err := json.Unmarshal(data, &value); err != nil {
2939 return err
2940 }
2941 s.Value = value
2942
2943 default:
2944 fmt.Println("Failed to decode DisplayOptions", base.Type)
2945 }
2946
2947 return nil
2948 }
2949
2950
2951
2952
2953 type DisplayReloadOptionsBase struct {
2954 Type DisplayReloadType `json:"type"`
2955 }
2956
2957
2958
2959
2960 type DisplayReloadOptions struct {
2961
2962 DisplayReloadOptionsBase
2963
2964
2965 Value Any
2966 }
2967
2968 func (s DisplayReloadOptions) MarshalJSON() ([]byte, error) {
2969 base, err := json.Marshal(s.DisplayReloadOptionsBase)
2970 if err != nil {
2971 return nil, err
2972 }
2973
2974 typestr := fmt.Sprintf("%T", s.Value)
2975 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
2976
2977
2978
2979 if typestr == "<nil>" {
2980 return []byte(base), nil
2981 }
2982
2983
2984 if typestr != "DisplayReloadOptionsVNC" {
2985 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
2986 }
2987 value, err := json.Marshal(s.Value)
2988 if err != nil {
2989 return nil, err
2990 }
2991
2992
2993 if string(value) == "{}" {
2994 return []byte(base), nil
2995 }
2996
2997
2998
2999 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
3000 return []byte(result), nil
3001 }
3002
3003 func (s *DisplayReloadOptions) UnmarshalJSON(data []byte) error {
3004
3005 var base DisplayReloadOptionsBase
3006 if err := json.Unmarshal(data, &base); err != nil {
3007 return err
3008 }
3009 s.DisplayReloadOptionsBase = base
3010
3011 switch base.Type {
3012 case DisplayReloadTypeVnc:
3013 value := DisplayReloadOptionsVNC{}
3014 if err := json.Unmarshal(data, &value); err != nil {
3015 return err
3016 }
3017 s.Value = value
3018
3019 default:
3020 fmt.Println("Failed to decode DisplayReloadOptions", base.Type)
3021 }
3022
3023 return nil
3024 }
3025
3026
3027
3028
3029
3030 type TransactionActionBase struct {
3031 Type TransactionActionKind `json:"type"`
3032 }
3033
3034
3035
3036
3037
3038 type TransactionAction struct {
3039
3040 TransactionActionBase
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054 Value Any
3055 }
3056
3057 func (s TransactionAction) MarshalJSON() ([]byte, error) {
3058 base, err := json.Marshal(s.TransactionActionBase)
3059 if err != nil {
3060 return nil, err
3061 }
3062
3063 typestr := fmt.Sprintf("%T", s.Value)
3064 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
3065
3066
3067
3068 if typestr == "<nil>" {
3069 return []byte(base), nil
3070 }
3071
3072
3073 if typestr != "AbortWrapper" &&
3074 typestr != "BlockDirtyBitmapAddWrapper" &&
3075 typestr != "BlockDirtyBitmapWrapper" &&
3076 typestr != "BlockDirtyBitmapMergeWrapper" &&
3077 typestr != "BlockdevBackupWrapper" &&
3078 typestr != "BlockdevSnapshotWrapper" &&
3079 typestr != "BlockdevSnapshotInternalWrapper" &&
3080 typestr != "BlockdevSnapshotSyncWrapper" &&
3081 typestr != "DriveBackupWrapper" {
3082 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
3083 }
3084 value, err := json.Marshal(s.Value)
3085 if err != nil {
3086 return nil, err
3087 }
3088
3089
3090 if string(value) == "{}" {
3091 return []byte(base), nil
3092 }
3093
3094
3095
3096 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
3097 return []byte(result), nil
3098 }
3099
3100 func (s *TransactionAction) UnmarshalJSON(data []byte) error {
3101
3102 var base TransactionActionBase
3103 if err := json.Unmarshal(data, &base); err != nil {
3104 return err
3105 }
3106 s.TransactionActionBase = base
3107
3108 switch base.Type {
3109 case TransactionActionKindAbort:
3110 value := AbortWrapper{}
3111 if err := json.Unmarshal(data, &value); err != nil {
3112 return err
3113 }
3114 s.Value = value
3115 case TransactionActionKindBlockDirtyBitmapAdd:
3116 value := BlockDirtyBitmapAddWrapper{}
3117 if err := json.Unmarshal(data, &value); err != nil {
3118 return err
3119 }
3120 s.Value = value
3121 case TransactionActionKindBlockDirtyBitmapClear:
3122 value := BlockDirtyBitmapWrapper{}
3123 if err := json.Unmarshal(data, &value); err != nil {
3124 return err
3125 }
3126 s.Value = value
3127 case TransactionActionKindBlockDirtyBitmapDisable:
3128 value := BlockDirtyBitmapWrapper{}
3129 if err := json.Unmarshal(data, &value); err != nil {
3130 return err
3131 }
3132 s.Value = value
3133 case TransactionActionKindBlockDirtyBitmapEnable:
3134 value := BlockDirtyBitmapWrapper{}
3135 if err := json.Unmarshal(data, &value); err != nil {
3136 return err
3137 }
3138 s.Value = value
3139 case TransactionActionKindBlockDirtyBitmapMerge:
3140 value := BlockDirtyBitmapMergeWrapper{}
3141 if err := json.Unmarshal(data, &value); err != nil {
3142 return err
3143 }
3144 s.Value = value
3145 case TransactionActionKindBlockDirtyBitmapRemove:
3146 value := BlockDirtyBitmapWrapper{}
3147 if err := json.Unmarshal(data, &value); err != nil {
3148 return err
3149 }
3150 s.Value = value
3151 case TransactionActionKindBlockdevBackup:
3152 value := BlockdevBackupWrapper{}
3153 if err := json.Unmarshal(data, &value); err != nil {
3154 return err
3155 }
3156 s.Value = value
3157 case TransactionActionKindBlockdevSnapshot:
3158 value := BlockdevSnapshotWrapper{}
3159 if err := json.Unmarshal(data, &value); err != nil {
3160 return err
3161 }
3162 s.Value = value
3163 case TransactionActionKindBlockdevSnapshotInternalSync:
3164 value := BlockdevSnapshotInternalWrapper{}
3165 if err := json.Unmarshal(data, &value); err != nil {
3166 return err
3167 }
3168 s.Value = value
3169 case TransactionActionKindBlockdevSnapshotSync:
3170 value := BlockdevSnapshotSyncWrapper{}
3171 if err := json.Unmarshal(data, &value); err != nil {
3172 return err
3173 }
3174 s.Value = value
3175 case TransactionActionKindDriveBackup:
3176 value := DriveBackupWrapper{}
3177 if err := json.Unmarshal(data, &value); err != nil {
3178 return err
3179 }
3180 s.Value = value
3181
3182 default:
3183 fmt.Println("Failed to decode TransactionAction", base.Type)
3184 }
3185
3186 return nil
3187 }
3188
3189
3190
3191
3192 type SchemaInfoBase struct {
3193 Name string `json:"name"`
3194 MetaType SchemaMetaType `json:"meta-type"`
3195 Features []string `json:"features,omitempty"`
3196 }
3197
3198
3199
3200
3201 type SchemaInfo struct {
3202
3203 SchemaInfoBase
3204
3205
3206
3207
3208
3209
3210
3211
3212 Value Any
3213 }
3214
3215 func (s SchemaInfo) MarshalJSON() ([]byte, error) {
3216 base, err := json.Marshal(s.SchemaInfoBase)
3217 if err != nil {
3218 return nil, err
3219 }
3220
3221 typestr := fmt.Sprintf("%T", s.Value)
3222 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
3223
3224
3225
3226 if typestr == "<nil>" {
3227 return []byte(base), nil
3228 }
3229
3230
3231 if typestr != "SchemaInfoAlternate" &&
3232 typestr != "SchemaInfoArray" &&
3233 typestr != "SchemaInfoBuiltin" &&
3234 typestr != "SchemaInfoCommand" &&
3235 typestr != "SchemaInfoEnum" &&
3236 typestr != "SchemaInfoEvent" &&
3237 typestr != "SchemaInfoObject" {
3238 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
3239 }
3240 value, err := json.Marshal(s.Value)
3241 if err != nil {
3242 return nil, err
3243 }
3244
3245
3246 if string(value) == "{}" {
3247 return []byte(base), nil
3248 }
3249
3250
3251
3252 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
3253 return []byte(result), nil
3254 }
3255
3256 func (s *SchemaInfo) UnmarshalJSON(data []byte) error {
3257
3258 var base SchemaInfoBase
3259 if err := json.Unmarshal(data, &base); err != nil {
3260 return err
3261 }
3262 s.SchemaInfoBase = base
3263
3264 switch base.MetaType {
3265 case SchemaMetaTypeAlternate:
3266 value := SchemaInfoAlternate{}
3267 if err := json.Unmarshal(data, &value); err != nil {
3268 return err
3269 }
3270 s.Value = value
3271 case SchemaMetaTypeArray:
3272 value := SchemaInfoArray{}
3273 if err := json.Unmarshal(data, &value); err != nil {
3274 return err
3275 }
3276 s.Value = value
3277 case SchemaMetaTypeBuiltin:
3278 value := SchemaInfoBuiltin{}
3279 if err := json.Unmarshal(data, &value); err != nil {
3280 return err
3281 }
3282 s.Value = value
3283 case SchemaMetaTypeCommand:
3284 value := SchemaInfoCommand{}
3285 if err := json.Unmarshal(data, &value); err != nil {
3286 return err
3287 }
3288 s.Value = value
3289 case SchemaMetaTypeEnum:
3290 value := SchemaInfoEnum{}
3291 if err := json.Unmarshal(data, &value); err != nil {
3292 return err
3293 }
3294 s.Value = value
3295 case SchemaMetaTypeEvent:
3296 value := SchemaInfoEvent{}
3297 if err := json.Unmarshal(data, &value); err != nil {
3298 return err
3299 }
3300 s.Value = value
3301 case SchemaMetaTypeObject:
3302 value := SchemaInfoObject{}
3303 if err := json.Unmarshal(data, &value); err != nil {
3304 return err
3305 }
3306 s.Value = value
3307
3308 default:
3309 fmt.Println("Failed to decode SchemaInfo", base.MetaType)
3310 }
3311
3312 return nil
3313 }
3314
3315
3316
3317
3318 type ObjectOptionsBase struct {
3319 QomType ObjectType `json:"qom-type"`
3320 Id string `json:"id"`
3321 }
3322
3323
3324
3325
3326 type ObjectOptions struct {
3327
3328 ObjectOptionsBase
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367 Value Any
3368 }
3369
3370 func (s ObjectOptions) MarshalJSON() ([]byte, error) {
3371 base, err := json.Marshal(s.ObjectOptionsBase)
3372 if err != nil {
3373 return nil, err
3374 }
3375
3376 typestr := fmt.Sprintf("%T", s.Value)
3377 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
3378
3379
3380
3381 if typestr == "<nil>" {
3382 return []byte(base), nil
3383 }
3384
3385
3386 if typestr != "AuthZListProperties" &&
3387 typestr != "AuthZListFileProperties" &&
3388 typestr != "AuthZPAMProperties" &&
3389 typestr != "AuthZSimpleProperties" &&
3390 typestr != "CanHostSocketcanProperties" &&
3391 typestr != "ColoCompareProperties" &&
3392 typestr != "CryptodevBackendProperties" &&
3393 typestr != "CryptodevVhostUserProperties" &&
3394 typestr != "DBusVMStateProperties" &&
3395 typestr != "FilterBufferProperties" &&
3396 typestr != "FilterDumpProperties" &&
3397 typestr != "FilterMirrorProperties" &&
3398 typestr != "FilterRedirectorProperties" &&
3399 typestr != "NetfilterProperties" &&
3400 typestr != "FilterRewriterProperties" &&
3401 typestr != "InputBarrierProperties" &&
3402 typestr != "InputLinuxProperties" &&
3403 typestr != "IothreadProperties" &&
3404 typestr != "MemoryBackendEpcProperties" &&
3405 typestr != "MemoryBackendFileProperties" &&
3406 typestr != "MemoryBackendMemfdProperties" &&
3407 typestr != "MemoryBackendProperties" &&
3408 typestr != "PrManagerHelperProperties" &&
3409 typestr != "QtestProperties" &&
3410 typestr != "RngProperties" &&
3411 typestr != "RngEgdProperties" &&
3412 typestr != "RngRandomProperties" &&
3413 typestr != "SecretProperties" &&
3414 typestr != "SecretKeyringProperties" &&
3415 typestr != "SevGuestProperties" &&
3416 typestr != "ThrottleGroupProperties" &&
3417 typestr != "TlsCredsProperties" &&
3418 typestr != "TlsCredsAnonProperties" &&
3419 typestr != "TlsCredsPskProperties" &&
3420 typestr != "TlsCredsX509Properties" &&
3421 typestr != "RemoteObjectProperties" {
3422 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
3423 }
3424 value, err := json.Marshal(s.Value)
3425 if err != nil {
3426 return nil, err
3427 }
3428
3429
3430 if string(value) == "{}" {
3431 return []byte(base), nil
3432 }
3433
3434
3435
3436 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
3437 return []byte(result), nil
3438 }
3439
3440 func (s *ObjectOptions) UnmarshalJSON(data []byte) error {
3441
3442 var base ObjectOptionsBase
3443 if err := json.Unmarshal(data, &base); err != nil {
3444 return err
3445 }
3446 s.ObjectOptionsBase = base
3447
3448 switch base.QomType {
3449 case ObjectTypeAuthzList:
3450 value := AuthZListProperties{}
3451 if err := json.Unmarshal(data, &value); err != nil {
3452 return err
3453 }
3454 s.Value = value
3455 case ObjectTypeAuthzListfile:
3456 value := AuthZListFileProperties{}
3457 if err := json.Unmarshal(data, &value); err != nil {
3458 return err
3459 }
3460 s.Value = value
3461 case ObjectTypeAuthzPam:
3462 value := AuthZPAMProperties{}
3463 if err := json.Unmarshal(data, &value); err != nil {
3464 return err
3465 }
3466 s.Value = value
3467 case ObjectTypeAuthzSimple:
3468 value := AuthZSimpleProperties{}
3469 if err := json.Unmarshal(data, &value); err != nil {
3470 return err
3471 }
3472 s.Value = value
3473 case ObjectTypeCanHostSocketcan:
3474 value := CanHostSocketcanProperties{}
3475 if err := json.Unmarshal(data, &value); err != nil {
3476 return err
3477 }
3478 s.Value = value
3479 case ObjectTypeColoCompare:
3480 value := ColoCompareProperties{}
3481 if err := json.Unmarshal(data, &value); err != nil {
3482 return err
3483 }
3484 s.Value = value
3485 case ObjectTypeCryptodevBackend:
3486 value := CryptodevBackendProperties{}
3487 if err := json.Unmarshal(data, &value); err != nil {
3488 return err
3489 }
3490 s.Value = value
3491 case ObjectTypeCryptodevBackendBuiltin:
3492 value := CryptodevBackendProperties{}
3493 if err := json.Unmarshal(data, &value); err != nil {
3494 return err
3495 }
3496 s.Value = value
3497 case ObjectTypeCryptodevVhostUser:
3498 value := CryptodevVhostUserProperties{}
3499 if err := json.Unmarshal(data, &value); err != nil {
3500 return err
3501 }
3502 s.Value = value
3503 case ObjectTypeDbusVmstate:
3504 value := DBusVMStateProperties{}
3505 if err := json.Unmarshal(data, &value); err != nil {
3506 return err
3507 }
3508 s.Value = value
3509 case ObjectTypeFilterBuffer:
3510 value := FilterBufferProperties{}
3511 if err := json.Unmarshal(data, &value); err != nil {
3512 return err
3513 }
3514 s.Value = value
3515 case ObjectTypeFilterDump:
3516 value := FilterDumpProperties{}
3517 if err := json.Unmarshal(data, &value); err != nil {
3518 return err
3519 }
3520 s.Value = value
3521 case ObjectTypeFilterMirror:
3522 value := FilterMirrorProperties{}
3523 if err := json.Unmarshal(data, &value); err != nil {
3524 return err
3525 }
3526 s.Value = value
3527 case ObjectTypeFilterRedirector:
3528 value := FilterRedirectorProperties{}
3529 if err := json.Unmarshal(data, &value); err != nil {
3530 return err
3531 }
3532 s.Value = value
3533 case ObjectTypeFilterReplay:
3534 value := NetfilterProperties{}
3535 if err := json.Unmarshal(data, &value); err != nil {
3536 return err
3537 }
3538 s.Value = value
3539 case ObjectTypeFilterRewriter:
3540 value := FilterRewriterProperties{}
3541 if err := json.Unmarshal(data, &value); err != nil {
3542 return err
3543 }
3544 s.Value = value
3545 case ObjectTypeInputBarrier:
3546 value := InputBarrierProperties{}
3547 if err := json.Unmarshal(data, &value); err != nil {
3548 return err
3549 }
3550 s.Value = value
3551 case ObjectTypeInputLinux:
3552 value := InputLinuxProperties{}
3553 if err := json.Unmarshal(data, &value); err != nil {
3554 return err
3555 }
3556 s.Value = value
3557 case ObjectTypeIothread:
3558 value := IothreadProperties{}
3559 if err := json.Unmarshal(data, &value); err != nil {
3560 return err
3561 }
3562 s.Value = value
3563 case ObjectTypeMemoryBackendEpc:
3564 value := MemoryBackendEpcProperties{}
3565 if err := json.Unmarshal(data, &value); err != nil {
3566 return err
3567 }
3568 s.Value = value
3569 case ObjectTypeMemoryBackendFile:
3570 value := MemoryBackendFileProperties{}
3571 if err := json.Unmarshal(data, &value); err != nil {
3572 return err
3573 }
3574 s.Value = value
3575 case ObjectTypeMemoryBackendMemfd:
3576 value := MemoryBackendMemfdProperties{}
3577 if err := json.Unmarshal(data, &value); err != nil {
3578 return err
3579 }
3580 s.Value = value
3581 case ObjectTypeMemoryBackendRam:
3582 value := MemoryBackendProperties{}
3583 if err := json.Unmarshal(data, &value); err != nil {
3584 return err
3585 }
3586 s.Value = value
3587 case ObjectTypePrManagerHelper:
3588 value := PrManagerHelperProperties{}
3589 if err := json.Unmarshal(data, &value); err != nil {
3590 return err
3591 }
3592 s.Value = value
3593 case ObjectTypeQtest:
3594 value := QtestProperties{}
3595 if err := json.Unmarshal(data, &value); err != nil {
3596 return err
3597 }
3598 s.Value = value
3599 case ObjectTypeRngBuiltin:
3600 value := RngProperties{}
3601 if err := json.Unmarshal(data, &value); err != nil {
3602 return err
3603 }
3604 s.Value = value
3605 case ObjectTypeRngEgd:
3606 value := RngEgdProperties{}
3607 if err := json.Unmarshal(data, &value); err != nil {
3608 return err
3609 }
3610 s.Value = value
3611 case ObjectTypeRngRandom:
3612 value := RngRandomProperties{}
3613 if err := json.Unmarshal(data, &value); err != nil {
3614 return err
3615 }
3616 s.Value = value
3617 case ObjectTypeSecret:
3618 value := SecretProperties{}
3619 if err := json.Unmarshal(data, &value); err != nil {
3620 return err
3621 }
3622 s.Value = value
3623 case ObjectTypeSecret_Keyring:
3624 value := SecretKeyringProperties{}
3625 if err := json.Unmarshal(data, &value); err != nil {
3626 return err
3627 }
3628 s.Value = value
3629 case ObjectTypeSevGuest:
3630 value := SevGuestProperties{}
3631 if err := json.Unmarshal(data, &value); err != nil {
3632 return err
3633 }
3634 s.Value = value
3635 case ObjectTypeThrottleGroup:
3636 value := ThrottleGroupProperties{}
3637 if err := json.Unmarshal(data, &value); err != nil {
3638 return err
3639 }
3640 s.Value = value
3641 case ObjectTypeTlsCipherSuites:
3642 value := TlsCredsProperties{}
3643 if err := json.Unmarshal(data, &value); err != nil {
3644 return err
3645 }
3646 s.Value = value
3647 case ObjectTypeTlsCredsAnon:
3648 value := TlsCredsAnonProperties{}
3649 if err := json.Unmarshal(data, &value); err != nil {
3650 return err
3651 }
3652 s.Value = value
3653 case ObjectTypeTlsCredsPsk:
3654 value := TlsCredsPskProperties{}
3655 if err := json.Unmarshal(data, &value); err != nil {
3656 return err
3657 }
3658 s.Value = value
3659 case ObjectTypeTlsCredsX509:
3660 value := TlsCredsX509Properties{}
3661 if err := json.Unmarshal(data, &value); err != nil {
3662 return err
3663 }
3664 s.Value = value
3665 case ObjectTypeXRemoteObject:
3666 value := RemoteObjectProperties{}
3667 if err := json.Unmarshal(data, &value); err != nil {
3668 return err
3669 }
3670 s.Value = value
3671
3672 default:
3673 fmt.Println("Failed to decode ObjectOptions", base.QomType)
3674 }
3675
3676 return nil
3677 }
3678
3679
3680
3681
3682 type CpuInfoFastBase struct {
3683 CpuIndex int64 `json:"cpu-index"`
3684 QomPath string `json:"qom-path"`
3685 ThreadId int64 `json:"thread-id"`
3686 Props *CpuInstanceProperties `json:"props,omitempty"`
3687 Target SysEmuTarget `json:"target"`
3688 }
3689
3690
3691
3692
3693 type CpuInfoFast struct {
3694
3695 CpuInfoFastBase
3696
3697
3698 Value Any
3699 }
3700
3701 func (s CpuInfoFast) MarshalJSON() ([]byte, error) {
3702 base, err := json.Marshal(s.CpuInfoFastBase)
3703 if err != nil {
3704 return nil, err
3705 }
3706
3707 typestr := fmt.Sprintf("%T", s.Value)
3708 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
3709
3710
3711
3712 if typestr == "<nil>" {
3713 return []byte(base), nil
3714 }
3715
3716
3717 if typestr != "CpuInfoS390" {
3718 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
3719 }
3720 value, err := json.Marshal(s.Value)
3721 if err != nil {
3722 return nil, err
3723 }
3724
3725
3726 if string(value) == "{}" {
3727 return []byte(base), nil
3728 }
3729
3730
3731
3732 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
3733 return []byte(result), nil
3734 }
3735
3736 func (s *CpuInfoFast) UnmarshalJSON(data []byte) error {
3737
3738 var base CpuInfoFastBase
3739 if err := json.Unmarshal(data, &base); err != nil {
3740 return err
3741 }
3742 s.CpuInfoFastBase = base
3743
3744 switch base.Target {
3745 case SysEmuTargetS390X:
3746 value := CpuInfoS390{}
3747 if err := json.Unmarshal(data, &value); err != nil {
3748 return err
3749 }
3750 s.Value = value
3751
3752 default:
3753 fmt.Println("Failed to decode CpuInfoFast", base.Target)
3754 }
3755
3756 return nil
3757 }
3758
3759
3760
3761
3762 type NumaOptionsBase struct {
3763 Type NumaOptionsType `json:"type"`
3764 }
3765
3766
3767
3768
3769 type NumaOptions struct {
3770
3771 NumaOptionsBase
3772
3773
3774
3775
3776
3777
3778 Value Any
3779 }
3780
3781 func (s NumaOptions) MarshalJSON() ([]byte, error) {
3782 base, err := json.Marshal(s.NumaOptionsBase)
3783 if err != nil {
3784 return nil, err
3785 }
3786
3787 typestr := fmt.Sprintf("%T", s.Value)
3788 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
3789
3790
3791
3792 if typestr == "<nil>" {
3793 return []byte(base), nil
3794 }
3795
3796
3797 if typestr != "NumaCpuOptions" &&
3798 typestr != "NumaDistOptions" &&
3799 typestr != "NumaHmatCacheOptions" &&
3800 typestr != "NumaHmatLBOptions" &&
3801 typestr != "NumaNodeOptions" {
3802 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
3803 }
3804 value, err := json.Marshal(s.Value)
3805 if err != nil {
3806 return nil, err
3807 }
3808
3809
3810 if string(value) == "{}" {
3811 return []byte(base), nil
3812 }
3813
3814
3815
3816 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
3817 return []byte(result), nil
3818 }
3819
3820 func (s *NumaOptions) UnmarshalJSON(data []byte) error {
3821
3822 var base NumaOptionsBase
3823 if err := json.Unmarshal(data, &base); err != nil {
3824 return err
3825 }
3826 s.NumaOptionsBase = base
3827
3828 switch base.Type {
3829 case NumaOptionsTypeCpu:
3830 value := NumaCpuOptions{}
3831 if err := json.Unmarshal(data, &value); err != nil {
3832 return err
3833 }
3834 s.Value = value
3835 case NumaOptionsTypeDist:
3836 value := NumaDistOptions{}
3837 if err := json.Unmarshal(data, &value); err != nil {
3838 return err
3839 }
3840 s.Value = value
3841 case NumaOptionsTypeHmatCache:
3842 value := NumaHmatCacheOptions{}
3843 if err := json.Unmarshal(data, &value); err != nil {
3844 return err
3845 }
3846 s.Value = value
3847 case NumaOptionsTypeHmatLb:
3848 value := NumaHmatLBOptions{}
3849 if err := json.Unmarshal(data, &value); err != nil {
3850 return err
3851 }
3852 s.Value = value
3853 case NumaOptionsTypeNode:
3854 value := NumaNodeOptions{}
3855 if err := json.Unmarshal(data, &value); err != nil {
3856 return err
3857 }
3858 s.Value = value
3859
3860 default:
3861 fmt.Println("Failed to decode NumaOptions", base.Type)
3862 }
3863
3864 return nil
3865 }
3866
3867
3868
3869
3870
3871
3872
3873 type MemoryDeviceInfoBase struct {
3874 Type MemoryDeviceInfoKind `json:"type"`
3875 }
3876
3877
3878
3879
3880
3881
3882
3883 type MemoryDeviceInfo struct {
3884
3885 MemoryDeviceInfoBase
3886
3887
3888
3889
3890
3891
3892 Value Any
3893 }
3894
3895 func (s MemoryDeviceInfo) MarshalJSON() ([]byte, error) {
3896 base, err := json.Marshal(s.MemoryDeviceInfoBase)
3897 if err != nil {
3898 return nil, err
3899 }
3900
3901 typestr := fmt.Sprintf("%T", s.Value)
3902 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
3903
3904
3905
3906 if typestr == "<nil>" {
3907 return []byte(base), nil
3908 }
3909
3910
3911 if typestr != "PCDIMMDeviceInfoWrapper" &&
3912 typestr != "SgxEPCDeviceInfoWrapper" &&
3913 typestr != "VirtioMEMDeviceInfoWrapper" &&
3914 typestr != "VirtioPMEMDeviceInfoWrapper" {
3915 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
3916 }
3917 value, err := json.Marshal(s.Value)
3918 if err != nil {
3919 return nil, err
3920 }
3921
3922
3923 if string(value) == "{}" {
3924 return []byte(base), nil
3925 }
3926
3927
3928
3929 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
3930 return []byte(result), nil
3931 }
3932
3933 func (s *MemoryDeviceInfo) UnmarshalJSON(data []byte) error {
3934
3935 var base MemoryDeviceInfoBase
3936 if err := json.Unmarshal(data, &base); err != nil {
3937 return err
3938 }
3939 s.MemoryDeviceInfoBase = base
3940
3941 switch base.Type {
3942 case MemoryDeviceInfoKindDimm:
3943 value := PCDIMMDeviceInfoWrapper{}
3944 if err := json.Unmarshal(data, &value); err != nil {
3945 return err
3946 }
3947 s.Value = value
3948 case MemoryDeviceInfoKindNvdimm:
3949 value := PCDIMMDeviceInfoWrapper{}
3950 if err := json.Unmarshal(data, &value); err != nil {
3951 return err
3952 }
3953 s.Value = value
3954 case MemoryDeviceInfoKindSgxEpc:
3955 value := SgxEPCDeviceInfoWrapper{}
3956 if err := json.Unmarshal(data, &value); err != nil {
3957 return err
3958 }
3959 s.Value = value
3960 case MemoryDeviceInfoKindVirtioMem:
3961 value := VirtioMEMDeviceInfoWrapper{}
3962 if err := json.Unmarshal(data, &value); err != nil {
3963 return err
3964 }
3965 s.Value = value
3966 case MemoryDeviceInfoKindVirtioPmem:
3967 value := VirtioPMEMDeviceInfoWrapper{}
3968 if err := json.Unmarshal(data, &value); err != nil {
3969 return err
3970 }
3971 s.Value = value
3972
3973 default:
3974 fmt.Println("Failed to decode MemoryDeviceInfo", base.Type)
3975 }
3976
3977 return nil
3978 }
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996 type YankInstanceBase struct {
3997 Type YankInstanceType `json:"type"`
3998 }
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016 type YankInstance struct {
4017
4018 YankInstanceBase
4019
4020
4021
4022 Value Any
4023 }
4024
4025 func (s YankInstance) MarshalJSON() ([]byte, error) {
4026 base, err := json.Marshal(s.YankInstanceBase)
4027 if err != nil {
4028 return nil, err
4029 }
4030
4031 typestr := fmt.Sprintf("%T", s.Value)
4032 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
4033
4034
4035
4036 if typestr == "<nil>" {
4037 return []byte(base), nil
4038 }
4039
4040
4041 if typestr != "YankInstanceBlockNode" &&
4042 typestr != "YankInstanceChardev" {
4043 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
4044 }
4045 value, err := json.Marshal(s.Value)
4046 if err != nil {
4047 return nil, err
4048 }
4049
4050
4051 if string(value) == "{}" {
4052 return []byte(base), nil
4053 }
4054
4055
4056
4057 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
4058 return []byte(result), nil
4059 }
4060
4061 func (s *YankInstance) UnmarshalJSON(data []byte) error {
4062
4063 var base YankInstanceBase
4064 if err := json.Unmarshal(data, &base); err != nil {
4065 return err
4066 }
4067 s.YankInstanceBase = base
4068
4069 switch base.Type {
4070 case YankInstanceTypeBlockNode:
4071 value := YankInstanceBlockNode{}
4072 if err := json.Unmarshal(data, &value); err != nil {
4073 return err
4074 }
4075 s.Value = value
4076 case YankInstanceTypeChardev:
4077 value := YankInstanceChardev{}
4078 if err := json.Unmarshal(data, &value); err != nil {
4079 return err
4080 }
4081 s.Value = value
4082
4083 default:
4084 fmt.Println("Failed to decode YankInstance", base.Type)
4085 }
4086
4087 return nil
4088 }
4089
4090
4091
4092
4093 type AudiodevBase struct {
4094 Id string `json:"id"`
4095 Driver AudiodevDriver `json:"driver"`
4096 TimerPeriod *uint32 `json:"timer-period,omitempty"`
4097 }
4098
4099
4100
4101
4102 type Audiodev struct {
4103
4104 AudiodevBase
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117 Value Any
4118 }
4119
4120 func (s Audiodev) MarshalJSON() ([]byte, error) {
4121 base, err := json.Marshal(s.AudiodevBase)
4122 if err != nil {
4123 return nil, err
4124 }
4125
4126 typestr := fmt.Sprintf("%T", s.Value)
4127 typestr = typestr[strings.LastIndex(typestr, ".")+1:]
4128
4129
4130
4131 if typestr == "<nil>" {
4132 return []byte(base), nil
4133 }
4134
4135
4136 if typestr != "AudiodevAlsaOptions" &&
4137 typestr != "AudiodevCoreaudioOptions" &&
4138 typestr != "AudiodevGenericOptions" &&
4139 typestr != "AudiodevDsoundOptions" &&
4140 typestr != "AudiodevJackOptions" &&
4141 typestr != "AudiodevOssOptions" &&
4142 typestr != "AudiodevPaOptions" &&
4143 typestr != "AudiodevSdlOptions" &&
4144 typestr != "AudiodevWavOptions" {
4145 return nil, errors.New(fmt.Sprintf("Type is not supported: %s", typestr))
4146 }
4147 value, err := json.Marshal(s.Value)
4148 if err != nil {
4149 return nil, err
4150 }
4151
4152
4153 if string(value) == "{}" {
4154 return []byte(base), nil
4155 }
4156
4157
4158
4159 result := fmt.Sprintf("%s,%s", base[:len(base)-1], value[1:])
4160 return []byte(result), nil
4161 }
4162
4163 func (s *Audiodev) UnmarshalJSON(data []byte) error {
4164
4165 var base AudiodevBase
4166 if err := json.Unmarshal(data, &base); err != nil {
4167 return err
4168 }
4169 s.AudiodevBase = base
4170
4171 switch base.Driver {
4172 case AudiodevDriverAlsa:
4173 value := AudiodevAlsaOptions{}
4174 if err := json.Unmarshal(data, &value); err != nil {
4175 return err
4176 }
4177 s.Value = value
4178 case AudiodevDriverCoreaudio:
4179 value := AudiodevCoreaudioOptions{}
4180 if err := json.Unmarshal(data, &value); err != nil {
4181 return err
4182 }
4183 s.Value = value
4184 case AudiodevDriverDbus:
4185 value := AudiodevGenericOptions{}
4186 if err := json.Unmarshal(data, &value); err != nil {
4187 return err
4188 }
4189 s.Value = value
4190 case AudiodevDriverDsound:
4191 value := AudiodevDsoundOptions{}
4192 if err := json.Unmarshal(data, &value); err != nil {
4193 return err
4194 }
4195 s.Value = value
4196 case AudiodevDriverJack:
4197 value := AudiodevJackOptions{}
4198 if err := json.Unmarshal(data, &value); err != nil {
4199 return err
4200 }
4201 s.Value = value
4202 case AudiodevDriverNone:
4203 value := AudiodevGenericOptions{}
4204 if err := json.Unmarshal(data, &value); err != nil {
4205 return err
4206 }
4207 s.Value = value
4208 case AudiodevDriverOss:
4209 value := AudiodevOssOptions{}
4210 if err := json.Unmarshal(data, &value); err != nil {
4211 return err
4212 }
4213 s.Value = value
4214 case AudiodevDriverPa:
4215 value := AudiodevPaOptions{}
4216 if err := json.Unmarshal(data, &value); err != nil {
4217 return err
4218 }
4219 s.Value = value
4220 case AudiodevDriverSdl:
4221 value := AudiodevSdlOptions{}
4222 if err := json.Unmarshal(data, &value); err != nil {
4223 return err
4224 }
4225 s.Value = value
4226 case AudiodevDriverSpice:
4227 value := AudiodevGenericOptions{}
4228 if err := json.Unmarshal(data, &value); err != nil {
4229 return err
4230 }
4231 s.Value = value
4232 case AudiodevDriverWav:
4233 value := AudiodevWavOptions{}
4234 if err := json.Unmarshal(data, &value); err != nil {
4235 return err
4236 }
4237 s.Value = value
4238
4239 default:
4240 fmt.Println("Failed to decode Audiodev", base.Driver)
4241 }
4242
4243 return nil
4244 }
4245
View as plain text