@@ -5431,6 +5431,12 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
54315431 return diag .FromErr (err )
54325432 }
54335433
5434+ if stoppedBeforeUpdate {
5435+ if er := vmShutdown (ctx , vmAPI , d ); er != nil {
5436+ return er
5437+ }
5438+ }
5439+
54345440 rebootRequired = rebootRequired || rr
54355441
54365442 // Prepare the new efi disk configuration.
@@ -5507,8 +5513,10 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
55075513 if mustMove || mustChangeDatastore || existingInterface == "" {
55085514 // CloudInit must be moved, either from a device to another or from a datastore
55095515 // to another (or both). This requires the VM to be stopped.
5510- if er := vmShutdown (ctx , vmAPI , d ); er != nil {
5511- return er
5516+ if ! stoppedBeforeUpdate {
5517+ if er := vmShutdown (ctx , vmAPI , d ); er != nil {
5518+ return er
5519+ }
55125520 }
55135521
55145522 if er := deleteIdeDrives (ctx , vmAPI , initializationInterface , existingInterface ); er != nil {
@@ -5749,6 +5757,11 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
57495757 // Update the configuration now that everything has been prepared.
57505758 updateBody .Delete = del
57515759
5760+ e = vmAPI .UpdateVM (ctx , updateBody )
5761+ if e != nil {
5762+ return diag .FromErr (e )
5763+ }
5764+
57525765 // Determine if the state of the virtual machine state needs to be changed.
57535766 //nolint: nestif
57545767 if (d .HasChange (mkStarted ) || stoppedBeforeUpdate ) && ! bool (template ) {
@@ -5766,11 +5779,6 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
57665779 }
57675780 }
57685781
5769- e = vmAPI .UpdateVM (ctx , updateBody )
5770- if e != nil {
5771- return diag .FromErr (e )
5772- }
5773-
57745782 if stoppedBeforeUpdate && d .Get (mkStarted ).(bool ) {
57755783 if diags := vmStart (ctx , vmAPI , d ); diags != nil {
57765784 return diags
0 commit comments