VirtualBox

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

Last change on this file since 70648 was 70648, checked in by vboxsync, 7 years ago

scm police

  • 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 70648 2018-01-19 14:23:00Z vboxsync $ */
2/** @file
3 * Definition of MachineMoveVM
4 */
5
6/*
7 * Copyright (C) 2011-2017 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 ____H_MACHINEIMPLMOVEVM
19#define ____H_MACHINEIMPLMOVEVM
20
21#include "MachineImpl.h"
22#include "ProgressImpl.h"
23#include "ThreadTask.h"
24
25/////////////////////////////////////////////////////////////////////////////
26
27enum VBoxFolder_t
28{
29 VBox_UnknownFolderType = 0,
30 VBox_OutsideVMfolder,
31 VBox_SettingFolder,
32 VBox_LogFolder,
33 VBox_StateFolder,
34 VBox_SnapshotFolder
35};
36
37typedef struct
38{
39 Utf8Str strBaseName;
40 ComPtr<IMedium> pMedium;
41 uint32_t uIdx;
42 ULONG uWeight;
43 bool fSnapshot;
44} MEDIUMTASK;
45
46typedef struct
47{
48 RTCList<MEDIUMTASK> chain;
49 DeviceType_T devType;
50 bool fCreateDiffs;
51 bool fAttachLinked;
52} MEDIUMTASKCHAIN;
53
54typedef struct
55{
56 Guid snapshotUuid;
57 Utf8Str strSaveStateFile;
58 ULONG uWeight;
59} SAVESTATETASK;
60
61struct fileList_t;
62
63class MachineMoveVM : public ThreadTask
64{
65public:
66
67 MachineMoveVM(ComObjPtr<Machine> aMachine,
68 const com::Utf8Str &aTargetPath,
69 const com::Utf8Str &aType,
70 ComObjPtr<Progress> &aProgress)
71 : ThreadTask("TaskMoveVM"),
72 m_pMachine(aMachine),
73 m_pProgress(aProgress),
74 m_targetPath(aTargetPath),
75 m_type(aType),
76 result(S_OK)
77 {
78 }
79
80 virtual ~MachineMoveVM()
81 {
82 }
83
84 HRESULT init();
85 static DECLCALLBACK(int) updateProgress(unsigned uPercent, void *pvUser);
86 static DECLCALLBACK(int) copyFileProgress(unsigned uPercentage, void *pvUser);
87 static void i_MoveVMThreadTask(MachineMoveVM* task);
88
89 RTCList<MEDIUMTASKCHAIN> llMedias;
90 RTCList<SAVESTATETASK> llSaveStateFiles;
91 std::map<Utf8Str, MEDIUMTASK> finalMediumsMap;
92 std::map<Utf8Str, SAVESTATETASK> finalSaveStateFilesMap;
93 std::map<VBoxFolder_t, Utf8Str> vmFolders;
94
95 ComObjPtr<Machine> m_pMachine;
96 ComObjPtr<Progress> m_pProgress;
97 ComPtr<ISession> m_pSession;
98 ComPtr<IMachine> m_pSessionMachine;
99 Utf8Str m_targetPath;
100 Utf8Str m_type;
101 HRESULT result;
102
103 void handler()
104 {
105 i_MoveVMThreadTask(this);
106 }
107
108 /* MachineCloneVM::start helper: */
109 HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot, std::vector< ComObjPtr<Machine> > &aMachineList) const;
110 inline HRESULT queryBaseName(const ComPtr<IMedium> &pMedium, Utf8Str &strBaseName) const;
111 HRESULT queryMediasForAllStates(const std::vector<ComObjPtr<Machine> > &aMachineList, ULONG &uCount, ULONG &uTotalWeight);
112 void updateProgressStats(MEDIUMTASKCHAIN &mtc, ULONG &uCount, ULONG &uTotalWeight) const;
113 HRESULT addSaveState(const ComObjPtr<Machine> &machine, ULONG &uCount, ULONG &uTotalWeight);
114 void updateStateFile(settings::MachineConfigFile *snl, const Guid &id, const Utf8Str &strFile);
115 void updateStateFile(settings::SnapshotsList &snl, const Guid &id, const Utf8Str &strFile);
116 void printStateFile(settings::SnapshotsList &snl);
117 HRESULT getFilesList(const Utf8Str& strRootFolder, fileList_t &filesList);
118 HRESULT getFolderSize(const Utf8Str& strRootFolder, uint64_t& size);
119 HRESULT deleteFiles(const RTCList<Utf8Str>& listOfFiles);
120 HRESULT updateStateFilesXMLSettings(const std::map<Utf8Str, SAVESTATETASK>& listOfFiles, const Utf8Str& targetPath);
121 HRESULT moveAllDisks(const std::map<Utf8Str, MEDIUMTASK>& listOfDisks, const Utf8Str* strTargetFolder = NULL);
122 HRESULT restoreAllDisks(const std::map<Utf8Str, MEDIUMTASK>& listOfDisks);
123};
124
125#endif // ____H_MACHINEIMPLMOVEVM
126/* vi: set tabstop=4 shiftwidth=4 expandtab: */
127
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