+
    h  c                   sh    ^ RI t ^RIHt ^RIHt ^RIHt ^RIHtH	t	 R t
 ! R R4      tR	 tR
 tR# )i    N)progress)
DeviceDisk)log)StoragePoolStorageVolumec                s   \         P                  ! W4      pV'       dA   \        P                  ! RVP	                  4       V4       \         P
                  ! VRR7       V# \         P                  ! V R4      p\        P                  ! RW$4       \        V 4      pVP                  Vn        WEn        W%n	        VP                  VRRRR7      pV# )zf
Helper function for building a pool on demand. Used for building
a scratchdir pool for volume upload
zExisting pool '%s' found for %sT)Zrefreshzboot-scratchz&Building storage pool: path=%s name=%sF)meterZcreateZbuildZ	autostart)r   Zlookup_pool_by_pathr   debugnameZensure_pool_is_runningfind_free_nameZTYPE_DIRZtypeZtarget_pathZinstall)connr   pathpoolr   Z	poolbuildrets   &&&    8/usr/share/virt-manager/virtinst/install/volumeupload.py_build_poolr      s    
 **46D		3TYY[$G**4>%%dN;DII6CD!I''INN  

%ET

RCJ    c                   s0   a  ] tR t^'t o RtR tR tRtV tR# )_MockStreamNc                s    V P                   f   \        V4      V n         ^p\        V P                   V4      p\        ^ V P                   V,
          4      V n         V# N)
_data_sizelenZminZmax)selfdataZ
block_sizer   s   &&  r   sendZ_MockStream.send*   sH    ??"!$iDO
$//:.a:!=>
r   c                s    R # r    )r   s   &r   finishZ_MockStream.finish3   s    r   )r   )	Z__name__Z
__module__Z__qualname__Z__firstlineno__r   r   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r   '   s     J r   r   c                s  a V P                  4       '       d   \        4       oMV P                  ^ 4      oV3R lp\        P                  ! V4      p\
        P                  P                  V4      p\
        P                  P                  V4      p\        P                  ! WV4      p\        P                  ! RV4       \        P                  ! WV\        V4      R,          R,          R,          R4      p\        V 4      p	V	P!                  V4       V	P#                  4        V	P%                  V4       V	P'                  4       p
V
'       g   \)        R4      h ^ pTp^ pV P                  4       '       g   V
P+                  SWV4       \-        VR4      p^ p\/        R4      R\
        P                  P                  V4      /,          pVP1                  VV4        R	pVP3                  V4      pV'       g   M-V! V4       V\5        V4      ,          pVP7                  V4       KJ  SP9                  4        VP;                  4        V
#   \<         d    T
P?                  ^ 4       h i ; i)
z~
Helper for uploading a file to a pool, via libvirt. Used for
kernel/initrd upload when we can't access the system scratchdir
c                 sf   <  SP                  V 4      pV^ 8X  g   V\        V 4      8X  d   R# WR p K1  )TN)r   r   )r   r   streams   & r   	safe_sendZ_upload_file.<locals>.safe_sendB   s2    ++d#Cax3#d)+:Dr   zGenerated volume name %sg      @Tz%Failed to lookup scratch media volumeZrbzTransferring '%(filename)s'Zfilenamei   ) Zin_testsuiter   Z	newStreamr    Zensure_meterosr
   Zgetsizebasenamer   r   r   r   r   Zbuild_vol_installZfloatZset_vol_installZvalidateZbuild_storageZget_vol_objectZRuntimeErrorZuploadZopenZ_ZstartZreadr   Zupdater   Zend	Exceptiondelete)r	   r   ZdestpoolZsrcr   Zsizer   r   Zvol_installZdiskvolZoffsetZlengthZflagsZfileobjZtotalZmsgZ	blocksizer   r   s   &&&&               @r   _upload_filer    7   s    " !!%(E 77??3Dww$H''ADII($/..HuT{V3f<vEK dD%MMOu



CBCC  ""JJvvu5 sD/ -.*bgg>N>Ns>S1TTC#I<<	*DdOSYELL 			
 J	  

1s   I  0CI   Ic                s4   \         P                  ! R4       \        WV4      p. p. p V F?  p\        WWG4      pVP	                  VP                  4       4       VP	                  V4       KA  	  We3#   \         d    T F  pTP                  ^ 4       K  	  h i ; i)z2
Upload passed paths to the connection scratchdir
zUploading kernel/initrd media)r   r   r   r    Zappendr
   r   r   )	r	   Zsystem_scratchdirr   Zpathlistr   ZtmpvolsZnewpathsr
   r   s	   &&&&     r   upload_pathsr!      s    
 II-.t$56DGHDtD7COOCHHJ'NN3    CJJqM s   AA0 0'B)r   Z r    Zdevicesr   Zloggerr   Zstorager   r   r   r   r    r!   r   r   r   <module>r"      s1    
     00  GTr   