hidemium's blog

日々学んだことをアウトプットする。

VDDKのサンプルコードを動かしてみる

VDDK (Virtual Disk Development Kit) は、VMDKの作成やアクセスを行うことができるC ライブラリになります。VDDKのサンプルコードを動かしてみたので、書いてみようと思います。

構成

  • vCenter 7.0 U3
  • ESXi 7.0 Update 3
  • VDDK 7.0.3.3
  • Ubuntu 22.04 (作業用VM)

VDDKとは

VDDKの中には以下のコンポーネントが含まれています。

  • 仮想ディスク ライブラリ。VMDK ファイルを操作するための C 関数呼び出しのセット
  • ディスク マウント ライブラリ。VMDK ファイル システムをリモート マウントするための C 関数呼び出しのセット
  • Visual Studio または GNU C コンパイラコンパイルできる C++ コード サンプル
  • PDF マニュアルとオンライン HTML リファレンス

仮想ディスク ライブラリには、以下の機能があります。

  • 仮想ディスク ファイルの作成、変換、拡張、最適化、縮小、および名前変更
  • REDO ログ (親子ディスク チェーン、つまりデルタ)の作成、VMDK ファイルの削除
  • VMDK ファイル内の任意の場所のデータへのランダムな読み取り/書き込みアクセス、メタデータを読み取り
  • SANやHotAddといった高度なトランスポートを使用したリモートの vSphere ストレージ接続

インストール

それでは、VDDKをインストールしてみます。

以下からVDDKをダウンロードします。

VMware Virtual Disk Development Kit (VDDK)

ダウンロードすると、以下のファイルを入手することができます。

  • VMware-vix-disklib-7.0.3-21933544.x86_64.tar.gz

以下のディレクトリに移動し、解凍を行います。

cd /u
sudo tar xzf ./VMware-vix-disklib-7.0.3-21933544.x86_64.tar.gz 

以下の設定を行い、共有ライブラリをシステムに認識させます。

sudo vi /etc/ld.so.conf.d/vmware-vix-disklib.conf 
/usr/lib/vmware-vix-disklib-distrib/lib64
sudo ldconfig

共有ライブラリのパスが通っていない場合、以下のようなエラーが出ます。

./vixDiskLibSample: error while loading shared libraries: libvixDiskLib.so.7.0.3: cannot open shared object file: No such file or directory

サンプルコードのあるディレクトリに移動します。

cd /usr/lib/vmware-vix-disklib-distrib/doc/samples/diskLib/
tree
.
├── Makefile
├── vixDiskLibSample
├── vixDiskLibSample.cpp
└── vixMntapiSample

usageを見てみます。

sudo ./vixDiskLibSample
Usage: vixdisklibsample.exe command [options] diskPath

List of commands (all commands are mutually exclusive):
 -create : creates a sparse virtual disk with capacity specified by -cap
 -redo parentPath : creates a redo log 'diskPath' for base disk 'parentPath'
 -info : displays information for specified virtual disk
 -dump : dumps the contents of specified range of sectors in hexadecimal
 -mount : mount the virtual disk specified
 -fill : fills specified range of sectors with byte value specified by -val
 -wmeta key value : writes (key,value) entry into disk's metadata table
 -rmeta key : displays the value of the specified metada entry
 -meta : dumps all entries of the disk's metadata
 -clone sourcePath : clone source vmdk possibly to a remote site
 -compress type: specify the compression type for nbd transport mode
 -readbench blocksize: Does a read benchmark on a disk using the 
specified I/O block size (in sectors).
 -writebench blocksize: Does a write benchmark on a disk using the
specified I/O block size (in sectors). WARNING: This will
overwrite the contents of the disk specified.
 -readasyncbench blocksize: Does an async read benchmark on a disk using the 
specified I/O block size (in sectors).
 -writeasyncbench blocksize: Does an async write benchmark on a disk using the
specified I/O block size (in sectors). WARNING: This will
overwrite the contents of the disk specified.
 -getallocatedblocks : gets allocated block list on a disk using the 
