Revision d6e5767e lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
460 460
    constants.HV_ACPI: hv_base.NO_CHECK,
461 461
    constants.HV_SERIAL_CONSOLE: hv_base.NO_CHECK,
462 462
    constants.HV_SERIAL_SPEED: hv_base.NO_CHECK,
463
    constants.HV_VNC_BIND_ADDRESS:
464
      (False, lambda x: (netutils.IP4Address.IsValid(x) or
465
                         utils.IsNormAbsPath(x)),
466
       "The VNC bind address must be either a valid IP address or an absolute"
467
       " pathname", None, None),
463
    constants.HV_VNC_BIND_ADDRESS: hv_base.NO_CHECK, # will be checked later
468 464
    constants.HV_VNC_TLS: hv_base.NO_CHECK,
469 465
    constants.HV_VNC_X509: hv_base.OPT_DIR_CHECK,
470 466
    constants.HV_VNC_X509_VERIFY: hv_base.NO_CHECK,
......
1230 1226
      kvm_cmd.extend(["-usbdevice", constants.HT_MOUSE_TABLET])
1231 1227

  
1232 1228
    if vnc_bind_address:
1229
      if netutils.IsValidInterface(vnc_bind_address):
1230
        if_addresses = netutils.GetInterfaceIpAddresses(vnc_bind_address)
1231
        if_ip4_addresses = if_addresses[constants.IP4_VERSION]
1232
        if len(if_ip4_addresses) < 1:
1233
          logging.error("Could not determine IPv4 address of interface %s",
1234
                        vnc_bind_address)
1235
        else:
1236
          vnc_bind_address = if_ip4_addresses[0]
1233 1237
      if netutils.IP4Address.IsValid(vnc_bind_address):
1234 1238
        if instance.network_port > constants.VNC_BASE_PORT:
1235 1239
          display = instance.network_port - constants.VNC_BASE_PORT
......
2168 2172
      except KeyError:
2169 2173
        raise errors.HypervisorError("Unknown security domain user %s"
2170 2174
                                     % username)
2175
    vnc_bind_address = hvparams[constants.HV_VNC_BIND_ADDRESS]
2176
    if vnc_bind_address:
2177
      bound_to_addr = netutils.IP4Address.IsValid(vnc_bind_address)
2178
      is_interface = netutils.IsValidInterface(vnc_bind_address)
2179
      is_path = utils.IsNormAbsPath(vnc_bind_address)
2180
      if not bound_to_addr and not is_interface and not is_path:
2181
        raise errors.HypervisorError("VNC: The %s parameter must be either"
2182
                                     " a valid IP address, an interface name,"
2183
                                     " or an absolute path" %
2184
                                     constants.HV_KVM_SPICE_BIND)
2171 2185

  
2172 2186
    spice_bind = hvparams[constants.HV_KVM_SPICE_BIND]
2173 2187
    if spice_bind:

Also available in: Unified diff