Virtualbox --paravirtprovider Setting Doesn't Seem to Stick

571 views
Skip to first unread message

Thomas Duesing

unread,
Aug 3, 2015, 5:24:08 PM8/3/15
to Packer
Hi there,

After upgrading to Virtualbox 5.0, I updated my Packer templates to take advantage of the new KVM paravirtualization interface[1][2] by adding the following:

[
 
"modifyvm",
 
"{{.Name}}",
 
"--paravirtprovider",
 
"kvm"
],

When building a Vagrant box from this template, the build succeeds, with the above modifyvm command appearing to succeed as well. However, when starting up a Vagrant box created from this template, the VM is using the "Legacy" paravirtualization interface.

When run manually on the command line as `VBoxManage $UUID --paravirtprovider kvm`, the VM's paravirtualization interface changes successfully.

It appears you can change this setting within the Vagrantfile[3], but I'd prefer to avoid that, especially since the other modifyvm settings in my Packer template work properly.

I'm seeing this behavior for both the Fedora 21 and 22 templates in this repo: https://github.com/TFDuesing/packer-templates

Am I doing something wrong, or does this possibly point to a bug in Packer (or Vagrant)?

Thanks!

-Thomas Duesing


Alvaro Miranda Aguilera

unread,
Aug 3, 2015, 6:36:07 PM8/3/15
to packe...@googlegroups.com
On Tue, Aug 4, 2015 at 9:24 AM, Thomas Duesing <tfdu...@gmail.com> wrote:
> KVM

Hello,

If the VM is to be consumed by Vagrant, you can:

a. Include a Vagrantfile in the box build (the output of packer)
b. Share the Vagrantfile in the project to use this parameters, and
distribute the project


The counterpart to packer:

[
"modifyvm",
"{{.Name}}",
"--paravirtprovider",
"kvm"
],

is in vagrant :

config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--paravirtprovider", "kvm"]
end

Thomas Duesing

unread,
Aug 3, 2015, 10:53:27 PM8/3/15
to packe...@googlegroups.com
That strikes me as a workaround to a bug, no?

Why does the --paravirtprovider flag not stick when the --cpus and --memory flags, for instance, do?

-Thomas
> --
> This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/cn5EzFuvF1M/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0ewswEYZACESWM6MZVWrDp3KYMpFVOSQVwvfjGf2%3DjyL%3DQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Alvaro Miranda Aguilera

unread,
Aug 4, 2015, 12:56:19 AM8/4/15
to packe...@googlegroups.com
now I see what you mean.

Long story short, in the way packer works, it do a VBoxManage export

and there is where this property is lost.

So as I see it, no easy way so far, until Virtualbox includes this option.

Long version:

I tried this:

"vboxmanage": [
["modifyvm", "{{.Name}}", "--vram", "32"],
["modifyvm", "{{.Name}}", "--cpus", "2"],
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--paravirtprovider", "kvm"]
],
"vboxmanage_post": [
["modifyvm", "{{.Name}}", "--paravirtprovider", "kvm"]
]

And seems the issue is on the export process

since the box was set to "--paravirtprovider", "kvm" at creation
then i did set "--paravirtprovider", "kvm" before export

however the command VBoxManage export seems to be the one that is
clearing this out:

On Vm creation:

==> virtualbox-iso: Executing custom VBoxManage commands...
virtualbox-iso: Executing: modifyvm
packer-virtualbox-iso-1438661617 --vram 32
virtualbox-iso: Executing: modifyvm
packer-virtualbox-iso-1438661617 --cpus 2
virtualbox-iso: Executing: modifyvm
packer-virtualbox-iso-1438661617 --memory 2048
virtualbox-iso: Executing: modifyvm
packer-virtualbox-iso-1438661617 --paravirtprovider kvm
==> virtualbox-iso: Starting the virtual machine...

before export (just in case, to be sure i did this):



==> virtualbox-iso: Executing custom VBoxManage commands...
virtualbox-iso: Executing: modifyvm
packer-virtualbox-iso-1438661617 --paravirtprovider kvm
==> virtualbox-iso: Preparing to export machine...


Then export happens:

