VirtualBox

source: vbox/trunk/src/VBox/Main/include/MachineImplMoveVM.h

Last change on this file was 98352, checked in by vboxsync, 20 months ago

Main: Fix identifiers containing an incorrect plural of "medium".

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
RevLine 
[70648]1/* $Id: MachineImplMoveVM.h 98352 2023-01-30 19:44:51Z vboxsync $ */
2/** @file
3 * Definition of MachineMoveVM
4 */
5
6/*
[98103]7 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
[70648]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
[70648]26 */
27
[76562]28#ifndef MAIN_INCLUDED_MachineImplMoveVM_h
29#define MAIN_INCLUDED_MachineImplMoveVM_h
[76487]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[70648]33
34#include "MachineImpl.h"
35#include "ProgressImpl.h"
36#include "ThreadTask.h"
37
38/////////////////////////////////////////////////////////////////////////////
39
40enum VBoxFolder_t
41{
42 VBox_UnknownFolderType = 0,
43 VBox_OutsideVMfolder,
44 VBox_SettingFolder,
45 VBox_LogFolder,
46 VBox_StateFolder,
47 VBox_SnapshotFolder
48};
49
50typedef struct
51{
[71581]52 bool fSnapshot;
[70648]53 Utf8Str strBaseName;
54 ComPtr<IMedium> pMedium;
55 uint32_t uIdx;
56 ULONG uWeight;
[71581]57} MEDIUMTASKMOVE;
[70648]58
59typedef struct
60{
[81393]61 RTCList<MEDIUMTASKMOVE> chain;
[70648]62 DeviceType_T devType;
63 bool fCreateDiffs;
64 bool fAttachLinked;
[71581]65} MEDIUMTASKCHAINMOVE;
[70648]66
67typedef struct
68{
69 Guid snapshotUuid;
[81425]70 Utf8Str strFile;
[70648]71 ULONG uWeight;
[81425]72} SNAPFILETASKMOVE;
[70648]73
74struct fileList_t;
75
[91312]76class MachineMoveVM : public ThreadTask
[70648]77{
[81394]78 std::vector<ComObjPtr<Machine> > machineList;
[98352]79 RTCList<MEDIUMTASKCHAINMOVE> m_llMedia;
[81425]80 RTCList<SNAPFILETASKMOVE> m_llSaveStateFiles;
81 RTCList<SNAPFILETASKMOVE> m_llNVRAMFiles;
[98352]82 std::map<Utf8Str, MEDIUMTASKMOVE> m_finalMediaMap;
[81425]83 std::map<Utf8Str, SNAPFILETASKMOVE> m_finalSaveStateFilesMap;
84 std::map<Utf8Str, SNAPFILETASKMOVE> m_finalNVRAMFilesMap;
[78836]85 std::map<VBoxFolder_t, Utf8Str> m_vmFolders;
[71990]86
87 ComObjPtr<Machine> m_pMachine;
88 ComObjPtr<Progress> m_pProgress;
89 ComObjPtr<Progress> m_pRollBackProgress;
90 Utf8Str m_targetPath;
91 Utf8Str m_type;
[78836]92 HRESULT m_result;
[71990]93
[70648]94public:
[90828]95 DECLARE_TRANSLATE_METHODS(MachineMoveVM)
96
[70648]97 MachineMoveVM(ComObjPtr<Machine> aMachine,
98 const com::Utf8Str &aTargetPath,
99 const com::Utf8Str &aType,
100 ComObjPtr<Progress> &aProgress)
[78761]101 : ThreadTask("TaskMoveVM")
102 , m_pMachine(aMachine)
103 , m_pProgress(aProgress)
104 , m_targetPath(aTargetPath)
105 , m_type(aType.isEmpty() ? "basic" : aType)
[78836]106 , m_result(S_OK)
[70648]107 {
108 }
109
110 virtual ~MachineMoveVM()
111 {
112 }
113
114 HRESULT init();
[81393]115private:
[70648]116 static DECLCALLBACK(int) updateProgress(unsigned uPercent, void *pvUser);
117 static DECLCALLBACK(int) copyFileProgress(unsigned uPercentage, void *pvUser);
[81393]118 static void i_MoveVMThreadTask(MachineMoveVM *task);
[70648]119
[81393]120public:
[70648]121 void handler()
122 {
123 i_MoveVMThreadTask(this);
124 }
125
[81393]126private:
[81394]127 HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot);
[70648]128 inline HRESULT queryBaseName(const ComPtr<IMedium> &pMedium, Utf8Str &strBaseName) const;
[98352]129 HRESULT queryMediaForAllStates();
[71581]130 void updateProgressStats(MEDIUMTASKCHAINMOVE &mtc, ULONG &uCount, ULONG &uTotalWeight) const;
[70971]131 HRESULT addSaveState(const ComObjPtr<Machine> &machine);
[81425]132 HRESULT addNVRAM(const ComObjPtr<Machine> &machine);
[70648]133 void printStateFile(settings::SnapshotsList &snl);
[81393]134 HRESULT getFilesList(const Utf8Str &strRootFolder, fileList_t &filesList);
135 HRESULT getFolderSize(const Utf8Str &strRootFolder, uint64_t &size);
136 HRESULT deleteFiles(const RTCList<Utf8Str> &listOfFiles);
[81415]137 void updatePathsToStateFiles(const Utf8Str &sourcePath, const Utf8Str &targetPath);
[81425]138 void updatePathsToNVRAMFiles(const Utf8Str &sourcePath, const Utf8Str &targetPath);
[81393]139 HRESULT moveAllDisks(const std::map<Utf8Str, MEDIUMTASKMOVE> &listOfDisks, const Utf8Str &strTargetFolder = Utf8Str::Empty);
140 HRESULT restoreAllDisks(const std::map<Utf8Str, MEDIUMTASKMOVE> &listOfDisks);
[79955]141 HRESULT isMediumTypeSupportedForMoving(const ComPtr<IMedium> &pMedium);
[70648]142};
143
[76562]144#endif /* !MAIN_INCLUDED_MachineImplMoveVM_h */
[70648]145/* vi: set tabstop=4 shiftwidth=4 expandtab: */
146
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use