VixDiskLibSample: test virtual disks correctly

When we are faced with a certain software product with which we have to interact, we are free to choose the scenario of interaction ourselves. You can heroically reinvent the wheel, or you can hope that the authors know their product somewhat better than we do, so the API (or set of libraries) they provide is the optimal solution. In practice, unfortunately, not everything is so rosy, but today is not about that.



For many years, VMware has provided the VDDK to work with its disk subsystem, a sprawling set of libraries, documentation, and code samples that your application can use to work with virtual machine disks. Of course, at Veeam, we really don't like reinventing unnecessary bicycles, so VDDK is used very actively in our products.



But this still does not affect the number of clients who believe that working with disks can be even faster, and all the proposed performance tests show incorrect results a priori. It is at such moments that the ultimate weapon comes to our aid - VixDiskLibSample.







VixDiskLibSample is a small C ++ program included in the VDDK and demonstrates the principles of working with the vixDiskLib library, that is, no one will work with virtual machine disks better and faster than it. And what is especially important for us, it can be used as a benchmark for writing and reading. A sort of ultimatum test, the results of which can hardly be called invalid.



You can get it along with the VDDK itself. Download it from the VMware website and, in the case of Linux, just compile it after installation



[root@toor diskLib] cd /usr/lib/vmware-vix-disklib/doc/samples/diskLib
[root@toor diskLib] ls
Makefile  vixDiskLibSample.cpp
[root@toor disklib] make
[root@toor diskLib] ls
Makefile  vix-disklib-sample  vixDiskLibSample.cpp


The default installation path.

 

/usr/share/doc/vmware-vix-disklib/samples/disklib


There is also information on the network that on some distributions you need to add the following lines to vixDiskLibSample.cpp for successful compilation:



#else
#include <stdio.h>
#include <string.h>


If it does not compile in this case, then it is recommended to try adding the environment variable LD_LIBRARY_PATH = / usr / lib / vmware-vix-disklib / lib64 and run ldconf as root after adding the address / usr / lib / vmware-vix-disklib / lib64 to /etc/ld.so.conf.d/vmware-vix-disklib.conf



But under Windows in Visual Studio everything compiles without problems. And a note to the mistress: VDDK in Veeam is used only when working through a Windows proxy. On Linux, for a number of reasons, it uses its own solution using the vSphere API.  



What about Veeam users, you ask?



We answer: by connecting VDDK libraries of different versions that come with Veeam Backup & Replication, you can check the true speed of work with the host in a wide variety of modes.



Libraries are stored at C: \ Program Files (x86) \ Veeam \ Backup Transport \ x64 \ vddk_X_X , and their use is mandatory for correct results.



Now let's take a look at the most important commands and options for us at startup. For, as with all testing tools, the complete list here is very, very small.



-readbench Run the read benchmark with the specified block size. The size is indicated in sectors. 

 -writebench Everything is the same, only writing. Important:This is a destructive operation! The recording is fair! Do not try to launch a production machine! It will be overwritten with binary garbage!

-multithread N Since version 6.5, can be used in parallel to work with multiple disks.

-host Host to connect to. It can be in the form of a DNS name, or IP.

-user User according to the domain \ user

scheme -password I think it's clear 

-vm vmPath = / path / to / vm This is if we know where our machine is located, but we do not know its other coordinates

-vm "moref = vm-XXX" Path to cars in inventory. He's moref. The easiest way to find it is through the MOB at https: //vcenter.local/mob/ Important:if you just have a lonely host without vCenter, use moref = XXX, without vm

-ssmoref Link to a snapshot of your machine, because, as you know, reading data from disks is one thing, and another thing when a snapshot is in your way. Or a few snapshots. Required parameter (as well as the snapshot itself) for the included machines.

-mode A parameter indicating the mode of working with the disk. Refers to VixDiskLib_ConnectEx. The available values ​​are nbd, nbdssl, san, and hotadd. All of them are well known to our users.

-libdir Path to the library folder. The default should be "C: \ Program Files (x86) \ Veeam \ Backup Transport \ x86 \ vddk_X_X" If you work with a standalone host, you can leave it blank.

-thumbIntroduced in version 6.0, a mandatory parameter for specifying an SSL certificate fingerprint. It won't work without it. The easiest way is to spy on the browser;)

-initex configfile Path to the config file for VixDiskLib_InitEx



Detailed logs are written by default to the 

C: \ Users \ current user \ AppData \ Local \ Temp \ vmware-current user \ vixDiskLib - #### folder. log

For a hassle-free life, I strongly advise you to empty this folder after each test run in san and hotadd modes. And close the window with the console (I mean Windows cmd, not Linux). This is due to the peculiarity of the VDDKEndAccess function, which is not called if the test is terminated by Ctrl + C, and the test disks remain attached to the selected machine. 



Now that we are done with the general theory, go to section



Practice



The general startup syntax looks like 



vixdisklibsample.exe command [options] diskPath


In the simplest case, we can connect to the host by specifying its name, login, password and path to the desired machine.



C:\VDDK\bin>vixDiskLibSample.exe -info -host demo -user root -password secret [datastore1] test/test.vmdk


-info will show the DiskPath of the selected drive.



If the host is connected to the vCenter, the -libdir and -vm options must be added. In the case of VDDK> 6.0, do not forget about -thumb



C:\VDDK\bin>vixDiskLibSample.exe -info -host demo -user Administrator -password secret -thumb "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" -libdir "C:\Program Files (x86)\Veeam\Backup Transport\x86\vddk_X_X" -vm vmPath=Datastorage/vm/DemoVM "[datastore1] DemoVM/Demo.vmdk"




And then the fun begins: we specify -mode and -ssmoref. I highly recommend doing all tests with a snapshot, so as not to accidentally spoil the original disk. And remember: the write test is a destructive operation! It actually writes data, not simulates the process!



