theforeman/foreman · error · Foreman::Exception

VM is not running!

Error message

VM is not running!

What it means

Error "VM is not running!" thrown in theforeman/foreman.

Source

Thrown at app/models/compute_resources/foreman/model/libvirt.rb:184

      vm.save
    rescue Fog::Errors::Error => e
      Foreman::Logging.exception("Unhandled Libvirt error", e)
      begin
        destroy_vm vm.id if vm&.id
      rescue Fog::Errors::Error => destroy_e
        Foreman::Logging.exception("Libvirt destroy failed for #{vm.id}", destroy_e)
      end
      raise e
    end

    def console_password_length(type)
      # use an 8 character password for vnc (which is the allowed maximum) and 16 for everything else
      type == 'vnc' ? 8 : 16
    end

    def console(uuid)
      vm = find_vm_by_uuid(uuid)
      raise Foreman::Exception.new(N_("VM is not running!")) unless vm.ready?
      password = random_password(console_password_length(vm.display[:type]))
      # Listen address cannot be updated while the guest is running
      # When we update the display password, we pass the existing listen address
      vm.update_display(:password => password, :listen => vm.display[:listen], :type => vm.display[:type])
      WsProxy.start(:host => hypervisor.hostname, :host_port => vm.display[:port], :password => password).merge(:type => vm.display[:type], :name => vm.name)
    rescue ::Libvirt::Error => e
      if e.message =~ /cannot change listen address/
        logger.warn e
        Foreman::Exception.new(N_("Unable to change VM display listen address, make sure the display is not attached to localhost only"))
      else
        raise e
      end
    end

    def hypervisor
      client.nodes.first
    end

View on GitHub (pinned to 6b05625475)

When it happens

Trigger: Thrown at app/models/compute_resources/foreman/model/libvirt.rb:184 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of theforeman/foreman@6b05625475 (2026-08-23). Data as JSON: /api/errors/32ee1beaab5b7f58. Report an issue: GitHub.