mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	Correct disk initialisation logic
This commit is contained in:
		
							parent
							
								
									a688c798f5
								
							
						
					
					
						commit
						ed601549c0
					
				
					 1 changed files with 11 additions and 14 deletions
				
			
		
							
								
								
									
										23
									
								
								quickemu
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								quickemu
									
										
									
									
									
								
							|  | @ -53,15 +53,12 @@ function vm_boot() { | ||||||
|   echo "Starting ${VM}" |   echo "Starting ${VM}" | ||||||
|   echo " - QEMU:     ${QEMU} v${QEMU_VER}" |   echo " - QEMU:     ${QEMU} v${QEMU_VER}" | ||||||
| 
 | 
 | ||||||
|   if [ -n "${disk_img}" ]; then |   if [ -z "${disk_img}" ]; then | ||||||
|     disk_img_snapshot="${disk_img}.snapshot" |  | ||||||
|   else |  | ||||||
|     echo "ERROR! No disk_img defined." |     echo "ERROR! No disk_img defined." | ||||||
|     exit 1 |     exit 1 | ||||||
|   fi |   fi | ||||||
| 
 | 
 | ||||||
|   readonly disk_min_size=395264 |   readonly disk_min_size=395264 | ||||||
|   local disk_curr_size=$(stat -c%s "${disk_img}") |  | ||||||
|   if [ -z "${disk}" ]; then |   if [ -z "${disk}" ]; then | ||||||
|     disk="64G" |     disk="64G" | ||||||
|   fi |   fi | ||||||
|  | @ -84,21 +81,21 @@ function vm_boot() { | ||||||
|   echo " - Disk:     ${disk_img} (${disk})" |   echo " - Disk:     ${disk_img} (${disk})" | ||||||
|   if [ ! -f "${disk_img}" ]; then |   if [ ! -f "${disk_img}" ]; then | ||||||
|     # If there is no disk image, create a new image. |     # If there is no disk image, create a new image. | ||||||
|     ${QEMU_IMG} create -q -f qcow2 "${disk_img}" "${disk}" |       ${QEMU_IMG} create -q -f qcow2 "${disk_img}" "${disk}" | ||||||
|       echo "             Just created, booting from ${iso}" |       echo "             Just created, booting from ${iso}" | ||||||
|     if [ $? -ne 0 ]; then |     if [ $? -ne 0 ]; then | ||||||
|       echo "ERROR! Failed to create ${disk_img} of ${disk}. Stopping here." |       echo "ERROR! Failed to create ${disk_img} of ${disk}. Stopping here." | ||||||
|       exit 1 |       exit 1 | ||||||
|     fi |     fi | ||||||
|   elif [ -e ${disk_img} ] && [ ${disk_curr_size} -le ${disk_min_size} ]; then |   elif [ -e ${disk_img} ]; then | ||||||
|  |     disk_curr_size=$(stat -c%s "${disk_img}") | ||||||
|  |     if [ ${disk_curr_size} -le ${disk_min_size} ]; then | ||||||
|       echo "             Looks unused, booting from ${iso}" |       echo "             Looks unused, booting from ${iso}" | ||||||
|   else |     else | ||||||
|     # If there is a disk image, that appears to have an install |       # If there is a disk image, that appears to have an install | ||||||
|     # then do not boot from the iso |       # then do not boot from the iso | ||||||
|     iso="" |       iso="" | ||||||
|   fi |     fi | ||||||
|   if [ -e ${disk_img_snapshot} ]; then |  | ||||||
|     echo " - Snapshot: ${disk_img_snapshot}" |  | ||||||
|   fi |   fi | ||||||
| 
 | 
 | ||||||
|   local cores="1" |   local cores="1" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue