次のコード (C#) を使用してクローン VM を作成しようとしましたが、失敗しました。
VirtualBox.VirtualBox box = new VirtualBox.VirtualBox();
//create a new machine
IMachine machine = box.CreateMachine(null, "MyClone", null, null, "forceOverwrite=1");
box.RegisterMachine(machine);
//Lock machine for editing
machine.LockMachine(session, LockType.LockType_Write);
IMachine machsettings = session.Machine;
//clone the disk image from an existing vdi (source VDI is not being locked/used)
IMedium hddorig = box.OpenMedium("c:\\tmp\\VDI\\dsl-4.4.10-x86.vdi", DeviceType.DeviceType_HardDisk, AccessMode.AccessMode_ReadOnly, 0);
IMedium hddclone = box.CreateHardDisk("VDI", "c:\\tmp\\VDI\\clone.vdi");
IProgress hddprogress = hddorig.CloneTo(hddclone, 0, hddorig);
hddprogress.WaitForCompletion(-1);
//attach disk image to machine
machsettings.AddStorageController("IDE", StorageBus.StorageBus_IDE);
machsettings.AttachDevice("IDE", 0, 0, DeviceType.DeviceType_HardDisk, hddclone); //fails - Storage for the medium 'c:\tmp\VDI\clone.vdi' is not created
machsettings.SaveSettings();
AttachDevice は常に「メディアのストレージが作成されていません」と言って失敗します。ここで欠けているステップは何ですか?
次のコードは正常に動作するため、hddclone の作成に問題があるようです。machsettings.AttachDevice("IDE", 0, 0, DeviceType.DeviceType_HardDisk, hddorig); //わかった
ありがとうスティーブ