Information about 'flags' parameter in createMachine function

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Information about 'flags' parameter in createMachine function

Post by AdityaM »

Hello,
In the SDK documentation of Virtual Box version 5.1.8, for 'createMachine()' function, the 5th argument in that function is for flags. I wanted to get get more details related to that argument, like what flags can be set during creation and how can we read back those flag values?
Can I set some unique value in any flag element that I can read back to validate that this machine is created by 'me' and not using any other means? Kindly let me know if this is possible?
Thanks
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Information about 'flags' parameter in createMachine function

Post by socratis »

From the 5.1.14 SDKRef.pdf, as well as the online SDK reference (https://www.virtualbox.org/sdkref/inter ... 161a4da595):
flags
Additional property parameters, passed as a comma-separated list of “name=value” type entries. The following ones are recognized: forceOverwrite=1 to overwrite an existing machine settings file, UUID=<uuid> to specify a machine UUID and directoryIncludesUUID=1 to switch to a special VM directory naming scheme which should not be used unless necessary.
Also, a quick glance at the "src/VBox/Main/src-server/VirtualBoxImpl.cpp, createMachine" reveals pretty much the same thing.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Re: Information about 'flags' parameter in createMachine function

Post by AdityaM »

Hello,
Yes, I did have a look at the documentation and the point that you have mentioned about flags is correct. But I think if these are the only flags that we have access to, then I don't think I can use them for the purpose I was thinking for.
What I am looking is for a unique way to identify that the Virtual Machine is created by the software from where the createMachine() API is getting called. So do you think if there is a way to do so? If yes, kindly suggest.
An expected scenario in my case is something like -
"A Virtual Machine is created (cloned) from the software (application) which uses this API, and later on before executing/starting this Virtual Machine, I can do a check if the Machine is created using the same software (application) or not, and take appropriate action if the Virtual Machine is not created using the same application."

To achieve this, what I think I need is, a way to add "unique part" to Virtual Machine while creating it, which does not alter the VM functionality.

Your suggestion on this topic would be really helpful.

Regards
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Information about 'flags' parameter in createMachine function

Post by noteirak »

The best way to achieve that is using the Extra Data functionality which is an arbitrary key/value pair that can be set per VM.
See https://www.virtualbox.org/sdkref/inter ... 63602f795a
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Re: Information about 'flags' parameter in createMachine function

Post by AdityaM »

Thanks a lot for the pointer..I think it is working as per my expectations :D
Post Reply