...

Source file src/victortoso.com/qapi-go/pkg/qapi/enums.go

Documentation: victortoso.com/qapi-go/pkg/qapi

     1  package qapi
     2  
     3  import (
     4  	"encoding/json"
     5  	"errors"
     6  	"fmt"
     7  )
     8  
     9  // No documentation available
    10  type QType int32
    11  
    12  const (
    13  	QTypeNone QType = iota
    14  	QTypeQnull
    15  	QTypeQnum
    16  	QTypeQstring
    17  	QTypeQdict
    18  	QTypeQlist
    19  	QTypeQbool
    20  )
    21  
    22  func (s QType) MarshalJSON() ([]byte, error) {
    23  	switch s {
    24  	case QTypeNone:
    25  		return []byte(`"none"`), nil
    26  	case QTypeQnull:
    27  		return []byte(`"qnull"`), nil
    28  	case QTypeQnum:
    29  		return []byte(`"qnum"`), nil
    30  	case QTypeQstring:
    31  		return []byte(`"qstring"`), nil
    32  	case QTypeQdict:
    33  		return []byte(`"qdict"`), nil
    34  	case QTypeQlist:
    35  		return []byte(`"qlist"`), nil
    36  	case QTypeQbool:
    37  		return []byte(`"qbool"`), nil
    38  	default:
    39  		fmt.Println("Failed to decode QType", s)
    40  	}
    41  	return nil, errors.New("Failed")
    42  }
    43  
    44  func (s *QType) UnmarshalJSON(data []byte) error {
    45  	var name string
    46  
    47  	if err := json.Unmarshal(data, &name); err != nil {
    48  		return err
    49  	}
    50  
    51  	switch name {
    52  	case "none":
    53  		(*s) = QTypeNone
    54  	case "qnull":
    55  		(*s) = QTypeQnull
    56  	case "qnum":
    57  		(*s) = QTypeQnum
    58  	case "qstring":
    59  		(*s) = QTypeQstring
    60  	case "qdict":
    61  		(*s) = QTypeQdict
    62  	case "qlist":
    63  		(*s) = QTypeQlist
    64  	case "qbool":
    65  		(*s) = QTypeQbool
    66  	default:
    67  		fmt.Println("Failed to decode QType", *s)
    68  	}
    69  	return nil
    70  }
    71  
    72  // QEMU error classes
    73  //
    74  // Since: 1.2
    75  type QapiErrorClass int32
    76  
    77  const (
    78  	QapiErrorClassGenericerror    QapiErrorClass = iota
    79  	QapiErrorClassCommandnotfound                // the requested command has not been found
    80  	QapiErrorClassDevicenotactive                // a device has failed to be become active
    81  	QapiErrorClassDevicenotfound                 // the requested device has not been found
    82  	QapiErrorClassKvmmissingcap                  // the requested operation can't be fulfilled because a required KVM capability is missing
    83  )
    84  
    85  func (s QapiErrorClass) MarshalJSON() ([]byte, error) {
    86  	switch s {
    87  	case QapiErrorClassGenericerror:
    88  		return []byte(`"GenericError"`), nil
    89  	case QapiErrorClassCommandnotfound:
    90  		return []byte(`"CommandNotFound"`), nil
    91  	case QapiErrorClassDevicenotactive:
    92  		return []byte(`"DeviceNotActive"`), nil
    93  	case QapiErrorClassDevicenotfound:
    94  		return []byte(`"DeviceNotFound"`), nil
    95  	case QapiErrorClassKvmmissingcap:
    96  		return []byte(`"KVMMissingCap"`), nil
    97  	default:
    98  		fmt.Println("Failed to decode QapiErrorClass", s)
    99  	}
   100  	return nil, errors.New("Failed")
   101  }
   102  
   103  func (s *QapiErrorClass) UnmarshalJSON(data []byte) error {
   104  	var name string
   105  
   106  	if err := json.Unmarshal(data, &name); err != nil {
   107  		return err
   108  	}
   109  
   110  	switch name {
   111  	case "GenericError":
   112  		(*s) = QapiErrorClassGenericerror
   113  	case "CommandNotFound":
   114  		(*s) = QapiErrorClassCommandnotfound
   115  	case "DeviceNotActive":
   116  		(*s) = QapiErrorClassDevicenotactive
   117  	case "DeviceNotFound":
   118  		(*s) = QapiErrorClassDevicenotfound
   119  	case "KVMMissingCap":
   120  		(*s) = QapiErrorClassKvmmissingcap
   121  	default:
   122  		fmt.Println("Failed to decode QapiErrorClass", *s)
   123  	}
   124  	return nil
   125  }
   126  
   127  // An enumeration of the I/O operation types
   128  //
   129  // Since: 2.1
   130  type IoOperationType int32
   131  
   132  const (
   133  	IoOperationTypeRead  IoOperationType = iota
   134  	IoOperationTypeWrite                 // write operation
   135  )
   136  
   137  func (s IoOperationType) MarshalJSON() ([]byte, error) {
   138  	switch s {
   139  	case IoOperationTypeRead:
   140  		return []byte(`"read"`), nil
   141  	case IoOperationTypeWrite:
   142  		return []byte(`"write"`), nil
   143  	default:
   144  		fmt.Println("Failed to decode IoOperationType", s)
   145  	}
   146  	return nil, errors.New("Failed")
   147  }
   148  
   149  func (s *IoOperationType) UnmarshalJSON(data []byte) error {
   150  	var name string
   151  
   152  	if err := json.Unmarshal(data, &name); err != nil {
   153  		return err
   154  	}
   155  
   156  	switch name {
   157  	case "read":
   158  		(*s) = IoOperationTypeRead
   159  	case "write":
   160  		(*s) = IoOperationTypeWrite
   161  	default:
   162  		fmt.Println("Failed to decode IoOperationType", *s)
   163  	}
   164  	return nil
   165  }
   166  
   167  // An enumeration of three options: on, off, and auto
   168  //
   169  // Since: 2.2
   170  type OnOffAuto int32
   171  
   172  const (
   173  	OnOffAutoAuto OnOffAuto = iota
   174  	OnOffAutoOn             // Enabled
   175  	OnOffAutoOff            // Disabled
   176  )
   177  
   178  func (s OnOffAuto) MarshalJSON() ([]byte, error) {
   179  	switch s {
   180  	case OnOffAutoAuto:
   181  		return []byte(`"auto"`), nil
   182  	case OnOffAutoOn:
   183  		return []byte(`"on"`), nil
   184  	case OnOffAutoOff:
   185  		return []byte(`"off"`), nil
   186  	default:
   187  		fmt.Println("Failed to decode OnOffAuto", s)
   188  	}
   189  	return nil, errors.New("Failed")
   190  }
   191  
   192  func (s *OnOffAuto) UnmarshalJSON(data []byte) error {
   193  	var name string
   194  
   195  	if err := json.Unmarshal(data, &name); err != nil {
   196  		return err
   197  	}
   198  
   199  	switch name {
   200  	case "auto":
   201  		(*s) = OnOffAutoAuto
   202  	case "on":
   203  		(*s) = OnOffAutoOn
   204  	case "off":
   205  		(*s) = OnOffAutoOff
   206  	default:
   207  		fmt.Println("Failed to decode OnOffAuto", *s)
   208  	}
   209  	return nil
   210  }
   211  
   212  // An enumeration of three values: on, off, and split
   213  //
   214  // Since: 2.6
   215  type OnOffSplit int32
   216  
   217  const (
   218  	OnOffSplitOn    OnOffSplit = iota
   219  	OnOffSplitOff              // Disabled
   220  	OnOffSplitSplit            // Mixed
   221  )
   222  
   223  func (s OnOffSplit) MarshalJSON() ([]byte, error) {
   224  	switch s {
   225  	case OnOffSplitOn:
   226  		return []byte(`"on"`), nil
   227  	case OnOffSplitOff:
   228  		return []byte(`"off"`), nil
   229  	case OnOffSplitSplit:
   230  		return []byte(`"split"`), nil
   231  	default:
   232  		fmt.Println("Failed to decode OnOffSplit", s)
   233  	}
   234  	return nil, errors.New("Failed")
   235  }
   236  
   237  func (s *OnOffSplit) UnmarshalJSON(data []byte) error {
   238  	var name string
   239  
   240  	if err := json.Unmarshal(data, &name); err != nil {
   241  		return err
   242  	}
   243  
   244  	switch name {
   245  	case "on":
   246  		(*s) = OnOffSplitOn
   247  	case "off":
   248  		(*s) = OnOffSplitOff
   249  	case "split":
   250  		(*s) = OnOffSplitSplit
   251  	default:
   252  		fmt.Println("Failed to decode OnOffSplit", *s)
   253  	}
   254  	return nil
   255  }
   256  
   257  // An enumeration of options for specifying a PCI BAR
   258  //
   259  // Since: 2.12
   260  type OffAutoPCIBAR int32
   261  
   262  const (
   263  	OffAutoPCIBAROff  OffAutoPCIBAR = iota
   264  	OffAutoPCIBARAuto               // The PCI BAR for the feature is automatically selected
   265  	OffAutoPCIBARBar0               // PCI BAR0 is used for the feature
   266  	OffAutoPCIBARBar1               // PCI BAR1 is used for the feature
   267  	OffAutoPCIBARBar2               // PCI BAR2 is used for the feature
   268  	OffAutoPCIBARBar3               // PCI BAR3 is used for the feature
   269  	OffAutoPCIBARBar4               // PCI BAR4 is used for the feature
   270  	OffAutoPCIBARBar5               // PCI BAR5 is used for the feature
   271  )
   272  
   273  func (s OffAutoPCIBAR) MarshalJSON() ([]byte, error) {
   274  	switch s {
   275  	case OffAutoPCIBAROff:
   276  		return []byte(`"off"`), nil
   277  	case OffAutoPCIBARAuto:
   278  		return []byte(`"auto"`), nil
   279  	case OffAutoPCIBARBar0:
   280  		return []byte(`"bar0"`), nil
   281  	case OffAutoPCIBARBar1:
   282  		return []byte(`"bar1"`), nil
   283  	case OffAutoPCIBARBar2:
   284  		return []byte(`"bar2"`), nil
   285  	case OffAutoPCIBARBar3:
   286  		return []byte(`"bar3"`), nil
   287  	case OffAutoPCIBARBar4:
   288  		return []byte(`"bar4"`), nil
   289  	case OffAutoPCIBARBar5:
   290  		return []byte(`"bar5"`), nil
   291  	default:
   292  		fmt.Println("Failed to decode OffAutoPCIBAR", s)
   293  	}
   294  	return nil, errors.New("Failed")
   295  }
   296  
   297  func (s *OffAutoPCIBAR) UnmarshalJSON(data []byte) error {
   298  	var name string
   299  
   300  	if err := json.Unmarshal(data, &name); err != nil {
   301  		return err
   302  	}
   303  
   304  	switch name {
   305  	case "off":
   306  		(*s) = OffAutoPCIBAROff
   307  	case "auto":
   308  		(*s) = OffAutoPCIBARAuto
   309  	case "bar0":
   310  		(*s) = OffAutoPCIBARBar0
   311  	case "bar1":
   312  		(*s) = OffAutoPCIBARBar1
   313  	case "bar2":
   314  		(*s) = OffAutoPCIBARBar2
   315  	case "bar3":
   316  		(*s) = OffAutoPCIBARBar3
   317  	case "bar4":
   318  		(*s) = OffAutoPCIBARBar4
   319  	case "bar5":
   320  		(*s) = OffAutoPCIBARBar5
   321  	default:
   322  		fmt.Println("Failed to decode OffAutoPCIBAR", *s)
   323  	}
   324  	return nil
   325  }
   326  
   327  // An enumeration of PCIe link speeds in units of GT/s
   328  //
   329  // Since: 4.0
   330  type PCIELinkSpeed int32
   331  
   332  const (
   333  	PCIELinkSpeed2_5 PCIELinkSpeed = iota
   334  	PCIELinkSpeed5                 // 5.0GT/s
   335  	PCIELinkSpeed8                 // 8.0GT/s
   336  	PCIELinkSpeed16                // 16.0GT/s
   337  )
   338  
   339  func (s PCIELinkSpeed) MarshalJSON() ([]byte, error) {
   340  	switch s {
   341  	case PCIELinkSpeed2_5:
   342  		return []byte(`"2_5"`), nil
   343  	case PCIELinkSpeed5:
   344  		return []byte(`"5"`), nil
   345  	case PCIELinkSpeed8:
   346  		return []byte(`"8"`), nil
   347  	case PCIELinkSpeed16:
   348  		return []byte(`"16"`), nil
   349  	default:
   350  		fmt.Println("Failed to decode PCIELinkSpeed", s)
   351  	}
   352  	return nil, errors.New("Failed")
   353  }
   354  
   355  func (s *PCIELinkSpeed) UnmarshalJSON(data []byte) error {
   356  	var name string
   357  
   358  	if err := json.Unmarshal(data, &name); err != nil {
   359  		return err
   360  	}
   361  
   362  	switch name {
   363  	case "2_5":
   364  		(*s) = PCIELinkSpeed2_5
   365  	case "5":
   366  		(*s) = PCIELinkSpeed5
   367  	case "8":
   368  		(*s) = PCIELinkSpeed8
   369  	case "16":
   370  		(*s) = PCIELinkSpeed16
   371  	default:
   372  		fmt.Println("Failed to decode PCIELinkSpeed", *s)
   373  	}
   374  	return nil
   375  }
   376  
   377  // An enumeration of PCIe link width
   378  //
   379  // Since: 4.0
   380  type PCIELinkWidth int32
   381  
   382  const (
   383  	PCIELinkWidth1  PCIELinkWidth = iota
   384  	PCIELinkWidth2                // x2
   385  	PCIELinkWidth4                // x4
   386  	PCIELinkWidth8                // x8
   387  	PCIELinkWidth12               // x12
   388  	PCIELinkWidth16               // x16
   389  	PCIELinkWidth32               // x32
   390  )
   391  
   392  func (s PCIELinkWidth) MarshalJSON() ([]byte, error) {
   393  	switch s {
   394  	case PCIELinkWidth1:
   395  		return []byte(`"1"`), nil
   396  	case PCIELinkWidth2:
   397  		return []byte(`"2"`), nil
   398  	case PCIELinkWidth4:
   399  		return []byte(`"4"`), nil
   400  	case PCIELinkWidth8:
   401  		return []byte(`"8"`), nil
   402  	case PCIELinkWidth12:
   403  		return []byte(`"12"`), nil
   404  	case PCIELinkWidth16:
   405  		return []byte(`"16"`), nil
   406  	case PCIELinkWidth32:
   407  		return []byte(`"32"`), nil
   408  	default:
   409  		fmt.Println("Failed to decode PCIELinkWidth", s)
   410  	}
   411  	return nil, errors.New("Failed")
   412  }
   413  
   414  func (s *PCIELinkWidth) UnmarshalJSON(data []byte) error {
   415  	var name string
   416  
   417  	if err := json.Unmarshal(data, &name); err != nil {
   418  		return err
   419  	}
   420  
   421  	switch name {
   422  	case "1":
   423  		(*s) = PCIELinkWidth1
   424  	case "2":
   425  		(*s) = PCIELinkWidth2
   426  	case "4":
   427  		(*s) = PCIELinkWidth4
   428  	case "8":
   429  		(*s) = PCIELinkWidth8
   430  	case "12":
   431  		(*s) = PCIELinkWidth12
   432  	case "16":
   433  		(*s) = PCIELinkWidth16
   434  	case "32":
   435  		(*s) = PCIELinkWidth32
   436  	default:
   437  		fmt.Println("Failed to decode PCIELinkWidth", *s)
   438  	}
   439  	return nil
   440  }
   441  
   442  // Host memory policy types
   443  //
   444  // Since: 2.1
   445  type HostMemPolicy int32
   446  
   447  const (
   448  	HostMemPolicyDefault    HostMemPolicy = iota
   449  	HostMemPolicyPreferred                // set the preferred host nodes for allocation
   450  	HostMemPolicyBind                     // a strict policy that restricts memory allocation to the host nodes specified
   451  	HostMemPolicyInterleave               // memory allocations are interleaved across the set of host nodes specified
   452  )
   453  
   454  func (s HostMemPolicy) MarshalJSON() ([]byte, error) {
   455  	switch s {
   456  	case HostMemPolicyDefault:
   457  		return []byte(`"default"`), nil
   458  	case HostMemPolicyPreferred:
   459  		return []byte(`"preferred"`), nil
   460  	case HostMemPolicyBind:
   461  		return []byte(`"bind"`), nil
   462  	case HostMemPolicyInterleave:
   463  		return []byte(`"interleave"`), nil
   464  	default:
   465  		fmt.Println("Failed to decode HostMemPolicy", s)
   466  	}
   467  	return nil, errors.New("Failed")
   468  }
   469  
   470  func (s *HostMemPolicy) UnmarshalJSON(data []byte) error {
   471  	var name string
   472  
   473  	if err := json.Unmarshal(data, &name); err != nil {
   474  		return err
   475  	}
   476  
   477  	switch name {
   478  	case "default":
   479  		(*s) = HostMemPolicyDefault
   480  	case "preferred":
   481  		(*s) = HostMemPolicyPreferred
   482  	case "bind":
   483  		(*s) = HostMemPolicyBind
   484  	case "interleave":
   485  		(*s) = HostMemPolicyInterleave
   486  	default:
   487  		fmt.Println("Failed to decode HostMemPolicy", *s)
   488  	}
   489  	return nil
   490  }
   491  
   492  // Indicates whether a netfilter is attached to a netdev's transmit queue or
   493  // receive queue or both.
   494  //
   495  // Since: 2.5
   496  type NetFilterDirection int32
   497  
   498  const (
   499  	NetFilterDirectionAll NetFilterDirection = iota
   500  	NetFilterDirectionRx                     // the filter is attached to the receive queue of the netdev, where it will receive packets sent to the netdev.
   501  	NetFilterDirectionTx                     // the filter is attached to the transmit queue of the netdev, where it will receive packets sent by the netdev.
   502  )
   503  
   504  func (s NetFilterDirection) MarshalJSON() ([]byte, error) {
   505  	switch s {
   506  	case NetFilterDirectionAll:
   507  		return []byte(`"all"`), nil
   508  	case NetFilterDirectionRx:
   509  		return []byte(`"rx"`), nil
   510  	case NetFilterDirectionTx:
   511  		return []byte(`"tx"`), nil
   512  	default:
   513  		fmt.Println("Failed to decode NetFilterDirection", s)
   514  	}
   515  	return nil, errors.New("Failed")
   516  }
   517  
   518  func (s *NetFilterDirection) UnmarshalJSON(data []byte) error {
   519  	var name string
   520  
   521  	if err := json.Unmarshal(data, &name); err != nil {
   522  		return err
   523  	}
   524  
   525  	switch name {
   526  	case "all":
   527  		(*s) = NetFilterDirectionAll
   528  	case "rx":
   529  		(*s) = NetFilterDirectionRx
   530  	case "tx":
   531  		(*s) = NetFilterDirectionTx
   532  	default:
   533  		fmt.Println("Failed to decode NetFilterDirection", *s)
   534  	}
   535  	return nil
   536  }
   537  
   538  // Keys to toggle input-linux between host and guest.
   539  //
   540  // Since: 4.0
   541  type GrabToggleKeys int32
   542  
   543  const (
   544  	GrabToggleKeysCtrlCtrl GrabToggleKeys = iota
   545  	GrabToggleKeysAltAlt
   546  	GrabToggleKeysShiftShift
   547  	GrabToggleKeysMetaMeta
   548  	GrabToggleKeysScrolllock
   549  	GrabToggleKeysCtrlScrolllock
   550  )
   551  
   552  func (s GrabToggleKeys) MarshalJSON() ([]byte, error) {
   553  	switch s {
   554  	case GrabToggleKeysCtrlCtrl:
   555  		return []byte(`"ctrl-ctrl"`), nil
   556  	case GrabToggleKeysAltAlt:
   557  		return []byte(`"alt-alt"`), nil
   558  	case GrabToggleKeysShiftShift:
   559  		return []byte(`"shift-shift"`), nil
   560  	case GrabToggleKeysMetaMeta:
   561  		return []byte(`"meta-meta"`), nil
   562  	case GrabToggleKeysScrolllock:
   563  		return []byte(`"scrolllock"`), nil
   564  	case GrabToggleKeysCtrlScrolllock:
   565  		return []byte(`"ctrl-scrolllock"`), nil
   566  	default:
   567  		fmt.Println("Failed to decode GrabToggleKeys", s)
   568  	}
   569  	return nil, errors.New("Failed")
   570  }
   571  
   572  func (s *GrabToggleKeys) UnmarshalJSON(data []byte) error {
   573  	var name string
   574  
   575  	if err := json.Unmarshal(data, &name); err != nil {
   576  		return err
   577  	}
   578  
   579  	switch name {
   580  	case "ctrl-ctrl":
   581  		(*s) = GrabToggleKeysCtrlCtrl
   582  	case "alt-alt":
   583  		(*s) = GrabToggleKeysAltAlt
   584  	case "shift-shift":
   585  		(*s) = GrabToggleKeysShiftShift
   586  	case "meta-meta":
   587  		(*s) = GrabToggleKeysMetaMeta
   588  	case "scrolllock":
   589  		(*s) = GrabToggleKeysScrolllock
   590  	case "ctrl-scrolllock":
   591  		(*s) = GrabToggleKeysCtrlScrolllock
   592  	default:
   593  		fmt.Println("Failed to decode GrabToggleKeys", *s)
   594  	}
   595  	return nil
   596  }
   597  
   598  // The network address family
   599  //
   600  // Since: 2.1
   601  type NetworkAddressFamily int32
   602  
   603  const (
   604  	NetworkAddressFamilyIpv4    NetworkAddressFamily = iota
   605  	NetworkAddressFamilyIpv6                         // IPV6 family
   606  	NetworkAddressFamilyUnix                         // unix socket
   607  	NetworkAddressFamilyVsock                        // vsock family (since 2.8)
   608  	NetworkAddressFamilyUnknown                      // otherwise
   609  )
   610  
   611  func (s NetworkAddressFamily) MarshalJSON() ([]byte, error) {
   612  	switch s {
   613  	case NetworkAddressFamilyIpv4:
   614  		return []byte(`"ipv4"`), nil
   615  	case NetworkAddressFamilyIpv6:
   616  		return []byte(`"ipv6"`), nil
   617  	case NetworkAddressFamilyUnix:
   618  		return []byte(`"unix"`), nil
   619  	case NetworkAddressFamilyVsock:
   620  		return []byte(`"vsock"`), nil
   621  	case NetworkAddressFamilyUnknown:
   622  		return []byte(`"unknown"`), nil
   623  	default:
   624  		fmt.Println("Failed to decode NetworkAddressFamily", s)
   625  	}
   626  	return nil, errors.New("Failed")
   627  }
   628  
   629  func (s *NetworkAddressFamily) UnmarshalJSON(data []byte) error {
   630  	var name string
   631  
   632  	if err := json.Unmarshal(data, &name); err != nil {
   633  		return err
   634  	}
   635  
   636  	switch name {
   637  	case "ipv4":
   638  		(*s) = NetworkAddressFamilyIpv4
   639  	case "ipv6":
   640  		(*s) = NetworkAddressFamilyIpv6
   641  	case "unix":
   642  		(*s) = NetworkAddressFamilyUnix
   643  	case "vsock":
   644  		(*s) = NetworkAddressFamilyVsock
   645  	case "unknown":
   646  		(*s) = NetworkAddressFamilyUnknown
   647  	default:
   648  		fmt.Println("Failed to decode NetworkAddressFamily", *s)
   649  	}
   650  	return nil
   651  }
   652  
   653  // Available SocketAddress types
   654  //
   655  // Since: 2.9
   656  type SocketAddressType int32
   657  
   658  const (
   659  	SocketAddressTypeInet  SocketAddressType = iota
   660  	SocketAddressTypeUnix                    // Unix domain socket
   661  	SocketAddressTypeVsock                   // VMCI address
   662  	SocketAddressTypeFd                      // decimal is for file descriptor number, otherwise a file descriptor name. Named file descriptors are permitted in monitor commands, in combination with the 'getfd' command. Decimal file descriptors are permitted at startup or other contexts where no monitor context is active.
   663  )
   664  
   665  func (s SocketAddressType) MarshalJSON() ([]byte, error) {
   666  	switch s {
   667  	case SocketAddressTypeInet:
   668  		return []byte(`"inet"`), nil
   669  	case SocketAddressTypeUnix:
   670  		return []byte(`"unix"`), nil
   671  	case SocketAddressTypeVsock:
   672  		return []byte(`"vsock"`), nil
   673  	case SocketAddressTypeFd:
   674  		return []byte(`"fd"`), nil
   675  	default:
   676  		fmt.Println("Failed to decode SocketAddressType", s)
   677  	}
   678  	return nil, errors.New("Failed")
   679  }
   680  
   681  func (s *SocketAddressType) UnmarshalJSON(data []byte) error {
   682  	var name string
   683  
   684  	if err := json.Unmarshal(data, &name); err != nil {
   685  		return err
   686  	}
   687  
   688  	switch name {
   689  	case "inet":
   690  		(*s) = SocketAddressTypeInet
   691  	case "unix":
   692  		(*s) = SocketAddressTypeUnix
   693  	case "vsock":
   694  		(*s) = SocketAddressTypeVsock
   695  	case "fd":
   696  		(*s) = SocketAddressTypeFd
   697  	default:
   698  		fmt.Println("Failed to decode SocketAddressType", *s)
   699  	}
   700  	return nil
   701  }
   702  
   703  // An enumeration of VM run states.
   704  type RunState int32
   705  
   706  const (
   707  	RunStateDebug         RunState = iota
   708  	RunStateInmigrate              // guest is paused waiting for an incoming migration. Note that this state does not tell whether the machine will start at the end of the migration. This depends on the command-line -S option and any invocation of 'stop' or 'cont' that has happened since QEMU was started.
   709  	RunStateInternalError          // An internal error that prevents further guest execution has occurred
   710  	RunStateIoError                // the last IOP has failed and the device is configured to pause on I/O errors
   711  	RunStatePaused                 // guest has been paused via the 'stop' command
   712  	RunStatePostmigrate            // guest is paused following a successful 'migrate'
   713  	RunStatePrelaunch              // QEMU was started with -S and guest has not started
   714  	RunStateFinishMigrate          // guest is paused to finish the migration process
   715  	RunStateRestoreVm              // guest is paused to restore VM state
   716  	RunStateRunning                // guest is actively running
   717  	RunStateSaveVm                 // guest is paused to save the VM state
   718  	RunStateShutdown               // guest is shut down (and -no-shutdown is in use)
   719  	RunStateSuspended              // guest is suspended (ACPI S3)
   720  	RunStateWatchdog               // the watchdog action is configured to pause and has been triggered
   721  	RunStateGuestPanicked          // guest has been panicked as a result of guest OS panic
   722  	RunStateColo                   // guest is paused to save/restore VM state under colo checkpoint, VM can not get into this state unless colo capability is enabled for migration. (since 2.8)
   723  )
   724  
   725  func (s RunState) MarshalJSON() ([]byte, error) {
   726  	switch s {
   727  	case RunStateDebug:
   728  		return []byte(`"debug"`), nil
   729  	case RunStateInmigrate:
   730  		return []byte(`"inmigrate"`), nil
   731  	case RunStateInternalError:
   732  		return []byte(`"internal-error"`), nil
   733  	case RunStateIoError:
   734  		return []byte(`"io-error"`), nil
   735  	case RunStatePaused:
   736  		return []byte(`"paused"`), nil
   737  	case RunStatePostmigrate:
   738  		return []byte(`"postmigrate"`), nil
   739  	case RunStatePrelaunch:
   740  		return []byte(`"prelaunch"`), nil
   741  	case RunStateFinishMigrate:
   742  		return []byte(`"finish-migrate"`), nil
   743  	case RunStateRestoreVm:
   744  		return []byte(`"restore-vm"`), nil
   745  	case RunStateRunning:
   746  		return []byte(`"running"`), nil
   747  	case RunStateSaveVm:
   748  		return []byte(`"save-vm"`), nil
   749  	case RunStateShutdown:
   750  		return []byte(`"shutdown"`), nil
   751  	case RunStateSuspended:
   752  		return []byte(`"suspended"`), nil
   753  	case RunStateWatchdog:
   754  		return []byte(`"watchdog"`), nil
   755  	case RunStateGuestPanicked:
   756  		return []byte(`"guest-panicked"`), nil
   757  	case RunStateColo:
   758  		return []byte(`"colo"`), nil
   759  	default:
   760  		fmt.Println("Failed to decode RunState", s)
   761  	}
   762  	return nil, errors.New("Failed")
   763  }
   764  
   765  func (s *RunState) UnmarshalJSON(data []byte) error {
   766  	var name string
   767  
   768  	if err := json.Unmarshal(data, &name); err != nil {
   769  		return err
   770  	}
   771  
   772  	switch name {
   773  	case "debug":
   774  		(*s) = RunStateDebug
   775  	case "inmigrate":
   776  		(*s) = RunStateInmigrate
   777  	case "internal-error":
   778  		(*s) = RunStateInternalError
   779  	case "io-error":
   780  		(*s) = RunStateIoError
   781  	case "paused":
   782  		(*s) = RunStatePaused
   783  	case "postmigrate":
   784  		(*s) = RunStatePostmigrate
   785  	case "prelaunch":
   786  		(*s) = RunStatePrelaunch
   787  	case "finish-migrate":
   788  		(*s) = RunStateFinishMigrate
   789  	case "restore-vm":
   790  		(*s) = RunStateRestoreVm
   791  	case "running":
   792  		(*s) = RunStateRunning
   793  	case "save-vm":
   794  		(*s) = RunStateSaveVm
   795  	case "shutdown":
   796  		(*s) = RunStateShutdown
   797  	case "suspended":
   798  		(*s) = RunStateSuspended
   799  	case "watchdog":
   800  		(*s) = RunStateWatchdog
   801  	case "guest-panicked":
   802  		(*s) = RunStateGuestPanicked
   803  	case "colo":
   804  		(*s) = RunStateColo
   805  	default:
   806  		fmt.Println("Failed to decode RunState", *s)
   807  	}
   808  	return nil
   809  }
   810  
   811  // An enumeration of reasons for a Shutdown.
   812  type ShutdownCause int32
   813  
   814  const (
   815  	ShutdownCauseNone               ShutdownCause = iota
   816  	ShutdownCauseHostError                        // An error prevents further use of guest
   817  	ShutdownCauseHostQmpQuit                      // Reaction to the QMP command 'quit'
   818  	ShutdownCauseHostQmpSystemReset               // Reaction to the QMP command 'system_reset'
   819  	ShutdownCauseHostSignal                       // Reaction to a signal, such as SIGINT
   820  	ShutdownCauseHostUi                           // Reaction to a UI event, like window close
   821  	ShutdownCauseGuestShutdown                    // Guest shutdown/suspend request, via ACPI or other hardware-specific means
   822  	ShutdownCauseGuestReset                       // Guest reset request, and command line turns that into a shutdown
   823  	ShutdownCauseGuestPanic                       // Guest panicked, and command line turns that into a shutdown
   824  	ShutdownCauseSubsystemReset                   // Partial guest reset that does not trigger QMP events and ignores --no-reboot. This is useful for sanitizing hypercalls on s390 that are used during kexec/kdump/boot
   825  )
   826  
   827  func (s ShutdownCause) MarshalJSON() ([]byte, error) {
   828  	switch s {
   829  	case ShutdownCauseNone:
   830  		return []byte(`"none"`), nil
   831  	case ShutdownCauseHostError:
   832  		return []byte(`"host-error"`), nil
   833  	case ShutdownCauseHostQmpQuit:
   834  		return []byte(`"host-qmp-quit"`), nil
   835  	case ShutdownCauseHostQmpSystemReset:
   836  		return []byte(`"host-qmp-system-reset"`), nil
   837  	case ShutdownCauseHostSignal:
   838  		return []byte(`"host-signal"`), nil
   839  	case ShutdownCauseHostUi:
   840  		return []byte(`"host-ui"`), nil
   841  	case ShutdownCauseGuestShutdown:
   842  		return []byte(`"guest-shutdown"`), nil
   843  	case ShutdownCauseGuestReset:
   844  		return []byte(`"guest-reset"`), nil
   845  	case ShutdownCauseGuestPanic:
   846  		return []byte(`"guest-panic"`), nil
   847  	case ShutdownCauseSubsystemReset:
   848  		return []byte(`"subsystem-reset"`), nil
   849  	default:
   850  		fmt.Println("Failed to decode ShutdownCause", s)
   851  	}
   852  	return nil, errors.New("Failed")
   853  }
   854  
   855  func (s *ShutdownCause) UnmarshalJSON(data []byte) error {
   856  	var name string
   857  
   858  	if err := json.Unmarshal(data, &name); err != nil {
   859  		return err
   860  	}
   861  
   862  	switch name {
   863  	case "none":
   864  		(*s) = ShutdownCauseNone
   865  	case "host-error":
   866  		(*s) = ShutdownCauseHostError
   867  	case "host-qmp-quit":
   868  		(*s) = ShutdownCauseHostQmpQuit
   869  	case "host-qmp-system-reset":
   870  		(*s) = ShutdownCauseHostQmpSystemReset
   871  	case "host-signal":
   872  		(*s) = ShutdownCauseHostSignal
   873  	case "host-ui":
   874  		(*s) = ShutdownCauseHostUi
   875  	case "guest-shutdown":
   876  		(*s) = ShutdownCauseGuestShutdown
   877  	case "guest-reset":
   878  		(*s) = ShutdownCauseGuestReset
   879  	case "guest-panic":
   880  		(*s) = ShutdownCauseGuestPanic
   881  	case "subsystem-reset":
   882  		(*s) = ShutdownCauseSubsystemReset
   883  	default:
   884  		fmt.Println("Failed to decode ShutdownCause", *s)
   885  	}
   886  	return nil
   887  }
   888  
   889  // An enumeration of the actions taken when the watchdog device's timer is
   890  // expired
   891  //
   892  // Since: 2.1
   893  type WatchdogAction int32
   894  
   895  const (
   896  	WatchdogActionReset     WatchdogAction = iota
   897  	WatchdogActionShutdown                 // system shutdown, note that it is similar to @powerdown, which tries to set to system status and notify guest
   898  	WatchdogActionPoweroff                 // system poweroff, the emulator program exits
   899  	WatchdogActionPause                    // system pauses, similar to @stop
   900  	WatchdogActionDebug                    // system enters debug state
   901  	WatchdogActionNone                     // nothing is done
   902  	WatchdogActionInjectNmi                // a non-maskable interrupt is injected into the first VCPU (all VCPUS on x86) (since 2.4)
   903  )
   904  
   905  func (s WatchdogAction) MarshalJSON() ([]byte, error) {
   906  	switch s {
   907  	case WatchdogActionReset:
   908  		return []byte(`"reset"`), nil
   909  	case WatchdogActionShutdown:
   910  		return []byte(`"shutdown"`), nil
   911  	case WatchdogActionPoweroff:
   912  		return []byte(`"poweroff"`), nil
   913  	case WatchdogActionPause:
   914  		return []byte(`"pause"`), nil
   915  	case WatchdogActionDebug:
   916  		return []byte(`"debug"`), nil
   917  	case WatchdogActionNone:
   918  		return []byte(`"none"`), nil
   919  	case WatchdogActionInjectNmi:
   920  		return []byte(`"inject-nmi"`), nil
   921  	default:
   922  		fmt.Println("Failed to decode WatchdogAction", s)
   923  	}
   924  	return nil, errors.New("Failed")
   925  }
   926  
   927  func (s *WatchdogAction) UnmarshalJSON(data []byte) error {
   928  	var name string
   929  
   930  	if err := json.Unmarshal(data, &name); err != nil {
   931  		return err
   932  	}
   933  
   934  	switch name {
   935  	case "reset":
   936  		(*s) = WatchdogActionReset
   937  	case "shutdown":
   938  		(*s) = WatchdogActionShutdown
   939  	case "poweroff":
   940  		(*s) = WatchdogActionPoweroff
   941  	case "pause":
   942  		(*s) = WatchdogActionPause
   943  	case "debug":
   944  		(*s) = WatchdogActionDebug
   945  	case "none":
   946  		(*s) = WatchdogActionNone
   947  	case "inject-nmi":
   948  		(*s) = WatchdogActionInjectNmi
   949  	default:
   950  		fmt.Println("Failed to decode WatchdogAction", *s)
   951  	}
   952  	return nil
   953  }
   954  
   955  // Possible QEMU actions upon guest reboot
   956  //
   957  // Since: 6.0
   958  type RebootAction int32
   959  
   960  const (
   961  	RebootActionReset    RebootAction = iota
   962  	RebootActionShutdown              // Shutdown the VM and exit, according to the shutdown action
   963  )
   964  
   965  func (s RebootAction) MarshalJSON() ([]byte, error) {
   966  	switch s {
   967  	case RebootActionReset:
   968  		return []byte(`"reset"`), nil
   969  	case RebootActionShutdown:
   970  		return []byte(`"shutdown"`), nil
   971  	default:
   972  		fmt.Println("Failed to decode RebootAction", s)
   973  	}
   974  	return nil, errors.New("Failed")
   975  }
   976  
   977  func (s *RebootAction) UnmarshalJSON(data []byte) error {
   978  	var name string
   979  
   980  	if err := json.Unmarshal(data, &name); err != nil {
   981  		return err
   982  	}
   983  
   984  	switch name {
   985  	case "reset":
   986  		(*s) = RebootActionReset
   987  	case "shutdown":
   988  		(*s) = RebootActionShutdown
   989  	default:
   990  		fmt.Println("Failed to decode RebootAction", *s)
   991  	}
   992  	return nil
   993  }
   994  
   995  // Possible QEMU actions upon guest shutdown
   996  //
   997  // Since: 6.0
   998  type ShutdownAction int32
   999  
  1000  const (
  1001  	ShutdownActionPoweroff ShutdownAction = iota
  1002  	ShutdownActionPause                   // pause the VM#
  1003  )
  1004  
  1005  func (s ShutdownAction) MarshalJSON() ([]byte, error) {
  1006  	switch s {
  1007  	case ShutdownActionPoweroff:
  1008  		return []byte(`"poweroff"`), nil
  1009  	case ShutdownActionPause:
  1010  		return []byte(`"pause"`), nil
  1011  	default:
  1012  		fmt.Println("Failed to decode ShutdownAction", s)
  1013  	}
  1014  	return nil, errors.New("Failed")
  1015  }
  1016  
  1017  func (s *ShutdownAction) UnmarshalJSON(data []byte) error {
  1018  	var name string
  1019  
  1020  	if err := json.Unmarshal(data, &name); err != nil {
  1021  		return err
  1022  	}
  1023  
  1024  	switch name {
  1025  	case "poweroff":
  1026  		(*s) = ShutdownActionPoweroff
  1027  	case "pause":
  1028  		(*s) = ShutdownActionPause
  1029  	default:
  1030  		fmt.Println("Failed to decode ShutdownAction", *s)
  1031  	}
  1032  	return nil
  1033  }
  1034  
  1035  // Since: 6.0
  1036  type PanicAction int32
  1037  
  1038  const (
  1039  	PanicActionPause    PanicAction = iota
  1040  	PanicActionShutdown             // Shutdown the VM and exit, according to the shutdown action
  1041  	PanicActionNone                 // Continue VM execution
  1042  )
  1043  
  1044  func (s PanicAction) MarshalJSON() ([]byte, error) {
  1045  	switch s {
  1046  	case PanicActionPause:
  1047  		return []byte(`"pause"`), nil
  1048  	case PanicActionShutdown:
  1049  		return []byte(`"shutdown"`), nil
  1050  	case PanicActionNone:
  1051  		return []byte(`"none"`), nil
  1052  	default:
  1053  		fmt.Println("Failed to decode PanicAction", s)
  1054  	}
  1055  	return nil, errors.New("Failed")
  1056  }
  1057  
  1058  func (s *PanicAction) UnmarshalJSON(data []byte) error {
  1059  	var name string
  1060  
  1061  	if err := json.Unmarshal(data, &name); err != nil {
  1062  		return err
  1063  	}
  1064  
  1065  	switch name {
  1066  	case "pause":
  1067  		(*s) = PanicActionPause
  1068  	case "shutdown":
  1069  		(*s) = PanicActionShutdown
  1070  	case "none":
  1071  		(*s) = PanicActionNone
  1072  	default:
  1073  		fmt.Println("Failed to decode PanicAction", *s)
  1074  	}
  1075  	return nil
  1076  }
  1077  
  1078  // An enumeration of the actions taken when guest OS panic is detected
  1079  //
  1080  // Since: 2.1 (poweroff since 2.8, run since 5.0)
  1081  type GuestPanicAction int32
  1082  
  1083  const (
  1084  	GuestPanicActionPause GuestPanicAction = iota
  1085  	GuestPanicActionPoweroff
  1086  	GuestPanicActionRun
  1087  )
  1088  
  1089  func (s GuestPanicAction) MarshalJSON() ([]byte, error) {
  1090  	switch s {
  1091  	case GuestPanicActionPause:
  1092  		return []byte(`"pause"`), nil
  1093  	case GuestPanicActionPoweroff:
  1094  		return []byte(`"poweroff"`), nil
  1095  	case GuestPanicActionRun:
  1096  		return []byte(`"run"`), nil
  1097  	default:
  1098  		fmt.Println("Failed to decode GuestPanicAction", s)
  1099  	}
  1100  	return nil, errors.New("Failed")
  1101  }
  1102  
  1103  func (s *GuestPanicAction) UnmarshalJSON(data []byte) error {
  1104  	var name string
  1105  
  1106  	if err := json.Unmarshal(data, &name); err != nil {
  1107  		return err
  1108  	}
  1109  
  1110  	switch name {
  1111  	case "pause":
  1112  		(*s) = GuestPanicActionPause
  1113  	case "poweroff":
  1114  		(*s) = GuestPanicActionPoweroff
  1115  	case "run":
  1116  		(*s) = GuestPanicActionRun
  1117  	default:
  1118  		fmt.Println("Failed to decode GuestPanicAction", *s)
  1119  	}
  1120  	return nil
  1121  }
  1122  
  1123  // An enumeration of the guest panic information types
  1124  //
  1125  // Since: 2.9
  1126  type GuestPanicInformationType int32
  1127  
  1128  const (
  1129  	GuestPanicInformationTypeHyperV GuestPanicInformationType = iota
  1130  	GuestPanicInformationTypeS390                             // s390 guest panic information type (Since: 2.12)
  1131  )
  1132  
  1133  func (s GuestPanicInformationType) MarshalJSON() ([]byte, error) {
  1134  	switch s {
  1135  	case GuestPanicInformationTypeHyperV:
  1136  		return []byte(`"hyper-v"`), nil
  1137  	case GuestPanicInformationTypeS390:
  1138  		return []byte(`"s390"`), nil
  1139  	default:
  1140  		fmt.Println("Failed to decode GuestPanicInformationType", s)
  1141  	}
  1142  	return nil, errors.New("Failed")
  1143  }
  1144  
  1145  func (s *GuestPanicInformationType) UnmarshalJSON(data []byte) error {
  1146  	var name string
  1147  
  1148  	if err := json.Unmarshal(data, &name); err != nil {
  1149  		return err
  1150  	}
  1151  
  1152  	switch name {
  1153  	case "hyper-v":
  1154  		(*s) = GuestPanicInformationTypeHyperV
  1155  	case "s390":
  1156  		(*s) = GuestPanicInformationTypeS390
  1157  	default:
  1158  		fmt.Println("Failed to decode GuestPanicInformationType", *s)
  1159  	}
  1160  	return nil
  1161  }
  1162  
  1163  // Reason why the CPU is in a crashed state.
  1164  //
  1165  // Since: 2.12
  1166  type S390CrashReason int32
  1167  
  1168  const (
  1169  	S390CrashReasonUnknown      S390CrashReason = iota
  1170  	S390CrashReasonDisabledWait                 // the CPU has entered a disabled wait state
  1171  	S390CrashReasonExtintLoop                   // clock comparator or cpu timer interrupt with new PSW enabled for external interrupts
  1172  	S390CrashReasonPgmintLoop                   // program interrupt with BAD new PSW
  1173  	S390CrashReasonOpintLoop                    // operation exception interrupt with invalid code at the program interrupt new PSW
  1174  )
  1175  
  1176  func (s S390CrashReason) MarshalJSON() ([]byte, error) {
  1177  	switch s {
  1178  	case S390CrashReasonUnknown:
  1179  		return []byte(`"unknown"`), nil
  1180  	case S390CrashReasonDisabledWait:
  1181  		return []byte(`"disabled-wait"`), nil
  1182  	case S390CrashReasonExtintLoop:
  1183  		return []byte(`"extint-loop"`), nil
  1184  	case S390CrashReasonPgmintLoop:
  1185  		return []byte(`"pgmint-loop"`), nil
  1186  	case S390CrashReasonOpintLoop:
  1187  		return []byte(`"opint-loop"`), nil
  1188  	default:
  1189  		fmt.Println("Failed to decode S390CrashReason", s)
  1190  	}
  1191  	return nil, errors.New("Failed")
  1192  }
  1193  
  1194  func (s *S390CrashReason) UnmarshalJSON(data []byte) error {
  1195  	var name string
  1196  
  1197  	if err := json.Unmarshal(data, &name); err != nil {
  1198  		return err
  1199  	}
  1200  
  1201  	switch name {
  1202  	case "unknown":
  1203  		(*s) = S390CrashReasonUnknown
  1204  	case "disabled-wait":
  1205  		(*s) = S390CrashReasonDisabledWait
  1206  	case "extint-loop":
  1207  		(*s) = S390CrashReasonExtintLoop
  1208  	case "pgmint-loop":
  1209  		(*s) = S390CrashReasonPgmintLoop
  1210  	case "opint-loop":
  1211  		(*s) = S390CrashReasonOpintLoop
  1212  	default:
  1213  		fmt.Println("Failed to decode S390CrashReason", *s)
  1214  	}
  1215  	return nil
  1216  }
  1217  
  1218  // Hardware memory failure occurs, handled by recipient.
  1219  //
  1220  // Since: 5.2
  1221  type MemoryFailureRecipient int32
  1222  
  1223  const (
  1224  	MemoryFailureRecipientHypervisor MemoryFailureRecipient = iota
  1225  	MemoryFailureRecipientGuest                             // memory failure at guest memory,
  1226  )
  1227  
  1228  func (s MemoryFailureRecipient) MarshalJSON() ([]byte, error) {
  1229  	switch s {
  1230  	case MemoryFailureRecipientHypervisor:
  1231  		return []byte(`"hypervisor"`), nil
  1232  	case MemoryFailureRecipientGuest:
  1233  		return []byte(`"guest"`), nil
  1234  	default:
  1235  		fmt.Println("Failed to decode MemoryFailureRecipient", s)
  1236  	}
  1237  	return nil, errors.New("Failed")
  1238  }
  1239  
  1240  func (s *MemoryFailureRecipient) UnmarshalJSON(data []byte) error {
  1241  	var name string
  1242  
  1243  	if err := json.Unmarshal(data, &name); err != nil {
  1244  		return err
  1245  	}
  1246  
  1247  	switch name {
  1248  	case "hypervisor":
  1249  		(*s) = MemoryFailureRecipientHypervisor
  1250  	case "guest":
  1251  		(*s) = MemoryFailureRecipientGuest
  1252  	default:
  1253  		fmt.Println("Failed to decode MemoryFailureRecipient", *s)
  1254  	}
  1255  	return nil
  1256  }
  1257  
  1258  // Actions taken by QEMU in response to a hardware memory failure.
  1259  //
  1260  // Since: 5.2
  1261  type MemoryFailureAction int32
  1262  
  1263  const (
  1264  	MemoryFailureActionIgnore MemoryFailureAction = iota
  1265  	MemoryFailureActionInject                     // memory failure occurred in guest memory, the guest enabled MCE handling mechanism, and QEMU could inject the MCE into the guest successfully.
  1266  	MemoryFailureActionFatal                      // the failure is unrecoverable. This occurs for action-required failures if the recipient is the hypervisor; QEMU will exit.
  1267  	MemoryFailureActionReset                      // the failure is unrecoverable but confined to the guest. This occurs if the recipient is a guest guest which is not ready to handle memory failures.
  1268  )
  1269  
  1270  func (s MemoryFailureAction) MarshalJSON() ([]byte, error) {
  1271  	switch s {
  1272  	case MemoryFailureActionIgnore:
  1273  		return []byte(`"ignore"`), nil
  1274  	case MemoryFailureActionInject:
  1275  		return []byte(`"inject"`), nil
  1276  	case MemoryFailureActionFatal:
  1277  		return []byte(`"fatal"`), nil
  1278  	case MemoryFailureActionReset:
  1279  		return []byte(`"reset"`), nil
  1280  	default:
  1281  		fmt.Println("Failed to decode MemoryFailureAction", s)
  1282  	}
  1283  	return nil, errors.New("Failed")
  1284  }
  1285  
  1286  func (s *MemoryFailureAction) UnmarshalJSON(data []byte) error {
  1287  	var name string
  1288  
  1289  	if err := json.Unmarshal(data, &name); err != nil {
  1290  		return err
  1291  	}
  1292  
  1293  	switch name {
  1294  	case "ignore":
  1295  		(*s) = MemoryFailureActionIgnore
  1296  	case "inject":
  1297  		(*s) = MemoryFailureActionInject
  1298  	case "fatal":
  1299  		(*s) = MemoryFailureActionFatal
  1300  	case "reset":
  1301  		(*s) = MemoryFailureActionReset
  1302  	default:
  1303  		fmt.Println("Failed to decode MemoryFailureAction", *s)
  1304  	}
  1305  	return nil
  1306  }
  1307  
  1308  // The type of network endpoint that will be using the credentials.
  1309  // Most types of credential require different setup / structures
  1310  // depending on whether they will be used in a server versus a
  1311  // client.
  1312  //
  1313  // Since: 2.5
  1314  type QCryptoTLSCredsEndpoint int32
  1315  
  1316  const (
  1317  	QCryptoTLSCredsEndpointClient QCryptoTLSCredsEndpoint = iota
  1318  	QCryptoTLSCredsEndpointServer                         // the network endpoint is acting as the server
  1319  )
  1320  
  1321  func (s QCryptoTLSCredsEndpoint) MarshalJSON() ([]byte, error) {
  1322  	switch s {
  1323  	case QCryptoTLSCredsEndpointClient:
  1324  		return []byte(`"client"`), nil
  1325  	case QCryptoTLSCredsEndpointServer:
  1326  		return []byte(`"server"`), nil
  1327  	default:
  1328  		fmt.Println("Failed to decode QCryptoTLSCredsEndpoint", s)
  1329  	}
  1330  	return nil, errors.New("Failed")
  1331  }
  1332  
  1333  func (s *QCryptoTLSCredsEndpoint) UnmarshalJSON(data []byte) error {
  1334  	var name string
  1335  
  1336  	if err := json.Unmarshal(data, &name); err != nil {
  1337  		return err
  1338  	}
  1339  
  1340  	switch name {
  1341  	case "client":
  1342  		(*s) = QCryptoTLSCredsEndpointClient
  1343  	case "server":
  1344  		(*s) = QCryptoTLSCredsEndpointServer
  1345  	default:
  1346  		fmt.Println("Failed to decode QCryptoTLSCredsEndpoint", *s)
  1347  	}
  1348  	return nil
  1349  }
  1350  
  1351  // The data format that the secret is provided in
  1352  //
  1353  // Since: 2.6
  1354  type QCryptoSecretFormat int32
  1355  
  1356  const (
  1357  	QCryptoSecretFormatRaw    QCryptoSecretFormat = iota
  1358  	QCryptoSecretFormatBase64                     // arbitrary base64 encoded binary data
  1359  )
  1360  
  1361  func (s QCryptoSecretFormat) MarshalJSON() ([]byte, error) {
  1362  	switch s {
  1363  	case QCryptoSecretFormatRaw:
  1364  		return []byte(`"raw"`), nil
  1365  	case QCryptoSecretFormatBase64:
  1366  		return []byte(`"base64"`), nil
  1367  	default:
  1368  		fmt.Println("Failed to decode QCryptoSecretFormat", s)
  1369  	}
  1370  	return nil, errors.New("Failed")
  1371  }
  1372  
  1373  func (s *QCryptoSecretFormat) UnmarshalJSON(data []byte) error {
  1374  	var name string
  1375  
  1376  	if err := json.Unmarshal(data, &name); err != nil {
  1377  		return err
  1378  	}
  1379  
  1380  	switch name {
  1381  	case "raw":
  1382  		(*s) = QCryptoSecretFormatRaw
  1383  	case "base64":
  1384  		(*s) = QCryptoSecretFormatBase64
  1385  	default:
  1386  		fmt.Println("Failed to decode QCryptoSecretFormat", *s)
  1387  	}
  1388  	return nil
  1389  }
  1390  
  1391  // The supported algorithms for computing content digests
  1392  //
  1393  // Since: 2.6
  1394  type QCryptoHashAlgorithm int32
  1395  
  1396  const (
  1397  	QCryptoHashAlgorithmMd5       QCryptoHashAlgorithm = iota
  1398  	QCryptoHashAlgorithmSha1                           // SHA-1. Should not be used in any new code, legacy compat only
  1399  	QCryptoHashAlgorithmSha224                         // SHA-224. (since 2.7)
  1400  	QCryptoHashAlgorithmSha256                         // SHA-256. Current recommended strong hash.
  1401  	QCryptoHashAlgorithmSha384                         // SHA-384. (since 2.7)
  1402  	QCryptoHashAlgorithmSha512                         // SHA-512. (since 2.7)
  1403  	QCryptoHashAlgorithmRipemd160                      // RIPEMD-160. (since 2.7)
  1404  )
  1405  
  1406  func (s QCryptoHashAlgorithm) MarshalJSON() ([]byte, error) {
  1407  	switch s {
  1408  	case QCryptoHashAlgorithmMd5:
  1409  		return []byte(`"md5"`), nil
  1410  	case QCryptoHashAlgorithmSha1:
  1411  		return []byte(`"sha1"`), nil
  1412  	case QCryptoHashAlgorithmSha224:
  1413  		return []byte(`"sha224"`), nil
  1414  	case QCryptoHashAlgorithmSha256:
  1415  		return []byte(`"sha256"`), nil
  1416  	case QCryptoHashAlgorithmSha384:
  1417  		return []byte(`"sha384"`), nil
  1418  	case QCryptoHashAlgorithmSha512:
  1419  		return []byte(`"sha512"`), nil
  1420  	case QCryptoHashAlgorithmRipemd160:
  1421  		return []byte(`"ripemd160"`), nil
  1422  	default:
  1423  		fmt.Println("Failed to decode QCryptoHashAlgorithm", s)
  1424  	}
  1425  	return nil, errors.New("Failed")
  1426  }
  1427  
  1428  func (s *QCryptoHashAlgorithm) UnmarshalJSON(data []byte) error {
  1429  	var name string
  1430  
  1431  	if err := json.Unmarshal(data, &name); err != nil {
  1432  		return err
  1433  	}
  1434  
  1435  	switch name {
  1436  	case "md5":
  1437  		(*s) = QCryptoHashAlgorithmMd5
  1438  	case "sha1":
  1439  		(*s) = QCryptoHashAlgorithmSha1
  1440  	case "sha224":
  1441  		(*s) = QCryptoHashAlgorithmSha224
  1442  	case "sha256":
  1443  		(*s) = QCryptoHashAlgorithmSha256
  1444  	case "sha384":
  1445  		(*s) = QCryptoHashAlgorithmSha384
  1446  	case "sha512":
  1447  		(*s) = QCryptoHashAlgorithmSha512
  1448  	case "ripemd160":
  1449  		(*s) = QCryptoHashAlgorithmRipemd160
  1450  	default:
  1451  		fmt.Println("Failed to decode QCryptoHashAlgorithm", *s)
  1452  	}
  1453  	return nil
  1454  }
  1455  
  1456  // The supported algorithms for content encryption ciphers
  1457  //
  1458  // Since: 2.6
  1459  type QCryptoCipherAlgorithm int32
  1460  
  1461  const (
  1462  	QCryptoCipherAlgorithmAes128     QCryptoCipherAlgorithm = iota
  1463  	QCryptoCipherAlgorithmAes192                            // AES with 192 bit / 24 byte keys
  1464  	QCryptoCipherAlgorithmAes256                            // AES with 256 bit / 32 byte keys
  1465  	QCryptoCipherAlgorithmDes                               // DES with 56 bit / 8 byte keys. Do not use except in VNC. (since 6.1)
  1466  	QCryptoCipherAlgorithm3Des                              // 3DES(EDE) with 192 bit / 24 byte keys (since 2.9)
  1467  	QCryptoCipherAlgorithmCast5128                          // Cast5 with 128 bit / 16 byte keys
  1468  	QCryptoCipherAlgorithmSerpent128                        // Serpent with 128 bit / 16 byte keys
  1469  	QCryptoCipherAlgorithmSerpent192                        // Serpent with 192 bit / 24 byte keys
  1470  	QCryptoCipherAlgorithmSerpent256                        // Serpent with 256 bit / 32 byte keys
  1471  	QCryptoCipherAlgorithmTwofish128                        // Twofish with 128 bit / 16 byte keys
  1472  	QCryptoCipherAlgorithmTwofish192                        // Twofish with 192 bit / 24 byte keys
  1473  	QCryptoCipherAlgorithmTwofish256                        // Twofish with 256 bit / 32 byte keys
  1474  )
  1475  
  1476  func (s QCryptoCipherAlgorithm) MarshalJSON() ([]byte, error) {
  1477  	switch s {
  1478  	case QCryptoCipherAlgorithmAes128:
  1479  		return []byte(`"aes-128"`), nil
  1480  	case QCryptoCipherAlgorithmAes192:
  1481  		return []byte(`"aes-192"`), nil
  1482  	case QCryptoCipherAlgorithmAes256:
  1483  		return []byte(`"aes-256"`), nil
  1484  	case QCryptoCipherAlgorithmDes:
  1485  		return []byte(`"des"`), nil
  1486  	case QCryptoCipherAlgorithm3Des:
  1487  		return []byte(`"3des"`), nil
  1488  	case QCryptoCipherAlgorithmCast5128:
  1489  		return []byte(`"cast5-128"`), nil
  1490  	case QCryptoCipherAlgorithmSerpent128:
  1491  		return []byte(`"serpent-128"`), nil
  1492  	case QCryptoCipherAlgorithmSerpent192:
  1493  		return []byte(`"serpent-192"`), nil
  1494  	case QCryptoCipherAlgorithmSerpent256:
  1495  		return []byte(`"serpent-256"`), nil
  1496  	case QCryptoCipherAlgorithmTwofish128:
  1497  		return []byte(`"twofish-128"`), nil
  1498  	case QCryptoCipherAlgorithmTwofish192:
  1499  		return []byte(`"twofish-192"`), nil
  1500  	case QCryptoCipherAlgorithmTwofish256:
  1501  		return []byte(`"twofish-256"`), nil
  1502  	default:
  1503  		fmt.Println("Failed to decode QCryptoCipherAlgorithm", s)
  1504  	}
  1505  	return nil, errors.New("Failed")
  1506  }
  1507  
  1508  func (s *QCryptoCipherAlgorithm) UnmarshalJSON(data []byte) error {
  1509  	var name string
  1510  
  1511  	if err := json.Unmarshal(data, &name); err != nil {
  1512  		return err
  1513  	}
  1514  
  1515  	switch name {
  1516  	case "aes-128":
  1517  		(*s) = QCryptoCipherAlgorithmAes128
  1518  	case "aes-192":
  1519  		(*s) = QCryptoCipherAlgorithmAes192
  1520  	case "aes-256":
  1521  		(*s) = QCryptoCipherAlgorithmAes256
  1522  	case "des":
  1523  		(*s) = QCryptoCipherAlgorithmDes
  1524  	case "3des":
  1525  		(*s) = QCryptoCipherAlgorithm3Des
  1526  	case "cast5-128":
  1527  		(*s) = QCryptoCipherAlgorithmCast5128
  1528  	case "serpent-128":
  1529  		(*s) = QCryptoCipherAlgorithmSerpent128
  1530  	case "serpent-192":
  1531  		(*s) = QCryptoCipherAlgorithmSerpent192
  1532  	case "serpent-256":
  1533  		(*s) = QCryptoCipherAlgorithmSerpent256
  1534  	case "twofish-128":
  1535  		(*s) = QCryptoCipherAlgorithmTwofish128
  1536  	case "twofish-192":
  1537  		(*s) = QCryptoCipherAlgorithmTwofish192
  1538  	case "twofish-256":
  1539  		(*s) = QCryptoCipherAlgorithmTwofish256
  1540  	default:
  1541  		fmt.Println("Failed to decode QCryptoCipherAlgorithm", *s)
  1542  	}
  1543  	return nil
  1544  }
  1545  
  1546  // The supported modes for content encryption ciphers
  1547  //
  1548  // Since: 2.6
  1549  type QCryptoCipherMode int32
  1550  
  1551  const (
  1552  	QCryptoCipherModeEcb QCryptoCipherMode = iota
  1553  	QCryptoCipherModeCbc                   // Cipher Block Chaining
  1554  	QCryptoCipherModeXts                   // XEX with tweaked code book and ciphertext stealing
  1555  	QCryptoCipherModeCtr                   // Counter (Since 2.8)
  1556  )
  1557  
  1558  func (s QCryptoCipherMode) MarshalJSON() ([]byte, error) {
  1559  	switch s {
  1560  	case QCryptoCipherModeEcb:
  1561  		return []byte(`"ecb"`), nil
  1562  	case QCryptoCipherModeCbc:
  1563  		return []byte(`"cbc"`), nil
  1564  	case QCryptoCipherModeXts:
  1565  		return []byte(`"xts"`), nil
  1566  	case QCryptoCipherModeCtr:
  1567  		return []byte(`"ctr"`), nil
  1568  	default:
  1569  		fmt.Println("Failed to decode QCryptoCipherMode", s)
  1570  	}
  1571  	return nil, errors.New("Failed")
  1572  }
  1573  
  1574  func (s *QCryptoCipherMode) UnmarshalJSON(data []byte) error {
  1575  	var name string
  1576  
  1577  	if err := json.Unmarshal(data, &name); err != nil {
  1578  		return err
  1579  	}
  1580  
  1581  	switch name {
  1582  	case "ecb":
  1583  		(*s) = QCryptoCipherModeEcb
  1584  	case "cbc":
  1585  		(*s) = QCryptoCipherModeCbc
  1586  	case "xts":
  1587  		(*s) = QCryptoCipherModeXts
  1588  	case "ctr":
  1589  		(*s) = QCryptoCipherModeCtr
  1590  	default:
  1591  		fmt.Println("Failed to decode QCryptoCipherMode", *s)
  1592  	}
  1593  	return nil
  1594  }
  1595  
  1596  // The supported algorithms for generating initialization
  1597  // vectors for full disk encryption. The 'plain' generator
  1598  // should not be used for disks with sector numbers larger
  1599  // than 2^32, except where compatibility with pre-existing
  1600  // Linux dm-crypt volumes is required.
  1601  //
  1602  // Since: 2.6
  1603  type QCryptoIVGenAlgorithm int32
  1604  
  1605  const (
  1606  	QCryptoIVGenAlgorithmPlain   QCryptoIVGenAlgorithm = iota
  1607  	QCryptoIVGenAlgorithmPlain64                       // 64-bit sector number
  1608  	QCryptoIVGenAlgorithmEssiv                         // 64-bit sector number encrypted with a hash of the encryption key
  1609  )
  1610  
  1611  func (s QCryptoIVGenAlgorithm) MarshalJSON() ([]byte, error) {
  1612  	switch s {
  1613  	case QCryptoIVGenAlgorithmPlain:
  1614  		return []byte(`"plain"`), nil
  1615  	case QCryptoIVGenAlgorithmPlain64:
  1616  		return []byte(`"plain64"`), nil
  1617  	case QCryptoIVGenAlgorithmEssiv:
  1618  		return []byte(`"essiv"`), nil
  1619  	default:
  1620  		fmt.Println("Failed to decode QCryptoIVGenAlgorithm", s)
  1621  	}
  1622  	return nil, errors.New("Failed")
  1623  }
  1624  
  1625  func (s *QCryptoIVGenAlgorithm) UnmarshalJSON(data []byte) error {
  1626  	var name string
  1627  
  1628  	if err := json.Unmarshal(data, &name); err != nil {
  1629  		return err
  1630  	}
  1631  
  1632  	switch name {
  1633  	case "plain":
  1634  		(*s) = QCryptoIVGenAlgorithmPlain
  1635  	case "plain64":
  1636  		(*s) = QCryptoIVGenAlgorithmPlain64
  1637  	case "essiv":
  1638  		(*s) = QCryptoIVGenAlgorithmEssiv
  1639  	default:
  1640  		fmt.Println("Failed to decode QCryptoIVGenAlgorithm", *s)
  1641  	}
  1642  	return nil
  1643  }
  1644  
  1645  // The supported full disk encryption formats
  1646  //
  1647  // Since: 2.6
  1648  type QCryptoBlockFormat int32
  1649  
  1650  const (
  1651  	QCryptoBlockFormatQcow QCryptoBlockFormat = iota
  1652  	QCryptoBlockFormatLuks                    // LUKS encryption format. Recommended for new images
  1653  )
  1654  
  1655  func (s QCryptoBlockFormat) MarshalJSON() ([]byte, error) {
  1656  	switch s {
  1657  	case QCryptoBlockFormatQcow:
  1658  		return []byte(`"qcow"`), nil
  1659  	case QCryptoBlockFormatLuks:
  1660  		return []byte(`"luks"`), nil
  1661  	default:
  1662  		fmt.Println("Failed to decode QCryptoBlockFormat", s)
  1663  	}
  1664  	return nil, errors.New("Failed")
  1665  }
  1666  
  1667  func (s *QCryptoBlockFormat) UnmarshalJSON(data []byte) error {
  1668  	var name string
  1669  
  1670  	if err := json.Unmarshal(data, &name); err != nil {
  1671  		return err
  1672  	}
  1673  
  1674  	switch name {
  1675  	case "qcow":
  1676  		(*s) = QCryptoBlockFormatQcow
  1677  	case "luks":
  1678  		(*s) = QCryptoBlockFormatLuks
  1679  	default:
  1680  		fmt.Println("Failed to decode QCryptoBlockFormat", *s)
  1681  	}
  1682  	return nil
  1683  }
  1684  
  1685  // Defines state of keyslots that are affected by the update
  1686  //
  1687  // Since: 5.1
  1688  type QCryptoBlockLUKSKeyslotState int32
  1689  
  1690  const (
  1691  	QCryptoBlockLUKSKeyslotStateActive   QCryptoBlockLUKSKeyslotState = iota
  1692  	QCryptoBlockLUKSKeyslotStateInactive                              // The slots are erased (contain garbage) and marked as inactive
  1693  )
  1694  
  1695  func (s QCryptoBlockLUKSKeyslotState) MarshalJSON() ([]byte, error) {
  1696  	switch s {
  1697  	case QCryptoBlockLUKSKeyslotStateActive:
  1698  		return []byte(`"active"`), nil
  1699  	case QCryptoBlockLUKSKeyslotStateInactive:
  1700  		return []byte(`"inactive"`), nil
  1701  	default:
  1702  		fmt.Println("Failed to decode QCryptoBlockLUKSKeyslotState", s)
  1703  	}
  1704  	return nil, errors.New("Failed")
  1705  }
  1706  
  1707  func (s *QCryptoBlockLUKSKeyslotState) UnmarshalJSON(data []byte) error {
  1708  	var name string
  1709  
  1710  	if err := json.Unmarshal(data, &name); err != nil {
  1711  		return err
  1712  	}
  1713  
  1714  	switch name {
  1715  	case "active":
  1716  		(*s) = QCryptoBlockLUKSKeyslotStateActive
  1717  	case "inactive":
  1718  		(*s) = QCryptoBlockLUKSKeyslotStateInactive
  1719  	default:
  1720  		fmt.Println("Failed to decode QCryptoBlockLUKSKeyslotState", *s)
  1721  	}
  1722  	return nil
  1723  }
  1724  
  1725  // Policy that BIOS should use to interpret cylinder/head/sector
  1726  // addresses.  Note that Bochs BIOS and SeaBIOS will not actually
  1727  // translate logical CHS to physical; instead, they will use logical
  1728  // block addressing.
  1729  //
  1730  // Since: 2.0
  1731  type BiosAtaTranslation int32
  1732  
  1733  const (
  1734  	BiosAtaTranslationAuto  BiosAtaTranslation = iota
  1735  	BiosAtaTranslationNone                     // The physical disk geometry is equal to the logical geometry.
  1736  	BiosAtaTranslationLba                      // Assume 63 sectors per track and one of 16, 32, 64, 128 or 255 heads (if fewer than 255 are enough to cover the whole disk with 1024 cylinders/head). The number of cylinders/head is then computed based on the number of sectors and heads.
  1737  	BiosAtaTranslationLarge                    // The number of cylinders per head is scaled down to 1024 by correspondingly scaling up the number of heads.
  1738  	BiosAtaTranslationRechs                    // Same as @large, but first convert a 16-head geometry to 15-head, by proportionally scaling up the number of cylinders/head.
  1739  )
  1740  
  1741  func (s BiosAtaTranslation) MarshalJSON() ([]byte, error) {
  1742  	switch s {
  1743  	case BiosAtaTranslationAuto:
  1744  		return []byte(`"auto"`), nil
  1745  	case BiosAtaTranslationNone:
  1746  		return []byte(`"none"`), nil
  1747  	case BiosAtaTranslationLba:
  1748  		return []byte(`"lba"`), nil
  1749  	case BiosAtaTranslationLarge:
  1750  		return []byte(`"large"`), nil
  1751  	case BiosAtaTranslationRechs:
  1752  		return []byte(`"rechs"`), nil
  1753  	default:
  1754  		fmt.Println("Failed to decode BiosAtaTranslation", s)
  1755  	}
  1756  	return nil, errors.New("Failed")
  1757  }
  1758  
  1759  func (s *BiosAtaTranslation) UnmarshalJSON(data []byte) error {
  1760  	var name string
  1761  
  1762  	if err := json.Unmarshal(data, &name); err != nil {
  1763  		return err
  1764  	}
  1765  
  1766  	switch name {
  1767  	case "auto":
  1768  		(*s) = BiosAtaTranslationAuto
  1769  	case "none":
  1770  		(*s) = BiosAtaTranslationNone
  1771  	case "lba":
  1772  		(*s) = BiosAtaTranslationLba
  1773  	case "large":
  1774  		(*s) = BiosAtaTranslationLarge
  1775  	case "rechs":
  1776  		(*s) = BiosAtaTranslationRechs
  1777  	default:
  1778  		fmt.Println("Failed to decode BiosAtaTranslation", *s)
  1779  	}
  1780  	return nil
  1781  }
  1782  
  1783  // Type of Floppy drive to be emulated by the Floppy Disk Controller.
  1784  //
  1785  // Since: 2.6
  1786  type FloppyDriveType int32
  1787  
  1788  const (
  1789  	FloppyDriveType144  FloppyDriveType = iota
  1790  	FloppyDriveType288                  // 2.88MB 3.5" drive
  1791  	FloppyDriveType120                  // 1.2MB 5.25" drive
  1792  	FloppyDriveTypeNone                 // No drive connected
  1793  	FloppyDriveTypeAuto                 // Automatically determined by inserted media at boot
  1794  )
  1795  
  1796  func (s FloppyDriveType) MarshalJSON() ([]byte, error) {
  1797  	switch s {
  1798  	case FloppyDriveType144:
  1799  		return []byte(`"144"`), nil
  1800  	case FloppyDriveType288:
  1801  		return []byte(`"288"`), nil
  1802  	case FloppyDriveType120:
  1803  		return []byte(`"120"`), nil
  1804  	case FloppyDriveTypeNone:
  1805  		return []byte(`"none"`), nil
  1806  	case FloppyDriveTypeAuto:
  1807  		return []byte(`"auto"`), nil
  1808  	default:
  1809  		fmt.Println("Failed to decode FloppyDriveType", s)
  1810  	}
  1811  	return nil, errors.New("Failed")
  1812  }
  1813  
  1814  func (s *FloppyDriveType) UnmarshalJSON(data []byte) error {
  1815  	var name string
  1816  
  1817  	if err := json.Unmarshal(data, &name); err != nil {
  1818  		return err
  1819  	}
  1820  
  1821  	switch name {
  1822  	case "144":
  1823  		(*s) = FloppyDriveType144
  1824  	case "288":
  1825  		(*s) = FloppyDriveType288
  1826  	case "120":
  1827  		(*s) = FloppyDriveType120
  1828  	case "none":
  1829  		(*s) = FloppyDriveTypeNone
  1830  	case "auto":
  1831  		(*s) = FloppyDriveTypeAuto
  1832  	default:
  1833  		fmt.Println("Failed to decode FloppyDriveType", *s)
  1834  	}
  1835  	return nil
  1836  }
  1837  
  1838  // Specifies the new read-only mode of a block device subject to the
  1839  // @blockdev-change-medium command.
  1840  //
  1841  // Since: 2.3
  1842  type BlockdevChangeReadOnlyMode int32
  1843  
  1844  const (
  1845  	BlockdevChangeReadOnlyModeRetain    BlockdevChangeReadOnlyMode = iota
  1846  	BlockdevChangeReadOnlyModeReadOnly                             // Makes the device read-only
  1847  	BlockdevChangeReadOnlyModeReadWrite                            // Makes the device writable
  1848  )
  1849  
  1850  func (s BlockdevChangeReadOnlyMode) MarshalJSON() ([]byte, error) {
  1851  	switch s {
  1852  	case BlockdevChangeReadOnlyModeRetain:
  1853  		return []byte(`"retain"`), nil
  1854  	case BlockdevChangeReadOnlyModeReadOnly:
  1855  		return []byte(`"read-only"`), nil
  1856  	case BlockdevChangeReadOnlyModeReadWrite:
  1857  		return []byte(`"read-write"`), nil
  1858  	default:
  1859  		fmt.Println("Failed to decode BlockdevChangeReadOnlyMode", s)
  1860  	}
  1861  	return nil, errors.New("Failed")
  1862  }
  1863  
  1864  func (s *BlockdevChangeReadOnlyMode) UnmarshalJSON(data []byte) error {
  1865  	var name string
  1866  
  1867  	if err := json.Unmarshal(data, &name); err != nil {
  1868  		return err
  1869  	}
  1870  
  1871  	switch name {
  1872  	case "retain":
  1873  		(*s) = BlockdevChangeReadOnlyModeRetain
  1874  	case "read-only":
  1875  		(*s) = BlockdevChangeReadOnlyModeReadOnly
  1876  	case "read-write":
  1877  		(*s) = BlockdevChangeReadOnlyModeReadWrite
  1878  	default:
  1879  		fmt.Println("Failed to decode BlockdevChangeReadOnlyMode", *s)
  1880  	}
  1881  	return nil
  1882  }
  1883  
  1884  // Since: 1.7
  1885  type ImageInfoSpecificKind int32
  1886  
  1887  const (
  1888  	ImageInfoSpecificKindQcow2 ImageInfoSpecificKind = iota
  1889  	ImageInfoSpecificKindVmdk
  1890  	ImageInfoSpecificKindLuks // Since 2.7
  1891  	ImageInfoSpecificKindRbd  // Since 6.1
  1892  )
  1893  
  1894  func (s ImageInfoSpecificKind) MarshalJSON() ([]byte, error) {
  1895  	switch s {
  1896  	case ImageInfoSpecificKindQcow2:
  1897  		return []byte(`"qcow2"`), nil
  1898  	case ImageInfoSpecificKindVmdk:
  1899  		return []byte(`"vmdk"`), nil
  1900  	case ImageInfoSpecificKindLuks:
  1901  		return []byte(`"luks"`), nil
  1902  	case ImageInfoSpecificKindRbd:
  1903  		return []byte(`"rbd"`), nil
  1904  	default:
  1905  		fmt.Println("Failed to decode ImageInfoSpecificKind", s)
  1906  	}
  1907  	return nil, errors.New("Failed")
  1908  }
  1909  
  1910  func (s *ImageInfoSpecificKind) UnmarshalJSON(data []byte) error {
  1911  	var name string
  1912  
  1913  	if err := json.Unmarshal(data, &name); err != nil {
  1914  		return err
  1915  	}
  1916  
  1917  	switch name {
  1918  	case "qcow2":
  1919  		(*s) = ImageInfoSpecificKindQcow2
  1920  	case "vmdk":
  1921  		(*s) = ImageInfoSpecificKindVmdk
  1922  	case "luks":
  1923  		(*s) = ImageInfoSpecificKindLuks
  1924  	case "rbd":
  1925  		(*s) = ImageInfoSpecificKindRbd
  1926  	default:
  1927  		fmt.Println("Failed to decode ImageInfoSpecificKind", *s)
  1928  	}
  1929  	return nil
  1930  }
  1931  
  1932  // An enumeration of block device I/O status.
  1933  //
  1934  // Since: 1.0
  1935  type BlockDeviceIoStatus int32
  1936  
  1937  const (
  1938  	BlockDeviceIoStatusOk      BlockDeviceIoStatus = iota
  1939  	BlockDeviceIoStatusFailed                      // The last I/O operation has failed
  1940  	BlockDeviceIoStatusNospace                     // The last I/O operation has failed due to a no-space condition
  1941  )
  1942  
  1943  func (s BlockDeviceIoStatus) MarshalJSON() ([]byte, error) {
  1944  	switch s {
  1945  	case BlockDeviceIoStatusOk:
  1946  		return []byte(`"ok"`), nil
  1947  	case BlockDeviceIoStatusFailed:
  1948  		return []byte(`"failed"`), nil
  1949  	case BlockDeviceIoStatusNospace:
  1950  		return []byte(`"nospace"`), nil
  1951  	default:
  1952  		fmt.Println("Failed to decode BlockDeviceIoStatus", s)
  1953  	}
  1954  	return nil, errors.New("Failed")
  1955  }
  1956  
  1957  func (s *BlockDeviceIoStatus) UnmarshalJSON(data []byte) error {
  1958  	var name string
  1959  
  1960  	if err := json.Unmarshal(data, &name); err != nil {
  1961  		return err
  1962  	}
  1963  
  1964  	switch name {
  1965  	case "ok":
  1966  		(*s) = BlockDeviceIoStatusOk
  1967  	case "failed":
  1968  		(*s) = BlockDeviceIoStatusFailed
  1969  	case "nospace":
  1970  		(*s) = BlockDeviceIoStatusNospace
  1971  	default:
  1972  		fmt.Println("Failed to decode BlockDeviceIoStatus", *s)
  1973  	}
  1974  	return nil
  1975  }
  1976  
  1977  // An enumeration of flags that a bitmap can report to the user.
  1978  //
  1979  // Since: 4.0
  1980  type Qcow2BitmapInfoFlags int32
  1981  
  1982  const (
  1983  	Qcow2BitmapInfoFlagsInUse Qcow2BitmapInfoFlags = iota
  1984  	Qcow2BitmapInfoFlagsAuto                       // The bitmap must reflect all changes of the virtual disk by any application that would write to this qcow2 file.
  1985  )
  1986  
  1987  func (s Qcow2BitmapInfoFlags) MarshalJSON() ([]byte, error) {
  1988  	switch s {
  1989  	case Qcow2BitmapInfoFlagsInUse:
  1990  		return []byte(`"in-use"`), nil
  1991  	case Qcow2BitmapInfoFlagsAuto:
  1992  		return []byte(`"auto"`), nil
  1993  	default:
  1994  		fmt.Println("Failed to decode Qcow2BitmapInfoFlags", s)
  1995  	}
  1996  	return nil, errors.New("Failed")
  1997  }
  1998  
  1999  func (s *Qcow2BitmapInfoFlags) UnmarshalJSON(data []byte) error {
  2000  	var name string
  2001  
  2002  	if err := json.Unmarshal(data, &name); err != nil {
  2003  		return err
  2004  	}
  2005  
  2006  	switch name {
  2007  	case "in-use":
  2008  		(*s) = Qcow2BitmapInfoFlagsInUse
  2009  	case "auto":
  2010  		(*s) = Qcow2BitmapInfoFlagsAuto
  2011  	default:
  2012  		fmt.Println("Failed to decode Qcow2BitmapInfoFlags", *s)
  2013  	}
  2014  	return nil
  2015  }
  2016  
  2017  // An enumeration of possible behaviors for errors on I/O operations.
  2018  // The exact meaning depends on whether the I/O was initiated by a guest
  2019  // or by a block job
  2020  //
  2021  // Since: 1.3
  2022  type BlockdevOnError int32
  2023  
  2024  const (
  2025  	BlockdevOnErrorReport BlockdevOnError = iota
  2026  	BlockdevOnErrorIgnore                 // ignore the error, only report a QMP event (BLOCK_IO_ERROR or BLOCK_JOB_ERROR). The backup, mirror and commit block jobs retry the failing request later and may still complete successfully. The stream block job continues to stream and will complete with an error.
  2027  	BlockdevOnErrorEnospc                 // same as @stop on ENOSPC, same as @report otherwise.
  2028  	BlockdevOnErrorStop                   // for guest operations, stop the virtual machine; for jobs, pause the job
  2029  	BlockdevOnErrorAuto                   // inherit the error handling policy of the backend (since: 2.7)
  2030  )
  2031  
  2032  func (s BlockdevOnError) MarshalJSON() ([]byte, error) {
  2033  	switch s {
  2034  	case BlockdevOnErrorReport:
  2035  		return []byte(`"report"`), nil
  2036  	case BlockdevOnErrorIgnore:
  2037  		return []byte(`"ignore"`), nil
  2038  	case BlockdevOnErrorEnospc:
  2039  		return []byte(`"enospc"`), nil
  2040  	case BlockdevOnErrorStop:
  2041  		return []byte(`"stop"`), nil
  2042  	case BlockdevOnErrorAuto:
  2043  		return []byte(`"auto"`), nil
  2044  	default:
  2045  		fmt.Println("Failed to decode BlockdevOnError", s)
  2046  	}
  2047  	return nil, errors.New("Failed")
  2048  }
  2049  
  2050  func (s *BlockdevOnError) UnmarshalJSON(data []byte) error {
  2051  	var name string
  2052  
  2053  	if err := json.Unmarshal(data, &name); err != nil {
  2054  		return err
  2055  	}
  2056  
  2057  	switch name {
  2058  	case "report":
  2059  		(*s) = BlockdevOnErrorReport
  2060  	case "ignore":
  2061  		(*s) = BlockdevOnErrorIgnore
  2062  	case "enospc":
  2063  		(*s) = BlockdevOnErrorEnospc
  2064  	case "stop":
  2065  		(*s) = BlockdevOnErrorStop
  2066  	case "auto":
  2067  		(*s) = BlockdevOnErrorAuto
  2068  	default:
  2069  		fmt.Println("Failed to decode BlockdevOnError", *s)
  2070  	}
  2071  	return nil
  2072  }
  2073  
  2074  // An enumeration of possible behaviors for the initial synchronization
  2075  // phase of storage mirroring.
  2076  //
  2077  // Since: 1.3
  2078  type MirrorSyncMode int32
  2079  
  2080  const (
  2081  	MirrorSyncModeTop         MirrorSyncMode = iota
  2082  	MirrorSyncModeFull                       // copies data from all images to the destination
  2083  	MirrorSyncModeNone                       // only copy data written from now on
  2084  	MirrorSyncModeIncremental                // only copy data described by the dirty bitmap. (since: 2.4)
  2085  	MirrorSyncModeBitmap                     // only copy data described by the dirty bitmap. (since: 4.2) Behavior on completion is determined by the BitmapSyncMode.
  2086  )
  2087  
  2088  func (s MirrorSyncMode) MarshalJSON() ([]byte, error) {
  2089  	switch s {
  2090  	case MirrorSyncModeTop:
  2091  		return []byte(`"top"`), nil
  2092  	case MirrorSyncModeFull:
  2093  		return []byte(`"full"`), nil
  2094  	case MirrorSyncModeNone:
  2095  		return []byte(`"none"`), nil
  2096  	case MirrorSyncModeIncremental:
  2097  		return []byte(`"incremental"`), nil
  2098  	case MirrorSyncModeBitmap:
  2099  		return []byte(`"bitmap"`), nil
  2100  	default:
  2101  		fmt.Println("Failed to decode MirrorSyncMode", s)
  2102  	}
  2103  	return nil, errors.New("Failed")
  2104  }
  2105  
  2106  func (s *MirrorSyncMode) UnmarshalJSON(data []byte) error {
  2107  	var name string
  2108  
  2109  	if err := json.Unmarshal(data, &name); err != nil {
  2110  		return err
  2111  	}
  2112  
  2113  	switch name {
  2114  	case "top":
  2115  		(*s) = MirrorSyncModeTop
  2116  	case "full":
  2117  		(*s) = MirrorSyncModeFull
  2118  	case "none":
  2119  		(*s) = MirrorSyncModeNone
  2120  	case "incremental":
  2121  		(*s) = MirrorSyncModeIncremental
  2122  	case "bitmap":
  2123  		(*s) = MirrorSyncModeBitmap
  2124  	default:
  2125  		fmt.Println("Failed to decode MirrorSyncMode", *s)
  2126  	}
  2127  	return nil
  2128  }
  2129  
  2130  // An enumeration of possible behaviors for the synchronization of a bitmap
  2131  // when used for data copy operations.
  2132  //
  2133  // Since: 4.2
  2134  type BitmapSyncMode int32
  2135  
  2136  const (
  2137  	BitmapSyncModeOnSuccess BitmapSyncMode = iota
  2138  	BitmapSyncModeNever                    // The bitmap is never synchronized with the operation, and is treated solely as a read-only manifest of blocks to copy.
  2139  	BitmapSyncModeAlways                   // The bitmap is always synchronized with the operation, regardless of whether or not the operation was successful.
  2140  )
  2141  
  2142  func (s BitmapSyncMode) MarshalJSON() ([]byte, error) {
  2143  	switch s {
  2144  	case BitmapSyncModeOnSuccess:
  2145  		return []byte(`"on-success"`), nil
  2146  	case BitmapSyncModeNever:
  2147  		return []byte(`"never"`), nil
  2148  	case BitmapSyncModeAlways:
  2149  		return []byte(`"always"`), nil
  2150  	default:
  2151  		fmt.Println("Failed to decode BitmapSyncMode", s)
  2152  	}
  2153  	return nil, errors.New("Failed")
  2154  }
  2155  
  2156  func (s *BitmapSyncMode) UnmarshalJSON(data []byte) error {
  2157  	var name string
  2158  
  2159  	if err := json.Unmarshal(data, &name); err != nil {
  2160  		return err
  2161  	}
  2162  
  2163  	switch name {
  2164  	case "on-success":
  2165  		(*s) = BitmapSyncModeOnSuccess
  2166  	case "never":
  2167  		(*s) = BitmapSyncModeNever
  2168  	case "always":
  2169  		(*s) = BitmapSyncModeAlways
  2170  	default:
  2171  		fmt.Println("Failed to decode BitmapSyncMode", *s)
  2172  	}
  2173  	return nil
  2174  }
  2175  
  2176  // An enumeration whose values tell the mirror block job when to
  2177  // trigger writes to the target.
  2178  //
  2179  // Since: 3.0
  2180  type MirrorCopyMode int32
  2181  
  2182  const (
  2183  	MirrorCopyModeBackground    MirrorCopyMode = iota
  2184  	MirrorCopyModeWriteBlocking                // when data is written to the source, write it (synchronously) to the target as well. In addition, data is copied in background just like in @background mode.
  2185  )
  2186  
  2187  func (s MirrorCopyMode) MarshalJSON() ([]byte, error) {
  2188  	switch s {
  2189  	case MirrorCopyModeBackground:
  2190  		return []byte(`"background"`), nil
  2191  	case MirrorCopyModeWriteBlocking:
  2192  		return []byte(`"write-blocking"`), nil
  2193  	default:
  2194  		fmt.Println("Failed to decode MirrorCopyMode", s)
  2195  	}
  2196  	return nil, errors.New("Failed")
  2197  }
  2198  
  2199  func (s *MirrorCopyMode) UnmarshalJSON(data []byte) error {
  2200  	var name string
  2201  
  2202  	if err := json.Unmarshal(data, &name); err != nil {
  2203  		return err
  2204  	}
  2205  
  2206  	switch name {
  2207  	case "background":
  2208  		(*s) = MirrorCopyModeBackground
  2209  	case "write-blocking":
  2210  		(*s) = MirrorCopyModeWriteBlocking
  2211  	default:
  2212  		fmt.Println("Failed to decode MirrorCopyMode", *s)
  2213  	}
  2214  	return nil
  2215  }
  2216  
  2217  // An enumeration that tells QEMU how to set the backing file path in
  2218  // a new image file.
  2219  //
  2220  // Since: 1.1
  2221  type NewImageMode int32
  2222  
  2223  const (
  2224  	NewImageModeExisting      NewImageMode = iota
  2225  	NewImageModeAbsolutePaths              // QEMU should create a new image with absolute paths for the backing file. If there is no backing file available, the new image will not be backed either.
  2226  )
  2227  
  2228  func (s NewImageMode) MarshalJSON() ([]byte, error) {
  2229  	switch s {
  2230  	case NewImageModeExisting:
  2231  		return []byte(`"existing"`), nil
  2232  	case NewImageModeAbsolutePaths:
  2233  		return []byte(`"absolute-paths"`), nil
  2234  	default:
  2235  		fmt.Println("Failed to decode NewImageMode", s)
  2236  	}
  2237  	return nil, errors.New("Failed")
  2238  }
  2239  
  2240  func (s *NewImageMode) UnmarshalJSON(data []byte) error {
  2241  	var name string
  2242  
  2243  	if err := json.Unmarshal(data, &name); err != nil {
  2244  		return err
  2245  	}
  2246  
  2247  	switch name {
  2248  	case "existing":
  2249  		(*s) = NewImageModeExisting
  2250  	case "absolute-paths":
  2251  		(*s) = NewImageModeAbsolutePaths
  2252  	default:
  2253  		fmt.Println("Failed to decode NewImageMode", *s)
  2254  	}
  2255  	return nil
  2256  }
  2257  
  2258  // Since: 4.0
  2259  type XDbgBlockGraphNodeType int32
  2260  
  2261  const (
  2262  	XDbgBlockGraphNodeTypeBlockBackend XDbgBlockGraphNodeType = iota
  2263  	XDbgBlockGraphNodeTypeBlockJob                            // corresponds to BlockJob
  2264  	XDbgBlockGraphNodeTypeBlockDriver                         // corresponds to BlockDriverState
  2265  )
  2266  
  2267  func (s XDbgBlockGraphNodeType) MarshalJSON() ([]byte, error) {
  2268  	switch s {
  2269  	case XDbgBlockGraphNodeTypeBlockBackend:
  2270  		return []byte(`"block-backend"`), nil
  2271  	case XDbgBlockGraphNodeTypeBlockJob:
  2272  		return []byte(`"block-job"`), nil
  2273  	case XDbgBlockGraphNodeTypeBlockDriver:
  2274  		return []byte(`"block-driver"`), nil
  2275  	default:
  2276  		fmt.Println("Failed to decode XDbgBlockGraphNodeType", s)
  2277  	}
  2278  	return nil, errors.New("Failed")
  2279  }
  2280  
  2281  func (s *XDbgBlockGraphNodeType) UnmarshalJSON(data []byte) error {
  2282  	var name string
  2283  
  2284  	if err := json.Unmarshal(data, &name); err != nil {
  2285  		return err
  2286  	}
  2287  
  2288  	switch name {
  2289  	case "block-backend":
  2290  		(*s) = XDbgBlockGraphNodeTypeBlockBackend
  2291  	case "block-job":
  2292  		(*s) = XDbgBlockGraphNodeTypeBlockJob
  2293  	case "block-driver":
  2294  		(*s) = XDbgBlockGraphNodeTypeBlockDriver
  2295  	default:
  2296  		fmt.Println("Failed to decode XDbgBlockGraphNodeType", *s)
  2297  	}
  2298  	return nil
  2299  }
  2300  
  2301  // Enum of base block permissions.
  2302  //
  2303  // Since: 4.0
  2304  type BlockPermission int32
  2305  
  2306  const (
  2307  	BlockPermissionConsistentRead BlockPermission = iota
  2308  	BlockPermissionWrite                          // This permission is required to change the visible disk contents.
  2309  	BlockPermissionWriteUnchanged                 // This permission (which is weaker than BLK_PERM_WRITE) is both enough and required for writes to the block node when the caller promises that the visible disk content doesn't change. As the BLK_PERM_WRITE permission is strictly stronger, either is sufficient to perform an unchanging write.
  2310  	BlockPermissionResize                         // This permission is required to change the size of a block node.
  2311  )
  2312  
  2313  func (s BlockPermission) MarshalJSON() ([]byte, error) {
  2314  	switch s {
  2315  	case BlockPermissionConsistentRead:
  2316  		return []byte(`"consistent-read"`), nil
  2317  	case BlockPermissionWrite:
  2318  		return []byte(`"write"`), nil
  2319  	case BlockPermissionWriteUnchanged:
  2320  		return []byte(`"write-unchanged"`), nil
  2321  	case BlockPermissionResize:
  2322  		return []byte(`"resize"`), nil
  2323  	default:
  2324  		fmt.Println("Failed to decode BlockPermission", s)
  2325  	}
  2326  	return nil, errors.New("Failed")
  2327  }
  2328  
  2329  func (s *BlockPermission) UnmarshalJSON(data []byte) error {
  2330  	var name string
  2331  
  2332  	if err := json.Unmarshal(data, &name); err != nil {
  2333  		return err
  2334  	}
  2335  
  2336  	switch name {
  2337  	case "consistent-read":
  2338  		(*s) = BlockPermissionConsistentRead
  2339  	case "write":
  2340  		(*s) = BlockPermissionWrite
  2341  	case "write-unchanged":
  2342  		(*s) = BlockPermissionWriteUnchanged
  2343  	case "resize":
  2344  		(*s) = BlockPermissionResize
  2345  	default:
  2346  		fmt.Println("Failed to decode BlockPermission", *s)
  2347  	}
  2348  	return nil
  2349  }
  2350  
  2351  // Determines how to handle discard requests.
  2352  //
  2353  // Since: 2.9
  2354  type BlockdevDiscardOptions int32
  2355  
  2356  const (
  2357  	BlockdevDiscardOptionsIgnore BlockdevDiscardOptions = iota
  2358  	BlockdevDiscardOptionsUnmap                         // Forward as an unmap request
  2359  )
  2360  
  2361  func (s BlockdevDiscardOptions) MarshalJSON() ([]byte, error) {
  2362  	switch s {
  2363  	case BlockdevDiscardOptionsIgnore:
  2364  		return []byte(`"ignore"`), nil
  2365  	case BlockdevDiscardOptionsUnmap:
  2366  		return []byte(`"unmap"`), nil
  2367  	default:
  2368  		fmt.Println("Failed to decode BlockdevDiscardOptions", s)
  2369  	}
  2370  	return nil, errors.New("Failed")
  2371  }
  2372  
  2373  func (s *BlockdevDiscardOptions) UnmarshalJSON(data []byte) error {
  2374  	var name string
  2375  
  2376  	if err := json.Unmarshal(data, &name); err != nil {
  2377  		return err
  2378  	}
  2379  
  2380  	switch name {
  2381  	case "ignore":
  2382  		(*s) = BlockdevDiscardOptionsIgnore
  2383  	case "unmap":
  2384  		(*s) = BlockdevDiscardOptionsUnmap
  2385  	default:
  2386  		fmt.Println("Failed to decode BlockdevDiscardOptions", *s)
  2387  	}
  2388  	return nil
  2389  }
  2390  
  2391  // Describes the operation mode for the automatic conversion of plain
  2392  // zero writes by the OS to driver specific optimized zero write commands.
  2393  //
  2394  // Since: 2.1
  2395  type BlockdevDetectZeroesOptions int32
  2396  
  2397  const (
  2398  	BlockdevDetectZeroesOptionsOff   BlockdevDetectZeroesOptions = iota
  2399  	BlockdevDetectZeroesOptionsOn                                // Enabled
  2400  	BlockdevDetectZeroesOptionsUnmap                             // Enabled and even try to unmap blocks if possible. This requires also that @BlockdevDiscardOptions is set to unmap for this device.
  2401  )
  2402  
  2403  func (s BlockdevDetectZeroesOptions) MarshalJSON() ([]byte, error) {
  2404  	switch s {
  2405  	case BlockdevDetectZeroesOptionsOff:
  2406  		return []byte(`"off"`), nil
  2407  	case BlockdevDetectZeroesOptionsOn:
  2408  		return []byte(`"on"`), nil
  2409  	case BlockdevDetectZeroesOptionsUnmap:
  2410  		return []byte(`"unmap"`), nil
  2411  	default:
  2412  		fmt.Println("Failed to decode BlockdevDetectZeroesOptions", s)
  2413  	}
  2414  	return nil, errors.New("Failed")
  2415  }
  2416  
  2417  func (s *BlockdevDetectZeroesOptions) UnmarshalJSON(data []byte) error {
  2418  	var name string
  2419  
  2420  	if err := json.Unmarshal(data, &name); err != nil {
  2421  		return err
  2422  	}
  2423  
  2424  	switch name {
  2425  	case "off":
  2426  		(*s) = BlockdevDetectZeroesOptionsOff
  2427  	case "on":
  2428  		(*s) = BlockdevDetectZeroesOptionsOn
  2429  	case "unmap":
  2430  		(*s) = BlockdevDetectZeroesOptionsUnmap
  2431  	default:
  2432  		fmt.Println("Failed to decode BlockdevDetectZeroesOptions", *s)
  2433  	}
  2434  	return nil
  2435  }
  2436  
  2437  // Selects the AIO backend to handle I/O requests
  2438  //
  2439  // Since: 2.9
  2440  type BlockdevAioOptions int32
  2441  
  2442  const (
  2443  	BlockdevAioOptionsThreads  BlockdevAioOptions = iota
  2444  	BlockdevAioOptionsNative                      // Use native AIO backend (only Linux and Windows)
  2445  	BlockdevAioOptionsIo_Uring                    // Use linux io_uring (since 5.0)
  2446  )
  2447  
  2448  func (s BlockdevAioOptions) MarshalJSON() ([]byte, error) {
  2449  	switch s {
  2450  	case BlockdevAioOptionsThreads:
  2451  		return []byte(`"threads"`), nil
  2452  	case BlockdevAioOptionsNative:
  2453  		return []byte(`"native"`), nil
  2454  	case BlockdevAioOptionsIo_Uring:
  2455  		return []byte(`"io_uring"`), nil
  2456  	default:
  2457  		fmt.Println("Failed to decode BlockdevAioOptions", s)
  2458  	}
  2459  	return nil, errors.New("Failed")
  2460  }
  2461  
  2462  func (s *BlockdevAioOptions) UnmarshalJSON(data []byte) error {
  2463  	var name string
  2464  
  2465  	if err := json.Unmarshal(data, &name); err != nil {
  2466  		return err
  2467  	}
  2468  
  2469  	switch name {
  2470  	case "threads":
  2471  		(*s) = BlockdevAioOptionsThreads
  2472  	case "native":
  2473  		(*s) = BlockdevAioOptionsNative
  2474  	case "io_uring":
  2475  		(*s) = BlockdevAioOptionsIo_Uring
  2476  	default:
  2477  		fmt.Println("Failed to decode BlockdevAioOptions", *s)
  2478  	}
  2479  	return nil
  2480  }
  2481  
  2482  // Drivers that are supported in block device operations.
  2483  //
  2484  // Since: 2.9
  2485  type BlockdevDriver int32
  2486  
  2487  const (
  2488  	BlockdevDriverBlkdebug     BlockdevDriver = iota
  2489  	BlockdevDriverBlklogwrites                // Since 3.0
  2490  	BlockdevDriverBlkreplay                   // Since 4.2
  2491  	BlockdevDriverBlkverify
  2492  	BlockdevDriverBochs
  2493  	BlockdevDriverCloop
  2494  	BlockdevDriverCompress        // Since 5.0
  2495  	BlockdevDriverCopyBeforeWrite // Since 6.2
  2496  	BlockdevDriverCopyOnRead      // Since 3.0
  2497  	BlockdevDriverDmg
  2498  	BlockdevDriverFile
  2499  	BlockdevDriverSnapshotAccess // Since 7.0
  2500  	BlockdevDriverFtp
  2501  	BlockdevDriverFtps
  2502  	BlockdevDriverGluster
  2503  	BlockdevDriverHost_Cdrom
  2504  	BlockdevDriverHost_Device
  2505  	BlockdevDriverHttp
  2506  	BlockdevDriverHttps
  2507  	BlockdevDriverIscsi
  2508  	BlockdevDriverLuks
  2509  	BlockdevDriverNbd
  2510  	BlockdevDriverNfs
  2511  	BlockdevDriverNullAio
  2512  	BlockdevDriverNullCo
  2513  	BlockdevDriverNvme // Since 2.12
  2514  	BlockdevDriverParallels
  2515  	BlockdevDriverPreallocate
  2516  	BlockdevDriverQcow
  2517  	BlockdevDriverQcow2
  2518  	BlockdevDriverQed
  2519  	BlockdevDriverQuorum
  2520  	BlockdevDriverRaw
  2521  	BlockdevDriverRbd
  2522  	BlockdevDriverReplication
  2523  	BlockdevDriverSsh
  2524  	BlockdevDriverThrottle // Since 2.11
  2525  	BlockdevDriverVdi
  2526  	BlockdevDriverVhdx
  2527  	BlockdevDriverVmdk
  2528  	BlockdevDriverVpc
  2529  	BlockdevDriverVvfat
  2530  )
  2531  
  2532  func (s BlockdevDriver) MarshalJSON() ([]byte, error) {
  2533  	switch s {
  2534  	case BlockdevDriverBlkdebug:
  2535  		return []byte(`"blkdebug"`), nil
  2536  	case BlockdevDriverBlklogwrites:
  2537  		return []byte(`"blklogwrites"`), nil
  2538  	case BlockdevDriverBlkreplay:
  2539  		return []byte(`"blkreplay"`), nil
  2540  	case BlockdevDriverBlkverify:
  2541  		return []byte(`"blkverify"`), nil
  2542  	case BlockdevDriverBochs:
  2543  		return []byte(`"bochs"`), nil
  2544  	case BlockdevDriverCloop:
  2545  		return []byte(`"cloop"`), nil
  2546  	case BlockdevDriverCompress:
  2547  		return []byte(`"compress"`), nil
  2548  	case BlockdevDriverCopyBeforeWrite:
  2549  		return []byte(`"copy-before-write"`), nil
  2550  	case BlockdevDriverCopyOnRead:
  2551  		return []byte(`"copy-on-read"`), nil
  2552  	case BlockdevDriverDmg:
  2553  		return []byte(`"dmg"`), nil
  2554  	case BlockdevDriverFile:
  2555  		return []byte(`"file"`), nil
  2556  	case BlockdevDriverSnapshotAccess:
  2557  		return []byte(`"snapshot-access"`), nil
  2558  	case BlockdevDriverFtp:
  2559  		return []byte(`"ftp"`), nil
  2560  	case BlockdevDriverFtps:
  2561  		return []byte(`"ftps"`), nil
  2562  	case BlockdevDriverGluster:
  2563  		return []byte(`"gluster"`), nil
  2564  	case BlockdevDriverHost_Cdrom:
  2565  		return []byte(`"host_cdrom"`), nil
  2566  	case BlockdevDriverHost_Device:
  2567  		return []byte(`"host_device"`), nil
  2568  	case BlockdevDriverHttp:
  2569  		return []byte(`"http"`), nil
  2570  	case BlockdevDriverHttps:
  2571  		return []byte(`"https"`), nil
  2572  	case BlockdevDriverIscsi:
  2573  		return []byte(`"iscsi"`), nil
  2574  	case BlockdevDriverLuks:
  2575  		return []byte(`"luks"`), nil
  2576  	case BlockdevDriverNbd:
  2577  		return []byte(`"nbd"`), nil
  2578  	case BlockdevDriverNfs:
  2579  		return []byte(`"nfs"`), nil
  2580  	case BlockdevDriverNullAio:
  2581  		return []byte(`"null-aio"`), nil
  2582  	case BlockdevDriverNullCo:
  2583  		return []byte(`"null-co"`), nil
  2584  	case BlockdevDriverNvme:
  2585  		return []byte(`"nvme"`), nil
  2586  	case BlockdevDriverParallels:
  2587  		return []byte(`"parallels"`), nil
  2588  	case BlockdevDriverPreallocate:
  2589  		return []byte(`"preallocate"`), nil
  2590  	case BlockdevDriverQcow:
  2591  		return []byte(`"qcow"`), nil
  2592  	case BlockdevDriverQcow2:
  2593  		return []byte(`"qcow2"`), nil
  2594  	case BlockdevDriverQed:
  2595  		return []byte(`"qed"`), nil
  2596  	case BlockdevDriverQuorum:
  2597  		return []byte(`"quorum"`), nil
  2598  	case BlockdevDriverRaw:
  2599  		return []byte(`"raw"`), nil
  2600  	case BlockdevDriverRbd:
  2601  		return []byte(`"rbd"`), nil
  2602  	case BlockdevDriverReplication:
  2603  		return []byte(`"replication"`), nil
  2604  	case BlockdevDriverSsh:
  2605  		return []byte(`"ssh"`), nil
  2606  	case BlockdevDriverThrottle:
  2607  		return []byte(`"throttle"`), nil
  2608  	case BlockdevDriverVdi:
  2609  		return []byte(`"vdi"`), nil
  2610  	case BlockdevDriverVhdx:
  2611  		return []byte(`"vhdx"`), nil
  2612  	case BlockdevDriverVmdk:
  2613  		return []byte(`"vmdk"`), nil
  2614  	case BlockdevDriverVpc:
  2615  		return []byte(`"vpc"`), nil
  2616  	case BlockdevDriverVvfat:
  2617  		return []byte(`"vvfat"`), nil
  2618  	default:
  2619  		fmt.Println("Failed to decode BlockdevDriver", s)
  2620  	}
  2621  	return nil, errors.New("Failed")
  2622  }
  2623  
  2624  func (s *BlockdevDriver) UnmarshalJSON(data []byte) error {
  2625  	var name string
  2626  
  2627  	if err := json.Unmarshal(data, &name); err != nil {
  2628  		return err
  2629  	}
  2630  
  2631  	switch name {
  2632  	case "blkdebug":
  2633  		(*s) = BlockdevDriverBlkdebug
  2634  	case "blklogwrites":
  2635  		(*s) = BlockdevDriverBlklogwrites
  2636  	case "blkreplay":
  2637  		(*s) = BlockdevDriverBlkreplay
  2638  	case "blkverify":
  2639  		(*s) = BlockdevDriverBlkverify
  2640  	case "bochs":
  2641  		(*s) = BlockdevDriverBochs
  2642  	case "cloop":
  2643  		(*s) = BlockdevDriverCloop
  2644  	case "compress":
  2645  		(*s) = BlockdevDriverCompress
  2646  	case "copy-before-write":
  2647  		(*s) = BlockdevDriverCopyBeforeWrite
  2648  	case "copy-on-read":
  2649  		(*s) = BlockdevDriverCopyOnRead
  2650  	case "dmg":
  2651  		(*s) = BlockdevDriverDmg
  2652  	case "file":
  2653  		(*s) = BlockdevDriverFile
  2654  	case "snapshot-access":
  2655  		(*s) = BlockdevDriverSnapshotAccess
  2656  	case "ftp":
  2657  		(*s) = BlockdevDriverFtp
  2658  	case "ftps":
  2659  		(*s) = BlockdevDriverFtps
  2660  	case "gluster":
  2661  		(*s) = BlockdevDriverGluster
  2662  	case "host_cdrom":
  2663  		(*s) = BlockdevDriverHost_Cdrom
  2664  	case "host_device":
  2665  		(*s) = BlockdevDriverHost_Device
  2666  	case "http":
  2667  		(*s) = BlockdevDriverHttp
  2668  	case "https":
  2669  		(*s) = BlockdevDriverHttps
  2670  	case "iscsi":
  2671  		(*s) = BlockdevDriverIscsi
  2672  	case "luks":
  2673  		(*s) = BlockdevDriverLuks
  2674  	case "nbd":
  2675  		(*s) = BlockdevDriverNbd
  2676  	case "nfs":
  2677  		(*s) = BlockdevDriverNfs
  2678  	case "null-aio":
  2679  		(*s) = BlockdevDriverNullAio
  2680  	case "null-co":
  2681  		(*s) = BlockdevDriverNullCo
  2682  	case "nvme":
  2683  		(*s) = BlockdevDriverNvme
  2684  	case "parallels":
  2685  		(*s) = BlockdevDriverParallels
  2686  	case "preallocate":
  2687  		(*s) = BlockdevDriverPreallocate
  2688  	case "qcow":
  2689  		(*s) = BlockdevDriverQcow
  2690  	case "qcow2":
  2691  		(*s) = BlockdevDriverQcow2
  2692  	case "qed":
  2693  		(*s) = BlockdevDriverQed
  2694  	case "quorum":
  2695  		(*s) = BlockdevDriverQuorum
  2696  	case "raw":
  2697  		(*s) = BlockdevDriverRaw
  2698  	case "rbd":
  2699  		(*s) = BlockdevDriverRbd
  2700  	case "replication":
  2701  		(*s) = BlockdevDriverReplication
  2702  	case "ssh":
  2703  		(*s) = BlockdevDriverSsh
  2704  	case "throttle":
  2705  		(*s) = BlockdevDriverThrottle
  2706  	case "vdi":
  2707  		(*s) = BlockdevDriverVdi
  2708  	case "vhdx":
  2709  		(*s) = BlockdevDriverVhdx
  2710  	case "vmdk":
  2711  		(*s) = BlockdevDriverVmdk
  2712  	case "vpc":
  2713  		(*s) = BlockdevDriverVpc
  2714  	case "vvfat":
  2715  		(*s) = BlockdevDriverVvfat
  2716  	default:
  2717  		fmt.Println("Failed to decode BlockdevDriver", *s)
  2718  	}
  2719  	return nil
  2720  }
  2721  
  2722  // General overlap check modes.
  2723  //
  2724  // Since: 2.9
  2725  type Qcow2OverlapCheckMode int32
  2726  
  2727  const (
  2728  	Qcow2OverlapCheckModeNone     Qcow2OverlapCheckMode = iota
  2729  	Qcow2OverlapCheckModeConstant                       // Perform only checks which can be done in constant time and without reading anything from disk
  2730  	Qcow2OverlapCheckModeCached                         // Perform only checks which can be done without reading anything from disk
  2731  	Qcow2OverlapCheckModeAll                            // Perform all available overlap checks
  2732  )
  2733  
  2734  func (s Qcow2OverlapCheckMode) MarshalJSON() ([]byte, error) {
  2735  	switch s {
  2736  	case Qcow2OverlapCheckModeNone:
  2737  		return []byte(`"none"`), nil
  2738  	case Qcow2OverlapCheckModeConstant:
  2739  		return []byte(`"constant"`), nil
  2740  	case Qcow2OverlapCheckModeCached:
  2741  		return []byte(`"cached"`), nil
  2742  	case Qcow2OverlapCheckModeAll:
  2743  		return []byte(`"all"`), nil
  2744  	default:
  2745  		fmt.Println("Failed to decode Qcow2OverlapCheckMode", s)
  2746  	}
  2747  	return nil, errors.New("Failed")
  2748  }
  2749  
  2750  func (s *Qcow2OverlapCheckMode) UnmarshalJSON(data []byte) error {
  2751  	var name string
  2752  
  2753  	if err := json.Unmarshal(data, &name); err != nil {
  2754  		return err
  2755  	}
  2756  
  2757  	switch name {
  2758  	case "none":
  2759  		(*s) = Qcow2OverlapCheckModeNone
  2760  	case "constant":
  2761  		(*s) = Qcow2OverlapCheckModeConstant
  2762  	case "cached":
  2763  		(*s) = Qcow2OverlapCheckModeCached
  2764  	case "all":
  2765  		(*s) = Qcow2OverlapCheckModeAll
  2766  	default:
  2767  		fmt.Println("Failed to decode Qcow2OverlapCheckMode", *s)
  2768  	}
  2769  	return nil
  2770  }
  2771  
  2772  // Since: 2.10
  2773  type BlockdevQcowEncryptionFormat int32
  2774  
  2775  const (
  2776  	BlockdevQcowEncryptionFormatAes BlockdevQcowEncryptionFormat = iota
  2777  )
  2778  
  2779  func (s BlockdevQcowEncryptionFormat) MarshalJSON() ([]byte, error) {
  2780  	switch s {
  2781  	case BlockdevQcowEncryptionFormatAes:
  2782  		return []byte(`"aes"`), nil
  2783  	default:
  2784  		fmt.Println("Failed to decode BlockdevQcowEncryptionFormat", s)
  2785  	}
  2786  	return nil, errors.New("Failed")
  2787  }
  2788  
  2789  func (s *BlockdevQcowEncryptionFormat) UnmarshalJSON(data []byte) error {
  2790  	var name string
  2791  
  2792  	if err := json.Unmarshal(data, &name); err != nil {
  2793  		return err
  2794  	}
  2795  
  2796  	switch name {
  2797  	case "aes":
  2798  		(*s) = BlockdevQcowEncryptionFormatAes
  2799  	default:
  2800  		fmt.Println("Failed to decode BlockdevQcowEncryptionFormat", *s)
  2801  	}
  2802  	return nil
  2803  }
  2804  
  2805  // Since: 2.10
  2806  type BlockdevQcow2EncryptionFormat int32
  2807  
  2808  const (
  2809  	BlockdevQcow2EncryptionFormatAes BlockdevQcow2EncryptionFormat = iota
  2810  	BlockdevQcow2EncryptionFormatLuks
  2811  )
  2812  
  2813  func (s BlockdevQcow2EncryptionFormat) MarshalJSON() ([]byte, error) {
  2814  	switch s {
  2815  	case BlockdevQcow2EncryptionFormatAes:
  2816  		return []byte(`"aes"`), nil
  2817  	case BlockdevQcow2EncryptionFormatLuks:
  2818  		return []byte(`"luks"`), nil
  2819  	default:
  2820  		fmt.Println("Failed to decode BlockdevQcow2EncryptionFormat", s)
  2821  	}
  2822  	return nil, errors.New("Failed")
  2823  }
  2824  
  2825  func (s *BlockdevQcow2EncryptionFormat) UnmarshalJSON(data []byte) error {
  2826  	var name string
  2827  
  2828  	if err := json.Unmarshal(data, &name); err != nil {
  2829  		return err
  2830  	}
  2831  
  2832  	switch name {
  2833  	case "aes":
  2834  		(*s) = BlockdevQcow2EncryptionFormatAes
  2835  	case "luks":
  2836  		(*s) = BlockdevQcow2EncryptionFormatLuks
  2837  	default:
  2838  		fmt.Println("Failed to decode BlockdevQcow2EncryptionFormat", *s)
  2839  	}
  2840  	return nil
  2841  }
  2842  
  2843  // Since: 2.12
  2844  type SshHostKeyCheckMode int32
  2845  
  2846  const (
  2847  	SshHostKeyCheckModeNone        SshHostKeyCheckMode = iota
  2848  	SshHostKeyCheckModeHash                            // Compare the host key with a given hash
  2849  	SshHostKeyCheckModeKnown_Hosts                     // Check the host key against the known_hosts file
  2850  )
  2851  
  2852  func (s SshHostKeyCheckMode) MarshalJSON() ([]byte, error) {
  2853  	switch s {
  2854  	case SshHostKeyCheckModeNone:
  2855  		return []byte(`"none"`), nil
  2856  	case SshHostKeyCheckModeHash:
  2857  		return []byte(`"hash"`), nil
  2858  	case SshHostKeyCheckModeKnown_Hosts:
  2859  		return []byte(`"known_hosts"`), nil
  2860  	default:
  2861  		fmt.Println("Failed to decode SshHostKeyCheckMode", s)
  2862  	}
  2863  	return nil, errors.New("Failed")
  2864  }
  2865  
  2866  func (s *SshHostKeyCheckMode) UnmarshalJSON(data []byte) error {
  2867  	var name string
  2868  
  2869  	if err := json.Unmarshal(data, &name); err != nil {
  2870  		return err
  2871  	}
  2872  
  2873  	switch name {
  2874  	case "none":
  2875  		(*s) = SshHostKeyCheckModeNone
  2876  	case "hash":
  2877  		(*s) = SshHostKeyCheckModeHash
  2878  	case "known_hosts":
  2879  		(*s) = SshHostKeyCheckModeKnown_Hosts
  2880  	default:
  2881  		fmt.Println("Failed to decode SshHostKeyCheckMode", *s)
  2882  	}
  2883  	return nil
  2884  }
  2885  
  2886  // Since: 2.12
  2887  type SshHostKeyCheckHashType int32
  2888  
  2889  const (
  2890  	SshHostKeyCheckHashTypeMd5    SshHostKeyCheckHashType = iota
  2891  	SshHostKeyCheckHashTypeSha1                           // The given hash is an sha1 hash
  2892  	SshHostKeyCheckHashTypeSha256                         // The given hash is an sha256 hash
  2893  )
  2894  
  2895  func (s SshHostKeyCheckHashType) MarshalJSON() ([]byte, error) {
  2896  	switch s {
  2897  	case SshHostKeyCheckHashTypeMd5:
  2898  		return []byte(`"md5"`), nil
  2899  	case SshHostKeyCheckHashTypeSha1:
  2900  		return []byte(`"sha1"`), nil
  2901  	case SshHostKeyCheckHashTypeSha256:
  2902  		return []byte(`"sha256"`), nil
  2903  	default:
  2904  		fmt.Println("Failed to decode SshHostKeyCheckHashType", s)
  2905  	}
  2906  	return nil, errors.New("Failed")
  2907  }
  2908  
  2909  func (s *SshHostKeyCheckHashType) UnmarshalJSON(data []byte) error {
  2910  	var name string
  2911  
  2912  	if err := json.Unmarshal(data, &name); err != nil {
  2913  		return err
  2914  	}
  2915  
  2916  	switch name {
  2917  	case "md5":
  2918  		(*s) = SshHostKeyCheckHashTypeMd5
  2919  	case "sha1":
  2920  		(*s) = SshHostKeyCheckHashTypeSha1
  2921  	case "sha256":
  2922  		(*s) = SshHostKeyCheckHashTypeSha256
  2923  	default:
  2924  		fmt.Println("Failed to decode SshHostKeyCheckHashType", *s)
  2925  	}
  2926  	return nil
  2927  }
  2928  
  2929  // Trigger events supported by blkdebug.
  2930  //
  2931  // Since: 2.9
  2932  type BlkdebugEvent int32
  2933  
  2934  const (
  2935  	BlkdebugEventL1_Update BlkdebugEvent = iota
  2936  	BlkdebugEventL1_Grow_Alloc_Table
  2937  	BlkdebugEventL1_Grow_Write_Table
  2938  	BlkdebugEventL1_Grow_Activate_Table
  2939  	BlkdebugEventL2_Load
  2940  	BlkdebugEventL2_Update
  2941  	BlkdebugEventL2_Update_Compressed
  2942  	BlkdebugEventL2_Alloc_Cow_Read
  2943  	BlkdebugEventL2_Alloc_Write
  2944  	BlkdebugEventRead_Aio
  2945  	BlkdebugEventRead_Backing_Aio
  2946  	BlkdebugEventRead_Compressed
  2947  	BlkdebugEventWrite_Aio
  2948  	BlkdebugEventWrite_Compressed
  2949  	BlkdebugEventVmstate_Load
  2950  	BlkdebugEventVmstate_Save
  2951  	BlkdebugEventCow_Read
  2952  	BlkdebugEventCow_Write
  2953  	BlkdebugEventReftable_Load
  2954  	BlkdebugEventReftable_Grow
  2955  	BlkdebugEventReftable_Update
  2956  	BlkdebugEventRefblock_Load
  2957  	BlkdebugEventRefblock_Update
  2958  	BlkdebugEventRefblock_Update_Part
  2959  	BlkdebugEventRefblock_Alloc
  2960  	BlkdebugEventRefblock_Alloc_Hookup
  2961  	BlkdebugEventRefblock_Alloc_Write
  2962  	BlkdebugEventRefblock_Alloc_Write_Blocks
  2963  	BlkdebugEventRefblock_Alloc_Write_Table
  2964  	BlkdebugEventRefblock_Alloc_Switch_Table
  2965  	BlkdebugEventCluster_Alloc
  2966  	BlkdebugEventCluster_Alloc_Bytes
  2967  	BlkdebugEventCluster_Free
  2968  	BlkdebugEventFlush_To_Os
  2969  	BlkdebugEventFlush_To_Disk
  2970  	BlkdebugEventPwritev_Rmw_Head
  2971  	BlkdebugEventPwritev_Rmw_After_Head
  2972  	BlkdebugEventPwritev_Rmw_Tail
  2973  	BlkdebugEventPwritev_Rmw_After_Tail
  2974  	BlkdebugEventPwritev
  2975  	BlkdebugEventPwritev_Zero
  2976  	BlkdebugEventPwritev_Done
  2977  	BlkdebugEventEmpty_Image_Prepare
  2978  	BlkdebugEventL1_Shrink_Write_Table      // write zeros to the l1 table to shrink image. (since 2.11)
  2979  	BlkdebugEventL1_Shrink_Free_L2_Clusters // discard the l2 tables. (since 2.11)
  2980  	BlkdebugEventCor_Write                  // a write due to copy-on-read (since 2.11)
  2981  	BlkdebugEventCluster_Alloc_Space        // an allocation of file space for a cluster (since 4.1)
  2982  	BlkdebugEventNone                       // triggers once at creation of the blkdebug node (since 4.1)
  2983  )
  2984  
  2985  func (s BlkdebugEvent) MarshalJSON() ([]byte, error) {
  2986  	switch s {
  2987  	case BlkdebugEventL1_Update:
  2988  		return []byte(`"l1_update"`), nil
  2989  	case BlkdebugEventL1_Grow_Alloc_Table:
  2990  		return []byte(`"l1_grow_alloc_table"`), nil
  2991  	case BlkdebugEventL1_Grow_Write_Table:
  2992  		return []byte(`"l1_grow_write_table"`), nil
  2993  	case BlkdebugEventL1_Grow_Activate_Table:
  2994  		return []byte(`"l1_grow_activate_table"`), nil
  2995  	case BlkdebugEventL2_Load:
  2996  		return []byte(`"l2_load"`), nil
  2997  	case BlkdebugEventL2_Update:
  2998  		return []byte(`"l2_update"`), nil
  2999  	case BlkdebugEventL2_Update_Compressed:
  3000  		return []byte(`"l2_update_compressed"`), nil
  3001  	case BlkdebugEventL2_Alloc_Cow_Read:
  3002  		return []byte(`"l2_alloc_cow_read"`), nil
  3003  	case BlkdebugEventL2_Alloc_Write:
  3004  		return []byte(`"l2_alloc_write"`), nil
  3005  	case BlkdebugEventRead_Aio:
  3006  		return []byte(`"read_aio"`), nil
  3007  	case BlkdebugEventRead_Backing_Aio:
  3008  		return []byte(`"read_backing_aio"`), nil
  3009  	case BlkdebugEventRead_Compressed:
  3010  		return []byte(`"read_compressed"`), nil
  3011  	case BlkdebugEventWrite_Aio:
  3012  		return []byte(`"write_aio"`), nil
  3013  	case BlkdebugEventWrite_Compressed:
  3014  		return []byte(`"write_compressed"`), nil
  3015  	case BlkdebugEventVmstate_Load:
  3016  		return []byte(`"vmstate_load"`), nil
  3017  	case BlkdebugEventVmstate_Save:
  3018  		return []byte(`"vmstate_save"`), nil
  3019  	case BlkdebugEventCow_Read:
  3020  		return []byte(`"cow_read"`), nil
  3021  	case BlkdebugEventCow_Write:
  3022  		return []byte(`"cow_write"`), nil
  3023  	case BlkdebugEventReftable_Load:
  3024  		return []byte(`"reftable_load"`), nil
  3025  	case BlkdebugEventReftable_Grow:
  3026  		return []byte(`"reftable_grow"`), nil
  3027  	case BlkdebugEventReftable_Update:
  3028  		return []byte(`"reftable_update"`), nil
  3029  	case BlkdebugEventRefblock_Load:
  3030  		return []byte(`"refblock_load"`), nil
  3031  	case BlkdebugEventRefblock_Update:
  3032  		return []byte(`"refblock_update"`), nil
  3033  	case BlkdebugEventRefblock_Update_Part:
  3034  		return []byte(`"refblock_update_part"`), nil
  3035  	case BlkdebugEventRefblock_Alloc:
  3036  		return []byte(`"refblock_alloc"`), nil
  3037  	case BlkdebugEventRefblock_Alloc_Hookup:
  3038  		return []byte(`"refblock_alloc_hookup"`), nil
  3039  	case BlkdebugEventRefblock_Alloc_Write:
  3040  		return []byte(`"refblock_alloc_write"`), nil
  3041  	case BlkdebugEventRefblock_Alloc_Write_Blocks:
  3042  		return []byte(`"refblock_alloc_write_blocks"`), nil
  3043  	case BlkdebugEventRefblock_Alloc_Write_Table:
  3044  		return []byte(`"refblock_alloc_write_table"`), nil
  3045  	case BlkdebugEventRefblock_Alloc_Switch_Table:
  3046  		return []byte(`"refblock_alloc_switch_table"`), nil
  3047  	case BlkdebugEventCluster_Alloc:
  3048  		return []byte(`"cluster_alloc"`), nil
  3049  	case BlkdebugEventCluster_Alloc_Bytes:
  3050  		return []byte(`"cluster_alloc_bytes"`), nil
  3051  	case BlkdebugEventCluster_Free:
  3052  		return []byte(`"cluster_free"`), nil
  3053  	case BlkdebugEventFlush_To_Os:
  3054  		return []byte(`"flush_to_os"`), nil
  3055  	case BlkdebugEventFlush_To_Disk:
  3056  		return []byte(`"flush_to_disk"`), nil
  3057  	case BlkdebugEventPwritev_Rmw_Head:
  3058  		return []byte(`"pwritev_rmw_head"`), nil
  3059  	case BlkdebugEventPwritev_Rmw_After_Head:
  3060  		return []byte(`"pwritev_rmw_after_head"`), nil
  3061  	case BlkdebugEventPwritev_Rmw_Tail:
  3062  		return []byte(`"pwritev_rmw_tail"`), nil
  3063  	case BlkdebugEventPwritev_Rmw_After_Tail:
  3064  		return []byte(`"pwritev_rmw_after_tail"`), nil
  3065  	case BlkdebugEventPwritev:
  3066  		return []byte(`"pwritev"`), nil
  3067  	case BlkdebugEventPwritev_Zero:
  3068  		return []byte(`"pwritev_zero"`), nil
  3069  	case BlkdebugEventPwritev_Done:
  3070  		return []byte(`"pwritev_done"`), nil
  3071  	case BlkdebugEventEmpty_Image_Prepare:
  3072  		return []byte(`"empty_image_prepare"`), nil
  3073  	case BlkdebugEventL1_Shrink_Write_Table:
  3074  		return []byte(`"l1_shrink_write_table"`), nil
  3075  	case BlkdebugEventL1_Shrink_Free_L2_Clusters:
  3076  		return []byte(`"l1_shrink_free_l2_clusters"`), nil
  3077  	case BlkdebugEventCor_Write:
  3078  		return []byte(`"cor_write"`), nil
  3079  	case BlkdebugEventCluster_Alloc_Space:
  3080  		return []byte(`"cluster_alloc_space"`), nil
  3081  	case BlkdebugEventNone:
  3082  		return []byte(`"none"`), nil
  3083  	default:
  3084  		fmt.Println("Failed to decode BlkdebugEvent", s)
  3085  	}
  3086  	return nil, errors.New("Failed")
  3087  }
  3088  
  3089  func (s *BlkdebugEvent) UnmarshalJSON(data []byte) error {
  3090  	var name string
  3091  
  3092  	if err := json.Unmarshal(data, &name); err != nil {
  3093  		return err
  3094  	}
  3095  
  3096  	switch name {
  3097  	case "l1_update":
  3098  		(*s) = BlkdebugEventL1_Update
  3099  	case "l1_grow_alloc_table":
  3100  		(*s) = BlkdebugEventL1_Grow_Alloc_Table
  3101  	case "l1_grow_write_table":
  3102  		(*s) = BlkdebugEventL1_Grow_Write_Table
  3103  	case "l1_grow_activate_table":
  3104  		(*s) = BlkdebugEventL1_Grow_Activate_Table
  3105  	case "l2_load":
  3106  		(*s) = BlkdebugEventL2_Load
  3107  	case "l2_update":
  3108  		(*s) = BlkdebugEventL2_Update
  3109  	case "l2_update_compressed":
  3110  		(*s) = BlkdebugEventL2_Update_Compressed
  3111  	case "l2_alloc_cow_read":
  3112  		(*s) = BlkdebugEventL2_Alloc_Cow_Read
  3113  	case "l2_alloc_write":
  3114  		(*s) = BlkdebugEventL2_Alloc_Write
  3115  	case "read_aio":
  3116  		(*s) = BlkdebugEventRead_Aio
  3117  	case "read_backing_aio":
  3118  		(*s) = BlkdebugEventRead_Backing_Aio
  3119  	case "read_compressed":
  3120  		(*s) = BlkdebugEventRead_Compressed
  3121  	case "write_aio":
  3122  		(*s) = BlkdebugEventWrite_Aio
  3123  	case "write_compressed":
  3124  		(*s) = BlkdebugEventWrite_Compressed
  3125  	case "vmstate_load":
  3126  		(*s) = BlkdebugEventVmstate_Load
  3127  	case "vmstate_save":
  3128  		(*s) = BlkdebugEventVmstate_Save
  3129  	case "cow_read":
  3130  		(*s) = BlkdebugEventCow_Read
  3131  	case "cow_write":
  3132  		(*s) = BlkdebugEventCow_Write
  3133  	case "reftable_load":
  3134  		(*s) = BlkdebugEventReftable_Load
  3135  	case "reftable_grow":
  3136  		(*s) = BlkdebugEventReftable_Grow
  3137  	case "reftable_update":
  3138  		(*s) = BlkdebugEventReftable_Update
  3139  	case "refblock_load":
  3140  		(*s) = BlkdebugEventRefblock_Load
  3141  	case "refblock_update":
  3142  		(*s) = BlkdebugEventRefblock_Update
  3143  	case "refblock_update_part":
  3144  		(*s) = BlkdebugEventRefblock_Update_Part
  3145  	case "refblock_alloc":
  3146  		(*s) = BlkdebugEventRefblock_Alloc
  3147  	case "refblock_alloc_hookup":
  3148  		(*s) = BlkdebugEventRefblock_Alloc_Hookup
  3149  	case "refblock_alloc_write":
  3150  		(*s) = BlkdebugEventRefblock_Alloc_Write
  3151  	case "refblock_alloc_write_blocks":
  3152  		(*s) = BlkdebugEventRefblock_Alloc_Write_Blocks
  3153  	case "refblock_alloc_write_table":
  3154  		(*s) = BlkdebugEventRefblock_Alloc_Write_Table
  3155  	case "refblock_alloc_switch_table":
  3156  		(*s) = BlkdebugEventRefblock_Alloc_Switch_Table
  3157  	case "cluster_alloc":
  3158  		(*s) = BlkdebugEventCluster_Alloc
  3159  	case "cluster_alloc_bytes":
  3160  		(*s) = BlkdebugEventCluster_Alloc_Bytes
  3161  	case "cluster_free":
  3162  		(*s) = BlkdebugEventCluster_Free
  3163  	case "flush_to_os":
  3164  		(*s) = BlkdebugEventFlush_To_Os
  3165  	case "flush_to_disk":
  3166  		(*s) = BlkdebugEventFlush_To_Disk
  3167  	case "pwritev_rmw_head":
  3168  		(*s) = BlkdebugEventPwritev_Rmw_Head
  3169  	case "pwritev_rmw_after_head":
  3170  		(*s) = BlkdebugEventPwritev_Rmw_After_Head
  3171  	case "pwritev_rmw_tail":
  3172  		(*s) = BlkdebugEventPwritev_Rmw_Tail
  3173  	case "pwritev_rmw_after_tail":
  3174  		(*s) = BlkdebugEventPwritev_Rmw_After_Tail
  3175  	case "pwritev":
  3176  		(*s) = BlkdebugEventPwritev
  3177  	case "pwritev_zero":
  3178  		(*s) = BlkdebugEventPwritev_Zero
  3179  	case "pwritev_done":
  3180  		(*s) = BlkdebugEventPwritev_Done
  3181  	case "empty_image_prepare":
  3182  		(*s) = BlkdebugEventEmpty_Image_Prepare
  3183  	case "l1_shrink_write_table":
  3184  		(*s) = BlkdebugEventL1_Shrink_Write_Table
  3185  	case "l1_shrink_free_l2_clusters":
  3186  		(*s) = BlkdebugEventL1_Shrink_Free_L2_Clusters
  3187  	case "cor_write":
  3188  		(*s) = BlkdebugEventCor_Write
  3189  	case "cluster_alloc_space":
  3190  		(*s) = BlkdebugEventCluster_Alloc_Space
  3191  	case "none":
  3192  		(*s) = BlkdebugEventNone
  3193  	default:
  3194  		fmt.Println("Failed to decode BlkdebugEvent", *s)
  3195  	}
  3196  	return nil
  3197  }
  3198  
  3199  // Kinds of I/O that blkdebug can inject errors in.
  3200  //
  3201  // Since: 4.1
  3202  type BlkdebugIOType int32
  3203  
  3204  const (
  3205  	BlkdebugIOTypeRead        BlkdebugIOType = iota
  3206  	BlkdebugIOTypeWrite                      // .bdrv_co_pwritev()
  3207  	BlkdebugIOTypeWriteZeroes                // .bdrv_co_pwrite_zeroes()
  3208  	BlkdebugIOTypeDiscard                    // .bdrv_co_pdiscard()
  3209  	BlkdebugIOTypeFlush                      // .bdrv_co_flush_to_disk()
  3210  	BlkdebugIOTypeBlockStatus                // .bdrv_co_block_status()
  3211  )
  3212  
  3213  func (s BlkdebugIOType) MarshalJSON() ([]byte, error) {
  3214  	switch s {
  3215  	case BlkdebugIOTypeRead:
  3216  		return []byte(`"read"`), nil
  3217  	case BlkdebugIOTypeWrite:
  3218  		return []byte(`"write"`), nil
  3219  	case BlkdebugIOTypeWriteZeroes:
  3220  		return []byte(`"write-zeroes"`), nil
  3221  	case BlkdebugIOTypeDiscard:
  3222  		return []byte(`"discard"`), nil
  3223  	case BlkdebugIOTypeFlush:
  3224  		return []byte(`"flush"`), nil
  3225  	case BlkdebugIOTypeBlockStatus:
  3226  		return []byte(`"block-status"`), nil
  3227  	default:
  3228  		fmt.Println("Failed to decode BlkdebugIOType", s)
  3229  	}
  3230  	return nil, errors.New("Failed")
  3231  }
  3232  
  3233  func (s *BlkdebugIOType) UnmarshalJSON(data []byte) error {
  3234  	var name string
  3235  
  3236  	if err := json.Unmarshal(data, &name); err != nil {
  3237  		return err
  3238  	}
  3239  
  3240  	switch name {
  3241  	case "read":
  3242  		(*s) = BlkdebugIOTypeRead
  3243  	case "write":
  3244  		(*s) = BlkdebugIOTypeWrite
  3245  	case "write-zeroes":
  3246  		(*s) = BlkdebugIOTypeWriteZeroes
  3247  	case "discard":
  3248  		(*s) = BlkdebugIOTypeDiscard
  3249  	case "flush":
  3250  		(*s) = BlkdebugIOTypeFlush
  3251  	case "block-status":
  3252  		(*s) = BlkdebugIOTypeBlockStatus
  3253  	default:
  3254  		fmt.Println("Failed to decode BlkdebugIOType", *s)
  3255  	}
  3256  	return nil
  3257  }
  3258  
  3259  // An enumeration of quorum read patterns.
  3260  //
  3261  // Since: 2.9
  3262  type QuorumReadPattern int32
  3263  
  3264  const (
  3265  	QuorumReadPatternQuorum QuorumReadPattern = iota
  3266  	QuorumReadPatternFifo                     // read only from the first child that has not failed
  3267  )
  3268  
  3269  func (s QuorumReadPattern) MarshalJSON() ([]byte, error) {
  3270  	switch s {
  3271  	case QuorumReadPatternQuorum:
  3272  		return []byte(`"quorum"`), nil
  3273  	case QuorumReadPatternFifo:
  3274  		return []byte(`"fifo"`), nil
  3275  	default:
  3276  		fmt.Println("Failed to decode QuorumReadPattern", s)
  3277  	}
  3278  	return nil, errors.New("Failed")
  3279  }
  3280  
  3281  func (s *QuorumReadPattern) UnmarshalJSON(data []byte) error {
  3282  	var name string
  3283  
  3284  	if err := json.Unmarshal(data, &name); err != nil {
  3285  		return err
  3286  	}
  3287  
  3288  	switch name {
  3289  	case "quorum":
  3290  		(*s) = QuorumReadPatternQuorum
  3291  	case "fifo":
  3292  		(*s) = QuorumReadPatternFifo
  3293  	default:
  3294  		fmt.Println("Failed to decode QuorumReadPattern", *s)
  3295  	}
  3296  	return nil
  3297  }
  3298  
  3299  // An enumeration of libiscsi transport types
  3300  //
  3301  // Since: 2.9
  3302  type IscsiTransport int32
  3303  
  3304  const (
  3305  	IscsiTransportTcp IscsiTransport = iota
  3306  	IscsiTransportIser
  3307  )
  3308  
  3309  func (s IscsiTransport) MarshalJSON() ([]byte, error) {
  3310  	switch s {
  3311  	case IscsiTransportTcp:
  3312  		return []byte(`"tcp"`), nil
  3313  	case IscsiTransportIser:
  3314  		return []byte(`"iser"`), nil
  3315  	default:
  3316  		fmt.Println("Failed to decode IscsiTransport", s)
  3317  	}
  3318  	return nil, errors.New("Failed")
  3319  }
  3320  
  3321  func (s *IscsiTransport) UnmarshalJSON(data []byte) error {
  3322  	var name string
  3323  
  3324  	if err := json.Unmarshal(data, &name); err != nil {
  3325  		return err
  3326  	}
  3327  
  3328  	switch name {
  3329  	case "tcp":
  3330  		(*s) = IscsiTransportTcp
  3331  	case "iser":
  3332  		(*s) = IscsiTransportIser
  3333  	default:
  3334  		fmt.Println("Failed to decode IscsiTransport", *s)
  3335  	}
  3336  	return nil
  3337  }
  3338  
  3339  // An enumeration of header digests supported by libiscsi
  3340  //
  3341  // Since: 2.9
  3342  type IscsiHeaderDigest int32
  3343  
  3344  const (
  3345  	IscsiHeaderDigestCrc32C IscsiHeaderDigest = iota
  3346  	IscsiHeaderDigestNone
  3347  	IscsiHeaderDigestCrc32CNone
  3348  	IscsiHeaderDigestNoneCrc32C
  3349  )
  3350  
  3351  func (s IscsiHeaderDigest) MarshalJSON() ([]byte, error) {
  3352  	switch s {
  3353  	case IscsiHeaderDigestCrc32C:
  3354  		return []byte(`"crc32c"`), nil
  3355  	case IscsiHeaderDigestNone:
  3356  		return []byte(`"none"`), nil
  3357  	case IscsiHeaderDigestCrc32CNone:
  3358  		return []byte(`"crc32c-none"`), nil
  3359  	case IscsiHeaderDigestNoneCrc32C:
  3360  		return []byte(`"none-crc32c"`), nil
  3361  	default:
  3362  		fmt.Println("Failed to decode IscsiHeaderDigest", s)
  3363  	}
  3364  	return nil, errors.New("Failed")
  3365  }
  3366  
  3367  func (s *IscsiHeaderDigest) UnmarshalJSON(data []byte) error {
  3368  	var name string
  3369  
  3370  	if err := json.Unmarshal(data, &name); err != nil {
  3371  		return err
  3372  	}
  3373  
  3374  	switch name {
  3375  	case "crc32c":
  3376  		(*s) = IscsiHeaderDigestCrc32C
  3377  	case "none":
  3378  		(*s) = IscsiHeaderDigestNone
  3379  	case "crc32c-none":
  3380  		(*s) = IscsiHeaderDigestCrc32CNone
  3381  	case "none-crc32c":
  3382  		(*s) = IscsiHeaderDigestNoneCrc32C
  3383  	default:
  3384  		fmt.Println("Failed to decode IscsiHeaderDigest", *s)
  3385  	}
  3386  	return nil
  3387  }
  3388  
  3389  // Since: 3.0
  3390  type RbdAuthMode int32
  3391  
  3392  const (
  3393  	RbdAuthModeCephx RbdAuthMode = iota
  3394  	RbdAuthModeNone
  3395  )
  3396  
  3397  func (s RbdAuthMode) MarshalJSON() ([]byte, error) {
  3398  	switch s {
  3399  	case RbdAuthModeCephx:
  3400  		return []byte(`"cephx"`), nil
  3401  	case RbdAuthModeNone:
  3402  		return []byte(`"none"`), nil
  3403  	default:
  3404  		fmt.Println("Failed to decode RbdAuthMode", s)
  3405  	}
  3406  	return nil, errors.New("Failed")
  3407  }
  3408  
  3409  func (s *RbdAuthMode) UnmarshalJSON(data []byte) error {
  3410  	var name string
  3411  
  3412  	if err := json.Unmarshal(data, &name); err != nil {
  3413  		return err
  3414  	}
  3415  
  3416  	switch name {
  3417  	case "cephx":
  3418  		(*s) = RbdAuthModeCephx
  3419  	case "none":
  3420  		(*s) = RbdAuthModeNone
  3421  	default:
  3422  		fmt.Println("Failed to decode RbdAuthMode", *s)
  3423  	}
  3424  	return nil
  3425  }
  3426  
  3427  // Since: 6.1
  3428  type RbdImageEncryptionFormat int32
  3429  
  3430  const (
  3431  	RbdImageEncryptionFormatLuks RbdImageEncryptionFormat = iota
  3432  	RbdImageEncryptionFormatLuks2
  3433  )
  3434  
  3435  func (s RbdImageEncryptionFormat) MarshalJSON() ([]byte, error) {
  3436  	switch s {
  3437  	case RbdImageEncryptionFormatLuks:
  3438  		return []byte(`"luks"`), nil
  3439  	case RbdImageEncryptionFormatLuks2:
  3440  		return []byte(`"luks2"`), nil
  3441  	default:
  3442  		fmt.Println("Failed to decode RbdImageEncryptionFormat", s)
  3443  	}
  3444  	return nil, errors.New("Failed")
  3445  }
  3446  
  3447  func (s *RbdImageEncryptionFormat) UnmarshalJSON(data []byte) error {
  3448  	var name string
  3449  
  3450  	if err := json.Unmarshal(data, &name); err != nil {
  3451  		return err
  3452  	}
  3453  
  3454  	switch name {
  3455  	case "luks":
  3456  		(*s) = RbdImageEncryptionFormatLuks
  3457  	case "luks2":
  3458  		(*s) = RbdImageEncryptionFormatLuks2
  3459  	default:
  3460  		fmt.Println("Failed to decode RbdImageEncryptionFormat", *s)
  3461  	}
  3462  	return nil
  3463  }
  3464  
  3465  // An enumeration of replication modes.
  3466  //
  3467  // Since: 2.9
  3468  type ReplicationMode int32
  3469  
  3470  const (
  3471  	ReplicationModePrimary   ReplicationMode = iota
  3472  	ReplicationModeSecondary                 // Secondary mode, receive the vm's state from primary QEMU.
  3473  )
  3474  
  3475  func (s ReplicationMode) MarshalJSON() ([]byte, error) {
  3476  	switch s {
  3477  	case ReplicationModePrimary:
  3478  		return []byte(`"primary"`), nil
  3479  	case ReplicationModeSecondary:
  3480  		return []byte(`"secondary"`), nil
  3481  	default:
  3482  		fmt.Println("Failed to decode ReplicationMode", s)
  3483  	}
  3484  	return nil, errors.New("Failed")
  3485  }
  3486  
  3487  func (s *ReplicationMode) UnmarshalJSON(data []byte) error {
  3488  	var name string
  3489  
  3490  	if err := json.Unmarshal(data, &name); err != nil {
  3491  		return err
  3492  	}
  3493  
  3494  	switch name {
  3495  	case "primary":
  3496  		(*s) = ReplicationModePrimary
  3497  	case "secondary":
  3498  		(*s) = ReplicationModeSecondary
  3499  	default:
  3500  		fmt.Println("Failed to decode ReplicationMode", *s)
  3501  	}
  3502  	return nil
  3503  }
  3504  
  3505  // An enumeration of NFS transport types
  3506  //
  3507  // Since: 2.9
  3508  type NFSTransport int32
  3509  
  3510  const (
  3511  	NFSTransportInet NFSTransport = iota
  3512  )
  3513  
  3514  func (s NFSTransport) MarshalJSON() ([]byte, error) {
  3515  	switch s {
  3516  	case NFSTransportInet:
  3517  		return []byte(`"inet"`), nil
  3518  	default:
  3519  		fmt.Println("Failed to decode NFSTransport", s)
  3520  	}
  3521  	return nil, errors.New("Failed")
  3522  }
  3523  
  3524  func (s *NFSTransport) UnmarshalJSON(data []byte) error {
  3525  	var name string
  3526  
  3527  	if err := json.Unmarshal(data, &name); err != nil {
  3528  		return err
  3529  	}
  3530  
  3531  	switch name {
  3532  	case "inet":
  3533  		(*s) = NFSTransportInet
  3534  	default:
  3535  		fmt.Println("Failed to decode NFSTransport", *s)
  3536  	}
  3537  	return nil
  3538  }
  3539  
  3540  // Since: 2.12
  3541  type BlockdevQcow2Version int32
  3542  
  3543  const (
  3544  	BlockdevQcow2VersionV2 BlockdevQcow2Version = iota
  3545  	BlockdevQcow2VersionV3                      // The extended QCOW2 format as introduced in qemu 1.1 (version 3)
  3546  )
  3547  
  3548  func (s BlockdevQcow2Version) MarshalJSON() ([]byte, error) {
  3549  	switch s {
  3550  	case BlockdevQcow2VersionV2:
  3551  		return []byte(`"v2"`), nil
  3552  	case BlockdevQcow2VersionV3:
  3553  		return []byte(`"v3"`), nil
  3554  	default:
  3555  		fmt.Println("Failed to decode BlockdevQcow2Version", s)
  3556  	}
  3557  	return nil, errors.New("Failed")
  3558  }
  3559  
  3560  func (s *BlockdevQcow2Version) UnmarshalJSON(data []byte) error {
  3561  	var name string
  3562  
  3563  	if err := json.Unmarshal(data, &name); err != nil {
  3564  		return err
  3565  	}
  3566  
  3567  	switch name {
  3568  	case "v2":
  3569  		(*s) = BlockdevQcow2VersionV2
  3570  	case "v3":
  3571  		(*s) = BlockdevQcow2VersionV3
  3572  	default:
  3573  		fmt.Println("Failed to decode BlockdevQcow2Version", *s)
  3574  	}
  3575  	return nil
  3576  }
  3577  
  3578  // Compression type used in qcow2 image file
  3579  //
  3580  // Since: 5.1
  3581  type Qcow2CompressionType int32
  3582  
  3583  const (
  3584  	Qcow2CompressionTypeZlib Qcow2CompressionType = iota
  3585  	Qcow2CompressionTypeZstd                      // zstd compression, see <http://github.com/facebook/zstd>
  3586  )
  3587  
  3588  func (s Qcow2CompressionType) MarshalJSON() ([]byte, error) {
  3589  	switch s {
  3590  	case Qcow2CompressionTypeZlib:
  3591  		return []byte(`"zlib"`), nil
  3592  	case Qcow2CompressionTypeZstd:
  3593  		return []byte(`"zstd"`), nil
  3594  	default:
  3595  		fmt.Println("Failed to decode Qcow2CompressionType", s)
  3596  	}
  3597  	return nil, errors.New("Failed")
  3598  }
  3599  
  3600  func (s *Qcow2CompressionType) UnmarshalJSON(data []byte) error {
  3601  	var name string
  3602  
  3603  	if err := json.Unmarshal(data, &name); err != nil {
  3604  		return err
  3605  	}
  3606  
  3607  	switch name {
  3608  	case "zlib":
  3609  		(*s) = Qcow2CompressionTypeZlib
  3610  	case "zstd":
  3611  		(*s) = Qcow2CompressionTypeZstd
  3612  	default:
  3613  		fmt.Println("Failed to decode Qcow2CompressionType", *s)
  3614  	}
  3615  	return nil
  3616  }
  3617  
  3618  // Subformat options for VMDK images
  3619  //
  3620  // Since: 4.0
  3621  type BlockdevVmdkSubformat int32
  3622  
  3623  const (
  3624  	BlockdevVmdkSubformatMonolithicsparse     BlockdevVmdkSubformat = iota
  3625  	BlockdevVmdkSubformatMonolithicflat                             // Single flat data image and a descriptor file
  3626  	BlockdevVmdkSubformatTwogbmaxextentsparse                       // Data is split into 2GB (per virtual LBA) sparse extent files, in addition to a descriptor file
  3627  	BlockdevVmdkSubformatTwogbmaxextentflat                         // Data is split into 2GB (per virtual LBA) flat extent files, in addition to a descriptor file
  3628  	BlockdevVmdkSubformatStreamoptimized                            // Single file image sparse cluster allocation, optimized for streaming over network.
  3629  )
  3630  
  3631  func (s BlockdevVmdkSubformat) MarshalJSON() ([]byte, error) {
  3632  	switch s {
  3633  	case BlockdevVmdkSubformatMonolithicsparse:
  3634  		return []byte(`"monolithicSparse"`), nil
  3635  	case BlockdevVmdkSubformatMonolithicflat:
  3636  		return []byte(`"monolithicFlat"`), nil
  3637  	case BlockdevVmdkSubformatTwogbmaxextentsparse:
  3638  		return []byte(`"twoGbMaxExtentSparse"`), nil
  3639  	case BlockdevVmdkSubformatTwogbmaxextentflat:
  3640  		return []byte(`"twoGbMaxExtentFlat"`), nil
  3641  	case BlockdevVmdkSubformatStreamoptimized:
  3642  		return []byte(`"streamOptimized"`), nil
  3643  	default:
  3644  		fmt.Println("Failed to decode BlockdevVmdkSubformat", s)
  3645  	}
  3646  	return nil, errors.New("Failed")
  3647  }
  3648  
  3649  func (s *BlockdevVmdkSubformat) UnmarshalJSON(data []byte) error {
  3650  	var name string
  3651  
  3652  	if err := json.Unmarshal(data, &name); err != nil {
  3653  		return err
  3654  	}
  3655  
  3656  	switch name {
  3657  	case "monolithicSparse":
  3658  		(*s) = BlockdevVmdkSubformatMonolithicsparse
  3659  	case "monolithicFlat":
  3660  		(*s) = BlockdevVmdkSubformatMonolithicflat
  3661  	case "twoGbMaxExtentSparse":
  3662  		(*s) = BlockdevVmdkSubformatTwogbmaxextentsparse
  3663  	case "twoGbMaxExtentFlat":
  3664  		(*s) = BlockdevVmdkSubformatTwogbmaxextentflat
  3665  	case "streamOptimized":
  3666  		(*s) = BlockdevVmdkSubformatStreamoptimized
  3667  	default:
  3668  		fmt.Println("Failed to decode BlockdevVmdkSubformat", *s)
  3669  	}
  3670  	return nil
  3671  }
  3672  
  3673  // Adapter type info for VMDK images
  3674  //
  3675  // Since: 4.0
  3676  type BlockdevVmdkAdapterType int32
  3677  
  3678  const (
  3679  	BlockdevVmdkAdapterTypeIde BlockdevVmdkAdapterType = iota
  3680  	BlockdevVmdkAdapterTypeBuslogic
  3681  	BlockdevVmdkAdapterTypeLsilogic
  3682  	BlockdevVmdkAdapterTypeLegacyesx
  3683  )
  3684  
  3685  func (s BlockdevVmdkAdapterType) MarshalJSON() ([]byte, error) {
  3686  	switch s {
  3687  	case BlockdevVmdkAdapterTypeIde:
  3688  		return []byte(`"ide"`), nil
  3689  	case BlockdevVmdkAdapterTypeBuslogic:
  3690  		return []byte(`"buslogic"`), nil
  3691  	case BlockdevVmdkAdapterTypeLsilogic:
  3692  		return []byte(`"lsilogic"`), nil
  3693  	case BlockdevVmdkAdapterTypeLegacyesx:
  3694  		return []byte(`"legacyESX"`), nil
  3695  	default:
  3696  		fmt.Println("Failed to decode BlockdevVmdkAdapterType", s)
  3697  	}
  3698  	return nil, errors.New("Failed")
  3699  }
  3700  
  3701  func (s *BlockdevVmdkAdapterType) UnmarshalJSON(data []byte) error {
  3702  	var name string
  3703  
  3704  	if err := json.Unmarshal(data, &name); err != nil {
  3705  		return err
  3706  	}
  3707  
  3708  	switch name {
  3709  	case "ide":
  3710  		(*s) = BlockdevVmdkAdapterTypeIde
  3711  	case "buslogic":
  3712  		(*s) = BlockdevVmdkAdapterTypeBuslogic
  3713  	case "lsilogic":
  3714  		(*s) = BlockdevVmdkAdapterTypeLsilogic
  3715  	case "legacyESX":
  3716  		(*s) = BlockdevVmdkAdapterTypeLegacyesx
  3717  	default:
  3718  		fmt.Println("Failed to decode BlockdevVmdkAdapterType", *s)
  3719  	}
  3720  	return nil
  3721  }
  3722  
  3723  // Since: 2.12
  3724  type BlockdevVhdxSubformat int32
  3725  
  3726  const (
  3727  	BlockdevVhdxSubformatDynamic BlockdevVhdxSubformat = iota
  3728  	BlockdevVhdxSubformatFixed                         // Preallocated fixed-size image file
  3729  )
  3730  
  3731  func (s BlockdevVhdxSubformat) MarshalJSON() ([]byte, error) {
  3732  	switch s {
  3733  	case BlockdevVhdxSubformatDynamic:
  3734  		return []byte(`"dynamic"`), nil
  3735  	case BlockdevVhdxSubformatFixed:
  3736  		return []byte(`"fixed"`), nil
  3737  	default:
  3738  		fmt.Println("Failed to decode BlockdevVhdxSubformat", s)
  3739  	}
  3740  	return nil, errors.New("Failed")
  3741  }
  3742  
  3743  func (s *BlockdevVhdxSubformat) UnmarshalJSON(data []byte) error {
  3744  	var name string
  3745  
  3746  	if err := json.Unmarshal(data, &name); err != nil {
  3747  		return err
  3748  	}
  3749  
  3750  	switch name {
  3751  	case "dynamic":
  3752  		(*s) = BlockdevVhdxSubformatDynamic
  3753  	case "fixed":
  3754  		(*s) = BlockdevVhdxSubformatFixed
  3755  	default:
  3756  		fmt.Println("Failed to decode BlockdevVhdxSubformat", *s)
  3757  	}
  3758  	return nil
  3759  }
  3760  
  3761  // Since: 2.12
  3762  type BlockdevVpcSubformat int32
  3763  
  3764  const (
  3765  	BlockdevVpcSubformatDynamic BlockdevVpcSubformat = iota
  3766  	BlockdevVpcSubformatFixed                        // Preallocated fixed-size image file
  3767  )
  3768  
  3769  func (s BlockdevVpcSubformat) MarshalJSON() ([]byte, error) {
  3770  	switch s {
  3771  	case BlockdevVpcSubformatDynamic:
  3772  		return []byte(`"dynamic"`), nil
  3773  	case BlockdevVpcSubformatFixed:
  3774  		return []byte(`"fixed"`), nil
  3775  	default:
  3776  		fmt.Println("Failed to decode BlockdevVpcSubformat", s)
  3777  	}
  3778  	return nil, errors.New("Failed")
  3779  }
  3780  
  3781  func (s *BlockdevVpcSubformat) UnmarshalJSON(data []byte) error {
  3782  	var name string
  3783  
  3784  	if err := json.Unmarshal(data, &name); err != nil {
  3785  		return err
  3786  	}
  3787  
  3788  	switch name {
  3789  	case "dynamic":
  3790  		(*s) = BlockdevVpcSubformatDynamic
  3791  	case "fixed":
  3792  		(*s) = BlockdevVpcSubformatFixed
  3793  	default:
  3794  		fmt.Println("Failed to decode BlockdevVpcSubformat", *s)
  3795  	}
  3796  	return nil
  3797  }
  3798  
  3799  // An enumeration of action that has been taken when a DISK I/O occurs
  3800  //
  3801  // Since: 2.1
  3802  type BlockErrorAction int32
  3803  
  3804  const (
  3805  	BlockErrorActionIgnore BlockErrorAction = iota
  3806  	BlockErrorActionReport                  // error has been reported to the device
  3807  	BlockErrorActionStop                    // error caused VM to be stopped
  3808  )
  3809  
  3810  func (s BlockErrorAction) MarshalJSON() ([]byte, error) {
  3811  	switch s {
  3812  	case BlockErrorActionIgnore:
  3813  		return []byte(`"ignore"`), nil
  3814  	case BlockErrorActionReport:
  3815  		return []byte(`"report"`), nil
  3816  	case BlockErrorActionStop:
  3817  		return []byte(`"stop"`), nil
  3818  	default:
  3819  		fmt.Println("Failed to decode BlockErrorAction", s)
  3820  	}
  3821  	return nil, errors.New("Failed")
  3822  }
  3823  
  3824  func (s *BlockErrorAction) UnmarshalJSON(data []byte) error {
  3825  	var name string
  3826  
  3827  	if err := json.Unmarshal(data, &name); err != nil {
  3828  		return err
  3829  	}
  3830  
  3831  	switch name {
  3832  	case "ignore":
  3833  		(*s) = BlockErrorActionIgnore
  3834  	case "report":
  3835  		(*s) = BlockErrorActionReport
  3836  	case "stop":
  3837  		(*s) = BlockErrorActionStop
  3838  	default:
  3839  		fmt.Println("Failed to decode BlockErrorAction", *s)
  3840  	}
  3841  	return nil
  3842  }
  3843  
  3844  // Preallocation mode of QEMU image file
  3845  //
  3846  // Since: 2.2
  3847  type PreallocMode int32
  3848  
  3849  const (
  3850  	PreallocModeOff      PreallocMode = iota
  3851  	PreallocModeMetadata              // preallocate only for metadata
  3852  	PreallocModeFalloc                // like @full preallocation but allocate disk space by posix_fallocate() rather than writing data.
  3853  	PreallocModeFull                  // preallocate all data by writing it to the device to ensure disk space is really available. This data may or may not be zero, depending on the image format and storage. @full preallocation also sets up metadata correctly.
  3854  )
  3855  
  3856  func (s PreallocMode) MarshalJSON() ([]byte, error) {
  3857  	switch s {
  3858  	case PreallocModeOff:
  3859  		return []byte(`"off"`), nil
  3860  	case PreallocModeMetadata:
  3861  		return []byte(`"metadata"`), nil
  3862  	case PreallocModeFalloc:
  3863  		return []byte(`"falloc"`), nil
  3864  	case PreallocModeFull:
  3865  		return []byte(`"full"`), nil
  3866  	default:
  3867  		fmt.Println("Failed to decode PreallocMode", s)
  3868  	}
  3869  	return nil, errors.New("Failed")
  3870  }
  3871  
  3872  func (s *PreallocMode) UnmarshalJSON(data []byte) error {
  3873  	var name string
  3874  
  3875  	if err := json.Unmarshal(data, &name); err != nil {
  3876  		return err
  3877  	}
  3878  
  3879  	switch name {
  3880  	case "off":
  3881  		(*s) = PreallocModeOff
  3882  	case "metadata":
  3883  		(*s) = PreallocModeMetadata
  3884  	case "falloc":
  3885  		(*s) = PreallocModeFalloc
  3886  	case "full":
  3887  		(*s) = PreallocModeFull
  3888  	default:
  3889  		fmt.Println("Failed to decode PreallocMode", *s)
  3890  	}
  3891  	return nil
  3892  }
  3893  
  3894  // An enumeration of the quorum operation types
  3895  //
  3896  // Since: 2.6
  3897  type QuorumOpType int32
  3898  
  3899  const (
  3900  	QuorumOpTypeRead  QuorumOpType = iota
  3901  	QuorumOpTypeWrite              // write operation
  3902  	QuorumOpTypeFlush              // flush operation
  3903  )
  3904  
  3905  func (s QuorumOpType) MarshalJSON() ([]byte, error) {
  3906  	switch s {
  3907  	case QuorumOpTypeRead:
  3908  		return []byte(`"read"`), nil
  3909  	case QuorumOpTypeWrite:
  3910  		return []byte(`"write"`), nil
  3911  	case QuorumOpTypeFlush:
  3912  		return []byte(`"flush"`), nil
  3913  	default:
  3914  		fmt.Println("Failed to decode QuorumOpType", s)
  3915  	}
  3916  	return nil, errors.New("Failed")
  3917  }
  3918  
  3919  func (s *QuorumOpType) UnmarshalJSON(data []byte) error {
  3920  	var name string
  3921  
  3922  	if err := json.Unmarshal(data, &name); err != nil {
  3923  		return err
  3924  	}
  3925  
  3926  	switch name {
  3927  	case "read":
  3928  		(*s) = QuorumOpTypeRead
  3929  	case "write":
  3930  		(*s) = QuorumOpTypeWrite
  3931  	case "flush":
  3932  		(*s) = QuorumOpTypeFlush
  3933  	default:
  3934  		fmt.Println("Failed to decode QuorumOpType", *s)
  3935  	}
  3936  	return nil
  3937  }
  3938  
  3939  // Type of a background job.
  3940  //
  3941  // Since: 1.7
  3942  type JobType int32
  3943  
  3944  const (
  3945  	JobTypeCommit         JobType = iota
  3946  	JobTypeStream                 // block stream job type, see "block-stream"
  3947  	JobTypeMirror                 // drive mirror job type, see "drive-mirror"
  3948  	JobTypeBackup                 // drive backup job type, see "drive-backup"
  3949  	JobTypeCreate                 // image creation job type, see "blockdev-create" (since 3.0)
  3950  	JobTypeAmend                  // image options amend job type, see "x-blockdev-amend" (since 5.1)
  3951  	JobTypeSnapshotLoad           // snapshot load job type, see "snapshot-load" (since 6.0)
  3952  	JobTypeSnapshotSave           // snapshot save job type, see "snapshot-save" (since 6.0)
  3953  	JobTypeSnapshotDelete         // snapshot delete job type, see "snapshot-delete" (since 6.0)
  3954  )
  3955  
  3956  func (s JobType) MarshalJSON() ([]byte, error) {
  3957  	switch s {
  3958  	case JobTypeCommit:
  3959  		return []byte(`"commit"`), nil
  3960  	case JobTypeStream:
  3961  		return []byte(`"stream"`), nil
  3962  	case JobTypeMirror:
  3963  		return []byte(`"mirror"`), nil
  3964  	case JobTypeBackup:
  3965  		return []byte(`"backup"`), nil
  3966  	case JobTypeCreate:
  3967  		return []byte(`"create"`), nil
  3968  	case JobTypeAmend:
  3969  		return []byte(`"amend"`), nil
  3970  	case JobTypeSnapshotLoad:
  3971  		return []byte(`"snapshot-load"`), nil
  3972  	case JobTypeSnapshotSave:
  3973  		return []byte(`"snapshot-save"`), nil
  3974  	case JobTypeSnapshotDelete:
  3975  		return []byte(`"snapshot-delete"`), nil
  3976  	default:
  3977  		fmt.Println("Failed to decode JobType", s)
  3978  	}
  3979  	return nil, errors.New("Failed")
  3980  }
  3981  
  3982  func (s *JobType) UnmarshalJSON(data []byte) error {
  3983  	var name string
  3984  
  3985  	if err := json.Unmarshal(data, &name); err != nil {
  3986  		return err
  3987  	}
  3988  
  3989  	switch name {
  3990  	case "commit":
  3991  		(*s) = JobTypeCommit
  3992  	case "stream":
  3993  		(*s) = JobTypeStream
  3994  	case "mirror":
  3995  		(*s) = JobTypeMirror
  3996  	case "backup":
  3997  		(*s) = JobTypeBackup
  3998  	case "create":
  3999  		(*s) = JobTypeCreate
  4000  	case "amend":
  4001  		(*s) = JobTypeAmend
  4002  	case "snapshot-load":
  4003  		(*s) = JobTypeSnapshotLoad
  4004  	case "snapshot-save":
  4005  		(*s) = JobTypeSnapshotSave
  4006  	case "snapshot-delete":
  4007  		(*s) = JobTypeSnapshotDelete
  4008  	default:
  4009  		fmt.Println("Failed to decode JobType", *s)
  4010  	}
  4011  	return nil
  4012  }
  4013  
  4014  // Indicates the present state of a given job in its lifetime.
  4015  //
  4016  // Since: 2.12
  4017  type JobStatus int32
  4018  
  4019  const (
  4020  	JobStatusUndefined JobStatus = iota
  4021  	JobStatusCreated             // The job has been created, but not yet started.
  4022  	JobStatusRunning             // The job is currently running.
  4023  	JobStatusPaused              // The job is running, but paused. The pause may be requested by either the QMP user or by internal processes.
  4024  	JobStatusReady               // The job is running, but is ready for the user to signal completion. This is used for long-running jobs like mirror that are designed to run indefinitely.
  4025  	JobStatusStandby             // The job is ready, but paused. This is nearly identical to @paused. The job may return to @ready or otherwise be canceled.
  4026  	JobStatusWaiting             // The job is waiting for other jobs in the transaction to converge to the waiting state. This status will likely not be visible for the last job in a transaction.
  4027  	JobStatusPending             // The job has finished its work, but has finalization steps that it needs to make prior to completing. These changes will require manual intervention via @job-finalize if auto-finalize was set to false. These pending changes may still fail.
  4028  	JobStatusAborting            // The job is in the process of being aborted, and will finish with an error. The job will afterwards report that it is @concluded. This status may not be visible to the management process.
  4029  	JobStatusConcluded           // The job has finished all work. If auto-dismiss was set to false, the job will remain in the query list until it is dismissed via @job-dismiss.
  4030  	JobStatusNull                // The job is in the process of being dismantled. This state should not ever be visible externally.
  4031  )
  4032  
  4033  func (s JobStatus) MarshalJSON() ([]byte, error) {
  4034  	switch s {
  4035  	case JobStatusUndefined:
  4036  		return []byte(`"undefined"`), nil
  4037  	case JobStatusCreated:
  4038  		return []byte(`"created"`), nil
  4039  	case JobStatusRunning:
  4040  		return []byte(`"running"`), nil
  4041  	case JobStatusPaused:
  4042  		return []byte(`"paused"`), nil
  4043  	case JobStatusReady:
  4044  		return []byte(`"ready"`), nil
  4045  	case JobStatusStandby:
  4046  		return []byte(`"standby"`), nil
  4047  	case JobStatusWaiting:
  4048  		return []byte(`"waiting"`), nil
  4049  	case JobStatusPending:
  4050  		return []byte(`"pending"`), nil
  4051  	case JobStatusAborting:
  4052  		return []byte(`"aborting"`), nil
  4053  	case JobStatusConcluded:
  4054  		return []byte(`"concluded"`), nil
  4055  	case JobStatusNull:
  4056  		return []byte(`"null"`), nil
  4057  	default:
  4058  		fmt.Println("Failed to decode JobStatus", s)
  4059  	}
  4060  	return nil, errors.New("Failed")
  4061  }
  4062  
  4063  func (s *JobStatus) UnmarshalJSON(data []byte) error {
  4064  	var name string
  4065  
  4066  	if err := json.Unmarshal(data, &name); err != nil {
  4067  		return err
  4068  	}
  4069  
  4070  	switch name {
  4071  	case "undefined":
  4072  		(*s) = JobStatusUndefined
  4073  	case "created":
  4074  		(*s) = JobStatusCreated
  4075  	case "running":
  4076  		(*s) = JobStatusRunning
  4077  	case "paused":
  4078  		(*s) = JobStatusPaused
  4079  	case "ready":
  4080  		(*s) = JobStatusReady
  4081  	case "standby":
  4082  		(*s) = JobStatusStandby
  4083  	case "waiting":
  4084  		(*s) = JobStatusWaiting
  4085  	case "pending":
  4086  		(*s) = JobStatusPending
  4087  	case "aborting":
  4088  		(*s) = JobStatusAborting
  4089  	case "concluded":
  4090  		(*s) = JobStatusConcluded
  4091  	case "null":
  4092  		(*s) = JobStatusNull
  4093  	default:
  4094  		fmt.Println("Failed to decode JobStatus", *s)
  4095  	}
  4096  	return nil
  4097  }
  4098  
  4099  // Represents command verbs that can be applied to a job.
  4100  //
  4101  // Since: 2.12
  4102  type JobVerb int32
  4103  
  4104  const (
  4105  	JobVerbCancel   JobVerb = iota
  4106  	JobVerbPause            // see @job-pause
  4107  	JobVerbResume           // see @job-resume
  4108  	JobVerbSetSpeed         // see @block-job-set-speed
  4109  	JobVerbComplete         // see @job-complete
  4110  	JobVerbDismiss          // see @job-dismiss
  4111  	JobVerbFinalize         // see @job-finalize
  4112  )
  4113  
  4114  func (s JobVerb) MarshalJSON() ([]byte, error) {
  4115  	switch s {
  4116  	case JobVerbCancel:
  4117  		return []byte(`"cancel"`), nil
  4118  	case JobVerbPause:
  4119  		return []byte(`"pause"`), nil
  4120  	case JobVerbResume:
  4121  		return []byte(`"resume"`), nil
  4122  	case JobVerbSetSpeed:
  4123  		return []byte(`"set-speed"`), nil
  4124  	case JobVerbComplete:
  4125  		return []byte(`"complete"`), nil
  4126  	case JobVerbDismiss:
  4127  		return []byte(`"dismiss"`), nil
  4128  	case JobVerbFinalize:
  4129  		return []byte(`"finalize"`), nil
  4130  	default:
  4131  		fmt.Println("Failed to decode JobVerb", s)
  4132  	}
  4133  	return nil, errors.New("Failed")
  4134  }
  4135  
  4136  func (s *JobVerb) UnmarshalJSON(data []byte) error {
  4137  	var name string
  4138  
  4139  	if err := json.Unmarshal(data, &name); err != nil {
  4140  		return err
  4141  	}
  4142  
  4143  	switch name {
  4144  	case "cancel":
  4145  		(*s) = JobVerbCancel
  4146  	case "pause":
  4147  		(*s) = JobVerbPause
  4148  	case "resume":
  4149  		(*s) = JobVerbResume
  4150  	case "set-speed":
  4151  		(*s) = JobVerbSetSpeed
  4152  	case "complete":
  4153  		(*s) = JobVerbComplete
  4154  	case "dismiss":
  4155  		(*s) = JobVerbDismiss
  4156  	case "finalize":
  4157  		(*s) = JobVerbFinalize
  4158  	default:
  4159  		fmt.Println("Failed to decode JobVerb", *s)
  4160  	}
  4161  	return nil
  4162  }
  4163  
  4164  // Possible allow_other modes for FUSE exports.
  4165  //
  4166  // Since: 6.1
  4167  type FuseExportAllowOther int32
  4168  
  4169  const (
  4170  	FuseExportAllowOtherOff  FuseExportAllowOther = iota
  4171  	FuseExportAllowOtherOn                        // Pass allow_other as a mount option.
  4172  	FuseExportAllowOtherAuto                      // Try mounting with allow_other first, and if that fails, retry without allow_other.
  4173  )
  4174  
  4175  func (s FuseExportAllowOther) MarshalJSON() ([]byte, error) {
  4176  	switch s {
  4177  	case FuseExportAllowOtherOff:
  4178  		return []byte(`"off"`), nil
  4179  	case FuseExportAllowOtherOn:
  4180  		return []byte(`"on"`), nil
  4181  	case FuseExportAllowOtherAuto:
  4182  		return []byte(`"auto"`), nil
  4183  	default:
  4184  		fmt.Println("Failed to decode FuseExportAllowOther", s)
  4185  	}
  4186  	return nil, errors.New("Failed")
  4187  }
  4188  
  4189  func (s *FuseExportAllowOther) UnmarshalJSON(data []byte) error {
  4190  	var name string
  4191  
  4192  	if err := json.Unmarshal(data, &name); err != nil {
  4193  		return err
  4194  	}
  4195  
  4196  	switch name {
  4197  	case "off":
  4198  		(*s) = FuseExportAllowOtherOff
  4199  	case "on":
  4200  		(*s) = FuseExportAllowOtherOn
  4201  	case "auto":
  4202  		(*s) = FuseExportAllowOtherAuto
  4203  	default:
  4204  		fmt.Println("Failed to decode FuseExportAllowOther", *s)
  4205  	}
  4206  	return nil
  4207  }
  4208  
  4209  // Mode for removing a block export.
  4210  //
  4211  // None: Potential additional modes to be added in the future:
  4212  //
  4213  // hide: Just hide export from new clients, leave existing connections as is.
  4214  // Remove export after all clients are disconnected.
  4215  //
  4216  // soft: Hide export from new clients, answer with ESHUTDOWN for all further
  4217  // requests from existing clients.
  4218  //
  4219  // Since: 2.12
  4220  type BlockExportRemoveMode int32
  4221  
  4222  const (
  4223  	BlockExportRemoveModeSafe BlockExportRemoveMode = iota
  4224  	BlockExportRemoveModeHard                       // Drop all connections immediately and remove export.
  4225  )
  4226  
  4227  func (s BlockExportRemoveMode) MarshalJSON() ([]byte, error) {
  4228  	switch s {
  4229  	case BlockExportRemoveModeSafe:
  4230  		return []byte(`"safe"`), nil
  4231  	case BlockExportRemoveModeHard:
  4232  		return []byte(`"hard"`), nil
  4233  	default:
  4234  		fmt.Println("Failed to decode BlockExportRemoveMode", s)
  4235  	}
  4236  	return nil, errors.New("Failed")
  4237  }
  4238  
  4239  func (s *BlockExportRemoveMode) UnmarshalJSON(data []byte) error {
  4240  	var name string
  4241  
  4242  	if err := json.Unmarshal(data, &name); err != nil {
  4243  		return err
  4244  	}
  4245  
  4246  	switch name {
  4247  	case "safe":
  4248  		(*s) = BlockExportRemoveModeSafe
  4249  	case "hard":
  4250  		(*s) = BlockExportRemoveModeHard
  4251  	default:
  4252  		fmt.Println("Failed to decode BlockExportRemoveMode", *s)
  4253  	}
  4254  	return nil
  4255  }
  4256  
  4257  // An enumeration of block export types
  4258  //
  4259  // Since: 4.2
  4260  type BlockExportType int32
  4261  
  4262  const (
  4263  	BlockExportTypeNbd          BlockExportType = iota
  4264  	BlockExportTypeVhostUserBlk                 // vhost-user-blk export (since 5.2)
  4265  	BlockExportTypeFuse                         // FUSE export (since: 6.0)
  4266  )
  4267  
  4268  func (s BlockExportType) MarshalJSON() ([]byte, error) {
  4269  	switch s {
  4270  	case BlockExportTypeNbd:
  4271  		return []byte(`"nbd"`), nil
  4272  	case BlockExportTypeVhostUserBlk:
  4273  		return []byte(`"vhost-user-blk"`), nil
  4274  	case BlockExportTypeFuse:
  4275  		return []byte(`"fuse"`), nil
  4276  	default:
  4277  		fmt.Println("Failed to decode BlockExportType", s)
  4278  	}
  4279  	return nil, errors.New("Failed")
  4280  }
  4281  
  4282  func (s *BlockExportType) UnmarshalJSON(data []byte) error {
  4283  	var name string
  4284  
  4285  	if err := json.Unmarshal(data, &name); err != nil {
  4286  		return err
  4287  	}
  4288  
  4289  	switch name {
  4290  	case "nbd":
  4291  		(*s) = BlockExportTypeNbd
  4292  	case "vhost-user-blk":
  4293  		(*s) = BlockExportTypeVhostUserBlk
  4294  	case "fuse":
  4295  		(*s) = BlockExportTypeFuse
  4296  	default:
  4297  		fmt.Println("Failed to decode BlockExportType", *s)
  4298  	}
  4299  	return nil
  4300  }
  4301  
  4302  // An enumeration of data format.
  4303  //
  4304  // Since: 1.4
  4305  type DataFormat int32
  4306  
  4307  const (
  4308  	DataFormatUtf8   DataFormat = iota
  4309  	DataFormatBase64            // Data is Base64 encoded binary (RFC 3548)
  4310  )
  4311  
  4312  func (s DataFormat) MarshalJSON() ([]byte, error) {
  4313  	switch s {
  4314  	case DataFormatUtf8:
  4315  		return []byte(`"utf8"`), nil
  4316  	case DataFormatBase64:
  4317  		return []byte(`"base64"`), nil
  4318  	default:
  4319  		fmt.Println("Failed to decode DataFormat", s)
  4320  	}
  4321  	return nil, errors.New("Failed")
  4322  }
  4323  
  4324  func (s *DataFormat) UnmarshalJSON(data []byte) error {
  4325  	var name string
  4326  
  4327  	if err := json.Unmarshal(data, &name); err != nil {
  4328  		return err
  4329  	}
  4330  
  4331  	switch name {
  4332  	case "utf8":
  4333  		(*s) = DataFormatUtf8
  4334  	case "base64":
  4335  		(*s) = DataFormatBase64
  4336  	default:
  4337  		fmt.Println("Failed to decode DataFormat", *s)
  4338  	}
  4339  	return nil
  4340  }
  4341  
  4342  // Since: 1.4
  4343  type ChardevBackendKind int32
  4344  
  4345  const (
  4346  	ChardevBackendKindFile ChardevBackendKind = iota
  4347  	ChardevBackendKindSerial
  4348  	ChardevBackendKindParallel
  4349  	ChardevBackendKindPipe // Since 1.5
  4350  	ChardevBackendKindSocket
  4351  	ChardevBackendKindUdp // Since 1.5
  4352  	ChardevBackendKindPty
  4353  	ChardevBackendKindNull
  4354  	ChardevBackendKindMux         // Since 1.5
  4355  	ChardevBackendKindMsmouse     // Since 1.5
  4356  	ChardevBackendKindWctablet    // Since 2.9
  4357  	ChardevBackendKindBraille     // Since 1.5
  4358  	ChardevBackendKindTestdev     // Since 2.2
  4359  	ChardevBackendKindStdio       // Since 1.5
  4360  	ChardevBackendKindConsole     // Since 1.5
  4361  	ChardevBackendKindSpicevmc    // Since 1.5
  4362  	ChardevBackendKindSpiceport   // Since 1.5
  4363  	ChardevBackendKindQemuVdagent // Since 6.1
  4364  	ChardevBackendKindDbus        // Since 7.0
  4365  	ChardevBackendKindVc          // v1.5
  4366  	ChardevBackendKindRingbuf     // Since 1.6
  4367  	ChardevBackendKindMemory      // Since 1.5
  4368  )
  4369  
  4370  func (s ChardevBackendKind) MarshalJSON() ([]byte, error) {
  4371  	switch s {
  4372  	case ChardevBackendKindFile:
  4373  		return []byte(`"file"`), nil
  4374  	case ChardevBackendKindSerial:
  4375  		return []byte(`"serial"`), nil
  4376  	case ChardevBackendKindParallel:
  4377  		return []byte(`"parallel"`), nil
  4378  	case ChardevBackendKindPipe:
  4379  		return []byte(`"pipe"`), nil
  4380  	case ChardevBackendKindSocket:
  4381  		return []byte(`"socket"`), nil
  4382  	case ChardevBackendKindUdp:
  4383  		return []byte(`"udp"`), nil
  4384  	case ChardevBackendKindPty:
  4385  		return []byte(`"pty"`), nil
  4386  	case ChardevBackendKindNull:
  4387  		return []byte(`"null"`), nil
  4388  	case ChardevBackendKindMux:
  4389  		return []byte(`"mux"`), nil
  4390  	case ChardevBackendKindMsmouse:
  4391  		return []byte(`"msmouse"`), nil
  4392  	case ChardevBackendKindWctablet:
  4393  		return []byte(`"wctablet"`), nil
  4394  	case ChardevBackendKindBraille:
  4395  		return []byte(`"braille"`), nil
  4396  	case ChardevBackendKindTestdev:
  4397  		return []byte(`"testdev"`), nil
  4398  	case ChardevBackendKindStdio:
  4399  		return []byte(`"stdio"`), nil
  4400  	case ChardevBackendKindConsole:
  4401  		return []byte(`"console"`), nil
  4402  	case ChardevBackendKindSpicevmc:
  4403  		return []byte(`"spicevmc"`), nil
  4404  	case ChardevBackendKindSpiceport:
  4405  		return []byte(`"spiceport"`), nil
  4406  	case ChardevBackendKindQemuVdagent:
  4407  		return []byte(`"qemu-vdagent"`), nil
  4408  	case ChardevBackendKindDbus:
  4409  		return []byte(`"dbus"`), nil
  4410  	case ChardevBackendKindVc:
  4411  		return []byte(`"vc"`), nil
  4412  	case ChardevBackendKindRingbuf:
  4413  		return []byte(`"ringbuf"`), nil
  4414  	case ChardevBackendKindMemory:
  4415  		return []byte(`"memory"`), nil
  4416  	default:
  4417  		fmt.Println("Failed to decode ChardevBackendKind", s)
  4418  	}
  4419  	return nil, errors.New("Failed")
  4420  }
  4421  
  4422  func (s *ChardevBackendKind) UnmarshalJSON(data []byte) error {
  4423  	var name string
  4424  
  4425  	if err := json.Unmarshal(data, &name); err != nil {
  4426  		return err
  4427  	}
  4428  
  4429  	switch name {
  4430  	case "file":
  4431  		(*s) = ChardevBackendKindFile
  4432  	case "serial":
  4433  		(*s) = ChardevBackendKindSerial
  4434  	case "parallel":
  4435  		(*s) = ChardevBackendKindParallel
  4436  	case "pipe":
  4437  		(*s) = ChardevBackendKindPipe
  4438  	case "socket":
  4439  		(*s) = ChardevBackendKindSocket
  4440  	case "udp":
  4441  		(*s) = ChardevBackendKindUdp
  4442  	case "pty":
  4443  		(*s) = ChardevBackendKindPty
  4444  	case "null":
  4445  		(*s) = ChardevBackendKindNull
  4446  	case "mux":
  4447  		(*s) = ChardevBackendKindMux
  4448  	case "msmouse":
  4449  		(*s) = ChardevBackendKindMsmouse
  4450  	case "wctablet":
  4451  		(*s) = ChardevBackendKindWctablet
  4452  	case "braille":
  4453  		(*s) = ChardevBackendKindBraille
  4454  	case "testdev":
  4455  		(*s) = ChardevBackendKindTestdev
  4456  	case "stdio":
  4457  		(*s) = ChardevBackendKindStdio
  4458  	case "console":
  4459  		(*s) = ChardevBackendKindConsole
  4460  	case "spicevmc":
  4461  		(*s) = ChardevBackendKindSpicevmc
  4462  	case "spiceport":
  4463  		(*s) = ChardevBackendKindSpiceport
  4464  	case "qemu-vdagent":
  4465  		(*s) = ChardevBackendKindQemuVdagent
  4466  	case "dbus":
  4467  		(*s) = ChardevBackendKindDbus
  4468  	case "vc":
  4469  		(*s) = ChardevBackendKindVc
  4470  	case "ringbuf":
  4471  		(*s) = ChardevBackendKindRingbuf
  4472  	case "memory":
  4473  		(*s) = ChardevBackendKindMemory
  4474  	default:
  4475  		fmt.Println("Failed to decode ChardevBackendKind", *s)
  4476  	}
  4477  	return nil
  4478  }
  4479  
  4480  // An enumeration of guest-memory-dump's format.
  4481  //
  4482  // Since: 2.0
  4483  type DumpGuestMemoryFormat int32
  4484  
  4485  const (
  4486  	DumpGuestMemoryFormatElf         DumpGuestMemoryFormat = iota
  4487  	DumpGuestMemoryFormatKdumpZlib                         // kdump-compressed format with zlib-compressed
  4488  	DumpGuestMemoryFormatKdumpLzo                          // kdump-compressed format with lzo-compressed
  4489  	DumpGuestMemoryFormatKdumpSnappy                       // kdump-compressed format with snappy-compressed
  4490  	DumpGuestMemoryFormatWinDmp                            // Windows full crashdump format, can be used instead of ELF converting (since 2.13)
  4491  )
  4492  
  4493  func (s DumpGuestMemoryFormat) MarshalJSON() ([]byte, error) {
  4494  	switch s {
  4495  	case DumpGuestMemoryFormatElf:
  4496  		return []byte(`"elf"`), nil
  4497  	case DumpGuestMemoryFormatKdumpZlib:
  4498  		return []byte(`"kdump-zlib"`), nil
  4499  	case DumpGuestMemoryFormatKdumpLzo:
  4500  		return []byte(`"kdump-lzo"`), nil
  4501  	case DumpGuestMemoryFormatKdumpSnappy:
  4502  		return []byte(`"kdump-snappy"`), nil
  4503  	case DumpGuestMemoryFormatWinDmp:
  4504  		return []byte(`"win-dmp"`), nil
  4505  	default:
  4506  		fmt.Println("Failed to decode DumpGuestMemoryFormat", s)
  4507  	}
  4508  	return nil, errors.New("Failed")
  4509  }
  4510  
  4511  func (s *DumpGuestMemoryFormat) UnmarshalJSON(data []byte) error {
  4512  	var name string
  4513  
  4514  	if err := json.Unmarshal(data, &name); err != nil {
  4515  		return err
  4516  	}
  4517  
  4518  	switch name {
  4519  	case "elf":
  4520  		(*s) = DumpGuestMemoryFormatElf
  4521  	case "kdump-zlib":
  4522  		(*s) = DumpGuestMemoryFormatKdumpZlib
  4523  	case "kdump-lzo":
  4524  		(*s) = DumpGuestMemoryFormatKdumpLzo
  4525  	case "kdump-snappy":
  4526  		(*s) = DumpGuestMemoryFormatKdumpSnappy
  4527  	case "win-dmp":
  4528  		(*s) = DumpGuestMemoryFormatWinDmp
  4529  	default:
  4530  		fmt.Println("Failed to decode DumpGuestMemoryFormat", *s)
  4531  	}
  4532  	return nil
  4533  }
  4534  
  4535  // Describe the status of a long-running background guest memory dump.
  4536  //
  4537  // Since: 2.6
  4538  type DumpStatus int32
  4539  
  4540  const (
  4541  	DumpStatusNone      DumpStatus = iota
  4542  	DumpStatusActive               // there is one dump running in background.
  4543  	DumpStatusCompleted            // the last dump has finished successfully.
  4544  	DumpStatusFailed               // the last dump has failed.
  4545  )
  4546  
  4547  func (s DumpStatus) MarshalJSON() ([]byte, error) {
  4548  	switch s {
  4549  	case DumpStatusNone:
  4550  		return []byte(`"none"`), nil
  4551  	case DumpStatusActive:
  4552  		return []byte(`"active"`), nil
  4553  	case DumpStatusCompleted:
  4554  		return []byte(`"completed"`), nil
  4555  	case DumpStatusFailed:
  4556  		return []byte(`"failed"`), nil
  4557  	default:
  4558  		fmt.Println("Failed to decode DumpStatus", s)
  4559  	}
  4560  	return nil, errors.New("Failed")
  4561  }
  4562  
  4563  func (s *DumpStatus) UnmarshalJSON(data []byte) error {
  4564  	var name string
  4565  
  4566  	if err := json.Unmarshal(data, &name); err != nil {
  4567  		return err
  4568  	}
  4569  
  4570  	switch name {
  4571  	case "none":
  4572  		(*s) = DumpStatusNone
  4573  	case "active":
  4574  		(*s) = DumpStatusActive
  4575  	case "completed":
  4576  		(*s) = DumpStatusCompleted
  4577  	case "failed":
  4578  		(*s) = DumpStatusFailed
  4579  	default:
  4580  		fmt.Println("Failed to decode DumpStatus", *s)
  4581  	}
  4582  	return nil
  4583  }
  4584  
  4585  // Available netdev drivers.
  4586  //
  4587  // Since: 2.7
  4588  //
  4589  // @vhost-vdpa since 5.1
  4590  type NetClientDriver int32
  4591  
  4592  const (
  4593  	NetClientDriverNone NetClientDriver = iota
  4594  	NetClientDriverNic
  4595  	NetClientDriverUser
  4596  	NetClientDriverTap
  4597  	NetClientDriverL2Tpv3
  4598  	NetClientDriverSocket
  4599  	NetClientDriverVde
  4600  	NetClientDriverBridge
  4601  	NetClientDriverHubport
  4602  	NetClientDriverNetmap
  4603  	NetClientDriverVhostUser
  4604  	NetClientDriverVhostVdpa
  4605  )
  4606  
  4607  func (s NetClientDriver) MarshalJSON() ([]byte, error) {
  4608  	switch s {
  4609  	case NetClientDriverNone:
  4610  		return []byte(`"none"`), nil
  4611  	case NetClientDriverNic:
  4612  		return []byte(`"nic"`), nil
  4613  	case NetClientDriverUser:
  4614  		return []byte(`"user"`), nil
  4615  	case NetClientDriverTap:
  4616  		return []byte(`"tap"`), nil
  4617  	case NetClientDriverL2Tpv3:
  4618  		return []byte(`"l2tpv3"`), nil
  4619  	case NetClientDriverSocket:
  4620  		return []byte(`"socket"`), nil
  4621  	case NetClientDriverVde:
  4622  		return []byte(`"vde"`), nil
  4623  	case NetClientDriverBridge:
  4624  		return []byte(`"bridge"`), nil
  4625  	case NetClientDriverHubport:
  4626  		return []byte(`"hubport"`), nil
  4627  	case NetClientDriverNetmap:
  4628  		return []byte(`"netmap"`), nil
  4629  	case NetClientDriverVhostUser:
  4630  		return []byte(`"vhost-user"`), nil
  4631  	case NetClientDriverVhostVdpa:
  4632  		return []byte(`"vhost-vdpa"`), nil
  4633  	default:
  4634  		fmt.Println("Failed to decode NetClientDriver", s)
  4635  	}
  4636  	return nil, errors.New("Failed")
  4637  }
  4638  
  4639  func (s *NetClientDriver) UnmarshalJSON(data []byte) error {
  4640  	var name string
  4641  
  4642  	if err := json.Unmarshal(data, &name); err != nil {
  4643  		return err
  4644  	}
  4645  
  4646  	switch name {
  4647  	case "none":
  4648  		(*s) = NetClientDriverNone
  4649  	case "nic":
  4650  		(*s) = NetClientDriverNic
  4651  	case "user":
  4652  		(*s) = NetClientDriverUser
  4653  	case "tap":
  4654  		(*s) = NetClientDriverTap
  4655  	case "l2tpv3":
  4656  		(*s) = NetClientDriverL2Tpv3
  4657  	case "socket":
  4658  		(*s) = NetClientDriverSocket
  4659  	case "vde":
  4660  		(*s) = NetClientDriverVde
  4661  	case "bridge":
  4662  		(*s) = NetClientDriverBridge
  4663  	case "hubport":
  4664  		(*s) = NetClientDriverHubport
  4665  	case "netmap":
  4666  		(*s) = NetClientDriverNetmap
  4667  	case "vhost-user":
  4668  		(*s) = NetClientDriverVhostUser
  4669  	case "vhost-vdpa":
  4670  		(*s) = NetClientDriverVhostVdpa
  4671  	default:
  4672  		fmt.Println("Failed to decode NetClientDriver", *s)
  4673  	}
  4674  	return nil
  4675  }
  4676  
  4677  // Packets receiving state
  4678  //
  4679  // Since: 1.6
  4680  type RxState int32
  4681  
  4682  const (
  4683  	RxStateNormal RxState = iota
  4684  	RxStateNone           // don't receive any assigned packet
  4685  	RxStateAll            // receive all assigned packets
  4686  )
  4687  
  4688  func (s RxState) MarshalJSON() ([]byte, error) {
  4689  	switch s {
  4690  	case RxStateNormal:
  4691  		return []byte(`"normal"`), nil
  4692  	case RxStateNone:
  4693  		return []byte(`"none"`), nil
  4694  	case RxStateAll:
  4695  		return []byte(`"all"`), nil
  4696  	default:
  4697  		fmt.Println("Failed to decode RxState", s)
  4698  	}
  4699  	return nil, errors.New("Failed")
  4700  }
  4701  
  4702  func (s *RxState) UnmarshalJSON(data []byte) error {
  4703  	var name string
  4704  
  4705  	if err := json.Unmarshal(data, &name); err != nil {
  4706  		return err
  4707  	}
  4708  
  4709  	switch name {
  4710  	case "normal":
  4711  		(*s) = RxStateNormal
  4712  	case "none":
  4713  		(*s) = RxStateNone
  4714  	case "all":
  4715  		(*s) = RxStateAll
  4716  	default:
  4717  		fmt.Println("Failed to decode RxState", *s)
  4718  	}
  4719  	return nil
  4720  }
  4721  
  4722  // An eumeration of port duplex states.
  4723  //
  4724  // Since: 2.4
  4725  type RockerPortDuplex int32
  4726  
  4727  const (
  4728  	RockerPortDuplexHalf RockerPortDuplex = iota
  4729  	RockerPortDuplexFull                  // full duplex
  4730  )
  4731  
  4732  func (s RockerPortDuplex) MarshalJSON() ([]byte, error) {
  4733  	switch s {
  4734  	case RockerPortDuplexHalf:
  4735  		return []byte(`"half"`), nil
  4736  	case RockerPortDuplexFull:
  4737  		return []byte(`"full"`), nil
  4738  	default:
  4739  		fmt.Println("Failed to decode RockerPortDuplex", s)
  4740  	}
  4741  	return nil, errors.New("Failed")
  4742  }
  4743  
  4744  func (s *RockerPortDuplex) UnmarshalJSON(data []byte) error {
  4745  	var name string
  4746  
  4747  	if err := json.Unmarshal(data, &name); err != nil {
  4748  		return err
  4749  	}
  4750  
  4751  	switch name {
  4752  	case "half":
  4753  		(*s) = RockerPortDuplexHalf
  4754  	case "full":
  4755  		(*s) = RockerPortDuplexFull
  4756  	default:
  4757  		fmt.Println("Failed to decode RockerPortDuplex", *s)
  4758  	}
  4759  	return nil
  4760  }
  4761  
  4762  // An eumeration of port autoneg states.
  4763  //
  4764  // Since: 2.4
  4765  type RockerPortAutoneg int32
  4766  
  4767  const (
  4768  	RockerPortAutonegOff RockerPortAutoneg = iota
  4769  	RockerPortAutonegOn                    // autoneg is on
  4770  )
  4771  
  4772  func (s RockerPortAutoneg) MarshalJSON() ([]byte, error) {
  4773  	switch s {
  4774  	case RockerPortAutonegOff:
  4775  		return []byte(`"off"`), nil
  4776  	case RockerPortAutonegOn:
  4777  		return []byte(`"on"`), nil
  4778  	default:
  4779  		fmt.Println("Failed to decode RockerPortAutoneg", s)
  4780  	}
  4781  	return nil, errors.New("Failed")
  4782  }
  4783  
  4784  func (s *RockerPortAutoneg) UnmarshalJSON(data []byte) error {
  4785  	var name string
  4786  
  4787  	if err := json.Unmarshal(data, &name); err != nil {
  4788  		return err
  4789  	}
  4790  
  4791  	switch name {
  4792  	case "off":
  4793  		(*s) = RockerPortAutonegOff
  4794  	case "on":
  4795  		(*s) = RockerPortAutonegOn
  4796  	default:
  4797  		fmt.Println("Failed to decode RockerPortAutoneg", *s)
  4798  	}
  4799  	return nil
  4800  }
  4801  
  4802  // An enumeration of TPM models
  4803  //
  4804  // Since: 1.5
  4805  type TpmModel int32
  4806  
  4807  const (
  4808  	TpmModelTpmTis   TpmModel = iota
  4809  	TpmModelTpmCrb            // TPM CRB model (since 2.12)
  4810  	TpmModelTpmSpapr          // TPM SPAPR model (since 5.0)
  4811  )
  4812  
  4813  func (s TpmModel) MarshalJSON() ([]byte, error) {
  4814  	switch s {
  4815  	case TpmModelTpmTis:
  4816  		return []byte(`"tpm-tis"`), nil
  4817  	case TpmModelTpmCrb:
  4818  		return []byte(`"tpm-crb"`), nil
  4819  	case TpmModelTpmSpapr:
  4820  		return []byte(`"tpm-spapr"`), nil
  4821  	default:
  4822  		fmt.Println("Failed to decode TpmModel", s)
  4823  	}
  4824  	return nil, errors.New("Failed")
  4825  }
  4826  
  4827  func (s *TpmModel) UnmarshalJSON(data []byte) error {
  4828  	var name string
  4829  
  4830  	if err := json.Unmarshal(data, &name); err != nil {
  4831  		return err
  4832  	}
  4833  
  4834  	switch name {
  4835  	case "tpm-tis":
  4836  		(*s) = TpmModelTpmTis
  4837  	case "tpm-crb":
  4838  		(*s) = TpmModelTpmCrb
  4839  	case "tpm-spapr":
  4840  		(*s) = TpmModelTpmSpapr
  4841  	default:
  4842  		fmt.Println("Failed to decode TpmModel", *s)
  4843  	}
  4844  	return nil
  4845  }
  4846  
  4847  // An enumeration of TPM types
  4848  //
  4849  // Since: 1.5
  4850  type TpmType int32
  4851  
  4852  const (
  4853  	TpmTypePassthrough TpmType = iota
  4854  	TpmTypeEmulator            // Software Emulator TPM type Since: 2.11
  4855  )
  4856  
  4857  func (s TpmType) MarshalJSON() ([]byte, error) {
  4858  	switch s {
  4859  	case TpmTypePassthrough:
  4860  		return []byte(`"passthrough"`), nil
  4861  	case TpmTypeEmulator:
  4862  		return []byte(`"emulator"`), nil
  4863  	default:
  4864  		fmt.Println("Failed to decode TpmType", s)
  4865  	}
  4866  	return nil, errors.New("Failed")
  4867  }
  4868  
  4869  func (s *TpmType) UnmarshalJSON(data []byte) error {
  4870  	var name string
  4871  
  4872  	if err := json.Unmarshal(data, &name); err != nil {
  4873  		return err
  4874  	}
  4875  
  4876  	switch name {
  4877  	case "passthrough":
  4878  		(*s) = TpmTypePassthrough
  4879  	case "emulator":
  4880  		(*s) = TpmTypeEmulator
  4881  	default:
  4882  		fmt.Println("Failed to decode TpmType", *s)
  4883  	}
  4884  	return nil
  4885  }
  4886  
  4887  // Display protocols which support changing password options.
  4888  //
  4889  // Since: 7.0
  4890  type DisplayProtocol int32
  4891  
  4892  const (
  4893  	DisplayProtocolVnc DisplayProtocol = iota
  4894  	DisplayProtocolSpice
  4895  )
  4896  
  4897  func (s DisplayProtocol) MarshalJSON() ([]byte, error) {
  4898  	switch s {
  4899  	case DisplayProtocolVnc:
  4900  		return []byte(`"vnc"`), nil
  4901  	case DisplayProtocolSpice:
  4902  		return []byte(`"spice"`), nil
  4903  	default:
  4904  		fmt.Println("Failed to decode DisplayProtocol", s)
  4905  	}
  4906  	return nil, errors.New("Failed")
  4907  }
  4908  
  4909  func (s *DisplayProtocol) UnmarshalJSON(data []byte) error {
  4910  	var name string
  4911  
  4912  	if err := json.Unmarshal(data, &name); err != nil {
  4913  		return err
  4914  	}
  4915  
  4916  	switch name {
  4917  	case "vnc":
  4918  		(*s) = DisplayProtocolVnc
  4919  	case "spice":
  4920  		(*s) = DisplayProtocolSpice
  4921  	default:
  4922  		fmt.Println("Failed to decode DisplayProtocol", *s)
  4923  	}
  4924  	return nil
  4925  }
  4926  
  4927  // An action to take on changing a password on a connection with active clients.
  4928  //
  4929  // Since: 7.0
  4930  type SetPasswordAction int32
  4931  
  4932  const (
  4933  	SetPasswordActionKeep       SetPasswordAction = iota
  4934  	SetPasswordActionFail                         // fail the command if clients are connected
  4935  	SetPasswordActionDisconnect                   // disconnect existing clients
  4936  )
  4937  
  4938  func (s SetPasswordAction) MarshalJSON() ([]byte, error) {
  4939  	switch s {
  4940  	case SetPasswordActionKeep:
  4941  		return []byte(`"keep"`), nil
  4942  	case SetPasswordActionFail:
  4943  		return []byte(`"fail"`), nil
  4944  	case SetPasswordActionDisconnect:
  4945  		return []byte(`"disconnect"`), nil
  4946  	default:
  4947  		fmt.Println("Failed to decode SetPasswordAction", s)
  4948  	}
  4949  	return nil, errors.New("Failed")
  4950  }
  4951  
  4952  func (s *SetPasswordAction) UnmarshalJSON(data []byte) error {
  4953  	var name string
  4954  
  4955  	if err := json.Unmarshal(data, &name); err != nil {
  4956  		return err
  4957  	}
  4958  
  4959  	switch name {
  4960  	case "keep":
  4961  		(*s) = SetPasswordActionKeep
  4962  	case "fail":
  4963  		(*s) = SetPasswordActionFail
  4964  	case "disconnect":
  4965  		(*s) = SetPasswordActionDisconnect
  4966  	default:
  4967  		fmt.Println("Failed to decode SetPasswordAction", *s)
  4968  	}
  4969  	return nil
  4970  }
  4971  
  4972  // An enumeration of Spice mouse states.
  4973  //
  4974  // Note: spice/enums.h has a SpiceMouseMode already, hence the name.
  4975  //
  4976  // Since: 1.1
  4977  type SpiceQueryMouseMode int32
  4978  
  4979  const (
  4980  	SpiceQueryMouseModeClient  SpiceQueryMouseMode = iota
  4981  	SpiceQueryMouseModeServer                      // Mouse cursor position is determined by the server.
  4982  	SpiceQueryMouseModeUnknown                     // No information is available about mouse mode used by the spice server.
  4983  )
  4984  
  4985  func (s SpiceQueryMouseMode) MarshalJSON() ([]byte, error) {
  4986  	switch s {
  4987  	case SpiceQueryMouseModeClient:
  4988  		return []byte(`"client"`), nil
  4989  	case SpiceQueryMouseModeServer:
  4990  		return []byte(`"server"`), nil
  4991  	case SpiceQueryMouseModeUnknown:
  4992  		return []byte(`"unknown"`), nil
  4993  	default:
  4994  		fmt.Println("Failed to decode SpiceQueryMouseMode", s)
  4995  	}
  4996  	return nil, errors.New("Failed")
  4997  }
  4998  
  4999  func (s *SpiceQueryMouseMode) UnmarshalJSON(data []byte) error {
  5000  	var name string
  5001  
  5002  	if err := json.Unmarshal(data, &name); err != nil {
  5003  		return err
  5004  	}
  5005  
  5006  	switch name {
  5007  	case "client":
  5008  		(*s) = SpiceQueryMouseModeClient
  5009  	case "server":
  5010  		(*s) = SpiceQueryMouseModeServer
  5011  	case "unknown":
  5012  		(*s) = SpiceQueryMouseModeUnknown
  5013  	default:
  5014  		fmt.Println("Failed to decode SpiceQueryMouseMode", *s)
  5015  	}
  5016  	return nil
  5017  }
  5018  
  5019  // vnc primary authentication method.
  5020  //
  5021  // Since: 2.3
  5022  type VncPrimaryAuth int32
  5023  
  5024  const (
  5025  	VncPrimaryAuthNone VncPrimaryAuth = iota
  5026  	VncPrimaryAuthVnc
  5027  	VncPrimaryAuthRa2
  5028  	VncPrimaryAuthRa2Ne
  5029  	VncPrimaryAuthTight
  5030  	VncPrimaryAuthUltra
  5031  	VncPrimaryAuthTls
  5032  	VncPrimaryAuthVencrypt
  5033  	VncPrimaryAuthSasl
  5034  )
  5035  
  5036  func (s VncPrimaryAuth) MarshalJSON() ([]byte, error) {
  5037  	switch s {
  5038  	case VncPrimaryAuthNone:
  5039  		return []byte(`"none"`), nil
  5040  	case VncPrimaryAuthVnc:
  5041  		return []byte(`"vnc"`), nil
  5042  	case VncPrimaryAuthRa2:
  5043  		return []byte(`"ra2"`), nil
  5044  	case VncPrimaryAuthRa2Ne:
  5045  		return []byte(`"ra2ne"`), nil
  5046  	case VncPrimaryAuthTight:
  5047  		return []byte(`"tight"`), nil
  5048  	case VncPrimaryAuthUltra:
  5049  		return []byte(`"ultra"`), nil
  5050  	case VncPrimaryAuthTls:
  5051  		return []byte(`"tls"`), nil
  5052  	case VncPrimaryAuthVencrypt:
  5053  		return []byte(`"vencrypt"`), nil
  5054  	case VncPrimaryAuthSasl:
  5055  		return []byte(`"sasl"`), nil
  5056  	default:
  5057  		fmt.Println("Failed to decode VncPrimaryAuth", s)
  5058  	}
  5059  	return nil, errors.New("Failed")
  5060  }
  5061  
  5062  func (s *VncPrimaryAuth) UnmarshalJSON(data []byte) error {
  5063  	var name string
  5064  
  5065  	if err := json.Unmarshal(data, &name); err != nil {
  5066  		return err
  5067  	}
  5068  
  5069  	switch name {
  5070  	case "none":
  5071  		(*s) = VncPrimaryAuthNone
  5072  	case "vnc":
  5073  		(*s) = VncPrimaryAuthVnc
  5074  	case "ra2":
  5075  		(*s) = VncPrimaryAuthRa2
  5076  	case "ra2ne":
  5077  		(*s) = VncPrimaryAuthRa2Ne
  5078  	case "tight":
  5079  		(*s) = VncPrimaryAuthTight
  5080  	case "ultra":
  5081  		(*s) = VncPrimaryAuthUltra
  5082  	case "tls":
  5083  		(*s) = VncPrimaryAuthTls
  5084  	case "vencrypt":
  5085  		(*s) = VncPrimaryAuthVencrypt
  5086  	case "sasl":
  5087  		(*s) = VncPrimaryAuthSasl
  5088  	default:
  5089  		fmt.Println("Failed to decode VncPrimaryAuth", *s)
  5090  	}
  5091  	return nil
  5092  }
  5093  
  5094  // vnc sub authentication method with vencrypt.
  5095  //
  5096  // Since: 2.3
  5097  type VncVencryptSubAuth int32
  5098  
  5099  const (
  5100  	VncVencryptSubAuthPlain VncVencryptSubAuth = iota
  5101  	VncVencryptSubAuthTlsNone
  5102  	VncVencryptSubAuthX509None
  5103  	VncVencryptSubAuthTlsVnc
  5104  	VncVencryptSubAuthX509Vnc
  5105  	VncVencryptSubAuthTlsPlain
  5106  	VncVencryptSubAuthX509Plain
  5107  	VncVencryptSubAuthTlsSasl
  5108  	VncVencryptSubAuthX509Sasl
  5109  )
  5110  
  5111  func (s VncVencryptSubAuth) MarshalJSON() ([]byte, error) {
  5112  	switch s {
  5113  	case VncVencryptSubAuthPlain:
  5114  		return []byte(`"plain"`), nil
  5115  	case VncVencryptSubAuthTlsNone:
  5116  		return []byte(`"tls-none"`), nil
  5117  	case VncVencryptSubAuthX509None:
  5118  		return []byte(`"x509-none"`), nil
  5119  	case VncVencryptSubAuthTlsVnc:
  5120  		return []byte(`"tls-vnc"`), nil
  5121  	case VncVencryptSubAuthX509Vnc:
  5122  		return []byte(`"x509-vnc"`), nil
  5123  	case VncVencryptSubAuthTlsPlain:
  5124  		return []byte(`"tls-plain"`), nil
  5125  	case VncVencryptSubAuthX509Plain:
  5126  		return []byte(`"x509-plain"`), nil
  5127  	case VncVencryptSubAuthTlsSasl:
  5128  		return []byte(`"tls-sasl"`), nil
  5129  	case VncVencryptSubAuthX509Sasl:
  5130  		return []byte(`"x509-sasl"`), nil
  5131  	default:
  5132  		fmt.Println("Failed to decode VncVencryptSubAuth", s)
  5133  	}
  5134  	return nil, errors.New("Failed")
  5135  }
  5136  
  5137  func (s *VncVencryptSubAuth) UnmarshalJSON(data []byte) error {
  5138  	var name string
  5139  
  5140  	if err := json.Unmarshal(data, &name); err != nil {
  5141  		return err
  5142  	}
  5143  
  5144  	switch name {
  5145  	case "plain":
  5146  		(*s) = VncVencryptSubAuthPlain
  5147  	case "tls-none":
  5148  		(*s) = VncVencryptSubAuthTlsNone
  5149  	case "x509-none":
  5150  		(*s) = VncVencryptSubAuthX509None
  5151  	case "tls-vnc":
  5152  		(*s) = VncVencryptSubAuthTlsVnc
  5153  	case "x509-vnc":
  5154  		(*s) = VncVencryptSubAuthX509Vnc
  5155  	case "tls-plain":
  5156  		(*s) = VncVencryptSubAuthTlsPlain
  5157  	case "x509-plain":
  5158  		(*s) = VncVencryptSubAuthX509Plain
  5159  	case "tls-sasl":
  5160  		(*s) = VncVencryptSubAuthTlsSasl
  5161  	case "x509-sasl":
  5162  		(*s) = VncVencryptSubAuthX509Sasl
  5163  	default:
  5164  		fmt.Println("Failed to decode VncVencryptSubAuth", *s)
  5165  	}
  5166  	return nil
  5167  }
  5168  
  5169  // An enumeration of key name.
  5170  //
  5171  // This is used by the @send-key command.
  5172  //
  5173  // None: 'sysrq' was mistakenly added to hack around the fact that
  5174  // the ps2 driver was not generating correct scancodes sequences
  5175  // when 'alt+print' was pressed. This flaw is now fixed and the
  5176  // 'sysrq' key serves no further purpose. Any further use of
  5177  // 'sysrq' will be transparently changed to 'print', so they
  5178  // are effectively synonyms.
  5179  //
  5180  // Since: 1.3
  5181  type QKeyCode int32
  5182  
  5183  const (
  5184  	QKeyCodeUnmapped QKeyCode = iota
  5185  	QKeyCodeShift
  5186  	QKeyCodeShift_R
  5187  	QKeyCodeAlt
  5188  	QKeyCodeAlt_R
  5189  	QKeyCodeCtrl
  5190  	QKeyCodeCtrl_R
  5191  	QKeyCodeMenu
  5192  	QKeyCodeEsc
  5193  	QKeyCode1
  5194  	QKeyCode2
  5195  	QKeyCode3
  5196  	QKeyCode4
  5197  	QKeyCode5
  5198  	QKeyCode6
  5199  	QKeyCode7
  5200  	QKeyCode8
  5201  	QKeyCode9
  5202  	QKeyCode0
  5203  	QKeyCodeMinus
  5204  	QKeyCodeEqual
  5205  	QKeyCodeBackspace
  5206  	QKeyCodeTab
  5207  	QKeyCodeQ
  5208  	QKeyCodeW
  5209  	QKeyCodeE
  5210  	QKeyCodeR
  5211  	QKeyCodeT
  5212  	QKeyCodeY
  5213  	QKeyCodeU
  5214  	QKeyCodeI
  5215  	QKeyCodeO
  5216  	QKeyCodeP
  5217  	QKeyCodeBracket_Left
  5218  	QKeyCodeBracket_Right
  5219  	QKeyCodeRet
  5220  	QKeyCodeA
  5221  	QKeyCodeS
  5222  	QKeyCodeD
  5223  	QKeyCodeF
  5224  	QKeyCodeG
  5225  	QKeyCodeH
  5226  	QKeyCodeJ
  5227  	QKeyCodeK
  5228  	QKeyCodeL
  5229  	QKeyCodeSemicolon
  5230  	QKeyCodeApostrophe
  5231  	QKeyCodeGrave_Accent
  5232  	QKeyCodeBackslash
  5233  	QKeyCodeZ
  5234  	QKeyCodeX
  5235  	QKeyCodeC
  5236  	QKeyCodeV
  5237  	QKeyCodeB
  5238  	QKeyCodeN
  5239  	QKeyCodeM
  5240  	QKeyCodeComma
  5241  	QKeyCodeDot
  5242  	QKeyCodeSlash
  5243  	QKeyCodeAsterisk
  5244  	QKeyCodeSpc
  5245  	QKeyCodeCaps_Lock
  5246  	QKeyCodeF1
  5247  	QKeyCodeF2
  5248  	QKeyCodeF3
  5249  	QKeyCodeF4
  5250  	QKeyCodeF5
  5251  	QKeyCodeF6
  5252  	QKeyCodeF7
  5253  	QKeyCodeF8
  5254  	QKeyCodeF9
  5255  	QKeyCodeF10
  5256  	QKeyCodeNum_Lock
  5257  	QKeyCodeScroll_Lock
  5258  	QKeyCodeKp_Divide
  5259  	QKeyCodeKp_Multiply
  5260  	QKeyCodeKp_Subtract
  5261  	QKeyCodeKp_Add
  5262  	QKeyCodeKp_Enter
  5263  	QKeyCodeKp_Decimal
  5264  	QKeyCodeSysrq
  5265  	QKeyCodeKp_0
  5266  	QKeyCodeKp_1
  5267  	QKeyCodeKp_2
  5268  	QKeyCodeKp_3
  5269  	QKeyCodeKp_4
  5270  	QKeyCodeKp_5
  5271  	QKeyCodeKp_6
  5272  	QKeyCodeKp_7
  5273  	QKeyCodeKp_8
  5274  	QKeyCodeKp_9
  5275  	QKeyCodeLess
  5276  	QKeyCodeF11
  5277  	QKeyCodeF12
  5278  	QKeyCodePrint
  5279  	QKeyCodeHome
  5280  	QKeyCodePgup
  5281  	QKeyCodePgdn
  5282  	QKeyCodeEnd
  5283  	QKeyCodeLeft
  5284  	QKeyCodeUp
  5285  	QKeyCodeDown
  5286  	QKeyCodeRight
  5287  	QKeyCodeInsert
  5288  	QKeyCodeDelete
  5289  	QKeyCodeStop
  5290  	QKeyCodeAgain
  5291  	QKeyCodeProps
  5292  	QKeyCodeUndo
  5293  	QKeyCodeFront
  5294  	QKeyCodeCopy
  5295  	QKeyCodeOpen
  5296  	QKeyCodePaste
  5297  	QKeyCodeFind
  5298  	QKeyCodeCut
  5299  	QKeyCodeLf
  5300  	QKeyCodeHelp
  5301  	QKeyCodeMeta_L
  5302  	QKeyCodeMeta_R
  5303  	QKeyCodeCompose
  5304  	QKeyCodePause            // since 2.0
  5305  	QKeyCodeRo               // since 2.4
  5306  	QKeyCodeHiragana         // since 2.9
  5307  	QKeyCodeHenkan           // since 2.9
  5308  	QKeyCodeYen              // since 2.9
  5309  	QKeyCodeMuhenkan         // since 2.12
  5310  	QKeyCodeKatakanahiragana // since 2.12
  5311  	QKeyCodeKp_Comma         // since 2.4
  5312  	QKeyCodeKp_Equals        // since 2.6
  5313  	QKeyCodePower            // since 2.6
  5314  	QKeyCodeSleep            // since 2.10
  5315  	QKeyCodeWake             // since 2.10
  5316  	QKeyCodeAudionext        // since 2.10
  5317  	QKeyCodeAudioprev        // since 2.10
  5318  	QKeyCodeAudiostop        // since 2.10
  5319  	QKeyCodeAudioplay        // since 2.10
  5320  	QKeyCodeAudiomute        // since 2.10
  5321  	QKeyCodeVolumeup         // since 2.10
  5322  	QKeyCodeVolumedown       // since 2.10
  5323  	QKeyCodeMediaselect      // since 2.10
  5324  	QKeyCodeMail             // since 2.10
  5325  	QKeyCodeCalculator       // since 2.10
  5326  	QKeyCodeComputer         // since 2.10
  5327  	QKeyCodeAc_Home          // since 2.10
  5328  	QKeyCodeAc_Back          // since 2.10
  5329  	QKeyCodeAc_Forward       // since 2.10
  5330  	QKeyCodeAc_Refresh       // since 2.10
  5331  	QKeyCodeAc_Bookmarks     // since 2.10
  5332  	QKeyCodeLang1            // since 6.1
  5333  	QKeyCodeLang2            // since 6.1
  5334  )
  5335  
  5336  func (s QKeyCode) MarshalJSON() ([]byte, error) {
  5337  	switch s {
  5338  	case QKeyCodeUnmapped:
  5339  		return []byte(`"unmapped"`), nil
  5340  	case QKeyCodeShift:
  5341  		return []byte(`"shift"`), nil
  5342  	case QKeyCodeShift_R:
  5343  		return []byte(`"shift_r"`), nil
  5344  	case QKeyCodeAlt:
  5345  		return []byte(`"alt"`), nil
  5346  	case QKeyCodeAlt_R:
  5347  		return []byte(`"alt_r"`), nil
  5348  	case QKeyCodeCtrl:
  5349  		return []byte(`"ctrl"`), nil
  5350  	case QKeyCodeCtrl_R:
  5351  		return []byte(`"ctrl_r"`), nil
  5352  	case QKeyCodeMenu:
  5353  		return []byte(`"menu"`), nil
  5354  	case QKeyCodeEsc:
  5355  		return []byte(`"esc"`), nil
  5356  	case QKeyCode1:
  5357  		return []byte(`"1"`), nil
  5358  	case QKeyCode2:
  5359  		return []byte(`"2"`), nil
  5360  	case QKeyCode3:
  5361  		return []byte(`"3"`), nil
  5362  	case QKeyCode4:
  5363  		return []byte(`"4"`), nil
  5364  	case QKeyCode5:
  5365  		return []byte(`"5"`), nil
  5366  	case QKeyCode6:
  5367  		return []byte(`"6"`), nil
  5368  	case QKeyCode7:
  5369  		return []byte(`"7"`), nil
  5370  	case QKeyCode8:
  5371  		return []byte(`"8"`), nil
  5372  	case QKeyCode9:
  5373  		return []byte(`"9"`), nil
  5374  	case QKeyCode0:
  5375  		return []byte(`"0"`), nil
  5376  	case QKeyCodeMinus:
  5377  		return []byte(`"minus"`), nil
  5378  	case QKeyCodeEqual:
  5379  		return []byte(`"equal"`), nil
  5380  	case QKeyCodeBackspace:
  5381  		return []byte(`"backspace"`), nil
  5382  	case QKeyCodeTab:
  5383  		return []byte(`"tab"`), nil
  5384  	case QKeyCodeQ:
  5385  		return []byte(`"q"`), nil
  5386  	case QKeyCodeW:
  5387  		return []byte(`"w"`), nil
  5388  	case QKeyCodeE:
  5389  		return []byte(`"e"`), nil
  5390  	case QKeyCodeR:
  5391  		return []byte(`"r"`), nil
  5392  	case QKeyCodeT:
  5393  		return []byte(`"t"`), nil
  5394  	case QKeyCodeY:
  5395  		return []byte(`"y"`), nil
  5396  	case QKeyCodeU:
  5397  		return []byte(`"u"`), nil
  5398  	case QKeyCodeI:
  5399  		return []byte(`"i"`), nil
  5400  	case QKeyCodeO:
  5401  		return []byte(`"o"`), nil
  5402  	case QKeyCodeP:
  5403  		return []byte(`"p"`), nil
  5404  	case QKeyCodeBracket_Left:
  5405  		return []byte(`"bracket_left"`), nil
  5406  	case QKeyCodeBracket_Right:
  5407  		return []byte(`"bracket_right"`), nil
  5408  	case QKeyCodeRet:
  5409  		return []byte(`"ret"`), nil
  5410  	case QKeyCodeA:
  5411  		return []byte(`"a"`), nil
  5412  	case QKeyCodeS:
  5413  		return []byte(`"s"`), nil
  5414  	case QKeyCodeD:
  5415  		return []byte(`"d"`), nil
  5416  	case QKeyCodeF:
  5417  		return []byte(`"f"`), nil
  5418  	case QKeyCodeG:
  5419  		return []byte(`"g"`), nil
  5420  	case QKeyCodeH:
  5421  		return []byte(`"h"`), nil
  5422  	case QKeyCodeJ:
  5423  		return []byte(`"j"`), nil
  5424  	case QKeyCodeK:
  5425  		return []byte(`"k"`), nil
  5426  	case QKeyCodeL:
  5427  		return []byte(`"l"`), nil
  5428  	case QKeyCodeSemicolon:
  5429  		return []byte(`"semicolon"`), nil
  5430  	case QKeyCodeApostrophe:
  5431  		return []byte(`"apostrophe"`), nil
  5432  	case QKeyCodeGrave_Accent:
  5433  		return []byte(`"grave_accent"`), nil
  5434  	case QKeyCodeBackslash:
  5435  		return []byte(`"backslash"`), nil
  5436  	case QKeyCodeZ:
  5437  		return []byte(`"z"`), nil
  5438  	case QKeyCodeX:
  5439  		return []byte(`"x"`), nil
  5440  	case QKeyCodeC:
  5441  		return []byte(`"c"`), nil
  5442  	case QKeyCodeV:
  5443  		return []byte(`"v"`), nil
  5444  	case QKeyCodeB:
  5445  		return []byte(`"b"`), nil
  5446  	case QKeyCodeN:
  5447  		return []byte(`"n"`), nil
  5448  	case QKeyCodeM:
  5449  		return []byte(`"m"`), nil
  5450  	case QKeyCodeComma:
  5451  		return []byte(`"comma"`), nil
  5452  	case QKeyCodeDot:
  5453  		return []byte(`"dot"`), nil
  5454  	case QKeyCodeSlash:
  5455  		return []byte(`"slash"`), nil
  5456  	case QKeyCodeAsterisk:
  5457  		return []byte(`"asterisk"`), nil
  5458  	case QKeyCodeSpc:
  5459  		return []byte(`"spc"`), nil
  5460  	case QKeyCodeCaps_Lock:
  5461  		return []byte(`"caps_lock"`), nil
  5462  	case QKeyCodeF1:
  5463  		return []byte(`"f1"`), nil
  5464  	case QKeyCodeF2:
  5465  		return []byte(`"f2"`), nil
  5466  	case QKeyCodeF3:
  5467  		return []byte(`"f3"`), nil
  5468  	case QKeyCodeF4:
  5469  		return []byte(`"f4"`), nil
  5470  	case QKeyCodeF5:
  5471  		return []byte(`"f5"`), nil
  5472  	case QKeyCodeF6:
  5473  		return []byte(`"f6"`), nil
  5474  	case QKeyCodeF7:
  5475  		return []byte(`"f7"`), nil
  5476  	case QKeyCodeF8:
  5477  		return []byte(`"f8"`), nil
  5478  	case QKeyCodeF9:
  5479  		return []byte(`"f9"`), nil
  5480  	case QKeyCodeF10:
  5481  		return []byte(`"f10"`), nil
  5482  	case QKeyCodeNum_Lock:
  5483  		return []byte(`"num_lock"`), nil
  5484  	case QKeyCodeScroll_Lock:
  5485  		return []byte(`"scroll_lock"`), nil
  5486  	case QKeyCodeKp_Divide:
  5487  		return []byte(`"kp_divide"`), nil
  5488  	case QKeyCodeKp_Multiply:
  5489  		return []byte(`"kp_multiply"`), nil
  5490  	case QKeyCodeKp_Subtract:
  5491  		return []byte(`"kp_subtract"`), nil
  5492  	case QKeyCodeKp_Add:
  5493  		return []byte(`"kp_add"`), nil
  5494  	case QKeyCodeKp_Enter:
  5495  		return []byte(`"kp_enter"`), nil
  5496  	case QKeyCodeKp_Decimal:
  5497  		return []byte(`"kp_decimal"`), nil
  5498  	case QKeyCodeSysrq:
  5499  		return []byte(`"sysrq"`), nil
  5500  	case QKeyCodeKp_0:
  5501  		return []byte(`"kp_0"`), nil
  5502  	case QKeyCodeKp_1:
  5503  		return []byte(`"kp_1"`), nil
  5504  	case QKeyCodeKp_2:
  5505  		return []byte(`"kp_2"`), nil
  5506  	case QKeyCodeKp_3:
  5507  		return []byte(`"kp_3"`), nil
  5508  	case QKeyCodeKp_4:
  5509  		return []byte(`"kp_4"`), nil
  5510  	case QKeyCodeKp_5:
  5511  		return []byte(`"kp_5"`), nil
  5512  	case QKeyCodeKp_6:
  5513  		return []byte(`"kp_6"`), nil
  5514  	case QKeyCodeKp_7:
  5515  		return []byte(`"kp_7"`), nil
  5516  	case QKeyCodeKp_8:
  5517  		return []byte(`"kp_8"`), nil
  5518  	case QKeyCodeKp_9:
  5519  		return []byte(`"kp_9"`), nil
  5520  	case QKeyCodeLess:
  5521  		return []byte(`"less"`), nil
  5522  	case QKeyCodeF11:
  5523  		return []byte(`"f11"`), nil
  5524  	case QKeyCodeF12:
  5525  		return []byte(`"f12"`), nil
  5526  	case QKeyCodePrint:
  5527  		return []byte(`"print"`), nil
  5528  	case QKeyCodeHome:
  5529  		return []byte(`"home"`), nil
  5530  	case QKeyCodePgup:
  5531  		return []byte(`"pgup"`), nil
  5532  	case QKeyCodePgdn:
  5533  		return []byte(`"pgdn"`), nil
  5534  	case QKeyCodeEnd:
  5535  		return []byte(`"end"`), nil
  5536  	case QKeyCodeLeft:
  5537  		return []byte(`"left"`), nil
  5538  	case QKeyCodeUp:
  5539  		return []byte(`"up"`), nil
  5540  	case QKeyCodeDown:
  5541  		return []byte(`"down"`), nil
  5542  	case QKeyCodeRight:
  5543  		return []byte(`"right"`), nil
  5544  	case QKeyCodeInsert:
  5545  		return []byte(`"insert"`), nil
  5546  	case QKeyCodeDelete:
  5547  		return []byte(`"delete"`), nil
  5548  	case QKeyCodeStop:
  5549  		return []byte(`"stop"`), nil
  5550  	case QKeyCodeAgain:
  5551  		return []byte(`"again"`), nil
  5552  	case QKeyCodeProps:
  5553  		return []byte(`"props"`), nil
  5554  	case QKeyCodeUndo:
  5555  		return []byte(`"undo"`), nil
  5556  	case QKeyCodeFront:
  5557  		return []byte(`"front"`), nil
  5558  	case QKeyCodeCopy:
  5559  		return []byte(`"copy"`), nil
  5560  	case QKeyCodeOpen:
  5561  		return []byte(`"open"`), nil
  5562  	case QKeyCodePaste:
  5563  		return []byte(`"paste"`), nil
  5564  	case QKeyCodeFind:
  5565  		return []byte(`"find"`), nil
  5566  	case QKeyCodeCut:
  5567  		return []byte(`"cut"`), nil
  5568  	case QKeyCodeLf:
  5569  		return []byte(`"lf"`), nil
  5570  	case QKeyCodeHelp:
  5571  		return []byte(`"help"`), nil
  5572  	case QKeyCodeMeta_L:
  5573  		return []byte(`"meta_l"`), nil
  5574  	case QKeyCodeMeta_R:
  5575  		return []byte(`"meta_r"`), nil
  5576  	case QKeyCodeCompose:
  5577  		return []byte(`"compose"`), nil
  5578  	case QKeyCodePause:
  5579  		return []byte(`"pause"`), nil
  5580  	case QKeyCodeRo:
  5581  		return []byte(`"ro"`), nil
  5582  	case QKeyCodeHiragana:
  5583  		return []byte(`"hiragana"`), nil
  5584  	case QKeyCodeHenkan:
  5585  		return []byte(`"henkan"`), nil
  5586  	case QKeyCodeYen:
  5587  		return []byte(`"yen"`), nil
  5588  	case QKeyCodeMuhenkan:
  5589  		return []byte(`"muhenkan"`), nil
  5590  	case QKeyCodeKatakanahiragana:
  5591  		return []byte(`"katakanahiragana"`), nil
  5592  	case QKeyCodeKp_Comma:
  5593  		return []byte(`"kp_comma"`), nil
  5594  	case QKeyCodeKp_Equals:
  5595  		return []byte(`"kp_equals"`), nil
  5596  	case QKeyCodePower:
  5597  		return []byte(`"power"`), nil
  5598  	case QKeyCodeSleep:
  5599  		return []byte(`"sleep"`), nil
  5600  	case QKeyCodeWake:
  5601  		return []byte(`"wake"`), nil
  5602  	case QKeyCodeAudionext:
  5603  		return []byte(`"audionext"`), nil
  5604  	case QKeyCodeAudioprev:
  5605  		return []byte(`"audioprev"`), nil
  5606  	case QKeyCodeAudiostop:
  5607  		return []byte(`"audiostop"`), nil
  5608  	case QKeyCodeAudioplay:
  5609  		return []byte(`"audioplay"`), nil
  5610  	case QKeyCodeAudiomute:
  5611  		return []byte(`"audiomute"`), nil
  5612  	case QKeyCodeVolumeup:
  5613  		return []byte(`"volumeup"`), nil
  5614  	case QKeyCodeVolumedown:
  5615  		return []byte(`"volumedown"`), nil
  5616  	case QKeyCodeMediaselect:
  5617  		return []byte(`"mediaselect"`), nil
  5618  	case QKeyCodeMail:
  5619  		return []byte(`"mail"`), nil
  5620  	case QKeyCodeCalculator:
  5621  		return []byte(`"calculator"`), nil
  5622  	case QKeyCodeComputer:
  5623  		return []byte(`"computer"`), nil
  5624  	case QKeyCodeAc_Home:
  5625  		return []byte(`"ac_home"`), nil
  5626  	case QKeyCodeAc_Back:
  5627  		return []byte(`"ac_back"`), nil
  5628  	case QKeyCodeAc_Forward:
  5629  		return []byte(`"ac_forward"`), nil
  5630  	case QKeyCodeAc_Refresh:
  5631  		return []byte(`"ac_refresh"`), nil
  5632  	case QKeyCodeAc_Bookmarks:
  5633  		return []byte(`"ac_bookmarks"`), nil
  5634  	case QKeyCodeLang1:
  5635  		return []byte(`"lang1"`), nil
  5636  	case QKeyCodeLang2:
  5637  		return []byte(`"lang2"`), nil
  5638  	default:
  5639  		fmt.Println("Failed to decode QKeyCode", s)
  5640  	}
  5641  	return nil, errors.New("Failed")
  5642  }
  5643  
  5644  func (s *QKeyCode) UnmarshalJSON(data []byte) error {
  5645  	var name string
  5646  
  5647  	if err := json.Unmarshal(data, &name); err != nil {
  5648  		return err
  5649  	}
  5650  
  5651  	switch name {
  5652  	case "unmapped":
  5653  		(*s) = QKeyCodeUnmapped
  5654  	case "shift":
  5655  		(*s) = QKeyCodeShift
  5656  	case "shift_r":
  5657  		(*s) = QKeyCodeShift_R
  5658  	case "alt":
  5659  		(*s) = QKeyCodeAlt
  5660  	case "alt_r":
  5661  		(*s) = QKeyCodeAlt_R
  5662  	case "ctrl":
  5663  		(*s) = QKeyCodeCtrl
  5664  	case "ctrl_r":
  5665  		(*s) = QKeyCodeCtrl_R
  5666  	case "menu":
  5667  		(*s) = QKeyCodeMenu
  5668  	case "esc":
  5669  		(*s) = QKeyCodeEsc
  5670  	case "1":
  5671  		(*s) = QKeyCode1
  5672  	case "2":
  5673  		(*s) = QKeyCode2
  5674  	case "3":
  5675  		(*s) = QKeyCode3
  5676  	case "4":
  5677  		(*s) = QKeyCode4
  5678  	case "5":
  5679  		(*s) = QKeyCode5
  5680  	case "6":
  5681  		(*s) = QKeyCode6
  5682  	case "7":
  5683  		(*s) = QKeyCode7
  5684  	case "8":
  5685  		(*s) = QKeyCode8
  5686  	case "9":
  5687  		(*s) = QKeyCode9
  5688  	case "0":
  5689  		(*s) = QKeyCode0
  5690  	case "minus":
  5691  		(*s) = QKeyCodeMinus
  5692  	case "equal":
  5693  		(*s) = QKeyCodeEqual
  5694  	case "backspace":
  5695  		(*s) = QKeyCodeBackspace
  5696  	case "tab":
  5697  		(*s) = QKeyCodeTab
  5698  	case "q":
  5699  		(*s) = QKeyCodeQ
  5700  	case "w":
  5701  		(*s) = QKeyCodeW
  5702  	case "e":
  5703  		(*s) = QKeyCodeE
  5704  	case "r":
  5705  		(*s) = QKeyCodeR
  5706  	case "t":
  5707  		(*s) = QKeyCodeT
  5708  	case "y":
  5709  		(*s) = QKeyCodeY
  5710  	case "u":
  5711  		(*s) = QKeyCodeU
  5712  	case "i":
  5713  		(*s) = QKeyCodeI
  5714  	case "o":
  5715  		(*s) = QKeyCodeO
  5716  	case "p":
  5717  		(*s) = QKeyCodeP
  5718  	case "bracket_left":
  5719  		(*s) = QKeyCodeBracket_Left
  5720  	case "bracket_right":
  5721  		(*s) = QKeyCodeBracket_Right
  5722  	case "ret":
  5723  		(*s) = QKeyCodeRet
  5724  	case "a":
  5725  		(*s) = QKeyCodeA
  5726  	case "s":
  5727  		(*s) = QKeyCodeS
  5728  	case "d":
  5729  		(*s) = QKeyCodeD
  5730  	case "f":
  5731  		(*s) = QKeyCodeF
  5732  	case "g":
  5733  		(*s) = QKeyCodeG
  5734  	case "h":
  5735  		(*s) = QKeyCodeH
  5736  	case "j":
  5737  		(*s) = QKeyCodeJ
  5738  	case "k":
  5739  		(*s) = QKeyCodeK
  5740  	case "l":
  5741  		(*s) = QKeyCodeL
  5742  	case "semicolon":
  5743  		(*s) = QKeyCodeSemicolon
  5744  	case "apostrophe":
  5745  		(*s) = QKeyCodeApostrophe
  5746  	case "grave_accent":
  5747  		(*s) = QKeyCodeGrave_Accent
  5748  	case "backslash":
  5749  		(*s) = QKeyCodeBackslash
  5750  	case "z":
  5751  		(*s) = QKeyCodeZ
  5752  	case "x":
  5753  		(*s) = QKeyCodeX
  5754  	case "c":
  5755  		(*s) = QKeyCodeC
  5756  	case "v":
  5757  		(*s) = QKeyCodeV
  5758  	case "b":
  5759  		(*s) = QKeyCodeB
  5760  	case "n":
  5761  		(*s) = QKeyCodeN
  5762  	case "m":
  5763  		(*s) = QKeyCodeM
  5764  	case "comma":
  5765  		(*s) = QKeyCodeComma
  5766  	case "dot":
  5767  		(*s) = QKeyCodeDot
  5768  	case "slash":
  5769  		(*s) = QKeyCodeSlash
  5770  	case "asterisk":
  5771  		(*s) = QKeyCodeAsterisk
  5772  	case "spc":
  5773  		(*s) = QKeyCodeSpc
  5774  	case "caps_lock":
  5775  		(*s) = QKeyCodeCaps_Lock
  5776  	case "f1":
  5777  		(*s) = QKeyCodeF1
  5778  	case "f2":
  5779  		(*s) = QKeyCodeF2
  5780  	case "f3":
  5781  		(*s) = QKeyCodeF3
  5782  	case "f4":
  5783  		(*s) = QKeyCodeF4
  5784  	case "f5":
  5785  		(*s) = QKeyCodeF5
  5786  	case "f6":
  5787  		(*s) = QKeyCodeF6
  5788  	case "f7":
  5789  		(*s) = QKeyCodeF7
  5790  	case "f8":
  5791  		(*s) = QKeyCodeF8
  5792  	case "f9":
  5793  		(*s) = QKeyCodeF9
  5794  	case "f10":
  5795  		(*s) = QKeyCodeF10
  5796  	case "num_lock":
  5797  		(*s) = QKeyCodeNum_Lock
  5798  	case "scroll_lock":
  5799  		(*s) = QKeyCodeScroll_Lock
  5800  	case "kp_divide":
  5801  		(*s) = QKeyCodeKp_Divide
  5802  	case "kp_multiply":
  5803  		(*s) = QKeyCodeKp_Multiply
  5804  	case "kp_subtract":
  5805  		(*s) = QKeyCodeKp_Subtract
  5806  	case "kp_add":
  5807  		(*s) = QKeyCodeKp_Add
  5808  	case "kp_enter":
  5809  		(*s) = QKeyCodeKp_Enter
  5810  	case "kp_decimal":
  5811  		(*s) = QKeyCodeKp_Decimal
  5812  	case "sysrq":
  5813  		(*s) = QKeyCodeSysrq
  5814  	case "kp_0":
  5815  		(*s) = QKeyCodeKp_0
  5816  	case "kp_1":
  5817  		(*s) = QKeyCodeKp_1
  5818  	case "kp_2":
  5819  		(*s) = QKeyCodeKp_2
  5820  	case "kp_3":
  5821  		(*s) = QKeyCodeKp_3
  5822  	case "kp_4":
  5823  		(*s) = QKeyCodeKp_4
  5824  	case "kp_5":
  5825  		(*s) = QKeyCodeKp_5
  5826  	case "kp_6":
  5827  		(*s) = QKeyCodeKp_6
  5828  	case "kp_7":
  5829  		(*s) = QKeyCodeKp_7
  5830  	case "kp_8":
  5831  		(*s) = QKeyCodeKp_8
  5832  	case "kp_9":
  5833  		(*s) = QKeyCodeKp_9
  5834  	case "less":
  5835  		(*s) = QKeyCodeLess
  5836  	case "f11":
  5837  		(*s) = QKeyCodeF11
  5838  	case "f12":
  5839  		(*s) = QKeyCodeF12
  5840  	case "print":
  5841  		(*s) = QKeyCodePrint
  5842  	case "home":
  5843  		(*s) = QKeyCodeHome
  5844  	case "pgup":
  5845  		(*s) = QKeyCodePgup
  5846  	case "pgdn":
  5847  		(*s) = QKeyCodePgdn
  5848  	case "end":
  5849  		(*s) = QKeyCodeEnd
  5850  	case "left":
  5851  		(*s) = QKeyCodeLeft
  5852  	case "up":
  5853  		(*s) = QKeyCodeUp
  5854  	case "down":
  5855  		(*s) = QKeyCodeDown
  5856  	case "right":
  5857  		(*s) = QKeyCodeRight
  5858  	case "insert":
  5859  		(*s) = QKeyCodeInsert
  5860  	case "delete":
  5861  		(*s) = QKeyCodeDelete
  5862  	case "stop":
  5863  		(*s) = QKeyCodeStop
  5864  	case "again":
  5865  		(*s) = QKeyCodeAgain
  5866  	case "props":
  5867  		(*s) = QKeyCodeProps
  5868  	case "undo":
  5869  		(*s) = QKeyCodeUndo
  5870  	case "front":
  5871  		(*s) = QKeyCodeFront
  5872  	case "copy":
  5873  		(*s) = QKeyCodeCopy
  5874  	case "open":
  5875  		(*s) = QKeyCodeOpen
  5876  	case "paste":
  5877  		(*s) = QKeyCodePaste
  5878  	case "find":
  5879  		(*s) = QKeyCodeFind
  5880  	case "cut":
  5881  		(*s) = QKeyCodeCut
  5882  	case "lf":
  5883  		(*s) = QKeyCodeLf
  5884  	case "help":
  5885  		(*s) = QKeyCodeHelp
  5886  	case "meta_l":
  5887  		(*s) = QKeyCodeMeta_L
  5888  	case "meta_r":
  5889  		(*s) = QKeyCodeMeta_R
  5890  	case "compose":
  5891  		(*s) = QKeyCodeCompose
  5892  	case "pause":
  5893  		(*s) = QKeyCodePause
  5894  	case "ro":
  5895  		(*s) = QKeyCodeRo
  5896  	case "hiragana":
  5897  		(*s) = QKeyCodeHiragana
  5898  	case "henkan":
  5899  		(*s) = QKeyCodeHenkan
  5900  	case "yen":
  5901  		(*s) = QKeyCodeYen
  5902  	case "muhenkan":
  5903  		(*s) = QKeyCodeMuhenkan
  5904  	case "katakanahiragana":
  5905  		(*s) = QKeyCodeKatakanahiragana
  5906  	case "kp_comma":
  5907  		(*s) = QKeyCodeKp_Comma
  5908  	case "kp_equals":
  5909  		(*s) = QKeyCodeKp_Equals
  5910  	case "power":
  5911  		(*s) = QKeyCodePower
  5912  	case "sleep":
  5913  		(*s) = QKeyCodeSleep
  5914  	case "wake":
  5915  		(*s) = QKeyCodeWake
  5916  	case "audionext":
  5917  		(*s) = QKeyCodeAudionext
  5918  	case "audioprev":
  5919  		(*s) = QKeyCodeAudioprev
  5920  	case "audiostop":
  5921  		(*s) = QKeyCodeAudiostop
  5922  	case "audioplay":
  5923  		(*s) = QKeyCodeAudioplay
  5924  	case "audiomute":
  5925  		(*s) = QKeyCodeAudiomute
  5926  	case "volumeup":
  5927  		(*s) = QKeyCodeVolumeup
  5928  	case "volumedown":
  5929  		(*s) = QKeyCodeVolumedown
  5930  	case "mediaselect":
  5931  		(*s) = QKeyCodeMediaselect
  5932  	case "mail":
  5933  		(*s) = QKeyCodeMail
  5934  	case "calculator":
  5935  		(*s) = QKeyCodeCalculator
  5936  	case "computer":
  5937  		(*s) = QKeyCodeComputer
  5938  	case "ac_home":
  5939  		(*s) = QKeyCodeAc_Home
  5940  	case "ac_back":
  5941  		(*s) = QKeyCodeAc_Back
  5942  	case "ac_forward":
  5943  		(*s) = QKeyCodeAc_Forward
  5944  	case "ac_refresh":
  5945  		(*s) = QKeyCodeAc_Refresh
  5946  	case "ac_bookmarks":
  5947  		(*s) = QKeyCodeAc_Bookmarks
  5948  	case "lang1":
  5949  		(*s) = QKeyCodeLang1
  5950  	case "lang2":
  5951  		(*s) = QKeyCodeLang2
  5952  	default:
  5953  		fmt.Println("Failed to decode QKeyCode", *s)
  5954  	}
  5955  	return nil
  5956  }
  5957  
  5958  // Since: 1.3
  5959  type KeyValueKind int32
  5960  
  5961  const (
  5962  	KeyValueKindNumber KeyValueKind = iota
  5963  	KeyValueKindQcode
  5964  )
  5965  
  5966  func (s KeyValueKind) MarshalJSON() ([]byte, error) {
  5967  	switch s {
  5968  	case KeyValueKindNumber:
  5969  		return []byte(`"number"`), nil
  5970  	case KeyValueKindQcode:
  5971  		return []byte(`"qcode"`), nil
  5972  	default:
  5973  		fmt.Println("Failed to decode KeyValueKind", s)
  5974  	}
  5975  	return nil, errors.New("Failed")
  5976  }
  5977  
  5978  func (s *KeyValueKind) UnmarshalJSON(data []byte) error {
  5979  	var name string
  5980  
  5981  	if err := json.Unmarshal(data, &name); err != nil {
  5982  		return err
  5983  	}
  5984  
  5985  	switch name {
  5986  	case "number":
  5987  		(*s) = KeyValueKindNumber
  5988  	case "qcode":
  5989  		(*s) = KeyValueKindQcode
  5990  	default:
  5991  		fmt.Println("Failed to decode KeyValueKind", *s)
  5992  	}
  5993  	return nil
  5994  }
  5995  
  5996  // Button of a pointer input device (mouse, tablet).
  5997  //
  5998  // Since: 2.0
  5999  type InputButton int32
  6000  
  6001  const (
  6002  	InputButtonLeft InputButton = iota
  6003  	InputButtonMiddle
  6004  	InputButtonRight
  6005  	InputButtonWheelUp
  6006  	InputButtonWheelDown
  6007  	InputButtonSide  // front side button of a 5-button mouse (since 2.9)
  6008  	InputButtonExtra // rear side button of a 5-button mouse (since 2.9)
  6009  	InputButtonWheelLeft
  6010  	InputButtonWheelRight
  6011  )
  6012  
  6013  func (s InputButton) MarshalJSON() ([]byte, error) {
  6014  	switch s {
  6015  	case InputButtonLeft:
  6016  		return []byte(`"left"`), nil
  6017  	case InputButtonMiddle:
  6018  		return []byte(`"middle"`), nil
  6019  	case InputButtonRight:
  6020  		return []byte(`"right"`), nil
  6021  	case InputButtonWheelUp:
  6022  		return []byte(`"wheel-up"`), nil
  6023  	case InputButtonWheelDown:
  6024  		return []byte(`"wheel-down"`), nil
  6025  	case InputButtonSide:
  6026  		return []byte(`"side"`), nil
  6027  	case InputButtonExtra:
  6028  		return []byte(`"extra"`), nil
  6029  	case InputButtonWheelLeft:
  6030  		return []byte(`"wheel-left"`), nil
  6031  	case InputButtonWheelRight:
  6032  		return []byte(`"wheel-right"`), nil
  6033  	default:
  6034  		fmt.Println("Failed to decode InputButton", s)
  6035  	}
  6036  	return nil, errors.New("Failed")
  6037  }
  6038  
  6039  func (s *InputButton) UnmarshalJSON(data []byte) error {
  6040  	var name string
  6041  
  6042  	if err := json.Unmarshal(data, &name); err != nil {
  6043  		return err
  6044  	}
  6045  
  6046  	switch name {
  6047  	case "left":
  6048  		(*s) = InputButtonLeft
  6049  	case "middle":
  6050  		(*s) = InputButtonMiddle
  6051  	case "right":
  6052  		(*s) = InputButtonRight
  6053  	case "wheel-up":
  6054  		(*s) = InputButtonWheelUp
  6055  	case "wheel-down":
  6056  		(*s) = InputButtonWheelDown
  6057  	case "side":
  6058  		(*s) = InputButtonSide
  6059  	case "extra":
  6060  		(*s) = InputButtonExtra
  6061  	case "wheel-left":
  6062  		(*s) = InputButtonWheelLeft
  6063  	case "wheel-right":
  6064  		(*s) = InputButtonWheelRight
  6065  	default:
  6066  		fmt.Println("Failed to decode InputButton", *s)
  6067  	}
  6068  	return nil
  6069  }
  6070  
  6071  // Position axis of a pointer input device (mouse, tablet).
  6072  //
  6073  // Since: 2.0
  6074  type InputAxis int32
  6075  
  6076  const (
  6077  	InputAxisX InputAxis = iota
  6078  	InputAxisY
  6079  )
  6080  
  6081  func (s InputAxis) MarshalJSON() ([]byte, error) {
  6082  	switch s {
  6083  	case InputAxisX:
  6084  		return []byte(`"x"`), nil
  6085  	case InputAxisY:
  6086  		return []byte(`"y"`), nil
  6087  	default:
  6088  		fmt.Println("Failed to decode InputAxis", s)
  6089  	}
  6090  	return nil, errors.New("Failed")
  6091  }
  6092  
  6093  func (s *InputAxis) UnmarshalJSON(data []byte) error {
  6094  	var name string
  6095  
  6096  	if err := json.Unmarshal(data, &name); err != nil {
  6097  		return err
  6098  	}
  6099  
  6100  	switch name {
  6101  	case "x":
  6102  		(*s) = InputAxisX
  6103  	case "y":
  6104  		(*s) = InputAxisY
  6105  	default:
  6106  		fmt.Println("Failed to decode InputAxis", *s)
  6107  	}
  6108  	return nil
  6109  }
  6110  
  6111  // Since: 2.0
  6112  type InputEventKind int32
  6113  
  6114  const (
  6115  	InputEventKindKey InputEventKind = iota
  6116  	InputEventKindBtn
  6117  	InputEventKindRel
  6118  	InputEventKindAbs
  6119  )
  6120  
  6121  func (s InputEventKind) MarshalJSON() ([]byte, error) {
  6122  	switch s {
  6123  	case InputEventKindKey:
  6124  		return []byte(`"key"`), nil
  6125  	case InputEventKindBtn:
  6126  		return []byte(`"btn"`), nil
  6127  	case InputEventKindRel:
  6128  		return []byte(`"rel"`), nil
  6129  	case InputEventKindAbs:
  6130  		return []byte(`"abs"`), nil
  6131  	default:
  6132  		fmt.Println("Failed to decode InputEventKind", s)
  6133  	}
  6134  	return nil, errors.New("Failed")
  6135  }
  6136  
  6137  func (s *InputEventKind) UnmarshalJSON(data []byte) error {
  6138  	var name string
  6139  
  6140  	if err := json.Unmarshal(data, &name); err != nil {
  6141  		return err
  6142  	}
  6143  
  6144  	switch name {
  6145  	case "key":
  6146  		(*s) = InputEventKindKey
  6147  	case "btn":
  6148  		(*s) = InputEventKindBtn
  6149  	case "rel":
  6150  		(*s) = InputEventKindRel
  6151  	case "abs":
  6152  		(*s) = InputEventKindAbs
  6153  	default:
  6154  		fmt.Println("Failed to decode InputEventKind", *s)
  6155  	}
  6156  	return nil
  6157  }
  6158  
  6159  // Display OpenGL mode.
  6160  //
  6161  // Since: 3.0
  6162  type DisplayGLMode int32
  6163  
  6164  const (
  6165  	DisplayGLModeOff  DisplayGLMode = iota
  6166  	DisplayGLModeOn                 // Use OpenGL, pick context type automatically. Would better be named 'auto' but is called 'on' for backward compatibility with bool type.
  6167  	DisplayGLModeCore               // Use OpenGL with Core (desktop) Context.
  6168  	DisplayGLModeEs                 // Use OpenGL with ES (embedded systems) Context.
  6169  )
  6170  
  6171  func (s DisplayGLMode) MarshalJSON() ([]byte, error) {
  6172  	switch s {
  6173  	case DisplayGLModeOff:
  6174  		return []byte(`"off"`), nil
  6175  	case DisplayGLModeOn:
  6176  		return []byte(`"on"`), nil
  6177  	case DisplayGLModeCore:
  6178  		return []byte(`"core"`), nil
  6179  	case DisplayGLModeEs:
  6180  		return []byte(`"es"`), nil
  6181  	default:
  6182  		fmt.Println("Failed to decode DisplayGLMode", s)
  6183  	}
  6184  	return nil, errors.New("Failed")
  6185  }
  6186  
  6187  func (s *DisplayGLMode) UnmarshalJSON(data []byte) error {
  6188  	var name string
  6189  
  6190  	if err := json.Unmarshal(data, &name); err != nil {
  6191  		return err
  6192  	}
  6193  
  6194  	switch name {
  6195  	case "off":
  6196  		(*s) = DisplayGLModeOff
  6197  	case "on":
  6198  		(*s) = DisplayGLModeOn
  6199  	case "core":
  6200  		(*s) = DisplayGLModeCore
  6201  	case "es":
  6202  		(*s) = DisplayGLModeEs
  6203  	default:
  6204  		fmt.Println("Failed to decode DisplayGLMode", *s)
  6205  	}
  6206  	return nil
  6207  }
  6208  
  6209  // Display (user interface) type.
  6210  //
  6211  // Since: 2.12
  6212  type DisplayType int32
  6213  
  6214  const (
  6215  	DisplayTypeDefault     DisplayType = iota
  6216  	DisplayTypeNone                    // No user interface or video output display. The guest will still see an emulated graphics card, but its output will not be displayed to the QEMU user.
  6217  	DisplayTypeGtk                     // The GTK user interface.
  6218  	DisplayTypeSdl                     // The SDL user interface.
  6219  	DisplayTypeEglHeadless             // No user interface, offload GL operations to a local DRI device. Graphical display need to be paired with VNC or Spice. (Since 3.1)
  6220  	DisplayTypeCurses                  // Display video output via curses. For graphics device models which support a text mode, QEMU can display this output using a curses/ncurses interface. Nothing is displayed when the graphics device is in graphical mode or if the graphics device does not support a text mode. Generally only the VGA device models support text mode.
  6221  	DisplayTypeCocoa                   // The Cocoa user interface.
  6222  	DisplayTypeSpiceApp                // Set up a Spice server and run the default associated application to connect to it. The server will redirect the serial console and QEMU monitors. (Since 4.0)
  6223  	DisplayTypeDbus                    // Start a D-Bus service for the display. (Since 7.0)
  6224  )
  6225  
  6226  func (s DisplayType) MarshalJSON() ([]byte, error) {
  6227  	switch s {
  6228  	case DisplayTypeDefault:
  6229  		return []byte(`"default"`), nil
  6230  	case DisplayTypeNone:
  6231  		return []byte(`"none"`), nil
  6232  	case DisplayTypeGtk:
  6233  		return []byte(`"gtk"`), nil
  6234  	case DisplayTypeSdl:
  6235  		return []byte(`"sdl"`), nil
  6236  	case DisplayTypeEglHeadless:
  6237  		return []byte(`"egl-headless"`), nil
  6238  	case DisplayTypeCurses:
  6239  		return []byte(`"curses"`), nil
  6240  	case DisplayTypeCocoa:
  6241  		return []byte(`"cocoa"`), nil
  6242  	case DisplayTypeSpiceApp:
  6243  		return []byte(`"spice-app"`), nil
  6244  	case DisplayTypeDbus:
  6245  		return []byte(`"dbus"`), nil
  6246  	default:
  6247  		fmt.Println("Failed to decode DisplayType", s)
  6248  	}
  6249  	return nil, errors.New("Failed")
  6250  }
  6251  
  6252  func (s *DisplayType) UnmarshalJSON(data []byte) error {
  6253  	var name string
  6254  
  6255  	if err := json.Unmarshal(data, &name); err != nil {
  6256  		return err
  6257  	}
  6258  
  6259  	switch name {
  6260  	case "default":
  6261  		(*s) = DisplayTypeDefault
  6262  	case "none":
  6263  		(*s) = DisplayTypeNone
  6264  	case "gtk":
  6265  		(*s) = DisplayTypeGtk
  6266  	case "sdl":
  6267  		(*s) = DisplayTypeSdl
  6268  	case "egl-headless":
  6269  		(*s) = DisplayTypeEglHeadless
  6270  	case "curses":
  6271  		(*s) = DisplayTypeCurses
  6272  	case "cocoa":
  6273  		(*s) = DisplayTypeCocoa
  6274  	case "spice-app":
  6275  		(*s) = DisplayTypeSpiceApp
  6276  	case "dbus":
  6277  		(*s) = DisplayTypeDbus
  6278  	default:
  6279  		fmt.Println("Failed to decode DisplayType", *s)
  6280  	}
  6281  	return nil
  6282  }
  6283  
  6284  // Available DisplayReload types.
  6285  //
  6286  // Since: 6.0
  6287  type DisplayReloadType int32
  6288  
  6289  const (
  6290  	DisplayReloadTypeVnc DisplayReloadType = iota
  6291  )
  6292  
  6293  func (s DisplayReloadType) MarshalJSON() ([]byte, error) {
  6294  	switch s {
  6295  	case DisplayReloadTypeVnc:
  6296  		return []byte(`"vnc"`), nil
  6297  	default:
  6298  		fmt.Println("Failed to decode DisplayReloadType", s)
  6299  	}
  6300  	return nil, errors.New("Failed")
  6301  }
  6302  
  6303  func (s *DisplayReloadType) UnmarshalJSON(data []byte) error {
  6304  	var name string
  6305  
  6306  	if err := json.Unmarshal(data, &name); err != nil {
  6307  		return err
  6308  	}
  6309  
  6310  	switch name {
  6311  	case "vnc":
  6312  		(*s) = DisplayReloadTypeVnc
  6313  	default:
  6314  		fmt.Println("Failed to decode DisplayReloadType", *s)
  6315  	}
  6316  	return nil
  6317  }
  6318  
  6319  // The authorization policy result
  6320  //
  6321  // Since: 4.0
  6322  type QAuthZListPolicy int32
  6323  
  6324  const (
  6325  	QAuthZListPolicyDeny  QAuthZListPolicy = iota
  6326  	QAuthZListPolicyAllow                  // allow access
  6327  )
  6328  
  6329  func (s QAuthZListPolicy) MarshalJSON() ([]byte, error) {
  6330  	switch s {
  6331  	case QAuthZListPolicyDeny:
  6332  		return []byte(`"deny"`), nil
  6333  	case QAuthZListPolicyAllow:
  6334  		return []byte(`"allow"`), nil
  6335  	default:
  6336  		fmt.Println("Failed to decode QAuthZListPolicy", s)
  6337  	}
  6338  	return nil, errors.New("Failed")
  6339  }
  6340  
  6341  func (s *QAuthZListPolicy) UnmarshalJSON(data []byte) error {
  6342  	var name string
  6343  
  6344  	if err := json.Unmarshal(data, &name); err != nil {
  6345  		return err
  6346  	}
  6347  
  6348  	switch name {
  6349  	case "deny":
  6350  		(*s) = QAuthZListPolicyDeny
  6351  	case "allow":
  6352  		(*s) = QAuthZListPolicyAllow
  6353  	default:
  6354  		fmt.Println("Failed to decode QAuthZListPolicy", *s)
  6355  	}
  6356  	return nil
  6357  }
  6358  
  6359  // The authorization policy match format
  6360  //
  6361  // Since: 4.0
  6362  type QAuthZListFormat int32
  6363  
  6364  const (
  6365  	QAuthZListFormatExact QAuthZListFormat = iota
  6366  	QAuthZListFormatGlob                   // string with ? and * shell wildcard support
  6367  )
  6368  
  6369  func (s QAuthZListFormat) MarshalJSON() ([]byte, error) {
  6370  	switch s {
  6371  	case QAuthZListFormatExact:
  6372  		return []byte(`"exact"`), nil
  6373  	case QAuthZListFormatGlob:
  6374  		return []byte(`"glob"`), nil
  6375  	default:
  6376  		fmt.Println("Failed to decode QAuthZListFormat", s)
  6377  	}
  6378  	return nil, errors.New("Failed")
  6379  }
  6380  
  6381  func (s *QAuthZListFormat) UnmarshalJSON(data []byte) error {
  6382  	var name string
  6383  
  6384  	if err := json.Unmarshal(data, &name); err != nil {
  6385  		return err
  6386  	}
  6387  
  6388  	switch name {
  6389  	case "exact":
  6390  		(*s) = QAuthZListFormatExact
  6391  	case "glob":
  6392  		(*s) = QAuthZListFormatGlob
  6393  	default:
  6394  		fmt.Println("Failed to decode QAuthZListFormat", *s)
  6395  	}
  6396  	return nil
  6397  }
  6398  
  6399  // An enumeration of migration status.
  6400  //
  6401  // Since: 2.3
  6402  type MigrationStatus int32
  6403  
  6404  const (
  6405  	MigrationStatusNone            MigrationStatus = iota
  6406  	MigrationStatusSetup                           // migration process has been initiated.
  6407  	MigrationStatusCancelling                      // in the process of cancelling migration.
  6408  	MigrationStatusCancelled                       // cancelling migration is finished.
  6409  	MigrationStatusActive                          // in the process of doing migration.
  6410  	MigrationStatusPostcopyActive                  // like active, but now in postcopy mode. (since 2.5)
  6411  	MigrationStatusPostcopyPaused                  // during postcopy but paused. (since 3.0)
  6412  	MigrationStatusPostcopyRecover                 // trying to recover from a paused postcopy. (since 3.0)
  6413  	MigrationStatusCompleted                       // migration is finished.
  6414  	MigrationStatusFailed                          // some error occurred during migration process.
  6415  	MigrationStatusColo                            // VM is in the process of fault tolerance, VM can not get into this state unless colo capability is enabled for migration. (since 2.8)
  6416  	MigrationStatusPreSwitchover                   // Paused before device serialisation. (since 2.11)
  6417  	MigrationStatusDevice                          // During device serialisation when pause-before-switchover is enabled (since 2.11)
  6418  	MigrationStatusWaitUnplug                      // wait for device unplug request by guest OS to be completed. (since 4.2)
  6419  )
  6420  
  6421  func (s MigrationStatus) MarshalJSON() ([]byte, error) {
  6422  	switch s {
  6423  	case MigrationStatusNone:
  6424  		return []byte(`"none"`), nil
  6425  	case MigrationStatusSetup:
  6426  		return []byte(`"setup"`), nil
  6427  	case MigrationStatusCancelling:
  6428  		return []byte(`"cancelling"`), nil
  6429  	case MigrationStatusCancelled:
  6430  		return []byte(`"cancelled"`), nil
  6431  	case MigrationStatusActive:
  6432  		return []byte(`"active"`), nil
  6433  	case MigrationStatusPostcopyActive:
  6434  		return []byte(`"postcopy-active"`), nil
  6435  	case MigrationStatusPostcopyPaused:
  6436  		return []byte(`"postcopy-paused"`), nil
  6437  	case MigrationStatusPostcopyRecover:
  6438  		return []byte(`"postcopy-recover"`), nil
  6439  	case MigrationStatusCompleted:
  6440  		return []byte(`"completed"`), nil
  6441  	case MigrationStatusFailed:
  6442  		return []byte(`"failed"`), nil
  6443  	case MigrationStatusColo:
  6444  		return []byte(`"colo"`), nil
  6445  	case MigrationStatusPreSwitchover:
  6446  		return []byte(`"pre-switchover"`), nil
  6447  	case MigrationStatusDevice:
  6448  		return []byte(`"device"`), nil
  6449  	case MigrationStatusWaitUnplug:
  6450  		return []byte(`"wait-unplug"`), nil
  6451  	default:
  6452  		fmt.Println("Failed to decode MigrationStatus", s)
  6453  	}
  6454  	return nil, errors.New("Failed")
  6455  }
  6456  
  6457  func (s *MigrationStatus) UnmarshalJSON(data []byte) error {
  6458  	var name string
  6459  
  6460  	if err := json.Unmarshal(data, &name); err != nil {
  6461  		return err
  6462  	}
  6463  
  6464  	switch name {
  6465  	case "none":
  6466  		(*s) = MigrationStatusNone
  6467  	case "setup":
  6468  		(*s) = MigrationStatusSetup
  6469  	case "cancelling":
  6470  		(*s) = MigrationStatusCancelling
  6471  	case "cancelled":
  6472  		(*s) = MigrationStatusCancelled
  6473  	case "active":
  6474  		(*s) = MigrationStatusActive
  6475  	case "postcopy-active":
  6476  		(*s) = MigrationStatusPostcopyActive
  6477  	case "postcopy-paused":
  6478  		(*s) = MigrationStatusPostcopyPaused
  6479  	case "postcopy-recover":
  6480  		(*s) = MigrationStatusPostcopyRecover
  6481  	case "completed":
  6482  		(*s) = MigrationStatusCompleted
  6483  	case "failed":
  6484  		(*s) = MigrationStatusFailed
  6485  	case "colo":
  6486  		(*s) = MigrationStatusColo
  6487  	case "pre-switchover":
  6488  		(*s) = MigrationStatusPreSwitchover
  6489  	case "device":
  6490  		(*s) = MigrationStatusDevice
  6491  	case "wait-unplug":
  6492  		(*s) = MigrationStatusWaitUnplug
  6493  	default:
  6494  		fmt.Println("Failed to decode MigrationStatus", *s)
  6495  	}
  6496  	return nil
  6497  }
  6498  
  6499  // Migration capabilities enumeration
  6500  //
  6501  // Since: 1.2
  6502  type MigrationCapability int32
  6503  
  6504  const (
  6505  	MigrationCapabilityXbzrle                MigrationCapability = iota
  6506  	MigrationCapabilityRdmaPinAll                                // Controls whether or not the entire VM memory footprint is mlock()'d on demand or all at once. Refer to docs/rdma.txt for usage. Disabled by default. (since 2.0)
  6507  	MigrationCapabilityAutoConverge                              // If enabled, QEMU will automatically throttle down the guest to speed up convergence of RAM migration. (since 1.6)
  6508  	MigrationCapabilityZeroBlocks                                // During storage migration encode blocks of zeroes efficiently. This essentially saves 1MB of zeroes per block on the wire. Enabling requires source and target VM to support this feature. To enable it is sufficient to enable the capability on the source VM. The feature is disabled by default. (since 1.6)
  6509  	MigrationCapabilityCompress                                  // Use multiple compression threads to accelerate live migration. This feature can help to reduce the migration traffic, by sending compressed pages. Please note that if compress and xbzrle are both on, compress only takes effect in the ram bulk stage, after that, it will be disabled and only xbzrle takes effect, this can help to minimize migration traffic. The feature is disabled by default. (since 2.4 )
  6510  	MigrationCapabilityEvents                                    // generate events for each migration state change (since 2.4 )
  6511  	MigrationCapabilityPostcopyRam                               // Start executing on the migration target before all of RAM has been migrated, pulling the remaining pages along as needed. The capacity must have the same setting on both source and target or migration will not even start. NOTE: If the migration fails during postcopy the VM will fail. (since 2.6)
  6512  	MigrationCapabilityXColo                                     // If enabled, migration will never end, and the state of the VM on the primary side will be migrated continuously to the VM on secondary side, this process is called COarse-Grain LOck Stepping (COLO) for Non-stop Service. (since 2.8)
  6513  	MigrationCapabilityReleaseRam                                // if enabled, qemu will free the migrated ram pages on the source during postcopy-ram migration. (since 2.9)
  6514  	MigrationCapabilityBlock                                     // If enabled, QEMU will also migrate the contents of all block devices. Default is disabled. A possible alternative uses mirror jobs to a builtin NBD server on the destination, which offers more flexibility. (Since 2.10)
  6515  	MigrationCapabilityReturnPath                                // If enabled, migration will use the return path even for precopy. (since 2.10)
  6516  	MigrationCapabilityPauseBeforeSwitchover                     // Pause outgoing migration before serialising device state and before disabling block IO (since 2.11)
  6517  	MigrationCapabilityMultifd                                   // Use more than one fd for migration (since 4.0)
  6518  	MigrationCapabilityDirtyBitmaps                              // If enabled, QEMU will migrate named dirty bitmaps. (since 2.12)
  6519  	MigrationCapabilityPostcopyBlocktime                         // Calculate downtime for postcopy live migration (since 3.0)
  6520  	MigrationCapabilityLateBlockActivate                         // If enabled, the destination will not activate block devices (and thus take locks) immediately at the end of migration. (since 3.0)
  6521  	MigrationCapabilityXIgnoreShared                             // If enabled, QEMU will not migrate shared memory (since 4.0)
  6522  	MigrationCapabilityValidateUuid                              // Send the UUID of the source to allow the destination to ensure it is the same. (since 4.2)
  6523  	MigrationCapabilityBackgroundSnapshot                        // If enabled, the migration stream will be a snapshot of the VM exactly at the point when the migration procedure starts. The VM RAM is saved with running VM. (since 6.0)
  6524  )
  6525  
  6526  func (s MigrationCapability) MarshalJSON() ([]byte, error) {
  6527  	switch s {
  6528  	case MigrationCapabilityXbzrle:
  6529  		return []byte(`"xbzrle"`), nil
  6530  	case MigrationCapabilityRdmaPinAll:
  6531  		return []byte(`"rdma-pin-all"`), nil
  6532  	case MigrationCapabilityAutoConverge:
  6533  		return []byte(`"auto-converge"`), nil
  6534  	case MigrationCapabilityZeroBlocks:
  6535  		return []byte(`"zero-blocks"`), nil
  6536  	case MigrationCapabilityCompress:
  6537  		return []byte(`"compress"`), nil
  6538  	case MigrationCapabilityEvents:
  6539  		return []byte(`"events"`), nil
  6540  	case MigrationCapabilityPostcopyRam:
  6541  		return []byte(`"postcopy-ram"`), nil
  6542  	case MigrationCapabilityXColo:
  6543  		return []byte(`"x-colo"`), nil
  6544  	case MigrationCapabilityReleaseRam:
  6545  		return []byte(`"release-ram"`), nil
  6546  	case MigrationCapabilityBlock:
  6547  		return []byte(`"block"`), nil
  6548  	case MigrationCapabilityReturnPath:
  6549  		return []byte(`"return-path"`), nil
  6550  	case MigrationCapabilityPauseBeforeSwitchover:
  6551  		return []byte(`"pause-before-switchover"`), nil
  6552  	case MigrationCapabilityMultifd:
  6553  		return []byte(`"multifd"`), nil
  6554  	case MigrationCapabilityDirtyBitmaps:
  6555  		return []byte(`"dirty-bitmaps"`), nil
  6556  	case MigrationCapabilityPostcopyBlocktime:
  6557  		return []byte(`"postcopy-blocktime"`), nil
  6558  	case MigrationCapabilityLateBlockActivate:
  6559  		return []byte(`"late-block-activate"`), nil
  6560  	case MigrationCapabilityXIgnoreShared:
  6561  		return []byte(`"x-ignore-shared"`), nil
  6562  	case MigrationCapabilityValidateUuid:
  6563  		return []byte(`"validate-uuid"`), nil
  6564  	case MigrationCapabilityBackgroundSnapshot:
  6565  		return []byte(`"background-snapshot"`), nil
  6566  	default:
  6567  		fmt.Println("Failed to decode MigrationCapability", s)
  6568  	}
  6569  	return nil, errors.New("Failed")
  6570  }
  6571  
  6572  func (s *MigrationCapability) UnmarshalJSON(data []byte) error {
  6573  	var name string
  6574  
  6575  	if err := json.Unmarshal(data, &name); err != nil {
  6576  		return err
  6577  	}
  6578  
  6579  	switch name {
  6580  	case "xbzrle":
  6581  		(*s) = MigrationCapabilityXbzrle
  6582  	case "rdma-pin-all":
  6583  		(*s) = MigrationCapabilityRdmaPinAll
  6584  	case "auto-converge":
  6585  		(*s) = MigrationCapabilityAutoConverge
  6586  	case "zero-blocks":
  6587  		(*s) = MigrationCapabilityZeroBlocks
  6588  	case "compress":
  6589  		(*s) = MigrationCapabilityCompress
  6590  	case "events":
  6591  		(*s) = MigrationCapabilityEvents
  6592  	case "postcopy-ram":
  6593  		(*s) = MigrationCapabilityPostcopyRam
  6594  	case "x-colo":
  6595  		(*s) = MigrationCapabilityXColo
  6596  	case "release-ram":
  6597  		(*s) = MigrationCapabilityReleaseRam
  6598  	case "block":
  6599  		(*s) = MigrationCapabilityBlock
  6600  	case "return-path":
  6601  		(*s) = MigrationCapabilityReturnPath
  6602  	case "pause-before-switchover":
  6603  		(*s) = MigrationCapabilityPauseBeforeSwitchover
  6604  	case "multifd":
  6605  		(*s) = MigrationCapabilityMultifd
  6606  	case "dirty-bitmaps":
  6607  		(*s) = MigrationCapabilityDirtyBitmaps
  6608  	case "postcopy-blocktime":
  6609  		(*s) = MigrationCapabilityPostcopyBlocktime
  6610  	case "late-block-activate":
  6611  		(*s) = MigrationCapabilityLateBlockActivate
  6612  	case "x-ignore-shared":
  6613  		(*s) = MigrationCapabilityXIgnoreShared
  6614  	case "validate-uuid":
  6615  		(*s) = MigrationCapabilityValidateUuid
  6616  	case "background-snapshot":
  6617  		(*s) = MigrationCapabilityBackgroundSnapshot
  6618  	default:
  6619  		fmt.Println("Failed to decode MigrationCapability", *s)
  6620  	}
  6621  	return nil
  6622  }
  6623  
  6624  // An enumeration of multifd compression methods.
  6625  //
  6626  // Since: 5.0
  6627  type MultiFDCompression int32
  6628  
  6629  const (
  6630  	MultiFDCompressionNone MultiFDCompression = iota
  6631  	MultiFDCompressionZlib                    // use zlib compression method.
  6632  	MultiFDCompressionZstd                    // use zstd compression method.
  6633  )
  6634  
  6635  func (s MultiFDCompression) MarshalJSON() ([]byte, error) {
  6636  	switch s {
  6637  	case MultiFDCompressionNone:
  6638  		return []byte(`"none"`), nil
  6639  	case MultiFDCompressionZlib:
  6640  		return []byte(`"zlib"`), nil
  6641  	case MultiFDCompressionZstd:
  6642  		return []byte(`"zstd"`), nil
  6643  	default:
  6644  		fmt.Println("Failed to decode MultiFDCompression", s)
  6645  	}
  6646  	return nil, errors.New("Failed")
  6647  }
  6648  
  6649  func (s *MultiFDCompression) UnmarshalJSON(data []byte) error {
  6650  	var name string
  6651  
  6652  	if err := json.Unmarshal(data, &name); err != nil {
  6653  		return err
  6654  	}
  6655  
  6656  	switch name {
  6657  	case "none":
  6658  		(*s) = MultiFDCompressionNone
  6659  	case "zlib":
  6660  		(*s) = MultiFDCompressionZlib
  6661  	case "zstd":
  6662  		(*s) = MultiFDCompressionZstd
  6663  	default:
  6664  		fmt.Println("Failed to decode MultiFDCompression", *s)
  6665  	}
  6666  	return nil
  6667  }
  6668  
  6669  // Migration parameters enumeration
  6670  //
  6671  // Since: 2.4
  6672  type MigrationParameter int32
  6673  
  6674  const (
  6675  	MigrationParameterAnnounceInitial          MigrationParameter = iota
  6676  	MigrationParameterAnnounceMax                                 // Maximum delay (in milliseconds) between packets in the announcement (Since 4.0)
  6677  	MigrationParameterAnnounceRounds                              // Number of self-announce packets sent after migration (Since 4.0)
  6678  	MigrationParameterAnnounceStep                                // Increase in delay (in milliseconds) between subsequent packets in the announcement (Since 4.0)
  6679  	MigrationParameterCompressLevel                               // Set the compression level to be used in live migration, the compression level is an integer between 0 and 9, where 0 means no compression, 1 means the best compression speed, and 9 means best compression ratio which will consume more CPU.
  6680  	MigrationParameterCompressThreads                             // Set compression thread count to be used in live migration, the compression thread count is an integer between 1 and 255.
  6681  	MigrationParameterDecompressThreads                           // Set decompression thread count to be used in live migration, the decompression thread count is an integer between 1 and 255. Usually, decompression is at least 4 times as fast as compression, so set the decompress-threads to the number about 1/4 of compress-threads is adequate.
  6682  	MigrationParameterCompressWaitThread                          // Controls behavior when all compression threads are currently busy. If true (default), wait for a free compression thread to become available; otherwise, send the page uncompressed. (Since 3.1)
  6683  	MigrationParameterThrottleTriggerThreshold                    // The ratio of bytes_dirty_period and bytes_xfer_period to trigger throttling. It is expressed as percentage. The default value is 50. (Since 5.0)
  6684  	MigrationParameterCpuThrottleInitial                          // Initial percentage of time guest cpus are throttled when migration auto-converge is activated. The default value is 20. (Since 2.7)
  6685  	MigrationParameterCpuThrottleIncrement                        // throttle percentage increase each time auto-converge detects that migration is not making progress. The default value is 10. (Since 2.7)
  6686  	MigrationParameterCpuThrottleTailslow                         // Make CPU throttling slower at tail stage At the tail stage of throttling, the Guest is very sensitive to CPU percentage while the @cpu-throttle -increment is excessive usually at tail stage. If this parameter is true, we will compute the ideal CPU percentage used by the Guest, which may exactly make the dirty rate match the dirty rate threshold. Then we will choose a smaller throttle increment between the one specified by @cpu-throttle-increment and the one generated by ideal CPU percentage. Therefore, it is compatible to traditional throttling, meanwhile the throttle increment won't be excessive at tail stage. The default value is false. (Since 5.1)
  6687  	MigrationParameterTlsCreds                                    // ID of the 'tls-creds' object that provides credentials for establishing a TLS connection over the migration data channel. On the outgoing side of the migration, the credentials must be for a 'client' endpoint, while for the incoming side the credentials must be for a 'server' endpoint. Setting this will enable TLS for all migrations. The default is unset, resulting in unsecured migration at the QEMU level. (Since 2.7)
  6688  	MigrationParameterTlsHostname                                 // hostname of the target host for the migration. This is required when using x509 based TLS credentials and the migration URI does not already include a hostname. For example if using fd: or exec: based migration, the hostname must be provided so that the server's x509 certificate identity can be validated. (Since 2.7)
  6689  	MigrationParameterTlsAuthz                                    // ID of the 'authz' object subclass that provides access control checking of the TLS x509 certificate distinguished name. This object is only resolved at time of use, so can be deleted and recreated on the fly while the migration server is active. If missing, it will default to denying access (Since 4.0)
  6690  	MigrationParameterMaxBandwidth                                // to set maximum speed for migration. maximum speed in bytes per second. (Since 2.8)
  6691  	MigrationParameterDowntimeLimit                               // set maximum tolerated downtime for migration. maximum downtime in milliseconds (Since 2.8)
  6692  	MigrationParameterXCheckpointDelay                            // The delay time (in ms) between two COLO checkpoints in periodic mode. (Since 2.8)
  6693  	MigrationParameterBlockIncremental                            // Affects how much storage is migrated when the block migration capability is enabled. When false, the entire storage backing chain is migrated into a flattened image at the destination; when true, only the active qcow2 layer is migrated and the destination must already have access to the same backing chain as was used on the source. (since 2.10)
  6694  	MigrationParameterMultifdChannels                             // Number of channels used to migrate data in parallel. This is the same number that the number of sockets used for migration. The default value is 2 (since 4.0)
  6695  	MigrationParameterXbzrleCacheSize                             // cache size to be used by XBZRLE migration. It needs to be a multiple of the target page size and a power of 2 (Since 2.11)
  6696  	MigrationParameterMaxPostcopyBandwidth                        // Background transfer bandwidth during postcopy. Defaults to 0 (unlimited). In bytes per second. (Since 3.0)
  6697  	MigrationParameterMaxCpuThrottle                              // maximum cpu throttle percentage. Defaults to 99. (Since 3.1)
  6698  	MigrationParameterMultifdCompression                          // Which compression method to use. Defaults to none. (Since 5.0)
  6699  	MigrationParameterMultifdZlibLevel                            // Set the compression level to be used in live migration, the compression level is an integer between 0 and 9, where 0 means no compression, 1 means the best compression speed, and 9 means best compression ratio which will consume more CPU. Defaults to 1. (Since 5.0)
  6700  	MigrationParameterMultifdZstdLevel                            // Set the compression level to be used in live migration, the compression level is an integer between 0 and 20, where 0 means no compression, 1 means the best compression speed, and 20 means best compression ratio which will consume more CPU. Defaults to 1. (Since 5.0)
  6701  	MigrationParameterBlockBitmapMapping                          // Maps block nodes and bitmaps on them to aliases for the purpose of dirty bitmap migration. Such aliases may for example be the corresponding names on the opposite site. The mapping must be one-to-one, but not necessarily complete: On the source, unmapped bitmaps and all bitmaps on unmapped nodes will be ignored. On the destination, encountering an unmapped alias in the incoming migration stream will result in a report, and all further bitmap migration data will then be discarded. Note that the destination does not know about bitmaps it does not receive, so there is no limitation or requirement regarding the number of bitmaps received, or how they are named, or on which nodes they are placed. By default (when this parameter has never been set), bitmap names are mapped to themselves. Nodes are mapped to their block device name if there is one, and to their node name otherwise. (Since 5.2)
  6702  )
  6703  
  6704  func (s MigrationParameter) MarshalJSON() ([]byte, error) {
  6705  	switch s {
  6706  	case MigrationParameterAnnounceInitial:
  6707  		return []byte(`"announce-initial"`), nil
  6708  	case MigrationParameterAnnounceMax:
  6709  		return []byte(`"announce-max"`), nil
  6710  	case MigrationParameterAnnounceRounds:
  6711  		return []byte(`"announce-rounds"`), nil
  6712  	case MigrationParameterAnnounceStep:
  6713  		return []byte(`"announce-step"`), nil
  6714  	case MigrationParameterCompressLevel:
  6715  		return []byte(`"compress-level"`), nil
  6716  	case MigrationParameterCompressThreads:
  6717  		return []byte(`"compress-threads"`), nil
  6718  	case MigrationParameterDecompressThreads:
  6719  		return []byte(`"decompress-threads"`), nil
  6720  	case MigrationParameterCompressWaitThread:
  6721  		return []byte(`"compress-wait-thread"`), nil
  6722  	case MigrationParameterThrottleTriggerThreshold:
  6723  		return []byte(`"throttle-trigger-threshold"`), nil
  6724  	case MigrationParameterCpuThrottleInitial:
  6725  		return []byte(`"cpu-throttle-initial"`), nil
  6726  	case MigrationParameterCpuThrottleIncrement:
  6727  		return []byte(`"cpu-throttle-increment"`), nil
  6728  	case MigrationParameterCpuThrottleTailslow:
  6729  		return []byte(`"cpu-throttle-tailslow"`), nil
  6730  	case MigrationParameterTlsCreds:
  6731  		return []byte(`"tls-creds"`), nil
  6732  	case MigrationParameterTlsHostname:
  6733  		return []byte(`"tls-hostname"`), nil
  6734  	case MigrationParameterTlsAuthz:
  6735  		return []byte(`"tls-authz"`), nil
  6736  	case MigrationParameterMaxBandwidth:
  6737  		return []byte(`"max-bandwidth"`), nil
  6738  	case MigrationParameterDowntimeLimit:
  6739  		return []byte(`"downtime-limit"`), nil
  6740  	case MigrationParameterXCheckpointDelay:
  6741  		return []byte(`"x-checkpoint-delay"`), nil
  6742  	case MigrationParameterBlockIncremental:
  6743  		return []byte(`"block-incremental"`), nil
  6744  	case MigrationParameterMultifdChannels:
  6745  		return []byte(`"multifd-channels"`), nil
  6746  	case MigrationParameterXbzrleCacheSize:
  6747  		return []byte(`"xbzrle-cache-size"`), nil
  6748  	case MigrationParameterMaxPostcopyBandwidth:
  6749  		return []byte(`"max-postcopy-bandwidth"`), nil
  6750  	case MigrationParameterMaxCpuThrottle:
  6751  		return []byte(`"max-cpu-throttle"`), nil
  6752  	case MigrationParameterMultifdCompression:
  6753  		return []byte(`"multifd-compression"`), nil
  6754  	case MigrationParameterMultifdZlibLevel:
  6755  		return []byte(`"multifd-zlib-level"`), nil
  6756  	case MigrationParameterMultifdZstdLevel:
  6757  		return []byte(`"multifd-zstd-level"`), nil
  6758  	case MigrationParameterBlockBitmapMapping:
  6759  		return []byte(`"block-bitmap-mapping"`), nil
  6760  	default:
  6761  		fmt.Println("Failed to decode MigrationParameter", s)
  6762  	}
  6763  	return nil, errors.New("Failed")
  6764  }
  6765  
  6766  func (s *MigrationParameter) UnmarshalJSON(data []byte) error {
  6767  	var name string
  6768  
  6769  	if err := json.Unmarshal(data, &name); err != nil {
  6770  		return err
  6771  	}
  6772  
  6773  	switch name {
  6774  	case "announce-initial":
  6775  		(*s) = MigrationParameterAnnounceInitial
  6776  	case "announce-max":
  6777  		(*s) = MigrationParameterAnnounceMax
  6778  	case "announce-rounds":
  6779  		(*s) = MigrationParameterAnnounceRounds
  6780  	case "announce-step":
  6781  		(*s) = MigrationParameterAnnounceStep
  6782  	case "compress-level":
  6783  		(*s) = MigrationParameterCompressLevel
  6784  	case "compress-threads":
  6785  		(*s) = MigrationParameterCompressThreads
  6786  	case "decompress-threads":
  6787  		(*s) = MigrationParameterDecompressThreads
  6788  	case "compress-wait-thread":
  6789  		(*s) = MigrationParameterCompressWaitThread
  6790  	case "throttle-trigger-threshold":
  6791  		(*s) = MigrationParameterThrottleTriggerThreshold
  6792  	case "cpu-throttle-initial":
  6793  		(*s) = MigrationParameterCpuThrottleInitial
  6794  	case "cpu-throttle-increment":
  6795  		(*s) = MigrationParameterCpuThrottleIncrement
  6796  	case "cpu-throttle-tailslow":
  6797  		(*s) = MigrationParameterCpuThrottleTailslow
  6798  	case "tls-creds":
  6799  		(*s) = MigrationParameterTlsCreds
  6800  	case "tls-hostname":
  6801  		(*s) = MigrationParameterTlsHostname
  6802  	case "tls-authz":
  6803  		(*s) = MigrationParameterTlsAuthz
  6804  	case "max-bandwidth":
  6805  		(*s) = MigrationParameterMaxBandwidth
  6806  	case "downtime-limit":
  6807  		(*s) = MigrationParameterDowntimeLimit
  6808  	case "x-checkpoint-delay":
  6809  		(*s) = MigrationParameterXCheckpointDelay
  6810  	case "block-incremental":
  6811  		(*s) = MigrationParameterBlockIncremental
  6812  	case "multifd-channels":
  6813  		(*s) = MigrationParameterMultifdChannels
  6814  	case "xbzrle-cache-size":
  6815  		(*s) = MigrationParameterXbzrleCacheSize
  6816  	case "max-postcopy-bandwidth":
  6817  		(*s) = MigrationParameterMaxPostcopyBandwidth
  6818  	case "max-cpu-throttle":
  6819  		(*s) = MigrationParameterMaxCpuThrottle
  6820  	case "multifd-compression":
  6821  		(*s) = MigrationParameterMultifdCompression
  6822  	case "multifd-zlib-level":
  6823  		(*s) = MigrationParameterMultifdZlibLevel
  6824  	case "multifd-zstd-level":
  6825  		(*s) = MigrationParameterMultifdZstdLevel
  6826  	case "block-bitmap-mapping":
  6827  		(*s) = MigrationParameterBlockBitmapMapping
  6828  	default:
  6829  		fmt.Println("Failed to decode MigrationParameter", *s)
  6830  	}
  6831  	return nil
  6832  }
  6833  
  6834  // The message transmission between Primary side and Secondary side.
  6835  //
  6836  // Since: 2.8
  6837  type COLOMessage int32
  6838  
  6839  const (
  6840  	COLOMessageCheckpointReady   COLOMessage = iota
  6841  	COLOMessageCheckpointRequest             // Primary VM (PVM) tells SVM to prepare for checkpointing
  6842  	COLOMessageCheckpointReply               // SVM gets PVM's checkpoint request
  6843  	COLOMessageVmstateSend                   // VM's state will be sent by PVM.
  6844  	COLOMessageVmstateSize                   // The total size of VMstate.
  6845  	COLOMessageVmstateReceived               // VM's state has been received by SVM.
  6846  	COLOMessageVmstateLoaded                 // VM's state has been loaded by SVM.
  6847  )
  6848  
  6849  func (s COLOMessage) MarshalJSON() ([]byte, error) {
  6850  	switch s {
  6851  	case COLOMessageCheckpointReady:
  6852  		return []byte(`"checkpoint-ready"`), nil
  6853  	case COLOMessageCheckpointRequest:
  6854  		return []byte(`"checkpoint-request"`), nil
  6855  	case COLOMessageCheckpointReply:
  6856  		return []byte(`"checkpoint-reply"`), nil
  6857  	case COLOMessageVmstateSend:
  6858  		return []byte(`"vmstate-send"`), nil
  6859  	case COLOMessageVmstateSize:
  6860  		return []byte(`"vmstate-size"`), nil
  6861  	case COLOMessageVmstateReceived:
  6862  		return []byte(`"vmstate-received"`), nil
  6863  	case COLOMessageVmstateLoaded:
  6864  		return []byte(`"vmstate-loaded"`), nil
  6865  	default:
  6866  		fmt.Println("Failed to decode COLOMessage", s)
  6867  	}
  6868  	return nil, errors.New("Failed")
  6869  }
  6870  
  6871  func (s *COLOMessage) UnmarshalJSON(data []byte) error {
  6872  	var name string
  6873  
  6874  	if err := json.Unmarshal(data, &name); err != nil {
  6875  		return err
  6876  	}
  6877  
  6878  	switch name {
  6879  	case "checkpoint-ready":
  6880  		(*s) = COLOMessageCheckpointReady
  6881  	case "checkpoint-request":
  6882  		(*s) = COLOMessageCheckpointRequest
  6883  	case "checkpoint-reply":
  6884  		(*s) = COLOMessageCheckpointReply
  6885  	case "vmstate-send":
  6886  		(*s) = COLOMessageVmstateSend
  6887  	case "vmstate-size":
  6888  		(*s) = COLOMessageVmstateSize
  6889  	case "vmstate-received":
  6890  		(*s) = COLOMessageVmstateReceived
  6891  	case "vmstate-loaded":
  6892  		(*s) = COLOMessageVmstateLoaded
  6893  	default:
  6894  		fmt.Println("Failed to decode COLOMessage", *s)
  6895  	}
  6896  	return nil
  6897  }
  6898  
  6899  // The COLO current mode.
  6900  //
  6901  // Since: 2.8
  6902  type COLOMode int32
  6903  
  6904  const (
  6905  	COLOModeNone      COLOMode = iota
  6906  	COLOModePrimary            // COLO node in primary side.
  6907  	COLOModeSecondary          // COLO node in slave side.
  6908  )
  6909  
  6910  func (s COLOMode) MarshalJSON() ([]byte, error) {
  6911  	switch s {
  6912  	case COLOModeNone:
  6913  		return []byte(`"none"`), nil
  6914  	case COLOModePrimary:
  6915  		return []byte(`"primary"`), nil
  6916  	case COLOModeSecondary:
  6917  		return []byte(`"secondary"`), nil
  6918  	default:
  6919  		fmt.Println("Failed to decode COLOMode", s)
  6920  	}
  6921  	return nil, errors.New("Failed")
  6922  }
  6923  
  6924  func (s *COLOMode) UnmarshalJSON(data []byte) error {
  6925  	var name string
  6926  
  6927  	if err := json.Unmarshal(data, &name); err != nil {
  6928  		return err
  6929  	}
  6930  
  6931  	switch name {
  6932  	case "none":
  6933  		(*s) = COLOModeNone
  6934  	case "primary":
  6935  		(*s) = COLOModePrimary
  6936  	case "secondary":
  6937  		(*s) = COLOModeSecondary
  6938  	default:
  6939  		fmt.Println("Failed to decode COLOMode", *s)
  6940  	}
  6941  	return nil
  6942  }
  6943  
  6944  // An enumeration of COLO failover status
  6945  //
  6946  // Since: 2.8
  6947  type FailoverStatus int32
  6948  
  6949  const (
  6950  	FailoverStatusNone      FailoverStatus = iota
  6951  	FailoverStatusRequire                  // got failover requirement but not handled
  6952  	FailoverStatusActive                   // in the process of doing failover
  6953  	FailoverStatusCompleted                // finish the process of failover
  6954  	FailoverStatusRelaunch                 // restart the failover process, from 'none' -> 'completed' (Since 2.9)
  6955  )
  6956  
  6957  func (s FailoverStatus) MarshalJSON() ([]byte, error) {
  6958  	switch s {
  6959  	case FailoverStatusNone:
  6960  		return []byte(`"none"`), nil
  6961  	case FailoverStatusRequire:
  6962  		return []byte(`"require"`), nil
  6963  	case FailoverStatusActive:
  6964  		return []byte(`"active"`), nil
  6965  	case FailoverStatusCompleted:
  6966  		return []byte(`"completed"`), nil
  6967  	case FailoverStatusRelaunch:
  6968  		return []byte(`"relaunch"`), nil
  6969  	default:
  6970  		fmt.Println("Failed to decode FailoverStatus", s)
  6971  	}
  6972  	return nil, errors.New("Failed")
  6973  }
  6974  
  6975  func (s *FailoverStatus) UnmarshalJSON(data []byte) error {
  6976  	var name string
  6977  
  6978  	if err := json.Unmarshal(data, &name); err != nil {
  6979  		return err
  6980  	}
  6981  
  6982  	switch name {
  6983  	case "none":
  6984  		(*s) = FailoverStatusNone
  6985  	case "require":
  6986  		(*s) = FailoverStatusRequire
  6987  	case "active":
  6988  		(*s) = FailoverStatusActive
  6989  	case "completed":
  6990  		(*s) = FailoverStatusCompleted
  6991  	case "relaunch":
  6992  		(*s) = FailoverStatusRelaunch
  6993  	default:
  6994  		fmt.Println("Failed to decode FailoverStatus", *s)
  6995  	}
  6996  	return nil
  6997  }
  6998  
  6999  // The reason for a COLO exit.
  7000  //
  7001  // Since: 3.1
  7002  type COLOExitReason int32
  7003  
  7004  const (
  7005  	COLOExitReasonNone       COLOExitReason = iota
  7006  	COLOExitReasonRequest                   // COLO exit is due to an external request.
  7007  	COLOExitReasonError                     // COLO exit is due to an internal error.
  7008  	COLOExitReasonProcessing                // COLO is currently handling a failover (since 4.0).
  7009  )
  7010  
  7011  func (s COLOExitReason) MarshalJSON() ([]byte, error) {
  7012  	switch s {
  7013  	case COLOExitReasonNone:
  7014  		return []byte(`"none"`), nil
  7015  	case COLOExitReasonRequest:
  7016  		return []byte(`"request"`), nil
  7017  	case COLOExitReasonError:
  7018  		return []byte(`"error"`), nil
  7019  	case COLOExitReasonProcessing:
  7020  		return []byte(`"processing"`), nil
  7021  	default:
  7022  		fmt.Println("Failed to decode COLOExitReason", s)
  7023  	}
  7024  	return nil, errors.New("Failed")
  7025  }
  7026  
  7027  func (s *COLOExitReason) UnmarshalJSON(data []byte) error {
  7028  	var name string
  7029  
  7030  	if err := json.Unmarshal(data, &name); err != nil {
  7031  		return err
  7032  	}
  7033  
  7034  	switch name {
  7035  	case "none":
  7036  		(*s) = COLOExitReasonNone
  7037  	case "request":
  7038  		(*s) = COLOExitReasonRequest
  7039  	case "error":
  7040  		(*s) = COLOExitReasonError
  7041  	case "processing":
  7042  		(*s) = COLOExitReasonProcessing
  7043  	default:
  7044  		fmt.Println("Failed to decode COLOExitReason", *s)
  7045  	}
  7046  	return nil
  7047  }
  7048  
  7049  // An enumeration of dirtyrate status.
  7050  //
  7051  // Since: 5.2
  7052  type DirtyRateStatus int32
  7053  
  7054  const (
  7055  	DirtyRateStatusUnstarted DirtyRateStatus = iota
  7056  	DirtyRateStatusMeasuring                 // the dirtyrate thread is measuring.
  7057  	DirtyRateStatusMeasured                  // the dirtyrate thread has measured and results are available.
  7058  )
  7059  
  7060  func (s DirtyRateStatus) MarshalJSON() ([]byte, error) {
  7061  	switch s {
  7062  	case DirtyRateStatusUnstarted:
  7063  		return []byte(`"unstarted"`), nil
  7064  	case DirtyRateStatusMeasuring:
  7065  		return []byte(`"measuring"`), nil
  7066  	case DirtyRateStatusMeasured:
  7067  		return []byte(`"measured"`), nil
  7068  	default:
  7069  		fmt.Println("Failed to decode DirtyRateStatus", s)
  7070  	}
  7071  	return nil, errors.New("Failed")
  7072  }
  7073  
  7074  func (s *DirtyRateStatus) UnmarshalJSON(data []byte) error {
  7075  	var name string
  7076  
  7077  	if err := json.Unmarshal(data, &name); err != nil {
  7078  		return err
  7079  	}
  7080  
  7081  	switch name {
  7082  	case "unstarted":
  7083  		(*s) = DirtyRateStatusUnstarted
  7084  	case "measuring":
  7085  		(*s) = DirtyRateStatusMeasuring
  7086  	case "measured":
  7087  		(*s) = DirtyRateStatusMeasured
  7088  	default:
  7089  		fmt.Println("Failed to decode DirtyRateStatus", *s)
  7090  	}
  7091  	return nil
  7092  }
  7093  
  7094  // An enumeration of mode of measuring dirtyrate.
  7095  //
  7096  // Since: 6.2
  7097  type DirtyRateMeasureMode int32
  7098  
  7099  const (
  7100  	DirtyRateMeasureModePageSampling DirtyRateMeasureMode = iota
  7101  	DirtyRateMeasureModeDirtyRing                         // calculate dirtyrate by dirty ring.
  7102  	DirtyRateMeasureModeDirtyBitmap                       // calculate dirtyrate by dirty bitmap.
  7103  )
  7104  
  7105  func (s DirtyRateMeasureMode) MarshalJSON() ([]byte, error) {
  7106  	switch s {
  7107  	case DirtyRateMeasureModePageSampling:
  7108  		return []byte(`"page-sampling"`), nil
  7109  	case DirtyRateMeasureModeDirtyRing:
  7110  		return []byte(`"dirty-ring"`), nil
  7111  	case DirtyRateMeasureModeDirtyBitmap:
  7112  		return []byte(`"dirty-bitmap"`), nil
  7113  	default:
  7114  		fmt.Println("Failed to decode DirtyRateMeasureMode", s)
  7115  	}
  7116  	return nil, errors.New("Failed")
  7117  }
  7118  
  7119  func (s *DirtyRateMeasureMode) UnmarshalJSON(data []byte) error {
  7120  	var name string
  7121  
  7122  	if err := json.Unmarshal(data, &name); err != nil {
  7123  		return err
  7124  	}
  7125  
  7126  	switch name {
  7127  	case "page-sampling":
  7128  		(*s) = DirtyRateMeasureModePageSampling
  7129  	case "dirty-ring":
  7130  		(*s) = DirtyRateMeasureModeDirtyRing
  7131  	case "dirty-bitmap":
  7132  		(*s) = DirtyRateMeasureModeDirtyBitmap
  7133  	default:
  7134  		fmt.Println("Failed to decode DirtyRateMeasureMode", *s)
  7135  	}
  7136  	return nil
  7137  }
  7138  
  7139  // An enumeration of Transactional completion modes.
  7140  //
  7141  // Since: 2.5
  7142  type ActionCompletionMode int32
  7143  
  7144  const (
  7145  	ActionCompletionModeIndividual ActionCompletionMode = iota
  7146  	ActionCompletionModeGrouped                         // If any Action fails after the Transaction succeeds, cancel all Actions. Actions do not complete until all Actions are ready to complete. May be rejected by Actions that do not support this completion mode.
  7147  )
  7148  
  7149  func (s ActionCompletionMode) MarshalJSON() ([]byte, error) {
  7150  	switch s {
  7151  	case ActionCompletionModeIndividual:
  7152  		return []byte(`"individual"`), nil
  7153  	case ActionCompletionModeGrouped:
  7154  		return []byte(`"grouped"`), nil
  7155  	default:
  7156  		fmt.Println("Failed to decode ActionCompletionMode", s)
  7157  	}
  7158  	return nil, errors.New("Failed")
  7159  }
  7160  
  7161  func (s *ActionCompletionMode) UnmarshalJSON(data []byte) error {
  7162  	var name string
  7163  
  7164  	if err := json.Unmarshal(data, &name); err != nil {
  7165  		return err
  7166  	}
  7167  
  7168  	switch name {
  7169  	case "individual":
  7170  		(*s) = ActionCompletionModeIndividual
  7171  	case "grouped":
  7172  		(*s) = ActionCompletionModeGrouped
  7173  	default:
  7174  		fmt.Println("Failed to decode ActionCompletionMode", *s)
  7175  	}
  7176  	return nil
  7177  }
  7178  
  7179  // Since: 1.1
  7180  type TransactionActionKind int32
  7181  
  7182  const (
  7183  	TransactionActionKindAbort                        TransactionActionKind = iota
  7184  	TransactionActionKindBlockDirtyBitmapAdd                                // Since 2.5
  7185  	TransactionActionKindBlockDirtyBitmapRemove                             // Since 4.2
  7186  	TransactionActionKindBlockDirtyBitmapClear                              // Since 2.5
  7187  	TransactionActionKindBlockDirtyBitmapEnable                             // Since 4.0
  7188  	TransactionActionKindBlockDirtyBitmapDisable                            // Since 4.0
  7189  	TransactionActionKindBlockDirtyBitmapMerge                              // Since 4.0
  7190  	TransactionActionKindBlockdevBackup                                     // Since 2.3
  7191  	TransactionActionKindBlockdevSnapshot                                   // Since 2.5
  7192  	TransactionActionKindBlockdevSnapshotInternalSync                       // Since 1.7
  7193  	TransactionActionKindBlockdevSnapshotSync                               // since 1.1
  7194  	TransactionActionKindDriveBackup                                        // Since 1.6
  7195  )
  7196  
  7197  func (s TransactionActionKind) MarshalJSON() ([]byte, error) {
  7198  	switch s {
  7199  	case TransactionActionKindAbort:
  7200  		return []byte(`"abort"`), nil
  7201  	case TransactionActionKindBlockDirtyBitmapAdd:
  7202  		return []byte(`"block-dirty-bitmap-add"`), nil
  7203  	case TransactionActionKindBlockDirtyBitmapRemove:
  7204  		return []byte(`"block-dirty-bitmap-remove"`), nil
  7205  	case TransactionActionKindBlockDirtyBitmapClear:
  7206  		return []byte(`"block-dirty-bitmap-clear"`), nil
  7207  	case TransactionActionKindBlockDirtyBitmapEnable:
  7208  		return []byte(`"block-dirty-bitmap-enable"`), nil
  7209  	case TransactionActionKindBlockDirtyBitmapDisable:
  7210  		return []byte(`"block-dirty-bitmap-disable"`), nil
  7211  	case TransactionActionKindBlockDirtyBitmapMerge:
  7212  		return []byte(`"block-dirty-bitmap-merge"`), nil
  7213  	case TransactionActionKindBlockdevBackup:
  7214  		return []byte(`"blockdev-backup"`), nil
  7215  	case TransactionActionKindBlockdevSnapshot:
  7216  		return []byte(`"blockdev-snapshot"`), nil
  7217  	case TransactionActionKindBlockdevSnapshotInternalSync:
  7218  		return []byte(`"blockdev-snapshot-internal-sync"`), nil
  7219  	case TransactionActionKindBlockdevSnapshotSync:
  7220  		return []byte(`"blockdev-snapshot-sync"`), nil
  7221  	case TransactionActionKindDriveBackup:
  7222  		return []byte(`"drive-backup"`), nil
  7223  	default:
  7224  		fmt.Println("Failed to decode TransactionActionKind", s)
  7225  	}
  7226  	return nil, errors.New("Failed")
  7227  }
  7228  
  7229  func (s *TransactionActionKind) UnmarshalJSON(data []byte) error {
  7230  	var name string
  7231  
  7232  	if err := json.Unmarshal(data, &name); err != nil {
  7233  		return err
  7234  	}
  7235  
  7236  	switch name {
  7237  	case "abort":
  7238  		(*s) = TransactionActionKindAbort
  7239  	case "block-dirty-bitmap-add":
  7240  		(*s) = TransactionActionKindBlockDirtyBitmapAdd
  7241  	case "block-dirty-bitmap-remove":
  7242  		(*s) = TransactionActionKindBlockDirtyBitmapRemove
  7243  	case "block-dirty-bitmap-clear":
  7244  		(*s) = TransactionActionKindBlockDirtyBitmapClear
  7245  	case "block-dirty-bitmap-enable":
  7246  		(*s) = TransactionActionKindBlockDirtyBitmapEnable
  7247  	case "block-dirty-bitmap-disable":
  7248  		(*s) = TransactionActionKindBlockDirtyBitmapDisable
  7249  	case "block-dirty-bitmap-merge":
  7250  		(*s) = TransactionActionKindBlockDirtyBitmapMerge
  7251  	case "blockdev-backup":
  7252  		(*s) = TransactionActionKindBlockdevBackup
  7253  	case "blockdev-snapshot":
  7254  		(*s) = TransactionActionKindBlockdevSnapshot
  7255  	case "blockdev-snapshot-internal-sync":
  7256  		(*s) = TransactionActionKindBlockdevSnapshotInternalSync
  7257  	case "blockdev-snapshot-sync":
  7258  		(*s) = TransactionActionKindBlockdevSnapshotSync
  7259  	case "drive-backup":
  7260  		(*s) = TransactionActionKindDriveBackup
  7261  	default:
  7262  		fmt.Println("Failed to decode TransactionActionKind", *s)
  7263  	}
  7264  	return nil
  7265  }
  7266  
  7267  // State of a tracing event.
  7268  //
  7269  // Since: 2.2
  7270  type TraceEventState int32
  7271  
  7272  const (
  7273  	TraceEventStateUnavailable TraceEventState = iota
  7274  	TraceEventStateDisabled                    // The event is dynamically disabled.
  7275  	TraceEventStateEnabled                     // The event is dynamically enabled.
  7276  )
  7277  
  7278  func (s TraceEventState) MarshalJSON() ([]byte, error) {
  7279  	switch s {
  7280  	case TraceEventStateUnavailable:
  7281  		return []byte(`"unavailable"`), nil
  7282  	case TraceEventStateDisabled:
  7283  		return []byte(`"disabled"`), nil
  7284  	case TraceEventStateEnabled:
  7285  		return []byte(`"enabled"`), nil
  7286  	default:
  7287  		fmt.Println("Failed to decode TraceEventState", s)
  7288  	}
  7289  	return nil, errors.New("Failed")
  7290  }
  7291  
  7292  func (s *TraceEventState) UnmarshalJSON(data []byte) error {
  7293  	var name string
  7294  
  7295  	if err := json.Unmarshal(data, &name); err != nil {
  7296  		return err
  7297  	}
  7298  
  7299  	switch name {
  7300  	case "unavailable":
  7301  		(*s) = TraceEventStateUnavailable
  7302  	case "disabled":
  7303  		(*s) = TraceEventStateDisabled
  7304  	case "enabled":
  7305  		(*s) = TraceEventStateEnabled
  7306  	default:
  7307  		fmt.Println("Failed to decode TraceEventState", *s)
  7308  	}
  7309  	return nil
  7310  }
  7311  
  7312  // Policy for handling "funny" input.
  7313  //
  7314  // Since: 6.0
  7315  type CompatPolicyInput int32
  7316  
  7317  const (
  7318  	CompatPolicyInputAccept CompatPolicyInput = iota
  7319  	CompatPolicyInputReject                   // Reject with an error
  7320  	CompatPolicyInputCrash                    // abort() the process
  7321  )
  7322  
  7323  func (s CompatPolicyInput) MarshalJSON() ([]byte, error) {
  7324  	switch s {
  7325  	case CompatPolicyInputAccept:
  7326  		return []byte(`"accept"`), nil
  7327  	case CompatPolicyInputReject:
  7328  		return []byte(`"reject"`), nil
  7329  	case CompatPolicyInputCrash:
  7330  		return []byte(`"crash"`), nil
  7331  	default:
  7332  		fmt.Println("Failed to decode CompatPolicyInput", s)
  7333  	}
  7334  	return nil, errors.New("Failed")
  7335  }
  7336  
  7337  func (s *CompatPolicyInput) UnmarshalJSON(data []byte) error {
  7338  	var name string
  7339  
  7340  	if err := json.Unmarshal(data, &name); err != nil {
  7341  		return err
  7342  	}
  7343  
  7344  	switch name {
  7345  	case "accept":
  7346  		(*s) = CompatPolicyInputAccept
  7347  	case "reject":
  7348  		(*s) = CompatPolicyInputReject
  7349  	case "crash":
  7350  		(*s) = CompatPolicyInputCrash
  7351  	default:
  7352  		fmt.Println("Failed to decode CompatPolicyInput", *s)
  7353  	}
  7354  	return nil
  7355  }
  7356  
  7357  // Policy for handling "funny" output.
  7358  //
  7359  // Since: 6.0
  7360  type CompatPolicyOutput int32
  7361  
  7362  const (
  7363  	CompatPolicyOutputAccept CompatPolicyOutput = iota
  7364  	CompatPolicyOutputHide                      // Filter out
  7365  )
  7366  
  7367  func (s CompatPolicyOutput) MarshalJSON() ([]byte, error) {
  7368  	switch s {
  7369  	case CompatPolicyOutputAccept:
  7370  		return []byte(`"accept"`), nil
  7371  	case CompatPolicyOutputHide:
  7372  		return []byte(`"hide"`), nil
  7373  	default:
  7374  		fmt.Println("Failed to decode CompatPolicyOutput", s)
  7375  	}
  7376  	return nil, errors.New("Failed")
  7377  }
  7378  
  7379  func (s *CompatPolicyOutput) UnmarshalJSON(data []byte) error {
  7380  	var name string
  7381  
  7382  	if err := json.Unmarshal(data, &name); err != nil {
  7383  		return err
  7384  	}
  7385  
  7386  	switch name {
  7387  	case "accept":
  7388  		(*s) = CompatPolicyOutputAccept
  7389  	case "hide":
  7390  		(*s) = CompatPolicyOutputHide
  7391  	default:
  7392  		fmt.Println("Failed to decode CompatPolicyOutput", *s)
  7393  	}
  7394  	return nil
  7395  }
  7396  
  7397  // Enumeration of capabilities to be advertised during initial client
  7398  // connection, used for agreeing on particular QMP extension behaviors.
  7399  //
  7400  // Since: 2.12
  7401  type QMPCapability int32
  7402  
  7403  const (
  7404  	QMPCapabilityOob QMPCapability = iota
  7405  )
  7406  
  7407  func (s QMPCapability) MarshalJSON() ([]byte, error) {
  7408  	switch s {
  7409  	case QMPCapabilityOob:
  7410  		return []byte(`"oob"`), nil
  7411  	default:
  7412  		fmt.Println("Failed to decode QMPCapability", s)
  7413  	}
  7414  	return nil, errors.New("Failed")
  7415  }
  7416  
  7417  func (s *QMPCapability) UnmarshalJSON(data []byte) error {
  7418  	var name string
  7419  
  7420  	if err := json.Unmarshal(data, &name); err != nil {
  7421  		return err
  7422  	}
  7423  
  7424  	switch name {
  7425  	case "oob":
  7426  		(*s) = QMPCapabilityOob
  7427  	default:
  7428  		fmt.Println("Failed to decode QMPCapability", *s)
  7429  	}
  7430  	return nil
  7431  }
  7432  
  7433  // An enumeration of monitor modes.
  7434  //
  7435  // Since: 5.0
  7436  type MonitorMode int32
  7437  
  7438  const (
  7439  	MonitorModeReadline MonitorMode = iota
  7440  	MonitorModeControl              // QMP monitor (JSON-based machine interface)
  7441  )
  7442  
  7443  func (s MonitorMode) MarshalJSON() ([]byte, error) {
  7444  	switch s {
  7445  	case MonitorModeReadline:
  7446  		return []byte(`"readline"`), nil
  7447  	case MonitorModeControl:
  7448  		return []byte(`"control"`), nil
  7449  	default:
  7450  		fmt.Println("Failed to decode MonitorMode", s)
  7451  	}
  7452  	return nil, errors.New("Failed")
  7453  }
  7454  
  7455  func (s *MonitorMode) UnmarshalJSON(data []byte) error {
  7456  	var name string
  7457  
  7458  	if err := json.Unmarshal(data, &name); err != nil {
  7459  		return err
  7460  	}
  7461  
  7462  	switch name {
  7463  	case "readline":
  7464  		(*s) = MonitorModeReadline
  7465  	case "control":
  7466  		(*s) = MonitorModeControl
  7467  	default:
  7468  		fmt.Println("Failed to decode MonitorMode", *s)
  7469  	}
  7470  	return nil
  7471  }
  7472  
  7473  // This is a @SchemaInfo's meta type, i.e. the kind of entity it
  7474  // describes.
  7475  //
  7476  // Since: 2.5
  7477  type SchemaMetaType int32
  7478  
  7479  const (
  7480  	SchemaMetaTypeBuiltin   SchemaMetaType = iota
  7481  	SchemaMetaTypeEnum                     // an enumeration type
  7482  	SchemaMetaTypeArray                    // an array type
  7483  	SchemaMetaTypeObject                   // an object type (struct or union)
  7484  	SchemaMetaTypeAlternate                // an alternate type
  7485  	SchemaMetaTypeCommand                  // a QMP command
  7486  	SchemaMetaTypeEvent                    // a QMP event
  7487  )
  7488  
  7489  func (s SchemaMetaType) MarshalJSON() ([]byte, error) {
  7490  	switch s {
  7491  	case SchemaMetaTypeBuiltin:
  7492  		return []byte(`"builtin"`), nil
  7493  	case SchemaMetaTypeEnum:
  7494  		return []byte(`"enum"`), nil
  7495  	case SchemaMetaTypeArray:
  7496  		return []byte(`"array"`), nil
  7497  	case SchemaMetaTypeObject:
  7498  		return []byte(`"object"`), nil
  7499  	case SchemaMetaTypeAlternate:
  7500  		return []byte(`"alternate"`), nil
  7501  	case SchemaMetaTypeCommand:
  7502  		return []byte(`"command"`), nil
  7503  	case SchemaMetaTypeEvent:
  7504  		return []byte(`"event"`), nil
  7505  	default:
  7506  		fmt.Println("Failed to decode SchemaMetaType", s)
  7507  	}
  7508  	return nil, errors.New("Failed")
  7509  }
  7510  
  7511  func (s *SchemaMetaType) UnmarshalJSON(data []byte) error {
  7512  	var name string
  7513  
  7514  	if err := json.Unmarshal(data, &name); err != nil {
  7515  		return err
  7516  	}
  7517  
  7518  	switch name {
  7519  	case "builtin":
  7520  		(*s) = SchemaMetaTypeBuiltin
  7521  	case "enum":
  7522  		(*s) = SchemaMetaTypeEnum
  7523  	case "array":
  7524  		(*s) = SchemaMetaTypeArray
  7525  	case "object":
  7526  		(*s) = SchemaMetaTypeObject
  7527  	case "alternate":
  7528  		(*s) = SchemaMetaTypeAlternate
  7529  	case "command":
  7530  		(*s) = SchemaMetaTypeCommand
  7531  	case "event":
  7532  		(*s) = SchemaMetaTypeEvent
  7533  	default:
  7534  		fmt.Println("Failed to decode SchemaMetaType", *s)
  7535  	}
  7536  	return nil
  7537  }
  7538  
  7539  // The four primitive and two structured types according to RFC 8259
  7540  // section 1, plus 'int' (split off 'number'), plus the obvious top
  7541  // type 'value'.
  7542  //
  7543  // Since: 2.5
  7544  type JSONType int32
  7545  
  7546  const (
  7547  	JSONTypeString JSONType = iota
  7548  	JSONTypeNumber
  7549  	JSONTypeInt
  7550  	JSONTypeBoolean
  7551  	JSONTypeNull
  7552  	JSONTypeObject
  7553  	JSONTypeArray
  7554  	JSONTypeValue
  7555  )
  7556  
  7557  func (s JSONType) MarshalJSON() ([]byte, error) {
  7558  	switch s {
  7559  	case JSONTypeString:
  7560  		return []byte(`"string"`), nil
  7561  	case JSONTypeNumber:
  7562  		return []byte(`"number"`), nil
  7563  	case JSONTypeInt:
  7564  		return []byte(`"int"`), nil
  7565  	case JSONTypeBoolean:
  7566  		return []byte(`"boolean"`), nil
  7567  	case JSONTypeNull:
  7568  		return []byte(`"null"`), nil
  7569  	case JSONTypeObject:
  7570  		return []byte(`"object"`), nil
  7571  	case JSONTypeArray:
  7572  		return []byte(`"array"`), nil
  7573  	case JSONTypeValue:
  7574  		return []byte(`"value"`), nil
  7575  	default:
  7576  		fmt.Println("Failed to decode JSONType", s)
  7577  	}
  7578  	return nil, errors.New("Failed")
  7579  }
  7580  
  7581  func (s *JSONType) UnmarshalJSON(data []byte) error {
  7582  	var name string
  7583  
  7584  	if err := json.Unmarshal(data, &name); err != nil {
  7585  		return err
  7586  	}
  7587  
  7588  	switch name {
  7589  	case "string":
  7590  		(*s) = JSONTypeString
  7591  	case "number":
  7592  		(*s) = JSONTypeNumber
  7593  	case "int":
  7594  		(*s) = JSONTypeInt
  7595  	case "boolean":
  7596  		(*s) = JSONTypeBoolean
  7597  	case "null":
  7598  		(*s) = JSONTypeNull
  7599  	case "object":
  7600  		(*s) = JSONTypeObject
  7601  	case "array":
  7602  		(*s) = JSONTypeArray
  7603  	case "value":
  7604  		(*s) = JSONTypeValue
  7605  	default:
  7606  		fmt.Println("Failed to decode JSONType", *s)
  7607  	}
  7608  	return nil
  7609  }
  7610  
  7611  // Indicates where to insert a netfilter relative to a given other filter.
  7612  //
  7613  // Since: 5.0
  7614  type NetfilterInsert int32
  7615  
  7616  const (
  7617  	NetfilterInsertBefore NetfilterInsert = iota
  7618  	NetfilterInsertBehind                 // insert behind the specified filter
  7619  )
  7620  
  7621  func (s NetfilterInsert) MarshalJSON() ([]byte, error) {
  7622  	switch s {
  7623  	case NetfilterInsertBefore:
  7624  		return []byte(`"before"`), nil
  7625  	case NetfilterInsertBehind:
  7626  		return []byte(`"behind"`), nil
  7627  	default:
  7628  		fmt.Println("Failed to decode NetfilterInsert", s)
  7629  	}
  7630  	return nil, errors.New("Failed")
  7631  }
  7632  
  7633  func (s *NetfilterInsert) UnmarshalJSON(data []byte) error {
  7634  	var name string
  7635  
  7636  	if err := json.Unmarshal(data, &name); err != nil {
  7637  		return err
  7638  	}
  7639  
  7640  	switch name {
  7641  	case "before":
  7642  		(*s) = NetfilterInsertBefore
  7643  	case "behind":
  7644  		(*s) = NetfilterInsertBehind
  7645  	default:
  7646  		fmt.Println("Failed to decode NetfilterInsert", *s)
  7647  	}
  7648  	return nil
  7649  }
  7650  
  7651  // Since: 6.0
  7652  type ObjectType int32
  7653  
  7654  const (
  7655  	ObjectTypeAuthzList ObjectType = iota
  7656  	ObjectTypeAuthzListfile
  7657  	ObjectTypeAuthzPam
  7658  	ObjectTypeAuthzSimple
  7659  	ObjectTypeCanBus
  7660  	ObjectTypeCanHostSocketcan
  7661  	ObjectTypeColoCompare
  7662  	ObjectTypeCryptodevBackend
  7663  	ObjectTypeCryptodevBackendBuiltin
  7664  	ObjectTypeCryptodevVhostUser
  7665  	ObjectTypeDbusVmstate
  7666  	ObjectTypeFilterBuffer
  7667  	ObjectTypeFilterDump
  7668  	ObjectTypeFilterMirror
  7669  	ObjectTypeFilterRedirector
  7670  	ObjectTypeFilterReplay
  7671  	ObjectTypeFilterRewriter
  7672  	ObjectTypeInputBarrier
  7673  	ObjectTypeInputLinux
  7674  	ObjectTypeIothread
  7675  	ObjectTypeMemoryBackendEpc
  7676  	ObjectTypeMemoryBackendFile
  7677  	ObjectTypeMemoryBackendMemfd
  7678  	ObjectTypeMemoryBackendRam
  7679  	ObjectTypePefGuest
  7680  	ObjectTypePrManagerHelper
  7681  	ObjectTypeQtest
  7682  	ObjectTypeRngBuiltin
  7683  	ObjectTypeRngEgd
  7684  	ObjectTypeRngRandom
  7685  	ObjectTypeSecret
  7686  	ObjectTypeSecret_Keyring
  7687  	ObjectTypeSevGuest
  7688  	ObjectTypeS390PvGuest
  7689  	ObjectTypeThrottleGroup
  7690  	ObjectTypeTlsCredsAnon
  7691  	ObjectTypeTlsCredsPsk
  7692  	ObjectTypeTlsCredsX509
  7693  	ObjectTypeTlsCipherSuites
  7694  	ObjectTypeXRemoteObject
  7695  )
  7696  
  7697  func (s ObjectType) MarshalJSON() ([]byte, error) {
  7698  	switch s {
  7699  	case ObjectTypeAuthzList:
  7700  		return []byte(`"authz-list"`), nil
  7701  	case ObjectTypeAuthzListfile:
  7702  		return []byte(`"authz-listfile"`), nil
  7703  	case ObjectTypeAuthzPam:
  7704  		return []byte(`"authz-pam"`), nil
  7705  	case ObjectTypeAuthzSimple:
  7706  		return []byte(`"authz-simple"`), nil
  7707  	case ObjectTypeCanBus:
  7708  		return []byte(`"can-bus"`), nil
  7709  	case ObjectTypeCanHostSocketcan:
  7710  		return []byte(`"can-host-socketcan"`), nil
  7711  	case ObjectTypeColoCompare:
  7712  		return []byte(`"colo-compare"`), nil
  7713  	case ObjectTypeCryptodevBackend:
  7714  		return []byte(`"cryptodev-backend"`), nil
  7715  	case ObjectTypeCryptodevBackendBuiltin:
  7716  		return []byte(`"cryptodev-backend-builtin"`), nil
  7717  	case ObjectTypeCryptodevVhostUser:
  7718  		return []byte(`"cryptodev-vhost-user"`), nil
  7719  	case ObjectTypeDbusVmstate:
  7720  		return []byte(`"dbus-vmstate"`), nil
  7721  	case ObjectTypeFilterBuffer:
  7722  		return []byte(`"filter-buffer"`), nil
  7723  	case ObjectTypeFilterDump:
  7724  		return []byte(`"filter-dump"`), nil
  7725  	case ObjectTypeFilterMirror:
  7726  		return []byte(`"filter-mirror"`), nil
  7727  	case ObjectTypeFilterRedirector:
  7728  		return []byte(`"filter-redirector"`), nil
  7729  	case ObjectTypeFilterReplay:
  7730  		return []byte(`"filter-replay"`), nil
  7731  	case ObjectTypeFilterRewriter:
  7732  		return []byte(`"filter-rewriter"`), nil
  7733  	case ObjectTypeInputBarrier:
  7734  		return []byte(`"input-barrier"`), nil
  7735  	case ObjectTypeInputLinux:
  7736  		return []byte(`"input-linux"`), nil
  7737  	case ObjectTypeIothread:
  7738  		return []byte(`"iothread"`), nil
  7739  	case ObjectTypeMemoryBackendEpc:
  7740  		return []byte(`"memory-backend-epc"`), nil
  7741  	case ObjectTypeMemoryBackendFile:
  7742  		return []byte(`"memory-backend-file"`), nil
  7743  	case ObjectTypeMemoryBackendMemfd:
  7744  		return []byte(`"memory-backend-memfd"`), nil
  7745  	case ObjectTypeMemoryBackendRam:
  7746  		return []byte(`"memory-backend-ram"`), nil
  7747  	case ObjectTypePefGuest:
  7748  		return []byte(`"pef-guest"`), nil
  7749  	case ObjectTypePrManagerHelper:
  7750  		return []byte(`"pr-manager-helper"`), nil
  7751  	case ObjectTypeQtest:
  7752  		return []byte(`"qtest"`), nil
  7753  	case ObjectTypeRngBuiltin:
  7754  		return []byte(`"rng-builtin"`), nil
  7755  	case ObjectTypeRngEgd:
  7756  		return []byte(`"rng-egd"`), nil
  7757  	case ObjectTypeRngRandom:
  7758  		return []byte(`"rng-random"`), nil
  7759  	case ObjectTypeSecret:
  7760  		return []byte(`"secret"`), nil
  7761  	case ObjectTypeSecret_Keyring:
  7762  		return []byte(`"secret_keyring"`), nil
  7763  	case ObjectTypeSevGuest:
  7764  		return []byte(`"sev-guest"`), nil
  7765  	case ObjectTypeS390PvGuest:
  7766  		return []byte(`"s390-pv-guest"`), nil
  7767  	case ObjectTypeThrottleGroup:
  7768  		return []byte(`"throttle-group"`), nil
  7769  	case ObjectTypeTlsCredsAnon:
  7770  		return []byte(`"tls-creds-anon"`), nil
  7771  	case ObjectTypeTlsCredsPsk:
  7772  		return []byte(`"tls-creds-psk"`), nil
  7773  	case ObjectTypeTlsCredsX509:
  7774  		return []byte(`"tls-creds-x509"`), nil
  7775  	case ObjectTypeTlsCipherSuites:
  7776  		return []byte(`"tls-cipher-suites"`), nil
  7777  	case ObjectTypeXRemoteObject:
  7778  		return []byte(`"x-remote-object"`), nil
  7779  	default:
  7780  		fmt.Println("Failed to decode ObjectType", s)
  7781  	}
  7782  	return nil, errors.New("Failed")
  7783  }
  7784  
  7785  func (s *ObjectType) UnmarshalJSON(data []byte) error {
  7786  	var name string
  7787  
  7788  	if err := json.Unmarshal(data, &name); err != nil {
  7789  		return err
  7790  	}
  7791  
  7792  	switch name {
  7793  	case "authz-list":
  7794  		(*s) = ObjectTypeAuthzList
  7795  	case "authz-listfile":
  7796  		(*s) = ObjectTypeAuthzListfile
  7797  	case "authz-pam":
  7798  		(*s) = ObjectTypeAuthzPam
  7799  	case "authz-simple":
  7800  		(*s) = ObjectTypeAuthzSimple
  7801  	case "can-bus":
  7802  		(*s) = ObjectTypeCanBus
  7803  	case "can-host-socketcan":
  7804  		(*s) = ObjectTypeCanHostSocketcan
  7805  	case "colo-compare":
  7806  		(*s) = ObjectTypeColoCompare
  7807  	case "cryptodev-backend":
  7808  		(*s) = ObjectTypeCryptodevBackend
  7809  	case "cryptodev-backend-builtin":
  7810  		(*s) = ObjectTypeCryptodevBackendBuiltin
  7811  	case "cryptodev-vhost-user":
  7812  		(*s) = ObjectTypeCryptodevVhostUser
  7813  	case "dbus-vmstate":
  7814  		(*s) = ObjectTypeDbusVmstate
  7815  	case "filter-buffer":
  7816  		(*s) = ObjectTypeFilterBuffer
  7817  	case "filter-dump":
  7818  		(*s) = ObjectTypeFilterDump
  7819  	case "filter-mirror":
  7820  		(*s) = ObjectTypeFilterMirror
  7821  	case "filter-redirector":
  7822  		(*s) = ObjectTypeFilterRedirector
  7823  	case "filter-replay":
  7824  		(*s) = ObjectTypeFilterReplay
  7825  	case "filter-rewriter":
  7826  		(*s) = ObjectTypeFilterRewriter
  7827  	case "input-barrier":
  7828  		(*s) = ObjectTypeInputBarrier
  7829  	case "input-linux":
  7830  		(*s) = ObjectTypeInputLinux
  7831  	case "iothread":
  7832  		(*s) = ObjectTypeIothread
  7833  	case "memory-backend-epc":
  7834  		(*s) = ObjectTypeMemoryBackendEpc
  7835  	case "memory-backend-file":
  7836  		(*s) = ObjectTypeMemoryBackendFile
  7837  	case "memory-backend-memfd":
  7838  		(*s) = ObjectTypeMemoryBackendMemfd
  7839  	case "memory-backend-ram":
  7840  		(*s) = ObjectTypeMemoryBackendRam
  7841  	case "pef-guest":
  7842  		(*s) = ObjectTypePefGuest
  7843  	case "pr-manager-helper":
  7844  		(*s) = ObjectTypePrManagerHelper
  7845  	case "qtest":
  7846  		(*s) = ObjectTypeQtest
  7847  	case "rng-builtin":
  7848  		(*s) = ObjectTypeRngBuiltin
  7849  	case "rng-egd":
  7850  		(*s) = ObjectTypeRngEgd
  7851  	case "rng-random":
  7852  		(*s) = ObjectTypeRngRandom
  7853  	case "secret":
  7854  		(*s) = ObjectTypeSecret
  7855  	case "secret_keyring":
  7856  		(*s) = ObjectTypeSecret_Keyring
  7857  	case "sev-guest":
  7858  		(*s) = ObjectTypeSevGuest
  7859  	case "s390-pv-guest":
  7860  		(*s) = ObjectTypeS390PvGuest
  7861  	case "throttle-group":
  7862  		(*s) = ObjectTypeThrottleGroup
  7863  	case "tls-creds-anon":
  7864  		(*s) = ObjectTypeTlsCredsAnon
  7865  	case "tls-creds-psk":
  7866  		(*s) = ObjectTypeTlsCredsPsk
  7867  	case "tls-creds-x509":
  7868  		(*s) = ObjectTypeTlsCredsX509
  7869  	case "tls-cipher-suites":
  7870  		(*s) = ObjectTypeTlsCipherSuites
  7871  	case "x-remote-object":
  7872  		(*s) = ObjectTypeXRemoteObject
  7873  	default:
  7874  		fmt.Println("Failed to decode ObjectType", *s)
  7875  	}
  7876  	return nil
  7877  }
  7878  
  7879  // The comprehensive enumeration of QEMU system emulation ("softmmu")
  7880  // targets. Run "./configure --help" in the project root directory, and
  7881  // look for the \*-softmmu targets near the "--target-list" option. The
  7882  // individual target constants are not documented here, for the time
  7883  // being.
  7884  //
  7885  // Notes: The resulting QMP strings can be appended to the "qemu-system-"
  7886  // prefix to produce the corresponding QEMU executable name. This
  7887  // is true even for "qemu-system-x86_64".
  7888  //
  7889  // Since: 3.0
  7890  type SysEmuTarget int32
  7891  
  7892  const (
  7893  	SysEmuTargetAarch64 SysEmuTarget = iota
  7894  	SysEmuTargetAlpha
  7895  	SysEmuTargetArm
  7896  	SysEmuTargetAvr // since 5.1
  7897  	SysEmuTargetCris
  7898  	SysEmuTargetHppa
  7899  	SysEmuTargetI386
  7900  	SysEmuTargetM68K
  7901  	SysEmuTargetMicroblaze
  7902  	SysEmuTargetMicroblazeel
  7903  	SysEmuTargetMips
  7904  	SysEmuTargetMips64
  7905  	SysEmuTargetMips64El
  7906  	SysEmuTargetMipsel
  7907  	SysEmuTargetNios2
  7908  	SysEmuTargetOr1K
  7909  	SysEmuTargetPpc
  7910  	SysEmuTargetPpc64
  7911  	SysEmuTargetRiscv32
  7912  	SysEmuTargetRiscv64
  7913  	SysEmuTargetRx // since 5.0
  7914  	SysEmuTargetS390X
  7915  	SysEmuTargetSh4
  7916  	SysEmuTargetSh4Eb
  7917  	SysEmuTargetSparc
  7918  	SysEmuTargetSparc64
  7919  	SysEmuTargetTricore
  7920  	SysEmuTargetX86_64
  7921  	SysEmuTargetXtensa
  7922  	SysEmuTargetXtensaeb
  7923  )
  7924  
  7925  func (s SysEmuTarget) MarshalJSON() ([]byte, error) {
  7926  	switch s {
  7927  	case SysEmuTargetAarch64:
  7928  		return []byte(`"aarch64"`), nil
  7929  	case SysEmuTargetAlpha:
  7930  		return []byte(`"alpha"`), nil
  7931  	case SysEmuTargetArm:
  7932  		return []byte(`"arm"`), nil
  7933  	case SysEmuTargetAvr:
  7934  		return []byte(`"avr"`), nil
  7935  	case SysEmuTargetCris:
  7936  		return []byte(`"cris"`), nil
  7937  	case SysEmuTargetHppa:
  7938  		return []byte(`"hppa"`), nil
  7939  	case SysEmuTargetI386:
  7940  		return []byte(`"i386"`), nil
  7941  	case SysEmuTargetM68K:
  7942  		return []byte(`"m68k"`), nil
  7943  	case SysEmuTargetMicroblaze:
  7944  		return []byte(`"microblaze"`), nil
  7945  	case SysEmuTargetMicroblazeel:
  7946  		return []byte(`"microblazeel"`), nil
  7947  	case SysEmuTargetMips:
  7948  		return []byte(`"mips"`), nil
  7949  	case SysEmuTargetMips64:
  7950  		return []byte(`"mips64"`), nil
  7951  	case SysEmuTargetMips64El:
  7952  		return []byte(`"mips64el"`), nil
  7953  	case SysEmuTargetMipsel:
  7954  		return []byte(`"mipsel"`), nil
  7955  	case SysEmuTargetNios2:
  7956  		return []byte(`"nios2"`), nil
  7957  	case SysEmuTargetOr1K:
  7958  		return []byte(`"or1k"`), nil
  7959  	case SysEmuTargetPpc:
  7960  		return []byte(`"ppc"`), nil
  7961  	case SysEmuTargetPpc64:
  7962  		return []byte(`"ppc64"`), nil
  7963  	case SysEmuTargetRiscv32:
  7964  		return []byte(`"riscv32"`), nil
  7965  	case SysEmuTargetRiscv64:
  7966  		return []byte(`"riscv64"`), nil
  7967  	case SysEmuTargetRx:
  7968  		return []byte(`"rx"`), nil
  7969  	case SysEmuTargetS390X:
  7970  		return []byte(`"s390x"`), nil
  7971  	case SysEmuTargetSh4:
  7972  		return []byte(`"sh4"`), nil
  7973  	case SysEmuTargetSh4Eb:
  7974  		return []byte(`"sh4eb"`), nil
  7975  	case SysEmuTargetSparc:
  7976  		return []byte(`"sparc"`), nil
  7977  	case SysEmuTargetSparc64:
  7978  		return []byte(`"sparc64"`), nil
  7979  	case SysEmuTargetTricore:
  7980  		return []byte(`"tricore"`), nil
  7981  	case SysEmuTargetX86_64:
  7982  		return []byte(`"x86_64"`), nil
  7983  	case SysEmuTargetXtensa:
  7984  		return []byte(`"xtensa"`), nil
  7985  	case SysEmuTargetXtensaeb:
  7986  		return []byte(`"xtensaeb"`), nil
  7987  	default:
  7988  		fmt.Println("Failed to decode SysEmuTarget", s)
  7989  	}
  7990  	return nil, errors.New("Failed")
  7991  }
  7992  
  7993  func (s *SysEmuTarget) UnmarshalJSON(data []byte) error {
  7994  	var name string
  7995  
  7996  	if err := json.Unmarshal(data, &name); err != nil {
  7997  		return err
  7998  	}
  7999  
  8000  	switch name {
  8001  	case "aarch64":
  8002  		(*s) = SysEmuTargetAarch64
  8003  	case "alpha":
  8004  		(*s) = SysEmuTargetAlpha
  8005  	case "arm":
  8006  		(*s) = SysEmuTargetArm
  8007  	case "avr":
  8008  		(*s) = SysEmuTargetAvr
  8009  	case "cris":
  8010  		(*s) = SysEmuTargetCris
  8011  	case "hppa":
  8012  		(*s) = SysEmuTargetHppa
  8013  	case "i386":
  8014  		(*s) = SysEmuTargetI386
  8015  	case "m68k":
  8016  		(*s) = SysEmuTargetM68K
  8017  	case "microblaze":
  8018  		(*s) = SysEmuTargetMicroblaze
  8019  	case "microblazeel":
  8020  		(*s) = SysEmuTargetMicroblazeel
  8021  	case "mips":
  8022  		(*s) = SysEmuTargetMips
  8023  	case "mips64":
  8024  		(*s) = SysEmuTargetMips64
  8025  	case "mips64el":
  8026  		(*s) = SysEmuTargetMips64El
  8027  	case "mipsel":
  8028  		(*s) = SysEmuTargetMipsel
  8029  	case "nios2":
  8030  		(*s) = SysEmuTargetNios2
  8031  	case "or1k":
  8032  		(*s) = SysEmuTargetOr1K
  8033  	case "ppc":
  8034  		(*s) = SysEmuTargetPpc
  8035  	case "ppc64":
  8036  		(*s) = SysEmuTargetPpc64
  8037  	case "riscv32":
  8038  		(*s) = SysEmuTargetRiscv32
  8039  	case "riscv64":
  8040  		(*s) = SysEmuTargetRiscv64
  8041  	case "rx":
  8042  		(*s) = SysEmuTargetRx
  8043  	case "s390x":
  8044  		(*s) = SysEmuTargetS390X
  8045  	case "sh4":
  8046  		(*s) = SysEmuTargetSh4
  8047  	case "sh4eb":
  8048  		(*s) = SysEmuTargetSh4Eb
  8049  	case "sparc":
  8050  		(*s) = SysEmuTargetSparc
  8051  	case "sparc64":
  8052  		(*s) = SysEmuTargetSparc64
  8053  	case "tricore":
  8054  		(*s) = SysEmuTargetTricore
  8055  	case "x86_64":
  8056  		(*s) = SysEmuTargetX86_64
  8057  	case "xtensa":
  8058  		(*s) = SysEmuTargetXtensa
  8059  	case "xtensaeb":
  8060  		(*s) = SysEmuTargetXtensaeb
  8061  	default:
  8062  		fmt.Println("Failed to decode SysEmuTarget", *s)
  8063  	}
  8064  	return nil
  8065  }
  8066  
  8067  // An enumeration of cpu states that can be assumed by a virtual
  8068  // S390 CPU
  8069  //
  8070  // Since: 2.12
  8071  type CpuS390State int32
  8072  
  8073  const (
  8074  	CpuS390StateUninitialized CpuS390State = iota
  8075  	CpuS390StateStopped
  8076  	CpuS390StateCheckStop
  8077  	CpuS390StateOperating
  8078  	CpuS390StateLoad
  8079  )
  8080  
  8081  func (s CpuS390State) MarshalJSON() ([]byte, error) {
  8082  	switch s {
  8083  	case CpuS390StateUninitialized:
  8084  		return []byte(`"uninitialized"`), nil
  8085  	case CpuS390StateStopped:
  8086  		return []byte(`"stopped"`), nil
  8087  	case CpuS390StateCheckStop:
  8088  		return []byte(`"check-stop"`), nil
  8089  	case CpuS390StateOperating:
  8090  		return []byte(`"operating"`), nil
  8091  	case CpuS390StateLoad:
  8092  		return []byte(`"load"`), nil
  8093  	default:
  8094  		fmt.Println("Failed to decode CpuS390State", s)
  8095  	}
  8096  	return nil, errors.New("Failed")
  8097  }
  8098  
  8099  func (s *CpuS390State) UnmarshalJSON(data []byte) error {
  8100  	var name string
  8101  
  8102  	if err := json.Unmarshal(data, &name); err != nil {
  8103  		return err
  8104  	}
  8105  
  8106  	switch name {
  8107  	case "uninitialized":
  8108  		(*s) = CpuS390StateUninitialized
  8109  	case "stopped":
  8110  		(*s) = CpuS390StateStopped
  8111  	case "check-stop":
  8112  		(*s) = CpuS390StateCheckStop
  8113  	case "operating":
  8114  		(*s) = CpuS390StateOperating
  8115  	case "load":
  8116  		(*s) = CpuS390StateLoad
  8117  	default:
  8118  		fmt.Println("Failed to decode CpuS390State", *s)
  8119  	}
  8120  	return nil
  8121  }
  8122  
  8123  // Policy for handling lost ticks in timer devices.  Ticks end up getting
  8124  // lost when, for example, the guest is paused.
  8125  //
  8126  // Since: 2.0
  8127  type LostTickPolicy int32
  8128  
  8129  const (
  8130  	LostTickPolicyDiscard LostTickPolicy = iota
  8131  	LostTickPolicyDelay                  // continue to deliver ticks at the normal rate. The guest OS will not notice anything is amiss, as from its point of view time will have continued to flow normally. The time in the guest should now be behind the time in the host by exactly the amount of time during which ticks have been missed.
  8132  	LostTickPolicySlew                   // deliver ticks at a higher rate to catch up with the missed ticks. The guest OS will not notice anything is amiss, as from its point of view time will have continued to flow normally. Once the timer has managed to catch up with all the missing ticks, the time in the guest and in the host should match.
  8133  )
  8134  
  8135  func (s LostTickPolicy) MarshalJSON() ([]byte, error) {
  8136  	switch s {
  8137  	case LostTickPolicyDiscard:
  8138  		return []byte(`"discard"`), nil
  8139  	case LostTickPolicyDelay:
  8140  		return []byte(`"delay"`), nil
  8141  	case LostTickPolicySlew:
  8142  		return []byte(`"slew"`), nil
  8143  	default:
  8144  		fmt.Println("Failed to decode LostTickPolicy", s)
  8145  	}
  8146  	return nil, errors.New("Failed")
  8147  }
  8148  
  8149  func (s *LostTickPolicy) UnmarshalJSON(data []byte) error {
  8150  	var name string
  8151  
  8152  	if err := json.Unmarshal(data, &name); err != nil {
  8153  		return err
  8154  	}
  8155  
  8156  	switch name {
  8157  	case "discard":
  8158  		(*s) = LostTickPolicyDiscard
  8159  	case "delay":
  8160  		(*s) = LostTickPolicyDelay
  8161  	case "slew":
  8162  		(*s) = LostTickPolicySlew
  8163  	default:
  8164  		fmt.Println("Failed to decode LostTickPolicy", *s)
  8165  	}
  8166  	return nil
  8167  }
  8168  
  8169  // Since: 2.1
  8170  type NumaOptionsType int32
  8171  
  8172  const (
  8173  	NumaOptionsTypeNode      NumaOptionsType = iota
  8174  	NumaOptionsTypeDist                      // NUMA distance configuration (since 2.10)
  8175  	NumaOptionsTypeCpu                       // property based CPU(s) to node mapping (Since: 2.10)
  8176  	NumaOptionsTypeHmatLb                    // memory latency and bandwidth information (Since: 5.0)
  8177  	NumaOptionsTypeHmatCache                 // memory side cache information (Since: 5.0)
  8178  )
  8179  
  8180  func (s NumaOptionsType) MarshalJSON() ([]byte, error) {
  8181  	switch s {
  8182  	case NumaOptionsTypeNode:
  8183  		return []byte(`"node"`), nil
  8184  	case NumaOptionsTypeDist:
  8185  		return []byte(`"dist"`), nil
  8186  	case NumaOptionsTypeCpu:
  8187  		return []byte(`"cpu"`), nil
  8188  	case NumaOptionsTypeHmatLb:
  8189  		return []byte(`"hmat-lb"`), nil
  8190  	case NumaOptionsTypeHmatCache:
  8191  		return []byte(`"hmat-cache"`), nil
  8192  	default:
  8193  		fmt.Println("Failed to decode NumaOptionsType", s)
  8194  	}
  8195  	return nil, errors.New("Failed")
  8196  }
  8197  
  8198  func (s *NumaOptionsType) UnmarshalJSON(data []byte) error {
  8199  	var name string
  8200  
  8201  	if err := json.Unmarshal(data, &name); err != nil {
  8202  		return err
  8203  	}
  8204  
  8205  	switch name {
  8206  	case "node":
  8207  		(*s) = NumaOptionsTypeNode
  8208  	case "dist":
  8209  		(*s) = NumaOptionsTypeDist
  8210  	case "cpu":
  8211  		(*s) = NumaOptionsTypeCpu
  8212  	case "hmat-lb":
  8213  		(*s) = NumaOptionsTypeHmatLb
  8214  	case "hmat-cache":
  8215  		(*s) = NumaOptionsTypeHmatCache
  8216  	default:
  8217  		fmt.Println("Failed to decode NumaOptionsType", *s)
  8218  	}
  8219  	return nil
  8220  }
  8221  
  8222  // A X86 32-bit register
  8223  //
  8224  // Since: 1.5
  8225  type X86CPURegister32 int32
  8226  
  8227  const (
  8228  	X86CPURegister32Eax X86CPURegister32 = iota
  8229  	X86CPURegister32Ebx
  8230  	X86CPURegister32Ecx
  8231  	X86CPURegister32Edx
  8232  	X86CPURegister32Esp
  8233  	X86CPURegister32Ebp
  8234  	X86CPURegister32Esi
  8235  	X86CPURegister32Edi
  8236  )
  8237  
  8238  func (s X86CPURegister32) MarshalJSON() ([]byte, error) {
  8239  	switch s {
  8240  	case X86CPURegister32Eax:
  8241  		return []byte(`"EAX"`), nil
  8242  	case X86CPURegister32Ebx:
  8243  		return []byte(`"EBX"`), nil
  8244  	case X86CPURegister32Ecx:
  8245  		return []byte(`"ECX"`), nil
  8246  	case X86CPURegister32Edx:
  8247  		return []byte(`"EDX"`), nil
  8248  	case X86CPURegister32Esp:
  8249  		return []byte(`"ESP"`), nil
  8250  	case X86CPURegister32Ebp:
  8251  		return []byte(`"EBP"`), nil
  8252  	case X86CPURegister32Esi:
  8253  		return []byte(`"ESI"`), nil
  8254  	case X86CPURegister32Edi:
  8255  		return []byte(`"EDI"`), nil
  8256  	default:
  8257  		fmt.Println("Failed to decode X86CPURegister32", s)
  8258  	}
  8259  	return nil, errors.New("Failed")
  8260  }
  8261  
  8262  func (s *X86CPURegister32) UnmarshalJSON(data []byte) error {
  8263  	var name string
  8264  
  8265  	if err := json.Unmarshal(data, &name); err != nil {
  8266  		return err
  8267  	}
  8268  
  8269  	switch name {
  8270  	case "EAX":
  8271  		(*s) = X86CPURegister32Eax
  8272  	case "EBX":
  8273  		(*s) = X86CPURegister32Ebx
  8274  	case "ECX":
  8275  		(*s) = X86CPURegister32Ecx
  8276  	case "EDX":
  8277  		(*s) = X86CPURegister32Edx
  8278  	case "ESP":
  8279  		(*s) = X86CPURegister32Esp
  8280  	case "EBP":
  8281  		(*s) = X86CPURegister32Ebp
  8282  	case "ESI":
  8283  		(*s) = X86CPURegister32Esi
  8284  	case "EDI":
  8285  		(*s) = X86CPURegister32Edi
  8286  	default:
  8287  		fmt.Println("Failed to decode X86CPURegister32", *s)
  8288  	}
  8289  	return nil
  8290  }
  8291  
  8292  // The memory hierarchy in the System Locality Latency and Bandwidth
  8293  // Information Structure of HMAT (Heterogeneous Memory Attribute Table)
  8294  //
  8295  // For more information about @HmatLBMemoryHierarchy, see chapter
  8296  // 5.2.27.4: Table 5-146: Field "Flags" of ACPI 6.3 spec.
  8297  //
  8298  // Since: 5.0
  8299  type HmatLBMemoryHierarchy int32
  8300  
  8301  const (
  8302  	HmatLBMemoryHierarchyMemory      HmatLBMemoryHierarchy = iota
  8303  	HmatLBMemoryHierarchyFirstLevel                        // first level of memory side cache
  8304  	HmatLBMemoryHierarchySecondLevel                       // second level of memory side cache
  8305  	HmatLBMemoryHierarchyThirdLevel                        // third level of memory side cache
  8306  )
  8307  
  8308  func (s HmatLBMemoryHierarchy) MarshalJSON() ([]byte, error) {
  8309  	switch s {
  8310  	case HmatLBMemoryHierarchyMemory:
  8311  		return []byte(`"memory"`), nil
  8312  	case HmatLBMemoryHierarchyFirstLevel:
  8313  		return []byte(`"first-level"`), nil
  8314  	case HmatLBMemoryHierarchySecondLevel:
  8315  		return []byte(`"second-level"`), nil
  8316  	case HmatLBMemoryHierarchyThirdLevel:
  8317  		return []byte(`"third-level"`), nil
  8318  	default:
  8319  		fmt.Println("Failed to decode HmatLBMemoryHierarchy", s)
  8320  	}
  8321  	return nil, errors.New("Failed")
  8322  }
  8323  
  8324  func (s *HmatLBMemoryHierarchy) UnmarshalJSON(data []byte) error {
  8325  	var name string
  8326  
  8327  	if err := json.Unmarshal(data, &name); err != nil {
  8328  		return err
  8329  	}
  8330  
  8331  	switch name {
  8332  	case "memory":
  8333  		(*s) = HmatLBMemoryHierarchyMemory
  8334  	case "first-level":
  8335  		(*s) = HmatLBMemoryHierarchyFirstLevel
  8336  	case "second-level":
  8337  		(*s) = HmatLBMemoryHierarchySecondLevel
  8338  	case "third-level":
  8339  		(*s) = HmatLBMemoryHierarchyThirdLevel
  8340  	default:
  8341  		fmt.Println("Failed to decode HmatLBMemoryHierarchy", *s)
  8342  	}
  8343  	return nil
  8344  }
  8345  
  8346  // Data type in the System Locality Latency and Bandwidth
  8347  // Information Structure of HMAT (Heterogeneous Memory Attribute Table)
  8348  //
  8349  // For more information about @HmatLBDataType, see chapter
  8350  // 5.2.27.4: Table 5-146:  Field "Data Type" of ACPI 6.3 spec.
  8351  //
  8352  // Since: 5.0
  8353  type HmatLBDataType int32
  8354  
  8355  const (
  8356  	HmatLBDataTypeAccessLatency   HmatLBDataType = iota
  8357  	HmatLBDataTypeReadLatency                    // read latency (nanoseconds)
  8358  	HmatLBDataTypeWriteLatency                   // write latency (nanoseconds)
  8359  	HmatLBDataTypeAccessBandwidth                // access bandwidth (Bytes per second)
  8360  	HmatLBDataTypeReadBandwidth                  // read bandwidth (Bytes per second)
  8361  	HmatLBDataTypeWriteBandwidth                 // write bandwidth (Bytes per second)
  8362  )
  8363  
  8364  func (s HmatLBDataType) MarshalJSON() ([]byte, error) {
  8365  	switch s {
  8366  	case HmatLBDataTypeAccessLatency:
  8367  		return []byte(`"access-latency"`), nil
  8368  	case HmatLBDataTypeReadLatency:
  8369  		return []byte(`"read-latency"`), nil
  8370  	case HmatLBDataTypeWriteLatency:
  8371  		return []byte(`"write-latency"`), nil
  8372  	case HmatLBDataTypeAccessBandwidth:
  8373  		return []byte(`"access-bandwidth"`), nil
  8374  	case HmatLBDataTypeReadBandwidth:
  8375  		return []byte(`"read-bandwidth"`), nil
  8376  	case HmatLBDataTypeWriteBandwidth:
  8377  		return []byte(`"write-bandwidth"`), nil
  8378  	default:
  8379  		fmt.Println("Failed to decode HmatLBDataType", s)
  8380  	}
  8381  	return nil, errors.New("Failed")
  8382  }
  8383  
  8384  func (s *HmatLBDataType) UnmarshalJSON(data []byte) error {
  8385  	var name string
  8386  
  8387  	if err := json.Unmarshal(data, &name); err != nil {
  8388  		return err
  8389  	}
  8390  
  8391  	switch name {
  8392  	case "access-latency":
  8393  		(*s) = HmatLBDataTypeAccessLatency
  8394  	case "read-latency":
  8395  		(*s) = HmatLBDataTypeReadLatency
  8396  	case "write-latency":
  8397  		(*s) = HmatLBDataTypeWriteLatency
  8398  	case "access-bandwidth":
  8399  		(*s) = HmatLBDataTypeAccessBandwidth
  8400  	case "read-bandwidth":
  8401  		(*s) = HmatLBDataTypeReadBandwidth
  8402  	case "write-bandwidth":
  8403  		(*s) = HmatLBDataTypeWriteBandwidth
  8404  	default:
  8405  		fmt.Println("Failed to decode HmatLBDataType", *s)
  8406  	}
  8407  	return nil
  8408  }
  8409  
  8410  // Cache associativity in the Memory Side Cache Information Structure
  8411  // of HMAT
  8412  //
  8413  // For more information of @HmatCacheAssociativity, see chapter
  8414  // 5.2.27.5: Table 5-147 of ACPI 6.3 spec.
  8415  //
  8416  // Since: 5.0
  8417  type HmatCacheAssociativity int32
  8418  
  8419  const (
  8420  	HmatCacheAssociativityNone    HmatCacheAssociativity = iota
  8421  	HmatCacheAssociativityDirect                         // Direct Mapped
  8422  	HmatCacheAssociativityComplex                        // Complex Cache Indexing (implementation specific)
  8423  )
  8424  
  8425  func (s HmatCacheAssociativity) MarshalJSON() ([]byte, error) {
  8426  	switch s {
  8427  	case HmatCacheAssociativityNone:
  8428  		return []byte(`"none"`), nil
  8429  	case HmatCacheAssociativityDirect:
  8430  		return []byte(`"direct"`), nil
  8431  	case HmatCacheAssociativityComplex:
  8432  		return []byte(`"complex"`), nil
  8433  	default:
  8434  		fmt.Println("Failed to decode HmatCacheAssociativity", s)
  8435  	}
  8436  	return nil, errors.New("Failed")
  8437  }
  8438  
  8439  func (s *HmatCacheAssociativity) UnmarshalJSON(data []byte) error {
  8440  	var name string
  8441  
  8442  	if err := json.Unmarshal(data, &name); err != nil {
  8443  		return err
  8444  	}
  8445  
  8446  	switch name {
  8447  	case "none":
  8448  		(*s) = HmatCacheAssociativityNone
  8449  	case "direct":
  8450  		(*s) = HmatCacheAssociativityDirect
  8451  	case "complex":
  8452  		(*s) = HmatCacheAssociativityComplex
  8453  	default:
  8454  		fmt.Println("Failed to decode HmatCacheAssociativity", *s)
  8455  	}
  8456  	return nil
  8457  }
  8458  
  8459  // Cache write policy in the Memory Side Cache Information Structure
  8460  // of HMAT
  8461  //
  8462  // For more information of @HmatCacheWritePolicy, see chapter
  8463  // 5.2.27.5: Table 5-147: Field "Cache Attributes" of ACPI 6.3 spec.
  8464  //
  8465  // Since: 5.0
  8466  type HmatCacheWritePolicy int32
  8467  
  8468  const (
  8469  	HmatCacheWritePolicyNone         HmatCacheWritePolicy = iota
  8470  	HmatCacheWritePolicyWriteBack                         // Write Back (WB)
  8471  	HmatCacheWritePolicyWriteThrough                      // Write Through (WT)
  8472  )
  8473  
  8474  func (s HmatCacheWritePolicy) MarshalJSON() ([]byte, error) {
  8475  	switch s {
  8476  	case HmatCacheWritePolicyNone:
  8477  		return []byte(`"none"`), nil
  8478  	case HmatCacheWritePolicyWriteBack:
  8479  		return []byte(`"write-back"`), nil
  8480  	case HmatCacheWritePolicyWriteThrough:
  8481  		return []byte(`"write-through"`), nil
  8482  	default:
  8483  		fmt.Println("Failed to decode HmatCacheWritePolicy", s)
  8484  	}
  8485  	return nil, errors.New("Failed")
  8486  }
  8487  
  8488  func (s *HmatCacheWritePolicy) UnmarshalJSON(data []byte) error {
  8489  	var name string
  8490  
  8491  	if err := json.Unmarshal(data, &name); err != nil {
  8492  		return err
  8493  	}
  8494  
  8495  	switch name {
  8496  	case "none":
  8497  		(*s) = HmatCacheWritePolicyNone
  8498  	case "write-back":
  8499  		(*s) = HmatCacheWritePolicyWriteBack
  8500  	case "write-through":
  8501  		(*s) = HmatCacheWritePolicyWriteThrough
  8502  	default:
  8503  		fmt.Println("Failed to decode HmatCacheWritePolicy", *s)
  8504  	}
  8505  	return nil
  8506  }
  8507  
  8508  // Since: 2.1
  8509  type MemoryDeviceInfoKind int32
  8510  
  8511  const (
  8512  	MemoryDeviceInfoKindDimm MemoryDeviceInfoKind = iota
  8513  	MemoryDeviceInfoKindNvdimm
  8514  	MemoryDeviceInfoKindVirtioPmem
  8515  	MemoryDeviceInfoKindVirtioMem
  8516  	MemoryDeviceInfoKindSgxEpc
  8517  )
  8518  
  8519  func (s MemoryDeviceInfoKind) MarshalJSON() ([]byte, error) {
  8520  	switch s {
  8521  	case MemoryDeviceInfoKindDimm:
  8522  		return []byte(`"dimm"`), nil
  8523  	case MemoryDeviceInfoKindNvdimm:
  8524  		return []byte(`"nvdimm"`), nil
  8525  	case MemoryDeviceInfoKindVirtioPmem:
  8526  		return []byte(`"virtio-pmem"`), nil
  8527  	case MemoryDeviceInfoKindVirtioMem:
  8528  		return []byte(`"virtio-mem"`), nil
  8529  	case MemoryDeviceInfoKindSgxEpc:
  8530  		return []byte(`"sgx-epc"`), nil
  8531  	default:
  8532  		fmt.Println("Failed to decode MemoryDeviceInfoKind", s)
  8533  	}
  8534  	return nil, errors.New("Failed")
  8535  }
  8536  
  8537  func (s *MemoryDeviceInfoKind) UnmarshalJSON(data []byte) error {
  8538  	var name string
  8539  
  8540  	if err := json.Unmarshal(data, &name); err != nil {
  8541  		return err
  8542  	}
  8543  
  8544  	switch name {
  8545  	case "dimm":
  8546  		(*s) = MemoryDeviceInfoKindDimm
  8547  	case "nvdimm":
  8548  		(*s) = MemoryDeviceInfoKindNvdimm
  8549  	case "virtio-pmem":
  8550  		(*s) = MemoryDeviceInfoKindVirtioPmem
  8551  	case "virtio-mem":
  8552  		(*s) = MemoryDeviceInfoKindVirtioMem
  8553  	case "sgx-epc":
  8554  		(*s) = MemoryDeviceInfoKindSgxEpc
  8555  	default:
  8556  		fmt.Println("Failed to decode MemoryDeviceInfoKind", *s)
  8557  	}
  8558  	return nil
  8559  }
  8560  
  8561  // Since: 7.0
  8562  type SmbiosEntryPointType int32
  8563  
  8564  const (
  8565  	SmbiosEntryPointType32 SmbiosEntryPointType = iota
  8566  	SmbiosEntryPointType64                      // SMBIOS version 3.0 (64-bit) Entry Point
  8567  )
  8568  
  8569  func (s SmbiosEntryPointType) MarshalJSON() ([]byte, error) {
  8570  	switch s {
  8571  	case SmbiosEntryPointType32:
  8572  		return []byte(`"32"`), nil
  8573  	case SmbiosEntryPointType64:
  8574  		return []byte(`"64"`), nil
  8575  	default:
  8576  		fmt.Println("Failed to decode SmbiosEntryPointType", s)
  8577  	}
  8578  	return nil, errors.New("Failed")
  8579  }
  8580  
  8581  func (s *SmbiosEntryPointType) UnmarshalJSON(data []byte) error {
  8582  	var name string
  8583  
  8584  	if err := json.Unmarshal(data, &name); err != nil {
  8585  		return err
  8586  	}
  8587  
  8588  	switch name {
  8589  	case "32":
  8590  		(*s) = SmbiosEntryPointType32
  8591  	case "64":
  8592  		(*s) = SmbiosEntryPointType64
  8593  	default:
  8594  		fmt.Println("Failed to decode SmbiosEntryPointType", *s)
  8595  	}
  8596  	return nil
  8597  }
  8598  
  8599  // An enumeration of CPU model expansion types.
  8600  //
  8601  // Note: When a non-migration-safe CPU model is expanded in static mode, some
  8602  // features enabled by the CPU model may be omitted, because they can't be
  8603  // implemented by a static CPU model definition (e.g. cache info passthrough and
  8604  // PMU passthrough in x86). If you need an accurate representation of the
  8605  // features enabled by a non-migration-safe CPU model, use @full. If you need a
  8606  // static representation that will keep ABI compatibility even when changing QEMU
  8607  // version or machine-type, use @static (but keep in mind that some features may
  8608  // be omitted).
  8609  //
  8610  // Since: 2.8
  8611  type CpuModelExpansionType int32
  8612  
  8613  const (
  8614  	CpuModelExpansionTypeStatic CpuModelExpansionType = iota
  8615  	CpuModelExpansionTypeFull                         // Expand all properties. The produced model is not guaranteed to be migration-safe, but allows tooling to get an insight and work with model details.
  8616  )
  8617  
  8618  func (s CpuModelExpansionType) MarshalJSON() ([]byte, error) {
  8619  	switch s {
  8620  	case CpuModelExpansionTypeStatic:
  8621  		return []byte(`"static"`), nil
  8622  	case CpuModelExpansionTypeFull:
  8623  		return []byte(`"full"`), nil
  8624  	default:
  8625  		fmt.Println("Failed to decode CpuModelExpansionType", s)
  8626  	}
  8627  	return nil, errors.New("Failed")
  8628  }
  8629  
  8630  func (s *CpuModelExpansionType) UnmarshalJSON(data []byte) error {
  8631  	var name string
  8632  
  8633  	if err := json.Unmarshal(data, &name); err != nil {
  8634  		return err
  8635  	}
  8636  
  8637  	switch name {
  8638  	case "static":
  8639  		(*s) = CpuModelExpansionTypeStatic
  8640  	case "full":
  8641  		(*s) = CpuModelExpansionTypeFull
  8642  	default:
  8643  		fmt.Println("Failed to decode CpuModelExpansionType", *s)
  8644  	}
  8645  	return nil
  8646  }
  8647  
  8648  // An enumeration of CPU model comparison results. The result is usually
  8649  // calculated using e.g. CPU features or CPU generations.
  8650  //
  8651  // Since: 2.8
  8652  type CpuModelCompareResult int32
  8653  
  8654  const (
  8655  	CpuModelCompareResultIncompatible CpuModelCompareResult = iota
  8656  	CpuModelCompareResultIdentical                          // If model A is identical to model B, model A is guaranteed to run where model B runs and the other way around.
  8657  	CpuModelCompareResultSuperset                           // If model A is a superset of model B, model B is guaranteed to run where model A runs. There are no guarantees about the other way.
  8658  	CpuModelCompareResultSubset                             // If model A is a subset of model B, model A is guaranteed to run where model B runs. There are no guarantees about the other way.
  8659  )
  8660  
  8661  func (s CpuModelCompareResult) MarshalJSON() ([]byte, error) {
  8662  	switch s {
  8663  	case CpuModelCompareResultIncompatible:
  8664  		return []byte(`"incompatible"`), nil
  8665  	case CpuModelCompareResultIdentical:
  8666  		return []byte(`"identical"`), nil
  8667  	case CpuModelCompareResultSuperset:
  8668  		return []byte(`"superset"`), nil
  8669  	case CpuModelCompareResultSubset:
  8670  		return []byte(`"subset"`), nil
  8671  	default:
  8672  		fmt.Println("Failed to decode CpuModelCompareResult", s)
  8673  	}
  8674  	return nil, errors.New("Failed")
  8675  }
  8676  
  8677  func (s *CpuModelCompareResult) UnmarshalJSON(data []byte) error {
  8678  	var name string
  8679  
  8680  	if err := json.Unmarshal(data, &name); err != nil {
  8681  		return err
  8682  	}
  8683  
  8684  	switch name {
  8685  	case "incompatible":
  8686  		(*s) = CpuModelCompareResultIncompatible
  8687  	case "identical":
  8688  		(*s) = CpuModelCompareResultIdentical
  8689  	case "superset":
  8690  		(*s) = CpuModelCompareResultSuperset
  8691  	case "subset":
  8692  		(*s) = CpuModelCompareResultSubset
  8693  	default:
  8694  		fmt.Println("Failed to decode CpuModelCompareResult", *s)
  8695  	}
  8696  	return nil
  8697  }
  8698  
  8699  // Mode of the replay subsystem.
  8700  //
  8701  // Since: 2.5
  8702  type ReplayMode int32
  8703  
  8704  const (
  8705  	ReplayModeNone   ReplayMode = iota
  8706  	ReplayModeRecord            // record mode. All non-deterministic data is written into the replay log.
  8707  	ReplayModePlay              // replay mode. Non-deterministic data required for system execution is read from the log.
  8708  )
  8709  
  8710  func (s ReplayMode) MarshalJSON() ([]byte, error) {
  8711  	switch s {
  8712  	case ReplayModeNone:
  8713  		return []byte(`"none"`), nil
  8714  	case ReplayModeRecord:
  8715  		return []byte(`"record"`), nil
  8716  	case ReplayModePlay:
  8717  		return []byte(`"play"`), nil
  8718  	default:
  8719  		fmt.Println("Failed to decode ReplayMode", s)
  8720  	}
  8721  	return nil, errors.New("Failed")
  8722  }
  8723  
  8724  func (s *ReplayMode) UnmarshalJSON(data []byte) error {
  8725  	var name string
  8726  
  8727  	if err := json.Unmarshal(data, &name); err != nil {
  8728  		return err
  8729  	}
  8730  
  8731  	switch name {
  8732  	case "none":
  8733  		(*s) = ReplayModeNone
  8734  	case "record":
  8735  		(*s) = ReplayModeRecord
  8736  	case "play":
  8737  		(*s) = ReplayModePlay
  8738  	default:
  8739  		fmt.Println("Failed to decode ReplayMode", *s)
  8740  	}
  8741  	return nil
  8742  }
  8743  
  8744  // An enumeration of yank instance types. See @YankInstance for more
  8745  // information.
  8746  //
  8747  // Since: 6.0
  8748  type YankInstanceType int32
  8749  
  8750  const (
  8751  	YankInstanceTypeBlockNode YankInstanceType = iota
  8752  	YankInstanceTypeChardev
  8753  	YankInstanceTypeMigration
  8754  )
  8755  
  8756  func (s YankInstanceType) MarshalJSON() ([]byte, error) {
  8757  	switch s {
  8758  	case YankInstanceTypeBlockNode:
  8759  		return []byte(`"block-node"`), nil
  8760  	case YankInstanceTypeChardev:
  8761  		return []byte(`"chardev"`), nil
  8762  	case YankInstanceTypeMigration:
  8763  		return []byte(`"migration"`), nil
  8764  	default:
  8765  		fmt.Println("Failed to decode YankInstanceType", s)
  8766  	}
  8767  	return nil, errors.New("Failed")
  8768  }
  8769  
  8770  func (s *YankInstanceType) UnmarshalJSON(data []byte) error {
  8771  	var name string
  8772  
  8773  	if err := json.Unmarshal(data, &name); err != nil {
  8774  		return err
  8775  	}
  8776  
  8777  	switch name {
  8778  	case "block-node":
  8779  		(*s) = YankInstanceTypeBlockNode
  8780  	case "chardev":
  8781  		(*s) = YankInstanceTypeChardev
  8782  	case "migration":
  8783  		(*s) = YankInstanceTypeMigration
  8784  	default:
  8785  		fmt.Println("Failed to decode YankInstanceType", *s)
  8786  	}
  8787  	return nil
  8788  }
  8789  
  8790  // Possible types for an option parameter.
  8791  //
  8792  // Since: 1.5
  8793  type CommandLineParameterType int32
  8794  
  8795  const (
  8796  	CommandLineParameterTypeString  CommandLineParameterType = iota
  8797  	CommandLineParameterTypeBoolean                          // accepts "on" or "off"
  8798  	CommandLineParameterTypeNumber                           // accepts a number
  8799  	CommandLineParameterTypeSize                             // accepts a number followed by an optional suffix (K)ilo, (M)ega, (G)iga, (T)era
  8800  )
  8801  
  8802  func (s CommandLineParameterType) MarshalJSON() ([]byte, error) {
  8803  	switch s {
  8804  	case CommandLineParameterTypeString:
  8805  		return []byte(`"string"`), nil
  8806  	case CommandLineParameterTypeBoolean:
  8807  		return []byte(`"boolean"`), nil
  8808  	case CommandLineParameterTypeNumber:
  8809  		return []byte(`"number"`), nil
  8810  	case CommandLineParameterTypeSize:
  8811  		return []byte(`"size"`), nil
  8812  	default:
  8813  		fmt.Println("Failed to decode CommandLineParameterType", s)
  8814  	}
  8815  	return nil, errors.New("Failed")
  8816  }
  8817  
  8818  func (s *CommandLineParameterType) UnmarshalJSON(data []byte) error {
  8819  	var name string
  8820  
  8821  	if err := json.Unmarshal(data, &name); err != nil {
  8822  		return err
  8823  	}
  8824  
  8825  	switch name {
  8826  	case "string":
  8827  		(*s) = CommandLineParameterTypeString
  8828  	case "boolean":
  8829  		(*s) = CommandLineParameterTypeBoolean
  8830  	case "number":
  8831  		(*s) = CommandLineParameterTypeNumber
  8832  	case "size":
  8833  		(*s) = CommandLineParameterTypeSize
  8834  	default:
  8835  		fmt.Println("Failed to decode CommandLineParameterType", *s)
  8836  	}
  8837  	return nil
  8838  }
  8839  
  8840  // An enumeration of SEV state information used during @query-sev.
  8841  //
  8842  // Since: 2.12
  8843  type SevState int32
  8844  
  8845  const (
  8846  	SevStateUninit        SevState = iota
  8847  	SevStateLaunchUpdate           // The guest is currently being launched; plaintext data and register state is being imported.
  8848  	SevStateLaunchSecret           // The guest is currently being launched; ciphertext data is being imported.
  8849  	SevStateRunning                // The guest is fully launched or migrated in.
  8850  	SevStateSendUpdate             // The guest is currently being migrated out to another machine.
  8851  	SevStateReceiveUpdate          // The guest is currently being migrated from another machine.
  8852  )
  8853  
  8854  func (s SevState) MarshalJSON() ([]byte, error) {
  8855  	switch s {
  8856  	case SevStateUninit:
  8857  		return []byte(`"uninit"`), nil
  8858  	case SevStateLaunchUpdate:
  8859  		return []byte(`"launch-update"`), nil
  8860  	case SevStateLaunchSecret:
  8861  		return []byte(`"launch-secret"`), nil
  8862  	case SevStateRunning:
  8863  		return []byte(`"running"`), nil
  8864  	case SevStateSendUpdate:
  8865  		return []byte(`"send-update"`), nil
  8866  	case SevStateReceiveUpdate:
  8867  		return []byte(`"receive-update"`), nil
  8868  	default:
  8869  		fmt.Println("Failed to decode SevState", s)
  8870  	}
  8871  	return nil, errors.New("Failed")
  8872  }
  8873  
  8874  func (s *SevState) UnmarshalJSON(data []byte) error {
  8875  	var name string
  8876  
  8877  	if err := json.Unmarshal(data, &name); err != nil {
  8878  		return err
  8879  	}
  8880  
  8881  	switch name {
  8882  	case "uninit":
  8883  		(*s) = SevStateUninit
  8884  	case "launch-update":
  8885  		(*s) = SevStateLaunchUpdate
  8886  	case "launch-secret":
  8887  		(*s) = SevStateLaunchSecret
  8888  	case "running":
  8889  		(*s) = SevStateRunning
  8890  	case "send-update":
  8891  		(*s) = SevStateSendUpdate
  8892  	case "receive-update":
  8893  		(*s) = SevStateReceiveUpdate
  8894  	default:
  8895  		fmt.Println("Failed to decode SevState", *s)
  8896  	}
  8897  	return nil
  8898  }
  8899  
  8900  // An enumeration of possible audio formats.
  8901  //
  8902  // Since: 4.0
  8903  type AudioFormat int32
  8904  
  8905  const (
  8906  	AudioFormatU8  AudioFormat = iota
  8907  	AudioFormatS8              // signed 8 bit integer
  8908  	AudioFormatU16             // unsigned 16 bit integer
  8909  	AudioFormatS16             // signed 16 bit integer
  8910  	AudioFormatU32             // unsigned 32 bit integer
  8911  	AudioFormatS32             // signed 32 bit integer
  8912  	AudioFormatF32             // single precision floating-point (since 5.0)
  8913  )
  8914  
  8915  func (s AudioFormat) MarshalJSON() ([]byte, error) {
  8916  	switch s {
  8917  	case AudioFormatU8:
  8918  		return []byte(`"u8"`), nil
  8919  	case AudioFormatS8:
  8920  		return []byte(`"s8"`), nil
  8921  	case AudioFormatU16:
  8922  		return []byte(`"u16"`), nil
  8923  	case AudioFormatS16:
  8924  		return []byte(`"s16"`), nil
  8925  	case AudioFormatU32:
  8926  		return []byte(`"u32"`), nil
  8927  	case AudioFormatS32:
  8928  		return []byte(`"s32"`), nil
  8929  	case AudioFormatF32:
  8930  		return []byte(`"f32"`), nil
  8931  	default:
  8932  		fmt.Println("Failed to decode AudioFormat", s)
  8933  	}
  8934  	return nil, errors.New("Failed")
  8935  }
  8936  
  8937  func (s *AudioFormat) UnmarshalJSON(data []byte) error {
  8938  	var name string
  8939  
  8940  	if err := json.Unmarshal(data, &name); err != nil {
  8941  		return err
  8942  	}
  8943  
  8944  	switch name {
  8945  	case "u8":
  8946  		(*s) = AudioFormatU8
  8947  	case "s8":
  8948  		(*s) = AudioFormatS8
  8949  	case "u16":
  8950  		(*s) = AudioFormatU16
  8951  	case "s16":
  8952  		(*s) = AudioFormatS16
  8953  	case "u32":
  8954  		(*s) = AudioFormatU32
  8955  	case "s32":
  8956  		(*s) = AudioFormatS32
  8957  	case "f32":
  8958  		(*s) = AudioFormatF32
  8959  	default:
  8960  		fmt.Println("Failed to decode AudioFormat", *s)
  8961  	}
  8962  	return nil
  8963  }
  8964  
  8965  // An enumeration of possible audio backend drivers.
  8966  //
  8967  // Since: 4.0
  8968  type AudiodevDriver int32
  8969  
  8970  const (
  8971  	AudiodevDriverNone AudiodevDriver = iota
  8972  	AudiodevDriverAlsa
  8973  	AudiodevDriverCoreaudio
  8974  	AudiodevDriverDbus
  8975  	AudiodevDriverDsound
  8976  	AudiodevDriverJack // JACK audio backend (since 5.1)
  8977  	AudiodevDriverOss
  8978  	AudiodevDriverPa
  8979  	AudiodevDriverSdl
  8980  	AudiodevDriverSpice
  8981  	AudiodevDriverWav
  8982  )
  8983  
  8984  func (s AudiodevDriver) MarshalJSON() ([]byte, error) {
  8985  	switch s {
  8986  	case AudiodevDriverNone:
  8987  		return []byte(`"none"`), nil
  8988  	case AudiodevDriverAlsa:
  8989  		return []byte(`"alsa"`), nil
  8990  	case AudiodevDriverCoreaudio:
  8991  		return []byte(`"coreaudio"`), nil
  8992  	case AudiodevDriverDbus:
  8993  		return []byte(`"dbus"`), nil
  8994  	case AudiodevDriverDsound:
  8995  		return []byte(`"dsound"`), nil
  8996  	case AudiodevDriverJack:
  8997  		return []byte(`"jack"`), nil
  8998  	case AudiodevDriverOss:
  8999  		return []byte(`"oss"`), nil
  9000  	case AudiodevDriverPa:
  9001  		return []byte(`"pa"`), nil
  9002  	case AudiodevDriverSdl:
  9003  		return []byte(`"sdl"`), nil
  9004  	case AudiodevDriverSpice:
  9005  		return []byte(`"spice"`), nil
  9006  	case AudiodevDriverWav:
  9007  		return []byte(`"wav"`), nil
  9008  	default:
  9009  		fmt.Println("Failed to decode AudiodevDriver", s)
  9010  	}
  9011  	return nil, errors.New("Failed")
  9012  }
  9013  
  9014  func (s *AudiodevDriver) UnmarshalJSON(data []byte) error {
  9015  	var name string
  9016  
  9017  	if err := json.Unmarshal(data, &name); err != nil {
  9018  		return err
  9019  	}
  9020  
  9021  	switch name {
  9022  	case "none":
  9023  		(*s) = AudiodevDriverNone
  9024  	case "alsa":
  9025  		(*s) = AudiodevDriverAlsa
  9026  	case "coreaudio":
  9027  		(*s) = AudiodevDriverCoreaudio
  9028  	case "dbus":
  9029  		(*s) = AudiodevDriverDbus
  9030  	case "dsound":
  9031  		(*s) = AudiodevDriverDsound
  9032  	case "jack":
  9033  		(*s) = AudiodevDriverJack
  9034  	case "oss":
  9035  		(*s) = AudiodevDriverOss
  9036  	case "pa":
  9037  		(*s) = AudiodevDriverPa
  9038  	case "sdl":
  9039  		(*s) = AudiodevDriverSdl
  9040  	case "spice":
  9041  		(*s) = AudiodevDriverSpice
  9042  	case "wav":
  9043  		(*s) = AudiodevDriverWav
  9044  	default:
  9045  		fmt.Println("Failed to decode AudiodevDriver", *s)
  9046  	}
  9047  	return nil
  9048  }
  9049  
  9050  type ACPISlotType int32
  9051  
  9052  const (
  9053  	ACPISlotTypeDimm ACPISlotType = iota
  9054  	ACPISlotTypeCpu               // logical CPU slot (since 2.7)
  9055  )
  9056  
  9057  func (s ACPISlotType) MarshalJSON() ([]byte, error) {
  9058  	switch s {
  9059  	case ACPISlotTypeDimm:
  9060  		return []byte(`"DIMM"`), nil
  9061  	case ACPISlotTypeCpu:
  9062  		return []byte(`"CPU"`), nil
  9063  	default:
  9064  		fmt.Println("Failed to decode ACPISlotType", s)
  9065  	}
  9066  	return nil, errors.New("Failed")
  9067  }
  9068  
  9069  func (s *ACPISlotType) UnmarshalJSON(data []byte) error {
  9070  	var name string
  9071  
  9072  	if err := json.Unmarshal(data, &name); err != nil {
  9073  		return err
  9074  	}
  9075  
  9076  	switch name {
  9077  	case "DIMM":
  9078  		(*s) = ACPISlotTypeDimm
  9079  	case "CPU":
  9080  		(*s) = ACPISlotTypeCpu
  9081  	default:
  9082  		fmt.Println("Failed to decode ACPISlotType", *s)
  9083  	}
  9084  	return nil
  9085  }
  9086  

View as plain text