mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
(cherry picked from commit c6965c3cfe
)
This commit is contained in:
parent
6ec28c4f35
commit
d787313ea1
@ -121,7 +121,6 @@
|
|||||||
<xs:element name="MEMORY" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="MEMORY" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="MEMORY_COST" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="MEMORY_COST" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="MEMORY_MAX" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
<xs:element name="MEMORY_MAX" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||||
<xs:element name="MEMORY_SLOTS" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
||||||
<xs:element name="NIC" minOccurs="0" maxOccurs="unbounded">
|
<xs:element name="NIC" minOccurs="0" maxOccurs="unbounded">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
|
@ -179,7 +179,6 @@ import { ScheduleAction } from 'client/constants/scheduler'
|
|||||||
* @property {string} [TEMPLATE.MEMORY] -
|
* @property {string} [TEMPLATE.MEMORY] -
|
||||||
* @property {string} [TEMPLATE.MEMORY_COST] -
|
* @property {string} [TEMPLATE.MEMORY_COST] -
|
||||||
* @property {string} [TEMPLATE.MEMORY_MAX] -
|
* @property {string} [TEMPLATE.MEMORY_MAX] -
|
||||||
* @property {string} [TEMPLATE.MEMORY_SLOTS] -
|
|
||||||
* @property {Nic|Nic[]} [TEMPLATE.NIC] -
|
* @property {Nic|Nic[]} [TEMPLATE.NIC] -
|
||||||
* @property {NicAlias|NicAlias[]} [TEMPLATE.NIC_ALIAS] -
|
* @property {NicAlias|NicAlias[]} [TEMPLATE.NIC_ALIAS] -
|
||||||
* @property {any} [TEMPLATE.NIC_DEFAULT] -
|
* @property {any} [TEMPLATE.NIC_DEFAULT] -
|
||||||
|
@ -832,19 +832,13 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
|||||||
user_obj_template->erase("MEMORY");
|
user_obj_template->erase("MEMORY");
|
||||||
obj_template->add("MEMORY", memory);
|
obj_template->add("MEMORY", memory);
|
||||||
|
|
||||||
// Check optional MEMORY_MAX and MEMORY_SLOTS attribute
|
// Check optional MEMORY_MAX attribute
|
||||||
if ( user_obj_template->get("MEMORY_MAX", ivalue) && ivalue > 0 )
|
if ( user_obj_template->get("MEMORY_MAX", ivalue) && ivalue > 0 )
|
||||||
{
|
{
|
||||||
user_obj_template->erase("MEMORY_MAX");
|
user_obj_template->erase("MEMORY_MAX");
|
||||||
obj_template->add("MEMORY_MAX", ivalue);
|
obj_template->add("MEMORY_MAX", ivalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( user_obj_template->get("MEMORY_SLOTS", ivalue) && ivalue > 0 )
|
|
||||||
{
|
|
||||||
user_obj_template->erase("MEMORY_SLOTS");
|
|
||||||
obj_template->add("MEMORY_SLOTS", ivalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( user_obj_template->get("CPU", fvalue) == false || fvalue <= 0 )
|
if ( user_obj_template->get("CPU", fvalue) == false || fvalue <= 0 )
|
||||||
{
|
{
|
||||||
goto error_cpu;
|
goto error_cpu;
|
||||||
|
@ -718,7 +718,16 @@ int LibVirtDriver::deployment_description_kvm(
|
|||||||
// Memory must be expressed in Kb
|
// Memory must be expressed in Kb
|
||||||
if (vm->get_template_attribute("MEMORY",memory))
|
if (vm->get_template_attribute("MEMORY",memory))
|
||||||
{
|
{
|
||||||
file << "\t<memory>" << memory * 1024 << "</memory>" << endl;
|
bool has_memory_max = vm->get_template_attribute("MEMORY_MAX", memory_max);
|
||||||
|
has_memory_max = has_memory_max && memory < memory_max;
|
||||||
|
|
||||||
|
if (!has_memory_max)
|
||||||
|
{
|
||||||
|
memory_max = memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
file << "\t<memory>" << memory_max * 1024 << "</memory>" << endl;
|
||||||
|
file << "\t<currentMemory>" << memory * 1024 << "</currentMemory>" << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -726,18 +735,6 @@ int LibVirtDriver::deployment_description_kvm(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_memory_max = vm->get_template_attribute("MEMORY_MAX", memory_max);
|
|
||||||
has_memory_max = has_memory_max && memory < memory_max;
|
|
||||||
|
|
||||||
if (!topology && has_memory_max)
|
|
||||||
{
|
|
||||||
int slots = 0;
|
|
||||||
get_attribute(vm, host, cluster, "MEMORY_SLOTS", slots);
|
|
||||||
|
|
||||||
file << "\t<maxMemory slots='" << slots
|
|
||||||
<< "'>" << memory_max * 1024 << "</maxMemory>" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// OS and boot options
|
// OS and boot options
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -851,7 +848,7 @@ int LibVirtDriver::deployment_description_kvm(
|
|||||||
cpu_mode = "custom";
|
cpu_mode = "custom";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !cpu_model.empty() || topology != 0 || has_memory_max )
|
if ( !cpu_model.empty() || topology != 0 )
|
||||||
{
|
{
|
||||||
file << "\t<cpu";
|
file << "\t<cpu";
|
||||||
|
|
||||||
@ -870,19 +867,6 @@ int LibVirtDriver::deployment_description_kvm(
|
|||||||
file << ">\n";
|
file << ">\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodes.empty() && has_memory_max)
|
|
||||||
{
|
|
||||||
int cpus = to_i(vcpu) - 1;
|
|
||||||
if (cpus < 0)
|
|
||||||
{
|
|
||||||
cpus = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
file << "\t\t<numa>\n\t\t\t<cell id='0' cpus='0-" << cpus
|
|
||||||
<< "' memory=" << one_util::escape_xml_attr(memory * 1024)
|
|
||||||
<< " unit='KiB'/>\n\t\t</numa>" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
vtopol(file, topology, nodes, numa_tune, mbacking);
|
vtopol(file, topology, nodes, numa_tune, mbacking);
|
||||||
|
|
||||||
file << "\t</cpu>\n";
|
file << "\t</cpu>\n";
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
# - emulator
|
# - emulator
|
||||||
# - os [kernel,initrd,boot,root,kernel_cmd,arch,machine,sd_disk_bus]
|
# - os [kernel,initrd,boot,root,kernel_cmd,arch,machine,sd_disk_bus]
|
||||||
# - vcpu
|
# - vcpu
|
||||||
# - memory_slots: number of memory slots for hotplug memory
|
|
||||||
# - graphics [type, listen, passwd, keymap, random_passwd]
|
# - graphics [type, listen, passwd, keymap, random_passwd]
|
||||||
# - features [acpi, pae, apic, hyperv, localtime, guest_agent, virtio_scsi_queues, iothreads]
|
# - features [acpi, pae, apic, hyperv, localtime, guest_agent, virtio_scsi_queues, iothreads]
|
||||||
# - cpu_model [model]
|
# - cpu_model [model]
|
||||||
@ -34,8 +33,6 @@
|
|||||||
|
|
||||||
#VCPU = 1
|
#VCPU = 1
|
||||||
|
|
||||||
MEMORY_SLOTS = 16
|
|
||||||
|
|
||||||
OS = [
|
OS = [
|
||||||
ARCH = "x86_64"
|
ARCH = "x86_64"
|
||||||
]
|
]
|
||||||
|
@ -53,33 +53,8 @@ if [ ! -z "$MEM" -a "$MEM" -ne "$MEM_OLD" ]; then
|
|||||||
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null
|
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract node id from virsh dumpxml
|
|
||||||
XML_INFO=$(virsh --connect ${LIBVIRT_URI} dumpxml ${DOMAIN})
|
|
||||||
IFS= read -r -d '' NODE_ID < <(echo "$XML_INFO" | $XPATH --subtree /domain/cpu/numa/cell/@id)
|
|
||||||
|
|
||||||
MEM_DIFF=$(expr $MEM - $MEM_OLD)
|
|
||||||
|
|
||||||
case $MEM_DIFF in
|
|
||||||
-*)
|
|
||||||
ACTION="detach-device"
|
|
||||||
MEM_DIFF=${MEM_DIFF#-}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
ACTION="attach-device"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Create tmp file with memory device specification
|
|
||||||
TMPFILE=$(mktemp /tmp/resize.XXXXXX)
|
|
||||||
echo -e "<memory model='dimm'>\n\t<target>\n\
|
|
||||||
<size unit='MiB'>$MEM_DIFF</size>\n\
|
|
||||||
<node>$NODE_ID</node>\n\t</target>\n</memory>" >$TMPFILE
|
|
||||||
|
|
||||||
# Add memory to VM
|
# Add memory to VM
|
||||||
exec_and_log "virsh --connect ${LIBVIRT_URI} ${ACTION} ${DOMAIN} ${TMPFILE} --live"
|
exec_and_log "virsh --connect ${LIBVIRT_URI} setmem ${DOMAIN} $((${MEM}*1024))"
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
rm $TMPFILE
|
|
||||||
|
|
||||||
# Compact memory
|
# Compact memory
|
||||||
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
|
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user