{"record":{"id":"32ee1beaab5b7f58","repo":"theforeman/foreman","slug":"vm-is-not-running","errorCode":null,"errorMessage":"VM is not running!","messagePattern":"VM is not running!","errorType":"exception","errorClass":"Foreman::Exception","httpStatus":null,"severity":"error","filePath":"app/models/compute_resources/foreman/model/libvirt.rb","lineNumber":184,"sourceCode":"      vm.save\n    rescue Fog::Errors::Error => e\n      Foreman::Logging.exception(\"Unhandled Libvirt error\", e)\n      begin\n        destroy_vm vm.id if vm&.id\n      rescue Fog::Errors::Error => destroy_e\n        Foreman::Logging.exception(\"Libvirt destroy failed for #{vm.id}\", destroy_e)\n      end\n      raise e\n    end\n\n    def console_password_length(type)\n      # use an 8 character password for vnc (which is the allowed maximum) and 16 for everything else\n      type == 'vnc' ? 8 : 16\n    end\n\n    def console(uuid)\n      vm = find_vm_by_uuid(uuid)\n      raise Foreman::Exception.new(N_(\"VM is not running!\")) unless vm.ready?\n      password = random_password(console_password_length(vm.display[:type]))\n      # Listen address cannot be updated while the guest is running\n      # When we update the display password, we pass the existing listen address\n      vm.update_display(:password => password, :listen => vm.display[:listen], :type => vm.display[:type])\n      WsProxy.start(:host => hypervisor.hostname, :host_port => vm.display[:port], :password => password).merge(:type => vm.display[:type], :name => vm.name)\n    rescue ::Libvirt::Error => e\n      if e.message =~ /cannot change listen address/\n        logger.warn e\n        Foreman::Exception.new(N_(\"Unable to change VM display listen address, make sure the display is not attached to localhost only\"))\n      else\n        raise e\n      end\n    end\n\n    def hypervisor\n      client.nodes.first\n    end\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/theforeman/foreman/blob/6b05625475cfe6aac31a88f8c8ee6e62e4efe620/app/models/compute_resources/foreman/model/libvirt.rb#L166-L202","documentation":"Error \"VM is not running!\" thrown in theforeman/foreman.","triggerScenarios":"Thrown at app/models/compute_resources/foreman/model/libvirt.rb:184 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6b05625475cfe6aac31a88f8c8ee6e62e4efe620","analyzedAt":"2026-08-23T17:46:34.094Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}