Virtual Disk Development Kit

 View Only
  • 1.  How to dismount the volumes if the application crashes.

    Posted Mar 07, 2013 01:01 PM

    Hi,

    I am opening a vmdk file and mounting the volumes by using the below code

        m_vixError = VixDiskLib_Open(
            m_vixDiskLibCon,
            fileName,
            VIXDISKLIB_FLAG_OPEN_UNBUFFERED,
            &m_vixDiskLibHandle);
      
        m_vixError = VixMntapi_OpenDiskSet(
            &m_vixDiskLibHandle,
            1,
            0,
            &m_vixDiskSetHandle);

        m_vixError = VixMntapi_GetVolumeHandles(
            m_vixDiskSetHandle,
            &m_numberOfVolumes,
            &m_vixVolumeHandle);

      
        for ( int i = 0; i < m_numberOfVolumes; i++ )
        {
            m_vixError = VixMntapi_MountVolume(m_vixVolumeHandle[i], FALSE);
        }

    Doing some operation here.............


    ....... How to dismount the volumes and close the disk handles if the application CRASHES here.......

    Normally i'm using the below functions for unmounting the volumes and closing the disk handles

                VixMntapi_DismountVolume(m_vixVolumeHandle[i], TRUE);
                VixMntapi_FreeVolumeHandles(m_vixVolumeHandle);
                VixMntapi_CloseDiskSet(m_vixDiskSetHandle);
                VixDiskLib_Close(CVMDKFileRestore::vmdkVixDiskLibHandle.find(it->first)->second);

    Thanks

    Manickam



  • 2.  RE: How to dismount the volumes if the application crashes.

    Posted Mar 09, 2013 07:16 AM

    Hi Manickam,

    I think you are talking about cleanup of symlinks that you have created if the process have crashed - please refer to the following thread which gives the solution to the exact same problem.

    http://communities.vmware.com/thread/293782

    Thanks,

    ./Siva.



  • 3.  RE: How to dismount the volumes if the application crashes.

    Posted Mar 11, 2013 07:18 AM

    Hi,

    Thanks Siva,

    The given  link(Forum thread) explains about the implementation of  "Mounting and  dismounting the volumes through the two different processes in  parallel(With handles)".

    But i will need to dismount the volumes after the application crash(Without the handles).

    Thanks,

    manickam



  • 4.  RE: How to dismount the volumes if the application crashes.

    Posted Jun 23, 2013 06:29 PM

    Hi Manickam,

    In response to your redirection here Re: Unable to accessing VMDK files of Windows 2012 Guest os with VixMntApi. (VMDK files of other guest OSs are working f… : you say

    RManickam wrote:

    If the application crashes before 3rd step.,We will not be able to Dismount the VMDK file and we will not be able to mount the vmdk file again.

    What are the exact symptoms? Why are you not able to mount the vmdk file again? You say it depends on R/W mode switched on or off. As it works in read only mode, what is different in R/W mode. What do the VDDK logs present when you try to remount in R/W mode. Do you see any problems being reported when the VDDK actually tries to open the uncleanly shutdown disks? Which kind of disks are we talking about, FLAT - SPLIT - SPARSE - MONOLITHIC?

    --

    Thomas G.



  • 5.  RE: How to dismount the volumes if the application crashes.
    Best Answer

    Posted Jun 24, 2013 09:34 PM

    Hi Manickam,

    In response to your post here (please do not cross post between different discussions)

    Finally :-)))

    I think chances are good that there is some light at the end of the tunnel - at least regarding your dismount problem.

    In the above scenario.,If i will try to mount the vmdk file after the above crash,I am getting the following error message

    Read error : The specified virtual disk needs repair

    I was hoping that you would report this error. Unfortunately I am currently not behind my development machine which means I do not have the VDDK header files available right now but if I remember correctly there must be a function named VixDiskLib_CheckRepair(...) in vixDiskLib.h. Take a look at it and its docs. This should be the function you are looking for. The thing is that this function clears the unclean shutdown flag set in the uncleanly shutdown .vmdk file. The unclean shutdown results from the crash.

    As soon as I am back behind my development machine I will send you a snippet of my mount test routine which exactly addresses the unclean shutdonw flag via VixDiskLib_CheckRepair(...).

    Hold on I will get back to you in about 10 hours ;-)

    --

    Thomas G.



  • 6.  RE: How to dismount the volumes if the application crashes.

    Posted Jun 25, 2013 08:00 AM

    Hi Thomas,

    Thanks a lot.

    VixDiskLib_CheckRepair(...) is working fine.,With this function now i can able to use the vmdk files which are all not properly unmounted.

    Thanks

    Manickam



  • 7.  RE: How to dismount the volumes if the application crashes.

    Posted Jun 25, 2013 08:13 AM

    Hi Manickam,

    Great to hear that you finally managed to reopen the disks. One more thing I want to stress with respect to this. The problem is not that you actually have not dismounted the disk properly, to me it seems that the vstor driver does that properly, but that you did not VixDiskLib_Close(...) the disks properly. That is VixDiskLib_CheckRepair(...) should always be your friend when you have to reckon with disks that have not been closed properly for any reason.


    Here is wishing happy coding ;-)

    --

    Thomas G.



  • 8.  RE: How to dismount the volumes if the application crashes.

    Posted Jun 25, 2013 07:07 AM

    Hi Manickam,

    Just back behind my development machine here the code which safeguards you against the "disk needs repair error":

         // Open disk to mount
         VixDiskLibHandle lnv_mountDiskHandle = NULL;
         li_vixError = VixDiskLib_Open(lnv_connection, MOUNT_DISK_NAME,
              MOUNT_RW ? 0 : VIXDISKLIB_FLAG_OPEN_READ_ONLY, &lnv_mountDiskHandle);
         if (VIX_ERROR_CODE(li_vixError) == VIX_E_DISK_NEEDSREPAIR)
         {
              li_vixError = VixDiskLib_CheckRepair(lnv_connection, MOUNT_DISK_NAME,
                   TRUE);
              li_vixError = VixDiskLib_Open(lnv_connection, MOUNT_DISK_NAME,
                   MOUNT_RW ? 0 : VIXDISKLIB_FLAG_OPEN_READ_ONLY
                   , &lnv_mountDiskHandle);
         }
         ABORT_IF_ERROR(li_vixError)
    

    As I said it's a snippet from my test mount routine but I guess adaption to your needs should be straight forward.

    Please let me know whether this solves your problem :-)

    --

    Thomas G.