add option to disable kvm hardware virtualization

This commit is contained in:
Roman Tomjak 2020-07-15 18:47:24 +01:00
parent 3fa4499f91
commit be7251f185
No known key found for this signature in database
GPG Key ID: BB29BA0B3501D719
3 changed files with 7 additions and 0 deletions

View File

@ -53,6 +53,7 @@ type Config struct {
Agent bool `mapstructure:"qemu_agent"`
SCSIController string `mapstructure:"scsi_controller"`
Onboot bool `mapstructure:"onboot"`
DisableKVM bool `mapstructure:"disable_kvm"`
TemplateName string `mapstructure:"template_name"`
TemplateDescription string `mapstructure:"template_description"`

View File

@ -96,6 +96,7 @@ type FlatConfig struct {
Agent *bool `mapstructure:"qemu_agent" cty:"qemu_agent" hcl:"qemu_agent"`
SCSIController *string `mapstructure:"scsi_controller" cty:"scsi_controller" hcl:"scsi_controller"`
Onboot *bool `mapstructure:"onboot" cty:"onboot" hcl:"onboot"`
DisableKVM *bool `mapstructure:"disable_kvm" cty:"disable_kvm" hcl:"disable_kvm"`
TemplateName *string `mapstructure:"template_name" cty:"template_name" hcl:"template_name"`
TemplateDescription *string `mapstructure:"template_description" cty:"template_description" hcl:"template_description"`
UnmountISO *bool `mapstructure:"unmount_iso" cty:"unmount_iso" hcl:"unmount_iso"`
@ -202,6 +203,7 @@ func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
"qemu_agent": &hcldec.AttrSpec{Name: "qemu_agent", Type: cty.Bool, Required: false},
"scsi_controller": &hcldec.AttrSpec{Name: "scsi_controller", Type: cty.String, Required: false},
"onboot": &hcldec.AttrSpec{Name: "onboot", Type: cty.Bool, Required: false},
"disable_kvm": &hcldec.AttrSpec{Name: "disable_kvm", Type: cty.Bool, Required: false},
"template_name": &hcldec.AttrSpec{Name: "template_name", Type: cty.String, Required: false},
"template_description": &hcldec.AttrSpec{Name: "template_description", Type: cty.String, Required: false},
"unmount_iso": &hcldec.AttrSpec{Name: "unmount_iso", Type: cty.Bool, Required: false},

View File

@ -98,6 +98,7 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) {
// Agent not set, default is true
// SCSI controller not set, using default 'lsi'
// Firewall toggle not set, using default: 0
// Disable KVM not set, using default: 0
if b.config.Memory != 512 {
t.Errorf("Expected Memory to be 512, got %d", b.config.Memory)
@ -126,6 +127,9 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) {
if b.config.Agent != true {
t.Errorf("Expected Agent to be true, got %t", b.config.Agent)
}
if b.config.DisableKVM != false {
t.Errorf("Expected Disable KVM toggle to be false, got %t", b.config.DisableKVM)
}
if b.config.SCSIController != "lsi" {
t.Errorf("Expected SCSI controller to be 'lsi', got %s", b.config.SCSIController)
}