SCVMM 2008 R2 VM Status Tricks


I experienced couple times the VM migration stuck in middle of the process due to this and that reasons. After the failed migration, there is not much you can do in the SCVMM console, as the only choice you can do is to click ‘repair’ to try to fix it. But sometimes, the repair can not repair it.

I did some researches in the SCVMM database, in which you have more control. Please be very careful when you change the database, a full backup is always needed before you modify anything.

Launch the ‘Microsoft SQL Server Management Studio’ and navigate to the SCVMM DB, then right click the table ‘dbo.tbl_WLC_VObject’ and choose ‘Open table’.

image

The ObjectType means the VM file type: 46 is snapshot, 1 is normal VM, 3 is the VM template. The ObjectState means the VM status: 0 is running, 1 is stopped, 107 is update failed, 201 is migration failed, 220 is missing, 223 is incomplete configuration, 225 is unsupported cluster configuration …

image

Here are my two real examples:

Example 1

Issue: The VM migration failed and unfortunately the repair is unable to solve it. The VM status shows ‘Migration failed’.

Resolution: Find the VM in the table and change the ObjectState value from 201 to 0, then go back to SCVMM console and right click the VM, more options are displayed. I can do the migration from scratch instead of retrying the failed job.

Example 2

Issue: The VM has already been removed from the cluster, but somehow it is still listed in the VM inventory. The VM status shows ‘unsupported cluster configuration’.

Resolution: Run the following SQL script to clean the VM. The ObjectState value of ‘unsupported cluster configuration’ is 225. The script can also be used for other cases, like missing (220). After the SQL was executed, restart the Virtual Machine Manager service on SCVMM server.

*************************************************

BEGIN TRANSACTION T1

DECLARE custom_cursor CURSOR FOR
SELECT ObjectId from
dbo.tbl_WLC_VObject WHERE [ObjectState] = 225
DECLARE @ObjectId uniqueidentifier
OPEN custom_cursor
FETCH NEXT FROM custom_cursor INTO @ObjectId
WHILE(@@fetch_status = 0)
BEGIN
DECLARE vdrive_cursor CURSOR FOR
SELECT VDriveId, VHDId, ISOId from
dbo.tbl_WLC_VDrive WHERE ParentId = @ObjectId
DECLARE @VDriveId uniqueidentifier
DECLARE @VHDId uniqueidentifier
DECLARE @ISOId uniqueidentifier

OPEN vdrive_cursor
FETCH NEXT FROM vdrive_cursor INTO @VDriveId, @VHDId, @ISOId
WHILE(@@fetch_status = 0)
BEGIN
  DELETE FROM dbo.tbl_WLC_VDrive
         WHERE VDriveId = @VDriveId
  if(@VHDId is NOT NULL)
  BEGIN
   DELETE FROM dbo.tbl_WLC_VHD
   WHERE VHDId = @VHDId
   DELETE FROM dbo.tbl_WLC_PhysicalObject
   WHERE PhysicalObjectId = @VHDId
  END
  if(@ISOId is NOT NULL)
  BEGIN
   DELETE FROM dbo.tbl_WLC_ISO
          WHERE ISOId = @ISOId
   DELETE FROM dbo.tbl_WLC_PhysicalObject
   WHERE PhysicalObjectId = @ISOId
  END
     FETCH NEXT FROM vdrive_cursor INTO @VDriveId, @VHDId, @ISOId
   END
CLOSE vdrive_cursor
DEALLOCATE vdrive_cursor
—————–
DECLARE floppy_cursor CURSOR FOR
SELECT VFDId, vFloppyId from
dbo.tbl_WLC_VFloppy WHERE HWProfileId = @ObjectId
DECLARE @vFloppyId uniqueidentifier
DECLARE @vfdId uniqueidentifier
OPEN floppy_cursor
FETCH NEXT FROM floppy_cursor INTO @vfdId, @vFloppyId
WHILE(@@fetch_status = 0)
BEGIN
      DELETE FROM dbo.tbl_WLC_VFloppy
  WHERE VFloppyId = @vFloppyId
  if(@vfdid is NOT NULL)
  BEGIN
   DELETE FROM dbo.tbl_WLC_VFD
   WHERE VFDId = @vfdId
   DELETE FROM dbo.tbl_WLC_PhysicalObject
   WHERE PhysicalObjectId = @vfdId
  END
     FETCH NEXT FROM floppy_cursor INTO @vfdId, @vFloppyId
   END
CLOSE floppy_cursor
DEALLOCATE floppy_cursor
—————-
DECLARE checkpoint_cursor CURSOR FOR
SELECT VMCheckpointId from
dbo.tbl_WLC_VMCheckpoint WHERE VMId = @ObjectId
DECLARE @vmCheckpointId uniqueidentifier
OPEN checkpoint_cursor
FETCH NEXT FROM checkpoint_cursor INTO @vmCheckpointId
WHILE(@@fetch_status = 0)
BEGIN
      DELETE FROM dbo.tbl_WLC_VMCheckpointRelation
  WHERE VMCheckpointId = @vmCheckpointId
     FETCH NEXT FROM checkpoint_cursor INTO @vmCheckpointId
   END
CLOSE checkpoint_cursor
DEALLOCATE checkpoint_cursor
————————-
———Clean checkpoint
DELETE FROM dbo.tbl_WLC_VMCheckpoint
WHERE VMId = @ObjectID

        exec [dbo].[prc_VMMigration_Delete_VMInfoAndLUNMappings] @ObjectId
        DECLARE @RefreshId uniqueidentifier
        exec [dbo].[prc_RR_Refresher_Delete] @ObjectId, @RefreshId

        DELETE FROM dbo.tbl_WLC_VAdapter
WHERE HWProfileId = @ObjectId

        DELETE FROM dbo.tbl_WLC_VNetworkAdapter
WHERE HWProfileId = @ObjectId
        DELETE FROM dbo.tbl_WLC_VCOMPort
WHERE HWProfileId = @ObjectId
        DELETE FROM dbo.tbl_WLC_HWProfile
        WHERE HWProfileId = @ObjectId
        DELETE FROM dbo.tbl_WLC_VMInstance
        WHERE VMInstanceId = @ObjectId
DELETE FROM dbo.tbl_WLC_VObject
WHERE ObjectId = @ObjectId
    FETCH NEXT FROM custom_cursor INTO @ObjectId
  END
CLOSE custom_cursor
DEALLOCATE custom_cursor
COMMIT TRANSACTION T1

*************************************************

Reference: http://technet.microsoft.com/en-us/library/ff641854.aspx

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s