specified I/O block size (in sectors).
 -check repair: Check a sparse disk for internal consistency, where repair is a boolean value to indicate if a repair operation should be attempted.

各オプションについてイメージが付きづらいですが、vixDiskLibSampleに対応する関数とコールされるVDDKの関数の詳細はドキュメントに記載あります。

Command Functions - VMware Virtual Disk Development Kit Programming Guide (7.0.3)

vixDiskLibSampleを実行するために、vCenterのThumbprintが必要なため、govcで取得します。

govc about.cert
:
Thumbprints:                 
  SHA-256 Thumbprint:      <Thumbprint> 
  SHA-1 Thumbprint:        <Thumbprint> 

まずは、仮想マシンのVMDKの情報を取得してみます。

sudo ./vixDiskLibSample -info -host <vCenter IPアドレス> -user <username> -password <password> -vm "moref=<仮想マシンのmoid>" -thumb  <Thumbprint> "[Datastore] test/test.vmdk"

Disk[0] "[Datastore] test/test.vmdk is opened using transport mode "nbd".
capacity             = 209715200 sectors
logical sector size  = 512 bytes
physical sector size = 512 bytes
number of links      = 1
adapter type         = LsiLogic SCSI
BIOS geometry        = 0/0/0
physical geometry    = 13054/255/63
Transport modes supported by vixDiskLib: file:nbdssl:nbd
Disk[0] is closed.

VMDKの容量やトランスポートモードでNBDがサポートされることが確認できます。

次に、dumpというものを試し見ます。dumpは VixDiskLib_Read() を呼び出してセクタを取得し、セクタの内容を16 進数で出力します。

sudo ./vixDiskLibSample -dump -host <vCenter IPアドレス> -user <username> -password <password> -vm "moref=<仮想マシンのmoid>" -thumb  <Thumbprint> "[Datastore] test/test.vmdk"
Disk[0] "[Datastore] test/test.vmdk is opened using transport mode "nbd".
0000 : eb 63 90 00 00 00 00 00 00 00 00 00 00 00 00 00   .c..............
0010 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0020 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0030 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0040 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0050 : 00 00 00 00 00 00 00 00 00 00 00 80 00 08 00 00   ................
0060 : 00 00 00 00 ff fa 90 90 f6 c2 80 74 05 f6 c2 70   ...........t...p
0070 : 74 02 b2 80 ea 79 7c 00 00 31 c0 8e d8 8e d0 bc   t....y|..1......
0080 : 00 20 fb a0 64 7c 3c ff 74 02 88 c2 52 bb 17 04   . ..d|<.t...R...
0090 : f6 07 03 74 06 be 88 7d e8 17 01 be 05 7c b4 41   ...t...}.....|.A
00a0 : bb aa 55 cd 13 5a 52 72 3d 81 fb 55 aa 75 37 83   ..U..ZRr=..U.u7.
00b0 : e1 01 74 32 31 c0 89 44 04 40 88 44 ff 89 44 02   ..t21..D.@.D..D.
00c0 : c7 04 10 00 66 8b 1e 5c 7c 66 89 5c 08 66 8b 1e   ....f..\|f.\.f..
00d0 : 60 7c 66 89 5c 0c c7 44 06 00 70 b4 42 cd 13 72   `|f.\..D..p.B..r
00e0 : 05 bb 00 70 eb 76 b4 08 cd 13 73 0d 5a 84 d2 0f   ...p.v....s.Z...
00f0 : 83 d0 00 be 93 7d e9 82 00 66 0f b6 c6 88 64 ff   .....}...f....d.
0100 : 40 66 89 44 04 0f b6 d1 c1 e2 02 88 e8 88 f4 40   @f.D...........@
0110 : 89 44 08 0f b6 c2 c0 e8 02 66 89 04 66 a1 60 7c   .D.......f..f.`|
0120 : 66 09 c0 75 4e 66 a1 5c 7c 66 31 d2 66 f7 34 88   f..uNf.\|f1.f.4.
0130 : d1 31 d2 66 f7 74 04 3b 44 08 7d 37 fe c1 88 c5   .1.f.t.;D.}7....
0140 : 30 c0 c1 e8 02 08 c1 88 d0 5a 88 c6 bb 00 70 8e   0........Z....p.
0150 : c3 31 db b8 01 02 cd 13 72 1e 8c c3 60 1e b9 00   .1......r...`...
0160 : 01 8e db 31 f6 bf 00 80 8e c6 fc f3 a5 1f 61 ff   ...1..........a.
0170 : 26 5a 7c be 8e 7d eb 03 be 9d 7d e8 34 00 be a2   &Z|..}....}.4...
0180 : 7d e8 2e 00 cd 18 eb fe 47 52 55 42 20 00 47 65   }.......GRUB .Ge
0190 : 6f 6d 00 48 61 72 64 20 44 69 73 6b 00 52 65 61   om.Hard Disk.Rea
01a0 : 64 00 20 45 72 72 6f 72 0d 0a 00 bb 01 00 b4 0e   d. Error........
01b0 : cd 10 ac 3c 00 75 f4 c3 00 00 00 00 00 00 00 00   ...<.u..........
01c0 : 02 00 ee ff ff ff 01 00 00 00 ff ff 7f 0c 00 00   ................
01d0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01e0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
01f0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa   ..............U.

Disk[0] is closed.

createを使うと、vmdkの作成ができます。

また、fillをつかうと VixDiskLib_Write() を呼び出して、ディスク セクタを 1 で埋めることができます。

createとfillとdumpを組み合わせて、動作を見てみます。

sudo ./vixDiskLibSample  -create sample.vmdk  # VMDK作成
sudo ./vixDiskLibSample  -fill -val 1 sample.vmdk # ディスクセクタを1で埋める
sudo ./vixDiskLibSample  -fill -val 2 -start 1 -count 1 sample.vmdk # ディスクセクタを2で埋める
sudo ./vixDiskLibSample  -dump -start 0 -count 2 sample.vmdk # セクタの内容を表示
Disk[0] "sample.vmdk" is opened using transport mode "file".
0000 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0010 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0020 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0030 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0040 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0050 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0060 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0070 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0080 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0090 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
00a0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
00b0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
00c0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
00d0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
00e0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
00f0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0100 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0110 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0120 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0130 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0140 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0150 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0160 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0170 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0180 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
0190 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
01a0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
01b0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
01c0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
01d0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
01e0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................
01f0 : 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01   ................

0000 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0010 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0020 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0030 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0040 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0050 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0060 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0070 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0080 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0090 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
00a0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
00b0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
00c0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
00d0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
00e0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
00f0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0100 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0110 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0120 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0130 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0140 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0150 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0160 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0170 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0180 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
0190 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
01a0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
01b0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
01c0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
01d0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
01e0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................
01f0 : 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02   ................

Disk[0] is closed.

vixDiskLibSampleコマンドはC++で書かれており、ソースコードはvixDiskLibSample.cppで確認することができます。

エラー関連

共有ライブラリ

共有ライブラリの設定後、aptを実行すると、以下のようなエラーが発生します。

sudo apt
apt: /usr/lib/vmware-vix-disklib-distrib/lib64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libapt-private.so.0.0)
apt: /usr/lib/vmware-vix-disklib-distrib/lib64/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libapt-pkg.so.6.0)

VDDKの「libstdc++.so.6」がどのバージョンまでの GLIBCXX に対応しているか確認したところ、GLIBCXX_3.4.28までしか対応していないことが分かります。

strings /usr/lib/vmware-vix-disklib-distrib/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
:
GLIBCXX_3.4.27
GLIBCXX_3.4.28

VDDKのバージョンを新しくするとこのあたりは変わってくるかもしれません。

/etc/ld.so.conf/ ではなく、環境変数でライブラリを指定する場合は、上記のようなエラーは発生しませんした。

export LD_LIBRARY_PATH=/usr/lib/vmware-vix-disklib-distrib/lib64

sudoで実行する場合、環境変数を渡すことができない場合があり、以下のようなエラーがでることがあります。

./vixDiskLibSample: error while loading shared libraries: libvixDiskLib.so.7.0.3: cannot open shared object file: No such file or directory

その場合は、以下のようにsudoに環境変数を指定して実行することもできます。

sudo env LD_LIBRARY_PATH=/usr/lib/vmware-vix-disklib-distrib/lib64 <command>

vixDiskLibSample

-thumbを指定しない場合、以下のエラーが表示されます。

サンプルコードはパラメーターのエラーが分かる程度で、どのパラメータが間違っているかは教えてくれません。

Error: [bora/apps/vixDiskLib/sampleProgram/vixDiskLibSample.cpp:1545]  3 One of the parameters was invalid

コンパイル

vixDiskLibSample.cppのコンパイルを試してみます。

G++のコンパイルに必要なパッケージをインストールします。G++ 10のパッケージもインストールしておきます。

sudo apt install build-essential
sudo apt install g++-10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 10
sudo update-alternatives --config g++
# g++-10を選択します。

g++ 11でmakeした際に、以下のエラーメッセージが発生しコンパイルに失敗しました。

g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ sudo make 
g++ -std=c++1y -lpthread -o vix-disklib-sample -I../../../include -L../../../lib64 vixDiskLibSample.cpp -ldl -lz -lsqlite3 -lcurl -lssl -lcrypto -lcares -lvixDiskLib
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `std::__exception_ptr::exception_ptr::exception_ptr(std::__exception_ptr::exception_ptr const&)':
vixDiskLibSample.cpp:(.text._ZNSt15__exception_ptr13exception_ptrC2ERKS0_[_ZNSt15__exception_ptr13exception_ptrC5ERKS0_]+0x36): undefined reference to `std::__exception_ptr::exception_ptr::_M_addref()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `std::__exception_ptr::exception_ptr::~exception_ptr()':
vixDiskLibSample.cpp:(.text._ZNSt15__exception_ptr13exception_ptrD2Ev[_ZNSt15__exception_ptr13exception_ptrD5Ev]+0x24): undefined reference to `std::__exception_ptr::exception_ptr::_M_release()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<DiskIOPipeline::DiskInfo*>::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorIPN14DiskIOPipeline8DiskInfoEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIPN14DiskIOPipeline8DiskInfoEE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<std::thread>::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt6threadE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorISt6threadE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<DiskIOPipeline::DiskInfo>::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorIN14DiskIOPipeline8DiskInfoEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorIN14DiskIOPipeline8DiskInfoEE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<VixDiskLibBlock>::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorI15VixDiskLibBlockE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorI15VixDiskLibBlockE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `std::__atomic_futex_unsigned<2147483648u>::_M_load_and_test_until_steady(unsigned int, unsigned int, bool, std::memory_order, bool, std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >)':
vixDiskLibSample.cpp:(.text._ZNSt23__atomic_futex_unsignedILj2147483648EE29_M_load_and_test_until_steadyEjjbSt12memory_orderbNSt6chrono8durationIlSt5ratioILl1ELl1EEEENS3_IlS4_ILl1ELl1000000000EEEE[_ZNSt23__atomic_futex_unsignedILj2147483648EE29_M_load_and_test_until_steadyEjjbSt12memory_orderbNSt6chrono8durationIlSt5ratioILl1ELl1EEEENS3_IlS4_ILl1ELl1000000000EEEE]+0x7c): undefined reference to `std::__atomic_futex_unsigned_base::_M_futex_wait_until_steady(unsigned int*, unsigned int, bool, std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >)'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<ThreadData>::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorI10ThreadDataE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorI10ThreadDataE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<unsigned long>::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorImE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorImE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<std::_Fwd_list_node<std::future<std::shared_ptr<VixDisk> > > >::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt14_Fwd_list_nodeISt6futureISt10shared_ptrI7VixDiskEEEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorISt14_Fwd_list_nodeISt6futureISt10shared_ptrI7VixDiskEEEE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<std::mutex, std::allocator<std::mutex>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceISt5mutexSaIS2_ELNS_12_Lock_policyE2EEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceISt5mutexSaIS2_ELNS_12_Lock_policyE2EEE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o: in function `__gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<VixDisk, std::allocator<VixDisk>, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*)':
vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceI7VixDiskSaIS2_ELNS_12_Lock_policyE2EEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceI7VixDiskSaIS2_ELNS_12_Lock_policyE2EEE8allocateEmPKv]+0x49): undefined reference to `std::__throw_bad_array_new_length()'
/usr/bin/ld: /tmp/ccOjIOGn.o:vixDiskLibSample.cpp:(.text._ZN9__gnu_cxx13new_allocatorISt10_List_nodeIPhEE8allocateEmPKv[_ZN9__gnu_cxx13new_allocatorISt10_List_nodeIPhEE8allocateEmPKv]+0x49): more undefined references to `std::__throw_bad_array_new_length()' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:14: vix-disklib-sample] Error 1

