How to set solid state drive option for VDI programmatically

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Bidyut
Posts: 10
Joined: 19. Aug 2018, 15:52

How to set solid state drive option for VDI programmatically

Post by Bidyut »

I was looking for the right virtual box API to enable / disable 'Solid State Drive' option for VDI type of storage.

FYI, I have tried using IMachine::NonRotationalDevice("Controller", 0, 0, DeviceType.DeviceType_HardDisk, 1) but it was not setting the option. I was invoking this method before IMachine::SaveSettings() method call. In addition, IMachine::AttachDevice() and IMachine::AdoptSavedState() are also called.

Just want to understand, when underlying harddisk is solid state drive then "Solid State Drive" option helps in improving VM performance ?
SmithersTheOracle
Posts: 60
Joined: 28. Dec 2019, 08:58
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to set solid state drive option for VDI programmatically

Post by SmithersTheOracle »

IMachine::NonRotationalDevice() works fine for me. Where are you getting the "DeviceType.DeviceType_HardDisk" parameter? I don't see that in the API documentation. Are you perhaps using another version? I'm on 6.1.0. Maybe IMachine::NonRotationalDevice("Controller", 0, 0, 1) would work better? My call is like this: $mutabletestmachine.NonRotationalDevice("IDE", 0, 0, 1) where IDE is the actual name of the controller and the disk is attached to the primary master (0, 0) port of the IDE controller. I'd post the full code, but there's a LOT of custom objects in mine... so it'd be messy.

Edit: Also, the documentation says
VirtualBox Programming Guide and Reference 6.1.0 wrote:This may or may not be supported by a particular drive, and is silently ignored in the latter case.
Could you post the variant, type, format, etc. for the storage controller and virtual disk? I could try to recreate it more closely.
Bidyut
Posts: 10
Joined: 19. Aug 2018, 15:52

Re: How to set solid state drive option for VDI programmatically

Post by Bidyut »

I am using VDI format, Controller type = StorageControllerType_IntelAhci. You are right, there is no param "DeviceType.DeviceType_HardDisk".

Unfortunately, I am bound to use virtual box 5.1.30 / 5.2.34 but not the latest due to certain limitation.
SmithersTheOracle
Posts: 60
Joined: 28. Dec 2019, 08:58
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to set solid state drive option for VDI programmatically

Post by SmithersTheOracle »

Bidyut wrote:I am using VDI format, Controller type = StorageControllerType_IntelAhci.
I created a standard VDI disk and attached it to an IntelAhci controller and was still able to do it without a problem.
Bidyut wrote:Unfortunately, I am bound to use virtual box 5.1.30 / 5.2.34 but not the latest due to certain limitation.
Sorry I can't test this specific version for you right now. I'm pretty deep into working on this 6.1 module myself.

I'm pretty sure IMachine::NonRotationalDevice("Controller", 0, 0, 1) should work for you. Just to be sure, Controller is the actual name of your IntelAhci storage controller and the virtual disk is connected to port 0, device 0 of that controller, correct?
Bidyut
Posts: 10
Joined: 19. Aug 2018, 15:52

Re: How to set solid state drive option for VDI programmatically

Post by Bidyut »

You are right. "Controller" is the actual name and the virtual disk is connected to port 0, device 0 of that controller.
Post Reply