[libvirt] [PATCH 1/1] [RFC] Parallels Server Bare Metal driver stub

Parallels Server Bare Metal is a virtualization solution which allows to run both Containers (OpenVZ-like) and virtual machines (like any other hardware hypervisor). This patch implements initial driver stub with almost no functionality except an ability to open and close driver. At the same time it contains initialization of Parallels API and clearly demonstrates supposed approach to future driver implementation. In particular, I suppose to use parallels-virtualization-sdk library provisioned with the PSBM distribution (and separately also) for PSBM's virtual servers management. Signed-off-by: Dmitry Mishin <dim@parallels.com> --- autobuild.sh | 1 + configure.ac | 21 +++++ include/libvirt/virterror.h | 1 + src/Makefile.am | 22 +++++ src/README | 1 + src/driver.h | 1 + src/libvirt.c | 9 ++ src/psbm/psbm_api.c | 117 ++++++++++++++++++++++++ src/psbm/psbm_api.h | 59 ++++++++++++ src/psbm/psbm_driver.c | 208 +++++++++++++++++++++++++++++++++++++++++++ src/psbm/psbm_driver.h | 32 +++++++ src/psbm/psbm_private.h | 49 ++++++++++ src/util/virterror.c | 3 + 13 files changed, 524 insertions(+), 0 deletions(-) create mode 100644 src/psbm/psbm_api.c create mode 100644 src/psbm/psbm_api.h create mode 100644 src/psbm/psbm_driver.c create mode 100644 src/psbm/psbm_driver.h create mode 100644 src/psbm/psbm_private.h diff --git a/autobuild.sh b/autobuild.sh index 491f1b8..f552343 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -81,6 +81,7 @@ if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then --without-uml \ --without-vbox \ --without-openvz \ + --without-psbm \ --without-phyp \ --without-netcf \ --without-audit \ diff --git a/configure.ac b/configure.ac index df19445..7cff4f5 100644 --- a/configure.ac +++ b/configure.ac @@ -283,6 +283,8 @@ AC_ARG_WITH([uml], AC_HELP_STRING([--with-uml], [add UML support @<:@default=check@:>@]),[],[with_uml=check]) AC_ARG_WITH([openvz], AC_HELP_STRING([--with-openvz], [add OpenVZ support @<:@default=check@:>@]),[],[with_openvz=check]) +AC_ARG_WITH([psbm], + AC_HELP_STRING([--with-psbm], [add PSBM support @<:@default=no@:>@]),[],[with_psbm=no]) AC_ARG_WITH([vmware], AC_HELP_STRING([--with-vmware], [add VMware support @<:@default=yes@:>@]),[],[with_vmware=yes]) AC_ARG_WITH([libssh2], @@ -385,6 +387,24 @@ AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"]) dnl +dnl Checks for the PSBM driver +dnl + +if test "$with_psbm" = "check"; then + with_psbm=$with_linux +fi + +if test "$with_psbm" = "yes" && test "$with_linux" = "no"; then + AC_MSG_ERROR([The PSBM driver can be enabled on Linux only.]) +fi + +if test "$with_psbm" = "yes"; then + AC_DEFINE_UNQUOTED([WITH_PSBM], 1, [whether PSBM driver is enabled]) +fi +AM_CONDITIONAL([WITH_PSBM], [test "$with_psbm" = "yes"]) + + +dnl dnl Checks for the VMware Workstation/Player driver dnl @@ -2504,6 +2524,7 @@ AC_MSG_NOTICE([ Xen: $with_xen]) AC_MSG_NOTICE([ QEMU: $with_qemu]) AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) +AC_MSG_NOTICE([ PSBM: $with_psbm]) AC_MSG_NOTICE([ VMware: $with_vmware]) AC_MSG_NOTICE([ VBox: $with_vbox]) AC_MSG_NOTICE([ XenAPI: $with_xenapi]) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 0aae622..858e051 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -83,6 +83,7 @@ typedef enum { 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 */ + VIR_FROM_PSBM = 44, /* Error from PSBM driver */ } virErrorDomain; diff --git a/src/Makefile.am b/src/Makefile.am index 738ee91..99f4995 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -320,6 +320,11 @@ OPENVZ_DRIVER_SOURCES = \ openvz/openvz_conf.c openvz/openvz_conf.h \ openvz/openvz_driver.c openvz/openvz_driver.h +PSBM_DRIVER_SOURCES = \ + psbm/psbm_driver.c psbm/psbm_driver.h \ + psbm/psbm_api.c psbm/psbm_api.h \ + psbm/psbm_private.h + VMWARE_DRIVER_SOURCES = \ vmware/vmware_driver.c vmware/vmware_driver.h \ vmware/vmware_conf.c vmware/vmware_conf.h @@ -684,6 +689,22 @@ endif libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES) endif +if WITH_PSBM +if WITH_DRIVER_MODULES +mod_LTLIBRARIES += libvirt_driver_psbm.la +else +noinst_LTLIBRARIES += libvirt_driver_psbm.la +libvirt_la_BUILT_LIBADD += libvirt_driver_psbm.la +endif +libvirt_driver_psbm_la_CFLAGS = \ + -I@top_srcdir@/src/conf $(AM_CFLAGS) +if WITH_DRIVER_MODULES +libvirt_driver_psbm_la_LIBADD = ../gnulib/lib/libgnu.la +libvirt_driver_psbm_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS) +endif +libvirt_driver_psbm_la_SOURCES = $(PSBM_DRIVER_SOURCES) +endif + if WITH_VMWARE if WITH_DRIVER_MODULES mod_LTLIBRARIES += libvirt_driver_vmware.la @@ -1078,6 +1099,7 @@ EXTRA_DIST += \ $(LXC_DRIVER_SOURCES) \ $(UML_DRIVER_SOURCES) \ $(OPENVZ_DRIVER_SOURCES) \ + $(PSBM_DRIVER_SOURCES) \ $(PHYP_DRIVER_SOURCES) \ $(VBOX_DRIVER_SOURCES) \ $(XENAPI_DRIVER_SOURCES) \ diff --git a/src/README b/src/README index 00d11d1..02c3f9c 100644 --- a/src/README +++ b/src/README @@ -29,6 +29,7 @@ Then there are the hypervisor implementations: * hyperv/ - Microsoft Hyper-V support using WinRM * lxc/ - Linux Native Containers * openvz/ - OpenVZ containers using cli tools + * psbm/ - Parallels Server Bare Metal using SDK API * phyp/ - IBM Power Hypervisor using CLI tools over SSH * qemu/ - QEMU / KVM using qemu CLI/monitor * remote/ - Generic libvirt native RPC client diff --git a/src/driver.h b/src/driver.h index 3792003..ad97790 100644 --- a/src/driver.h +++ b/src/driver.h @@ -30,6 +30,7 @@ typedef enum { VIR_DRV_VMWARE = 13, VIR_DRV_LIBXL = 14, VIR_DRV_HYPERV = 15, + VIR_DRV_PSBM = 16, } virDrvNo; diff --git a/src/libvirt.c b/src/libvirt.c index 8f94b11..59eb368 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -55,6 +55,9 @@ # ifdef WITH_OPENVZ # include "openvz/openvz_driver.h" # endif +# ifdef WITH_PSBM +# include "psbm/psbm_driver.h" +# endif # ifdef WITH_VMWARE # include "vmware/vmware_driver.h" # endif @@ -447,6 +450,9 @@ virInitialize(void) # ifdef WITH_OPENVZ virDriverLoadModule("openvz"); # endif +# ifdef WITH_PSBM + virDriverLoadModule("psbm"); +# endif # ifdef WITH_VMWARE virDriverLoadModule("vmware"); # endif @@ -475,6 +481,9 @@ virInitialize(void) # ifdef WITH_OPENVZ if (openvzRegister() == -1) return -1; # endif +# ifdef WITH_PSBM + if (psbmRegister() == -1) return -1; +# endif # ifdef WITH_VMWARE if (vmwareRegister() == -1) return -1; # endif diff --git a/src/psbm/psbm_api.c b/src/psbm/psbm_api.c new file mode 100644 index 0000000..b5a89f1 --- /dev/null +++ b/src/psbm/psbm_api.c @@ -0,0 +1,117 @@ +/* + * psbm_api.c: core driver methods for managing PSBM virtual servers + * + * Copyright (C) 2011 Parallels, Inc. + * + * 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 + * + * Authors: + * Dmitry Mishin <dim@parallels.com> + * + */ + +#include <config.h> + +#include <sys/utsname.h> +#include <dlfcn.h> + +#include "psbm_api.h" +#include "virterror_internal.h" + +#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR +#endif +#define PRL_SDK_WRAP_FOR_EACH_ITERATOR( name ) \ + name##wrap##_Ptr name; +#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR( name ) \ + name##wrap##_Ptr name; + +PRL_SDK_WRAP_FOR_EACH() + +#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR +#endif + + +int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so"; + void *handle = NULL; + PRL_RESULT res; + + handle = dlopen(libname, RTLD_LAZY); + if (!handle) { + psbmError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load SDK library %s %s"), libname, dlerror()); + return VIR_ERR_INTERNAL_ERROR; + } + +#define PRL_SDK_WRAP_FOR_EACH_ITERATOR(name) \ + if (!(name = (name##wrap##_Ptr)dlsym(handle, #name))) { \ + psbmError(VIR_ERR_INTERNAL_ERROR, \ + _("Failed to locate SDK symbol '%s' on initialization"), #name); \ + } + +#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR(name) \ + if (!(name = (name##wrap##_Ptr)dlsym(handle, #name))) { \ + } + + PRL_SDK_WRAP_FOR_EACH(); +#undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR +#undef PRL_SDK_WRAP_FOR_EACH_ITERATOR + + res = PrlApi_Init(PARALLELS_API_VER); + if (PRL_FAILED(res)) { + psbmError(VIR_ERR_OPERATION_FAILED, + _("Can't initialize Parallels SDK")); + dlclose(handle); + return VIR_ERR_OPERATION_FAILED; + } + + driver->handle = handle; + return VIR_ERR_OK; +} + +int psbmApiDeinit(struct psbm_driver *driver) +{ + if (driver->handle) { + PrlApi_Deinit(); + + if (dlclose(driver->handle)) { + psbmError(VIR_ERR_SYSTEM_ERROR, _("Can't unload Parallels SDK")); + return VIR_ERR_SYSTEM_ERROR; + } + } + +#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR +# undef PRL_SDK_WRAP_FOR_EACH_ITERATOR +# undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR +#endif + +#define PRL_SDK_WRAP_FOR_EACH_ITERATOR(name) \ + name = 0; +#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR(name) \ + name = 0; + +PRL_SDK_WRAP_FOR_EACH() + +#undef PRL_SDK_WRAP_FOR_EACH_ITERATOR +#undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR + + driver->handle = NULL; + return VIR_ERR_OK; +} diff --git a/src/psbm/psbm_api.h b/src/psbm/psbm_api.h new file mode 100644 index 0000000..8793bc6 --- /dev/null +++ b/src/psbm/psbm_api.h @@ -0,0 +1,59 @@ +/* + * psbm_api.h: SDK API methods for managing PSBM virtual servers + * + * Copyright (C) 2011 Parallels, Inc. + * + * 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 + * + * Authors: + * Dmitry Mishin <dim@parallels.com> + * + */ + + +#ifndef _PSBM_API_H_ +#define _PSBM_API_H_ + +/* necessary for dynamic loading of Parallels SDK library define */ +#define DYN_API_WRAP + +#include <parallels-virtualization-sdk/Parallels.h> +#include <parallels-virtualization-sdk/PrlApiMacro.h> + +#include "internal.h" +#include "psbm_private.h" + +#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR +#endif +#define PRL_SDK_WRAP_FOR_EACH_ITERATOR( name ) \ + extern name##wrap##_Ptr name; +#define PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR( name ) \ + extern name##wrap##_Ptr name; + +PRL_SDK_WRAP_FOR_EACH() + +#ifdef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_ITERATOR + #undef PRL_SDK_WRAP_FOR_EACH_DEPR_ITERATOR +#endif + + +/* Library initialization/deinitialization */ +int psbmApiInit(struct psbm_driver *driver); +int psbmApiDeinit(struct psbm_driver *driver); + +#endif /* _PSBM_API_H_ */ diff --git a/src/psbm/psbm_driver.c b/src/psbm/psbm_driver.c new file mode 100644 index 0000000..183d5ba --- /dev/null +++ b/src/psbm/psbm_driver.c @@ -0,0 +1,208 @@ +/* + * psbm_driver.c: core driver methods for managing PSBM virtual servers + * + * Copyright (C) 2011 Parallels, Inc. + * + * 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 + * + * Authors: + * Dmitry Mishin <dim@parallels.com> + * + */ + +#include <config.h> + +#include <sys/utsname.h> + +#include "psbm_driver.h" +#include "psbm_api.h" +#include "virterror_internal.h" +#include "datatypes.h" +#include "memory.h" +#include "nodeinfo.h" + +static void psbmDriverLock(struct psbm_driver *driver) +{ + virMutexLock(&driver->lock); +} + +static void psbmDriverUnlock(struct psbm_driver *driver) +{ + virMutexUnlock(&driver->lock); +} + +static void psbmFreeDriver(struct psbm_driver *driver) +{ + if (!driver) + return; + + virDomainObjListDeinit(&driver->domains); + virCapabilitiesFree(driver->caps); + VIR_FREE(driver); +} + +static virCapsPtr psbmCapsInit(void) +{ + struct utsname utsname; + virCapsPtr caps; + virCapsGuestPtr guest; + + uname(&utsname); + + if ((caps = virCapabilitiesNew(utsname.machine, + 0, 0)) == NULL) + goto no_memory; + + if (nodeCapsInitNUMA(caps) < 0) + goto no_memory; + + virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x52, 0x54, 0x00 }); + + if ((guest = virCapabilitiesAddGuest(caps, + "exe", + utsname.machine, + sizeof(int) == 4 ? 32 : 8, + NULL, + NULL, + 0, + NULL)) == NULL) + goto no_memory; + + if (virCapabilitiesAddGuestDomain(guest, + "psbm", + NULL, + NULL, + 0, + NULL) == NULL) + goto no_memory; + + caps->defaultInitPath = "/sbin/init"; + + return caps; +no_memory: + virCapabilitiesFree(caps); + return NULL; +} + + +static virDrvOpenStatus psbmOpen(virConnectPtr conn, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + unsigned int flags) +{ + struct psbm_driver *driver; + + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + + /* Decline if the URI is NULL or the scheme is not 'psbm' */ + if (conn->uri == NULL || conn->uri->scheme == NULL || + STRCASENEQ(conn->uri->scheme, "psbm")) + return VIR_DRV_OPEN_DECLINED; + + + /* If path isn't /system, then they typoed, so tell them correct path */ + if (conn->uri->path == NULL || + STRNEQ (conn->uri->path, "/system")) { + psbmError(VIR_ERR_INTERNAL_ERROR, + _("unexpected PSBM URI path '%s', try psbm:///system"), + conn->uri->path); + return VIR_DRV_OPEN_ERROR; + } + + /* We now know the URI is definitely for this driver, so beyond + * here, don't return DECLINED, always use ERROR */ + + if (VIR_ALLOC(driver) < 0) { + virReportOOMError(); + return VIR_DRV_OPEN_ERROR; + } + + if (virDomainObjListInit(&driver->domains) < 0) + goto cleanup; + + if (!(driver->caps = psbmCapsInit())) + goto cleanup; + + /* load Parallels SDK library, resolve symbols, initialize it */ + if (psbmApiInit(driver) != VIR_ERR_OK) + goto cleanup; + + conn->privateData = driver; + + return VIR_DRV_OPEN_SUCCESS; + +cleanup: + psbmFreeDriver(driver); + return VIR_DRV_OPEN_ERROR; +}; + +static int psbmClose(virConnectPtr conn) { + struct psbm_driver *driver = conn->privateData; + int err; + + err = psbmApiDeinit(driver); + if (err != VIR_ERR_OK) + return err; + + psbmFreeDriver(driver); + conn->privateData = NULL; + + return 0; +} + +static const char *psbmGetType(virConnectPtr conn ATTRIBUTE_UNUSED) { + return "PSBM"; +} + +static int psbmGetVersion(virConnectPtr conn, unsigned long *version) { + struct psbm_driver *driver = conn->privateData; + psbmDriverLock(driver); + *version = driver->version; + psbmDriverUnlock(driver); + return 0; +} + +static int psbmListDomains(virConnectPtr conn ATTRIBUTE_UNUSED, + int *ids ATTRIBUTE_UNUSED , int nids ATTRIBUTE_UNUSED) { + /* FIXME implement via API */ + return -1; +} + +static int psbmNumDomains(virConnectPtr conn) { + struct psbm_driver *driver = conn->privateData; + int n; + + psbmDriverLock(driver); + n = virDomainObjListNumOfDomains(&driver->domains, 1); + psbmDriverUnlock(driver); + + return n; +} + +static virDriver psbmDriver = { + .no = VIR_DRV_PSBM, + .name = "PSBM", + .open = psbmOpen, /* 0.3.1 */ + .close = psbmClose, /* 0.3.1 */ + .type = psbmGetType, /* 0.3.1 */ + .version = psbmGetVersion, /* 0.3.1 */ + .nodeGetInfo = nodeGetInfo, /* 0.3.1 */ + .listDomains = psbmListDomains, /* 0.3.1 */ + .numOfDomains = psbmNumDomains, /* 0.3.1 */ +}; + +int psbmRegister(void) { + virRegisterDriver(&psbmDriver); + return 0; +} diff --git a/src/psbm/psbm_driver.h b/src/psbm/psbm_driver.h new file mode 100644 index 0000000..aff171c --- /dev/null +++ b/src/psbm/psbm_driver.h @@ -0,0 +1,32 @@ +/* + * psbm_driver.h: core driver methods for managing PSBM virtual servers + * + * Copyright (C) 2011 Parallels, Inc. + * + * 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 + * + * Authors: + * Dmitry Mishin <dim@parallels.com> + * + */ + +#ifndef _PSBM_DRIVER_H_ +#define _PSBM_DRIVER_H_ + +#include "internal.h" + +int psbmRegister(void); + +#endif /* _PSBM_DRIVER_H_ */ diff --git a/src/psbm/psbm_private.h b/src/psbm/psbm_private.h new file mode 100644 index 0000000..6994feb --- /dev/null +++ b/src/psbm/psbm_private.h @@ -0,0 +1,49 @@ +/* + * psbm_private.h: internal definitions for PSBM driver + * + * Copyright (C) 2011 Parallels, Inc. + * + * 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 + * + * Authors: + * Dmitry Mishin <dim@parallels.com> + * + */ + +#ifndef _PSBM_PRIVATE_H_ +#define _PSBM_PRIVATE_H_ + +#include "internal.h" +#include "threads.h" +#include "capabilities.h" +#include "domain_conf.h" + + +#define VIR_FROM_THIS VIR_FROM_PSBM + +# define psbmError(code, ...) \ + virReportErrorHelper(VIR_FROM_PSBM, code, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) + +struct psbm_driver { + virMutex lock; + + virCapsPtr caps; + virDomainObjList domains; + int version; + void *handle; +}; + +#endif /* _PSBM_PRIVATE_H_ */ diff --git a/src/util/virterror.c b/src/util/virterror.c index 26c4981..73f2618 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -100,6 +100,9 @@ static const char *virErrorDomainName(virErrorDomain domain) { case VIR_FROM_OPENVZ: dom = "OpenVZ "; break; + case VIR_FROM_PSBM: + dom = "PSBM "; + break; case VIR_FROM_VMWARE: dom = "VMware "; break; -- 1.7.3.4

