Quantcast
Channel: VMware Communities : Discussion List - Backup & Recovery
Viewing all articles
Browse latest Browse all 1844

Backup vm to NFS server fail using VDDK5.5 or higher in CentOS7(7.1,7.2,7.3)

$
0
0

I write a program to backup vm to a NFS server using VDDK 5.5 or higher.

The program run correctly on CentOS 6.5. But on CentOS 7, there must be a error with errno=13.

 

 

In the code, directory '/tmp/backup/centos722' is a mounpoint of a NFS server.

 

I have try the following on CentOS 7:

1. write a program without any VDDK, just only write data into NFS mountpoint. There is NO error.

2. write a program with VDDK( only call VixDiskLib_InitEx() function) and write data into NFS mountpoint. There is an error with errno=13.

3. write a program with VDDK( only call VixDiskLib_InitEx() function) and write data into local disk path. There is NO error.

 

 

the code is :

#include <sys/types.h>

#include <sys/stat.h>

#include <stdlib.h>

#include <stdio.h>

#include <fcntl.h>

#include <errno.h>

#include <unistd.h>

#include <time.h>

#include <stdlib.h>

#include <stdio.h>

 

#include  <vixDiskLib.h>

 

#define VIXDISKLIB_VERSION_MAJOR 6

#define VIXDISKLIB_VERSION_MINOR 0

 

#define LOG_FLAG_DEBUG     "[DEBUG] "

#define LOG_FLAG_INFO      "[INFO] "

#define LOG_FLAG_WARN      "[WARN] "

#define LOG_FLAG_ERROR     "[ERROR] "

 

uint32 GetVix_Disk_Lib_Version_Major()

{

    return VIXDISKLIB_VERSION_MAJOR;

}

 

uint32 GetVix_Disk_Lib_Version_Minor()

{

    return VIXDISKLIB_VERSION_MINOR;

}

 

void LogFunc(const char *fmt, va_list args)

{

   printf("%s",LOG_FLAG_INFO);

   vprintf(fmt, args);

}

void LogFunc2(const char *fmt, va_list args)

{

    printf("%s",LOG_FLAG_INFO);

    vprintf(fmt, args);

}

 

void WarnFunc(const char *fmt, va_list args)

{

   printf("%s",LOG_FLAG_WARN);

   vprintf(fmt, args);

}

 

 

void WarnFunc2(const char *fmt, va_list args)

{

    printf("%s",LOG_FLAG_WARN);

    vprintf(fmt, args);

}

 

void PanicFunc(const char *fmt, va_list args)

{

   printf("%s",LOG_FLAG_ERROR);

   vprintf(fmt, args);

   exit(10);

}

 

void PanicFunc2(const char *fmt, va_list args)

{

    printf("%s",LOG_FLAG_ERROR);

    vprintf(fmt, args);

    exit(10);

}

 

int main(int argc, char * args[])

{

    char *pszFileName = "/usr/backup/12.vmdk";

    // pszFileName = "/tmp/backup/centos722/12.vmdk";

    int iBufferSize = 64 * 1024 + 1;

    char *pszBuffer = (char*)malloc(iBufferSize + 1);

    memset(pszBuffer,0,iBufferSize + 1);

 

    char *pszConfigFileName = NULL;

    VixError vixError;   

    vixError = VixDiskLib_InitEx(GetVix_Disk_Lib_Version_Major(),

                                 GetVix_Disk_Lib_Version_Minor(),

                                 LogFunc, WarnFunc, PanicFunc,

                                 "/usr/lib/vmware-vix-disklib",

                                 pszConfigFileName);

   

 

    int iFileHandle = open(pszFileName,O_RDWR   |  O_TRUNC | O_CREAT );

    if(iFileHandle < 0)

    {

        printf("Open %s fail. ErrorNo=%d\r\n",  pszFileName,errno);

       

        return 1; 

    }

   

    int iCount= 8000;

    int i=0;

    int iWriteSize = 0;

    for(i=0; i<iCount; i++)

    {

        iWriteSize=write(iFileHandle,pszBuffer,iBufferSize);

        if(iWriteSize < 1)

        {

            printf("Write Fail at i=%d,count=%d,errno=%d\r\n",i,iCount,errno);

        }

    }

    free(pszBuffer);

    close(iFileHandle);

}

 

compile command:

gcc -c -D LINUX -D LINUX_X64 -D _REENTRANT  -I/usr/lib/vmware-vix-disklib/include   -O3 -Wall TestWriteFile.cpp -o TestWriteFile.o

gcc -Wl,-Map,TestWriteFile.map -o TestWriteFile TestWriteFile.o -lpthread -lm -lc -lstdc++ /usr/lib/vmware-vix-disklib/lib64/libvixDiskLib.so


Viewing all articles
Browse latest Browse all 1844

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>