mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 13:29:31 +00:00
Merge pull request #1954 from marcel-apf/remove-pc
Remove the pc machine
This commit is contained in:
@@ -708,7 +708,7 @@ func (q *qemu) getMemArgs() (bool, string, string, error) {
|
||||
return share, target, memoryBack, nil
|
||||
}
|
||||
|
||||
func (q *qemu) setupVirtioMem() error {
|
||||
func (q *qemu) setupVirtioMem(ctx context.Context) error {
|
||||
maxMem, err := q.hostMemMB()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -724,7 +724,19 @@ func (q *qemu) setupVirtioMem() error {
|
||||
if err = q.qmpSetup(); err != nil {
|
||||
return err
|
||||
}
|
||||
err = q.qmpMonitorCh.qmp.ExecMemdevAdd(q.qmpMonitorCh.ctx, memoryBack, "virtiomem", target, sizeMB, share, "virtio-mem-pci", "virtiomem0")
|
||||
|
||||
addr, bridge, err := q.arch.addDeviceToBridge(ctx, "virtiomem-dev", types.PCI)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
q.arch.removeDeviceFromBridge("virtiomem-dev")
|
||||
}
|
||||
}()
|
||||
|
||||
err = q.qmpMonitorCh.qmp.ExecMemdevAdd(q.qmpMonitorCh.ctx, memoryBack, "virtiomem", target, sizeMB, share, "virtio-mem-pci", "virtiomem0", addr, bridge.ID)
|
||||
if err == nil {
|
||||
q.config.VirtioMem = true
|
||||
q.Logger().Infof("Setup %dMB virtio-mem-pci success", sizeMB)
|
||||
@@ -832,7 +844,7 @@ func (q *qemu) startSandbox(ctx context.Context, timeout int) error {
|
||||
}
|
||||
|
||||
if q.config.VirtioMem {
|
||||
err = q.setupVirtioMem()
|
||||
err = q.setupVirtioMem(ctx)
|
||||
}
|
||||
|
||||
return err
|
||||
@@ -2095,8 +2107,6 @@ func genericBridges(number uint32, machineType string) []types.Bridge {
|
||||
case QemuQ35:
|
||||
// currently only pci bridges are supported
|
||||
// qemu-2.10 will introduce pcie bridges
|
||||
fallthrough
|
||||
case QemuPC:
|
||||
bt = types.PCI
|
||||
case QemuVirt:
|
||||
bt = types.PCI
|
||||
|
@@ -29,7 +29,7 @@ type qemuAmd64 struct {
|
||||
const (
|
||||
defaultQemuPath = "/usr/bin/qemu-system-x86_64"
|
||||
|
||||
defaultQemuMachineType = QemuPC
|
||||
defaultQemuMachineType = QemuQ35
|
||||
|
||||
defaultQemuMachineOptions = "accel=kvm,kernel_irqchip"
|
||||
|
||||
@@ -44,7 +44,6 @@ const (
|
||||
|
||||
var qemuPaths = map[string]string{
|
||||
QemuPCLite: "/usr/bin/qemu-lite-system-x86_64",
|
||||
QemuPC: defaultQemuPath,
|
||||
QemuQ35: defaultQemuPath,
|
||||
QemuMicrovm: defaultQemuPath,
|
||||
}
|
||||
@@ -71,10 +70,6 @@ var supportedQemuMachines = []govmmQemu.Machine{
|
||||
Type: QemuPCLite,
|
||||
Options: defaultQemuMachineOptions,
|
||||
},
|
||||
{
|
||||
Type: QemuPC,
|
||||
Options: defaultQemuMachineOptions,
|
||||
},
|
||||
{
|
||||
Type: QemuQ35,
|
||||
Options: defaultQemuMachineOptions,
|
||||
@@ -158,8 +153,7 @@ func newQemuArch(config HypervisorConfig) (qemuArch, error) {
|
||||
func (q *qemuAmd64) capabilities() types.Capabilities {
|
||||
var caps types.Capabilities
|
||||
|
||||
if q.qemuMachine.Type == QemuPC ||
|
||||
q.qemuMachine.Type == QemuQ35 ||
|
||||
if q.qemuMachine.Type == QemuQ35 ||
|
||||
q.qemuMachine.Type == QemuVirt {
|
||||
caps.SetBlockDeviceHotplugSupport()
|
||||
}
|
||||
|
@@ -42,14 +42,10 @@ func TestQemuAmd64BadMachineType(t *testing.T) {
|
||||
func TestQemuAmd64Capabilities(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
amd64 := newTestQemu(assert, QemuPC)
|
||||
amd64 := newTestQemu(assert, QemuQ35)
|
||||
caps := amd64.capabilities()
|
||||
assert.True(caps.IsBlockDeviceHotplugSupported())
|
||||
|
||||
amd64 = newTestQemu(assert, QemuQ35)
|
||||
caps = amd64.capabilities()
|
||||
assert.True(caps.IsBlockDeviceHotplugSupported())
|
||||
|
||||
amd64 = newTestQemu(assert, QemuMicrovm)
|
||||
caps = amd64.capabilities()
|
||||
assert.False(caps.IsBlockDeviceHotplugSupported())
|
||||
@@ -57,23 +53,11 @@ func TestQemuAmd64Capabilities(t *testing.T) {
|
||||
|
||||
func TestQemuAmd64Bridges(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
amd64 := newTestQemu(assert, QemuPC)
|
||||
len := 5
|
||||
|
||||
amd64 := newTestQemu(assert, QemuMicrovm)
|
||||
amd64.bridges(uint32(len))
|
||||
bridges := amd64.getBridges()
|
||||
assert.Len(bridges, len)
|
||||
|
||||
for i, b := range bridges {
|
||||
id := fmt.Sprintf("%s-bridge-%d", types.PCI, i)
|
||||
assert.Equal(types.PCI, b.Type)
|
||||
assert.Equal(id, b.ID)
|
||||
assert.NotNil(b.Devices)
|
||||
}
|
||||
|
||||
amd64 = newTestQemu(assert, QemuMicrovm)
|
||||
amd64.bridges(uint32(len))
|
||||
bridges = amd64.getBridges()
|
||||
assert.Nil(bridges)
|
||||
|
||||
amd64 = newTestQemu(assert, QemuQ35)
|
||||
@@ -91,7 +75,7 @@ func TestQemuAmd64Bridges(t *testing.T) {
|
||||
|
||||
func TestQemuAmd64CPUModel(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
amd64 := newTestQemu(assert, QemuPC)
|
||||
amd64 := newTestQemu(assert, QemuQ35)
|
||||
|
||||
expectedOut := defaultCPUModel
|
||||
model := amd64.cpuModel()
|
||||
@@ -108,7 +92,7 @@ func TestQemuAmd64CPUModel(t *testing.T) {
|
||||
|
||||
func TestQemuAmd64MemoryTopology(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
amd64 := newTestQemu(assert, QemuPC)
|
||||
amd64 := newTestQemu(assert, QemuQ35)
|
||||
memoryOffset := uint64(1024)
|
||||
|
||||
hostMem := uint64(100)
|
||||
@@ -139,7 +123,7 @@ func TestQemuAmd64AppendImage(t *testing.T) {
|
||||
machinesCopy := make([]govmmQemu.Machine, len(supportedQemuMachines))
|
||||
assert.Equal(len(supportedQemuMachines), copy(machinesCopy, supportedQemuMachines))
|
||||
|
||||
cfg := qemuConfig(QemuPC)
|
||||
cfg := qemuConfig(QemuQ35)
|
||||
cfg.ImagePath = f.Name()
|
||||
cfg.DisableImageNvdimm = false
|
||||
amd64, err := newQemuArch(cfg)
|
||||
@@ -189,41 +173,18 @@ func TestQemuAmd64AppendBridges(t *testing.T) {
|
||||
var devices []govmmQemu.Device
|
||||
assert := assert.New(t)
|
||||
|
||||
// check PC
|
||||
amd64 := newTestQemu(assert, QemuPC)
|
||||
// Check Q35
|
||||
amd64 := newTestQemu(assert, QemuQ35)
|
||||
|
||||
amd64.bridges(1)
|
||||
bridges := amd64.getBridges()
|
||||
assert.Len(bridges, 1)
|
||||
|
||||
devices = amd64.appendBridges(devices)
|
||||
assert.Len(devices, 1)
|
||||
|
||||
expectedOut := []govmmQemu.Device{
|
||||
govmmQemu.BridgeDevice{
|
||||
Type: govmmQemu.PCIBridge,
|
||||
Bus: defaultPCBridgeBus,
|
||||
ID: bridges[0].ID,
|
||||
Chassis: 1,
|
||||
SHPC: true,
|
||||
Addr: "2",
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(expectedOut, devices)
|
||||
|
||||
// Check Q35
|
||||
amd64 = newTestQemu(assert, QemuQ35)
|
||||
|
||||
amd64.bridges(1)
|
||||
bridges = amd64.getBridges()
|
||||
assert.Len(bridges, 1)
|
||||
|
||||
devices = []govmmQemu.Device{}
|
||||
devices = amd64.appendBridges(devices)
|
||||
assert.Len(devices, 1)
|
||||
|
||||
expectedOut = []govmmQemu.Device{
|
||||
expectedOut := []govmmQemu.Device{
|
||||
govmmQemu.BridgeDevice{
|
||||
Type: govmmQemu.PCIBridge,
|
||||
Bus: defaultBridgeBus,
|
||||
@@ -240,7 +201,7 @@ func TestQemuAmd64AppendBridges(t *testing.T) {
|
||||
func TestQemuAmd64WithInitrd(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cfg := qemuConfig(QemuPC)
|
||||
cfg := qemuConfig(QemuQ35)
|
||||
cfg.InitrdPath = "dummy-initrd"
|
||||
amd64, err := newQemuArch(cfg)
|
||||
assert.NoError(err)
|
||||
@@ -282,7 +243,7 @@ func TestQemuAmd64AppendProtectionDevice(t *testing.T) {
|
||||
var devices []govmmQemu.Device
|
||||
assert := assert.New(t)
|
||||
|
||||
amd64 := newTestQemu(assert, QemuPC)
|
||||
amd64 := newTestQemu(assert, QemuQ35)
|
||||
|
||||
id := amd64.(*qemuAmd64).devLoadersCount
|
||||
firmware := "tdvf.fd"
|
||||
|
@@ -212,9 +212,6 @@ const (
|
||||
// QemuPCLite is the QEMU pc-lite machine type for amd64
|
||||
QemuPCLite = "pc-lite"
|
||||
|
||||
// QemuPC is the QEMU pc machine type for amd64
|
||||
QemuPC = "pc"
|
||||
|
||||
// QemuQ35 is the QEMU Q35 machine type for amd64
|
||||
QemuQ35 = "q35"
|
||||
|
||||
|
@@ -28,7 +28,7 @@ const (
|
||||
)
|
||||
|
||||
var qemuArchBaseMachine = govmmQemu.Machine{
|
||||
Type: "pc",
|
||||
Type: "q35",
|
||||
}
|
||||
|
||||
var qemuArchBaseQemuPaths = map[string]string{
|
||||
@@ -143,7 +143,7 @@ func TestQemuAddDeviceToBridge(t *testing.T) {
|
||||
|
||||
// addDeviceToBridge successfully
|
||||
q := newQemuArchBase()
|
||||
q.qemuMachine.Type = QemuPC
|
||||
q.qemuMachine.Type = QemuQ35
|
||||
|
||||
q.bridges(1)
|
||||
for i := uint32(1); i <= types.PCIBridgeMaxCapacity; i++ {
|
||||
@@ -559,10 +559,6 @@ func TestQemuArchBaseAppendIOMMU(t *testing.T) {
|
||||
CachingMode: true,
|
||||
},
|
||||
}
|
||||
// Test IOMMU is not appended to PC machine type
|
||||
qemuArchBase.qemuMachine.Type = QemuPC
|
||||
devices, err = qemuArchBase.appendIOMMU(devices)
|
||||
assert.Error(err)
|
||||
|
||||
qemuArchBase.qemuMachine.Type = QemuQ35
|
||||
devices, err = qemuArchBase.appendIOMMU(devices)
|
||||
|
@@ -362,7 +362,7 @@ func TestQemuQemuPath(t *testing.T) {
|
||||
qemuConfig.HypervisorPath = expectedPath
|
||||
qkvm := &qemuArchBase{
|
||||
qemuMachine: govmmQemu.Machine{
|
||||
Type: "pc",
|
||||
Type: "q35",
|
||||
Options: "",
|
||||
},
|
||||
qemuExePath: expectedPath,
|
||||
|
Reference in New Issue
Block a user