VirtualBox

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

Last change on this file since 81393 was 81393, checked in by vboxsync, 6 years ago

Main/MachineImplMoveVM: many cleanups including removal of unused code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: MachineImplMoveVM.h 81393 2019-10-21 08:33:26Z vboxsync $ */
2/** @file
3 * Definition of MachineMoveVM
4 */
5
6/*
7 * Copyright (C) 2011-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef MAIN_INCLUDED_MachineImplMoveVM_h
19#define MAIN_INCLUDED_MachineImplMoveVM_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "MachineImpl.h"
25#include "ProgressImpl.h"
26#include "ThreadTask.h"
27
28/////////////////////////////////////////////////////////////////////////////
29
30enum VBoxFolder_t
31{
32 VBox_UnknownFolderType = 0,
33 VBox_OutsideVMfolder,
34 VBox_SettingFolder,
35 VBox_LogFolder,
36 VBox_StateFolder,
37 VBox_SnapshotFolder
38};
39
40typedef struct
41{
42 bool fSnapshot;
43 Utf8Str strBaseName;
44 ComPtr<IMedium> pMedium;
45 uint32_t uIdx;
46 ULONG uWeight;
47} MEDIUMTASKMOVE;
48
49typedef struct
50{
51 RTCList<MEDIUMTASKMOVE> chain;
52 DeviceType_T devType;
53 bool fCreateDiffs;
54 bool fAttachLinked;
55} MEDIUMTASKCHAINMOVE;
56
57typedef struct
58{
59 Guid snapshotUuid;
60 Utf8Str strSaveStateFile;
61 ULONG uWeight;
62} SAVESTATETASKMOVE;
63
64struct fileList_t;
65
66class MachineMoveVM : public ThreadTask
67{
68 RTCList<MEDIUMTASKCHAINMOVE> m_llMedias;
69 RTCList<SAVESTATETASKMOVE> m_llSaveStateFiles;
70 std::map<Utf8Str, MEDIUMTASKMOVE> m_finalMediumsMap;
71 std::map<Utf8Str, SAVESTATETASKMOVE> m_finalSaveStateFilesMap;
72 std::map<VBoxFolder_t, Utf8Str> m_vmFolders;
73
74 ComObjPtr<Machine> m_pMachine;
75 ComObjPtr<Progress> m_pProgress;
76 ComObjPtr<Progress> m_pRollBackProgress;
77 Utf8Str m_targetPath;
78 Utf8Str m_type;
79 HRESULT m_result;
80
81public:
82 MachineMoveVM(ComObjPtr<Machine> aMachine,
83 const com::Utf8Str &aTargetPath,
84 const com::Utf8Str &aType,
85 ComObjPtr<Progress> &aProgress)
86 : ThreadTask("TaskMoveVM")
87 , m_pMachine(aMachine)
88 , m_pProgress(aProgress)
89 , m_targetPath(aTargetPath)
90 , m_type(aType.isEmpty() ? "basic" : aType)
91 , m_result(S_OK)
92 {
93 }
94
95 virtual ~MachineMoveVM()
96 {
97 }
98
99 HRESULT init();
100private:
101 static DECLCALLBACK(int) updateProgress(unsigned uPercent, void *pvUser);
102 static DECLCALLBACK(int) copyFileProgress(unsigned uPercentage, void *pvUser);
103 static void i_MoveVMThreadTask(MachineMoveVM *task);
104
105public:
106 void handler()
107 {
108 i_MoveVMThreadTask(this);
109 }
110
111private:
112 HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot, std::vector<ComObjPtr<Machine> > &aMachineList) const;
113 inline HRESULT queryBaseName(const ComPtr<IMedium> &pMedium, Utf8Str &strBaseName) const;
114 HRESULT queryMediasForAllStates(const std::vector<ComObjPtr<Machine> > &aMachineList);
115 void updateProgressStats(MEDIUMTASKCHAINMOVE &mtc, ULONG &uCount, ULONG &uTotalWeight) const;
116 HRESULT addSaveState(const ComObjPtr<Machine> &machine);
117 void printStateFile(settings::SnapshotsList &snl);
118 HRESULT getFilesList(const Utf8Str &strRootFolder, fileList_t &filesList);
119 HRESULT getFolderSize(const Utf8Str &strRootFolder, uint64_t &size);
120 HRESULT deleteFiles(const RTCList<Utf8Str> &listOfFiles);
121 HRESULT updatePathsToStateFiles(const std::map<Utf8Str, SAVESTATETASKMOVE> &listOfFiles,
122 const Utf8Str &sourcePath, const Utf8Str &targetPath);
123 HRESULT moveAllDisks(const std::map<Utf8Str, MEDIUMTASKMOVE> &listOfDisks, const Utf8Str &strTargetFolder = Utf8Str::Empty);
124 HRESULT restoreAllDisks(const std::map<Utf8Str, MEDIUMTASKMOVE> &listOfDisks);
125 HRESULT isMediumTypeSupportedForMoving(const ComPtr<IMedium> &pMedium);
126};
127
128#endif /* !MAIN_INCLUDED_MachineImplMoveVM_h */
129/* vi: set tabstop=4 shiftwidth=4 expandtab: */
130
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette