Changeset 23882 in vbox
- Timestamp:
- Oct 19, 2009 6:36:03 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 53663
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r23802 r23882 169 169 170 170 /* VBoxManageVMInfo.cpp */ 171 void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const com::Bstr &prefix = "", int level = 0); 171 void showSnapshots(ComPtr<ISnapshot> &rootSnapshot, 172 ComPtr<ISnapshot> ¤tSnapshot, 173 VMINFO_DETAILS details, 174 const com::Bstr &prefix = "", 175 int level = 0); 172 176 int handleShowVMInfo(HandlerArg *a); 173 177 HRESULT showVMInfo(ComPtr<IVirtualBox> virtualBox, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r23847 r23882 327 327 RTPrintf("VBoxManage snapshot <uuid>|<name>\n" 328 328 " take <name> [--description <desc>] [--pause] |\n" 329 " d iscard<uuid>|<name> |\n"330 " discardcurrent --state|--all|\n"329 " delete <uuid>|<name> |\n" 330 " restore <uuid>|<name> |\n" 331 331 " edit <uuid>|<name>|--current\n" 332 332 " [--name <name>]\n" -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r23801 r23882 48 48 /////////////////////////////////////////////////////////////////////////////// 49 49 50 void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const Bstr &prefix /* = ""*/, int level /*= 0*/) 50 void showSnapshots(ComPtr<ISnapshot> &rootSnapshot, 51 ComPtr<ISnapshot> ¤tSnapshot, 52 VMINFO_DETAILS details, 53 const Bstr &prefix /* = ""*/, 54 int level /*= 0*/) 51 55 { 52 56 /* start with the root */ … … 64 68 { 65 69 /* print with indentation */ 66 RTPrintf(" %lSName: %lS (UUID: %s)\n", prefix.raw(), name.raw(), Utf8Str(uuid).raw()); 70 bool fCurrent = (rootSnapshot == currentSnapshot); 71 RTPrintf(" %lSName: %lS (UUID: %s)%s\n", 72 prefix.raw(), 73 name.raw(), 74 Utf8Str(uuid).raw(), 75 (fCurrent) ? " *" : ""); 67 76 } 68 77 … … 81 90 newPrefix = Utf8StrFmt("%lS-%d", prefix.raw(), index + 1); 82 91 else 92 { 83 93 newPrefix = Utf8StrFmt("%lS ", prefix.raw()); 94 } 95 84 96 /* recursive call */ 85 showSnapshots(snapshot, details, newPrefix, level + 1);97 showSnapshots(snapshot, currentSnapshot, details, newPrefix, level + 1); 86 98 } 87 99 } … … 1832 1844 if (SUCCEEDED(rc) && snapshot) 1833 1845 { 1834 if (details != VMINFO_MACHINEREADABLE) 1835 RTPrintf("Snapshots:\n\n"); 1836 showSnapshots(snapshot, details); 1846 ComPtr<ISnapshot> currentSnapshot; 1847 rc = machine->GetCurrentSnapshot(currentSnapshot.asOutParam()); 1848 if (SUCCEEDED(rc)) 1849 { 1850 if (details != VMINFO_MACHINEREADABLE) 1851 RTPrintf("Snapshots:\n\n"); 1852 showSnapshots(snapshot, currentSnapshot, details); 1853 } 1837 1854 } 1838 1855 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r23879 r23882 68 68 69 69 /* switch based on the command */ 70 bool fDelete = false, fRestore = false; 70 71 if (!strcmp(a->argv[1], "take")) 71 72 { … … 154 155 } 155 156 } 156 else if (!strcmp(a->argv[1], "discard")) 157 else if ( (fDelete = !strcmp(a->argv[1], "delete")) 158 || (fRestore = !strcmp(a->argv[1], "restore")) 159 ) 157 160 { 158 161 /* exactly one parameter: snapshot name */ … … 164 167 } 165 168 166 ComPtr<ISnapshot> snapshot;169 ComPtr<ISnapshot> pSnapshot; 167 170 168 171 /* assume it's a UUID */ … … 170 173 if (!guid.isEmpty()) 171 174 { 172 CHECK_ERROR_BREAK(machine, GetSnapshot(guid, snapshot.asOutParam()));175 CHECK_ERROR_BREAK(machine, GetSnapshot(guid, pSnapshot.asOutParam())); 173 176 } 174 177 else 175 178 { 176 179 /* then it must be a name */ 177 CHECK_ERROR_BREAK(machine, FindSnapshot(Bstr(a->argv[2]), snapshot.asOutParam())); 178 } 179 180 snapshot->COMGETTER(Id)(guid.asOutParam()); 181 182 ComPtr<IProgress> progress; 183 CHECK_ERROR_BREAK(console, DeleteSnapshot(guid, progress.asOutParam())); 184 185 showProgress(progress); 186 LONG iRc; 187 progress->COMGETTER(ResultCode)(&iRc); 188 rc = iRc; 189 if (FAILED(rc)) 190 { 191 com::ProgressErrorInfo info(progress); 192 if (info.isBasicAvailable()) 193 RTPrintf("Error: failed to discard snapshot. Error message: %lS\n", info.getText().raw()); 194 else 195 RTPrintf("Error: failed to discard snapshot. No error message available!\n"); 196 } 197 } 198 else if (!strcmp(a->argv[1], "discardcurrent")) 199 { 200 if ( (a->argc != 3) 201 || ( strcmp(a->argv[2], "--state") 202 && strcmp(a->argv[2], "-state"))) 203 { 204 errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(a->argv[2]).raw()); 205 rc = E_FAIL; 206 break; 207 } 208 209 ComPtr<ISnapshot> pCurrentSnapshot; 210 CHECK_ERROR_BREAK(machine, COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam())); 180 CHECK_ERROR_BREAK(machine, FindSnapshot(Bstr(a->argv[2]), pSnapshot.asOutParam())); 181 pSnapshot->COMGETTER(Id)(guid.asOutParam()); 182 } 211 183 212 184 ComPtr<IProgress> pProgress; 213 CHECK_ERROR_BREAK(console, RestoreSnapshot(pCurrentSnapshot, pProgress.asOutParam())); 185 if (fDelete) 186 { 187 CHECK_ERROR_BREAK(console, DeleteSnapshot(guid, pProgress.asOutParam())); 188 } 189 else 190 { 191 // must be restore 192 CHECK_ERROR_BREAK(console, RestoreSnapshot(pSnapshot, pProgress.asOutParam())); 193 } 214 194 215 195 showProgress(pProgress); … … 221 201 com::ProgressErrorInfo info(pProgress); 222 202 if (info.isBasicAvailable()) 223 RTPrintf("Error: failed to restore snapshot. Error message: %lS\n", info.getText().raw()); 224 else 225 RTPrintf("Error: failed to restore snapshot. No error message available!\n"); 226 } 227 203 RTPrintf("Error: snapshot operation failed. Error message: %lS\n", info.getText().raw()); 204 else 205 RTPrintf("Error: snapshot operation failed. No error message available!\n"); 206 } 228 207 } 229 208 else if (!strcmp(a->argv[1], "edit")) -
trunk/src/VBox/Main/MachineImpl.cpp
r23881 r23882 7586 7586 void handler() 7587 7587 { 7588 machine->d iscardSnapshotHandler(*this);7588 machine->deleteSnapshotHandler(*this); 7589 7589 } 7590 7590 … … 9445 9445 9446 9446 /** 9447 * Helper struct for SessionMachine::d iscardSnapshotHandler().9447 * Helper struct for SessionMachine::deleteSnapshotHandler(). 9448 9448 */ 9449 9449 struct MediumDiscardRec … … 9484 9484 * @note Locks mParent + this + child objects for writing! 9485 9485 */ 9486 void SessionMachine::d iscardSnapshotHandler(DeleteSnapshotTask &aTask)9486 void SessionMachine::deleteSnapshotHandler(DeleteSnapshotTask &aTask) 9487 9487 { 9488 9488 LogFlowThisFuncEnter(); … … 9895 9895 { 9896 9896 mSSData->mStateFilePath = stateFilePath; 9897 9898 /* make the snapshot we restored from the current snapshot */ 9899 mData->mCurrentSnapshot = aTask.pSnapshot; 9897 9900 } 9898 9901 else -
trunk/src/VBox/Main/include/MachineImpl.h
r23879 r23882 1037 1037 typedef std::map<ComObjPtr<Machine>, MachineState_T> AffectedMachines; 1038 1038 1039 void d iscardSnapshotHandler(DeleteSnapshotTask &aTask);1039 void deleteSnapshotHandler(DeleteSnapshotTask &aTask); 1040 1040 void restoreSnapshotHandler(RestoreSnapshotTask &aTask); 1041 1041
Note:
See TracChangeset
for help on using the changeset viewer.