+
    h/B  c                   s   ^RI Ht ^RIHtHtHt ^RIHt  ! R R]4      t ! R R]4      t	 ! R R	]4      t
 ! R
 R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )i   )log)
XMLBuilderXMLPropertyXMLChildProperty)xmlutilc                   s   a  ] tR t^t o RtRt. ROt]! RRR7      t]! RRR7      t	]! RRR7      t
]! RRR7      tR	 tR
 tRtV tR# )_CPUTopologyz;
Class for generating XML for <cpu> child node <topology>.
topologyz
./@socketsTZis_intz./@diesz./@coresz
./@threadsc                s*   V P                   '       g   WP                  4       ,          V n         V P                  '       g   WP                  4       ,          V n        V P                  '       g   ^V n        V P                  '       g   WP                  4       ,          V n        V P                  4       V8w  d^   \        \        R4      RV P                  RV P                  RV P                   RV P                  RV P                  4       RV/,          4      hR# )	i   zTotal CPUs implied by topology (sockets=%(sockets)d * dies=%(dies)d * cores=%(cores)d * threads=%(threads)d == %(total)d) does not match vCPU count %(vcpus)dsocketsdiescoresthreadsZtotalvcpusN)r
   total_vcpusr   r	   r   Z
ValueErrorZ_)selfr   s   &&./usr/share/virt-manager/virtinst/domain/cpu.pyset_defaults_from_vcpusZ$_CPUTopology.set_defaults_from_vcpus!   s     zzz"2"2"44DJ||| $4$4$66DLyyyDI||| $4$4$66DL&H t||DIITZZt||T--/U   	    c                s    V P                   ;'       g    ^V P                  ;'       g    ^,          V P                  ;'       g    ^,          V P                  ;'       g    ^,          # )z1
Determine the CPU count represented by topology
r   r	   r
   r   r      &r   r   Z_CPUTopology.total_vcpusL   sF     !!diinn15qIT\\M^M^]^__r   )r
   r	   r   r   Nr   )__name__
__module____qualname____firstlineno____doc__XML_NAME_XML_PROP_ORDERr   r   r	   r
   r   r   r   __static_attributes____classdictcell__Z__classdict__   @r   r   r      sX      H=O,t4Gy.D
40E,t4G)V` `r   r   c                   sJ    ] tR t^WtRtRtRR.t]! RRR7      t]! R4      t	R	t
R
# )	_CPUCachez8
Class for generating XML for <cpu> child node <cache>.
cachelevelmode./@levelTr   ./@mode N)r   r   r   r   r   r   r   r   r"   r#   r   r&   r   r   r    r    W   s.     H'O
40Ey!Dr   r    c                   sF    ] tR t^ctRtRtRR.t]! R4      t]! R4      t	Rt
R# )	_CPUFeaturez;
Class for generating XML for <cpu> child nodes <feature>.
featurepolicynamez./@name	./@policyr&   N)r   r   r   r   r   r   r   r   r*   r)   r   r&   r   r   r'   r'   c   s,     H(Oy!D%Fr   r'   c                   sJ    ] tR t^otRtRtRR.t]! R4      t]! RRR7      t	R	t
R
# )_CPUMaxphysaddrz>
Class for generating XML for <cpu> child node <maxphysaddr>.
maxphysaddrr#   bitsr%   z./@bitsTr   r&   N)r   r   r   r   r   r   r   r   r#   r.   r   r&   r   r   r,   r,   o   s.     Hv&Oy!Dy.Dr   r,   c                   sN    ] tR t^tRtRtRR.t]! RRR7      t]! RRR7      t	R	t
R
# )_NUMACellSiblingz
Class for generating XML for <cpu><numa><cell><distances> child nodes
<sibling>, describing the distances to other NUMA cells.
Zsiblingidvalue./@idTr   ./@valuer&   N)r   r   r   r   r   r   r   r   r0   r1   r   r&   r   r   r/   r/      s/    
 HWoO	WT	*B
