Migration to libvirt - HVM
This commit is contained in:
		
							rodzic
							
								
									f3a7d5f6e6
								
							
						
					
					
						commit
						f44dc40858
					
				| @ -29,12 +29,12 @@ import subprocess | ||||
| import stat | ||||
| import sys | ||||
| import re | ||||
| 
 | ||||
| from qubes.qubes import QubesVm,register_qubes_vm_class,xs,xc,dry_run | ||||
| from qubes.qubes import QubesException,QubesVmCollection | ||||
| import stat | ||||
| from qubes.qubes import QubesVm,register_qubes_vm_class,xs,dry_run | ||||
| from qubes.qubes import system_path,defaults | ||||
| from qubes.qubes import QubesException | ||||
| 
 | ||||
| system_path["config_template_hvm"] = '/usr/share/qubes/vm-template-hvm.conf' | ||||
| system_path["config_template_hvm"] = '/usr/share/qubes/vm-template-hvm.xml' | ||||
| 
 | ||||
| defaults["hvm_disk_size"] = 20*1024*1024*1024 | ||||
| defaults["hvm_private_img_size"] = 2*1024*1024*1024 | ||||
| @ -285,40 +285,26 @@ class QubesHVm(QubesVm): | ||||
| 
 | ||||
|         params['volatiledev'] = '' | ||||
|         if self.drive: | ||||
|             type_mode = ":cdrom,r" | ||||
|             (drive_type, drive_domain, drive_path) = self.drive.split(":") | ||||
|             if drive_type == "hd": | ||||
|                 type_mode = ",w" | ||||
|             elif drive_type == "cdrom": | ||||
|                 type_mode = ":cdrom,r" | ||||
|             # leave empty to use standard syntax in case of dom0 | ||||
|             if drive_domain.lower() == "dom0": | ||||
|                 backend_domain = "" | ||||
|             else: | ||||
|                 backend_domain = "," + drive_domain | ||||
|                 drive_domain = None | ||||
| 
 | ||||
|             params['otherdevs'] = self._format_disk_dev(drive_path, None, "xvdc", | ||||
|                     rw=True if type == "disk" else False, type=type, | ||||
|                     domain=backend_domain) | ||||
| 
 | ||||
|             # FIXME: os.stat will work only when backend in dom0... | ||||
|             stat_res = None | ||||
|             if backend_domain == "": | ||||
|                 stat_res = os.stat(drive_path) | ||||
|             if stat_res and stat.S_ISBLK(stat_res.st_mode): | ||||
|                 params['otherdevs'] = "'phy:%s,xvdc%s%s'," % ( | ||||
|                     drive_path, type_mode, backend_domain) | ||||
|             else: | ||||
|                 params['otherdevs'] = "'script:file:%s,xvdc%s%s'," % ( | ||||
|                     drive_path, type_mode, backend_domain) | ||||
|         else: | ||||
|              params['otherdevs'] = '' | ||||
| 
 | ||||
|         if self.timezone.lower() == 'localtime': | ||||
|              params['localtime'] = '1' | ||||
|              params['time_basis'] = 'localtime' | ||||
|              params['timeoffset'] = '0' | ||||
|         elif self.timezone.isdigit(): | ||||
|             params['localtime'] = '0' | ||||
|             params['time_basis'] = 'UTC' | ||||
|             params['timeoffset'] = self.timezone | ||||
|         else: | ||||
|             print >>sys.stderr, "WARNING: invalid 'timezone' value: %s" % self.timezone | ||||
|             params['localtime'] = '0' | ||||
|             params['time_basis'] = 'UTC' | ||||
|             params['timeoffset'] = '0' | ||||
|         return params | ||||
| 
 | ||||
| @ -434,6 +420,7 @@ class QubesHVm(QubesVm): | ||||
|     def start_stubdom_guid(self): | ||||
|         cmdline = [system_path["qubes_guid_path"], | ||||
|                 "-d", str(self.stubdom_xid), | ||||
|                 "-t", str(self.xid), | ||||
|                 "-c", self.label.color, | ||||
|                 "-i", self.label.icon_path, | ||||
|                 "-l", str(self.label.index)] | ||||
| @ -532,20 +519,6 @@ class QubesHVm(QubesVm): | ||||
| 
 | ||||
|         self.pause() | ||||
| 
 | ||||
|     def pause(self): | ||||
|         if dry_run: | ||||
|             return | ||||
| 
 | ||||
|         xc.domain_pause(self.stubdom_xid) | ||||
|         super(QubesHVm, self).pause() | ||||
| 
 | ||||
|     def unpause(self): | ||||
|         if dry_run: | ||||
|             return | ||||
| 
 | ||||
|         xc.domain_unpause(self.stubdom_xid) | ||||
|         super(QubesHVm, self).unpause() | ||||
| 
 | ||||
