Closed hbokh closed 6 years ago
From this it looks like the only drivers none
, tcg
, and kvm
is currently supported. But if you know what driver hvf
should use it's probably trivial to patch.
switch domainType {
case "none", "tcg":
driver = "qemu"
case "kvm":
driver = domainType
default:
return "", nil, fmt.Errorf("Unknown libvirt domain type: %s", domainType)
}
Thanks, Rickard, you beat me to that!
I was thinking of "just" adding hvf
as an option to line https://github.com/hashicorp/packer/blob/master/post-processor/vagrant/libvirt.go#L42 but not sure about these drivers and the possible effect(s).
But without a patch like this, it is not possible -as of yet- to create a libvirt-box on macOS?
This patch seems to work:
diff --git a/post-processor/vagrant/libvirt.go b/post-processor/vagrant/libvirt.go
index c20e8473b..60e274a57 100644
--- a/post-processor/vagrant/libvirt.go
+++ b/post-processor/vagrant/libvirt.go
@@ -39,7 +39,7 @@ func (p *LibVirtProvider) Process(ui packer.Ui, artifact packer.Artifact, dir st
// Convert domain type to libvirt driver
var driver string
switch domainType {
- case "none", "tcg":
+ case "none", "tcg", "hvf":
driver = "qemu"
case "kvm":
driver = domainType
With the above change I recompiled Packer and ran it on macOS just as described in the first issue-post. Here is the trailing part of the buildlog as a gist.
The results in the build-dir:
-rw-r--r-- 1 hbokh 7864320000 Nov 4 08:51 base-stretch
-rw-r--r-- 1 hbokh 543173696 Nov 4 08:51 base-stretch-0.0.0-qemu.box
-rw-r--r-- 1 hbokh 543172961 Nov 4 08:52 base-stretch.raw.gz
And finally the contents of the box-file base-stretch-0.0.0-qemu.box
:
-rw-r--r-- 1 hbokh 629 Nov 4 08:51 Vagrantfile
-rw-r--r-- 1 hbokh 7864320000 Nov 4 08:51 box.img
-rw-r--r-- 1 hbokh 55 Nov 4 08:51 metadata.json
So far this seems to solve my issue. I have to go through the contributing-doc to see how to commit this as a PR.
Closed in #6955
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
If it is even possible to successfully build and export (e.g. to Vagrant Cloud) a libvirt-type Vagrant-box on macOS, please add to the documentation HOW.
As of yet I can partly build a Debian 9-box based on tylert/packer-build and these added settings in file
template/debian/9_stretch/base.json
:"accelerator": "hvf"
"qemuargs": [ "-global", "virtio-pci.disable-modern=on" ]
The command
./script/qemu.sh template/debian/9_stretch/base.json
will error at the end, complaining aboutUnknown libvirt domain type: hvf
, which seems logic, because it is not kvm and KVM is not available on macOS AFAIK:A raw disk and a compressed disk can be found in the build-directory, but not resulting in what is to be expected.
Expected output / result (build on a Linux host with QEMU-kvm, libvirt and such):
The output is free of errors and results in the creation of an (exportable)
base-stretch-0.0.0-qemu.box
.Once again: is this result even possible on macOS and if yes, how? TIA!
Versions: