PHP Howto use CloneMode

Discussion about using the VirtualBox API, Tutorials, Samples.

PHP Howto use CloneMode

Postby VBoxDeveloper » 18. Jan 2018, 15:01

I'm trying to clone a virtualmachine
The idea es a complete duplication (with new MAC's)

The machine is created as follows:

Code: Select all   Expand viewCollapse view
$newMachine  = $this->virtualbox->createMachine(null, $cloneName, '/Clones', $originalMachine->OSTypeId, null);
$cm = new CloneMode();
$result = $originalMachine->CloneTo($newMachine, $cm->ValueMap['AllStates'], null);

The result is always the same:

Code: Select all   Expand viewCollapse view
PHP Fatal error:  Uncaught SoapFault exception: [SOAP-ENV:Client] Validation constraint violation: invalid value in element 'mode' in vboxServiceWrappers.php:3465

Any hint for me?
Thanks in advance :)
Posts: 1
Joined: 18. Jan 2018, 14:35

Re: PHP Howto use CloneMode

Postby noteirak » 18. Jan 2018, 15:04

As the error suggets, you didn't pass a valid clone mode. See the IMachine::cloneTo reference for order of arguments and their acceptable values.
Getting a new CloneMode instance seems wrong, I would think you need to use one of the properties of the static class instead.
Hyperbox - Virtual Infrastructure Manager -
Manage your VirtualBox infrastructure the free way!
Site Moderator
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 1 guest