Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/libvirt/libvirt-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ typedef enum {
VIR_CONNECT_LIST_STORAGE_POOLS_ZFS = 1 << 17, /* (Since: 1.2.8) */
VIR_CONNECT_LIST_STORAGE_POOLS_VSTORAGE = 1 << 18, /* (Since: 3.1.0) */
VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI_DIRECT = 1 << 19, /* (Since: 5.6.0) */

VIR_CONNECT_LIST_STORAGE_POOLS_RAWSTOR = 1 << 20, /* (Since: 12.4.0) */
} virConnectListAllStoragePoolsFlags;

int virConnectListAllStoragePools(virConnectPtr conn,
Expand Down
11 changes: 11 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,8 @@ else
libpcap_dep = dependency('', required: false)
endif

librawstor_dep = dependency('rawstor', required: get_option('storage_rawstor'))

libssh_version = '0.8.1'
if conf.has('WITH_REMOTE')
libssh_dep = dependency('libssh', version: '>=' + libssh_version, required: get_option('libssh'))
Expand Down Expand Up @@ -1882,6 +1884,13 @@ if conf.has('WITH_LIBVIRTD')
error('mpath storage driver is supported only on Linux and you must install libdevmapper')
endif

if not get_option('storage_rawstor').disabled() and librawstor_dep.found()
use_storage = true
conf.set('WITH_STORAGE_RAWSTOR', 1)
elif get_option('storage_rawstor').enabled()
error('You must install the librawstor library & headers to compile libvirt')
endif

if not get_option('storage_rbd').disabled() and rbd_dep.found()
use_storage = true
conf.set('WITH_STORAGE_RBD', 1)
Expand Down Expand Up @@ -2273,6 +2282,7 @@ storagedriver_summary = {
'LVM': conf.has('WITH_STORAGE_LVM'),
'mpath': conf.has('WITH_STORAGE_MPATH'),
'NetFS': conf.has('WITH_STORAGE_FS'),
'Rawstor': conf.has('WITH_STORAGE_RAWSTOR'),
'RBD': conf.has('WITH_STORAGE_RBD'),
'SCSI': conf.has('WITH_STORAGE_SCSI'),
'Virtuozzo storage': conf.has('WITH_STORAGE_VSTORAGE'),
Expand Down Expand Up @@ -2312,6 +2322,7 @@ libs_summary = {
'libnl': libnl_dep,
'libparted': libparted_dep,
'libpcap': libpcap_dep,
'librawstor': librawstor_dep,
'libssh': libssh_dep,
'libssh2': libssh2_dep,
'libutil': libutil_dep,
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ option('storage_iscsi', type: 'feature', value: 'auto', description: 'iscsi back
option('storage_iscsi_direct', type: 'feature', value: 'auto', description: 'iscsi-direct backend for the storage driver')
option('storage_lvm', type: 'feature', value: 'auto', description: 'LVM backend for the storage driver')
option('storage_mpath', type: 'feature', value: 'auto', description: 'mpath backend for the storage driver')
option('storage_rawstor', type: 'feature', value: 'auto', description: 'Rawstor backend for the storage driver')
option('storage_rbd', type: 'feature', value: 'auto', description: 'RADOS Block Device backend for the storage driver')
option('storage_scsi', type: 'feature', value: 'auto', description: 'SCSI backend for the storage driver')
option('storage_vstorage', type: 'feature', value: 'auto', description: 'Virtuozzo storage backend for the storage driver')
Expand Down
1 change: 1 addition & 0 deletions src/conf/domain_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32792,6 +32792,7 @@ virDomainStorageSourceTranslateSourcePool(virStorageSource *src,
case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_SHEEPDOG:
case VIR_STORAGE_POOL_GLUSTER:
case VIR_STORAGE_POOL_RAWSTOR:
case VIR_STORAGE_POOL_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("using '%1$s' pools for backing 'volume' disks isn't yet supported"),
Expand Down
9 changes: 8 additions & 1 deletion src/conf/storage_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ VIR_ENUM_IMPL(virStoragePool,
"dir", "fs", "netfs",
"logical", "disk", "iscsi",
"iscsi-direct", "scsi", "mpath",
"rbd", "sheepdog", "gluster",
"rawstor", "rbd", "sheepdog", "gluster",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The order of elements in VIR_ENUM_IMPL must exactly match the virStoragePoolType enum in src/conf/storage_conf.h. Currently, VIR_STORAGE_POOL_RAWSTOR is placed at the end of the enum (index 14), but "rawstor" is inserted here at index 9 (before "rbd"). This mismatch will break the mapping between the enum and its string representation, causing bugs in XML parsing/formatting and API calls.

Please move "rawstor" to the end of the VIR_ENUM_IMPL list (after "vstorage").

              "rbd", "sheepdog", "gluster",

"zfs", "vstorage",
);

Expand Down Expand Up @@ -230,6 +230,13 @@ static virStoragePoolTypeInfo poolTypeInfo[] = {
.flags = (VIR_STORAGE_POOL_SOURCE_ADAPTER),
},
},
{.poolType = VIR_STORAGE_POOL_RAWSTOR,
.poolOptions = {
.flags = (VIR_STORAGE_POOL_SOURCE_HOST |
VIR_STORAGE_POOL_SOURCE_NETWORK |
VIR_STORAGE_POOL_SOURCE_NAME),
}
},
Comment on lines +233 to +239

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The indentation of the closing brace for .poolOptions is incorrect (6 spaces instead of 5), and it is missing a trailing comma. To match the style of other entries in this array, it should be indented with 5 spaces and have a trailing comma.

    {.poolType = VIR_STORAGE_POOL_RAWSTOR,
     .poolOptions = {
         .flags = (VIR_STORAGE_POOL_SOURCE_HOST |
                   VIR_STORAGE_POOL_SOURCE_NETWORK |
                   VIR_STORAGE_POOL_SOURCE_NAME),
     },
    },

{.poolType = VIR_STORAGE_POOL_RBD,
.poolOptions = {
.flags = (VIR_STORAGE_POOL_SOURCE_HOST |
Expand Down
2 changes: 2 additions & 0 deletions src/conf/storage_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ typedef enum {
VIR_STORAGE_POOL_GLUSTER, /* Gluster device */
VIR_STORAGE_POOL_ZFS, /* ZFS */
VIR_STORAGE_POOL_VSTORAGE, /* Virtuozzo Storage */
VIR_STORAGE_POOL_RAWSTOR, /* Rawstor device */

VIR_STORAGE_POOL_LAST,
} virStoragePoolType;
Expand Down Expand Up @@ -453,6 +454,7 @@ VIR_ENUM_DECL(virStoragePartedFs);
VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI | \
VIR_CONNECT_LIST_STORAGE_POOLS_SCSI | \
VIR_CONNECT_LIST_STORAGE_POOLS_MPATH | \
VIR_CONNECT_LIST_STORAGE_POOLS_RAWSTOR | \
VIR_CONNECT_LIST_STORAGE_POOLS_RBD | \
VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG | \
VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER | \
Expand Down
3 changes: 3 additions & 0 deletions src/conf/virstorageobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@ virStoragePoolObjSourceFindDuplicateCb(const void *payload,
break;

case VIR_STORAGE_POOL_ISCSI_DIRECT:
case VIR_STORAGE_POOL_RAWSTOR:
case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_LAST:
break;
Expand Down Expand Up @@ -1948,6 +1949,8 @@ virStoragePoolObjMatch(virStoragePoolObj *obj,
(obj->def->type == VIR_STORAGE_POOL_SCSI)) ||
(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_MPATH) &&
(obj->def->type == VIR_STORAGE_POOL_MPATH)) ||
(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_RAWSTOR) &&
(obj->def->type == VIR_STORAGE_POOL_RAWSTOR)) ||
(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_RBD) &&
(obj->def->type == VIR_STORAGE_POOL_RBD)) ||
(MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG) &&
Expand Down
1 change: 1 addition & 0 deletions src/libvirt-storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ virStoragePoolGetConnect(virStoragePoolPtr pool)
* VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI
* VIR_CONNECT_LIST_STORAGE_POOLS_SCSI
* VIR_CONNECT_LIST_STORAGE_POOLS_MPATH
* VIR_CONNECT_LIST_STORAGE_POOLS_RAWSTOR
* VIR_CONNECT_LIST_STORAGE_POOLS_RBD
* VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG
* VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER
Expand Down
17 changes: 17 additions & 0 deletions src/storage/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ storage_backend_mpath_sources = [
'storage_backend_mpath.c',
]

storage_backend_rawstor_sources = [
'storage_backend_rawstor.c',
]

storage_backend_rbd_sources = [
'storage_backend_rbd.c',
]
Expand Down Expand Up @@ -213,6 +217,19 @@ if conf.has('WITH_STORAGE_MPATH')
}
endif

if conf.has('WITH_STORAGE_RAWSTOR')
virt_modules += {
'name': 'virt_storage_backend_rawstor',
'sources': [
files(storage_backend_rawstor_sources),
],
'deps': [
librawstor_dep
],
'install_dir': storage_backend_install_dir,
}
endif

if conf.has('WITH_STORAGE_RBD')
virt_modules += {
'name': 'virt_storage_backend_rbd',
Expand Down
3 changes: 3 additions & 0 deletions src/storage/storage_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ virStorageBackendDriversRegister(bool allbackends G_GNUC_UNUSED)
#if WITH_STORAGE_DISK
VIR_STORAGE_BACKEND_REGISTER(virStorageBackendDiskRegister, "disk");
#endif
#if WITH_STORAGE_RAWSTOR
VIR_STORAGE_BACKEND_REGISTER(virStorageBackendRawstorRegister, "rawstor");
#endif
#if WITH_STORAGE_RBD
VIR_STORAGE_BACKEND_REGISTER(virStorageBackendRBDRegister, "rbd");
#endif
Expand Down
18 changes: 18 additions & 0 deletions src/storage/storage_backend_rawstor.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "storage_backend.h"
#include "storage_backend_rawstor.h"


static virStorageBackend virStorageBackendRawstor = {
.type = VIR_STORAGE_POOL_RAWSTOR,

// .refreshPool = virStorageBackendMyVhostRefreshPool,
// .createVol = virStorageBackendMyVhostCreateVol,
// ... остальные обработчики
Comment on lines +8 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The boilerplate code contains commented-out placeholder fields with Russian comments (// ... остальные обработчики). These should be removed or replaced with a standard English TODO comment to maintain code quality and consistency in the codebase.

Suggested change
// .refreshPool = virStorageBackendMyVhostRefreshPool,
// .createVol = virStorageBackendMyVhostCreateVol,
// ... остальные обработчики
/* TODO: implement storage pool/volume inherited/required callbacks */

};


int
virStorageBackendRawstorRegister(void)
{
return virStorageBackendRegister(&virStorageBackendRawstor);
}
23 changes: 23 additions & 0 deletions src/storage/storage_backend_rawstor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* storage_backend_iscsi.h: storage backend for iSCSI handling

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The header comment block contains copy-paste remnants from storage_backend_iscsi.h. It mentions storage_backend_iscsi.h and "iSCSI handling" instead of storage_backend_rawstor.h and "Rawstor handling".

Suggested change
* storage_backend_iscsi.h: storage backend for iSCSI handling
* storage_backend_rawstor.h: storage backend for Rawstor handling

*
* Copyright (C) 2025-2026 Vasily Stepanov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/

#pragma once

int virStorageBackendRawstorRegister(void);
1 change: 1 addition & 0 deletions src/storage/storage_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@ storageVolLookupByPathCallback(virStoragePoolObj *obj,
break;

case VIR_STORAGE_POOL_GLUSTER:
case VIR_STORAGE_POOL_RAWSTOR:
case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_SHEEPDOG:
case VIR_STORAGE_POOL_ZFS:
Expand Down
1 change: 1 addition & 0 deletions src/test/test_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -7362,6 +7362,7 @@ testStorageVolumeTypeForPool(int pooltype)
case VIR_STORAGE_POOL_ISCSI_DIRECT:
case VIR_STORAGE_POOL_GLUSTER:
case VIR_STORAGE_POOL_RBD:
case VIR_STORAGE_POOL_RAWSTOR:
return VIR_STORAGE_VOL_NETWORK;
case VIR_STORAGE_POOL_LOGICAL:
case VIR_STORAGE_POOL_DISK:
Expand Down
3 changes: 3 additions & 0 deletions tools/virsh-pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,9 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
case VIR_STORAGE_POOL_MPATH:
flags |= VIR_CONNECT_LIST_STORAGE_POOLS_MPATH;
break;
case VIR_STORAGE_POOL_RAWSTOR:
flags |= VIR_CONNECT_LIST_STORAGE_POOLS_RAWSTOR;
break;
case VIR_STORAGE_POOL_RBD:
flags |= VIR_CONNECT_LIST_STORAGE_POOLS_RBD;
break;
Expand Down