
    W'Fgh                         S SK JrJrJr   " S S\5      r " S S\5      r " S S\5      r " S S	\5      r " S
 S\5      r " S S\5      r	g)   )
XMLBuilderXMLChildPropertyXMLPropertyc                   T    \ rS rSrSrSr\" SSS9r\" SSS9r\" SSS9r	\" S	SS9r
S
rg)DeviceVirtioDriver   z+
Represents shared virtio <driver> options
driverz./@atsTis_onoffz./@iommuz	./@packedz./@page_per_vq N)__name__
__module____qualname____firstlineno____doc__XML_NAMEr   atsiommupackedpage_per_vq__static_attributes__r       2/usr/share/virt-manager/virtinst/devices/device.pyr   r      s?     H
h
.C
T2Et4F.>Kr   r   c                   J    \ rS rSrSrSr\" S5      r\" SSS9r\" S5      r	S	r
g
)DeviceSeclabel   z2
Minimal seclabel that's used for device sources.
seclabelz./@modelz
./@relabelT)is_yesnoz./labelr   N)r   r   r   r   r   r   r   modelrelabellabelr   r   r   r   r   r      s.     H
#E,6G	"Er   r   c                   (    \ rS rSrSr\" S5      rSrg)DeviceAlias!   aliasz./@namer   N)r   r   r   r   r   r   namer   r   r   r   r#   r#   !   s    Hy!Dr   r#   c                   6    \ rS rSrSr\" SSS9r\" S5      rSrg)	
DeviceBoot&   bootz./@orderTis_intz./@loadparmr   N)	r   r   r   r   r   r   orderloadparmr   r   r   r   r(   r(   &   s    H
40E=)Hr   r(   c                   \   \ rS rSrSrSrSrSrSrSr	Sr
/ S	QrS
 r\" S5      r\" SSS9r\" SSS9r\" SSS9r\" SSS9r\" SSS9r\" S5      r\" S5      r\" SSS9r\" SSS9r\" SSS9r\" SSS9r\" S5      r\" S5      r\" S5      r\" S5      r\" S5      r\" S5      r\" S 5      r S!r!g")#DeviceAddress,   z
Examples:
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
<address type='drive' controller='0' bus='0' unit='0'/>
<address type='ccid' controller='0' slot='0'/>
<address type='virtio-serial' controller='1' bus='0' port='4'/>
pcidrivezvirtio-serialccidz	spapr-vioaddress)	typedomain
controllerbusslotfunctiontargetunitmultifunctionc                     S nU R                   U R                  :X  a9  U R                  < SU R                  < SU R                  < SU R
                  < 3nU$ )N:)r6   ADDRESS_TYPE_DRIVEr8   r9   r<   r=   )selfpretty_descs     r   rC   DeviceAddress.pretty_desc?   s@    99///!__dhhTYYPKr   z./@typez	./@domainTr+   z./@busz./@slotz./@functionz./@multifunctionr
   z./zpci/@uidz./zpci/@fidz./@controllerz./@unitz./@portz	./@targetz./@regz./@cssidz./@ssidz./@devnoz	./@iobasez./@irqz./@baser   N)"r   r   r   r   r   ADDRESS_TYPE_PCIrA   ADDRESS_TYPE_VIRTIO_SERIALADDRESS_TYPE_CCIDADDRESS_TYPE_SPAPR_VIOr   _XML_PROP_ORDERrC   r   r6   r7   r9   r:   r;   r>   zpci_uidzpci_fidr8   r=   portr<   regcssidssiddevnoiobaseirqbaser   r   r   r   r0   r0   ,   s    "'!(!0!'!,HFO y!DT2F
ht
,Cy.D=6H 2TBM=)H=)H_T:Jy.Dy.DT2F
h
C
#Ey!D
#E%F
h
Cy!Dr   r0   c                   l    \ rS rSrSrS r\" \SS9r\" \	SS9r
\" \SS9r\" \SS9r\S 5       rS rSrg	)
Deviceb   z/
Base class for all domain xml device objects.
c                 d    [         R                  " U /UQ70 UD6  U R                  / SQ-   U l        g)zU
Initialize device state

:param conn: libvirt connection to validate device against
)virtio_driverr%   r5   N)r   __init__rI   )rB   argskwargss      r   rY   Device.__init__f   s4     	D24262#33 75  5r   T)	is_singlec                     U R                   $ )N)r   )rB   s    r   DEVICE_TYPEDevice.DEVICE_TYPEu   s    }}r   c           	      n   0 SSS/_SSS/_S/ SQ_S	S
S/_SSS/_SS
S/_SS
S/_S/ SQ_SSS/_SSS/_S/ SQ_SSS/_SSS/_SSS/_SSS/_SSS/_S/ SQ_SS/S S/S
S/S!S/S
S/S
S/S
S/S".En[        U 5      [        U5      :X  a  g#[        U [        U5      5      (       d  g$U R                  U;  a  g$S%UR	                  5       ;   =(       a    S%U R	                  5       ;   nX0R                      HB  nUS:X  a  U(       d  M  U R                  5       nUnO[        X5      n[        X5      nXg:w  d  MB    g$   g#)&a?  
Attempt to compare this device against the passed @newdev,
using various heuristics. For example, when removing a device
from both active and inactive XML, the device XML my be very
different or the devices may appear in different orders, so
we have to do some fuzzy matching to determine if the devices
are a 'match'
diskr<   r9   	interfacemacaddrxmlindexinput)r9   r6   re   soundr   audior6   idvideowatchdoghostdev)r6   managedre   productvendorr;   r7   r:   serialtarget_portparallelconsole)r6   target_typerq   graphicsr8   indexchanneltarget_name
filesystem	smartcardmoderedirdevbackend_modelr&   )tpmrngpanicshmemvsock
memballoonr   TFdevices)ri   
isinstancer6   r_   
get_xml_idget_xml_idxgetattr)rB   newdevidxdevpropscan_check_xmldevproporigvalnewvals           r   compare_deviceDevice.compare_devicey   s   
h.
i4
 8
 gz2	

 fd^
 gz2
 gz2
  <
 fm4
 fm4
 C
 fj1
 fg.
  fm4!
" h
3#
$ fj1%
& 8'
( %j1-z:%z2$j1%z2%z2%z25
: d8r&z!$V--8+
 #f&7&7&99 /T__.. 	   0 01G*$$**,!$0 1  2 r   )rI   N)r   r   r   r   r   rY   r   r#   r%   r0   r5   r(   r*   r   rX   propertyr_   r   r   r   r   r   rU   rU   b   sW    5 [D9E}=GJ$7D$%74HM Br   rU   N)

xmlbuilderr   r   r   r   r   r#   r(   r0   rU   r   r   r   <module>r      sY    C B? ?#Z #"* "
* *3"J 3"lYZ Yr   