On 09/26/2011 05:59 AM, Dmitry Mishin wrote:
Parallels Server Bare Metal is a virtualization solution which allows to run both Containers (OpenVZ-like) and virtual machines (like any other hardware hypervisor).
Any web page link so we can familiarize ourselves with the project?
This patch implements initial driver stub with almost no functionality except an ability to open and close driver. At the same time it contains initialization of Parallels API and clearly demonstrates supposed approach to future driver implementation. In particular, I suppose to use parallels-virtualization-sdk library provisioned with the PSBM distribution (and separately also) for PSBM's virtual servers management.
Signed-off-by: Dmitry Mishin<dim@parallels.com> --- autobuild.sh | 1 + configure.ac | 21 +++++ include/libvirt/virterror.h | 1 + src/Makefile.am | 22 +++++ src/README | 1 + src/driver.h | 1 + src/libvirt.c | 9 ++ src/psbm/psbm_api.c | 117 ++++++++++++++++++++++++ src/psbm/psbm_api.h | 59 ++++++++++++ src/psbm/psbm_driver.c | 208 +++++++++++++++++++++++++++++++++++++++++++ src/psbm/psbm_driver.h | 32 +++++++ src/psbm/psbm_private.h | 49 ++++++++++ src/util/virterror.c | 3 +
Missing a hypervisor stub page under docs/ (that would be a good place to include the link I mentioned above). Is this driver more like qemu, where it requires talking to a daemon like libvirtd (and where remote access is provided by libvirt), or more like esx, where it is translating things at the client level while talking to an esx protocol (and where remote access is provided by the hypervisor)? Missing changes to libvirt.spec.in and mingw32-libvirt.spec.in for making compilation of the new driver conditional when building for Fedora and friends. I'd feel a bit more comfortable reviewing this patch if you also had a followon patch that can do some basic APIs, such as start and stop guests, or even just list the names of running guests. Of course, those should be separate patches, but it is better to push a patch series that makes the hypervisor driver useful, rather than just pushing this patch in isolation where the hypervisor driver can't do anything at all. Look at the recent HyperV hypervisor driver addition (around commit 5e3b0f8) for an example of what all is needed to make this driver addition successful.
+ +if test "$with_psbm" = "yes"&& test "$with_linux" = "no"; then + AC_MSG_ERROR([The PSBM driver can be enabled on Linux only.])
Are there any libraries that have to be linked in? Is this all calls to third-party program(s) (in which case, should configure probe for the absolute path of that program)? Is it really Linux-only, or if those programs someday exist on other platforms, have you artificially restricted this driver?
+int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so";
Looks like you are using library calls, so configure needs to probe for the existence of this library.
+ +static virDriver psbmDriver = { + .no = VIR_DRV_PSBM, + .name = "PSBM", + .open = psbmOpen, /* 0.3.1 */ + .close = psbmClose, /* 0.3.1 */ + .type = psbmGetType, /* 0.3.1 */ + .version = psbmGetVersion, /* 0.3.1 */ + .nodeGetInfo = nodeGetInfo, /* 0.3.1 */ + .listDomains = psbmListDomains, /* 0.3.1 */ + .numOfDomains = psbmNumDomains, /* 0.3.1 */
Wrong version. You are adding this functions as of 0.9.7, not 0.3.1. I haven't reviewed this closely, because I'm not familiar enough with PSBM yet, but in general, I'm in favor of adding hypervisor drivers, so I hope to see this go somewhere. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric, Thank you for your comments! I'll check related to HyperV adoption commits and will try to fix necessary things in the next patch series. Links to product pages: http://www.parallels.com/products/server/baremetal/sp/resources/ http://www.parallels.com/download/server/
Is this driver more like qemu, where it requires talking to a daemon like libvirtd (and where remote access is provided by libvirt), or more like esx, where it is translating things at the client level while talking to an esx protocol (and where remote access is provided by the hypervisor)? We have a userspace daemon on PSBM node which is responsible for incoming requests management (like libvirtd) and client library (libprl_sdk.so) for remote/local access to it. Communication protocol is XML-based over TCP.
Is it really Linux-only, or if those programs someday exist on other platforms, have you artificially restricted this driver? Virtualization SDK is available for 3 platforms (Linux, Windows and Mac OS X) already. I decided to restrict it initially in order to achieve something usable on the single platform first, than extend it to others. Patches for extension will be small - just remove this restriction and add load of the shared library on appropriate paths. Just want to avoid additional testing on the adoption stage.
-- Thanks, Dmitry. On Tuesday, September 27, 2011 09:39:14 PM Eric Blake wrote:
On 09/26/2011 05:59 AM, Dmitry Mishin wrote:
Parallels Server Bare Metal is a virtualization solution which allows to run both Containers (OpenVZ-like) and virtual machines (like any other hardware hypervisor).
Any web page link so we can familiarize ourselves with the project?
This patch implements initial driver stub with almost no functionality except an ability to open and close driver. At the same time it contains initialization of Parallels API and clearly demonstrates supposed approach to future driver implementation. In particular, I suppose to use parallels-virtualization-sdk library provisioned with the PSBM distribution (and separately also) for PSBM's virtual servers management.
Signed-off-by: Dmitry Mishin<dim@parallels.com> ---
autobuild.sh | 1 + configure.ac | 21 +++++ include/libvirt/virterror.h | 1 + src/Makefile.am | 22 +++++ src/README | 1 + src/driver.h | 1 + src/libvirt.c | 9 ++ src/psbm/psbm_api.c | 117 ++++++++++++++++++++++++ src/psbm/psbm_api.h | 59 ++++++++++++ src/psbm/psbm_driver.c | 208 +++++++++++++++++++++++++++++++++++++++++++ src/psbm/psbm_driver.h | 32 +++++++ src/psbm/psbm_private.h | 49 ++++++++++ src/util/virterror.c | 3 +
Missing a hypervisor stub page under docs/ (that would be a good place to include the link I mentioned above). Is this driver more like qemu, where it requires talking to a daemon like libvirtd (and where remote access is provided by libvirt), or more like esx, where it is translating things at the client level while talking to an esx protocol (and where remote access is provided by the hypervisor)?
Missing changes to libvirt.spec.in and mingw32-libvirt.spec.in for making compilation of the new driver conditional when building for Fedora and friends.
I'd feel a bit more comfortable reviewing this patch if you also had a followon patch that can do some basic APIs, such as start and stop guests, or even just list the names of running guests. Of course, those should be separate patches, but it is better to push a patch series that makes the hypervisor driver useful, rather than just pushing this patch in isolation where the hypervisor driver can't do anything at all. Look at the recent HyperV hypervisor driver addition (around commit 5e3b0f8) for an example of what all is needed to make this driver addition successful.
+ +if test "$with_psbm" = "yes"&& test "$with_linux" = "no"; then + AC_MSG_ERROR([The PSBM driver can be enabled on Linux only.])
Are there any libraries that have to be linked in? Is this all calls to third-party program(s) (in which case, should configure probe for the absolute path of that program)? Is it really Linux-only, or if those programs someday exist on other platforms, have you artificially restricted this driver?
+int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so";
Looks like you are using library calls, so configure needs to probe for the existence of this library.
+ +static virDriver psbmDriver = { + .no = VIR_DRV_PSBM, + .name = "PSBM", + .open = psbmOpen, /* 0.3.1 */ + .close = psbmClose, /* 0.3.1 */ + .type = psbmGetType, /* 0.3.1 */ + .version = psbmGetVersion, /* 0.3.1 */ + .nodeGetInfo = nodeGetInfo, /* 0.3.1 */ + .listDomains = psbmListDomains, /* 0.3.1 */ + .numOfDomains = psbmNumDomains, /* 0.3.1 */
Wrong version. You are adding this functions as of 0.9.7, not 0.3.1.
I haven't reviewed this closely, because I'm not familiar enough with PSBM yet, but in general, I'm in favor of adding hypervisor drivers, so I hope to see this go somewhere.

On Mon, Sep 26, 2011 at 03:59:05PM +0400, Dmitry Mishin wrote:
Parallels Server Bare Metal is a virtualization solution which allows to run both Containers (OpenVZ-like) and virtual machines (like any other hardware hypervisor).
This patch implements initial driver stub with almost no functionality except an ability to open and close driver. At the same time it contains initialization of Parallels API and clearly demonstrates supposed approach to future driver implementation. In particular, I suppose to use parallels-virtualization-sdk library provisioned with the PSBM distribution (and separately also) for PSBM's virtual servers management.
Signed-off-by: Dmitry Mishin <dim@parallels.com> [...] diff --git a/src/psbm/psbm_api.c b/src/psbm/psbm_api.c new file mode 100644 index 0000000..b5a89f1 --- /dev/null +++ b/src/psbm/psbm_api.c @@ -0,0 +1,117 @@ +/* + * psbm_api.c: core driver methods for managing PSBM virtual servers + * + * Copyright (C) 2011 Parallels, Inc. + * + * 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 + * + * Authors: + * Dmitry Mishin <dim@parallels.com> + * + */
Copyrights and licencing terms looks okay :)
+int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so"; + void *handle = NULL; + PRL_RESULT res;
That I dislike, sorry this must not be dlopen'ed in at runtime, but checked in at configure time and properly linked in. Also means that proper dependancies and packaging have to be in place.
+ handle = dlopen(libname, RTLD_LAZY); + if (!handle) { + psbmError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load SDK library %s %s"), libname, dlerror()); + return VIR_ERR_INTERNAL_ERROR; + }
So what is that SDK library, how is it distributed and what is the licencing for it ? As much as I like adding a driver, I would like to make sure the deployement is clean and there is no licencing issues. Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/ and it's quite silent on code availability and Licence for the libraries. thanks in advance ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wed, Sep 28, 2011 at 09:34:47PM +0800, Daniel Veillard wrote:
On Mon, Sep 26, 2011 at 03:59:05PM +0400, Dmitry Mishin wrote:
Parallels Server Bare Metal is a virtualization solution which allows to run both Containers (OpenVZ-like) and virtual machines (like any other hardware hypervisor).
This patch implements initial driver stub with almost no functionality except an ability to open and close driver. At the same time it contains initialization of Parallels API and clearly demonstrates supposed approach to future driver implementation. In particular, I suppose to use parallels-virtualization-sdk library provisioned with the PSBM distribution (and separately also) for PSBM's virtual servers management.
After looking a bit and since I didn't find any packaging of your SDK in Fedora, I guess you're a bit as in the same situation as VMWare support, the best would be to implement the RPC ans allow to talk directly to the server as Matthias did for ESX. This will also drop the dependancy on that package and allow remote access directly. HTTP and XML libraries are already linked to libvirt that sounds the right way to proceed, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wednesday, September 28, 2011 05:34:47 PM Daniel Veillard wrote: [...]
+int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so"; + void *handle = NULL; + PRL_RESULT res;
That I dislike, sorry this must not be dlopen'ed in at runtime, but checked in at configure time and properly linked in. Also means that proper dependancies and packaging have to be in place. I exactly want to avoid dependencies.
Library can be used both remotely (for example, on Fedora host) and locally (on PSBM host). And if in the local case we can create special libvirt rpm with enabled PSBM support and integrate it to distribution, in remote case we force user to download not only Parallels SDK rpm (which will hardly be included to Fedora due to proprietary license), but also fixed libvirt package instead of already installed one. Is it preferable way from your point of view?
+ handle = dlopen(libname, RTLD_LAZY); + if (!handle) { + psbmError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load SDK library %s %s"), libname, dlerror()); + return VIR_ERR_INTERNAL_ERROR; + }
So what is that SDK library, how is it distributed and what is the licencing for it ? As much as I like adding a driver, I would like to make sure the deployement is clean and there is no licencing issues.
Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/ and it's quite silent on code availability and Licence for the libraries.
It has a proprietary license and not open sourced now. Is it a problem?
thanks in advance !
Daniel
-- Thanks, Dmitry.

On Wed, Sep 28, 2011 at 06:01:24PM +0400, Dmitry Mishin wrote:
On Wednesday, September 28, 2011 05:34:47 PM Daniel Veillard wrote: [...]
+int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so"; + void *handle = NULL; + PRL_RESULT res;
That I dislike, sorry this must not be dlopen'ed in at runtime, but checked in at configure time and properly linked in. Also means that proper dependancies and packaging have to be in place. I exactly want to avoid dependencies.
Library can be used both remotely (for example, on Fedora host) and locally (on PSBM host). And if in the local case we can create special libvirt rpm with enabled PSBM support and integrate it to distribution, in remote case we force user to download not only Parallels SDK rpm (which will hardly be included to Fedora due to proprietary license), but also fixed libvirt package instead of already installed one. Is it preferable way from your point of view?
That sounds fairly evil, I guess I would make a fuss if you started shipping libvirt rpms with non libvirt code in it. I think you need to go the XML-RPC way since that how access to the server seems to work, see my second mail, Matthias did this for VMWare support...
+ handle = dlopen(libname, RTLD_LAZY); + if (!handle) { + psbmError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load SDK library %s %s"), libname, dlerror()); + return VIR_ERR_INTERNAL_ERROR; + }
So what is that SDK library, how is it distributed and what is the licencing for it ? As much as I like adding a driver, I would like to make sure the deployement is clean and there is no licencing issues.
Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/ and it's quite silent on code availability and Licence for the libraries.
It has a proprietary license and not open sourced now. Is it a problem?
Yes our code is LGPL or GPL, we can't link with your SDK if it's not released under a compatible licence. See my second mail, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wed, Sep 28, 2011 at 06:01:24PM +0400, Dmitry Mishin wrote:
On Wednesday, September 28, 2011 05:34:47 PM Daniel Veillard wrote: [...]
+int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so"; + void *handle = NULL; + PRL_RESULT res;
That I dislike, sorry this must not be dlopen'ed in at runtime, but checked in at configure time and properly linked in. Also means that proper dependancies and packaging have to be in place. I exactly want to avoid dependencies.
Library can be used both remotely (for example, on Fedora host) and locally (on PSBM host). And if in the local case we can create special libvirt rpm with enabled PSBM support and integrate it to distribution, in remote case we force user to download not only Parallels SDK rpm (which will hardly be included to Fedora due to proprietary license), but also fixed libvirt package instead of already installed one. Is it preferable way from your point of view?
+ handle = dlopen(libname, RTLD_LAZY); + if (!handle) { + psbmError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load SDK library %s %s"), libname, dlerror()); + return VIR_ERR_INTERNAL_ERROR; + }
So what is that SDK library, how is it distributed and what is the licencing for it ? As much as I like adding a driver, I would like to make sure the deployement is clean and there is no licencing issues.
Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/ and it's quite silent on code availability and Licence for the libraries.
It has a proprietary license and not open sourced now. Is it a problem?
If the license is not LGPLv2+ compatible, then it can't be used by libvirt, regardless of whether it is directly linked, or dlopened. In other words using 'dlopen' doesn't magically solve the license compatibility problem. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

OK, I got it. Will think how to resolve this. On Wednesday, September 28, 2011 06:10:19 PM Daniel P. Berrange wrote:
On Wed, Sep 28, 2011 at 06:01:24PM +0400, Dmitry Mishin wrote:
On Wednesday, September 28, 2011 05:34:47 PM Daniel Veillard wrote: [...]
+int psbmApiInit(struct psbm_driver *driver) +{ + const char *libname = "libprl_sdk.so"; + void *handle = NULL; + PRL_RESULT res;
That I dislike, sorry this must not be dlopen'ed in at runtime,
but checked in at configure time and properly linked in. Also means that proper dependancies and packaging have to be in place.
I exactly want to avoid dependencies.
Library can be used both remotely (for example, on Fedora host) and locally (on PSBM host). And if in the local case we can create special libvirt rpm with enabled PSBM support and integrate it to distribution, in remote case we force user to download not only Parallels SDK rpm (which will hardly be included to Fedora due to proprietary license), but also fixed libvirt package instead of already installed one. Is it preferable way from your point of view?
+ handle = dlopen(libname, RTLD_LAZY); + if (!handle) { + psbmError(VIR_ERR_INTERNAL_ERROR, + _("Failed to load SDK library %s %s"), libname, dlerror()); + return VIR_ERR_INTERNAL_ERROR; + }
So what is that SDK library, how is it distributed and what is the
licencing for it ? As much as I like adding a driver, I would like to make sure the deployement is clean and there is no licencing issues.
Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/
and it's quite silent on code availability and Licence for the libraries.
It has a proprietary license and not open sourced now. Is it a problem?
If the license is not LGPLv2+ compatible, then it can't be used by libvirt, regardless of whether it is directly linked, or dlopened. In other words using 'dlopen' doesn't magically solve the license compatibility problem.
Daniel
-- Thanks, Dmitry.

On Wednesday, September 28, 2011 06:10:19 PM Daniel P. Berrange wrote:
Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/
and it's quite silent on code availability and Licence for the libraries.
It has a proprietary license and not open sourced now. Is it a problem?
If the license is not LGPLv2+ compatible, then it can't be used by libvirt, regardless of whether it is directly linked, or dlopened. In other words using 'dlopen' doesn't magically solve the license compatibility problem. Will we solve the issue if libvirt will be statically linked with SDK library (as Daniel requests) and SDK library itself will be distributed in binary form under BSD license conditions (which is LGPLv2 compatible)?
-- Thanks, Dmitry.

libvirt will be statically linked with SDK library Sorry, I meant dynamically but at compilation stage instead of dlopen()
On Friday, September 30, 2011 12:21:05 PM Dmitry Mishin wrote:
On Wednesday, September 28, 2011 06:10:19 PM Daniel P. Berrange wrote:
Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/
and it's quite silent on code availability and Licence for the libraries.
It has a proprietary license and not open sourced now. Is it a problem?
If the license is not LGPLv2+ compatible, then it can't be used by libvirt, regardless of whether it is directly linked, or dlopened. In other words using 'dlopen' doesn't magically solve the license compatibility problem.
Will we solve the issue if libvirt will be statically linked with SDK library (as Daniel requests) and SDK library itself will be distributed in binary form under BSD license conditions (which is LGPLv2 compatible)?
-- Thanks, Dmitry.

On Fri, Sep 30, 2011 at 12:21:05PM +0400, Dmitry Mishin wrote:
On Wednesday, September 28, 2011 06:10:19 PM Daniel P. Berrange wrote:
Any pointers ? All I found was http://www.parallels.com/ptn/download/sdk/
and it's quite silent on code availability and Licence for the libraries.
It has a proprietary license and not open sourced now. Is it a problem?
If the license is not LGPLv2+ compatible, then it can't be used by libvirt, regardless of whether it is directly linked, or dlopened. In other words using 'dlopen' doesn't magically solve the license compatibility problem. Will we solve the issue if libvirt will be statically linked with SDK library (as Daniel requests) and SDK library itself will be distributed in binary form under BSD license conditions (which is LGPLv2 compatible)?
Yes, linking to a BSD licensed library is fine from a licensing point of view. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (4)
-
Daniel P. Berrange
-
Daniel Veillard
-
Dmitry Mishin
-
Eric Blake