==> virtualbox-iso: Exporting virtual machine...
virtualbox-iso: Executing: export packer-virtualbox-iso-1438661617
--output output-virtualbox-iso/packer-virtualbox-iso-1438661617.ovf
==> virtualbox-iso: Unregistering and deleting virtual machine...

and the paravirt option is gone.

There is no option that I am aware to tell the export that the VM is
to be used with "--paravirtprovider", "kvm"


So, checking the options of VBoxManage export:

VBoxManage export <machines> --output|-o <name>.<ovf/ova>
[--legacy09|--ovf09|--ovf10|--ovf20]


the default is --ovf10

Utf8Str strOvfFormat("ovf-1.0"); // the default export version

http://www.virtualbox.org/svn/vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp


I tried adding this:

"export_opts": [
"--ovf20"
]

It got properly run:

==> virtualbox-iso: Exporting virtual machine...
virtualbox-iso: Executing: export packer-virtualbox-iso-1438663262
--output output-virtualbox-iso/packer-virtualbox-iso-1438663262.o
vf --ovf20
==> virtualbox-iso: Unregistering and deleting virtual machine...

however, this parameter wasn't set in the export.

$ egrep -i 'para|kvm' output-virtualbox-iso/*.ovf
$


Alvaro
> You received this message because you are subscribed to the Google Groups "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/ED6AA9E5-8DF4-4023-A1D6-89D58DBD5C59%40gmail.com.

Alvaro Miranda Aguilera

unread,
Aug 18, 2015, 5:47:12 AM8/18/15
to Packer, tfdu...@gmail.com
Hello There

Quick update, as Virtualbox 5.0.2 it works now.

I did open a bug with VirtualBox (the upstream project) and I have to say that they have fixed this and works.

I did open this ticket:
https://www.virtualbox.org/ticket/14390

And this was included in the changelog:
https://www.virtualbox.org/wiki/Changelog
OVF: properly export all VBox features including the setting for paravirtualization (bug #14390)

So as 5.0.2 now this works.

This is what's inside the .OVF if the source box had paravirt+kvm:
<Paravirt provider="KVM"/>



if I add this box to vagrant:

vagrant box add --name packer-kvm --provider=virtualbox packer_virtualbox-iso_virtualbox.box 

==> box: Box file was not detected as metadata. Adding it directly...

==> box: Adding box 'packer-kvm' (v0) for provider: virtualbox

    box: Unpacking necessary files from: file:///Volumes/hd1/Dropbox/work/hashicorp/packer-kvm/packer_virtualbox-iso_virtualbox.box

==> box: Successfully added box 'packer-kvm' (v0) for 'virtualbox'!



And check the ovf of the imported box:


z2-3:packer-kvm kikitux$ grep -i kvm ~/.vagrant.d/boxes/packer-kvm/0/virtualbox/box.ovf 

        <Paravirt provider="KVM"/>

z2-3:packer-kvm kikitux$ 


So, I can start this VM and KVM paravirt will be enabled:


z2-3:packer-kvm kikitux$ VBoxManage list vms

"packer-kvm_default_1439890992981_86049" {858335f1-541f-4056-ae69-27668cde08ea}


z2-3:packer-kvm kikitux$ VBoxManage showvminfo 858335f1-541f-4056-ae69-27668cde08ea | grep KVM

Paravirt. Provider: KVM

z2-3:packer-kvm kikitux$ 



Thanks!

Alvaro.

>> To unsubscribe from this group and all its topics, send an email to packer-tool+unsubscribe@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0ewswEYZACESWM6MZVWrDp3KYMpFVOSQVwvfjGf2%3DjyL%3DQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.

Thomas Duesing

unread,
Aug 18, 2015, 12:09:41 PM8/18/15
to Packer, tfdu...@gmail.com
Fantastic! Thanks so much for doing all that upstream legwork.

Also, it looks like "Paravirt. Provider: Default" is set by default on all VirtualBox Packer builds now, which is awesome.

-Thomas


>> To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0ewswEYZACESWM6MZVWrDp3KYMpFVOSQVwvfjGf2%3DjyL%3DQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages