+
    h)  c                   s   ^ RI t ^RIHt ^RIHtHt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    N)log)
XMLBuilderXMLChildPropertyXMLPropertyc                   sJ    ] tR t^tRt]! R4      t]! R4      t]! R4      tRt	R# )_CapsCPUcpu./arch./modelz./vendor N)
__name__
__module____qualname____firstlineno__XML_NAMEr   archmodelZvendor__static_attributes__r       0/usr/share/virt-manager/virtinst/capabilities.pyr   r      s%    Hx D	"E$Fr   r   c                   s:    ] tR t^ tRt]! R4      t]! R4      tRtR# )_CapsSecmodelBaselabel	baselabel./@type.r   N)	r	   r
   r   r   r   r   typecontentr   r   r   r   r   r       s    Hy!D#Gr   r   c                   s:    ] tR t^&tRt]! R4      t]! ]4      t	Rt
R# )_CapsSecmodelsecmodelr   r   N)r	   r
   r   r   r   r   r   r   r   
baselabelsr   r   r   r   r   r   &   s    H	"E!"89Jr   r   c                   sN   a  ] tR t^,t o Rt]! ]4      t]! ]RR7      t	R t
RtV tR# )	_CapsHosthostTZ	is_singlec                s   V P                    F  pVP                  R 8w  d   K  RpVP                   F"  pVP                  R9   g   K  VP                  p M	  V'       g   KT   \        VP                  R4      ^ ,          P                  RR4      4      p\        P                  ! V4      ^ ,          pWT3u # 	  R	#   \         d    \        P                  ! RTRR7        K  i ; i)
ZdacNZ:Z+Z z'Exception parsing qemu dac baselabel=%sT)Zexc_info)qemukvm)NN)	secmodelsr   r   r   r   ZintZsplitZreplacepwdZgetpwuidZ	Exceptionr    Zdebug)selfr   Zlabelr   ZuidZusers   &     r   get_qemu_baselabelZ_CapsHost.get_qemu_baselabel1   s    H~~&E%00	>>_4%--E 1 [%++c*1-55c2>?||C(+y / '4   [		CUUYZZ[s   "AB99$C! C!r   N)r	   r
   r   r   r   r   r   r!   r   r   r$   r   __classdictcell__Z__classdict__   @r   r   r   ,   s*     H /I
8t
4C r   r   c                   s:    ] tR t^TtRt]! R4      t]! R4      tRtR# )_CapsMachinemachiner   z./@canonicalr   N)	r	   r
   r   r   r   r   name	canonicalr   r   r   r   r(   r(   T   s    HsDN+Ir   r(   c                   sJ    ] tR t^ZtRt]! R4      t]! R4      t]! ]	4      t
RtR# )_CapsDomaindomainr   z
./emulatorr   N)r	   r
   r   r   r   r   hypervisor_typeemulatorr   r(   machinesr   r   r   r   r,   r,   Z   s%    H!),O<(H-Hr   r,   c                   sj    ] tR t^atRt]! RRR7      t]! RRR7      t]! RRR7      t]! RRR7      t	R	t
R
# )_CapsGuestFeaturesfeaturesz./paeT)Zis_boolz./acpi/@default)Zis_onoffz./apic/@defaultz./externalSnapshotr   N)r	   r
   r   r   r   r   paeacpiapicexternalSnapshotr   r   r   r   r1   r1   a   s;    H
