From d4ae41fe488c02138e3a790287ca24b977b3badd Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Wed, 10 Nov 2010 18:45:50 +0100 Subject: [PATCH 1/2] bug #399: KVM/Libvirt driver support the 'arch' attribute --- src/vmm/LibVirtDriverKVM.cc | 17 ++++++++++++----- src/vmm_mad/ssh/vmm_ssh_kvm.conf | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 4fdd14a4c1..641617ed3f 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -41,6 +41,7 @@ int LibVirtDriver::deployment_description_kvm( string root = ""; string kernel_cmd = ""; string bootloader = ""; + string arch = ""; const VectorAttribute * disk; const VectorAttribute * context; @@ -142,11 +143,6 @@ int LibVirtDriver::deployment_description_kvm( file << "\t" << endl; - if (emulator == "kvm") - { - file << "\t\thvm" << endl; - } - num = vm->get_template_attribute("OS",attrs); // Get values & defaults @@ -165,9 +161,20 @@ int LibVirtDriver::deployment_description_kvm( root = os->vector_value("ROOT"); kernel_cmd = os->vector_value("KERNEL_CMD"); bootloader = os->vector_value("BOOTLOADER"); + arch = os->vector_value("ARCH"); } } + if ( arch.empty() ) + { + get_default("OS","ARCH",arch); + } + + if (emulator == "kvm") + { + file << "\t\thvm" << endl; + } + if ( kernel.empty() ) { get_default("OS","KERNEL",kernel); diff --git a/src/vmm_mad/ssh/vmm_ssh_kvm.conf b/src/vmm_mad/ssh/vmm_ssh_kvm.conf index 17b50215d5..fc11a10ca9 100644 --- a/src/vmm_mad/ssh/vmm_ssh_kvm.conf +++ b/src/vmm_mad/ssh/vmm_ssh_kvm.conf @@ -1,7 +1,7 @@ # Default configuration attributes for the KVM driver # (all domains will use these values as defaults) # Valid atributes are: -# - os [kernel,initrd,boot,root,kernel_cmd] +# - os [kernel,initrd,boot,root,kernel_cmd,arch] # - memory # - cpu # - vcpu @@ -10,7 +10,7 @@ #VCPU = 1 #MEMORY = 128 -OS = [ boot = "hd" ] +OS = [ boot = "hd", arch = "i686" ] FEATURES = [ PAE = "no", ACPI = "yes" ] DISK = [ driver = "raw" ] From 95f7f037980eaee9dc44c06c3d57a6060f462f2c Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 13 Nov 2010 00:58:03 +0100 Subject: [PATCH 2/2] bug #399: Added test for no arch and no default provided --- src/vmm/LibVirtDriverKVM.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 641617ed3f..2a8e71f614 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -168,6 +168,11 @@ int LibVirtDriver::deployment_description_kvm( if ( arch.empty() ) { get_default("OS","ARCH",arch); + + if ( arch.empty() ) + { + goto error_arch; + } } if (emulator == "kvm") @@ -628,6 +633,11 @@ error_memory: file.close(); return -1; +error_arch: + vm->log("VMM", Log::ERROR, "No ARCH defined and no default provided."); + file.close(); + return -1; + error_boot: vm->log("VMM", Log::ERROR, "No BOOT device defined and no default provided."); file.close();