Merge pull request #3496 from fidencio/wip/use-govmm-from-kata

govmm: Use it from our own repo
This commit is contained in:
Fabiano Fidêncio 2022-01-20 09:47:32 +01:00 committed by GitHub
commit 1a59c5743e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 64 additions and 5421 deletions

View File

@ -28,7 +28,6 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/hashicorp/go-multierror v1.0.0
github.com/intel-go/cpuid v0.0.0-20210602155658-5747e5cec0d9
github.com/kata-containers/govmm v0.0.0-20220117131932-0781a21804ee
github.com/mdlayher/vsock v0.0.0-20191108225356-d9c65923cb8f
github.com/opencontainers/runc v1.0.3
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417

View File

@ -576,8 +576,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kata-containers/govmm v0.0.0-20220117131932-0781a21804ee h1:XofauxL6B1JEeDS+Ta/M1tM9Kutj/n72JSAvx10ubFA=
github.com/kata-containers/govmm v0.0.0-20220117131932-0781a21804ee/go.mod h1:A6QaNB6N6PRQ9mTRpFtUxiF5T5CJpzLALjxBrUQPlFI=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

View File

@ -1,96 +0,0 @@
# Contributing to Virtual Machine Manager for Go
Virtual Machine Manager for Go is an open source project licensed under the [Apache v2 License] (https://opensource.org/licenses/Apache-2.0)
## Coding Style
Virtual Machine Manager for Go follows the standard formatting recommendations and language idioms set out
in [Effective Go](https://golang.org/doc/effective_go.html) and in the
[Go Code Review Comments wiki](https://github.com/golang/go/wiki/CodeReviewComments).
## Certificate of Origin
In order to get a clear contribution chain of trust we use the [signed-off-by language] (https://01.org/community/signed-process)
used by the Linux kernel project.
## Patch format
Beside the signed-off-by footer, we expect each patch to comply with the following format:
```
Change summary
More detailed explanation of your changes: Why and how.
Wrap it to 72 characters.
See [here] (http://chris.beams.io/posts/git-commit/)
for some more good advices.
Fixes #NUMBER (or URL to the issue)
Signed-off-by: <contributor@foo.com>
```
For example:
```
Fix poorly named identifiers
One identifier, fnname, in func.go was poorly named. It has been renamed
to fnName. Another identifier retval was not needed and has been removed
entirely.
Fixes #1
Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
```
## New files
Each Go source file in the Virtual Machine Manager for Go project must
contain the following header:
```
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
```
## Contributors File
This CONTRIBUTORS.md file is a partial list of contributors to the
Virtual Machine Manager for Go project. To see the full list of
contributors, see the revision history in source control.
Contributors who wish to be recognized in this file should add
themselves (or their employer, as appropriate).
## Pull requests
We accept github pull requests.
## Quality Controls
We request you give quality assurance some consideration by:
* Adding go unit tests for changes where it makes sense.
* Enabling [Travis CI](https://travis-ci.org/kata-containers/govmm) on your github fork of Virtual Machine Manager for Go to get continuous integration feedback on your dev/test branches.
## Issue tracking
If you have a problem, please let us know. If it's a bug not already documented, by all means please [open an
issue in github](https://github.com/kata-containers/govmm/issues/new) so we all get visibility
the problem and work toward resolution.
Any security issues discovered with govmm should be reported by following the instructions on https://01.org/security.

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,21 +0,0 @@
# Virtual Machine Manager for Go
[![Go Report Card](https://goreportcard.com/badge/github.com/kata-containers/govmm)](https://goreportcard.com/report/github.com/kata-containers/govmm)
[![Build Status](https://travis-ci.org/kata-containers/govmm.svg?branch=master)](https://travis-ci.org/kata-containers/govmm)
[![GoDoc](https://godoc.org/github.com/kata-containers/govmm/qemu?status.svg)](https://godoc.org/github.com/kata-containers/govmm/qemu)
[![Coverage Status](https://coveralls.io/repos/github/kata-containers/govmm/badge.svg?branch=master)](https://coveralls.io/github/kata-containers/govmm?branch=master)
Virtual Machine Manager for Go (govmm) is a suite of packages that
provide Go APIs for creating and managing virtual machines. There's
currently support for only one hypervisor, qemu/kvm (version 5.0 and
later), support for which is provided by the
github.com/kata-containers/govmm/qemu package.
The qemu package provides APIs for launching qemu instances and for
managing those instances via QMP, once launched. VM instances can
be stopped, have devices attached to them and monitored for events
via the qemu APIs.
The qemu package has no external dependencies apart from the Go
standard library and so is nice and easy to vendor inside other
projects.

View File

@ -1,3 +0,0 @@
module github.com/kata-containers/govmm
go 1.16

View File

@ -1,18 +1,7 @@
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu_test
@ -21,7 +10,7 @@ import (
"context"
"github.com/kata-containers/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
)
func Example() {

View File

@ -1,18 +1,7 @@
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu

View File

@ -1,18 +1,7 @@
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
// Package qemu provides methods and types for launching and managing QEMU
// instances. Instances can be launched with the LaunchQemu function and
@ -250,6 +239,7 @@ const (
)
// Object is a qemu object representation.
// nolint: govet
type Object struct {
// Driver is the qemu device driver
Driver DeviceDriver
@ -439,6 +429,7 @@ const (
)
// FSDevice represents a qemu filesystem configuration.
// nolint: govet
type FSDevice struct {
// Driver is the qemu device driver
Driver DeviceDriver
@ -574,6 +565,7 @@ const (
)
// CharDevice represents a qemu character device.
// nolint: govet
type CharDevice struct {
Backend CharDeviceBackend
@ -784,6 +776,7 @@ func (n NetDeviceType) QemuDeviceParam(netdev *NetDevice, config *Config) Device
}
// NetDevice represents a guest networking device
// nolint: govet
type NetDevice struct {
// Type is the netdev type (e.g. tap).
Type NetDeviceType
@ -1041,6 +1034,7 @@ func (dev LegacySerialDevice) deviceName(config *Config) string {
*/
// SerialDevice represents a qemu serial device.
// nolint: govet
type SerialDevice struct {
// Driver is the qemu device driver
Driver DeviceDriver
@ -1149,6 +1143,7 @@ const (
)
// BlockDevice represents a qemu block device.
// nolint: govet
type BlockDevice struct {
Driver DeviceDriver
ID string
@ -1316,6 +1311,7 @@ func (dev LoaderDevice) QemuParams(config *Config) []string {
// VhostUserDevice represents a qemu vhost-user device meant to be passed
// in to the guest
// nolint: govet
type VhostUserDevice struct {
SocketPath string //path to vhostuser socket on host
CharDevID string
@ -1567,6 +1563,7 @@ func (vhostuserDev VhostUserDevice) deviceName(config *Config) string {
}
// PCIeRootPortDevice represents a memory balloon device.
// nolint: govet
type PCIeRootPortDevice struct {
ID string // format: rp{n}, n>=0
@ -1747,6 +1744,7 @@ func (vfioDev VFIODevice) deviceName(config *Config) string {
}
// SCSIController represents a SCSI controller device.
// nolint: govet
type SCSIController struct {
ID string
@ -1843,6 +1841,7 @@ const (
)
// BridgeDevice represents a qemu bridge device like pci-bridge, pxb, etc.
// nolint: govet
type BridgeDevice struct {
// Type of the bridge
Type BridgeType
@ -1940,6 +1939,7 @@ func (bridgeDev BridgeDevice) QemuParams(config *Config) []string {
}
// VSOCKDevice represents a AF_VSOCK socket.
// nolint: govet
type VSOCKDevice struct {
ID string
@ -2036,6 +2036,7 @@ func (vsock VSOCKDevice) deviceName(config *Config) string {
}
// RngDevice represents a random number generator device.
// nolint: govet
type RngDevice struct {
// ID is the device ID
ID string
@ -2124,6 +2125,7 @@ func (v RngDevice) deviceName(config *Config) string {
}
// BalloonDevice represents a memory balloon device.
// nolint: govet
type BalloonDevice struct {
DeflateOnOOM bool
DisableModern bool
@ -2358,6 +2360,7 @@ type SMP struct {
}
// Memory is the guest memory configuration structure.
// nolint: govet
type Memory struct {
// Size is the amount of memory made available to the guest.
// It should be suffixed with M or G for sizes in megabytes or
@ -2505,6 +2508,7 @@ const (
)
// Incoming controls migration source preparation
// nolint: govet
type Incoming struct {
// Possible values are MigrationFD, MigrationExec
MigrationType int
@ -2516,6 +2520,7 @@ type Incoming struct {
// Config is the qemu configuration structure.
// It allows for passing custom settings and parameters to the qemu API.
// nolint: govet
type Config struct {
// Path is the qemu binary path.
Path string

View File

@ -1,21 +1,10 @@
//go:build !s390x
// +build !s390x
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu

View File

@ -1,20 +1,9 @@
// +build s390x
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu
@ -24,7 +13,7 @@ import "testing"
// See https://wiki.qemu.org/Documentation/Platforms/S390X
var (
deviceFSString = "-device virtio-9p-ccw,fsdev=workload9p,mount_tag=rootfs,devno=" + DevNo + " -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none,multidevs=remap"
deviceFSIOMMUString = "-device virtio-9p-ccw,fsdev=workload9p,mount_tag=rootfs,iommu_platform=on,devno=" + DevNo + " -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none,multidevs=remap"
deviceFSIOMMUString = "-device virtio-9p-ccw,fsdev=workload9p,mount_tag=rootfs,iommu_platform=on,devno=" + DevNo + " -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none,multidevs=remap" //nolint
deviceNetworkString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef,devno=" + DevNo
deviceNetworkStringMq = "-netdev tap,id=tap0,vhost=on,fds=3:4 -device driver=virtio-net-ccw,netdev=tap0,mac=01:02:de:ad:be:ef,mq=on,devno=" + DevNo
deviceSerialString = "-device virtio-serial-ccw,id=serial0,devno=" + DevNo
@ -34,6 +23,7 @@ var (
deviceSCSIControllerBusAddrStr = "-device virtio-scsi-ccw,id=foo,bus=pci.0,addr=00:04.0,iothread=iothread1,devno=" + DevNo
deviceBlockString = "-device virtio-blk-ccw,drive=hd0,scsi=off,config-wce=off,devno=" + DevNo + ",share-rw=on,serial=hd0 -drive id=hd0,file=/var/lib/vm.img,aio=threads,format=qcow2,if=none,readonly"
devicePCIBridgeString = "-device pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,chassis_nr=5,shpc=on,addr=ff"
devicePCIBridgeStringReserved = "-device pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,chassis_nr=5,shpc=on,addr=ff,io-reserve=4k,mem-reserve=1m,pref64-reserve=1m"
devicePCIEBridgeString = "-device pcie-pci-bridge,bus=/pci-bus/pcie.0,id=mybridge,addr=ff"
romfile = ""
)
@ -82,6 +72,8 @@ func TestAppendDeviceFSCCW(t *testing.T) {
}
func TestAppendDeviceFSCCWIOMMU(t *testing.T) {
t.Skip("Skipping on due to: https://github.com/kata-containers/kata-containers/issues/3500")
defaultKnobs := Knobs{
NoUserConfig: true,
IOMMUPlatform: true,

View File

@ -1,18 +1,7 @@
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu
@ -21,6 +10,7 @@ import (
"io/ioutil"
"os"
"reflect"
"runtime"
"strings"
"testing"
)
@ -342,6 +332,10 @@ func TestAppendDeviceSerialPort(t *testing.T) {
}
func TestAppendDeviceBlock(t *testing.T) {
if runtime.GOARCH == "s390x" {
t.Skip("Skipping on s390x due to: https://github.com/kata-containers/kata-containers/issues/3500")
}
blkdev := BlockDevice{
Driver: VirtioBlock,
ID: "hd0",
@ -522,6 +516,9 @@ func TestAppendPCIBridgeDevice(t *testing.T) {
}
func TestAppendPCIBridgeDeviceWithReservations(t *testing.T) {
if runtime.GOARCH == "s390x" {
t.Skip("Skipping on s390x due to: https://github.com/kata-containers/kata-containers/issues/3500")
}
bridge := BridgeDevice{
Type: PCIBridge,

View File

@ -1,18 +1,7 @@
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu
@ -96,6 +85,7 @@ type qmpEventFilter struct {
}
// QMPEvent contains a single QMP event, sent on the QMPConfig.EventCh channel.
// nolint: govet
type QMPEvent struct {
// The name of the event, e.g., DEVICE_DELETED
Name string
@ -118,6 +108,7 @@ type qmpResult struct {
err error
}
// nolint: govet
type qmpCommand struct {
ctx context.Context
res chan qmpResult
@ -130,6 +121,7 @@ type qmpCommand struct {
// QMP is a structure that contains the internal state used by startQMPLoop and
// the go routines it spwans. All the contents of this structure are private.
// nolint: govet
type QMP struct {
cmdCh chan qmpCommand
conn io.ReadWriteCloser
@ -141,6 +133,7 @@ type QMP struct {
// QMPVersion contains the version number and the capabailities of a QEMU
// instance, as reported in the QMP greeting message.
// nolint: govet
type QMPVersion struct {
Major int
Minor int
@ -158,6 +151,7 @@ type CPUProperties struct {
}
// HotpluggableCPU represents a hotpluggable CPU
// nolint: govet
type HotpluggableCPU struct {
Type string `json:"type"`
VcpusCount int `json:"vcpus-count"`
@ -166,6 +160,7 @@ type HotpluggableCPU struct {
}
// MemoryDevicesData cotains the data describes a memory device
// nolint: govet
type MemoryDevicesData struct {
Slot int `json:"slot"`
Node int `json:"node"`
@ -178,12 +173,14 @@ type MemoryDevicesData struct {
}
// MemoryDevices represents memory devices of vm
// nolint: govet
type MemoryDevices struct {
Data MemoryDevicesData `json:"data"`
Type string `json:"type"`
}
// CPUInfo represents information about each virtual CPU
// nolint: govet
type CPUInfo struct {
CPU int `json:"CPU"`
Current bool `json:"current"`
@ -196,6 +193,7 @@ type CPUInfo struct {
}
// CPUInfoFast represents information about each virtual CPU
// nolint: govet
type CPUInfoFast struct {
CPUIndex int `json:"cpu-index"`
QomPath string `json:"qom-path"`
@ -252,6 +250,7 @@ type SchemaInfo struct {
}
// StatusInfo represents guest running status
// nolint: govet
type StatusInfo struct {
Running bool `json:"running"`
SingleStep bool `json:"singlestep"`

View File

@ -1,18 +1,7 @@
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// SPDX-License-Identifier: Apache-2.0
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu
@ -61,11 +50,13 @@ func (l qmpTestLogger) Errorf(format string, v ...interface{}) {
l.Infof(format, v...)
}
// nolint: govet
type qmpTestCommand struct {
name string
args map[string]interface{}
}
// nolint: govet
type qmpTestEvent struct {
name string
data map[string]interface{}
@ -73,11 +64,13 @@ type qmpTestEvent struct {
after time.Duration
}
// nolint: govet
type qmpTestResult struct {
result string
data interface{}
}
// nolint: govet
type qmpTestCommandBuffer struct {
newDataCh chan []byte
t *testing.T

View File

@ -15,7 +15,7 @@ import (
"strings"
"github.com/BurntSushi/toml"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
"github.com/kata-containers/kata-containers/src/runtime/pkg/oci"
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,77 +0,0 @@
/*
// Copyright contributors to the Virtual Machine Manager for Go project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/
package qemu
import (
"context"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
"syscall"
)
// CreateCloudInitISO creates a cloud-init ConfigDrive ISO image. This is
// useful for configuring newly booted VMs. Before it can create the ISO
// image it needs to create a file tree with the various files that will
// make up the image. This directory is created under scratchDir and is
// deleted when when the function returns, successfully or otherwise. ctx is
// a context that can be used to timeout or cancel the image creation.
// isoPath contains the desired path of the ISO image to be created. The
// userdata and metadata parameters are byte slices that contain the
// ConfigDrive userdata and metadata that will be stored with the ISO image.
// The attrs parameter can be used to control aspects of the newly created
// qemu process, such as the user and group under which it runs. It may be nil.
func CreateCloudInitISO(ctx context.Context, scratchDir, isoPath string,
userData, metaData []byte, attr *syscall.SysProcAttr) error {
configDrivePath := path.Join(scratchDir, "clr-cloud-init")
dataDirPath := path.Join(configDrivePath, "openstack", "latest")
metaDataPath := path.Join(dataDirPath, "meta_data.json")
userDataPath := path.Join(dataDirPath, "user_data")
defer func() {
/* #nosec */
_ = os.RemoveAll(configDrivePath)
}()
err := os.MkdirAll(dataDirPath, 0750)
if err != nil {
return fmt.Errorf("unable to create config drive directory %s : %v",
dataDirPath, err)
}
err = ioutil.WriteFile(metaDataPath, metaData, 0644)
if err != nil {
return fmt.Errorf("unable to create %s : %v", metaDataPath, err)
}
err = ioutil.WriteFile(userDataPath, userData, 0644)
if err != nil {
return fmt.Errorf("unable to create %s : %v", userDataPath, err)
}
cmd := exec.CommandContext(ctx, "xorriso", "-as", "mkisofs", "-R", "-V", "config-2",
"-o", isoPath, configDrivePath)
cmd.SysProcAttr = attr
err = cmd.Run()
if err != nil {
return fmt.Errorf("unable to create cloudinit iso image %v", err)
}
return nil
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -206,9 +206,6 @@ github.com/hashicorp/go-multierror
github.com/intel-go/cpuid
# github.com/josharian/intern v1.0.0
github.com/josharian/intern
# github.com/kata-containers/govmm v0.0.0-20220117131932-0781a21804ee
## explicit
github.com/kata-containers/govmm/qemu
# github.com/mailru/easyjson v0.7.6
github.com/mailru/easyjson/buffer
github.com/mailru/easyjson/jlexer

View File

@ -24,7 +24,7 @@ import (
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/rootless"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

View File

@ -14,7 +14,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/intel-go/cpuid"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
)
type qemuAmd64 struct {

View File

@ -12,7 +12,7 @@ import (
"testing"
"github.com/intel-go/cpuid"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/stretchr/testify/assert"
)

View File

@ -14,7 +14,7 @@ import (
"runtime"
"strings"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"

View File

@ -13,7 +13,7 @@ import (
"path/filepath"
"testing"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/stretchr/testify/assert"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"

View File

@ -12,7 +12,7 @@ import (
"runtime"
"time"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
)

View File

@ -11,7 +11,7 @@ import (
"os"
"testing"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/stretchr/testify/assert"
)

View File

@ -9,7 +9,7 @@ import (
"fmt"
"time"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/sirupsen/logrus"
)

View File

@ -9,7 +9,7 @@ import (
"fmt"
"testing"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/stretchr/testify/assert"
)

View File

@ -10,7 +10,7 @@ import (
"fmt"
"time"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/utils"

View File

@ -10,7 +10,7 @@ import (
"fmt"
"testing"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/stretchr/testify/assert"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"

View File

@ -12,7 +12,7 @@ import (
"path/filepath"
"testing"
govmmQemu "github.com/kata-containers/govmm/qemu"
govmmQemu "github.com/kata-containers/kata-containers/src/runtime/pkg/govmm/qemu"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"