From 4035b1bfb1e5843a539a8b624d21952b756974d1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 16:19:18 +0200 Subject: Adding upstream version 6.1.22-dfsg. Signed-off-by: Daniel Baumann --- src/VBox/Main/include/MachineImplMoveVM.h | 134 ++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 src/VBox/Main/include/MachineImplMoveVM.h (limited to 'src/VBox/Main/include/MachineImplMoveVM.h') diff --git a/src/VBox/Main/include/MachineImplMoveVM.h b/src/VBox/Main/include/MachineImplMoveVM.h new file mode 100644 index 00000000..30d472fc --- /dev/null +++ b/src/VBox/Main/include/MachineImplMoveVM.h @@ -0,0 +1,134 @@ +/* $Id: MachineImplMoveVM.h $ */ +/** @file + * Definition of MachineMoveVM + */ + +/* + * Copyright (C) 2011-2020 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 MAIN_INCLUDED_MachineImplMoveVM_h +#define MAIN_INCLUDED_MachineImplMoveVM_h +#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 strFile; + ULONG uWeight; +} SNAPFILETASKMOVE; + +struct fileList_t; + +class MachineMoveVM : public ThreadTask +{ + std::vector > machineList; + RTCList m_llMedias; + RTCList m_llSaveStateFiles; + RTCList m_llNVRAMFiles; + std::map m_finalMediumsMap; + std::map m_finalSaveStateFilesMap; + std::map m_finalNVRAMFilesMap; + std::map m_vmFolders; + + ComObjPtr m_pMachine; + ComObjPtr m_pProgress; + ComObjPtr m_pRollBackProgress; + Utf8Str m_targetPath; + Utf8Str m_type; + HRESULT m_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() ? "basic" : aType) + , m_result(S_OK) + { + } + + virtual ~MachineMoveVM() + { + } + + HRESULT init(); +private: + static DECLCALLBACK(int) updateProgress(unsigned uPercent, void *pvUser); + static DECLCALLBACK(int) copyFileProgress(unsigned uPercentage, void *pvUser); + static void i_MoveVMThreadTask(MachineMoveVM *task); + +public: + void handler() + { + i_MoveVMThreadTask(this); + } + +private: + HRESULT createMachineList(const ComPtr &pSnapshot); + inline HRESULT queryBaseName(const ComPtr &pMedium, Utf8Str &strBaseName) const; + HRESULT queryMediasForAllStates(); + void updateProgressStats(MEDIUMTASKCHAINMOVE &mtc, ULONG &uCount, ULONG &uTotalWeight) const; + HRESULT addSaveState(const ComObjPtr &machine); + HRESULT addNVRAM(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); + void updatePathsToStateFiles(const Utf8Str &sourcePath, const Utf8Str &targetPath); + void updatePathsToNVRAMFiles(const Utf8Str &sourcePath, const Utf8Str &targetPath); + HRESULT moveAllDisks(const std::map &listOfDisks, const Utf8Str &strTargetFolder = Utf8Str::Empty); + HRESULT restoreAllDisks(const std::map &listOfDisks); + HRESULT isMediumTypeSupportedForMoving(const ComPtr &pMedium); +}; + +#endif /* !MAIN_INCLUDED_MachineImplMoveVM_h */ +/* vi: set tabstop=4 shiftwidth=4 expandtab: */ + -- cgit v1.2.3