Skip to content
Merged
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
9 changes: 2 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ require (
github.com/golang/mock v1.2.0
github.com/golang/protobuf v1.4.2 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/libvirt/libvirt-go v4.10.0+incompatible
github.com/libvirt/libvirt-go-xml v4.10.0+incompatible
github.com/libvirt/libvirt-go v5.10.0+incompatible
github.com/libvirt/libvirt-go-xml v5.10.0+incompatible
github.com/openshift/machine-api-operator v0.2.1-0.20200513150041-09efe6c914b4
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/cobra v1.0.0 // indirect
Expand All @@ -35,8 +35,3 @@ require (
k8s.io/utils v0.0.0-20200414100711-2df71ebbae66 // indirect
sigs.k8s.io/controller-runtime v0.5.1-0.20200330174416-a11a908d91e0
)

replace (
github.com/libvirt/libvirt-go => github.com/libvirt/libvirt-go v4.6.0+incompatible
github.com/libvirt/libvirt-go-xml => github.com/libvirt/libvirt-go-xml v4.6.0+incompatible
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kubernetes-sigs/kube-storage-version-migrator v0.0.0-20191127225502-51849bc15f17/go.mod h1:enH0BVV+4+DAgWdwSlMefG8bBzTfVMTr1lApzdLZ/cc=
github.com/libvirt/libvirt-go v4.6.0+incompatible h1:7OenwWTPRPSYIkJMMSX9loYLBBOaGdOjxZHTkXSe67E=
github.com/libvirt/libvirt-go v4.6.0+incompatible/go.mod h1:34zsnB4iGeOv7Byj6qotuW8Ya4v4Tr43ttjz/F0wjLE=
github.com/libvirt/libvirt-go-xml v4.6.0+incompatible h1:dL2JDzkEtsiZkPh42KHvLt208wgNfO40IsBjHtaXohs=
github.com/libvirt/libvirt-go-xml v4.6.0+incompatible/go.mod h1:oBlgD3xOA01ihiK5stbhFzvieyW+jVS6kbbsMVF623A=
github.com/libvirt/libvirt-go v5.10.0+incompatible h1:01fwkdUHH2hk4YyFNCr48OvSGqXYLzp9cofUpeyeLNc=
github.com/libvirt/libvirt-go v5.10.0+incompatible/go.mod h1:34zsnB4iGeOv7Byj6qotuW8Ya4v4Tr43ttjz/F0wjLE=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's required to bump libvirt-go, only libvirt-go-xml should be needed? If you bump the libvirt-go dependency, this can cause unexpected failures to run the installer (if you build on a system where libvirt 5.10 is installed and you then try to run it on a system with libvirt 4.6 installed). I'd prefer to keep the libvirt-go dependency unchanged if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed libvirt-go and libvirt-go-xml to match that of the openshift installer. I thought it would be good to keep both in sync? in any case the installer uses the same versions so should be fine ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the installer upgraded to a newer version indirectly (it updated another module which needed a newer version). This caused issues fwiw openshift/installer#4339
Since we already bit the bullet with the installer, we can try changing it here as well :)

github.com/libvirt/libvirt-go-xml v5.10.0+incompatible h1:kcgVynR4a9cuh/kc7Ywl8XRBUxbqe05seR2qgN+yTno=
github.com/libvirt/libvirt-go-xml v5.10.0+incompatible/go.mod h1:oBlgD3xOA01ihiK5stbhFzvieyW+jVS6kbbsMVF623A=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
Expand Down
12 changes: 6 additions & 6 deletions pkg/cloud/libvirt/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ func (client *libvirtClient) CreateDomain(ctx context.Context, input CreateDomai
return fmt.Errorf("Failed to newDomainDefForConnection: %s", err)
}

arch, err := getHostArchitecture(client.connection)
if err != nil {
return fmt.Errorf("Error retrieving host architecture: %s", err)
}

// Get values from machineProviderConfig
if err := domainDefInit(&domainDef, input.DomainName, input.DomainMemory, input.DomainVcpu); err != nil {
if err := domainDefInit(&domainDef, &input, arch); err != nil {
return fmt.Errorf("Failed to init domain definition from machineProviderConfig: %v", err)
}

Expand All @@ -203,11 +208,6 @@ func (client *libvirtClient) CreateDomain(ctx context.Context, input CreateDomai

glog.Info("Create ignition configuration")

arch, err := getHostArchitecture(client.connection)
if err != nil {
return fmt.Errorf("Error retrieving host architecture: %s", err)
}

if input.Ignition != nil {
if err := setIgnition(ctx, &domainDef, client, input.Ignition, input.KubeClient, input.MachineNamespace, input.IgnitionVolumeName, arch); err != nil {
return err
Expand Down
24 changes: 16 additions & 8 deletions pkg/cloud/libvirt/client/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,35 +460,43 @@ type Config struct {
URI string
}

func domainDefInit(domainDef *libvirtxml.Domain, name string, memory, vcpu int) error {
if name != "" {
domainDef.Name = name
func setFirmware(input *CreateDomainInput, domainDef *libvirtxml.Domain, arch string) {
// for aarch64 speciffying this will automatically select the firmware and NVRAM file
// reference: https://libvirt.org/formatdomain.html#bios-bootloader
if arch == "aarch64" {
domainDef.OS.Firmware = "efi"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with hardcoding this for aarch64, but do we want to expose this through the machine provider api so it can be set through the installer and this code can be arch agnostic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok..on second thought .. probably not...this is a basic property of aarch64...better to leave it as is and keep things simple

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must not be so basic, otherwise it would be the libvirt default ;) I agree with leaving this as is for now, as I don't think cluster-api-provider-libvirt should support arbitrary VM configurations. This is one case where it should be able to pick up the correct value needed by openshift. For x86_64, the efi switch would happen when we start using the q35 machine type.

}

func domainDefInit(domainDef *libvirtxml.Domain, input *CreateDomainInput, arch string) error {
if input.DomainName != "" {
domainDef.Name = input.DomainName
} else {
return fmt.Errorf("machine does not have an name set")
}

if memory != 0 {
if input.DomainMemory != 0 {
domainDef.Memory = &libvirtxml.DomainMemory{
Value: uint(memory),
Value: uint(input.DomainMemory),
Unit: "MiB",
}
} else {
return fmt.Errorf("machine does not have an DomainMemory set")
}

if vcpu != 0 {
if input.DomainVcpu != 0 {
domainDef.VCPU = &libvirtxml.DomainVCPU{
Value: vcpu,
Value: input.DomainVcpu,
}
} else {
return fmt.Errorf("machine does not have an DomainVcpu set")
}

domainDef.CPU.Mode = "host-passthrough"
setFirmware(input, domainDef, arch)

//setConsoles(d, &domainDef)
//setCmdlineArgs(d, &domainDef)
//setFirmware(d, &domainDef)
//setBootDevices(d, &domainDef)

return nil
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading