From 0cee3d7ac05c05f0a13e7dcf9e504021df98f6a2 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 20 Nov 2013 17:18:06 +0100 Subject: [PATCH] feature #538: Changes using the new split function. --- src/vmm/LibVirtDriverKVM.cc | 8 +++++- src/vmm/LibVirtDriverVMware.cc | 19 ++++++++++++++ src/vmm/XenDriver.cc | 48 +++++++++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 9ece6427b4..750820e032 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -47,6 +47,8 @@ int LibVirtDriver::deployment_description_kvm( string bootloader = ""; string arch = ""; + vector boots; + const VectorAttribute * disk; const VectorAttribute * context; @@ -261,8 +263,12 @@ int LibVirtDriver::deployment_description_kvm( file << "\t\t" << bootloader << "" << endl; } + boots = one_util::split(boot, ','); - file << "\t\t" << endl; + for (vector::const_iterator it=boots.begin(); it!=boots.end(); it++) + { + file << "\t\t" << endl; + } file << "\t" << endl; diff --git a/src/vmm/LibVirtDriverVMware.cc b/src/vmm/LibVirtDriverVMware.cc index 285b2df66e..cc2135d866 100644 --- a/src/vmm/LibVirtDriverVMware.cc +++ b/src/vmm/LibVirtDriverVMware.cc @@ -46,6 +46,9 @@ int LibVirtDriver::deployment_description_vmware( string arch = ""; string guestOS = ""; string pciBridge = ""; + string boot = ""; + + vector boots; const VectorAttribute * features; @@ -156,6 +159,7 @@ int LibVirtDriver::deployment_description_vmware( { arch = os->vector_value("ARCH"); guestOS = os->vector_value("GUESTOS"); + boot = os->vector_value("BOOT"); } } @@ -174,12 +178,27 @@ int LibVirtDriver::deployment_description_vmware( metadata << "" << guestOS << "" << endl; } + if ( boot.empty() ) + { + get_default("OS","BOOT",boot); + } + // Start writing to the file with the info we got file << "\t" << endl; file << "\t\thvm" << endl; + if (!boot.empty()) + { + boots = one_util::split(boot, ','); + + for (vector::const_iterator it=boots.begin(); it!=boots.end(); it++) + { + file << "\t\t" << endl; + } + } + file << "\t" << endl; attrs.clear(); diff --git a/src/vmm/XenDriver.cc b/src/vmm/XenDriver.cc index 2f852e4283..298b81e740 100644 --- a/src/vmm/XenDriver.cc +++ b/src/vmm/XenDriver.cc @@ -43,7 +43,10 @@ int XenDriver::deployment_description( string root = ""; string kernel_cmd = ""; string bootloader = ""; - string hvm = ""; + string hvm = ""; + string boot = ""; + + vector boots; const VectorAttribute * disk; const VectorAttribute * context; @@ -158,6 +161,7 @@ int XenDriver::deployment_description( kernel_cmd = os->vector_value("KERNEL_CMD"); bootloader = os->vector_value("BOOTLOADER"); hvm = os->vector_value("HVM"); + boot = os->vector_value("BOOT"); } } @@ -217,6 +221,43 @@ int XenDriver::deployment_description( else //No kernel & no bootloader use hvm { file << "builder = \"hvm\"" << endl; + + if ( !boot.empty() ) + { + file << "boot = \""; + + boots = one_util::split(boot, ','); + + for (vector::const_iterator it=boots.begin(); it!=boots.end(); it++) + { + string boot_option = *it; + + one_util::tolower(boot_option); + + if ( boot_option == "hd" ) + { + file << "c"; + } + else if ( boot_option == "fd" ) + { + file << "a"; + } + else if ( boot_option == "cdrom" ) + { + file << "d"; + } + else if ( boot_option == "network" ) + { + file << "n"; + } + else + { + goto error_boot; + } + } + + file << "\"" << endl; + } } attrs.clear(); @@ -521,6 +562,11 @@ error_file: vm->log("VMM", Log::ERROR, "Could not open Xen deployment file."); return -1; +error_boot: + vm->log("VMM", Log::ERROR, "Boot option not supported."); + file.close(); + return -1; + error_memory: vm->log("VMM", Log::ERROR, "No memory defined and no default provided."); file.close();