gt
,C(48D(48D"#7Fr   r1   c                   s   a  ] tR t^jt o Rt]! R4      t]! R4      t]! R4      t]! R4      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V tR# )
_CapsGuestguestz	./os_typez./arch/@namez./arch/loaderz./arch/emulatorr   )Zrelative_xpathTr   c                s*   T;'       d    VP                   ;'       g    V P                   p. pV F`  pVP                  VP                  4       VP                  '       g   K2  VP                  V9  g   KE  VP                  VP                  4       Kb  	  V# )zq
Return all machine string names, including canonical aliases for
the guest+domain combo but avoiding duplicates
)r0   appendr*   r+   )r#   r-   mobjsZretms   &&   r   all_machine_namesZ_CapsGuest.all_machine_namesz   sk    
 ++FOO==AJJqvv{{{q{{#5

1;;'  
r   c                s    T;'       d    VP                   ;'       g    V P                   pV F*  pVP                  V8X  g   K  VP                  V8X  g   K)   R# 	  R# )z8
Determine if machine @src is an alias for machine @tgt
TF)r0   r*   r+   )r#   r-   srctgtr:   r;   s   &&&&  r   is_machine_aliasZ_CapsGuest.is_machine_alias   sI     ++FOO==Avv}!3  r   c                sT    V P                    F  pVP                  R8X  g   K   R# 	  R# )z,
Return True if kvm guests can be installed
r    TF)domainsr.   )r#   d   & r   is_kvm_availableZ_CapsGuest.is_kvm_available   s(     A  E)  r   c                @    \        V P                  P                  4      # )z4
Return True if capabilities report support for PAE
)boolr2   r3   r#      &r   supports_paeZ_CapsGuest.supports_pae   s     DMM%%&&r   c                rD   )z5
Return Tree if capabilities report support for ACPI
)rE   r2   r4   rF   rG   r   supports_acpiZ_CapsGuest.supports_acpi        DMM&&''r   c                rD   )z5
Return Tree if capabilities report support for APIC
)rE   r2   r5   rF   rG   r   supports_apicZ_CapsGuest.supports_apic   rJ   r   c                rD   )zC
Return True if capabilities report support for external snapshots
)rE   r2   r6   rF   rG   r   supports_externalSnapshotZ$_CapsGuest.supports_externalSnapshot   s     DMM2233r   r   N)r	   r
   r   r   r   r   os_typer   loaderr/   r   r,   r@   r1   r2   r(   r0   r<   r?   rC   rH   rI   rK   rL   r   r%   r&   r'   r   r7   r7   j   s     H+&G~&D)F,-H{8DG 2dCHXFH'((4 4r   r7   c                   s0   a  ] tR t^t o RtR tR tRtV tR# )	_CapsInfoza
Container object to hold the results of guest_lookup, so users don't
need to juggle two objects
c                s   Wn         W n        W0n        V P                  P                  V n        V P                  P                  V n        V P                  P
                  V n        V P                  P                  V n        V P                  P                  ;'       g    V P                  P                  V n        V P                  P                  V P                  4      V n	        R # N)
connr8   r-   r.   rM   r   rN   r/   r<   r0   )r#   rQ   r8   r-   s   &&&&r   __init__Z_CapsInfo.__init__   s    	
#{{::zz))JJOO	jj'',,CC

0C0C

44T[[Ar   c                sN    V P                   P                  V P                  W4      # rP   )r8   r?   r-   )r#   r=   r>   s   &&&r   r?   Z_CapsInfo.is_machine_alias   s    zz**4;;AAr   )	r   rQ   r-   r/   r8   r.   rN   r0   rM   N)	r	   r
   r   r   Z__doc__rR   r?   r   r%   r&   r'   r   rO   rO      s     
BB Br   rO   c                   sj   a  ] tR t^t o R tRt]! ]RR7      t]! ]	4      t
R tR tR tRR	 ltR
tV tR# )Capabilitiesc                sH    \         P                  ! V .VO5/ VB  / V n        R # rP   )r   rR   _cpu_models_cache)r#   ZargsZkwargss   &*,r   rR   ZCapabilities.__init__   s"    D24262!#r   ZcapabilitiesTr   c                s    V.pVf#   V P                   P                  P                  R .pV FH  pV P                   F5  pVe   VP                  V8X  g   K  Ve   VP                  V8X  g   K1  Vu u # 	  KJ  	  R # rP   )r   r   r   guestsrM   )r#   rM   r   ZarchsZaZgs   &&&   r   _guestForOSTypeZCapabilities._guestForOSType   sb    <YY]]''.EA[[OqyyG';!)qvvYZ{H ! r   c                s^   . pVP                    F\  pV'       d"   VP                  VP                  4       8w  d   K,  V'       d   W1P                  V4      9  d   KK  VP	                  V4       K^  	  V'       g   R# . ROpV F#  pV F  pVP                  V8X  g   K  Vu u # 	  K%  	  VR,          # )zT
Return the recommended domain for use if the user does not explicitly
request one.
N)r    xenZhvfr   i)r@   r.   Zlowerr<   r9   )r#   r8   Zdtyper)   r@   rA   ZpriorityZts   &&&&    r   _bestDomainTypeZCapabilities._bestDomainType   s    
 A**ekkm;7*A*A!*DDNN1  0A$$)H   r{r   c                sV    V P                    F  pVP                  '       g   K   R# 	  R# )z8
Return True if there are any install options available
TF)rU   r@   )r#   r8   rB   r   has_install_optionsZ Capabilities.has_install_options  s#     [[E}}} ! r   Nc           	     sl   VR8X  d   RpV P                  W4      pV'       gx   V'       d    V'       d   \        R4      RVRV/,          pMEV'       d   \        R4      RV/,          pM(V'       d   \        R4      RV/,          pM\        R4      p\        V4      hV P                  WSV4      pVfo   V'       d0   \        R	4      R
VRVP                  RVP
                  RV/,          pM,\        R4      R
VRVP                  RVP
                  /,          p\        V4      h\        V P                  WW4      pV# )a1  
Simple virtualization availability lookup

Convenience function for looking up 'Guest' and 'Domain' capabilities
objects for the desired virt type. If type, arch, or os_type are none,
we return the default virt type associated with those values. These are
typically:

    - os_type : hvm, then xen
    - typ     : kvm over plain qemu
    - arch    : host arch over all others

Otherwise the default will be the first listed in the capabilities xml.
This function throws C{ValueError}s if any of the requested values are
not found.

:param typ: Virtualization type ('hvm', 'xen', ...)
:param arch: Guest architecture ('x86_64', 'i686' ...)
:param os_type: Hypervisor name ('qemu', 'kvm', 'xen', ...)
:param machine: Optional machine type to emulate

:returns: A _CapsInfo object containing the found guest and domain
ZlinuxrW   zTHost does not support virtualization type '%(virttype)s' for architecture '%(arch)s'Zvirttyper   zLHost does not support any virtualization options for architecture '%(arch)s'z8Host does not support virtualization type '%(virttype)s'z0Host does not support any virtualization optionszHost does not support domain type %(domain)s with machine '%(machine)s' for virtualization type '%(virttype)s' with architecture '%(arch)s'r-   r)   zpHost does not support domain type %(domain)s for virtualization type '%(virttype)s' with architecture '%(arch)s')rV   Z_Z
ValueErrorrX   rM   r   rO   rQ   )	r#   rM   r   Ztypr)   r8   Zmsgr-   Zcapsinfos	   &&&&&    r   guest_lookupZCapabilities.guest_lookup  sI   4 gG$$W3A  &$78 2 TN# RSW  JKS/!%%e':>B
 cEJJw			 . sJvuzzR	S
 S/!TYY6r   )rT   )NNNN)r	   r
   r   r   rR   r   r   r   r   r7   rU   rV   rX   rY   rZ   r   r%   r&   r'   r   rS   rS      sB     $ HI6Dj)F6G Gr   rS   )r"   Zloggerr    Z
xmlbuilderr   r   r   r   r   r   r   r(   r,   r1   r7   rO   rS   r   r   r   <module>r[      s      A A%z %Z :J : 
  P,: ,.* .G GF4 F4\B B.C: Cr   