Skip to content

Commit

Permalink
consume libvirt's host bundled UEFI bios by default
Browse files Browse the repository at this point in the history
Signed-off-by: António Meireles <antonio.meireles@reformi.st>
  • Loading branch information
AntonioMeireles committed Apr 19, 2019
1 parent 6291aee commit 005fcec
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ define buildBaseImg
endef

define imgToVMDK
qemu-img convert -p -C -t none -T none media/$(OSV)-$1-factory.img -O vmdk media/$(OSV)-$1-factory.vmdk
qemu-img convert -p -C media/$(OSV)-$1-factory.img -O vmdk media/$(OSV)-$1-factory.vmdk
endef

define vmxBuilder
Expand Down Expand Up @@ -141,10 +141,6 @@ help:
@echo "To target a specific one add 'VERSION=...' to your make invocation"
@echo

media/OVMF.fd:
@mkdir -p media
@curl -sSL $(CLR_BASE_URL)/image/OVMF.fd -o media/OVMF.fd

$(foreach T,$(PROVIDERS),$(eval $(IMGtarget)))

$(foreach T,$(PROVIDERS),$(eval $(VMDKtarget)))
Expand All @@ -171,7 +167,7 @@ all: $(PROVIDERS) ## Packer Builds All providers boxes

$(foreach T,$(PROVIDERS),$(eval $(PROVIDERtarget)))

boxes/libvirt/$(NV).libvirt.box: $(call mediaFactory,libvirt).img media/OVMF.fd
boxes/libvirt/$(NV).libvirt.box: $(call mediaFactory,libvirt).img
$(call pack,libvirt)

