mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-28 17:57:22 +03:00
F #1439: Fix attach_disk issues
This commit is contained in:
parent
cd288c349b
commit
774a0a6580
@ -127,11 +127,11 @@
|
||||
{{/unless}}
|
||||
</div>
|
||||
<fieldset>
|
||||
<legend>{{tr "Throttling Bytes/s"}}</legend>
|
||||
<legend>{{tr "Throttling (Bytes/s)"}}</legend>
|
||||
<div class="row vm_param">
|
||||
<div class="medium-4 columns hypervisor only_kvm">
|
||||
<fieldset>
|
||||
<legend>{{tr "TOTAL (R+W)"}}</legend>
|
||||
<legend>{{tr "Total"}}</legend>
|
||||
<label for="TOTAL_BYTES_SEC">
|
||||
{{tr "Value"}}
|
||||
</label>
|
||||
@ -148,7 +148,7 @@
|
||||
</div>
|
||||
<div class="medium-4 columns hypervisor only_kvm">
|
||||
<fieldset>
|
||||
<legend>{{tr "READ"}}</legend>
|
||||
<legend>{{tr "Read"}}</legend>
|
||||
<label for="READ_BYTES_SEC">
|
||||
{{tr "Value"}}
|
||||
</label>
|
||||
@ -165,7 +165,7 @@
|
||||
</div>
|
||||
<div class="medium-4 columns hypervisor only_kvm">
|
||||
<fieldset>
|
||||
<legend>{{tr "WRITE"}}</legend>
|
||||
<legend>{{tr "Write"}}</legend>
|
||||
<label for="WRITE_BYTES_SEC">
|
||||
{{tr "Value"}}
|
||||
</label>
|
||||
@ -183,11 +183,11 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{tr "Throttling IOPS Sec"}}</legend>
|
||||
<legend>{{tr "Throttling (IOPS)"}}</legend>
|
||||
<div class="row vm_param">
|
||||
<div class="medium-4 columns hypervisor only_kvm">
|
||||
<fieldset>
|
||||
<legend>{{tr "TOTAL (R+W)"}}</legend>
|
||||
<legend>{{tr "Total"}}</legend>
|
||||
<label for="TOTAL_IOPS_SEC">
|
||||
{{tr "Value"}}
|
||||
</label>
|
||||
@ -204,7 +204,7 @@
|
||||
</div>
|
||||
<div class="medium-4 columns hypervisor only_kvm">
|
||||
<fieldset>
|
||||
<legend>{{tr "READ"}}</legend>
|
||||
<legend>{{tr "Read"}}</legend>
|
||||
<label for="READ_IOPS_SEC">
|
||||
{{tr "Value"}}
|
||||
</label>
|
||||
@ -221,7 +221,7 @@
|
||||
</div>
|
||||
<div class="medium-4 columns hypervisor only_kvm">
|
||||
<fieldset>
|
||||
<legend>{{tr "WRITE"}}</legend>
|
||||
<legend>{{tr "Write"}}</legend>
|
||||
<label for="WRITE_IOPS_SEC">
|
||||
{{tr "Value"}}
|
||||
</label>
|
||||
|
@ -90,24 +90,33 @@ static void do_network_hosts(ofstream& file,
|
||||
static void insert_sec(ofstream& file, const string& base, const string& s,
|
||||
const string& sm, const string& sml)
|
||||
{
|
||||
int s_i = 0;
|
||||
|
||||
if (!s.empty())
|
||||
{
|
||||
file << "\t\t\t\t<" << base << "_sec>"
|
||||
<< one_util::escape_xml(s)
|
||||
<<"</" << base << "_sec>\n";
|
||||
|
||||
s_i = stoi(s);
|
||||
}
|
||||
|
||||
if (!sm.empty())
|
||||
{
|
||||
file << "\t\t\t\t<" << base << "_sec_max>"
|
||||
<< one_util::escape_xml(sm)
|
||||
<< "</" << base << "_sec_max>\n";
|
||||
int sm_i = stoi(sm);
|
||||
|
||||
if (!sml.empty())
|
||||
if ( sm_i > s_i )
|
||||
{
|
||||
file << "\t\t\t\t<" << base << "_sec_max_length>"
|
||||
<< one_util::escape_xml(sml)
|
||||
<< "</" << base << "_sec_max_length>\n";
|
||||
file << "\t\t\t\t<" << base << "_sec_max>"
|
||||
<< one_util::escape_xml(sm)
|
||||
<< "</" << base << "_sec_max>\n";
|
||||
|
||||
if (!sml.empty())
|
||||
{
|
||||
file << "\t\t\t\t<" << base << "_sec_max_length>"
|
||||
<< one_util::escape_xml(sml)
|
||||
<< "</" << base << "_sec_max_length>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,28 +30,27 @@ DRV_ACTION="$5"
|
||||
get_disk_information "ATTACH='YES'"
|
||||
|
||||
function insert_sec() {
|
||||
base=$1
|
||||
name=$1
|
||||
s=$2
|
||||
sm=$3
|
||||
sml=$4
|
||||
|
||||
if [ -n "${s}" ]; then
|
||||
XML+=" <${name}_sec>$(xml_esc "${s}")</${name}_sec>"
|
||||
XML+="<${name}_sec>$(xml_esc "${s}")</${name}_sec>"
|
||||
fi
|
||||
|
||||
if [ -n "${sm}" ]; then
|
||||
|
||||
XML+=" <${name}_sec_max>$(xml_esc "${sm}")</${name}_sec_max>"
|
||||
if [ -n "${sm}" -a ${sm} -gt ${s} ]; then
|
||||
XML+="<${name}_sec_max>$(xml_esc "${sm}")</${name}_sec_max>"
|
||||
|
||||
if [ -n "${sml}" ]; then
|
||||
XML+=" <${name}_sec_max_length>$(xml_esc "${sml}")</${name}_sec_max_length>"
|
||||
XML+="<${name}_sec_max_length>$(xml_esc "${sml}")</${name}_sec_max_length>"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# defaults
|
||||
CACHE=${CACHE:-${DEFAULT_ATTACH_CACHE}}
|
||||
CACHE=${CACHE:-default} # https://github.com/OpenNebula/one/blob/c0d081917224f1d467582b8d8ac052a48040ec00/src/vmm/LibVirtDriverKVM.cc#L459
|
||||
CACHE=${CACHE:-default}
|
||||
DISCARD=${DISCARD:-${DEFAULT_ATTACH_DISCARD}}
|
||||
DISK_IO=${DISK_IO:-${DEFAULT_ATTACH_IO}}
|
||||
TOTAL_BYTES_SEC=${TOTAL_BYTES_SEC:-${DEFAULT_ATTACH_TOTAL_BYTES_SEC}}
|
||||
@ -78,55 +77,56 @@ XML=''
|
||||
|
||||
XML+="<disk type='$(xml_esc "${TYPE_XML}")' device='$(xml_esc "${DEVICE}")'>"
|
||||
|
||||
XML+=" <driver name='qemu' type='$(xml_esc "${DRIVER}")'"
|
||||
XML+="<driver name='qemu' type='$(xml_esc "${DRIVER}")'"
|
||||
[ -n "${CACHE}" ] && XML+=" cache='$(xml_esc "${CACHE}")'"
|
||||
[ -n "${DISK_IO}" ] && XML+=" io='$(xml_esc "${DISK_IO}")'"
|
||||
[ -n "${DISCARD}" ] && XML+=" discard='$(xml_esc "${DISCARD}")'"
|
||||
XML+=" />"
|
||||
XML+="/>"
|
||||
|
||||
XML+=" <source ${TYPE_SOURCE}='$(xml_esc "${SOURCE}")' ${SOURCE_ARGS}>"
|
||||
XML+=" ${SOURCE_HOST}"
|
||||
XML+=" </source>"
|
||||
XML+="<source ${TYPE_SOURCE}='$(xml_esc "${SOURCE}")' ${SOURCE_ARGS}>"
|
||||
XML+="${SOURCE_HOST}"
|
||||
XML+="</source>"
|
||||
|
||||
[ -n "${AUTH}" ] && XML+=" ${AUTH}"
|
||||
|
||||
XML+=" <target dev='$(xml_esc "${TARGET}")'/>"
|
||||
XML+="<target dev='$(xml_esc "${TARGET}")'/>"
|
||||
[ -n "${ORDER}" ] && XML+=" <boot order='$(xml_esc "${ORDER}")'/>"
|
||||
[ "${READONLY}" = 'yes' ] && XML+=" <readonly/>"
|
||||
[ "${READONLY}" = 'yes' ] && XML+="<readonly/>"
|
||||
|
||||
if [ -n "${TOTAL_BYTES_SEC}${READ_BYTES_SEC}${WRITE_BYTES_SEC}" ] || \
|
||||
[ -n "${TOTAL_BYTES_SEC_MAX}${READ_BYTES_SEC_MAX}${WRITE_BYTES_SEC_MAX}" ] || \
|
||||
[ -n "${TOTAL_IOPS_SEC}${READ_IOPS_SEC}${WRITE_IOPS_SEC}" ] || \
|
||||
[ -n "${TOTAL_IOPS_SEC_MAX}${READ_IOPS_SEC_MAX}${WRITE_IOPS_SEC_MAX}" ];
|
||||
then
|
||||
XML+=" <iotune>"
|
||||
XML+="<iotune>"
|
||||
|
||||
insert_sec "read_bytes" $READ_BYTES_SEC $READ_BYTES_SEC_MAX $READ_BYTES_SEC_MAX_LENGTH
|
||||
insert_sec "read_bytes" "${READ_BYTES_SEC}" "${READ_BYTES_SEC_MAX}" "${READ_BYTES_SEC_MAX_LENGTH}"
|
||||
|
||||
insert_sec "write_bytes" $WRITE_BYTES_SEC $WRITE_BYTES_SEC_MAX $WRITE_BYTES_SEC_MAX_LENGTH
|
||||
insert_sec "write_bytes" "${WRITE_BYTES_SEC}" "${WRITE_BYTES_SEC_MAX}" "${WRITE_BYTES_SEC_MAX_LENGTH}"
|
||||
|
||||
insert_sec "total_bytes" $TOTAL_BYTES_SEC $TOTAL_BYTES_SEC_MAX $TOTAL_BYTES_SEC_MAX_LENGTH
|
||||
insert_sec "total_bytes" "${TOTAL_BYTES_SEC}" "${TOTAL_BYTES_SEC_MAX}" "${TOTAL_BYTES_SEC_MAX_LENGTH}"
|
||||
|
||||
insert_sec "read_iops" $READ_IOPS_SEC $READ_IOPS_SEC_MAX $READ_IOPS_SEC_MAX_LENGTH
|
||||
insert_sec "read_iops" "${READ_IOPS_SEC}" "${READ_IOPS_SEC_MAX}" "${READ_IOPS_SEC_MAX_LENGTH}"
|
||||
|
||||
insert_sec "write_iops" $WRITE_IOPS_SEC $WRITE_IOPS_SEC_MAX $WRITE_IOPS_SEC_MAX_LENGTH
|
||||
insert_sec "write_iops" "${WRITE_IOPS_SEC}" "${WRITE_IOPS_SEC_MAX}" "${WRITE_IOPS_SEC_MAX_LENGTH}"
|
||||
|
||||
insert_sec "total_iops" $TOTAL_IOPS_SEC $TOTAL_IOPS_SEC_MAX $TOTAL_IOPS_SEC_MAX_LENGTH
|
||||
insert_sec "total_iops" "${TOTAL_IOPS_SEC}" "${TOTAL_IOPS_SEC_MAX}" "${TOTAL_IOPS_SEC_MAX_LENGTH}"
|
||||
|
||||
XML+=" </iotune>"
|
||||
XML+="</iotune>"
|
||||
fi
|
||||
|
||||
if [ -z "${DISK_TARGET##sd*}" ]; then
|
||||
CTRL_TARGET=$(( $(LC_CTYPE=C printf '%d' "'${DISK_TARGET##sd}") - 97 ))
|
||||
if [ ${CTRL_TARGET} -ge 0 ] && [ ${CTRL_TARGET} -lt 256 ]; then
|
||||
XML+=" <address type='drive' controller='0' bus='0' target='${CTRL_TARGET}' unit='0'/>"
|
||||
XML+="<address type='drive' controller='0' bus='0' target='${CTRL_TARGET}' unit='0'/>"
|
||||
fi
|
||||
fi
|
||||
|
||||
XML+=" </disk>"
|
||||
XML+="</disk>"
|
||||
|
||||
# device attach
|
||||
ATTACH_CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
virsh --connect $LIBVIRT_URI attach-device $DOMAIN <(
|
||||
cat <<EOT
|
||||
${XML}
|
||||
|
Loading…
x
Reference in New Issue
Block a user