vix-disklib-sampleのビルドは無事成功しましたが、vix-mntapi-sample側で以下のエラーが発生しました。

$ sudo make
g++ -std=c++1y -lpthread -o vix-disklib-sample -I../../../include -L../../../lib64 vixDiskLibSample.cpp -ldl -lz -lsqlite3 -lcurl -lssl -lcrypto -lcares -lvixDiskLib
g++ -std=c++1y -lpthread -o vix-mntapi-sample -DFOR_MNTAPI -I../../../include -L../../../lib64 vixDiskLibSample.cpp -ldl -lz -lsqlite3 -lcurl -lssl -lcrypto -lcares \
   -lfuse -lvixDiskLib -lvixMntapi
/usr/bin/ld: cannot find -lfuse: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:17: vix-mntapi-sample] Error 1

Ubuntu 22.04で libfuseが 3系がデフォルトになってしまっており、libfuse2をインストールする必要があります。

ldconfig -p | grep fuse
        libfuse3.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libfuse3.so.3
sudo apt install libfuse2
ldconfig -p | grep fuse
        libfuse3.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libfuse3.so.3
        libfuse.so.2 (libc6,x86-64) => /lib/x86_64-linux-gnu/libfuse.so.2
ls -la /usr/lib/x86_64-linux-gnu | grep fuse
lrwxrwxrwx  1 root root       18 Mar 23  2022 libfuse3.so.3 -> libfuse3.so.3.10.5
-rw-r--r--  1 root root   252088 Mar 23  2022 libfuse3.so.3.10.5
lrwxrwxrwx  1 root root       16 Mar 23  2022 libfuse.so.2 -> libfuse.so.2.9.9
-rw-r--r--  1 root root   260376 Mar 23  2022 libfuse.so.2.9.9