boxes/virtualbox/$(NV).virtualbox.box: $(call mediaFactory,virtualbox)/$(NV).ova
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ vagrant up
config.vm.provision :set_timezone, timezone: 'Asia/Dili'
```

- The boxes expect the UEFI bios to be found on the host filesystem, where libvirt sits, at
`/usr/share/qemu/OVMF.fd` which is its canonical location on major OSs.

If you are consuming the boxes over a OS that has `OVMF.fd` placed elsewhere please adapt your
`Vagrantfile` accordingly:

```ruby
config.vm.provider :libvirt do |libvirt, override|
libvirt.loader = '/NON_DEFAULT_LOCATION/OVMF.fd'
end
```

## Vagrant Cloud

This project Vagrant boxes are hosted on **Vagrant Cloud** at
Expand Down
6 changes: 3 additions & 3 deletions Vagrantfile.template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
].each do |plugin|
next if Vagrant.has_plugin?(plugin[:name], plugin[:version])

verb = 'install'
verb = 'update' if Vagrant.has_plugin?(plugin[:name])
verb = Vagrant.has_plugin?(plugin[:name]) ? 'update' : 'install'
system("vagrant plugin #{verb} #{plugin[:name]}", chdir: '/tmp') || exit!
need_restart = true
end
Expand Down Expand Up @@ -67,7 +66,8 @@
end
end
config.vm.provider 'libvirt' do |libvirt|
libvirt.loader = File.join(File.dirname(__FILE__), 'OVMF.fd')
# XXX: this is the default location in ClearLinux and Debian
libvirt.loader = "/usr/share/qemu/OVMF.fd"
libvirt.driver = 'kvm'
libvirt.cpu_mode = 'host-passthrough'
libvirt.nested = true
Expand Down
1 change: 0 additions & 1 deletion extras/test/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Vagrant.configure(2) do |config|
libvirt.username = username
libvirt.socket = '/var/run/libvirt/libvirt-sock'
libvirt.storage_pool_path = '/home/clear/.local/share/libvirt/images'
libvirt.loader = '/usr/share/qemu/OVMF.fd'
override.ssh.forward_agent = true
override.ssh.proxy_command = "ssh -q -W %h:%p -l #{username} -x #{host}"
end
Expand Down
5 changes: 2 additions & 3 deletions packer.conf.libvirt.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"qemuargs": [
[
"-bios",
"media/OVMF.fd"
"/usr/share/qemu/OVMF.fd"
]
],
"iso_checksum_type": "none",
Expand Down Expand Up @@ -67,8 +67,7 @@
"compression_level": 9,
"vagrantfile_template": "Vagrantfile.template.rb",
"include": [
"info.json",
"media/OVMF.fd"
"info.json"
]
}
]
Expand Down

2 comments on commit 005fcec

@electrocucaracha
Copy link

Choose a reason for hiding this comment

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

@AntonioMeireles what are the proper permissions of this OVMF.fd file, this change is affecting my tests.

$ vagrant up
Bringing machine 'default' up with 'libvirt' provider...
==> default: Box 'AntonioMeireles/ClearLinux' could not be found. Attempting to find and install...
    default: Box Provider: libvirt
    default: Box Version: 28600
==> default: Loading metadata for box 'AntonioMeireles/ClearLinux'
    default: URL: https://vagrantcloud.com/AntonioMeireles/ClearLinux
==> default: Adding box 'AntonioMeireles/ClearLinux' (v28600) for provider: libvirt
    default: Downloading: https://vagrantcloud.com/AntonioMeireles/boxes/ClearLinux/versions/28600/providers/libvirt.box
    default: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
==> default: Successfully added box 'AntonioMeireles/ClearLinux' (v28600) for 'libvirt'!
==> default: Uploading base box image as volume into libvirt storage...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
==> default:  -- Name:              vjmorale_default_1557771034_01bfda1ad817732c7d0d
==> default:  -- Domain type:       kvm
==> default:  -- Cpus:              2
==> default:  -- Feature:           acpi
==> default:  -- Feature:           apic
==> default:  -- Feature:           pae
==> default:  -- Memory:            2048M
==> default:  -- Management MAC:    
==> default:  -- Loader:            /usr/share/qemu/OVMF.fd
==> default:  -- Nvram:             
==> default:  -- Base box:          AntonioMeireles/ClearLinux
==> default:  -- Storage pool:      default
==> default:  -- Image:             /var/lib/libvirt/images/vjmorale_default_1557771034_01bfda1ad817732c7d0d.img (40G)
==> default:  -- Volume Cache:      default
==> default:  -- Kernel:            
==> default:  -- Initrd:            
==> default:  -- Graphics Type:     vnc
==> default:  -- Graphics Port:     -1
==> default:  -- Graphics IP:       127.0.0.1
==> default:  -- Graphics Password: Not defined
==> default:  -- Video Type:        cirrus
==> default:  -- Video VRAM:        256
==> default:  -- Sound Type:
==> default:  -- Keymap:            en-us
==> default:  -- TPM Path:          
==> default:  -- INPUT:             type=mouse, bus=ps2
==> default:  -- CHANNEL:             type=unix, mode=
==> default:  -- CHANNEL:             target_type=virtio, target_name=org.qemu.guest_agent.0
==> default: Creating shared folders metadata...
==> default: Starting domain.
There was an error talking to Libvirt. The error message is shown
below:

Call to virDomainCreateWithFlags failed: internal error: cannot load AppArmor profile 'libvirt-2addc22b-4b39-44c5-8f86-86a719b164f8'
$ ls -l /usr/share/qemu/OVMF.fd
-rw-rw-r-- 1 root root 4194304 May  8 08:54 /usr/share/qemu/OVMF.fd

@AntonioMeireles
Copy link
Owner Author

Choose a reason for hiding this comment

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

hummm... things work out of the box over CL, in other distros one may have to cope with their idiosyncrasies... try to install "libvirt-daemon-system" (i guess you 're in a debian derivative and i suspect you haven't it installed), reboot and check again - if things still fail - get me online :-) . that error is unrelated with above commit at all :-)

Thanks once again for your patience :-)

Please sign in to comment.