]> xenbits.xensource.com Git - libvirt.git/commitdiff
hyperv: Add driver skeleton
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 13 Jul 2011 14:47:01 +0000 (16:47 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 26 Aug 2011 15:52:55 +0000 (17:52 +0200)
22 files changed:
cfg.mk
include/libvirt/virterror.h
po/POTFILES.in
src/Makefile.am
src/driver.h
src/hyperv/hyperv_device_monitor.c [new file with mode: 0644]
src/hyperv/hyperv_device_monitor.h [new file with mode: 0644]
src/hyperv/hyperv_driver.c [new file with mode: 0644]
src/hyperv/hyperv_driver.h [new file with mode: 0644]
src/hyperv/hyperv_interface_driver.c [new file with mode: 0644]
src/hyperv/hyperv_interface_driver.h [new file with mode: 0644]
src/hyperv/hyperv_network_driver.c [new file with mode: 0644]
src/hyperv/hyperv_network_driver.h [new file with mode: 0644]
src/hyperv/hyperv_nwfilter_driver.c [new file with mode: 0644]
src/hyperv/hyperv_nwfilter_driver.h [new file with mode: 0644]
src/hyperv/hyperv_private.h [new file with mode: 0644]
src/hyperv/hyperv_secret_driver.c [new file with mode: 0644]
src/hyperv/hyperv_secret_driver.h [new file with mode: 0644]
src/hyperv/hyperv_storage_driver.c [new file with mode: 0644]
src/hyperv/hyperv_storage_driver.h [new file with mode: 0644]
src/libvirt.c
src/util/virterror.c

diff --git a/cfg.mk b/cfg.mk
index 9f1f6c5ff4724fff43bf3187ff74b095cb840f2b..1bd9891ada9889f64bae1d51ff9470e8931b3356 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -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
index 9cac4372871b907ea754d04099431c9e7bb2d3f9..c270b54b4a798c4c3446a45ee95877965d316346 100644 (file)
@@ -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;
 
 
index b200f896f293a1888336f17ecbde19dbb324a90b..b28794a147a6947cc7368c1ea02aeeafb6809fe0 100644 (file)
@@ -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
index 5ba189c56d8c2eb982f3264b3265fa5e7b200c6a..8dfc0b9aa4d8b9754b07ac4500766cc56db19561 100644 (file)
@@ -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)                       \
index 5136fb55ecfaac401341bd1bcfb016af3e795bbf..80d662896ed55cea56fe9b21912d3ecded02c39e 100644 (file)
@@ -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 (file)
index 0000000..675d43a
--- /dev/null
@@ -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@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);
+}
diff --git a/src/hyperv/hyperv_device_monitor.h b/src/hyperv/hyperv_device_monitor.h
new file mode 100644 (file)
index 0000000..864e8af
--- /dev/null
@@ -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@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__ */
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
new file mode 100644 (file)
index 0000000..301aeb2
--- /dev/null
@@ -0,0 +1,108 @@
+
+/*
+ * 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;
+}
diff --git a/src/hyperv/hyperv_driver.h b/src/hyperv/hyperv_driver.h
new file mode 100644 (file)
index 0000000..17ffa2c
--- /dev/null
@@ -0,0 +1,29 @@
+
+/*
+ * 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__ */
diff --git a/src/hyperv/hyperv_interface_driver.c b/src/hyperv/hyperv_interface_driver.c
new file mode 100644 (file)
index 0000000..f2e8dee
--- /dev/null
@@ -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@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);
+}
diff --git a/src/hyperv/hyperv_interface_driver.h b/src/hyperv/hyperv_interface_driver.h
new file mode 100644 (file)
index 0000000..730234c
--- /dev/null
@@ -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@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__ */
diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c
new file mode 100644 (file)
index 0000000..92a43e3
--- /dev/null
@@ -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@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);
+}
diff --git a/src/hyperv/hyperv_network_driver.h b/src/hyperv/hyperv_network_driver.h
new file mode 100644 (file)
index 0000000..49c856f
--- /dev/null
@@ -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@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__ */
diff --git a/src/hyperv/hyperv_nwfilter_driver.c b/src/hyperv/hyperv_nwfilter_driver.c
new file mode 100644 (file)
index 0000000..b5d8069
--- /dev/null
@@ -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@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);
+}
diff --git a/src/hyperv/hyperv_nwfilter_driver.h b/src/hyperv/hyperv_nwfilter_driver.h
new file mode 100644 (file)
index 0000000..ef4f660
--- /dev/null
@@ -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@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__ */
diff --git a/src/hyperv/hyperv_private.h b/src/hyperv/hyperv_private.h
new file mode 100644 (file)
index 0000000..17bdd60
--- /dev/null
@@ -0,0 +1,34 @@
+
+/*
+ * 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__ */
diff --git a/src/hyperv/hyperv_secret_driver.c b/src/hyperv/hyperv_secret_driver.c
new file mode 100644 (file)
index 0000000..b238e06
--- /dev/null
@@ -0,0 +1,79 @@
+
+/*
+ * 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);
+}
diff --git a/src/hyperv/hyperv_secret_driver.h b/src/hyperv/hyperv_secret_driver.h
new file mode 100644 (file)
index 0000000..a7e9f25
--- /dev/null
@@ -0,0 +1,29 @@
+
+/*
+ * 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__ */
diff --git a/src/hyperv/hyperv_storage_driver.c b/src/hyperv/hyperv_storage_driver.c
new file mode 100644 (file)
index 0000000..4bfefd0
--- /dev/null
@@ -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@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);
+}
diff --git a/src/hyperv/hyperv_storage_driver.h b/src/hyperv/hyperv_storage_driver.h
new file mode 100644 (file)
index 0000000..c9bca22
--- /dev/null
@@ -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@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__ */
index a9a34f52f4b43faa78ac1b8d09fcd5ee5e630717..b8fe1b1384c85449f3cec40d431cf859833959ba 100644 (file)
@@ -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
index 9b8a340145ee71d6763d7501cd580cea3388f7b1..b50fbfd109276acce809637e90e0d4347e2311da 100644 (file)
@@ -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);
 }