@@ -624,7 +624,8 @@ public function remote_getEvents($args) {
624
624
$ machine ->releaseRemote ();
625
625
626
626
} catch (Exception $ e ) {
627
- // pass
627
+ // pass
628
+ $ this ->errors [] = $ e ;
628
629
}
629
630
break ;
630
631
@@ -723,7 +724,7 @@ public function remote_subscribeEvents($args) {
723
724
724
725
// Create and register event listener
725
726
$ listener = $ this ->vbox ->eventSource ->createListener ();
726
- $ this ->vbox ->eventSource ->registerListener ($ listener ,array ('MachineEvent ' ,'SnapshotEvent ' ,'OnMediumRegistered ' ,'OnExtraDataChanged ' ), false );
727
+ $ this ->vbox ->eventSource ->registerListener ($ listener ,array ('MachineEvent ' , 'SnapshotEvent ' , 'OnMediumRegistered ' , 'OnExtraDataChanged ' , ' OnSnapshotRestored ' ), false );
727
728
728
729
// Add to event listener list
729
730
$ this ->persistentRequest ['vboxEventListeners ' ]['vbox ' ] = array (
@@ -755,7 +756,7 @@ private function _getEventData($event, $listenerKey) {
755
756
756
757
// Convert to parent class
757
758
$ parentClass = 'I ' .substr ($ data ['eventType ' ],2 ).'Event ' ;
758
- $ eventDataObject = new $ parentClass ($ this ->client , $ event ->handle );
759
+ $ eventDataObject = new $ parentClass ($ this ->client , $ event ->handle );
759
760
760
761
// Dedup ID is at least listener key ('vbox' or machine id) and event type
761
762
$ data ['dedupId ' ] = $ listenerKey .'- ' .$ data ['eventType ' ];
@@ -2368,8 +2369,10 @@ public function remote_progressGet($args) {
2368
2369
try {
2369
2370
2370
2371
// Force web call to keep session open.
2371
- $ this ->session = new ISession ($ this ->client , $ this ->persistentRequest ['sessionHandle ' ]);
2372
- if ((string )$ this ->session ->state ) {}
2372
+ if ($ this ->persistentRequest ['sessionHandle ' ]) {
2373
+ $ this ->session = new ISession ($ this ->client , $ this ->persistentRequest ['sessionHandle ' ]);
2374
+ if ((string )$ this ->session ->state ) {}
2375
+ }
2373
2376
2374
2377
/* @var $progress IProgress */
2375
2378
$ progress = new IProgress ($ this ->client , $ args ['progress ' ]);
@@ -2489,15 +2492,14 @@ private function _util_progressDestroy($pop) {
2489
2492
// Close session and logoff
2490
2493
try {
2491
2494
2492
- if (!$ this ->session )
2493
- $ this ->session = $ this ->websessionManager ->getSessionObject ($ this ->vbox ->handle );
2494
-
2495
- if ($ this ->session && (string )$ this ->session ->state != 'Unlocked ' ) {
2496
- $ this ->session ->unlockMachine ();
2495
+ if ($ this ->session ->handle ) {
2496
+ if ((string )$ this ->session ->state != 'Unlocked ' ) {
2497
+ $ this ->session ->unlockMachine ();
2498
+ }
2499
+ $ this ->session ->releaseRemote ();
2500
+ unset($ this ->session );
2497
2501
}
2498
2502
2499
- $ this ->session ->releaseRemote ();
2500
- unset($ this ->session );
2501
2503
2502
2504
} catch (Exception $ e ) {
2503
2505
$ this ->errors [] = $ e ;
@@ -3291,7 +3293,7 @@ public function remote_machineSetState($args) {
3291
3293
if ($ state == 'saveState ' ) {
3292
3294
$ progress = $ this ->session ->machine ->saveState ();
3293
3295
} else {
3294
- $ progress = $ this ->session ->console ->$ state ();
3296
+ $ progress = $ this ->session ->console ->$ state ();
3295
3297
}
3296
3298
3297
3299
if (!$ progress ->handle ) {
@@ -4700,7 +4702,7 @@ public function remote_snapshotTake($args) {
4700
4702
$ machine ->lockMachine ($ this ->session ->handle , ((string )$ machine ->sessionState == 'Unlocked ' ? 'Write ' : 'Shared ' ));
4701
4703
4702
4704
/* @var $progress IProgress */
4703
- $ progress = $ this ->session ->machine ->takeSnapshot ($ args ['name ' ], $ args ['description ' ]);
4705
+ list ( $ progress, $ snapshotId ) = $ this ->session ->machine ->takeSnapshot ($ args ['name ' ], $ args ['description ' ]);
4704
4706
4705
4707
// Does an exception exist?
4706
4708
try {
@@ -4717,8 +4719,6 @@ public function remote_snapshotTake($args) {
4717
4719
4718
4720
} catch (Exception $ e ) {
4719
4721
4720
- $ this ->errors [] = $ e ;
4721
-
4722
4722
if (!$ progress ->handle && $ this ->session ->handle ) {
4723
4723
try {$ this ->session ->unlockMachine ();$ this ->session =null ;}catch (Exception $ e ){}
4724
4724
}
@@ -4886,11 +4886,11 @@ public function remote_mediumChangeEncryption($args) {
4886
4886
// Connect to vboxwebsrv
4887
4887
$ this ->connect ();
4888
4888
4889
- $ m = $ this ->vbox ->openMedium ($ args ['medium ' ],'HardDisk ' );
4889
+ $ m = $ this ->vbox ->openMedium ($ args ['medium ' ], 'HardDisk ' , ' ReadWrite ' );
4890
4890
4891
4891
/* @var $progress IProgress */
4892
- $ progress = $ m ->changeEncryption ($ args ['old_pw ' ],
4893
- $ args ['cipher ' ], $ args ['new_pw ' ], $ args ['new_pwid ' ]);
4892
+ $ progress = $ m ->changeEncryption ($ args ['old_password ' ],
4893
+ $ args ['cipher ' ], $ args ['password ' ], $ args ['id ' ]);
4894
4894
4895
4895
// Does an exception exist?
4896
4896
try {
@@ -4927,7 +4927,7 @@ public function remote_mediumResize($args) {
4927
4927
// Connect to vboxwebsrv
4928
4928
$ this ->connect ();
4929
4929
4930
- $ m = $ this ->vbox ->openMedium ($ args ['medium ' ],'HardDisk ' );
4930
+ $ m = $ this ->vbox ->openMedium ($ args ['medium ' ], 'HardDisk ' );
4931
4931
4932
4932
/* @var $progress IProgress */
4933
4933
$ progress = $ m ->resize ($ args ['bytes ' ]);
@@ -4965,7 +4965,7 @@ public function remote_mediumCloneTo($args) {
4965
4965
$ mid = $ target ->id ;
4966
4966
4967
4967
/* @var $src IMedium */
4968
- $ src = $ this ->vbox ->openMedium ($ args ['src ' ],'HardDisk ' );
4968
+ $ src = $ this ->vbox ->openMedium ($ args ['src ' ], 'HardDisk ' );
4969
4969
4970
4970
$ type = array (($ args ['type ' ] == 'fixed ' ? 'Fixed ' : 'Standard ' ));
4971
4971
if ($ args ['split ' ]) $ type [] = 'VmdkSplit2G ' ;
@@ -5003,7 +5003,7 @@ public function remote_mediumSetType($args) {
5003
5003
$ this ->connect ();
5004
5004
5005
5005
/* @var $m IMedium */
5006
- $ m = $ this ->vbox ->openMedium ($ args ['medium ' ],'HardDisk ' );
5006
+ $ m = $ this ->vbox ->openMedium ($ args ['medium ' ], 'HardDisk ' );
5007
5007
$ m ->type = $ args ['type ' ];
5008
5008
$ m ->releaseRemote ();
5009
5009
@@ -5067,7 +5067,7 @@ public function remote_mediumAdd($args) {
5067
5067
$ this ->connect ();
5068
5068
5069
5069
/* @var $m IMedium */
5070
- $ m = $ this ->vbox ->openMedium ($ args ['path ' ],$ args ['type ' ],'ReadWrite ' ,false );
5070
+ $ m = $ this ->vbox ->openMedium ($ args ['path ' ], $ args ['type ' ], 'ReadWrite ' , false );
5071
5071
5072
5072
$ mid = $ m ->id ;
5073
5073
$ m ->releaseRemote ();
@@ -5470,13 +5470,14 @@ private function _mediumGetDetails(&$m) {
5470
5470
if ((string )$ m ->deviceType == 'HardDisk ' ) {
5471
5471
try {
5472
5472
list ($ id , $ cipher ) = $ m ->getEncryptionSettings ();
5473
- $ encryptionSettings = array (
5474
- 'id ' => $ id ,
5475
- 'cipher ' => $ cipher ,
5476
- );
5473
+ if ($ id ) {
5474
+ $ encryptionSettings = array (
5475
+ 'id ' => $ id ,
5476
+ 'cipher ' => $ cipher ,
5477
+ );
5478
+ }
5477
5479
} catch (Exception $ e ) {
5478
5480
// Pass. Encryption is not configured
5479
- $ encryptionSettings = array ();
5480
5481
}
5481
5482
5482
5483
}
@@ -5515,9 +5516,11 @@ private function _mediumGetDetails(&$m) {
5515
5516
*/
5516
5517
private function _util_progressStore (&$ progress ) {
5517
5518
5518
- /* Store vbox handle */
5519
+ /* Store vbox and session handle */
5519
5520
$ this ->persistentRequest ['vboxHandle ' ] = $ this ->vbox ->handle ;
5520
- $ this ->persistentRequest ['sessionHandle ' ] = $ this ->session ->handle ;
5521
+ if ($ this ->session ->handle ) {
5522
+ $ this ->persistentRequest ['sessionHandle ' ] = $ this ->session ->handle ;
5523
+ }
5521
5524
5522
5525
/* Store server if multiple servers are configured */
5523
5526
if (@is_array ($ this ->settings ->servers ) && count ($ this ->settings ->servers ) > 1 )
@@ -5559,12 +5562,12 @@ public function remote_vboxSystemPropertiesGet($args) {
5559
5562
$ scs = array ();
5560
5563
5561
5564
$ scts = array ('LsiLogic ' ,
5562
- 'BusLogic ' ,
5563
- 'IntelAhci ' ,
5564
- 'PIIX4 ' ,
5565
- 'ICH6 ' ,
5566
- 'I82078 ' ,
5567
- 'USB ' );
5565
+ 'BusLogic ' ,
5566
+ 'IntelAhci ' ,
5567
+ 'PIIX4 ' ,
5568
+ 'ICH6 ' ,
5569
+ 'I82078 ' ,
5570
+ 'USB ' );
5568
5571
5569
5572
foreach ($ scts as $ t ) {
5570
5573
$ scs [$ t ] = $ sp ->getStorageControllerHotplugCapable ($ t );
0 commit comments