On the other hand, I can’t forbid you anything either.



So, we run the write test in Hotadd mode



C:\VDDK\bin>vixDiskLibSample.exe -writebench 1024 -host demo.local -user "demo\adm" -password "%TOPSECRET%" -vm "moref=vm-80380" -ssmoref "snapshot-82782" -thumb "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"
-mode hotadd -libdir "C:\Program Files (x86)\Veeam\Backup Transport\x86\vddk_6_0" "[datastore1] test/test.vmdk"

appGlobals.port902VixDiskLib: Invalid configuration file parameter.  Failed to read configuration file.
Disk "[datastore1] test/test-000001.vmdk" is open using transport mode "hotadd".
ReadFlag  : 0
Processing 10240 buffers of 1048576 bytes.
Wrote 64 MBytes in 2699 msec (23 MBytes/sec)
Wrote 64 MBytes in 2667 msec (23 MBytes/sec)
Wrote 64 MBytes in 687 msec (93 MBytes/sec)
Wrote 64 MBytes in 608 msec (105 MBytes/sec)
Wrote 64 MBytes in 687 msec (93 MBytes/sec)
...
Wrote 64 MBytes in 795 msec (80 MBytes/sec)
Wrote 64 MBytes in 749 msec (85 MBytes/sec)
Wrote 64 MBytes in 1326 msec (48 MBytes/sec)
Wrote 64 MBytes in 2465 msec (25 MBytes/sec)
Wrote 64 MBytes in 2449 msec (26 MBytes/sec)
Wrote 10240 MBytes in 141040 msec (72 MBytes/sec)
Deleted directory C:\Users\ADMINI~1\AppData\Local\Temp\2\vmware-Administrator\4206be79-cfef-4175-51a5-6e7c0900591b-vm-80380\hotadd


For SAN mode, everything is the same, but keep in mind that for this test cmd must be run with administrator rights, otherwise you will receive errors "You do not have access rights to this file" and "No path to device LVID".



And if you want to test the recovery option in Direct SAN mode, then you need to specify the fake UUID in the HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ VMware, Inc. \ volatile \ UUIDHost branch



Now let's try to run the read speed test in nbd mode.



C:\VDDK\bin>vixDiskLibSample.exe -readbench 1024 -host demo.local -user "demo\adm" -password "%TOPSECRET%" -vm "moref=vm-80380" -ssmoref "snapshot-82782" -thumb "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"  -ssmoref "snapshot-82782"
-mode nbd -libdir "C:\Program Files (x86)\Veeam\Backup Transport\x86\vddk_6_0" "[datastore1] test/test.vmdk"

appGlobals.port902VixDiskLib: Invalid configuration file parameter.  Failed to read configuration file.
Disk "[datastore1] test/test.vmdk" is open using transportmode "nbd".
ReadFlag  : 4
Processing 20480 buffers of 524288 bytes.
Read 64 MBytes in 2293 msec (27 MBytes/sec)
Read 64 MBytes in 2153 msec (29 MBytes/sec)
Read 64 MBytes in 1747 msec (36 MBytes/sec)
Read 64 MBytes in 2013 msec (31 MBytes/sec)
Read 64 MBytes in 2823 msec (22 MBytes/sec)


If you want to give a real load, feel free to run -readbench or -writebench for several disks at once. But for this you need VDDK 6.5 or 7.0



C:\VDDK\bin\vixDiskLibSample.exe" -readbench 1024 -host "10.0.0.1" -user "AD\user" -password "****" -vm "moref=vm-1" -ssmoref "snapshot-100" -thumb "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" -mode san -libdir "C:\Program Files (x86)\Veeam\Backup Transport\x64\vddk_6_5" -initex "C:\VDDK60\initex.txt" "[Datastore01] VM/VM.vmdk" "[Datastore01] VM/VM_1.vmdk" "[Datastore01] VM/VM_2.vmdk" "[Datastore01] VM/VM_3.vmdk


Finally, let's see what information about virtual disks we can get using -info



C:\VDDK\bin>vixDiskLibSample.exe -info -host demo.local -user "demo\adm" -password "%TOPSECRET%" -vm "moref=vm-80380"
-ssmoref "snapshot-82787" -thumb "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" -mode nbd -libdir "C:\Program Files (x86)\Veeam\Backup Transport\x86\vddk_6_0" "[datastore1] test/test.vmdk"

appGlobals.port902VixDiskLib: Invalid configuration file parameter.  Failed to read configuration file.
Disk "[datastore1] test/test.vmdk" is open using transport mode "nbd".
capacity          = 20971520 sectors
number of links   = 1
adapter type      = LsiLogic SCSI
BIOS geometry     = 0/0/0
physical geometry = 1305/255/63
Transport modes supported by vixDiskLib: file:san:hotadd:nbdssl:nbd


By the way, if you suddenly don't want to risk real disks from real machines, you can create them here. True, through -create you cannot create a disk immediately on the host, but here the -clone option comes to our rescue. The -cap parameter sets the size in megabytes, and this is more convenient to do on a linux machine.



./vix-disklib-sample -create -cap 1024 newdisk.vmdk
./vix-disklib-sample -clone virtdisk.vmdk –host demo.local –user root –password TOP_SECRET newdisk.vmdk


This concludes my quick excursion into the world of wide possibilities of VixDiskLibSample. Yes, in some places the utility is somewhat blockhead, and its output is not very convenient. However, you can always make something of your own based on it, which will allow you to elegantly solve your problems without the invention of bicycles and the use of indistinct layers.



And some useful links at the end:



  • Any version of the VDDK can be downloaded from this link . By default, you will be offered 7.0, but from above you can switch at least to 5.1
  • VDDK.



All Articles