Revision a985b417 lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
235 | 235 |
if not instance.hvparams[constants.HV_ACPI]: |
236 | 236 |
kvm_cmd.extend(['-no-acpi']) |
237 | 237 |
|
238 |
boot_disk = (instance.hvparams[constants.HV_BOOT_ORDER] == "disk") |
|
239 |
boot_cdrom = (instance.hvparams[constants.HV_BOOT_ORDER] == "cdrom") |
|
240 |
boot_network = (instance.hvparams[constants.HV_BOOT_ORDER] == "network") |
|
238 |
hvp = instance.hvparams |
|
239 |
boot_disk = hvp[constants.HV_BOOT_ORDER] == "disk" |
|
240 |
boot_cdrom = hvp[constants.HV_BOOT_ORDER] == "cdrom" |
|
241 |
boot_network = hvp[constants.HV_BOOT_ORDER] == "network" |
|
241 | 242 |
|
242 | 243 |
if boot_network: |
243 | 244 |
kvm_cmd.extend(['-boot', 'n']) |
244 | 245 |
|
245 |
disk_type = instance.hvparams[constants.HV_DISK_TYPE]
|
|
246 |
disk_type = hvp[constants.HV_DISK_TYPE]
|
|
246 | 247 |
if disk_type == constants.HT_DISK_PARAVIRTUAL: |
247 | 248 |
if_val = ',if=virtio' |
248 | 249 |
else: |
... | ... | |
263 | 264 |
drive_val = 'file=%s,format=raw%s%s' % (dev_path, if_val, boot_val) |
264 | 265 |
kvm_cmd.extend(['-drive', drive_val]) |
265 | 266 |
|
266 |
iso_image = instance.hvparams[constants.HV_CDROM_IMAGE_PATH]
|
|
267 |
iso_image = hvp[constants.HV_CDROM_IMAGE_PATH]
|
|
267 | 268 |
if iso_image: |
268 | 269 |
options = ',format=raw,media=cdrom' |
269 | 270 |
if boot_cdrom: |
... | ... | |
274 | 275 |
drive_val = 'file=%s%s' % (iso_image, options) |
275 | 276 |
kvm_cmd.extend(['-drive', drive_val]) |
276 | 277 |
|
277 |
kernel_path = instance.hvparams[constants.HV_KERNEL_PATH]
|
|
278 |
kernel_path = hvp[constants.HV_KERNEL_PATH]
|
|
278 | 279 |
if kernel_path: |
279 | 280 |
kvm_cmd.extend(['-kernel', kernel_path]) |
280 |
initrd_path = instance.hvparams[constants.HV_INITRD_PATH]
|
|
281 |
initrd_path = hvp[constants.HV_INITRD_PATH]
|
|
281 | 282 |
if initrd_path: |
282 | 283 |
kvm_cmd.extend(['-initrd', initrd_path]) |
283 | 284 |
root_append = 'root=%s ro' % instance.hvparams[constants.HV_ROOT_PATH] |
... | ... | |
286 | 287 |
else: |
287 | 288 |
kvm_cmd.extend(['-append', root_append]) |
288 | 289 |
|
289 |
mouse_type = instance.hvparams[constants.HV_USB_MOUSE]
|
|
290 |
mouse_type = hvp[constants.HV_USB_MOUSE]
|
|
290 | 291 |
if mouse_type: |
291 | 292 |
kvm_cmd.extend(['-usb']) |
292 | 293 |
kvm_cmd.extend(['-usbdevice', mouse_type]) |
293 | 294 |
|
294 | 295 |
# FIXME: handle vnc password |
295 |
vnc_bind_address = instance.hvparams[constants.HV_VNC_BIND_ADDRESS]
|
|
296 |
vnc_bind_address = hvp[constants.HV_VNC_BIND_ADDRESS]
|
|
296 | 297 |
if vnc_bind_address: |
297 | 298 |
if utils.IsValidIP(vnc_bind_address): |
298 | 299 |
if instance.network_port > constants.VNC_BASE_PORT: |
... | ... | |
311 | 312 |
# Only allow tls and other option when not binding to a file, for now. |
312 | 313 |
# kvm/qemu gets confused otherwise about the filename to use. |
313 | 314 |
vnc_append = '' |
314 |
if instance.hvparams[constants.HV_VNC_TLS]:
|
|
315 |
if hvp[constants.HV_VNC_TLS]:
|
|
315 | 316 |
vnc_append = '%s,tls' % vnc_append |
316 |
if instance.hvparams[constants.HV_VNC_X509_VERIFY]:
|
|
317 |
if hvp[constants.HV_VNC_X509_VERIFY]:
|
|
317 | 318 |
vnc_append = '%s,x509verify=%s' % (vnc_append, |
318 |
instance.hvparams[constants.HV_VNC_X509])
|
|
319 |
elif instance.hvparams[constants.HV_VNC_X509]:
|
|
319 |
hvp[constants.HV_VNC_X509])
|
|
320 |
elif hvp[constants.HV_VNC_X509]:
|
|
320 | 321 |
vnc_append = '%s,x509=%s' % (vnc_append, |
321 |
instance.hvparams[constants.HV_VNC_X509])
|
|
322 |
hvp[constants.HV_VNC_X509])
|
|
322 | 323 |
vnc_arg = '%s%s' % (vnc_arg, vnc_append) |
323 | 324 |
|
324 | 325 |
else: |
... | ... | |
331 | 332 |
monitor_dev = 'unix:%s,server,nowait' % \ |
332 | 333 |
self._InstanceMonitor(instance.name) |
333 | 334 |
kvm_cmd.extend(['-monitor', monitor_dev]) |
334 |
if instance.hvparams[constants.HV_SERIAL_CONSOLE]: |
|
335 |
serial_dev = 'unix:%s,server,nowait' % self._InstanceSerial(instance.name) |
|
335 |
if hvp[constants.HV_SERIAL_CONSOLE]: |
|
336 |
serial_dev = ('unix:%s,server,nowait' % |
|
337 |
self._InstanceSerial(instance.name)) |
|
336 | 338 |
kvm_cmd.extend(['-serial', serial_dev]) |
337 | 339 |
else: |
338 | 340 |
kvm_cmd.extend(['-serial', 'none']) |
... | ... | |
340 | 342 |
# Save the current instance nics, but defer their expansion as parameters, |
341 | 343 |
# as we'll need to generate executable temp files for them. |
342 | 344 |
kvm_nics = instance.nics |
343 |
hvparams = instance.hvparams
|
|
345 |
hvparams = hvp
|
|
344 | 346 |
|
345 | 347 |
return (kvm_cmd, kvm_nics, hvparams) |
346 | 348 |
|
Also available in: Unified diff