libfuse.soというファイル名でしたが、libfuse.so.2という末尾にバージョン情報が入ってしまい、修正が必要になります。

sudo ln -s libfuse.so.2 /usr/lib/x86_64-linux-gnu/libfuse.so
ls -la /usr/lib/x86_64-linux-gnu | grep fuse
lrwxrwxrwx  1 root root       18 Mar 23  2022 libfuse3.so.3 -> libfuse3.so.3.10.5
-rw-r--r--  1 root root   252088 Mar 23  2022 libfuse3.so.3.10.5
lrwxrwxrwx  1 root root       12 Dec 25 02:19 libfuse.so -> libfuse.so.2
lrwxrwxrwx  1 root root       16 Mar 23  2022 libfuse.so.2 -> libfuse.so.2.9.9
-rw-r--r--  1 root root   260376 Mar 23  2022 libfuse.so.2.9.9

こちらで無事vix-mntapi-sampleのコンパイルも完了しました。

sudo make
g++ -std=c++1y -lpthread -o vix-mntapi-sample -DFOR_MNTAPI -I../../../include -L../../../lib64 vixDiskLibSample.cpp -ldl -lz -lsqlite3 -lcurl -lssl -lcrypto -lcares \
   -lfuse -lvixDiskLib -lvixMntapi

参考