Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Add support for VixDiskLib_PrepareForAccess.
Browse files Browse the repository at this point in the history
We should tell Vsphere we are opening disks e.g. call
VixDiskLib_PrepareForAccess() before opening and VixDiskLib_EndAccess()
after closing.

From the include file:

This function is used to notify the host of the virtual machine that the
disks of the virtual machine will be opened. The host disables
operations on the virtual machine that may be adversely affected
if they are performed while the disks are open by a third party
application.
  • Loading branch information
Marco van Wieringen committed Oct 2, 2015
1 parent 5e9df67 commit 9c0b243
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions vadp_dumper/bareos_vadp_dumper.cpp
Expand Up @@ -87,6 +87,8 @@
#define BAREOSMAGIC 0x12122012
#define PROTOCOL_VERSION 1

#define BAREOS_VADPDUMPER_IDENTITY "BareosVADPDumper"

/*
* Generic identification structure, 128 bytes with padding.
* This includes a protocol version.
Expand Down Expand Up @@ -357,16 +359,35 @@ static inline void cleanup_vixdisklib()
*/
static void cleanup(int sig)
{
VixError err;

if (info) {
VixDiskLib_FreeInfo(info);
}

if (diskHandle) {
VixDiskLib_Close(diskHandle);
diskHandle = NULL;
}

if (connection) {
VixDiskLib_Disconnect(connection);
if (cleanup_on_disconnect) {
cleanup_vixdisklib();
}
}

if (!local_vmdk) {
err = VixDiskLib_EndAccess(&cnxParams, BAREOS_VADPDUMPER_IDENTITY);
if (VIX_FAILED(err)) {
char *error_txt;

error_txt = VixDiskLib_GetErrorText(err, NULL);
fprintf(stderr, "Failed to End Access: %s [%d]\n", error_txt, err);
VixDiskLib_FreeErrorText(error_txt);
}
}

cleanup_cnxParams();

VixDiskLib_Exit();
Expand Down Expand Up @@ -477,9 +498,20 @@ static inline void do_vixdisklib_connect(const char *key, json_t *connect_params
}
snapshot_moref = json_string_value(object);
}

if (!local_vmdk) {
err = VixDiskLib_PrepareForAccess(&cnxParams, BAREOS_VADPDUMPER_IDENTITY);
if (VIX_FAILED(err)) {
char *error_txt;

error_txt = VixDiskLib_GetErrorText(err, NULL);
fprintf(stderr, "Failed to Prepare For Access: %s [%d]\n", error_txt, err);
VixDiskLib_FreeErrorText(error_txt);
}
}
}
err = VixDiskLib_ConnectEx(&cnxParams, (readonly) ? TRUE : FALSE, snapshot_moref, vixdisklib_config, &connection);

err = VixDiskLib_ConnectEx(&cnxParams, (readonly) ? TRUE : FALSE, snapshot_moref, vixdisklib_config, &connection);
if (VIX_FAILED(err)) {
char *error_txt;

Expand All @@ -494,10 +526,6 @@ static inline void do_vixdisklib_connect(const char *key, json_t *connect_params
bail_out:
if (!succeeded) {
cleanup(1);
} else if (!cleanup_on_disconnect) {
if (!local_vmdk) {
cleanup_cnxParams();
}
}
}

Expand Down Expand Up @@ -1113,6 +1141,7 @@ static inline bool process_cbt(const char *key, json_t *cbt)
bail_out:
if (diskHandle) {
VixDiskLib_Close(diskHandle);
diskHandle = NULL;
}

return retval;
Expand Down Expand Up @@ -1236,6 +1265,7 @@ static inline bool process_restore_stream(bool validate_only, json_t *value)
bail_out:
if (diskHandle) {
VixDiskLib_Close(diskHandle);
diskHandle = NULL;
}

return retval;
Expand Down

0 comments on commit 9c0b243

Please sign in to comment.