diff --git a/build/virt-prerunner/Dockerfile b/build/virt-prerunner/Dockerfile index afc67e7..44357ee 100644 --- a/build/virt-prerunner/Dockerfile +++ b/build/virt-prerunner/Dockerfile @@ -20,13 +20,13 @@ RUN set -eux; \ mkdir /var/lib/cloud-hypervisor; \ case "$(uname -m)" in \ 'x86_64') \ - curl -sLo /usr/bin/cloud-hypervisor https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v37.0/cloud-hypervisor-static; \ - curl -sLo /usr/bin/ch-remote https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v37.0/ch-remote-static; \ + curl -sLo /usr/bin/cloud-hypervisor https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v42.0/cloud-hypervisor-static; \ + curl -sLo /usr/bin/ch-remote https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v42.0/ch-remote-static; \ curl -sLo /var/lib/cloud-hypervisor/hypervisor-fw https://github.com/cloud-hypervisor/rust-hypervisor-firmware/releases/download/0.4.0/hypervisor-fw; \ ;; \ 'aarch64') \ - curl -sLo /usr/bin/cloud-hypervisor https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v37.0/cloud-hypervisor-static-aarch64; \ - curl -sLo /usr/bin/ch-remote https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v37.0/ch-remote-static-aarch64; \ + curl -sLo /usr/bin/cloud-hypervisor https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v42.0/cloud-hypervisor-static-aarch64; \ + curl -sLo /usr/bin/ch-remote https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v42.0/ch-remote-static-aarch64; \ curl -sLo /var/lib/cloud-hypervisor/CLOUDHV_EFI.fd https://github.com/smartxworks/cloud-hypervisor-edk2-builder/releases/download/20220706/CLOUDHV_EFI.fd; \ ;; \ *) echo >&2 "error: unsupported architecture '$(uname -m)'"; exit 1 ;; \ diff --git a/cmd/cloud-hypervisor-client-gen/main.go b/cmd/cloud-hypervisor-client-gen/main.go index 031e610..f7ef787 100644 --- a/cmd/cloud-hypervisor-client-gen/main.go +++ b/cmd/cloud-hypervisor-client-gen/main.go @@ -18,7 +18,7 @@ import ( var clientTemplate string func main() { - resp, err := http.Get("https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/v37.0/vmm/src/api/openapi/cloud-hypervisor.yaml") + resp, err := http.Get("https://raw.githubusercontent.com/cloud-hypervisor/cloud-hypervisor/v42.0/vmm/src/api/openapi/cloud-hypervisor.yaml") if err != nil { panic(err) } diff --git a/pkg/cloudhypervisor/client.go b/pkg/cloudhypervisor/client.go index 6d6c4f8..db5b096 100644 --- a/pkg/cloudhypervisor/client.go +++ b/pkg/cloudhypervisor/client.go @@ -719,6 +719,28 @@ func (c *Client) VmSnapshot(ctx context.Context, arg *VmSnapshotConfig) error { return nil } +// Inject an NMI. +func (c *Client) VmmNmi(ctx context.Context) error { + + req, err := http.NewRequestWithContext(ctx, "PUT", "http://localhost/api/v1/vmm.nmi", nil) + if err != nil { + return fmt.Errorf("build request: %s", err) + } + + resp, err := c.httpClient.Do(req) + if err != nil { + return fmt.Errorf("do request: %s", err) + } + defer resp.Body.Close() + + if resp.StatusCode >= 400 { + body, _ := io.ReadAll(resp.Body) + return fmt.Errorf("request failed: %d %s: %s", resp.StatusCode, http.StatusText(resp.StatusCode), string(body)) + } + + return nil +} + // Ping the VMM to check for API server availability func (c *Client) VmmPing(ctx context.Context) (*VmmPingResponse, error) { @@ -807,11 +829,18 @@ type CpusConfig struct { Topology *CpuTopology `json:"topology,omitempty"` } +type DebugConsoleConfig struct { + File string `json:"file,omitempty"` + Iobase int `json:"iobase,omitempty"` + Mode string `json:"mode"` +} + type DeviceConfig struct { - Id string `json:"id,omitempty"` - Iommu bool `json:"iommu,omitempty"` - Path string `json:"path"` - PciSegment int16 `json:"pci_segment,omitempty"` + Id string `json:"id,omitempty"` + Iommu bool `json:"iommu,omitempty"` + Path string `json:"path"` + PciSegment int16 `json:"pci_segment,omitempty"` + XNvGpudirectClique int `json:"x_nv_gpudirect_clique,omitempty"` } type DeviceNode struct { @@ -822,18 +851,20 @@ type DeviceNode struct { } type DiskConfig struct { - Direct bool `json:"direct,omitempty"` - Id string `json:"id,omitempty"` - Iommu bool `json:"iommu,omitempty"` - NumQueues int `json:"num_queues,omitempty"` - Path string `json:"path"` - PciSegment int16 `json:"pci_segment,omitempty"` - QueueSize int `json:"queue_size,omitempty"` - RateLimiterConfig *RateLimiterConfig `json:"rate_limiter_config,omitempty"` - Readonly bool `json:"readonly,omitempty"` - Serial string `json:"serial,omitempty"` - VhostSocket string `json:"vhost_socket,omitempty"` - VhostUser bool `json:"vhost_user,omitempty"` + Direct bool `json:"direct,omitempty"` + Id string `json:"id,omitempty"` + Iommu bool `json:"iommu,omitempty"` + NumQueues int `json:"num_queues,omitempty"` + Path string `json:"path"` + PciSegment int16 `json:"pci_segment,omitempty"` + QueueAffinity []*VirtQueueAffinity `json:"queue_affinity,omitempty"` + QueueSize int `json:"queue_size,omitempty"` + RateLimitGroup string `json:"rate_limit_group,omitempty"` + RateLimiterConfig *RateLimiterConfig `json:"rate_limiter_config,omitempty"` + Readonly bool `json:"readonly,omitempty"` + Serial string `json:"serial,omitempty"` + VhostSocket string `json:"vhost_socket,omitempty"` + VhostUser bool `json:"vhost_user,omitempty"` } type FsConfig struct { @@ -845,6 +876,11 @@ type FsConfig struct { Tag string `json:"tag"` } +type LandlockConfig struct { + Access string `json:"access"` + Path string `json:"path"` +} + type MemoryConfig struct { HotplugMethod string `json:"hotplug_method,omitempty"` HotplugSize int64 `json:"hotplug_size,omitempty"` @@ -919,6 +955,12 @@ type PciDeviceInfo struct { Id string `json:"id"` } +type PciSegmentConfig struct { + Mmio32ApertureWeight int `json:"mmio32_aperture_weight,omitempty"` + Mmio64ApertureWeight int `json:"mmio64_aperture_weight,omitempty"` + PciSegment int16 `json:"pci_segment"` +} + type PlatformConfig struct { IommuSegments []int16 `json:"iommu_segments,omitempty"` NumPciSegments int16 `json:"num_pci_segments,omitempty"` @@ -937,6 +979,11 @@ type PmemConfig struct { Size int64 `json:"size,omitempty"` } +type RateLimitGroupConfig struct { + Id string `json:"id"` + RateLimiterConfig *RateLimiterConfig `json:"rate_limiter_config"` +} + // Defines an IO rate limiter with independent bytes/s and ops/s limits. Limits are defined by configuring each of the _bandwidth_ and _ops_ token buckets. type RateLimiterConfig struct { Bandwidth *TokenBucket `json:"bandwidth,omitempty"` @@ -987,32 +1034,43 @@ type VdpaConfig struct { PciSegment int16 `json:"pci_segment,omitempty"` } +type VirtQueueAffinity struct { + HostCpus []int `json:"host_cpus"` + QueueIndex int `json:"queue_index"` +} + type VmAddUserDevice struct { Socket string `json:"socket"` } // Virtual machine configuration type VmConfig struct { - Balloon *BalloonConfig `json:"balloon,omitempty"` - Console *ConsoleConfig `json:"console,omitempty"` - Cpus *CpusConfig `json:"cpus,omitempty"` - Devices []*DeviceConfig `json:"devices,omitempty"` - Disks []*DiskConfig `json:"disks,omitempty"` - Fs []*FsConfig `json:"fs,omitempty"` - Iommu bool `json:"iommu,omitempty"` - Memory *MemoryConfig `json:"memory,omitempty"` - Net []*NetConfig `json:"net,omitempty"` - Numa []*NumaConfig `json:"numa,omitempty"` - Payload *PayloadConfig `json:"payload"` - Platform *PlatformConfig `json:"platform,omitempty"` - Pmem []*PmemConfig `json:"pmem,omitempty"` - Rng *RngConfig `json:"rng,omitempty"` - Serial *ConsoleConfig `json:"serial,omitempty"` - SgxEpc []*SgxEpcConfig `json:"sgx_epc,omitempty"` - Tpm *TpmConfig `json:"tpm,omitempty"` - Vdpa []*VdpaConfig `json:"vdpa,omitempty"` - Vsock *VsockConfig `json:"vsock,omitempty"` - Watchdog bool `json:"watchdog,omitempty"` + Balloon *BalloonConfig `json:"balloon,omitempty"` + Console *ConsoleConfig `json:"console,omitempty"` + Cpus *CpusConfig `json:"cpus,omitempty"` + DebugConsole *DebugConsoleConfig `json:"debug_console,omitempty"` + Devices []*DeviceConfig `json:"devices,omitempty"` + Disks []*DiskConfig `json:"disks,omitempty"` + Fs []*FsConfig `json:"fs,omitempty"` + Iommu bool `json:"iommu,omitempty"` + LandlockEnable bool `json:"landlock_enable,omitempty"` + LandlockRules []*LandlockConfig `json:"landlock_rules,omitempty"` + Memory *MemoryConfig `json:"memory,omitempty"` + Net []*NetConfig `json:"net,omitempty"` + Numa []*NumaConfig `json:"numa,omitempty"` + Payload *PayloadConfig `json:"payload"` + PciSegments []*PciSegmentConfig `json:"pci_segments,omitempty"` + Platform *PlatformConfig `json:"platform,omitempty"` + Pmem []*PmemConfig `json:"pmem,omitempty"` + Pvpanic bool `json:"pvpanic,omitempty"` + RateLimitGroups []*RateLimitGroupConfig `json:"rate_limit_groups,omitempty"` + Rng *RngConfig `json:"rng,omitempty"` + Serial *ConsoleConfig `json:"serial,omitempty"` + SgxEpc []*SgxEpcConfig `json:"sgx_epc,omitempty"` + Tpm *TpmConfig `json:"tpm,omitempty"` + Vdpa []*VdpaConfig `json:"vdpa,omitempty"` + Vsock *VsockConfig `json:"vsock,omitempty"` + Watchdog bool `json:"watchdog,omitempty"` } type VmCoredumpData struct {