/* $Id: MachineImplMoveVM.h 76487 2018-12-27 03:31:39Z vboxsync $ */ /** @file * Definition of MachineMoveVM */ /* * Copyright (C) 2011-2017 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. */ #ifndef ____H_MACHINEIMPLMOVEVM #define ____H_MACHINEIMPLMOVEVM #ifndef RT_WITHOUT_PRAGMA_ONCE # pragma once #endif #include "MachineImpl.h" #include "ProgressImpl.h" #include "ThreadTask.h" ///////////////////////////////////////////////////////////////////////////// enum VBoxFolder_t { VBox_UnknownFolderType = 0, VBox_OutsideVMfolder, VBox_SettingFolder, VBox_LogFolder, VBox_StateFolder, VBox_SnapshotFolder }; typedef struct { bool fSnapshot; Utf8Str strBaseName; ComPtr pMedium; uint32_t uIdx; ULONG uWeight; } MEDIUMTASKMOVE; typedef struct { RTCList chain; DeviceType_T devType; bool fCreateDiffs; bool fAttachLinked; } MEDIUMTASKCHAINMOVE; typedef struct { Guid snapshotUuid; Utf8Str strSaveStateFile; ULONG uWeight; } SAVESTATETASKMOVE; struct fileList_t; class MachineMoveVM : public ThreadTask { struct ErrorInfoItem { ErrorInfoItem(HRESULT aCode, const char* aDescription): m_code(aCode), m_description(aDescription == NULL ? "There is no description" : aDescription) { } void printItem(bool fLog) const; HRESULT m_code; Utf8Str m_description; }; RTCList llMedias; RTCList llSaveStateFiles; std::map finalMediumsMap; std::map finalSaveStateFilesMap; std::map vmFolders; std::list errorsList; ComObjPtr m_pMachine; ComObjPtr m_pProgress; ComObjPtr m_pRollBackProgress; ComPtr m_pSession; ComPtr m_pSessionMachine; Utf8Str m_targetPath; Utf8Str m_type; HRESULT result; public: MachineMoveVM(ComObjPtr aMachine, const com::Utf8Str &aTargetPath, const com::Utf8Str &aType, ComObjPtr &aProgress) : ThreadTask("TaskMoveVM"), m_pMachine(aMachine), m_pProgress(aProgress), m_targetPath(aTargetPath), m_type (aType.isEmpty() == true ? "basic" : aType), result(S_OK) { } virtual ~MachineMoveVM() { } HRESULT init(); static DECLCALLBACK(int) updateProgress(unsigned uPercent, void *pvUser); static DECLCALLBACK(int) copyFileProgress(unsigned uPercentage, void *pvUser); static void i_MoveVMThreadTask(MachineMoveVM* task); void handler() { i_MoveVMThreadTask(this); } /* MachineCloneVM::start helper: */ HRESULT createMachineList(const ComPtr &pSnapshot, std::vector< ComObjPtr > &aMachineList) const; inline HRESULT queryBaseName(const ComPtr &pMedium, Utf8Str &strBaseName) const; HRESULT queryMediasForAllStates(const std::vector > &aMachineList); void updateProgressStats(MEDIUMTASKCHAINMOVE &mtc, ULONG &uCount, ULONG &uTotalWeight) const; HRESULT addSaveState(const ComObjPtr &machine); void printStateFile(settings::SnapshotsList &snl); HRESULT getFilesList(const Utf8Str& strRootFolder, fileList_t &filesList); HRESULT getFolderSize(const Utf8Str& strRootFolder, uint64_t& size); HRESULT deleteFiles(const RTCList& listOfFiles); HRESULT updatePathsToStateFiles(const std::map& listOfFiles, const Utf8Str& sourcePath, const Utf8Str& targetPath); HRESULT moveAllDisks(const std::map& listOfDisks, const Utf8Str* strTargetFolder = NULL); HRESULT restoreAllDisks(const std::map& listOfDisks); bool isMediumTypeSupportedForMoving(const ComPtr &pMedium); }; #endif // ____H_MACHINEIMPLMOVEVM /* vi: set tabstop=4 shiftwidth=4 expandtab: */