亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 Virtual Box 中還原虛擬機快照時出錯

在 Virtual Box 中還原虛擬機快照時出錯

C#
慕田峪7331174 2022-12-31 11:39:09
我在我的項目中使用 VirtualBox 和 Virtual Box API Microsoft Com C++。它是 VirtualBox 6.0.6 軟件開發工具包 (SDK) 和 VirtualBox 6.0.6 平臺包。我有個問題。我想恢復早期創建的快照系統,但程序顯示錯誤。我的代碼與評論:HRESULT rc; IVirtualBoxClient *virtualBoxClient = nullptr; IVirtualBox *virtualBox = nullptr; IMachine *machine = nullptr; ISession *session = nullptr; IProgress *progress = nullptr; ISnapshot* snapshot = nullptr; BSTR sessiontype = SysAllocString(L"gui"); BSTR machineName = SysAllocString(L"Win7x64"); HRESULT rc = CoCreateInstance(CLSID_VirtualBoxClient, NULL, CLSCTX_INPROC_SERVER, IID_IVirtualBoxClient, (void**)&virtualBoxClient); rc = virtualBoxClient->get_VirtualBox(&virtualBox); // looking for a machine with a name Win7x64 rc = virtualBox->FindMachine(machineName, &machine); // create a session object rc = CoCreateInstance(CLSID_Session, NULL, CLSCTX_INPROC_SERVER, IID_ISession, (void**)&session); if (!SUCCEEDED(rc)) { printf("Error creating Session instance! rc = 0x%x\n", rc); break; } // block the machine machine->LockMachine(session, LockType::LockType_Shared); // the name of the snapshot system BSTR snapshotUUID = SysAllocString(L"Win7_test_snapshot"); // looking for a snapshot system rc = machine->FindSnapshot(snapshotUUID, &snapshot); // recover snapshot. ERROR: variable rc - E_NOTIMPL Not implemented. rc = machine->RestoreSnapshot(snapshot, &progress); printf("Starting VM, please wait ...\n"); //waiting for the end of the operation. Abnormal termination- progress == nullptr ! rc = progress->WaitForCompletion(-1); // unlocking the machine rc = session->UnlockMachine(); if (!SUCCEEDED(rc)) { printf("Error restore state machine!\n"); break; }此外,我創建了一個簡單的 C# 應用程序,并在那里得到了完全相同的錯誤。怎么了?這是錯誤的API?我什至多次更改操作系統(虛擬):你能幫我嗎,如何修復調用方法錯誤“RestoreSnapshot - E_NOTIMPL Not implemented”或者如何正確恢復系統快照?謝謝你。PS:我在官方論壇上問過這個問題,沒人幫我。
查看完整描述

1 回答

?
蝴蝶不菲

TA貢獻1810條經驗 獲得超4個贊

我找到了問題的解決方案。應使用會話的當前系統恢復快照。所以代碼將如下所示:


HRESULT rc = machine->LockMachine(session, LockType::LockType_Shared);

rc = machine->FindSnapshot(snapshotUUID, &snapshot);

IMachine* currentMachine(nullptr);

rc = session->get_Machine(&currentMachine);

rc = currentMachine->RestoreSnapshot(snapshot, &progress);

rc = progress->WaitForCompletion(300000);

rc = session->UnlockMachine();

它適用于此代碼。


查看完整回答
反對 回復 2022-12-31
  • 1 回答
  • 0 關注
  • 174 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號