mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
Re-arrange storage backend registration
This commit is contained in:
parent
9b7fd9c4ae
commit
8a8826600c
@ -1,3 +1,9 @@
|
||||
Tue Nov 11 15:51:42 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/storage_backend.c, src/storage_backend.h, src/storage_driver.c:
|
||||
Decouple backend impls from generic backend code, by making driver
|
||||
register backends at startup
|
||||
|
||||
Mon Nov 10 12:05:42 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/openvz_conf.c: Read filesytem template name from config
|
||||
|
@ -47,49 +47,27 @@
|
||||
|
||||
#include "storage_backend.h"
|
||||
|
||||
#if WITH_STORAGE_LVM
|
||||
#include "storage_backend_logical.h"
|
||||
#endif
|
||||
#if WITH_STORAGE_ISCSI
|
||||
#include "storage_backend_iscsi.h"
|
||||
#endif
|
||||
#if WITH_STORAGE_DISK
|
||||
#include "storage_backend_disk.h"
|
||||
#endif
|
||||
#if WITH_STORAGE_DIR
|
||||
#include "storage_backend_fs.h"
|
||||
#endif
|
||||
|
||||
VIR_ENUM_IMPL(virStorageBackendPartTable,
|
||||
VIR_STORAGE_POOL_DISK_LAST,
|
||||
"unknown", "dos", "dvh", "gpt",
|
||||
"mac", "bsd", "pc98", "sun", "lvm2");
|
||||
|
||||
static virStorageBackendPtr backends[] = {
|
||||
#if WITH_STORAGE_DIR
|
||||
&virStorageBackendDirectory,
|
||||
#endif
|
||||
#if WITH_STORAGE_FS
|
||||
&virStorageBackendFileSystem,
|
||||
&virStorageBackendNetFileSystem,
|
||||
#endif
|
||||
#if WITH_STORAGE_LVM
|
||||
&virStorageBackendLogical,
|
||||
#endif
|
||||
#if WITH_STORAGE_ISCSI
|
||||
&virStorageBackendISCSI,
|
||||
#endif
|
||||
#if WITH_STORAGE_DISK
|
||||
&virStorageBackendDisk,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
static unsigned nbackends = 0;
|
||||
static virStorageBackendPtr *backends = NULL;
|
||||
|
||||
|
||||
int virStorageBackendRegister(virStorageBackendPtr bk) {
|
||||
if (VIR_REALLOC_N(backends, nbackends+1) < 0)
|
||||
return -1;
|
||||
|
||||
backends[nbackends++] = bk;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virStorageBackendPtr
|
||||
virStorageBackendForType(int type) {
|
||||
unsigned int i;
|
||||
for (i = 0; backends[i]; i++)
|
||||
for (i = 0; i < nbackends; i++)
|
||||
if (backends[i]->type == type)
|
||||
return backends[i];
|
||||
|
||||
|
@ -121,6 +121,7 @@ struct _virStorageBackend {
|
||||
int volType;
|
||||
};
|
||||
|
||||
int virStorageBackendRegister(virStorageBackendPtr bk);
|
||||
|
||||
virStorageBackendPtr virStorageBackendForType(int type);
|
||||
virStorageBackendPoolOptionsPtr virStorageBackendPoolOptionsForType(int type);
|
||||
|
@ -41,6 +41,20 @@
|
||||
#include "memory.h"
|
||||
#include "storage_backend.h"
|
||||
|
||||
|
||||
#if WITH_STORAGE_LVM
|
||||
#include "storage_backend_logical.h"
|
||||
#endif
|
||||
#if WITH_STORAGE_ISCSI
|
||||
#include "storage_backend_iscsi.h"
|
||||
#endif
|
||||
#if WITH_STORAGE_DISK
|
||||
#include "storage_backend_disk.h"
|
||||
#endif
|
||||
#if WITH_STORAGE_DIR
|
||||
#include "storage_backend_fs.h"
|
||||
#endif
|
||||
|
||||
#define storageLog(msg...) fprintf(stderr, msg)
|
||||
|
||||
static virStorageDriverStatePtr driverState;
|
||||
@ -97,6 +111,29 @@ storageDriverStartup(void) {
|
||||
char *base = NULL;
|
||||
char driverConf[PATH_MAX];
|
||||
|
||||
#if WITH_STORAGE_DIR
|
||||
if (virStorageBackendRegister(&virStorageBackendDirectory) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
#if WITH_STORAGE_FS
|
||||
if (virStorageBackendRegister(&virStorageBackendFileSystem) < 0)
|
||||
return -1;
|
||||
if (virStorageBackendRegister(&virStorageBackendNetFileSystem) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
#if WITH_STORAGE_LVM
|
||||
if (virStorageBackendRegister(&virStorageBackendLogical) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
#if WITH_STORAGE_ISCSI
|
||||
if (virStorageBackendRegister(&virStorageBackendISCSI) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
#if WITH_STORAGE_DISK
|
||||
if (virStorageBackendRegister(&virStorageBackendDisk) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if (VIR_ALLOC(driverState) < 0)
|
||||
return -1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user