mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
Refactor ESX storage driver to implement facade pattern
The patch refactors the current ESX storage driver due to following reasons: 1. Given most of the public APIs exposed by the storage driver in Libvirt remains same, ESX storage driver should not implement logic specific for only one supported format (current implementation only supports VMFS). 2. Decoupling interface from specific storage implementation gives us an extensible design to hook implementation for other supported storage formats. This patch refactors the current driver to implement it as a facade pattern i.e. the driver exposes all the public libvirt APIs, but uses backend drivers to get the required task done. The backend drivers provide implementation specific to the type of storage device. File changes: ------------------ esx_storage_driver.c ----> esx_storage_driver.c (base storage driver) | |---> esx_storage_backend_vmfs.c (VMFS backend)
This commit is contained in:
parent
99a388e612
commit
067e83ebee
@ -32,6 +32,7 @@ src/datatypes.c
|
||||
src/driver.c
|
||||
src/esx/esx_driver.c
|
||||
src/esx/esx_network_driver.c
|
||||
src/esx/esx_storage_backend_vmfs.c
|
||||
src/esx/esx_storage_driver.c
|
||||
src/esx/esx_util.c
|
||||
src/esx/esx_vi.c
|
||||
|
@ -493,6 +493,7 @@ ESX_DRIVER_SOURCES = \
|
||||
esx/esx_interface_driver.c esx/esx_interface_driver.h \
|
||||
esx/esx_network_driver.c esx/esx_network_driver.h \
|
||||
esx/esx_storage_driver.c esx/esx_storage_driver.h \
|
||||
esx/esx_storage_backend_vmfs.c esx/esx_storage_backend_vmfs.h \
|
||||
esx/esx_device_monitor.c esx/esx_device_monitor.h \
|
||||
esx/esx_secret_driver.c esx/esx_secret_driver.h \
|
||||
esx/esx_nwfilter_driver.c esx/esx_nwfilter_driver.h \
|
||||
|
@ -163,7 +163,8 @@ esxParseVMXFileName(const char *fileName, void *opaque)
|
||||
datastoreName = NULL;
|
||||
|
||||
if (esxVI_LookupDatastoreHostMount(data->ctx, datastore->obj,
|
||||
&hostMount) < 0 ||
|
||||
&hostMount,
|
||||
esxVI_Occurrence_RequiredItem) < 0 ||
|
||||
esxVI_GetStringValue(datastore, "summary.name", &datastoreName,
|
||||
esxVI_Occurrence_RequiredItem) < 0) {
|
||||
goto cleanup;
|
||||
@ -307,7 +308,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
|
||||
if (esxVI_LookupDatastoreByName(data->ctx, datastoreName, NULL, &datastore,
|
||||
esxVI_Occurrence_RequiredItem) < 0 ||
|
||||
esxVI_LookupDatastoreHostMount(data->ctx, datastore->obj,
|
||||
&hostMount) < 0) {
|
||||
&hostMount,
|
||||
esxVI_Occurrence_RequiredItem) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
1537
src/esx/esx_storage_backend_vmfs.c
Normal file
1537
src/esx/esx_storage_backend_vmfs.c
Normal file
File diff suppressed because it is too large
Load Diff
31
src/esx/esx_storage_backend_vmfs.h
Normal file
31
src/esx/esx_storage_backend_vmfs.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
/*
|
||||
* esx_storage_backend_vmfs.h: ESX storage driver backend for
|
||||
* managing VMFS datastores
|
||||
*
|
||||
* Copyright (C) 2012 Ata E Husain Bohra <ata.husain@hotmail.com>
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ESX_STORAGE_BACKEND_VMFS_H__
|
||||
# define __ESX_STORAGE_BACKEND_VMFS_H__
|
||||
|
||||
# include "driver.h"
|
||||
|
||||
extern virStorageDriver esxStorageBackendVMFS;
|
||||
|
||||
#endif /* __ESX_STORAGE_BACKEND_VMFS_H__ */
|
File diff suppressed because it is too large
Load Diff
@ -3107,7 +3107,8 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
|
||||
int
|
||||
esxVI_LookupDatastoreHostMount(esxVI_Context *ctx,
|
||||
esxVI_ManagedObjectReference *datastore,
|
||||
esxVI_DatastoreHostMount **hostMount)
|
||||
esxVI_DatastoreHostMount **hostMount,
|
||||
esxVI_Occurrence occurrence)
|
||||
{
|
||||
int result = -1;
|
||||
esxVI_String *propertyNameList = NULL;
|
||||
@ -3155,7 +3156,7 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx,
|
||||
break;
|
||||
}
|
||||
|
||||
if (*hostMount == NULL) {
|
||||
if (*hostMount == NULL && occurrence == esxVI_Occurrence_RequiredItem) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Could not lookup datastore host mount"));
|
||||
goto cleanup;
|
||||
|
@ -441,7 +441,8 @@ int esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx,
|
||||
|
||||
int esxVI_LookupDatastoreHostMount(esxVI_Context *ctx,
|
||||
esxVI_ManagedObjectReference *datastore,
|
||||
esxVI_DatastoreHostMount **hostMount);
|
||||
esxVI_DatastoreHostMount **hostMount,
|
||||
esxVI_Occurrence occurrence);
|
||||
|
||||
int esxVI_LookupTaskInfoByTask(esxVI_Context *ctx,
|
||||
esxVI_ManagedObjectReference *task,
|
||||
|
Loading…
Reference in New Issue
Block a user