<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hi,all<div><br></div><div>I want to get a relatively accurate cpu usage of a domain. I have a few questions about virDomainGetInfo:</div><div> </div><div><ol class="dp-cpp" start="1" style="padding-right: 0px; padding-left: 50px; border: none; list-style-position: initial; list-style-image: initial; background-color: rgb(255, 255, 255); color: rgb(92, 92, 92); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; line-height: 18px; margin-right: 0px !important; margin-bottom: 1px !important; margin-left: 45px !important;"><li style="list-style: decimal outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;"><span class="keyword" style="margin: 0px; padding: 0px; borde!
r: none; color: rgb(0, 102, 153); background-color: inherit; font-weight: bold;">struct</span> virDomainInfo{ </span></li><li style="list-style: decimal outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">unsigned <span class="datatypes" style="margin: 0px; padding: 0px; border: none; background-color: inherit;">char</span> state : <span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">//the running state, one of virDomainState </span> </span></li><li style="list-style: decimal outside; border-style: none none none solid; border-left-width: 3px; border-left-col!
or: rgb(108, 226, 108); background-color: rgb(248, 248, 248); !
line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">unsigned <span class="datatypes" style="margin: 0px; padding: 0px; border: none; background-color: inherit;">long</span> maxMem :<span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">// the maximum memory in KBytes allowed </span> </span></li><li style="list-style: decimal outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">unsigned <span class="datatypes" style="margin: 0px; padding: 0px; border: none!
; background-color: inherit;">long</span> memory :<span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">// the memory in KBytes used by the domain </span> </span></li><li style="list-style: decimal outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">unsigned <span class="datatypes" style="margin: 0px; padding: 0px; border: none; background-color: inherit;">short</span> nrVirtCpu :<span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">// the number of virtual CPUs for&!
nbsp;the domain </span> </span></li><li style="lis!
t-style: decimal outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); background-color: rgb(248, 248, 248); line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">unsigned <span class="datatypes" style="margin: 0px; padding: 0px; border: none; background-color: inherit;">long</span> <span class="datatypes" style="margin: 0px; padding: 0px; border: none; background-color: inherit;">long</span> cpuTime : <span class="comment" style="margin: 0px; padding: 0px; border: none; color: rgb(0, 130, 0); background-color: inherit;">//the CPU time used in nanoseconds </span> </span></li><li style="list-style: decimal outside; border-style: none none none solid; border-left-width: 3px; border-left-color: rgb(108, 226, 108); background-color: rgb(2!
48, 248, 248); line-height: 14px; margin: 0px !important; padding: 0px 3px 0px 10px !important;"><span style="margin: 0px; padding: 0px; border: none; color: black; background-color: inherit;">} </span></li></ol></div><div><br></div><div>If a domain is assigned to 4 vcpus and my machine has 6 physical cores, then the cpuTime in virDomainInfo should be the sum of cpu time of the 4 vcpus. When I want to calculate the cpu usage, which of the following is more accurate?</div><div> 1/4 * cpu time / total time or 4/6 * cpu time / total time or just cpu time / total time </div><div><br></div><div><br></div><div>regards</div><div>zhangzhang</div><div><br></div><div><br></div> </div></body>
</html>