|     def is_guid_running(self): | ||||
|         # If user force the guiagent, is_guid_running will mimic a standard QubesVM | ||||
|         if self.guiagent_installed: | ||||
|  | ||||
| @ -171,7 +171,7 @@ mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/dvmdata | ||||
| 
 | ||||
| mkdir -p $RPM_BUILD_ROOT/usr/share/qubes | ||||
| cp xen-vm-config/vm-template.xml $RPM_BUILD_ROOT/usr/share/qubes/xen-vm-template.xml | ||||
| cp xen-vm-config/vm-template-hvm.conf $RPM_BUILD_ROOT/usr/share/qubes/ | ||||
| cp xen-vm-config/vm-template-hvm.xml $RPM_BUILD_ROOT/usr/share/qubes/ | ||||
| 
 | ||||
| mkdir -p $RPM_BUILD_ROOT/usr/bin | ||||
| 
 | ||||
| @ -320,7 +320,7 @@ fi | ||||
| %attr(0770,root,qubes) %dir /var/lib/qubes/dvmdata | ||||
| %attr(0770,root,qubes) %dir /var/lib/qubes/vm-kernels | ||||
| /usr/share/qubes/xen-vm-template.xml | ||||
| /usr/share/qubes/vm-template-hvm.conf | ||||
| /usr/share/qubes/vm-template-hvm.xml | ||||
| /usr/bin/xenstore-watch-qubes | ||||
| /usr/lib/qubes/qubes-restore | ||||
| /usr/lib/qubes/qubes-prepare-saved-domain.sh | ||||
|  | ||||
| @ -1,39 +0,0 @@ | ||||
| # | ||||
| # This is a Xen VM config file for Qubes VM | ||||
| # DO NOT EDIT - autogenerated by qubes tools | ||||
| # | ||||
| 
 | ||||
| name = "{name}" | ||||
| 
 | ||||
| builder='hvm' | ||||
| memory={mem} | ||||
| viridian=1 | ||||
| kernel='hvmloader' | ||||
| stdvga=1 | ||||
| #acpi=1 | ||||
| #apic=1 | ||||
| boot='dca' | ||||
| device_model='stubdom-dm' | ||||
| #pae=1 | ||||
| usbdevice='tablet' | ||||
| sdl=0 | ||||
| vnc=0 | ||||
| localtime = {localtime} | ||||
| rtc_timeoffset = {timeoffset} | ||||
| disk = [ {rootdev} | ||||
|          {privatedev} | ||||
|          {otherdevs} | ||||
|        ] | ||||
| vif = [ {netdev} ] | ||||
| pci = [ {pcidev} ] | ||||
| vcpus = {vcpus} | ||||
| 
 | ||||
| #tsc_mode = 2 | ||||
| #xen_extended_power_mgmt=0 | ||||
| 
 | ||||
| on_poweroff = 'destroy' | ||||
| on_reboot   = 'destroy' | ||||
| on_crash    = 'destroy' | ||||
| 
 | ||||
| # Use of DNS2 as DHCP server IP makes DNS2 not accessible, but DNS1 still should work | ||||
| {disable_network}device_model_args = [ '-net', 'lwip,client_ip={ip},server_ip={dns2},dns={dns1},gw={gateway},netmask={netmask}' ] | ||||
							
								
								
									
										30
									
								
								xen-vm-config/vm-template-hvm.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								xen-vm-config/vm-template-hvm.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| <domain type='xen'> | ||||
|     <name>{name}</name> | ||||
|     <memory unit='MiB'>{maxmem}</memory> | ||||
|     <currentMemory unit='MiB'>{mem}</currentMemory> | ||||
|     <vcpu placement='static'>{vcpus}</vcpu> | ||||
|   <os> | ||||
|     <type arch='x86_64' machine='xenfv'>hvm</type> | ||||
|     <loader>hvmloader</loader> | ||||
|     <boot dev='cdrom'/> | ||||
|     <boot dev='hd'/> | ||||
|     {disable_network1}<cmdline>-net lwip,client_ip={ip},server_ip={dns2},dns={dns1},gw={gateway},netmask={netmask}</cmdline>{disable_network2} | ||||
|   </os> | ||||
|   <features> | ||||
|     <viridian/> | ||||
|   </features> | ||||
|   <clock offset='variable' adjustment='{timeoffset}' basis='{time_basis}'/> | ||||
|   <on_poweroff>destroy</on_poweroff> | ||||
|   <on_reboot>destroy</on_reboot> | ||||
|   <on_crash>destroy</on_crash> | ||||
|   <devices> | ||||
|     <emulator>stubdom-dm</emulator> | ||||
| {rootdev} | ||||
| {privatedev} | ||||
| {otherdevs} | ||||
| {netdev} | ||||
| {pcidevs} | ||||
|     <input type='tablet' bus='usb'/> | ||||
|   </devices> | ||||
| </domain> | ||||
| 
 | ||||
		Ładowanie…
	
		Reference in New Issue
	
	Block a user
	 Marek Marczykowski
						Marek Marczykowski