From 1ced2d1b554a14fcf1496f110d6c08b168a0eb96 Mon Sep 17 00:00:00 2001 From: Ben Keith Date: Wed, 5 Feb 2014 15:12:45 -0500 Subject: [PATCH] Rounding `virtual_size` metadata up to nearest GB - It was rounding down before which was causing the VM to blow up when you try and launch it with vagrant-libvirt due to the filesystem extending beyond the end of the disk (assuming your root filesystem spans the whole disk). --- post-processor/vagrant/libvirt.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/post-processor/vagrant/libvirt.go b/post-processor/vagrant/libvirt.go index bb19b2d176c..087afc3451a 100644 --- a/post-processor/vagrant/libvirt.go +++ b/post-processor/vagrant/libvirt.go @@ -5,6 +5,7 @@ import ( "github.com/mitchellh/packer/packer" "path/filepath" "strings" + "math" ) type LibVirtProvider struct{} @@ -22,7 +23,8 @@ func (p *LibVirtProvider) Process(ui packer.Ui, artifact packer.Artifact, dir st } format := artifact.State("diskType").(string) - size := artifact.State("diskSize").(uint) / 1024 // In MB, want GB + // Round size up to nearest GB + size := math.Ceil(float64(artifact.State("diskSize").(uint)) / float64(1024)) domainType := artifact.State("domainType").(string) // Convert domain type to libvirt driver