40Er   r/   c                   s    ] tR t^tRtRt. ROt]! RRR7      t]! R4      t	]! R4      t
]! RRR7      t]! R	4      t]! R
RR7      t]! R4      tRtR# )_NUMACellCachezg
Class for generating XML for <cpu><numa><cell> child nodes <cache>,
describing caches for NUMA cells.
r!   r$   Tr   z./@associativityr+   z./size/@valuez./size/@unitz./line/@valuez./line/@unitr&   N)r"   associativityr)   
size_value	size_unit
line_value	line_unit)r   r   r   r   r   r   r   r   r"   r5   r)   r6   r7   r8   r9   r   r&   r   r   r4   r4      sd    
 HO 
40E 23M%F_T:JN+I_T:JN+Ir   r4   c                   s    ] tR t^tRtRt. ROt]! RRR7      t]! R4      t	]! RRR7      t
]! R4      t]! R	4      t]! R
RR7      t]! ]RR7      t]! ]4      tRtR# )	_NUMACellzY
Class for generating XML for <cpu><numa> child nodes <cell> XML, describing
NUMA cells.
Zcellr2   Tr   z./@cpusz	./@memory./@unitz./@memAccessz
./@discard)Zis_yesnoz./distancesZrelative_xpathr&   N)r0   cpusmemoryunit	memAccessdiscardsiblingscaches)r   r   r   r   r   r   r   r   r0   r=   r>   r?   r@   rA   r   r/   rB   r4   rC   r   r&   r   r   r:   r:      sl    
 HdO	WT	*By!DT2Fy!DN+I,6G 0OHn-Fr   r:   c                   s    ] tR t^tRtRt. ROt]! RRR7      t]! RRR7      t	]! RRR7      t
]! R4      t]! R	RR7      t]! R
4      tRtR# )_NUMALatencyz
Class for generating XML for <cpu><numa><cell><interconnects> child nodes
<latency>, describing latency between two NUMA memory nodes.
Zlatency./@initiatorTr   	./@target./@cache./@typer3   r;   r&   N	initiatortargetr!   typer1   r?   r   r   r   r   r   r   r   r   rJ   rK   r!   rL   r1   r?   r   r&   r   r   rD   rD      sY    
 HOO N48IT2F
40Ey!D
40Ey!Dr   rD   c                   s    ] tR t^tRtRt. ROt]! RRR7      t]! RRR7      t	]! RRR7      t
]! R4      t]! R	RR7      t]! R
4      tRtR# )_NUMABandwidthz
Class for generating XML for <cpu><numa><cell><interconnects> child nodes
<bandwidth>, describing bandwidth between two NUMA memory nodes.
Z	bandwidthrE   Tr   rF   rG   rH   r3   r;   r&   NrI   rM   r&   r   r   rN   rN      sY    
 HOO N48IT2F
40Ey!D
40Ey!Dr   rN   c                   s  a  ] tR t^t o RtRt. R*OtRt]! R4      t	]! R4      t
]! R4      t]! RRR7      t]! R	4      t]! R
4      t]! R4      t]! R4      t]! ]RR7      t]! ]RR7      t]! ]4      t]! ]RR7      t]! ]RR7      t]! ]RR7      t]! ]RR7      tRt Rt!Rt"Rt#Rt$Rt%Rt&Rt'Rt(]!]"]#]$]%]&]'](.t)R t*R t+R t,R t-R t.R t/R  t0R+R! lt1R" t2R# t3R,R$ lt4R% t5R& t6R' t7R(t8V t9R)# )-	DomainCpuz 
Class for generating <cpu> XML
cpuTr%   z./@matchz./@checkz./@migratable)Zis_onoffz./modelz./model/@fallbackz./model/@vendor_idz./vendor)Z	is_singlez./numar<   z./numa/interconnectsFzhost-model-onlyz
hv-defaultz	host-copyz
host-modelzhost-passthroughZmaximumclearZdefaultc                sX   VP                  4       '       d   VP                  R 8X  d   VP                  P                  4       '       ga   VP                  P	                  4       '       gA   VP                  P                  4       '       g!   VP                  P                  4       '       d   R# R# )ZqemuTF)Zsupports_maximum_cpu_moderL   osis_x86is_arm_machvirtZis_riscv_virtZis_loongarch64r   guestdomcaps   &&&r   _should_use_maximum_cpu_modeZ&DomainCpu._should_use_maximum_cpu_mode=  so    --//

