-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #37566 - Add UEFI Secure Boot Firmware to Libvirt #10321
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,9 @@ def new_vm(attr = { }) | |
opts[:boot_order] = %w[hd] | ||
opts[:boot_order].unshift 'network' unless attr[:image_id] | ||
|
||
firmware_type = opts.delete(:firmware_type).to_s | ||
opts.merge!(process_firmware_attributes(opts[:firmware], firmware_type)) | ||
|
||
vm = client.servers.new opts | ||
vm.memory = opts[:memory] if opts[:memory] | ||
vm | ||
|
@@ -289,7 +292,9 @@ def vm_instance_defaults | |
:display => { :type => display_type, | ||
:listen => Setting[:libvirt_default_console_address], | ||
:password => random_password(console_password_length(display_type)), | ||
:port => '-1' } | ||
:port => '-1' }, | ||
:firmware => 'automatic', | ||
:firmware_features => { "secure-boot" => "no" } | ||
) | ||
end | ||
|
||
|
@@ -326,5 +331,20 @@ def validate_volume_capacity(vol) | |
raise Foreman::Exception.new(N_("Please specify volume size. You may optionally use suffix 'G' to specify volume size in gigabytes.")) | ||
end | ||
end | ||
|
||
# Generates Secure Boot settings for Libvirt based on the provided firmware type. | ||
# The `secure_boot` setting is used to properly configure and display the Firmware in the `compute_attributes` form. | ||
# | ||
# @param firmware [String] The firmware type. | ||
# @return [Hash] A hash with secure boot settings if applicable. | ||
def generate_secure_boot_settings(firmware) | ||
return {} unless firmware == 'uefi_secure_boot' | ||
|
||
{ | ||
firmware_features: { 'secure-boot' => 'yes', 'enrolled-keys' => 'yes' }, | ||
loader_attributes: { 'secure' => 'yes' }, | ||
secure_boot: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For other keys and values, you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
group :libvirt do | ||
gem 'fog-libvirt', '>= 0.12.0' | ||
gem 'fog-libvirt', '>= 0.13.0' | ||
gem 'ruby-libvirt', '~> 0.5', :require => 'libvirt' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for having strings as keys in the inner hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the reason for using strings as keys here is that Libvirt expects these values in this format and converts them to XML accordingly. You can see this conversion in the Libvirt code here. For more details, refer to the related PR.