github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/firecracker/client/models/vsock.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 strfmt "github.com/go-openapi/strfmt" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/swag" 13 "github.com/go-openapi/validate" 14 ) 15 16 // Vsock Defines a vsock device, backed by a set of Unix Domain Sockets, on the host side. For host-initiated connections, Firecracker will be listening on the Unix socket identified by the path `uds_path`. Firecracker will create this socket, bind and listen on it. Host-initiated connections will be performed by connection to this socket and issuing a connection forwarding request to the desired guest-side vsock port (i.e. `CONNECT 52\n`, to connect to port 52). For guest-initiated connections, Firecracker will expect host software to be bound and listening on Unix sockets at `uds_path_<PORT>`. E.g. "/path/to/host_vsock.sock_52" for port number 52. 17 // swagger:model Vsock 18 type Vsock struct { 19 20 // Guest Vsock CID 21 // Required: true 22 // Minimum: 3 23 GuestCid *int64 `json:"guest_cid"` 24 25 // Path to UNIX domain socket, used to proxy vsock connections. 26 // Required: true 27 UdsPath *string `json:"uds_path"` 28 29 // vsock id 30 // Required: true 31 VsockID *string `json:"vsock_id"` 32 } 33 34 // Validate validates this vsock 35 func (m *Vsock) Validate(formats strfmt.Registry) error { 36 var res []error 37 38 if err := m.validateGuestCid(formats); err != nil { 39 res = append(res, err) 40 } 41 42 if err := m.validateUdsPath(formats); err != nil { 43 res = append(res, err) 44 } 45 46 if err := m.validateVsockID(formats); err != nil { 47 res = append(res, err) 48 } 49 50 if len(res) > 0 { 51 return errors.CompositeValidationError(res...) 52 } 53 return nil 54 } 55 56 func (m *Vsock) validateGuestCid(formats strfmt.Registry) error { 57 58 if err := validate.Required("guest_cid", "body", m.GuestCid); err != nil { 59 return err 60 } 61 62 if err := validate.MinimumInt("guest_cid", "body", int64(*m.GuestCid), 3, false); err != nil { 63 return err 64 } 65 66 return nil 67 } 68 69 func (m *Vsock) validateUdsPath(formats strfmt.Registry) error { 70 71 if err := validate.Required("uds_path", "body", m.UdsPath); err != nil { 72 return err 73 } 74 75 return nil 76 } 77 78 func (m *Vsock) validateVsockID(formats strfmt.Registry) error { 79 80 if err := validate.Required("vsock_id", "body", m.VsockID); err != nil { 81 return err 82 } 83 84 return nil 85 } 86 87 // MarshalBinary interface implementation 88 func (m *Vsock) MarshalBinary() ([]byte, error) { 89 if m == nil { 90 return nil, nil 91 } 92 return swag.WriteJSON(m) 93 } 94 95 // UnmarshalBinary interface implementation 96 func (m *Vsock) UnmarshalBinary(b []byte) error { 97 var res Vsock 98 if err := swag.ReadJSON(b, &res); err != nil { 99 return err 100 } 101 *m = res 102 return nil 103 }