Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/cloud/libvirt/client/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ func newDomainDef() libvirtxml.Domain {
return domainDef
}

// clearX86OnlyDomainFeaturesForArch removes PAE/ACPI/APIC features for
// architectures where libvirt does not support them. newDomainDef() always
// sets x86-style features; s390x guests use virtio-ccw / SCLP, and machine
// types such as s390-ccw-virtio-rhel9.6.0 on RHEL 9 + QEMU 9 reject
// <acpi/> with virError 67 (does not support ACPI).
func clearX86OnlyDomainFeaturesForArch(d *libvirtxml.Domain) {
if d == nil || d.OS == nil || d.OS.Type == nil {
return
}
if strings.HasPrefix(d.OS.Type.Arch, "s390") {
d.Features = nil
}
}

func newDevicesDef() *libvirtxml.DomainDeviceList {
domainList := libvirtxml.DomainDeviceList{
Channels: []libvirtxml.DomainChannel{
Expand Down Expand Up @@ -201,6 +215,9 @@ func newDomainDefForConnection(virConn *libvirt.Connect) (libvirtxml.Domain, err
return d, err
}
d.OS.Type.Machine = canonicalmachine

clearX86OnlyDomainFeaturesForArch(&d)

return d, nil
}

Expand Down
22 changes: 22 additions & 0 deletions pkg/cloud/libvirt/client/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ import (
libvirtxml "github.com/libvirt/libvirt-go-xml"
)

func TestClearX86OnlyDomainFeaturesForArchS390x(t *testing.T) {
d := newDomainDef()
if d.Features == nil || d.Features.ACPI == nil {
t.Fatal("newDomainDef should set x86-style features including ACPI")
}
d.OS.Type.Arch = "s390x"
clearX86OnlyDomainFeaturesForArch(&d)
if d.Features != nil {
t.Fatalf("s390x: expected Features=nil, got %#v", d.Features)
}
}

func TestClearX86OnlyDomainFeaturesForArchAmd64(t *testing.T) {
d := newDomainDef()
orig := d.Features
d.OS.Type.Arch = "x86_64"
clearX86OnlyDomainFeaturesForArch(&d)
if d.Features != orig {
t.Fatal("x86_64: Features should be unchanged")
}
}

func TestSetCoreOSIgnition(t *testing.T) {
testCases := []struct {
ignKey string
Expand Down