f$!!88++--88))++88**,, r   c                s`   VP                  4       pV P                  W4      '       d   V P                  # VP                  4       '       d   V P                  # \
        P                  ! R 4       VP                  4       '       d   V P                  # \
        P                  ! R4       V P                  # )z&Safe host-passthrough is not availablez Safe host-model is not available)
lookup_domcapsrY   SPECIAL_MODE_MAXIMUMZsupports_safe_host_passthroughSPECIAL_MODE_HOST_PASSTHROUGHr    debugZsupports_safe_host_modelSPECIAL_MODE_HOST_MODELSPECIAL_MODE_HOST_MODEL_ONLYrU      && r   _get_app_default_modeZDomainCpu._get_app_default_modeL  s     &&(,,U<<,,,1133555		:;++--///		45000r   c                s   W P                   8X  d)   V P                  V4      p\        P                  ! R V4       W P                  8X  g!   W P
                  8X  g   W P                  8X  dP   RV n        RV n        RV n	        RV n
        RV n        V P                   F  pV P                  V4       K  	  W n        EM.W P                  8X  g   W P                   8X  d   V P#                  4        MW P$                  8X  g   W P&                  8X  d   W P&                  8X  d#   \        P(                  ! RVV P$                  4       V P*                  P,                  P.                  P0                  P                  '       dT   V P#                  4        V P3                  WP*                  P,                  P.                  P0                  P                  4       M\4        P6                  ! RV,          4      hRV n        R# )zUsing default cpu mode=%sNz.CPU mode=%s no longer supported, using mode=%szunknown special cpu mode '%s'T)SPECIAL_MODE_APP_DEFAULTra   r    r]   r^   r\   r[   modelvendormodel_fallback
migratablecheckfeaturesremove_childr#   SPECIAL_MODE_HV_DEFAULTSPECIAL_MODE_CLEARrQ   r_   SPECIAL_MODE_HOST_COPYZwarningconncapshostrP   	set_modelr   ZDevErrorspecial_mode_was_set)r   rV   valf   &&& r   set_special_modeZDomainCpu.set_special_mode_  sg   ///,,U3CII137 ///888///DJDK"&D"DODJ]]!!!$ #I000C;R;R4RJJL555@[@[9[111D55
 yy~~""&&,,,

uiinn&9&9&=&=&C&CD""#BS#HII$(!r   c                s    VP                  4       pVP                  4        FH  pR pV P                   F  pVP                  V8X  g   K  Rp M	  V'       d   K7  V P	                  V4       KJ  	  R# )FTN)rZ   get_cpu_security_featuresrh   r*   add_feature)r   rV   rW   r(   Zexistsrs      &&    r   _add_security_featuresZ DomainCpu._add_security_features  s_    &&(88:GF]]66W$!F # 6  ) ;r   c                s   VP                  4       pVP                  4       p\        V4      ^ 8X  d
   RV n        R# V P                   Uu. uF!  qDP
                  R8X  g   K  VP                  NK#  	  ppV P                  '       de   V P                  P                  R4      '       d   VP                  R4       V P                  P                  R4      '       d   VP                  R4       \        V4      \        V4      8*  V n        R# u upi )za
Since 'secure' property is not exported into the domain XML
we might need to refresh its state.
FNrequireZIBRSz	spec-ctrlZIBPBZibpb)rZ   rv   Zlensecurerh   r)   r*   rc   ZendswithZappendZset)r   rV   rW   rh   rs   ZguestFeaturesrx   r   check_security_featuresZ!DomainCpu.check_security_features  s    
 &&(446x=ADK)-PA((i:OP:::zz""6**$$[1zz""6**$$V,(ms='99 Qs   DDc                s    VP                  4       pVP                  4        FN  pV P                   F;  pVP                  V8X  g   K  VP                  R 8X  g   K)  V P                  V4        KL  	  KP  	  R# )rz   N)rZ   rv   rh   r*   r)   ri   )r   rV   rW   r(   rs      &&   r   _remove_security_featuresZ#DomainCpu._remove_security_features  sY    &&(88:G]]66W$Y)>%%a( # ;r   c                s   \         P                  ! R V4       RV n        V'       dV   RV n        V P                  '       g   RV n        V P
                  '       d   V P                  V4       MV P                  V4       W n        R# )zsetting cpu model %sNcustomZexact)	r    r]   rf   r#   matchr{   ry   r~   rc   )r   rV   rr   rX   r   rp   ZDomainCpu.set_model  s\    		(#. DI:::$
{{{++E2..u5
r   c                sR    V P                   P                  4       pWn        W#n        R # N)rh   Zadd_newr*   r)   )r   r*   r)   r(   rt   r   rw   ZDomainCpu.add_feature  s    --'')r   c                s6    V P                   P                  4       # )zM
Determine the CPU count represented by topology, or 1 if
no topology is set
)r   r   r   r   r   vcpus_from_topologyZDomainCpu.vcpus_from_topology  s    
 }}((**r   c                sH    \        V P                  P                  4       4      # )z)
Return True if any topology info is set
)Zboolr   Zget_xmlr   r   r   has_topologyZDomainCpu.has_topology  s     DMM))+,,r   c                s|    V P                  4       '       g   V'       g   R# V P                  P                  V4       R# )z
Fill in unset topology values, using the passed vcpus count.
If @create is False, this will not set topology from scratch,
just fill in missing topology values.
If @create is True, this will create topology from scratch.
N)r   r   r   )r   r   ZcreaterX   r   set_topology_defaultsZDomainCpu.set_topology_defaults  s*       ""6--e4r   c                sT   V P                   '       g   R # VP                  4       pVP                  P                  R4      pV'       g   R # VP	                  V P                   4      pV'       d   VP
                  R8w  d   R # \        P                  ! RV P                   4       R V n         R # )Nr   ZnozaHost capabilities CPU '%s' is not supported according to domain capabilities. Unsetting CPU model)rc   rZ   rP   Zget_modeZ	get_modelZusabler    r]   )r   rV   rW   Zdomcaps_modeZ	cpu_modelr}   r   !_validate_default_host_model_onlyZ+DomainCpu._validate_default_host_model_only  s     zzz&&({{++H5 **4::6	))T1		DJJ	

 
r   c                s$   VP                   P                  V P                  P                  P                  P
                  P                  8w  d   R # VP                  pV P                  W4       W P                  8X  d   V P                  V4       R # R # r   )
rR   Zarchrm   rn   ro   rP   Zx86_cpu_defaultru   r_   r   )r   rV   r#   r`   r   _set_cpu_x86_kvm_defaultZ"DomainCpu._set_cpu_x86_kvm_default  sg    88==DIINN//33888$$e*4442259 5r   c                s   V P                   P                  4       '       g#   V P                   P                  4       '       g   R # V P                  '       d   R # V P                  '       g   V P
                  '       d   R # VP                  P                  4       '       d%   VP                  R8X  d   V P                  V n        R # VP                  P                  4       '       d%   VP                  R8X  d   V P                  V4       R # VP                  4       pV P                  W4      '       d   V P                  WP                  4       R # R # )NZkvm)rm   Zis_testZis_qemurq   rc   r#   rR   rT   rL   r\   rS   r   rZ   rY   ru   r[   rU   r`   r   set_defaultsZDomainCpu.set_defaults   s    yy  ""499+<+<+>+>$$$:::88##%%%***=::DIXX__5::#6))%0 **,G 00@@%%e-F-FG Ar   )	rg   r   rf   r#   rc   re   r{   rq   rd   N)r#   r   rg   rf   rc   re   model_vendor_idrd   r   r!   rh   cells	latencies
bandwidthsr-   )rz   )F):r   r   r   r   r   r   r   r{   r   r#   r   rg   rf   rc   re   r   rd   r   r   r   r    r!   r'   rh   r:   r   rD   r   rN   r   r,   r-   rq   r_   rj   rl   r^   r\   r[   rk   rb   ZSPECIAL_MODESrY   ra   ru   ry   r|   r~   rp   rw   r   r   r   r   r   r   r   r   r   r   r   rO   rO      sn     HO2 Fy!D
#E
#E_t<J	"E !45N!"67O$F=HY$7E,H Yx@E >TUI!.AWXJ"?dCK !#4 *(*$6!$ ($% 	M1&!)N	*:( 
+-	5.:H Hr   rO   N)Zloggerr    Z
xmlbuilderr   r   r   Z r   r   r    r'   r,   r/   r4   r:   rD   rN   rO   r&   r   r   <module>r      s     B B >`: >`J	"
 	"	&* 	&	/j 	/"
1z 
1,Z ,6.
 .2": "&"Z "4eH
 eHr   