From d6c40aaec8fc7460d579b5d0ac7e5db4dfad3861 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Fri, 15 Jan 2010 16:01:02 +0100 Subject: [PATCH] esx: Add stubs for secondary driver types This stops libvirt from probing for a libvirtd on the ESX server and sets the base for the implementation of the secondary drivers. --- src/Makefile.am | 6 ++ src/esx/esx_device_monitor.c | 93 ++++++++++++++++++++++++++ src/esx/esx_device_monitor.h | 29 ++++++++ src/esx/esx_driver.c | 29 ++++---- src/esx/esx_driver.h | 2 +- src/esx/esx_interface_driver.c | 96 +++++++++++++++++++++++++++ src/esx/esx_interface_driver.h | 29 ++++++++ src/esx/esx_network_driver.c | 101 ++++++++++++++++++++++++++++ src/esx/esx_network_driver.h | 29 ++++++++ src/esx/esx_private.h | 42 ++++++++++++ src/esx/esx_secret_driver.c | 91 +++++++++++++++++++++++++ src/esx/esx_secret_driver.h | 28 ++++++++ src/esx/esx_storage_driver.c | 117 +++++++++++++++++++++++++++++++++ src/esx/esx_storage_driver.h | 29 ++++++++ 14 files changed, 706 insertions(+), 15 deletions(-) create mode 100644 src/esx/esx_device_monitor.c create mode 100644 src/esx/esx_device_monitor.h create mode 100644 src/esx/esx_interface_driver.c create mode 100644 src/esx/esx_interface_driver.h create mode 100644 src/esx/esx_network_driver.c create mode 100644 src/esx/esx_network_driver.h create mode 100644 src/esx/esx_private.h create mode 100644 src/esx/esx_secret_driver.c create mode 100644 src/esx/esx_secret_driver.h create mode 100644 src/esx/esx_storage_driver.c create mode 100644 src/esx/esx_storage_driver.h diff --git a/src/Makefile.am b/src/Makefile.am index 324030b36e..49946afb0b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -213,7 +213,13 @@ ONE_DRIVER_SOURCES = \ ./opennebula/one_client.h ESX_DRIVER_SOURCES = \ + esx/esx_private.h \ esx/esx_driver.c esx/esx_driver.h \ + 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_device_monitor.c esx/esx_device_monitor.h \ + esx/esx_secret_driver.c esx/esx_secret_driver.h \ esx/esx_util.c esx/esx_util.h \ esx/esx_vi.c esx/esx_vi.h \ esx/esx_vi_methods.c esx/esx_vi_methods.h \ diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c new file mode 100644 index 0000000000..de67ebb986 --- /dev/null +++ b/src/esx/esx_device_monitor.c @@ -0,0 +1,93 @@ + +/* + * esx_device_monitor.c: device monitor methods for managing VMware ESX + * host devices + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "internal.h" +#include "virterror_internal.h" +#include "util.h" +#include "memory.h" +#include "logging.h" +#include "uuid.h" +#include "esx_private.h" +#include "esx_device_monitor.h" +#include "esx_vi.h" +#include "esx_vi_methods.h" +#include "esx_util.h" + +#define VIR_FROM_THIS VIR_FROM_ESX + +#define ESX_ERROR(conn, code, fmt...) \ + virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \ + __LINE__, fmt) + + + +static virDrvOpenStatus +esxDeviceOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED) +{ + if (STRNEQ(conn->driver->name, "ESX")) { + return VIR_DRV_OPEN_DECLINED; + } + + conn->devMonPrivateData = conn->privateData; + + return VIR_DRV_OPEN_SUCCESS; +} + + + +static int +esxDeviceClose(virConnectPtr conn) +{ + conn->devMonPrivateData = NULL; + + return 0; +} + + + +static virDeviceMonitor esxDeviceMonitor = { + "ESX", /* name */ + esxDeviceOpen, /* open */ + esxDeviceClose, /* close */ + NULL, /* numOfDevices */ + NULL, /* listDevices */ + NULL, /* deviceLookupByName */ + NULL, /* deviceDumpXML */ + NULL, /* deviceGetParent */ + NULL, /* deviceNumOfCaps */ + NULL, /* deviceListCaps */ + NULL, /* deviceCreateXML */ + NULL, /* deviceDestroy */ +}; + + + +int +esxDeviceRegister(void) +{ + return virRegisterDeviceMonitor(&esxDeviceMonitor); +} diff --git a/src/esx/esx_device_monitor.h b/src/esx/esx_device_monitor.h new file mode 100644 index 0000000000..e72a5b6041 --- /dev/null +++ b/src/esx/esx_device_monitor.h @@ -0,0 +1,29 @@ + +/* + * esx_device_monitor.h: device monitor methods for managing VMware ESX + * host devices + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ESX_DEVICE_MONITOR_H__ +#define __ESX_DEVICE_MONITOR_H__ + +int esxDeviceRegister(void); + +#endif /* __ESX_DEVICE_MONITOR_H__ */ diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index ddda66efda..2f346c36a6 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2,7 +2,7 @@ /* * esx_driver.c: core driver methods for managing VMware ESX hosts * - * Copyright (C) 2009 Matthias Bolte + * Copyright (C) 2009, 2010 Matthias Bolte * Copyright (C) 2009 Maximilian Wilhelm * * This library is free software; you can redistribute it and/or @@ -33,6 +33,12 @@ #include "logging.h" #include "uuid.h" #include "esx_driver.h" +#include "esx_interface_driver.h" +#include "esx_network_driver.h" +#include "esx_storage_driver.h" +#include "esx_device_monitor.h" +#include "esx_secret_driver.h" +#include "esx_private.h" #include "esx_vi.h" #include "esx_vi_methods.h" #include "esx_util.h" @@ -46,18 +52,6 @@ static int esxDomainGetMaxVcpus(virDomainPtr domain); -typedef struct _esxPrivate { - esxVI_Context *host; - esxVI_Context *vCenter; - virCapsPtr caps; - char *transport; - int32_t maxVcpus; - esxVI_Boolean supportsVMotion; - esxVI_Boolean supportsLongMode; /* aka x86_64 */ - esxVI_Boolean autoAnswer; - int32_t usedCpuTimeCounterId; -} esxPrivate; - static esxVI_Boolean @@ -3479,7 +3473,14 @@ static virDriver esxDriver = { int esxRegister(void) { - virRegisterDriver(&esxDriver); + if (virRegisterDriver(&esxDriver) < 0 || + esxInterfaceRegister() < 0 || + esxNetworkRegister() < 0 || + esxStorageRegister() < 0 || + esxDeviceRegister() < 0 || + esxSecretRegister() < 0) { + return -1; + } return 0; } diff --git a/src/esx/esx_driver.h b/src/esx/esx_driver.h index 85f4b328bf..6ecd5a7c44 100644 --- a/src/esx/esx_driver.h +++ b/src/esx/esx_driver.h @@ -2,7 +2,7 @@ /* * esx_driver.h: core driver methods for managing VMware ESX hosts * - * Copyright (C) 2009 Matthias Bolte + * Copyright (C) 2009, 2010 Matthias Bolte * Copyright (C) 2009 Maximilian Wilhelm * * This library is free software; you can redistribute it and/or diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c new file mode 100644 index 0000000000..6e9d22476e --- /dev/null +++ b/src/esx/esx_interface_driver.c @@ -0,0 +1,96 @@ + +/* + * esx_interface_driver.h: interface driver methods for managing VMware ESX + * host interfaces + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "internal.h" +#include "virterror_internal.h" +#include "util.h" +#include "memory.h" +#include "logging.h" +#include "uuid.h" +#include "esx_private.h" +#include "esx_interface_driver.h" +#include "esx_vi.h" +#include "esx_vi_methods.h" +#include "esx_util.h" + +#define VIR_FROM_THIS VIR_FROM_ESX + +#define ESX_ERROR(conn, code, fmt...) \ + virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \ + __LINE__, fmt) + + + +static virDrvOpenStatus +esxInterfaceOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED) +{ + if (STRNEQ(conn->driver->name, "ESX")) { + return VIR_DRV_OPEN_DECLINED; + } + + conn->interfacePrivateData = conn->privateData; + + return VIR_DRV_OPEN_SUCCESS; +} + + + +static int +esxInterfaceClose(virConnectPtr conn) +{ + conn->interfacePrivateData = NULL; + + return 0; +} + + + +static virInterfaceDriver esxInterfaceDriver = { + "ESX", /* name */ + esxInterfaceOpen, /* open */ + esxInterfaceClose, /* close */ + NULL, /* numOfInterfaces */ + NULL, /* listInterfaces */ + NULL, /* numOfDefinedInterfaces */ + NULL, /* listDefinedInterfaces */ + NULL, /* interfaceLookupByName */ + NULL, /* interfaceLookupByMACString */ + NULL, /* interfaceGetXMLDesc */ + NULL, /* interfaceDefineXML */ + NULL, /* interfaceUndefine */ + NULL, /* interfaceCreate */ + NULL, /* interfaceDestroy */ + NULL, /* interfaceIsActive */ +}; + + + +int +esxInterfaceRegister(void) +{ + return virRegisterInterfaceDriver(&esxInterfaceDriver); +} diff --git a/src/esx/esx_interface_driver.h b/src/esx/esx_interface_driver.h new file mode 100644 index 0000000000..d30641a34a --- /dev/null +++ b/src/esx/esx_interface_driver.h @@ -0,0 +1,29 @@ + +/* + * esx_interface_driver.h: interface driver methods for managing VMware ESX + * host interfaces + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ESX_INTERFACE_DRIVER_H__ +#define __ESX_INTERFACE_DRIVER_H__ + +int esxInterfaceRegister(void); + +#endif /* __ESX_INTERFACE_DRIVER_H__ */ diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c new file mode 100644 index 0000000000..1eeae444c9 --- /dev/null +++ b/src/esx/esx_network_driver.c @@ -0,0 +1,101 @@ + +/* + * esx_network_driver.c: network driver methods for managing VMware ESX + * host networks + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "internal.h" +#include "virterror_internal.h" +#include "util.h" +#include "memory.h" +#include "logging.h" +#include "uuid.h" +#include "esx_private.h" +#include "esx_network_driver.h" +#include "esx_vi.h" +#include "esx_vi_methods.h" +#include "esx_util.h" + +#define VIR_FROM_THIS VIR_FROM_ESX + +#define ESX_ERROR(conn, code, fmt...) \ + virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \ + __LINE__, fmt) + + + +static virDrvOpenStatus +esxNetworkOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED) +{ + if (STRNEQ(conn->driver->name, "ESX")) { + return VIR_DRV_OPEN_DECLINED; + } + + conn->networkPrivateData = conn->privateData; + + return VIR_DRV_OPEN_SUCCESS; +} + + + +static int +esxNetworkClose(virConnectPtr conn) +{ + conn->networkPrivateData = NULL; + + return 0; +} + + + +static virNetworkDriver esxNetworkDriver = { + "ESX", /* name */ + esxNetworkOpen, /* open */ + esxNetworkClose, /* close */ + NULL, /* numOfNetworks */ + NULL, /* listNetworks */ + NULL, /* numOfDefinedNetworks */ + NULL, /* listDefinedNetworks */ + NULL, /* networkLookupByUUID */ + NULL, /* networkLookupByName */ + NULL, /* networkCreateXML */ + NULL, /* networkDefineXML */ + NULL, /* networkUndefine */ + NULL, /* networkCreate */ + NULL, /* networkDestroy */ + NULL, /* networkDumpXML */ + NULL, /* networkGetBridgeName */ + NULL, /* networkGetAutostart */ + NULL, /* networkSetAutostart */ + NULL, /* networkIsActive */ + NULL, /* networkIsPersistent */ +}; + + + +int +esxNetworkRegister(void) +{ + return virRegisterNetworkDriver(&esxNetworkDriver); +} diff --git a/src/esx/esx_network_driver.h b/src/esx/esx_network_driver.h new file mode 100644 index 0000000000..f117e037c3 --- /dev/null +++ b/src/esx/esx_network_driver.h @@ -0,0 +1,29 @@ + +/* + * esx_network_driver.h: network driver methods for managing VMware ESX + * host networks + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ESX_NETWORK_DRIVER_H__ +#define __ESX_NETWORK_DRIVER_H__ + +int esxNetworkRegister(void); + +#endif /* __ESX_NETWORK_DRIVER_H__ */ diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h new file mode 100644 index 0000000000..7a82ed65b5 --- /dev/null +++ b/src/esx/esx_private.h @@ -0,0 +1,42 @@ + +/* + * esx_private.h: private driver struct for the VMware ESX driver + * + * Copyright (C) 2009, 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ESX_PRIVATE_H__ +#define __ESX_PRIVATE_H__ + +#include "internal.h" +#include "capabilities.h" +#include "esx_vi.h" + +typedef struct _esxPrivate { + esxVI_Context *host; + esxVI_Context *vCenter; + virCapsPtr caps; + char *transport; + int32_t maxVcpus; + esxVI_Boolean supportsVMotion; + esxVI_Boolean supportsLongMode; /* aka x86_64 */ + esxVI_Boolean autoAnswer; + int32_t usedCpuTimeCounterId; +} esxPrivate; + +#endif /* __ESX_PRIVATE_H__ */ diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c new file mode 100644 index 0000000000..7b24d0c519 --- /dev/null +++ b/src/esx/esx_secret_driver.c @@ -0,0 +1,91 @@ + +/* + * esx_secret_driver.c: secret driver methods for VMware ESX secret manipulation + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "internal.h" +#include "virterror_internal.h" +#include "util.h" +#include "memory.h" +#include "logging.h" +#include "uuid.h" +#include "esx_private.h" +#include "esx_secret_driver.h" +#include "esx_vi.h" +#include "esx_vi_methods.h" +#include "esx_util.h" + +#define VIR_FROM_THIS VIR_FROM_ESX + +#define ESX_ERROR(conn, code, fmt...) \ + virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \ + __LINE__, fmt) + + + +static virDrvOpenStatus +esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED) +{ + if (STRNEQ(conn->driver->name, "ESX")) { + return VIR_DRV_OPEN_DECLINED; + } + + conn->secretPrivateData = conn->privateData; + + return VIR_DRV_OPEN_SUCCESS; +} + + + +static int +esxSecretClose(virConnectPtr conn) +{ + conn->secretPrivateData = NULL; + + return 0; +} + + + +static virSecretDriver esxSecretDriver = { + "ESX", /* name */ + esxSecretOpen, /* open */ + esxSecretClose, /* close */ + NULL, /* numOfSecrets */ + NULL, /* listSecrets */ + NULL, /* lookupByUUID */ + NULL, /* lookupByUsage */ + NULL, /* defineXML */ + NULL, /* getXMLDesc */ + NULL, /* setValue */ + NULL, /* getValue */ + NULL, /* undefine */ +}; + + + +int +esxSecretRegister(void) +{ + return virRegisterSecretDriver(&esxSecretDriver); +} diff --git a/src/esx/esx_secret_driver.h b/src/esx/esx_secret_driver.h new file mode 100644 index 0000000000..c0d4a48166 --- /dev/null +++ b/src/esx/esx_secret_driver.h @@ -0,0 +1,28 @@ + +/* + * esx_secret_driver.h: secret driver methods for VMware ESX secret manipulation + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ESX_SECRET_DRIVER_H__ +#define __ESX_SECRET_DRIVER_H__ + +int esxSecretRegister(void); + +#endif /* __ESX_SECRET_DRIVER_H__ */ diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c new file mode 100644 index 0000000000..d09831a147 --- /dev/null +++ b/src/esx/esx_storage_driver.c @@ -0,0 +1,117 @@ + +/* + * esx_storage_driver.c: storage driver methods for managing VMware ESX + * host storage + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include "internal.h" +#include "virterror_internal.h" +#include "util.h" +#include "memory.h" +#include "logging.h" +#include "uuid.h" +#include "esx_private.h" +#include "esx_storage_driver.h" +#include "esx_vi.h" +#include "esx_vi_methods.h" +#include "esx_util.h" + +#define VIR_FROM_THIS VIR_FROM_ESX + +#define ESX_ERROR(conn, code, fmt...) \ + virReportErrorHelper(conn, VIR_FROM_ESX, code, __FILE__, __FUNCTION__, \ + __LINE__, fmt) + + + +static virDrvOpenStatus +esxStorageOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED) +{ + if (STRNEQ(conn->driver->name, "ESX")) { + return VIR_DRV_OPEN_DECLINED; + } + + conn->storagePrivateData = conn->privateData; + + return VIR_DRV_OPEN_SUCCESS; +} + + + +static int +esxStorageClose(virConnectPtr conn) +{ + conn->storagePrivateData = NULL; + + return 0; +} + + + +static virStorageDriver esxStorageDriver = { + "ESX", /* name */ + esxStorageOpen, /* open */ + esxStorageClose, /* close */ + NULL, /* numOfPools */ + NULL, /* listPools */ + NULL, /* numOfDefinedPools */ + NULL, /* listDefinedPools */ + NULL, /* findPoolSources */ + NULL, /* poolLookupByName */ + NULL, /* poolLookupByUUID */ + NULL, /* poolLookupByVolume */ + NULL, /* poolCreateXML */ + NULL, /* poolDefineXML */ + NULL, /* poolBuild */ + NULL, /* poolUndefine */ + NULL, /* poolCreate */ + NULL, /* poolDestroy */ + NULL, /* poolDelete */ + NULL, /* poolRefresh */ + NULL, /* poolGetInfo */ + NULL, /* poolGetXMLDesc */ + NULL, /* poolGetAutostart */ + NULL, /* poolSetAutostart */ + NULL, /* poolNumOfVolumes */ + NULL, /* poolListVolumes */ + NULL, /* volLookupByName */ + NULL, /* volLookupByKey */ + NULL, /* volLookupByPath */ + NULL, /* volCreateXML */ + NULL, /* volCreateXMLFrom */ + NULL, /* volDelete */ + NULL, /* volGetInfo */ + NULL, /* volGetXMLDesc */ + NULL, /* volGetPath */ + NULL, /* poolIsActive */ + NULL, /* poolIsPersistent */ +}; + + + +int +esxStorageRegister(void) +{ + return virRegisterStorageDriver(&esxStorageDriver); +} diff --git a/src/esx/esx_storage_driver.h b/src/esx/esx_storage_driver.h new file mode 100644 index 0000000000..91a5d03ee0 --- /dev/null +++ b/src/esx/esx_storage_driver.h @@ -0,0 +1,29 @@ + +/* + * esx_storage_driver.h: storage driver methods for managing VMware ESX + * host storage + * + * Copyright (C) 2010 Matthias Bolte + * + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __ESX_STORAGE_DRIVER_H__ +#define __ESX_STORAGE_DRIVER_H__ + +int esxStorageRegister(void); + +#endif /* __ESX_STORAGE_DRIVER_H__ */ -- 2.39.5