提交 d6c40aae 编写于 作者: M Matthias Bolte

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.
上级 9bca7a7e
......@@ -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 \
......
/*
* esx_device_monitor.c: device monitor methods for managing VMware ESX
* host devices
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <config.h>
#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);
}
/*
* esx_device_monitor.h: device monitor methods for managing VMware ESX
* host devices
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, 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__ */
......@@ -2,7 +2,7 @@
/*
* esx_driver.c: core driver methods for managing VMware ESX hosts
*
* Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009, 2010 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009 Maximilian Wilhelm <max@rfc2324.org>
*
* 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;
}
......@@ -2,7 +2,7 @@
/*
* esx_driver.h: core driver methods for managing VMware ESX hosts
*
* Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009, 2010 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009 Maximilian Wilhelm <max@rfc2324.org>
*
* This library is free software; you can redistribute it and/or
......
/*
* esx_interface_driver.h: interface driver methods for managing VMware ESX
* host interfaces
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <config.h>
#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);
}
/*
* esx_interface_driver.h: interface driver methods for managing VMware ESX
* host interfaces
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, 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__ */
/*
* esx_network_driver.c: network driver methods for managing VMware ESX
* host networks
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <config.h>
#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);
}
/*
* esx_network_driver.h: network driver methods for managing VMware ESX
* host networks
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, 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__ */
/*
* esx_private.h: private driver struct for the VMware ESX driver
*
* Copyright (C) 2009, 2010 Matthias Bolte <matthias.bolte@googlemail.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, 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__ */
/*
* esx_secret_driver.c: secret driver methods for VMware ESX secret manipulation
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <config.h>
#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);
}
/*
* esx_secret_driver.h: secret driver methods for VMware ESX secret manipulation
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, 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__ */
/*
* esx_storage_driver.c: storage driver methods for managing VMware ESX
* host storage
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <config.h>
#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);
}
/*
* esx_storage_driver.h: storage driver methods for managing VMware ESX
* host storage
*
* Copyright (C) 2010 Matthias Bolte <matthias.bolte@googlemail.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, 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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册