From 0ac07fb315a7f2537e4a921fb08a2f9048f21bdc Mon Sep 17 00:00:00 2001 From: Dean Smith Date: Tue, 29 Aug 2017 08:26:10 +0100 Subject: Adding support for arch and machine type This adds support for setting the architecture and machine type of the created virtual machine by adding two new attributes machine and arch to the domain definition --- libvirt/resource_libvirt_domain.go | 11 +++++++++++ website/docs/r/domain.html.markdown | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go index 1044223d..561cb712 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -147,6 +147,14 @@ func resourceLibvirtDomain() *schema.Resource { Optional: true, Required: false, }, + "machine": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, + "arch": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + }, }, } } @@ -239,6 +247,9 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error } } + domainDef.OS.Type.Arch = d.Get("arch").(string) + domainDef.OS.Type.Machine = d.Get("machine").(string) + if firmware, ok := d.GetOk("firmware"); ok { firmwareFile := firmware.(string) if _, err := os.Stat(firmwareFile); os.IsNotExist(err) { diff --git a/website/docs/r/domain.html.markdown b/website/docs/r/domain.html.markdown index bdb71077..5fae0006 100644 --- a/website/docs/r/domain.html.markdown +++ b/website/docs/r/domain.html.markdown @@ -50,6 +50,11 @@ The following arguments are supported: * `coreos_ignition` - (Optional) The [libvirt_ignition](/docs/providers/libvirt/r/coreos_ignition.html) resource that is to be used by the CoreOS domain. +* `arch` - (Optional) The architecture for the VM (probably x86_64 or i686), + you normally won't need to set this unless you are building a special VM +* `machine` - (Optional) The machine type, + you normally won't need to set this unless you are running on a platform that + defaults to the wrong machine type for your template ### UEFI images -- cgit v1.2.3