提交 4d6e6f4a 编写于 作者: M Matthias Bolte

hyperv: Add driver skeleton

上级 f2e70643
......@@ -457,6 +457,7 @@ sc_avoid_attribute_unused_in_header:
msg_gen_function =
msg_gen_function += ESX_ERROR
msg_gen_function += ESX_VI_ERROR
msg_gen_function += HYPERV_ERROR
msg_gen_function += PHYP_ERROR
msg_gen_function += VIR_ERROR
msg_gen_function += VMX_ERROR
......
......@@ -82,6 +82,7 @@ typedef enum {
VIR_FROM_EVENT = 40, /* Error from event loop impl */
VIR_FROM_LIBXL = 41, /* Error from libxenlight driver */
VIR_FROM_LOCKING = 42, /* Error from lock manager */
VIR_FROM_HYPERV = 43, /* Error from Hyper-V driver */
} virErrorDomain;
......
......@@ -28,6 +28,7 @@ src/esx/esx_vi.c
src/esx/esx_vi_methods.c
src/esx/esx_vi_types.c
src/fdstream.c
src/hyperv/hyperv_driver.c
src/interface/netcf_driver.c
src/internal.h
src/libvirt.c
......
......@@ -403,6 +403,15 @@ ESX_DRIVER_EXTRA_DIST = \
esx/esx_vi_generator.py \
$(ESX_DRIVER_GENERATED)
HYPERV_DRIVER_SOURCES = \
hyperv/hyperv_private.h \
hyperv/hyperv_driver.c hyperv/hyperv_driver.h \
hyperv/hyperv_interface_driver.c hyperv/hyperv_interface_driver.h \
hyperv/hyperv_network_driver.c hyperv/hyperv_network_driver.h \
hyperv/hyperv_storage_driver.c hyperv/hyperv_storage_driver.h \
hyperv/hyperv_device_monitor.c hyperv/hyperv_device_monitor.h \
hyperv/hyperv_secret_driver.c hyperv/hyperv_secret_driver.h \
hyperv/hyperv_nwfilter_driver.c hyperv/hyperv_nwfilter_driver.h
NETWORK_DRIVER_SOURCES = \
network/bridge_driver.h network/bridge_driver.c
......@@ -835,6 +844,25 @@ libvirt_driver_esx_la_SOURCES = $(ESX_DRIVER_SOURCES)
libvirt_driver_esx_la_DEPENDENCIES = $(ESX_DRIVER_GENERATED)
endif
if WITH_HYPERV
if WITH_DRIVER_MODULES
mod_LTLIBRARIES += libvirt_driver_hyperv.la
else
noinst_LTLIBRARIES += libvirt_driver_hyperv.la
libvirt_la_BUILT_LIBADD += libvirt_driver_hyperv.la
endif
libvirt_driver_hyperv_la_CFLAGS = $(OPENWSMAN_CFLAGS) \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
libvirt_driver_hyperv_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_hyperv_la_LIBADD = $(OPENWSMAN_LIBS)
if WITH_DRIVER_MODULES
libvirt_driver_hyperv_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_hyperv_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_hyperv_la_SOURCES = $(HYPERV_DRIVER_SOURCES)
endif
if WITH_NETWORK
if WITH_DRIVER_MODULES
mod_LTLIBRARIES += libvirt_driver_network.la
......@@ -1029,6 +1057,7 @@ EXTRA_DIST += \
$(LIBXL_DRIVER_SOURCES) \
$(ESX_DRIVER_SOURCES) \
$(ESX_DRIVER_EXTRA_DIST) \
$(HYPERV_DRIVER_SOURCES) \
$(NETWORK_DRIVER_SOURCES) \
$(INTERFACE_DRIVER_SOURCES) \
$(STORAGE_DRIVER_SOURCES) \
......
......@@ -29,6 +29,7 @@ typedef enum {
VIR_DRV_XENAPI = 12,
VIR_DRV_VMWARE = 13,
VIR_DRV_LIBXL = 14,
VIR_DRV_HYPERV = 15,
} virDrvNo;
......
/*
* hyperv_device_monitor.c: device monitor functions for managing
* Microsoft Hyper-V host devices
*
* Copyright (C) 2011 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 "datatypes.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "hyperv_device_monitor.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
static virDrvOpenStatus
hypervDeviceOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (conn->driver->no != VIR_DRV_HYPERV) {
return VIR_DRV_OPEN_DECLINED;
}
conn->devMonPrivateData = conn->privateData;
return VIR_DRV_OPEN_SUCCESS;
}
static int
hypervDeviceClose(virConnectPtr conn)
{
conn->devMonPrivateData = NULL;
return 0;
}
static virDeviceMonitor hypervDeviceMonitor = {
"Hyper-V",
.open = hypervDeviceOpen, /* 0.9.5 */
.close = hypervDeviceClose, /* 0.9.5 */
};
int
hypervDeviceRegister(void)
{
return virRegisterDeviceMonitor(&hypervDeviceMonitor);
}
/*
* hyperv_device_monitor.h: device monitor functions for managing
* Microsoft Hyper-V host devices
*
* Copyright (C) 2011 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 __HYPERV_DEVICE_MONITOR_H__
# define __HYPERV_DEVICE_MONITOR_H__
int hypervDeviceRegister(void);
#endif /* __HYPERV_DEVICE_MONITOR_H__ */
/*
* hyperv_driver.c: core driver functions for managing Microsoft Hyper-V hosts
*
* Copyright (C) 2011 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009 Michael Sievers <msievers83@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 "datatypes.h"
#include "domain_conf.h"
#include "authhelper.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "hyperv_driver.h"
#include "hyperv_interface_driver.h"
#include "hyperv_network_driver.h"
#include "hyperv_storage_driver.h"
#include "hyperv_device_monitor.h"
#include "hyperv_secret_driver.h"
#include "hyperv_nwfilter_driver.h"
#include "hyperv_private.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
static virDrvOpenStatus
hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Decline if the URI is NULL or the scheme is not hyperv */
if (conn->uri == NULL || conn->uri->scheme == NULL ||
STRCASENEQ(conn->uri->scheme, "hyperv")) {
return VIR_DRV_OPEN_DECLINED;
}
/* Require server part */
if (conn->uri->server == NULL) {
HYPERV_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("URI is missing the server part"));
return VIR_DRV_OPEN_ERROR;
}
/* Require auth */
if (auth == NULL || auth->cb == NULL) {
HYPERV_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("Missing or invalid auth pointer"));
return VIR_DRV_OPEN_ERROR;
}
return VIR_DRV_OPEN_SUCCESS;
}
static int
hypervClose(virConnectPtr conn ATTRIBUTE_UNUSED)
{
return 0;
}
static virDriver hypervDriver = {
.no = VIR_DRV_HYPERV,
.name = "Hyper-V",
.open = hypervOpen, /* 0.9.5 */
.close = hypervClose, /* 0.9.5 */
};
int
hypervRegister(void)
{
if (virRegisterDriver(&hypervDriver) < 0 ||
hypervInterfaceRegister() < 0 ||
hypervNetworkRegister() < 0 ||
hypervStorageRegister() < 0 ||
hypervDeviceRegister() < 0 ||
hypervSecretRegister() < 0 ||
hypervNWFilterRegister() < 0) {
return -1;
}
return 0;
}
/*
* hyperv_driver.h: core driver functions for managing Microsoft Hyper-V hosts
*
* Copyright (C) 2011 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009 Michael Sievers <msievers83@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 __HYPERV_DRIVER_H__
# define __HYPERV_DRIVER_H__
int hypervRegister(void);
#endif /* __HYPERV_DRIVER_H__ */
/*
* hyperv_interface_driver.c: interface driver functions for managing
* Microsoft Hyper-V host interfaces
*
* Copyright (C) 2011 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 "datatypes.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "hyperv_interface_driver.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
static virDrvOpenStatus
hypervInterfaceOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (conn->driver->no != VIR_DRV_HYPERV) {
return VIR_DRV_OPEN_DECLINED;
}
conn->interfacePrivateData = conn->privateData;
return VIR_DRV_OPEN_SUCCESS;
}
static int
hypervInterfaceClose(virConnectPtr conn)
{
conn->interfacePrivateData = NULL;
return 0;
}
static virInterfaceDriver hypervInterfaceDriver = {
.name = "Hyper-V",
.open = hypervInterfaceOpen, /* 0.9.5 */
.close = hypervInterfaceClose, /* 0.9.5 */
};
int
hypervInterfaceRegister(void)
{
return virRegisterInterfaceDriver(&hypervInterfaceDriver);
}
/*
* hyperv_interface_driver.h: interface driver functions for managing
* Microsoft Hyper-V host interfaces
*
* Copyright (C) 2011 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 __HYPERV_INTERFACE_DRIVER_H__
# define __HYPERV_INTERFACE_DRIVER_H__
int hypervInterfaceRegister(void);
#endif /* __HYPERV_INTERFACE_DRIVER_H__ */
/*
* hyperv_network_driver.c: network driver functions for managing
* Microsoft Hyper-V host networks
*
* Copyright (C) 2011 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 "datatypes.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "hyperv_network_driver.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
static virDrvOpenStatus
hypervNetworkOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (conn->driver->no != VIR_DRV_HYPERV) {
return VIR_DRV_OPEN_DECLINED;
}
conn->networkPrivateData = conn->privateData;
return VIR_DRV_OPEN_SUCCESS;
}
static int
hypervNetworkClose(virConnectPtr conn)
{
conn->networkPrivateData = NULL;
return 0;
}
static virNetworkDriver hypervNetworkDriver = {
.name = "Hyper-V",
.open = hypervNetworkOpen, /* 0.9.5 */
.close = hypervNetworkClose, /* 0.9.5 */
};
int
hypervNetworkRegister(void)
{
return virRegisterNetworkDriver(&hypervNetworkDriver);
}
/*
* hyperv_network_driver.h: network driver functions for managing
* Microsoft Hyper-V host networks
*
* Copyright (C) 2011 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 __HYPERV_NETWORK_DRIVER_H__
# define __HYPERV_NETWORK_DRIVER_H__
int hypervNetworkRegister(void);
#endif /* __HYPERV_NETWORK_DRIVER_H__ */
/*
* hyperv_nwfilter_driver.c: nwfilter driver functions for managing
* Microsoft Hyper-V firewall rules
*
* Copyright (C) 2011 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 "datatypes.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "hyperv_nwfilter_driver.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
static virDrvOpenStatus
hypervNWFilterOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (conn->driver->no != VIR_DRV_HYPERV) {
return VIR_DRV_OPEN_DECLINED;
}
conn->nwfilterPrivateData = conn->privateData;
return VIR_DRV_OPEN_SUCCESS;
}
static int
hypervNWFilterClose(virConnectPtr conn)
{
conn->nwfilterPrivateData = NULL;
return 0;
}
static virNWFilterDriver hypervNWFilterDriver = {
.name = "Hyper-V",
.open = hypervNWFilterOpen, /* 0.9.5 */
.close = hypervNWFilterClose, /* 0.9.5 */
};
int
hypervNWFilterRegister(void)
{
return virRegisterNWFilterDriver(&hypervNWFilterDriver);
}
/*
* hyperv_nwfilter_driver.h: nwfilter driver functions for managing
* Microsoft Hyper-V firewall rules
*
* Copyright (C) 2011 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 __HYPERV_NWFILTER_DRIVER_H__
# define __HYPERV_NWFILTER_DRIVER_H__
int hypervNWFilterRegister(void);
#endif /* __HYPERV_NWFILTER_DRIVER_H__ */
/*
* hyperv_private.h: private driver struct for the Microsoft Hyper-V driver
*
* Copyright (C) 2011 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009 Michael Sievers <msievers83@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 __HYPERV_PRIVATE_H__
# define __HYPERV_PRIVATE_H__
# include "internal.h"
# include "virterror_internal.h"
# define HYPERV_ERROR(code, ...) \
virReportErrorHelper(VIR_FROM_HYPERV, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
#endif /* __HYPERV_PRIVATE_H__ */
/*
* hyperv_secret_driver.c: secret driver functions for Microsoft Hyper-V
* secret manipulation
*
* Copyright (C) 2011 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 "datatypes.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "hyperv_secret_driver.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
static virDrvOpenStatus
hypervSecretOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (conn->driver->no != VIR_DRV_HYPERV) {
return VIR_DRV_OPEN_DECLINED;
}
conn->secretPrivateData = conn->privateData;
return VIR_DRV_OPEN_SUCCESS;
}
static int
hypervSecretClose(virConnectPtr conn)
{
conn->secretPrivateData = NULL;
return 0;
}
static virSecretDriver hypervSecretDriver = {
.name = "Hyper-V",
.open = hypervSecretOpen, /* 0.9.5 */
.close = hypervSecretClose, /* 0.9.5 */
};
int
hypervSecretRegister(void)
{
return virRegisterSecretDriver(&hypervSecretDriver);
}
/*
* hyperv_secret_driver.h: secret driver functions for Microsoft Hyper-V
* secret manipulation
*
* Copyright (C) 2011 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 __HYPERV_SECRET_DRIVER_H__
# define __HYPERV_SECRET_DRIVER_H__
int hypervSecretRegister(void);
#endif /* __HYPERV_SECRET_DRIVER_H__ */
/*
* hyperv_storage_driver.c: storage driver functions for managing
* Microsoft Hyper-V host storage
*
* Copyright (C) 2011 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 "datatypes.h"
#include "util.h"
#include "memory.h"
#include "logging.h"
#include "uuid.h"
#include "hyperv_storage_driver.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
static virDrvOpenStatus
hypervStorageOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (conn->driver->no != VIR_DRV_HYPERV) {
return VIR_DRV_OPEN_DECLINED;
}
conn->storagePrivateData = conn->privateData;
return VIR_DRV_OPEN_SUCCESS;
}
static int
hypervStorageClose(virConnectPtr conn)
{
conn->storagePrivateData = NULL;
return 0;
}
static virStorageDriver hypervStorageDriver = {
.name = "Hyper-V",
.open = hypervStorageOpen, /* 0.9.5*/
.close = hypervStorageClose, /* 0.9.5 */
};
int
hypervStorageRegister(void)
{
return virRegisterStorageDriver(&hypervStorageDriver);
}
/*
* hyperv_storage_driver.h: storage driver methods for managing
* Microsoft Hyper-V host storage
*
* Copyright (C) 2011 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 __HYPERV_STORAGE_DRIVER_H__
# define __HYPERV_STORAGE_DRIVER_H__
int hypervStorageRegister(void);
#endif /* __HYPERV_STORAGE_DRIVER_H__ */
......@@ -67,6 +67,9 @@
# ifdef WITH_ESX
# include "esx/esx_driver.h"
# endif
# ifdef WITH_HYPERV
# include "hyperv/hyperv_driver.h"
# endif
# ifdef WITH_XENAPI
# include "xenapi/xenapi_driver.h"
# endif
......@@ -453,6 +456,9 @@ virInitialize(void)
# ifdef WITH_ESX
virDriverLoadModule("esx");
# endif
# ifdef WITH_HYPERV
virDriverLoadModule("hyperv");
# endif
# ifdef WITH_XENAPI
virDriverLoadModule("xenapi");
# endif
......@@ -481,6 +487,9 @@ virInitialize(void)
# ifdef WITH_ESX
if (esxRegister() == -1) return -1;
# endif
# ifdef WITH_HYPERV
if (hypervRegister() == -1) return -1;
# endif
# ifdef WITH_XENAPI
if (xenapiRegister() == -1) return -1;
# endif
......@@ -1045,6 +1054,9 @@ do_open (const char *name,
STRCASEEQ(ret->uri->scheme, "esx") ||
STRCASEEQ(ret->uri->scheme, "gsx") ||
#endif
#ifndef WITH_HYPERV
STRCASEEQ(ret->uri->scheme, "hyperv") ||
#endif
#ifndef WITH_XENAPI
STRCASEEQ(ret->uri->scheme, "xenapi") ||
#endif
......
......@@ -172,6 +172,9 @@ static const char *virErrorDomainName(virErrorDomain domain) {
case VIR_FROM_LOCKING:
dom = "Locking ";
break;
case VIR_FROM_HYPERV:
dom = "Hyper-V ";
break;
}
return(dom);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册