VirtualBox

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

Last change on this file since 82797 was 81425, checked in by vboxsync, 5 years ago

Main/Machine+BIOSSettings+Console: Full implementation of NVRAM handling (part of VM delete, rename, clone and move code in combination with taking, deleting and restoring snapshots). Corresponding console update (ripping out old, never really used NVRAM handling).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: MachineImplMoveVM.h 81425 2019-10-21 18:19:39Z 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 strFile;
61 ULONG uWeight;
62} SNAPFILETASKMOVE;
63
64struct fileList_t;
65
66class MachineMoveVM : public ThreadTask
67{
68 std::vector<ComObjPtr<Machine> > machineList;
69 RTCList<MEDIUMTASKCHAINMOVE> m_llMedias;
70 RTCList<SNAPFILETASKMOVE> m_llSaveStateFiles;
71 RTCList<SNAPFILETASKMOVE> m_llNVRAMFiles;
72 std::map<Utf8Str, MEDIUMTASKMOVE> m_finalMediumsMap;
73 std::map<Utf8Str, SNAPFILETASKMOVE> m_finalSaveStateFilesMap;
74 std::map<Utf8Str, SNAPFILETASKMOVE> m_finalNVRAMFilesMap;
75 std::map<VBoxFolder_t, Utf8Str> m_vmFolders;
76
77 ComObjPtr<Machine> m_pMachine;
78 ComObjPtr<Progress> m_pProgress;
79 ComObjPtr<Progress> m_pRollBackProgress;
80 Utf8Str m_targetPath;
81 Utf8Str m_type;
82 HRESULT m_result;
83
84public:
85 MachineMoveVM(ComObjPtr<Machine> aMachine,
86 const com::Utf8Str &aTargetPath,
87 const com::Utf8Str &aType,
88 ComObjPtr<Progress> &aProgress)
89 : ThreadTask("TaskMoveVM")
90 , m_pMachine(aMachine)
91 , m_pProgress(aProgress)
92 , m_targetPath(aTargetPath)
93 , m_type(aType.isEmpty() ? "basic" : aType)
94 , m_result(S_OK)
95 {
96 }
97
98 virtual ~MachineMoveVM()
99 {
100 }
101
102 HRESULT init();
103private:
104 static DECLCALLBACK(int) updateProgress(unsigned uPercent, void *pvUser);
105 static DECLCALLBACK(int) copyFileProgress(unsigned uPercentage, void *pvUser);
106 static void i_MoveVMThreadTask(MachineMoveVM *task);
107
108public:
109 void handler()
110 {
111 i_MoveVMThreadTask(this);
112 }
113
114private:
115 HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot);
116 inline HRESULT queryBaseName(const ComPtr<IMedium> &pMedium, Utf8Str &strBaseName) const;
117 HRESULT queryMediasForAllStates();
118 void updateProgressStats(MEDIUMTASKCHAINMOVE &mtc, ULONG &uCount, ULONG &uTotalWeight) const;
119 HRESULT addSaveState(const ComObjPtr<Machine> &machine);
120 HRESULT addNVRAM(const ComObjPtr<Machine> &machine);
121 void printStateFile(settings::SnapshotsList &snl);
122 HRESULT getFilesList(const Utf8Str &strRootFolder, fileList_t &filesList);
123 HRESULT getFolderSize(const Utf8Str &strRootFolder, uint64_t &size);
124 HRESULT deleteFiles(const RTCList<Utf8Str> &listOfFiles);
125 void updatePathsToStateFiles(const Utf8Str &sourcePath, const Utf8Str &targetPath);
126 void updatePathsToNVRAMFiles(const Utf8Str &sourcePath, const Utf8Str &targetPath);
127 HRESULT moveAllDisks(const std::map<Utf8Str, MEDIUMTASKMOVE> &listOfDisks, const Utf8Str &strTargetFolder = Utf8Str::Empty);
128 HRESULT restoreAllDisks(const std::map<Utf8Str, MEDIUMTASKMOVE> &listOfDisks);
129 HRESULT isMediumTypeSupportedForMoving(const ComPtr<IMedium> &pMedium);
130};
131
132#endif /* !MAIN_INCLUDED_MachineImplMoveVM_h */
133/* vi: set tabstop=4 shiftwidth=4 expandtab: */
134
Note: See TracBrowser for help on using the repository browser.

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