VirtualBox

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

最後變更 在這個檔案從81415是 81415,由 vboxsync 提交於 5 年 前

Main/MachineImplMoveVM: simplify updatePathsToStateFiles (which is still very wrong, because it uses a method which is used for renaming VMs), because it used the method to update the snapshots too often (for each snapshot, when one call updates them all)

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.1 KB
 
1/* $Id: MachineImplMoveVM.h 81415 2019-10-21 15:06:34Z 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.alldomusa.eu.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 std::vector<ComObjPtr<Machine> > machineList;
69 RTCList<MEDIUMTASKCHAINMOVE> m_llMedias;
70 RTCList<SAVESTATETASKMOVE> m_llSaveStateFiles;
71 std::map<Utf8Str, MEDIUMTASKMOVE> m_finalMediumsMap;
72 std::map<Utf8Str, SAVESTATETASKMOVE> m_finalSaveStateFilesMap;
73 std::map<VBoxFolder_t, Utf8Str> m_vmFolders;
74
75 ComObjPtr<Machine> m_pMachine;
76 ComObjPtr<Progress> m_pProgress;
77 ComObjPtr<Progress> m_pRollBackProgress;
78 Utf8Str m_targetPath;
79 Utf8Str m_type;
80 HRESULT m_result;
81
82public:
83 MachineMoveVM(ComObjPtr<Machine> aMachine,
84 const com::Utf8Str &aTargetPath,
85 const com::Utf8Str &aType,
86 ComObjPtr<Progress> &aProgress)
87 : ThreadTask("TaskMoveVM")
88 , m_pMachine(aMachine)
89 , m_pProgress(aProgress)
90 , m_targetPath(aTargetPath)
91 , m_type(aType.isEmpty() ? "basic" : aType)
92 , m_result(S_OK)
93 {
94 }
95
96 virtual ~MachineMoveVM()
97 {
98 }
99
100 HRESULT init();
101private:
102 static DECLCALLBACK(int) updateProgress(unsigned uPercent, void *pvUser);
103 static DECLCALLBACK(int) copyFileProgress(unsigned uPercentage, void *pvUser);
104 static void i_MoveVMThreadTask(MachineMoveVM *task);
105
106public:
107 void handler()
108 {
109 i_MoveVMThreadTask(this);
110 }
111
112private:
113 HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot);
114 inline HRESULT queryBaseName(const ComPtr<IMedium> &pMedium, Utf8Str &strBaseName) const;
115 HRESULT queryMediasForAllStates();
116 void updateProgressStats(MEDIUMTASKCHAINMOVE &mtc, ULONG &uCount, ULONG &uTotalWeight) const;
117 HRESULT addSaveState(const ComObjPtr<Machine> &machine);
118 void printStateFile(settings::SnapshotsList &snl);
119 HRESULT getFilesList(const Utf8Str &strRootFolder, fileList_t &filesList);
120 HRESULT getFolderSize(const Utf8Str &strRootFolder, uint64_t &size);
121 HRESULT deleteFiles(const RTCList<Utf8Str> &listOfFiles);
122 void updatePathsToStateFiles(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
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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