1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Merge branch 'deployment_changes'

This commit is contained in:
Javi Fontan 2014-02-19 18:25:28 +01:00
commit a224d0777e
5 changed files with 296 additions and 15 deletions

View File

@ -2655,6 +2655,62 @@ function add_osTab(dialog) {
'<div class="tip">'+tr("Add support in the VM for Physical Address Extension (PAE)")+'</div>'+
'</div>'+
'</div>'+
'<div class="row">'+
'<div class="four columns">'+
'<label class="right inline" for="APIC">'+tr("APIC")+':</label>'+
'</div>'+
'<div class="six columns">'+
'<select id="APIC" name="apic">'+
'<option id="no_apic" name="no_apic" value=""></option>'+
'<option value="yes">'+tr("Yes")+'</option>'+
'<option value="no">'+tr("No")+'</option>'+
'</select>'+
'</div>'+
'<div class="two columns">'+
'<div class="tip">'+tr("Enables the advanced programmable IRQ management.")+'</div>'+
'</div>'+
'</div>'+
'<div class="row">'+
'<div class="four columns vm_param">'+
'<label class="right inline" for="HYPERV">'+tr("HYPERV")+':</label>'+
'</div>'+
'<div class="six columns">'+
'<select id="HYPERV" name="hyperv">'+
'<option id="no_hyperv" name="no_hyperv" value=""></option>'+
'<option value="yes">'+tr("Yes")+'</option>'+
'<option value="no">'+tr("No")+'</option>'+
'</select>'+
'</div>'+
'<div class="two columns">'+
'<div class="tip">'+tr("Add support in the VM for hyper-v features (HYPERV)")+'</div>'+
'</div>'+
'</div>'+
'<div class="row">'+
'<div class="four columns">'+
'<label class="right inline" for="LOCALTIME">'+tr("LOCALTIME")+':</label>'+
'</div>'+
'<div class="six columns">'+
'<select id="LOCALTIME" name="localtime">'+
'<option id="no_localtime" name="no_localtime" value=""></option>'+
'<option value="yes">'+tr("Yes")+'</option>'+
'<option value="no">'+tr("No")+'</option>'+
'</select>'+
'</div>'+
'<div class="two columns">'+
'<div class="tip">'+tr("The guest clock will be synchronized to the host's configured timezone when booted.")+'</div>'+
'</div>'+
'</div>'+
'<div class="row">'+
'<div class="four columns">'+
'<label class="right inline" for="DEVICE_MODEL">'+tr("Device model")+':</label>'+
'</div>'+
'<div class="six columns">'+
'<input type="text" id="DEVICE_MODEL" name="device_model"/>'+
'</div>'+
'<div class="two columns">'+
'<div class="tip">'+tr("Used to change the IO emulator in Xen HVM. Only XEN.")+'</div>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="six columns vm_param">'+
'<div class="row">'+

View File

@ -96,6 +96,7 @@ int LibVirtDriver::deployment_description_kvm(
string kernel_cmd = "";
string bootloader = "";
string arch = "";
string machine = "";
vector<string> boots;
@ -137,20 +138,29 @@ int LibVirtDriver::deployment_description_kvm(
const VectorAttribute * graphics;
string listen = "";
string port = "";
string passwd = "";
string keymap = "";
string listen = "";
string port = "";
string passwd = "";
string keymap = "";
string spice_options = "";
const VectorAttribute * input;
const VectorAttribute * features;
bool pae = false;
bool acpi = false;
bool pae = false;
bool acpi = false;
bool apic = false;
bool hyperv = false;
bool localtime = false;
int pae_found = -1;
int acpi_found = -1;
int pae_found = -1;
int acpi_found = -1;
int apic_found = -1;
int hyperv_found = -1;
int localtime_found = -1;
string hyperv_options = "";
const VectorAttribute * raw;
string default_raw;
@ -240,6 +250,7 @@ int LibVirtDriver::deployment_description_kvm(
kernel_cmd = os->vector_value("KERNEL_CMD");
bootloader = os->vector_value("BOOTLOADER");
arch = os->vector_value("ARCH");
machine = os->vector_value("MACHINE");
}
}
@ -253,7 +264,19 @@ int LibVirtDriver::deployment_description_kvm(
}
}
file << "\t\t<type arch='" << arch << "'>hvm</type>" << endl;
if ( machine.empty() )
{
get_default("OS", "MACHINE", machine);
}
file << "\t\t<type arch='" << arch << "'";
if ( !machine.empty() )
{
file << " machine='" << machine << "'";
}
file << ">hvm</type>" << endl;
if ( kernel.empty() )
{
@ -712,6 +735,16 @@ int LibVirtDriver::deployment_description_kvm(
}
file << "/>" << endl;
if ( type == "spice" )
{
get_default("SPICE_OPTIONS", spice_options);
if ( spice_options != "" )
{
file << "\t\t" << spice_options << endl;
}
}
}
else
{
@ -766,8 +799,11 @@ int LibVirtDriver::deployment_description_kvm(
if ( features != 0 )
{
pae_found = features->vector_value("PAE", pae);
acpi_found = features->vector_value("ACPI", acpi);
pae_found = features->vector_value("PAE", pae);
acpi_found = features->vector_value("ACPI", acpi);
apic_found = features->vector_value("APIC", apic);
hyperv_found = features->vector_value("HYPERV", hyperv);
localtime_found = features->vector_value("LOCALTIME", localtime);
}
}
@ -781,7 +817,22 @@ int LibVirtDriver::deployment_description_kvm(
get_default("FEATURES", "ACPI", acpi);
}
if( acpi || pae )
if ( apic_found != 0 )
{
get_default("FEATURES", "APIC", apic);
}
if ( hyperv_found != 0 )
{
get_default("FEATURES", "HYPERV", hyperv);
}
if ( localtime_found != 0 )
{
get_default("FEATURES", "LOCALTIME", localtime);
}
if ( acpi || pae || apic || hyperv )
{
file << "\t<features>" << endl;
@ -795,9 +846,28 @@ int LibVirtDriver::deployment_description_kvm(
file << "\t\t<acpi/>" << endl;
}
if ( apic )
{
file << "\t\t<apic/>" << endl;
}
if ( hyperv )
{
get_default("HYPERV_OPTIONS", hyperv_options);
file << "\t\t<hyperv>" << endl;
file << hyperv_options << endl;
file << "\t\t</hyperv>" << endl;
}
file << "\t</features>" << endl;
}
if ( localtime )
{
file << "\t<clock offset='localtime'/>" << endl;
}
attrs.clear();
// ------------------------------------------------------------------------

View File

@ -21,6 +21,12 @@
#include <fstream>
#include <math.h>
string on_off_string(bool value)
{
return value? "1" : "0";
}
int XenDriver::deployment_description(
const VirtualMachine * vm,
const string& file_name) const
@ -76,6 +82,24 @@ int XenDriver::deployment_description(
string passwd = "";
string keymap = "";
const VectorAttribute * input;
string bus = "";
const VectorAttribute * features;
bool pae = false;
bool acpi = false;
bool apic = false;
string device_model = "";
bool localtime = false;
int pae_found = -1;
int acpi_found = -1;
int apic_found = -1;
int device_model_found = -1;
int localtime_found = -1;
const VectorAttribute * raw;
string data;
string default_raw;
@ -577,6 +601,119 @@ int XenDriver::deployment_description(
attrs.clear();
// ------------------------------------------------------------------------
// Input (only usb tablet)
// ------------------------------------------------------------------------
if ( vm->get_template_attribute("INPUT",attrs) > 0 )
{
input = dynamic_cast<const VectorAttribute *>(attrs[0]);
if ( input != 0 )
{
type = input->vector_value("TYPE");
bus = input->vector_value("BUS");
if ( type == "tablet" && bus == "usb" )
{
file << "usb = 1" << endl;
file << "usbdevice = 'tablet'" << endl;
}
else
{
vm->log("VMM", Log::WARNING,
"Not supported input, only usb tablet, ignored.");
}
}
}
attrs.clear();
// ------------------------------------------------------------------------
// Features (only for HVM)
// ------------------------------------------------------------------------
if ( is_hvm )
{
num = vm->get_template_attribute("FEATURES",attrs);
if ( num > 0 )
{
features = dynamic_cast<const VectorAttribute *>(attrs[0]);
if ( features != 0 )
{
pae_found = features->vector_value("PAE", pae);
acpi_found = features->vector_value("ACPI", acpi);
apic_found = features->vector_value("APIC", apic);
localtime_found =
features->vector_value("LOCALTIME", localtime);
device_model = features->vector_value("DEVICE_MODEL");
if ( device_model != "" )
{
device_model_found = 0;
}
}
}
if ( pae_found != 0 && get_default("FEATURES", "PAE", pae) )
{
pae_found = 0;
}
if ( acpi_found != 0 && get_default("FEATURES", "ACPI", acpi) )
{
acpi_found = 0;
}
if ( apic_found != 0 && get_default("FEATURES", "APIC", apic) )
{
apic_found = 0;
}
if ( device_model_found != 0 )
{
get_default("FEATURES", "DEVICE_MODEL", device_model);
if ( device_model != "" )
{
device_model_found = 0;
}
}
if ( localtime_found != 0 )
{
get_default("FEATURES", "LOCALTIME", localtime);
}
if ( pae_found == 0)
{
file << "pae = " << on_off_string(pae) << endl;
}
if ( acpi_found == 0)
{
file << "acpi = " << on_off_string(acpi) << endl;
}
if ( apic_found == 0)
{
file << "apic = " << on_off_string(apic) << endl;
}
if ( device_model_found == 0)
{
file << "device_model = '" << device_model << "'" << endl;
}
if ( localtime )
{
file << "localtime = 'yes'" << endl;
}
attrs.clear();
}
// ------------------------------------------------------------------------
// Raw XEN attributes
// ------------------------------------------------------------------------

View File

@ -18,12 +18,13 @@
# (all domains will use these values as defaults). These values can
# be overridden in each VM template. Valid atributes are:
# - emulator
# - os [kernel,initrd,boot,root,kernel_cmd,arch]
# - os [kernel,initrd,boot,root,kernel_cmd,arch,machine]
# - vcpu
# - features [acpi, pae]
# - features [acpi, pae, apic, hyperv, localtime]
# - disk [driver, cache, io]
# - nic [filter, model]
# - raw
# - hyperv_options: options used for FEATURES = [ HYPERV = yes ]
# NOTE: raw attribute value is appended to that on the VM template
#EMULATOR = /usr/libexec/qemu-kvm
@ -31,9 +32,24 @@
#VCPU = 1
OS = [ boot = "hd", arch = "i686" ]
FEATURES = [ PAE = "no", ACPI = "yes" ]
FEATURES = [ PAE = "no", ACPI = "yes", APIC = "no", HYPERV = "no" ]
DISK = [ driver = "raw" , cache = "none"]
#NIC = [ filter = "clean-traffic", model="virtio" ]
#RAW = [ type = "kvm", data = "<devices><serial type=\"pty\"><source path=\"/dev/pts/5\"/><target port=\"0\"/></serial><console type=\"pty\" tty=\"/dev/pts/5\"><source path=\"/dev/pts/5\"/><target port=\"0\"/></console></devices>" ]
HYPERV_OPTIONS="<relaxed state='on'/><vapic state='on'/><spinlocks state='on' retries='4096'/>"
SPICE_OPTIONS="
<video>
<model type='qxl' heads='1'/>
</video>
<sound model='ich6' />
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
</channel>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>"

View File

@ -20,12 +20,14 @@
# - credit
# - os [kernel,initrd,root,kernel_cmd,hvm]
# - vcpu
# - features [acpi, pae, apic, device_model, localtime]
# - disk[driver]
# - nic[model]
# - raw
#VCPU = 1
#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", kernel_cmd="ro", hvm="yes" ]
#FEATURES = [ PAE = "no", ACPI = "yes", APIC = "yes" ]
CREDIT = 256
DISK = [ driver = "raw:" ]