2011/7/13 Eric Blake <eblake@xxxxxxxxxx>: > On 07/13/2011 01:01 PM, Matthias Bolte wrote: >> --- >> cfg.mk | 1 + >> include/libvirt/virterror.h | 1 + >> libvirt.spec.in | 9 +++ >> +++ b/src/hyperv/hyperv_driver.h >> @@ -0,0 +1,29 @@ >> + >> +/* >> + * hyperv_driver.h: core driver functions for managing Microsoft Hyper-V hosts >> + * >> + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> >> + * Copyright (C) 2009 Michael Sievers <msievers83@xxxxxxxxxxxxxx> > > How much of this file is really attributable to Michael, vs. this just > being copy and paste? > > ACK with the copyright nit fixed. hyperv_driver.h comes directly from his original codebase. I just changed indentation of the define to make cppi happy, so my copyright notice is more debatable here than his. In contrast the other secondary drivers were added by me to avoid libvirt trying to connect to a non-existing libvirtd on the Hyper-V server (just the same reason the ESX driver comes with stubs for all secondary drivers). Therefore, I think there is nothing to be fixed on the copyright notice here. Here's a v2 without the libvirt.spec.in part to match the v2 of 1/5. -- Matthias Bolte http://photron.blogspot.com
From 0a6b36391e810a302903b30669753583bef8a6b6 Mon Sep 17 00:00:00 2001 From: Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> Date: Wed, 13 Jul 2011 16:47:01 +0200 Subject: [PATCHv2 2/5] hyperv: Add driver skeleton --- v2: - move libvirt.spec.in change to 1/5 cfg.mk | 1 + include/libvirt/virterror.h | 1 + po/POTFILES.in | 1 + src/Makefile.am | 29 +++++++++ src/driver.h | 1 + src/hyperv/hyperv_device_monitor.c | 79 +++++++++++++++++++++++++ src/hyperv/hyperv_device_monitor.h | 29 +++++++++ src/hyperv/hyperv_driver.c | 108 ++++++++++++++++++++++++++++++++++ src/hyperv/hyperv_driver.h | 29 +++++++++ src/hyperv/hyperv_interface_driver.c | 79 +++++++++++++++++++++++++ src/hyperv/hyperv_interface_driver.h | 29 +++++++++ src/hyperv/hyperv_network_driver.c | 79 +++++++++++++++++++++++++ src/hyperv/hyperv_network_driver.h | 29 +++++++++ src/hyperv/hyperv_nwfilter_driver.c | 79 +++++++++++++++++++++++++ src/hyperv/hyperv_nwfilter_driver.h | 29 +++++++++ src/hyperv/hyperv_private.h | 34 +++++++++++ src/hyperv/hyperv_secret_driver.c | 79 +++++++++++++++++++++++++ src/hyperv/hyperv_secret_driver.h | 29 +++++++++ src/hyperv/hyperv_storage_driver.c | 79 +++++++++++++++++++++++++ src/hyperv/hyperv_storage_driver.h | 29 +++++++++ src/libvirt.c | 12 ++++ src/util/virterror.c | 3 + 22 files changed, 867 insertions(+), 0 deletions(-) create mode 100644 src/hyperv/hyperv_device_monitor.c create mode 100644 src/hyperv/hyperv_device_monitor.h create mode 100644 src/hyperv/hyperv_driver.c create mode 100644 src/hyperv/hyperv_driver.h create mode 100644 src/hyperv/hyperv_interface_driver.c create mode 100644 src/hyperv/hyperv_interface_driver.h create mode 100644 src/hyperv/hyperv_network_driver.c create mode 100644 src/hyperv/hyperv_network_driver.h create mode 100644 src/hyperv/hyperv_nwfilter_driver.c create mode 100644 src/hyperv/hyperv_nwfilter_driver.h create mode 100644 src/hyperv/hyperv_private.h create mode 100644 src/hyperv/hyperv_secret_driver.c create mode 100644 src/hyperv/hyperv_secret_driver.h create mode 100644 src/hyperv/hyperv_storage_driver.c create mode 100644 src/hyperv/hyperv_storage_driver.h diff --git a/cfg.mk b/cfg.mk index ffaca85..0c23ab8 100644 --- a/cfg.mk +++ b/cfg.mk @@ -421,6 +421,7 @@ sc_prohibit_xmlGetProp: 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 diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index efa4796..bd64eb4 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -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; diff --git a/po/POTFILES.in b/po/POTFILES.in index 5782cbf..b3344b3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 39f0cf8..49da107 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -379,6 +379,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 @@ -809,6 +818,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 @@ -1000,6 +1028,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) \ diff --git a/src/driver.h b/src/driver.h index 70ea4c2..589f232 100644 --- a/src/driver.h +++ b/src/driver.h @@ -29,6 +29,7 @@ typedef enum { VIR_DRV_XENAPI = 12, VIR_DRV_VMWARE = 13, VIR_DRV_LIBXL = 14, + VIR_DRV_HYPERV = 15, } virDrvNo; diff --git a/src/hyperv/hyperv_device_monitor.c b/src/hyperv/hyperv_device_monitor.c new file mode 100644 index 0000000..ea9e068 --- /dev/null +++ b/src/hyperv/hyperv_device_monitor.c @@ -0,0 +1,79 @@ + +/* + * hyperv_device_monitor.c: device monitor functions for managing + * Microsoft Hyper-V host devices + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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.4 */ + .close = hypervDeviceClose, /* 0.9.4 */ +}; + + + +int +hypervDeviceRegister(void) +{ + return virRegisterDeviceMonitor(&hypervDeviceMonitor); +} diff --git a/src/hyperv/hyperv_device_monitor.h b/src/hyperv/hyperv_device_monitor.h new file mode 100644 index 0000000..864e8af --- /dev/null +++ b/src/hyperv/hyperv_device_monitor.h @@ -0,0 +1,29 @@ + +/* + * hyperv_device_monitor.h: device monitor functions for managing + * Microsoft Hyper-V host devices + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c new file mode 100644 index 0000000..eb01bac --- /dev/null +++ b/src/hyperv/hyperv_driver.c @@ -0,0 +1,108 @@ + +/* + * hyperv_driver.c: core driver functions for managing Microsoft Hyper-V hosts + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * Copyright (C) 2009 Michael Sievers <msievers83@xxxxxxxxxxxxxx> + * + * 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.4 */ + .close = hypervClose, /* 0.9.4 */ +}; + + + +int +hypervRegister(void) +{ + if (virRegisterDriver(&hypervDriver) < 0 || + hypervInterfaceRegister() < 0 || + hypervNetworkRegister() < 0 || + hypervStorageRegister() < 0 || + hypervDeviceRegister() < 0 || + hypervSecretRegister() < 0 || + hypervNWFilterRegister() < 0) { + return -1; + } + + return 0; +} diff --git a/src/hyperv/hyperv_driver.h b/src/hyperv/hyperv_driver.h new file mode 100644 index 0000000..17ffa2c --- /dev/null +++ b/src/hyperv/hyperv_driver.h @@ -0,0 +1,29 @@ + +/* + * hyperv_driver.h: core driver functions for managing Microsoft Hyper-V hosts + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * Copyright (C) 2009 Michael Sievers <msievers83@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/hyperv/hyperv_interface_driver.c b/src/hyperv/hyperv_interface_driver.c new file mode 100644 index 0000000..bb92366 --- /dev/null +++ b/src/hyperv/hyperv_interface_driver.c @@ -0,0 +1,79 @@ + +/* + * hyperv_interface_driver.c: interface driver functions for managing + * Microsoft Hyper-V host interfaces + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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.4 */ + .close = hypervInterfaceClose, /* 0.9.4 */ +}; + + + +int +hypervInterfaceRegister(void) +{ + return virRegisterInterfaceDriver(&hypervInterfaceDriver); +} diff --git a/src/hyperv/hyperv_interface_driver.h b/src/hyperv/hyperv_interface_driver.h new file mode 100644 index 0000000..730234c --- /dev/null +++ b/src/hyperv/hyperv_interface_driver.h @@ -0,0 +1,29 @@ + +/* + * hyperv_interface_driver.h: interface driver functions for managing + * Microsoft Hyper-V host interfaces + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c new file mode 100644 index 0000000..07c7a7b --- /dev/null +++ b/src/hyperv/hyperv_network_driver.c @@ -0,0 +1,79 @@ + +/* + * hyperv_network_driver.c: network driver functions for managing + * Microsoft Hyper-V host networks + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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.4 */ + .close = hypervNetworkClose, /* 0.9.4 */ +}; + + + +int +hypervNetworkRegister(void) +{ + return virRegisterNetworkDriver(&hypervNetworkDriver); +} diff --git a/src/hyperv/hyperv_network_driver.h b/src/hyperv/hyperv_network_driver.h new file mode 100644 index 0000000..49c856f --- /dev/null +++ b/src/hyperv/hyperv_network_driver.h @@ -0,0 +1,29 @@ + +/* + * hyperv_network_driver.h: network driver functions for managing + * Microsoft Hyper-V host networks + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/hyperv/hyperv_nwfilter_driver.c b/src/hyperv/hyperv_nwfilter_driver.c new file mode 100644 index 0000000..e571995 --- /dev/null +++ b/src/hyperv/hyperv_nwfilter_driver.c @@ -0,0 +1,79 @@ + +/* + * hyperv_nwfilter_driver.c: nwfilter driver functions for managing + * Microsoft Hyper-V firewall rules + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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.4 */ + .close = hypervNWFilterClose, /* 0.9.4 */ +}; + + + +int +hypervNWFilterRegister(void) +{ + return virRegisterNWFilterDriver(&hypervNWFilterDriver); +} diff --git a/src/hyperv/hyperv_nwfilter_driver.h b/src/hyperv/hyperv_nwfilter_driver.h new file mode 100644 index 0000000..ef4f660 --- /dev/null +++ b/src/hyperv/hyperv_nwfilter_driver.h @@ -0,0 +1,29 @@ + +/* + * hyperv_nwfilter_driver.h: nwfilter driver functions for managing + * Microsoft Hyper-V firewall rules + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/hyperv/hyperv_private.h b/src/hyperv/hyperv_private.h new file mode 100644 index 0000000..17bdd60 --- /dev/null +++ b/src/hyperv/hyperv_private.h @@ -0,0 +1,34 @@ + +/* + * hyperv_private.h: private driver struct for the Microsoft Hyper-V driver + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * Copyright (C) 2009 Michael Sievers <msievers83@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/hyperv/hyperv_secret_driver.c b/src/hyperv/hyperv_secret_driver.c new file mode 100644 index 0000000..95a447d --- /dev/null +++ b/src/hyperv/hyperv_secret_driver.c @@ -0,0 +1,79 @@ + +/* + * hyperv_secret_driver.c: secret driver functions for Microsoft Hyper-V + * secret manipulation + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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.4 */ + .close = hypervSecretClose, /* 0.9.4 */ +}; + + + +int +hypervSecretRegister(void) +{ + return virRegisterSecretDriver(&hypervSecretDriver); +} diff --git a/src/hyperv/hyperv_secret_driver.h b/src/hyperv/hyperv_secret_driver.h new file mode 100644 index 0000000..a7e9f25 --- /dev/null +++ b/src/hyperv/hyperv_secret_driver.h @@ -0,0 +1,29 @@ + +/* + * hyperv_secret_driver.h: secret driver functions for Microsoft Hyper-V + * secret manipulation + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/hyperv/hyperv_storage_driver.c b/src/hyperv/hyperv_storage_driver.c new file mode 100644 index 0000000..e62e6d8 --- /dev/null +++ b/src/hyperv/hyperv_storage_driver.c @@ -0,0 +1,79 @@ + +/* + * hyperv_storage_driver.c: storage driver functions for managing + * Microsoft Hyper-V host storage + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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.4 */ + .close = hypervStorageClose, /* 0.9.4 */ +}; + + + +int +hypervStorageRegister(void) +{ + return virRegisterStorageDriver(&hypervStorageDriver); +} diff --git a/src/hyperv/hyperv_storage_driver.h b/src/hyperv/hyperv_storage_driver.h new file mode 100644 index 0000000..c9bca22 --- /dev/null +++ b/src/hyperv/hyperv_storage_driver.h @@ -0,0 +1,29 @@ + +/* + * hyperv_storage_driver.h: storage driver methods for managing + * Microsoft Hyper-V host storage + * + * Copyright (C) 2011 Matthias Bolte <matthias.bolte@xxxxxxxxxxxxxx> + * + * 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__ */ diff --git a/src/libvirt.c b/src/libvirt.c index 7e70caa..8eb8905 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -66,6 +66,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 @@ -446,6 +449,9 @@ virInitialize(void) # ifdef WITH_ESX virDriverLoadModule("esx"); # endif +# ifdef WITH_HYPERV + virDriverLoadModule("hyperv"); +# endif # ifdef WITH_XENAPI virDriverLoadModule("xenapi"); # endif @@ -474,6 +480,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 @@ -1038,6 +1047,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 diff --git a/src/util/virterror.c b/src/util/virterror.c index 75058f3..e13bac3 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -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); } -- 1.7.4.1
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list