PRL_RESULT Task_VzManager::mount_env() { CProtoCommandPtr cmd = CProtoSerializer::ParseCommand( getRequestPackage()); if ( ! cmd->IsValid() ) return PRL_ERR_FAILURE; PRL_RESULT res; QString sUuid = cmd->GetVmUuid(); res = check_env_state(PVE::DspCmdVmMount, sUuid); if (PRL_FAILED(res)) return res; bool infoMode = (cmd->GetCommandFlags() & PMVD_INFO); if (infoMode) { SmartPtr<CVmConfiguration> pConfig = getVzHelper()->getCtConfig(getClient(), sUuid); if (!pConfig) return PRL_ERR_VM_GET_CONFIG_FAILED; Prl::Expected<QString, PRL_RESULT> info = get_op_helper()->get_env_mount_info(pConfig); if (info.isFailed()) return info.error(); getResponseCmd()->AddStandardParam(info.value()); } else { res = get_op_helper()->mount_env(sUuid); } return res; }
PRL_RESULT Task_ChangeSID::run_changeSID_cmd(Libvirt::Instrument::Agent::Vm::Unit& u) { Libvirt::Instrument::Agent::Vm::Exec::Request request("%programfiles%\\Qemu-ga\\prl_newsid.exe", QList<QString>()); request.setRunInShell(true); Prl::Expected <Libvirt::Instrument::Agent::Vm::Exec::Result, Error::Simple> e = u.getGuest().runProgram(request); QString uuid; u.getUuid(uuid); if (e.isFailed()) { return CDspTaskFailure(*this)(e.error().convertToEvent()); } if (e.value().exitcode != 0) { QString err = QString("prl_newsid return error %1 for VM '%2' message '%3'") .arg(e.value().exitcode) .arg(uuid) .arg(QString::fromUtf8(e.value().stdErr)); WRITE_TRACE(DBG_FATAL, qPrintable(err)); return CDspTaskFailure(*this)(PRL_ERR_CHANGESID_FAILED, err); } return PRL_ERR_SUCCESS; }
PRL_RESULT Task_ChangeSID::change_sid(Libvirt::Instrument::Agent::Vm::Unit& u) { unsigned int i; WRITE_TRACE(DBG_DEBUG, "Wait for tools..."); jobProgressEvent(5); for (i = 0; i < WAITTOOLS_TIMEOUT / WAITINTERVAL; i++) { if (operationIsCancelled()) return PRL_ERR_OPERATION_WAS_CANCELED; // handle Vm start failure VIRTUAL_MACHINE_STATE state = VMS_UNKNOWN; u.getState(state); if (state != VMS_RUNNING) { WRITE_TRACE(DBG_FATAL, "Vm start failed, state changed to stopped"); return PRL_ERR_CHANGESID_VM_START_FAILED; } Prl::Expected<QString, Error::Simple> e = u.getGuest().getAgentVersion(); if (e.isSucceed()) { WRITE_TRACE(DBG_DEBUG, "Tools ready"); break; } HostUtils::Sleep(WAITINTERVAL); } jobProgressEvent(50); PRL_RESULT ret = run_changeSID_cmd(u); if (PRL_SUCCEEDED(ret) || ret != PRL_ERR_CHANGESID_NOT_AVAILABLE) return ret; return PRL_ERR_CHANGESID_GUEST_TOOLS_NOT_AVAILABLE; }