Revision 8b2d1013 lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
55 | 55 |
constants.HV_ACPI, |
56 | 56 |
constants.HV_SERIAL_CONSOLE, |
57 | 57 |
constants.HV_VNC_BIND_ADDRESS, |
58 |
constants.HV_VNC_TLS, |
|
59 |
constants.HV_VNC_X509, |
|
60 |
constants.HV_VNC_X509_VERIFY, |
|
58 | 61 |
] |
59 | 62 |
|
60 | 63 |
_MIGRATION_STATUS_RE = re.compile('Migration\s+status:\s+(\w+)', |
... | ... | |
277 | 280 |
(instance.network_port, |
278 | 281 |
constants.HT_HVM_VNC_BASE_PORT)) |
279 | 282 |
vnc_arg = 'none' |
283 |
|
|
284 |
# Only allow tls and other option when not binding to a file, for now. |
|
285 |
# kvm/qemu gets confused otherwise about the filename to use. |
|
286 |
vnc_append = '' |
|
287 |
if instance.hvparams[constants.HV_VNC_TLS]: |
|
288 |
vnc_append = '%s,tls' % vnc_append |
|
289 |
if instance.hvparams[constants.HV_VNC_X509_VERIFY]: |
|
290 |
vnc_append = '%s,x509verify=%s' % (vnc_append, |
|
291 |
instance.hvparams[constants.HV_VNC_X509]) |
|
292 |
elif instance.hvparams[constants.HV_VNC_X509]: |
|
293 |
vnc_append = '%s,x509=%s' % (vnc_append, |
|
294 |
instance.hvparams[constants.HV_VNC_X509]) |
|
295 |
vnc_arg = '%s%s' % (vnc_arg, vnc_append) |
|
296 |
|
|
280 | 297 |
else: |
281 |
if os.path.isdir(vnc_bind_address): |
|
282 |
vnc_arg = 'unix:%s/%s.vnc' % (vnc_bind_address, instance.name) |
|
283 |
else: |
|
284 |
vnc_arg = 'unix:%s' % vnc_bind_address |
|
298 |
vnc_arg = 'unix:%s/%s.vnc' % (vnc_bind_address, instance.name) |
|
299 |
|
|
285 | 300 |
kvm_cmd.extend(['-vnc', vnc_arg]) |
286 | 301 |
else: |
287 | 302 |
kvm_cmd.extend(['-nographic']) |
... | ... | |
696 | 711 |
" pathname. '%s' given" % |
697 | 712 |
vnc_bind_address) |
698 | 713 |
|
714 |
if hvparams[constants.HV_VNC_X509_VERIFY] and \ |
|
715 |
not hvparams[constants.HV_VNC_X509]: |
|
716 |
raise errors.HypervisorError("%s must be defined, if %s is" % |
|
717 |
(constants.HV_VNC_X509, |
|
718 |
constants.HV_VNC_X509_VERIFY)) |
|
719 |
|
|
720 |
if hvparams[constants.HV_VNC_X509]: |
|
721 |
if not os.path.isabs(hvparams[constants.HV_VNC_X509]): |
|
722 |
raise errors.HypervisorError("The vnc x509 path must an absolute path" |
|
723 |
", if defined") |
|
724 |
|
|
699 | 725 |
def ValidateParameters(self, hvparams): |
700 | 726 |
"""Check the given parameters for validity. |
701 | 727 |
|
... | ... | |
713 | 739 |
if initrd_path and not os.path.isfile(initrd_path): |
714 | 740 |
raise errors.HypervisorError("Instance initrd '%s' not found or" |
715 | 741 |
" not a file" % initrd_path) |
742 |
|
|
743 |
vnc_bind_address = hvparams[constants.HV_VNC_BIND_ADDRESS] |
|
744 |
if vnc_bind_address and not utils.IsValidIP(vnc_bind_address) and \ |
|
745 |
not os.path.isdir(vnc_bind_address): |
|
746 |
raise errors.HypervisorError("Instance vnc bind address must be either" |
|
747 |
" an ip address or an existing directory") |
|
748 |
|
|
749 |
vnc_x509 = hvparams[constants.HV_VNC_X509] |
|
750 |
if vnc_x509 and not os.path.isdir(vnc_x509): |
|
751 |
raise errors.HypervisorError("Instance vnc x509 path '%s' not found" |
|
752 |
" or not a directory" % vnc_x509) |
|
753 |
|
Also available in: Unified diff