mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
xenapi: remove driver
The xenapi driver has not seen any development since its initial contribution 9 years ago. There have been no bug reports, no patches, and no queries about the driver on the developer or user mailing lists. Remove the driver from the libvirt sources. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
357ce1e30c
commit
2171442d62
4
cfg.mk
4
cfg.mk
@ -611,7 +611,6 @@ msg_gen_function += virRaiseError
|
|||||||
msg_gen_function += virReportError
|
msg_gen_function += virReportError
|
||||||
msg_gen_function += virReportErrorHelper
|
msg_gen_function += virReportErrorHelper
|
||||||
msg_gen_function += virReportSystemError
|
msg_gen_function += virReportSystemError
|
||||||
msg_gen_function += xenapiSessionErrorHandler
|
|
||||||
msg_gen_function += virLastErrorPrefixMessage
|
msg_gen_function += virLastErrorPrefixMessage
|
||||||
|
|
||||||
# Uncomment the following and run "make syntax-check" to see diagnostics
|
# Uncomment the following and run "make syntax-check" to see diagnostics
|
||||||
@ -668,7 +667,7 @@ sc_prohibit_diagnostic_without_format:
|
|||||||
$(VC_LIST_EXCEPT) | xargs \
|
$(VC_LIST_EXCEPT) | xargs \
|
||||||
$(GREP) -A2 -nE '\<$(func_re) *\(.*,$$' /dev/null; } \
|
$(GREP) -A2 -nE '\<$(func_re) *\(.*,$$' /dev/null; } \
|
||||||
| $(SED) -rn -e ':l; /[,"]$$/ {N;b l;}' \
|
| $(SED) -rn -e ':l; /[,"]$$/ {N;b l;}' \
|
||||||
-e '/(xenapiSessionErrorHandler|vah_(error|warning))/d' \
|
-e '/(vah_(error|warning))/d' \
|
||||||
-e '/\<$(func_re) *\([^"]*"([^%"]|"\n[^"]*")*"[,)]/p' \
|
-e '/\<$(func_re) *\([^"]*"([^%"]|"\n[^"]*")*"[,)]/p' \
|
||||||
| $(GREP) -vE 'VIR_ERROR' && \
|
| $(GREP) -vE 'VIR_ERROR' && \
|
||||||
{ echo '$(ME): found diagnostic without %' 1>&2; \
|
{ echo '$(ME): found diagnostic without %' 1>&2; \
|
||||||
@ -791,7 +790,6 @@ sc_prohibit_cross_inclusion:
|
|||||||
access/ | conf/) safe="($$dir|conf|util)";; \
|
access/ | conf/) safe="($$dir|conf|util)";; \
|
||||||
cpu/| network/| node_device/| rpc/| security/| storage/) \
|
cpu/| network/| node_device/| rpc/| security/| storage/) \
|
||||||
safe="($$dir|util|conf|storage)";; \
|
safe="($$dir|util|conf|storage)";; \
|
||||||
xenapi/) safe="($$dir|util|conf|xen|cpu)";; \
|
|
||||||
*) safe="($$dir|$(mid_dirs)|util)";; \
|
*) safe="($$dir|$(mid_dirs)|util)";; \
|
||||||
esac; \
|
esac; \
|
||||||
in_vc_files="^src/$$dir" \
|
in_vc_files="^src/$$dir" \
|
||||||
|
@ -456,7 +456,6 @@ LIBVIRT_DRIVER_ARG_QEMU
|
|||||||
LIBVIRT_DRIVER_ARG_OPENVZ
|
LIBVIRT_DRIVER_ARG_OPENVZ
|
||||||
LIBVIRT_DRIVER_ARG_VMWARE
|
LIBVIRT_DRIVER_ARG_VMWARE
|
||||||
LIBVIRT_DRIVER_ARG_PHYP
|
LIBVIRT_DRIVER_ARG_PHYP
|
||||||
LIBVIRT_DRIVER_ARG_XENAPI
|
|
||||||
LIBVIRT_DRIVER_ARG_LIBXL
|
LIBVIRT_DRIVER_ARG_LIBXL
|
||||||
LIBVIRT_DRIVER_ARG_VBOX
|
LIBVIRT_DRIVER_ARG_VBOX
|
||||||
LIBVIRT_DRIVER_ARG_LXC
|
LIBVIRT_DRIVER_ARG_LXC
|
||||||
@ -474,7 +473,6 @@ LIBVIRT_DRIVER_CHECK_QEMU
|
|||||||
LIBVIRT_DRIVER_CHECK_OPENVZ
|
LIBVIRT_DRIVER_CHECK_OPENVZ
|
||||||
LIBVIRT_DRIVER_CHECK_VMWARE
|
LIBVIRT_DRIVER_CHECK_VMWARE
|
||||||
LIBVIRT_DRIVER_CHECK_PHYP
|
LIBVIRT_DRIVER_CHECK_PHYP
|
||||||
LIBVIRT_DRIVER_CHECK_XENAPI
|
|
||||||
LIBVIRT_DRIVER_CHECK_LIBXL
|
LIBVIRT_DRIVER_CHECK_LIBXL
|
||||||
LIBVIRT_DRIVER_CHECK_VBOX
|
LIBVIRT_DRIVER_CHECK_VBOX
|
||||||
LIBVIRT_DRIVER_CHECK_LXC
|
LIBVIRT_DRIVER_CHECK_LXC
|
||||||
@ -960,7 +958,6 @@ LIBVIRT_DRIVER_RESULT_QEMU
|
|||||||
LIBVIRT_DRIVER_RESULT_OPENVZ
|
LIBVIRT_DRIVER_RESULT_OPENVZ
|
||||||
LIBVIRT_DRIVER_RESULT_VMWARE
|
LIBVIRT_DRIVER_RESULT_VMWARE
|
||||||
LIBVIRT_DRIVER_RESULT_VBOX
|
LIBVIRT_DRIVER_RESULT_VBOX
|
||||||
LIBVIRT_DRIVER_RESULT_XENAPI
|
|
||||||
LIBVIRT_DRIVER_RESULT_LIBXL
|
LIBVIRT_DRIVER_RESULT_LIBXL
|
||||||
LIBVIRT_DRIVER_RESULT_LXC
|
LIBVIRT_DRIVER_RESULT_LXC
|
||||||
LIBVIRT_DRIVER_RESULT_PHYP
|
LIBVIRT_DRIVER_RESULT_PHYP
|
||||||
@ -1041,7 +1038,6 @@ LIBVIRT_RESULT_SSH2
|
|||||||
LIBVIRT_RESULT_UDEV
|
LIBVIRT_RESULT_UDEV
|
||||||
LIBVIRT_RESULT_VIRTUALPORT
|
LIBVIRT_RESULT_VIRTUALPORT
|
||||||
LIBVIRT_RESULT_XDR
|
LIBVIRT_RESULT_XDR
|
||||||
LIBVIRT_RESULT_XENAPI
|
|
||||||
LIBVIRT_RESULT_YAJL
|
LIBVIRT_RESULT_YAJL
|
||||||
AC_MSG_NOTICE([])
|
AC_MSG_NOTICE([])
|
||||||
AC_MSG_NOTICE([Windows])
|
AC_MSG_NOTICE([Windows])
|
||||||
|
@ -393,10 +393,6 @@
|
|||||||
<td>vz</td>
|
<td>vz</td>
|
||||||
<td>vz</td>
|
<td>vz</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>xenapi</td>
|
|
||||||
<td>XenAPI</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -132,8 +132,6 @@ credentials=defgrp</pre>
|
|||||||
over SSH</li>
|
over SSH</li>
|
||||||
<li><code>esx</code> - used for connections to an ESX or
|
<li><code>esx</code> - used for connections to an ESX or
|
||||||
VirtualCenter server</li>
|
VirtualCenter server</li>
|
||||||
<li><code>xen</code> - used for connections to a Xen Enterprise
|
|
||||||
sever using XenAPI</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -118,14 +118,13 @@
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
# RHEL doesn't ship OpenVZ, VBox, PowerHypervisor,
|
# RHEL doesn't ship OpenVZ, VBox, PowerHypervisor,
|
||||||
# VMware, libxenserver (xenapi), libxenlight (Xen 4.1 and newer),
|
# VMware, libxenlight (Xen 4.1 and newer),
|
||||||
# or HyperV.
|
# or HyperV.
|
||||||
%if 0%{?rhel}
|
%if 0%{?rhel}
|
||||||
%define with_openvz 0
|
%define with_openvz 0
|
||||||
%define with_vbox 0
|
%define with_vbox 0
|
||||||
%define with_phyp 0
|
%define with_phyp 0
|
||||||
%define with_vmware 0
|
%define with_vmware 0
|
||||||
%define with_xenapi 0
|
|
||||||
%define with_libxl 0
|
%define with_libxl 0
|
||||||
%define with_hyperv 0
|
%define with_hyperv 0
|
||||||
%define with_vz 0
|
%define with_vz 0
|
||||||
@ -1169,7 +1168,6 @@ rm -f po/stamp-po
|
|||||||
%{?arg_esx} \
|
%{?arg_esx} \
|
||||||
%{?arg_hyperv} \
|
%{?arg_hyperv} \
|
||||||
%{?arg_vmware} \
|
%{?arg_vmware} \
|
||||||
--without-xenapi \
|
|
||||||
--without-vz \
|
--without-vz \
|
||||||
--without-bhyve \
|
--without-bhyve \
|
||||||
--with-remote-default-mode=legacy \
|
--with-remote-default-mode=legacy \
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
dnl The XenAPI driver
|
|
||||||
dnl
|
|
||||||
dnl Copyright (C) 2016 Red Hat, Inc.
|
|
||||||
dnl
|
|
||||||
dnl This library is free software; you can redistribute it and/or
|
|
||||||
dnl modify it under the terms of the GNU Lesser General Public
|
|
||||||
dnl License as published by the Free Software Foundation; either
|
|
||||||
dnl version 2.1 of the License, or (at your option) any later version.
|
|
||||||
dnl
|
|
||||||
dnl This library is distributed in the hope that it will be useful,
|
|
||||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
dnl Lesser General Public License for more details.
|
|
||||||
dnl
|
|
||||||
dnl You should have received a copy of the GNU Lesser General Public
|
|
||||||
dnl License along with this library. If not, see
|
|
||||||
dnl <http://www.gnu.org/licenses/>.
|
|
||||||
dnl
|
|
||||||
|
|
||||||
AC_DEFUN([LIBVIRT_DRIVER_ARG_XENAPI], [
|
|
||||||
LIBVIRT_ARG_WITH_FEATURE([XENAPI], [XenAPI], [check])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_DEFUN([LIBVIRT_DRIVER_CHECK_XENAPI], [
|
|
||||||
AC_REQUIRE([LIBVIRT_CHECK_CURL])
|
|
||||||
|
|
||||||
old_with_xenapi="$with_xenapi"
|
|
||||||
|
|
||||||
dnl search for the XenServer library
|
|
||||||
LIBVIRT_CHECK_LIB([XENAPI], [xenserver], [xen_vm_start], [xen/api/xen_vm.h])
|
|
||||||
|
|
||||||
if test "x$with_xenapi" = "xyes" ; then
|
|
||||||
if test "x$with_curl" = "xno"; then
|
|
||||||
if test "$old_with_xenapi" != "check"; then
|
|
||||||
AC_MSG_ERROR([You must install libcurl to compile the XenAPI driver])
|
|
||||||
fi
|
|
||||||
with_xenapi=no
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_DEFUN([LIBVIRT_DRIVER_RESULT_XENAPI], [
|
|
||||||
LIBVIRT_RESULT([XenAPI], [$with_xenapi])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_DEFUN([LIBVIRT_RESULT_XENAPI], [
|
|
||||||
LIBVIRT_RESULT_LIB([XENAPI])
|
|
||||||
])
|
|
@ -292,8 +292,6 @@ src/vz/vz_driver.c
|
|||||||
src/vz/vz_sdk.c
|
src/vz/vz_sdk.c
|
||||||
src/vz/vz_utils.c
|
src/vz/vz_utils.c
|
||||||
src/vz/vz_utils.h
|
src/vz/vz_utils.h
|
||||||
src/xenapi/xenapi_driver.c
|
|
||||||
src/xenapi/xenapi_utils.c
|
|
||||||
tests/virpolkittest.c
|
tests/virpolkittest.c
|
||||||
tools/libvirt-guests.sh.in
|
tools/libvirt-guests.sh.in
|
||||||
tools/virsh-checkpoint.c
|
tools/virsh-checkpoint.c
|
||||||
|
@ -119,7 +119,6 @@ include openvz/Makefile.inc.am
|
|||||||
include qemu/Makefile.inc.am
|
include qemu/Makefile.inc.am
|
||||||
include bhyve/Makefile.inc.am
|
include bhyve/Makefile.inc.am
|
||||||
include libxl/Makefile.inc.am
|
include libxl/Makefile.inc.am
|
||||||
include xenapi/Makefile.inc.am
|
|
||||||
include vz/Makefile.inc.am
|
include vz/Makefile.inc.am
|
||||||
include lxc/Makefile.inc.am
|
include lxc/Makefile.inc.am
|
||||||
include interface/Makefile.inc.am
|
include interface/Makefile.inc.am
|
||||||
|
@ -37,7 +37,6 @@ Then there are the hypervisor implementations:
|
|||||||
* vbox/ - Virtual Box using native API
|
* vbox/ - Virtual Box using native API
|
||||||
* vmware/ - VMware Workstation and Player using the vmrun tool
|
* vmware/ - VMware Workstation and Player using the vmrun tool
|
||||||
* xen/ - Xen using hypercalls, XenD SEXPR & XenStore
|
* xen/ - Xen using hypercalls, XenD SEXPR & XenStore
|
||||||
* xenapi/ - Xen using libxenserver
|
|
||||||
|
|
||||||
|
|
||||||
Finally some secondary drivers that are shared for several HVs.
|
Finally some secondary drivers that are shared for several HVs.
|
||||||
|
@ -81,9 +81,6 @@
|
|||||||
#ifdef WITH_HYPERV
|
#ifdef WITH_HYPERV
|
||||||
# include "hyperv/hyperv_driver.h"
|
# include "hyperv/hyperv_driver.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_XENAPI
|
|
||||||
# include "xenapi/xenapi_driver.h"
|
|
||||||
#endif
|
|
||||||
#ifdef WITH_BHYVE
|
#ifdef WITH_BHYVE
|
||||||
# include "bhyve/bhyve_driver.h"
|
# include "bhyve/bhyve_driver.h"
|
||||||
#endif
|
#endif
|
||||||
@ -307,10 +304,6 @@ virGlobalInit(void)
|
|||||||
if (hypervRegister() == -1)
|
if (hypervRegister() == -1)
|
||||||
goto error;
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_XENAPI
|
|
||||||
if (xenapiRegister() == -1)
|
|
||||||
goto error;
|
|
||||||
#endif
|
|
||||||
#ifdef WITH_REMOTE
|
#ifdef WITH_REMOTE
|
||||||
if (remoteRegister() == -1)
|
if (remoteRegister() == -1)
|
||||||
goto error;
|
goto error;
|
||||||
@ -989,9 +982,6 @@ virConnectOpenInternal(const char *name,
|
|||||||
#ifndef WITH_HYPERV
|
#ifndef WITH_HYPERV
|
||||||
STRCASEEQ(ret->uri->scheme, "hyperv") ||
|
STRCASEEQ(ret->uri->scheme, "hyperv") ||
|
||||||
#endif
|
#endif
|
||||||
#ifndef WITH_XENAPI
|
|
||||||
STRCASEEQ(ret->uri->scheme, "xenapi") ||
|
|
||||||
#endif
|
|
||||||
#ifndef WITH_VZ
|
#ifndef WITH_VZ
|
||||||
STRCASEEQ(ret->uri->scheme, "parallels") ||
|
STRCASEEQ(ret->uri->scheme, "parallels") ||
|
||||||
#endif
|
#endif
|
||||||
|
@ -183,8 +183,7 @@ virRandomGenerateWWN(char **wwn,
|
|||||||
if (STREQ(virt_type, "QEMU")) {
|
if (STREQ(virt_type, "QEMU")) {
|
||||||
oui = QUMRANET_OUI;
|
oui = QUMRANET_OUI;
|
||||||
} else if (STREQ(virt_type, "Xen") ||
|
} else if (STREQ(virt_type, "Xen") ||
|
||||||
STREQ(virt_type, "xenlight") ||
|
STREQ(virt_type, "xenlight")) {
|
||||||
STREQ(virt_type, "XenAPI")) {
|
|
||||||
oui = XEN_OUI;
|
oui = XEN_OUI;
|
||||||
} else if (STREQ(virt_type, "ESX") ||
|
} else if (STREQ(virt_type, "ESX") ||
|
||||||
STREQ(virt_type, "VMWARE")) {
|
STREQ(virt_type, "VMWARE")) {
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
# vim: filetype=automake
|
|
||||||
|
|
||||||
XENAPI_DRIVER_SOURCES = \
|
|
||||||
xenapi/xenapi_driver.c \
|
|
||||||
xenapi/xenapi_driver.h \
|
|
||||||
xenapi/xenapi_driver_private.h \
|
|
||||||
xenapi/xenapi_utils.c \
|
|
||||||
xenapi/xenapi_utils.h \
|
|
||||||
$(NULL)
|
|
||||||
|
|
||||||
DRIVER_SOURCE_FILES += $(XENAPI_DRIVER_SOURCES)
|
|
||||||
EXTRA_DIST += $(XENAPI_DRIVER_SOURCES)
|
|
||||||
|
|
||||||
if WITH_XENAPI
|
|
||||||
noinst_LTLIBRARIES += libvirt_driver_xenapi.la
|
|
||||||
libvirt_la_BUILT_LIBADD += libvirt_driver_xenapi.la
|
|
||||||
libvirt_driver_xenapi_la_CFLAGS = \
|
|
||||||
$(XENAPI_CFLAGS) \
|
|
||||||
$(CURL_CFLAGS) \
|
|
||||||
-I$(srcdir)/conf \
|
|
||||||
$(AM_CFLAGS) \
|
|
||||||
$(NULL)
|
|
||||||
libvirt_driver_xenapi_la_LDFLAGS = $(AM_LDFLAGS)
|
|
||||||
libvirt_driver_xenapi_la_LIBADD = \
|
|
||||||
$(XENAPI_LIBS) \
|
|
||||||
$(CURL_LIBS) \
|
|
||||||
$(NULL)
|
|
||||||
libvirt_driver_xenapi_la_SOURCES = $(XENAPI_DRIVER_SOURCES)
|
|
||||||
endif WITH_XENAPI
|
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* xenapi_driver.h: Xen API driver header file to be included in libvirt.c.
|
|
||||||
* Copyright (C) 2009, 2010 Citrix Ltd.
|
|
||||||
*
|
|
||||||
* 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, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
int xenapiRegister(void);
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* xenapi_driver_private.h: Xen API driver's private header file.
|
|
||||||
* Copyright (C) 2009, 2010 Citrix Ltd.
|
|
||||||
*
|
|
||||||
* 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, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <libxml/tree.h>
|
|
||||||
#include <xen/api/xen_common.h>
|
|
||||||
#include "virerror.h"
|
|
||||||
|
|
||||||
/*# define PRINT_XML*/
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_XENAPI
|
|
||||||
#define LIBVIRT_MODELNAME_LEN (32)
|
|
||||||
#define xenapiSessionErrorHandler(conn, errNum, buf) \
|
|
||||||
xenapiSessionErrorHandle(conn, errNum, buf, \
|
|
||||||
__FILE__, __FUNCTION__, __LINE__)
|
|
||||||
|
|
||||||
void
|
|
||||||
xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
|
|
||||||
const char *buf, const char *filename,
|
|
||||||
const char *func, size_t lineno);
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
xen_result_func func;
|
|
||||||
void *handle;
|
|
||||||
} xen_comms;
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
call_func(const void *data, size_t len, void *user_handle,
|
|
||||||
void *result_handle, xen_result_func result_func);
|
|
||||||
size_t
|
|
||||||
write_func(void *ptr, size_t size, size_t nmemb, void *comms);
|
|
||||||
|
|
||||||
/* xenAPI driver's private data structure */
|
|
||||||
struct _xenapiPrivate {
|
|
||||||
xen_session *session;
|
|
||||||
char *url;
|
|
||||||
int noVerify;
|
|
||||||
virCapsPtr caps;
|
|
||||||
virDomainXMLOptionPtr xmlopt;
|
|
||||||
};
|
|
@ -1,562 +0,0 @@
|
|||||||
/*
|
|
||||||
* xenapi_utils.c: Xen API driver -- utils parts.
|
|
||||||
* Copyright (C) 2011-2014 Red Hat, Inc.
|
|
||||||
* Copyright (C) 2009, 2010 Citrix Ltd.
|
|
||||||
*
|
|
||||||
* 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, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include <xen/api/xen_all.h>
|
|
||||||
#include "internal.h"
|
|
||||||
#include "domain_conf.h"
|
|
||||||
#include "virerror.h"
|
|
||||||
#include "datatypes.h"
|
|
||||||
#include "viruuid.h"
|
|
||||||
#include "viralloc.h"
|
|
||||||
#include "virbuffer.h"
|
|
||||||
#include "virlog.h"
|
|
||||||
#include "viruri.h"
|
|
||||||
#include "xenapi_driver_private.h"
|
|
||||||
#include "xenapi_utils.h"
|
|
||||||
#include "virstring.h"
|
|
||||||
|
|
||||||
VIR_LOG_INIT("xenapi.xenapi_utils");
|
|
||||||
|
|
||||||
void
|
|
||||||
xenSessionFree(xen_session *session)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
char *tmp;
|
|
||||||
if (session->error_description != NULL) {
|
|
||||||
for (i = 0; i < session->error_description_count; i++)
|
|
||||||
VIR_FREE(session->error_description[i]);
|
|
||||||
VIR_FREE(session->error_description);
|
|
||||||
}
|
|
||||||
/* The session_id member is type of 'const char *'. Sigh. */
|
|
||||||
tmp = (char *)session->session_id;
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
VIR_FREE(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
|
||||||
xenapiUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
|
|
||||||
const char *hostname)
|
|
||||||
{
|
|
||||||
unsigned int ncred;
|
|
||||||
virConnectCredential cred;
|
|
||||||
char *prompt;
|
|
||||||
|
|
||||||
memset(&cred, 0, sizeof(virConnectCredential));
|
|
||||||
|
|
||||||
if (virAsprintf(&prompt, "Enter %s password for %s", username,
|
|
||||||
hostname) < 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ncred = 0; ncred < auth->ncredtype; ncred++) {
|
|
||||||
if (auth->credtype[ncred] != VIR_CRED_PASSPHRASE &&
|
|
||||||
auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
cred.type = auth->credtype[ncred];
|
|
||||||
cred.prompt = prompt;
|
|
||||||
cred.challenge = hostname;
|
|
||||||
cred.defresult = NULL;
|
|
||||||
cred.result = NULL;
|
|
||||||
cred.resultlen = 0;
|
|
||||||
|
|
||||||
if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
|
|
||||||
VIR_FREE(cred.result);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(prompt);
|
|
||||||
|
|
||||||
return cred.result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
xenapiUtil_ParseQuery(virConnectPtr conn, virURIPtr uri, int *noVerify)
|
|
||||||
{
|
|
||||||
int result = 0;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < uri->paramsCount; i++) {
|
|
||||||
virURIParamPtr queryParam = &uri->params[i];
|
|
||||||
if (STRCASEEQ(queryParam->name, "no_verify")) {
|
|
||||||
if (noVerify == NULL)
|
|
||||||
continue;
|
|
||||||
if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 ||
|
|
||||||
(*noVerify != 0 && *noVerify != 1)) {
|
|
||||||
xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG,
|
|
||||||
_("Query parameter 'no_verify' has unexpected value (should be 0 or 1)"));
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
failure:
|
|
||||||
result = -1;
|
|
||||||
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum xen_on_normal_exit
|
|
||||||
actionShutdownLibvirt2XenapiEnum(virDomainLifecycleAction action)
|
|
||||||
{
|
|
||||||
enum xen_on_normal_exit num = XEN_ON_NORMAL_EXIT_RESTART;
|
|
||||||
if (action == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY)
|
|
||||||
num = XEN_ON_NORMAL_EXIT_DESTROY;
|
|
||||||
else if (action == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART)
|
|
||||||
num = XEN_ON_NORMAL_EXIT_RESTART;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
enum xen_on_crash_behaviour
|
|
||||||
actionCrashLibvirt2XenapiEnum(virDomainLifecycleAction action)
|
|
||||||
{
|
|
||||||
enum xen_on_crash_behaviour num = XEN_ON_CRASH_BEHAVIOUR_RESTART;
|
|
||||||
if (action == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY)
|
|
||||||
num = XEN_ON_CRASH_BEHAVIOUR_DESTROY;
|
|
||||||
else if (action == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART)
|
|
||||||
num = XEN_ON_CRASH_BEHAVIOUR_RESTART;
|
|
||||||
else if (action == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE)
|
|
||||||
num = XEN_ON_CRASH_BEHAVIOUR_PRESERVE;
|
|
||||||
else if (action == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME)
|
|
||||||
num = XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART;
|
|
||||||
else if (action == VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY)
|
|
||||||
num = XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_DESTROY;
|
|
||||||
else if (action == VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART)
|
|
||||||
num = XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_RESTART;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* generate XenAPI boot order format from libvirt format */
|
|
||||||
char *
|
|
||||||
createXenAPIBootOrderString(int nboot, int *bootDevs)
|
|
||||||
{
|
|
||||||
virBuffer ret = VIR_BUFFER_INITIALIZER;
|
|
||||||
char *val = NULL;
|
|
||||||
size_t i;
|
|
||||||
for (i = 0; i < nboot; i++) {
|
|
||||||
if (bootDevs[i] == VIR_DOMAIN_BOOT_FLOPPY)
|
|
||||||
val = (char *)"a";
|
|
||||||
else if (bootDevs[i] == VIR_DOMAIN_BOOT_DISK)
|
|
||||||
val = (char *)"c";
|
|
||||||
else if (bootDevs[i] == VIR_DOMAIN_BOOT_CDROM)
|
|
||||||
val = (char *)"d";
|
|
||||||
else if (bootDevs[i] == VIR_DOMAIN_BOOT_NET)
|
|
||||||
val = (char *)"n";
|
|
||||||
if (val)
|
|
||||||
virBufferEscapeString(&ret, "%s", val);
|
|
||||||
}
|
|
||||||
return virBufferContentAndReset(&ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* convert boot order string to libvirt boot order enum */
|
|
||||||
virDomainBootOrder
|
|
||||||
map2LibvirtBootOrder(char c)
|
|
||||||
{
|
|
||||||
switch (c) {
|
|
||||||
case 'a':
|
|
||||||
return VIR_DOMAIN_BOOT_FLOPPY;
|
|
||||||
case 'c':
|
|
||||||
return VIR_DOMAIN_BOOT_DISK;
|
|
||||||
case 'd':
|
|
||||||
return VIR_DOMAIN_BOOT_CDROM;
|
|
||||||
case 'n':
|
|
||||||
return VIR_DOMAIN_BOOT_NET;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virDomainLifecycleAction
|
|
||||||
xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action)
|
|
||||||
{
|
|
||||||
virDomainLifecycleAction num = VIR_DOMAIN_LIFECYCLE_ACTION_RESTART;
|
|
||||||
if (action == XEN_ON_NORMAL_EXIT_DESTROY)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY;
|
|
||||||
else if (action == XEN_ON_NORMAL_EXIT_RESTART)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_RESTART;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virDomainLifecycleAction
|
|
||||||
xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action)
|
|
||||||
{
|
|
||||||
virDomainLifecycleAction num = VIR_DOMAIN_LIFECYCLE_ACTION_RESTART;
|
|
||||||
if (action == XEN_ON_CRASH_BEHAVIOUR_DESTROY)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY;
|
|
||||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_RESTART)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_RESTART;
|
|
||||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_PRESERVE)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE;
|
|
||||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME;
|
|
||||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_DESTROY)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY;
|
|
||||||
else if (action == XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_RESTART)
|
|
||||||
num = VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* returns 'file' or 'block' for the storage type */
|
|
||||||
int
|
|
||||||
getStorageVolumeType(char *type)
|
|
||||||
{
|
|
||||||
if (STREQ(type, "lvmoiscsi") ||
|
|
||||||
STREQ(type, "lvmohba") ||
|
|
||||||
STREQ(type, "lvm") ||
|
|
||||||
STREQ(type, "file") ||
|
|
||||||
STREQ(type, "iso") ||
|
|
||||||
STREQ(type, "ext") ||
|
|
||||||
STREQ(type, "nfs"))
|
|
||||||
return (int)VIR_STORAGE_VOL_FILE;
|
|
||||||
else if (STREQ(type, "iscsi") ||
|
|
||||||
STREQ(type, "equal") ||
|
|
||||||
STREQ(type, "hba") ||
|
|
||||||
STREQ(type, "cslg") ||
|
|
||||||
STREQ(type, "udev") ||
|
|
||||||
STREQ(type, "netapp"))
|
|
||||||
return (int)VIR_STORAGE_VOL_BLOCK;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* returns error description if any received from the server */
|
|
||||||
char *
|
|
||||||
returnErrorFromSession(xen_session *session)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
||||||
for (i = 0; i < session->error_description_count; i++) {
|
|
||||||
if (!i)
|
|
||||||
virBufferEscapeString(&buf, "%s", session->error_description[i]);
|
|
||||||
else
|
|
||||||
virBufferEscapeString(&buf, " : %s", session->error_description[i]);
|
|
||||||
}
|
|
||||||
if (virBufferUse(&buf) < 1)
|
|
||||||
virBufferAdd(&buf, _("unknown error"), -1);
|
|
||||||
return virBufferContentAndReset(&buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* converts bitmap to string of the form '1,2...' */
|
|
||||||
char *
|
|
||||||
mapDomainPinVcpu(unsigned char *cpumap, int maplen)
|
|
||||||
{
|
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
||||||
size_t len;
|
|
||||||
char *ret = NULL;
|
|
||||||
size_t i, j;
|
|
||||||
for (i = 0; i < maplen; i++) {
|
|
||||||
for (j = 0; j < 8; j++) {
|
|
||||||
if (cpumap[i] & (1 << j))
|
|
||||||
virBufferAsprintf(&buf, "%zu,", (8*i)+j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (virBufferCheckError(&buf) < 0)
|
|
||||||
return NULL;
|
|
||||||
ret = virBufferContentAndReset(&buf);
|
|
||||||
len = strlen(ret);
|
|
||||||
if (len > 0 && ret[len - 1] == ',')
|
|
||||||
ret[len - 1] = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* obtains the CPU bitmap from the string passed */
|
|
||||||
void
|
|
||||||
getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen)
|
|
||||||
{
|
|
||||||
int pos;
|
|
||||||
int max_bits = maplen * 8;
|
|
||||||
char *num = NULL, *bp = NULL;
|
|
||||||
bzero(cpumap, maplen);
|
|
||||||
num = strtok_r(mask, ",", &bp);
|
|
||||||
while (num != NULL) {
|
|
||||||
if (virStrToLong_i(num, NULL, 10, &pos) < 0)
|
|
||||||
return;
|
|
||||||
if (pos < 0 || pos > max_bits - 1)
|
|
||||||
VIR_WARN("number in str %d exceeds cpumap's max bits %d", pos, max_bits);
|
|
||||||
else
|
|
||||||
(cpumap)[pos / 8] |= (1 << (pos % 8));
|
|
||||||
num = strtok_r(NULL, ",", &bp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* mapping XenServer power state to Libvirt power state */
|
|
||||||
virDomainState
|
|
||||||
mapPowerState(enum xen_vm_power_state state)
|
|
||||||
{
|
|
||||||
virDomainState virState;
|
|
||||||
switch (state) {
|
|
||||||
case XEN_VM_POWER_STATE_HALTED:
|
|
||||||
case XEN_VM_POWER_STATE_SUSPENDED:
|
|
||||||
virState = VIR_DOMAIN_SHUTOFF;
|
|
||||||
break;
|
|
||||||
case XEN_VM_POWER_STATE_PAUSED:
|
|
||||||
virState = VIR_DOMAIN_PAUSED;
|
|
||||||
break;
|
|
||||||
case XEN_VM_POWER_STATE_RUNNING:
|
|
||||||
virState = VIR_DOMAIN_RUNNING;
|
|
||||||
break;
|
|
||||||
case XEN_VM_POWER_STATE_UNDEFINED:
|
|
||||||
default:
|
|
||||||
/* Includes XEN_VM_POWER_STATE_UNKNOWN from libxenserver
|
|
||||||
* 5.5.0, which is gone in 5.6.0. */
|
|
||||||
virState = VIR_DOMAIN_NOSTATE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return virState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* allocate a flexible array and fill values(key,val) */
|
|
||||||
int
|
|
||||||
allocStringMap(xen_string_string_map **strings, char *key, char *val)
|
|
||||||
{
|
|
||||||
int sz = ((*strings) == NULL) ? 0 : (*strings)->size;
|
|
||||||
sz++;
|
|
||||||
if (VIR_REALLOC_N(*strings, sizeof(xen_string_string_map) +
|
|
||||||
sizeof(xen_string_string_map_contents) * sz) < 0)
|
|
||||||
return -1;
|
|
||||||
(*strings)->size = sz;
|
|
||||||
if (VIR_STRDUP((*strings)->contents[sz-1].key, key) < 0 ||
|
|
||||||
VIR_STRDUP((*strings)->contents[sz-1].val, val) < 0)
|
|
||||||
goto error;
|
|
||||||
return 0;
|
|
||||||
error:
|
|
||||||
xen_string_string_map_free(*strings);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Error handling function returns error messages from the server if any */
|
|
||||||
void
|
|
||||||
xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
|
|
||||||
const char *buf, const char *filename, const char *func,
|
|
||||||
size_t lineno)
|
|
||||||
{
|
|
||||||
struct _xenapiPrivate *priv = conn->privateData;
|
|
||||||
|
|
||||||
if (buf == NULL && priv != NULL && priv->session != NULL) {
|
|
||||||
char *ret = returnErrorFromSession(priv->session);
|
|
||||||
virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno,
|
|
||||||
"%s", ret);
|
|
||||||
xen_session_clear_error(priv->session);
|
|
||||||
VIR_FREE(ret);
|
|
||||||
} else {
|
|
||||||
virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno,
|
|
||||||
"%s", buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* creates network intereface for VM */
|
|
||||||
static int
|
|
||||||
createVifNetwork(virConnectPtr conn, xen_vm vm, int device,
|
|
||||||
char *bridge, char *mac)
|
|
||||||
{
|
|
||||||
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
|
|
||||||
xen_vm xvm = NULL;
|
|
||||||
char *uuid = NULL;
|
|
||||||
xen_vm_get_uuid(session, &uuid, vm);
|
|
||||||
if (uuid) {
|
|
||||||
if (!xen_vm_get_by_uuid(session, &xvm, uuid))
|
|
||||||
return -1;
|
|
||||||
VIR_FREE(uuid);
|
|
||||||
}
|
|
||||||
xen_vm_record_opt *vm_opt = xen_vm_record_opt_alloc();
|
|
||||||
vm_opt->is_record = 0;
|
|
||||||
vm_opt->u.handle = xvm;
|
|
||||||
xen_network_set *net_set = NULL;
|
|
||||||
xen_network_record *net_rec = NULL;
|
|
||||||
int cnt = 0;
|
|
||||||
if (!xen_network_get_all(session, &net_set)) {
|
|
||||||
xen_vm_record_opt_free(vm_opt);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
for (cnt = 0; cnt < net_set->size; cnt++) {
|
|
||||||
if (xen_network_get_record(session, &net_rec, net_set->contents[cnt])) {
|
|
||||||
if (STREQ(net_rec->bridge, bridge)) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
xen_network_record_free(net_rec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cnt < net_set->size && net_rec) {
|
|
||||||
xen_network network = NULL;
|
|
||||||
xen_network_get_by_uuid(session, &network, net_rec->uuid);
|
|
||||||
xen_network_record_opt *network_opt = xen_network_record_opt_alloc();
|
|
||||||
network_opt->is_record = 0;
|
|
||||||
network_opt->u.handle = network;
|
|
||||||
xen_vif_record *vif_record = xen_vif_record_alloc();
|
|
||||||
vif_record->mac = mac;
|
|
||||||
vif_record->vm = vm_opt;
|
|
||||||
vif_record->network = network_opt;
|
|
||||||
xen_vif vif = NULL;
|
|
||||||
|
|
||||||
vif_record->other_config = xen_string_string_map_alloc(0);
|
|
||||||
vif_record->runtime_properties = xen_string_string_map_alloc(0);
|
|
||||||
vif_record->qos_algorithm_params = xen_string_string_map_alloc(0);
|
|
||||||
if (virAsprintfQuiet(&vif_record->device, "%d", device) < 0) {
|
|
||||||
xen_vif_record_free(vif_record);
|
|
||||||
xen_network_record_free(net_rec);
|
|
||||||
xen_network_set_free(net_set);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
xen_vif_create(session, &vif, vif_record);
|
|
||||||
if (!vif) {
|
|
||||||
xen_vif_free(vif);
|
|
||||||
xen_vif_record_free(vif_record);
|
|
||||||
xen_network_record_free(net_rec);
|
|
||||||
xen_network_set_free(net_set);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
xen_vif_record_free(vif_record);
|
|
||||||
xen_network_record_free(net_rec);
|
|
||||||
}
|
|
||||||
xen_network_set_free(net_set);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a VM record from the XML description */
|
|
||||||
int
|
|
||||||
createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
|
|
||||||
xen_vm_record **record, xen_vm *vm)
|
|
||||||
{
|
|
||||||
char uuidStr[VIR_UUID_STRING_BUFLEN];
|
|
||||||
xen_string_string_map *strings = NULL;
|
|
||||||
int device_number = 0;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
*record = xen_vm_record_alloc();
|
|
||||||
if (VIR_STRDUP((*record)->name_label, def->name) < 0)
|
|
||||||
goto error;
|
|
||||||
virUUIDFormat(def->uuid, uuidStr);
|
|
||||||
if (VIR_STRDUP((*record)->uuid, uuidStr) < 0)
|
|
||||||
goto error;
|
|
||||||
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
|
||||||
char *boot_order = NULL;
|
|
||||||
if (VIR_STRDUP((*record)->hvm_boot_policy, "BIOS order") < 0)
|
|
||||||
goto error;
|
|
||||||
if (def->os.nBootDevs != 0)
|
|
||||||
boot_order = createXenAPIBootOrderString(def->os.nBootDevs, &def->os.bootDevs[0]);
|
|
||||||
if (boot_order != NULL) {
|
|
||||||
xen_string_string_map *hvm_boot_params = NULL;
|
|
||||||
allocStringMap(&hvm_boot_params, (char *)"order", boot_order);
|
|
||||||
(*record)->hvm_boot_params = hvm_boot_params;
|
|
||||||
VIR_FREE(boot_order);
|
|
||||||
}
|
|
||||||
} else if (def->os.type == VIR_DOMAIN_OSTYPE_XEN) {
|
|
||||||
if (VIR_STRDUP((*record)->pv_bootloader, "pygrub") < 0)
|
|
||||||
goto error;
|
|
||||||
if (def->os.kernel) {
|
|
||||||
if (VIR_STRDUP((*record)->pv_kernel, def->os.kernel) < 0)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (def->os.initrd) {
|
|
||||||
if (VIR_STRDUP((*record)->pv_ramdisk, def->os.initrd) < 0)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (def->os.cmdline) {
|
|
||||||
if (VIR_STRDUP((*record)->pv_args, def->os.cmdline) < 0)
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
(*record)->hvm_boot_params = xen_string_string_map_alloc(0);
|
|
||||||
}
|
|
||||||
if (def->os.bootloaderArgs)
|
|
||||||
if (VIR_STRDUP((*record)->pv_bootloader_args, def->os.bootloaderArgs) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (def->mem.cur_balloon)
|
|
||||||
(*record)->memory_static_max = (int64_t) (def->mem.cur_balloon * 1024);
|
|
||||||
if (virDomainDefGetMemoryTotal(def))
|
|
||||||
(*record)->memory_dynamic_max = (int64_t) (virDomainDefGetMemoryTotal(def) * 1024);
|
|
||||||
else
|
|
||||||
(*record)->memory_dynamic_max = (*record)->memory_static_max;
|
|
||||||
|
|
||||||
if (virDomainDefGetVcpusMax(def) > 0) {
|
|
||||||
(*record)->vcpus_max = (int64_t) virDomainDefGetVcpusMax(def);
|
|
||||||
(*record)->vcpus_at_startup = (int64_t) virDomainDefGetVcpus(def);
|
|
||||||
}
|
|
||||||
if (def->onPoweroff)
|
|
||||||
(*record)->actions_after_shutdown = actionShutdownLibvirt2XenapiEnum(def->onPoweroff);
|
|
||||||
if (def->onReboot)
|
|
||||||
(*record)->actions_after_reboot = actionShutdownLibvirt2XenapiEnum(def->onReboot);
|
|
||||||
if (def->onCrash)
|
|
||||||
(*record)->actions_after_crash = actionCrashLibvirt2XenapiEnum(def->onCrash);
|
|
||||||
|
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON)
|
|
||||||
allocStringMap(&strings, (char *)"acpi", (char *)"true");
|
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON)
|
|
||||||
allocStringMap(&strings, (char *)"apic", (char *)"true");
|
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_TRISTATE_SWITCH_ON)
|
|
||||||
allocStringMap(&strings, (char *)"pae", (char *)"true");
|
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_HAP] == VIR_TRISTATE_SWITCH_ON)
|
|
||||||
allocStringMap(&strings, (char *)"hap", (char *)"true");
|
|
||||||
if (def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] == VIR_TRISTATE_SWITCH_ON)
|
|
||||||
allocStringMap(&strings, (char *)"viridian", (char *)"true");
|
|
||||||
if (strings != NULL)
|
|
||||||
(*record)->platform = strings;
|
|
||||||
|
|
||||||
(*record)->vcpus_params = xen_string_string_map_alloc(0);
|
|
||||||
(*record)->other_config = xen_string_string_map_alloc(0);
|
|
||||||
(*record)->last_boot_cpu_flags = xen_string_string_map_alloc(0);
|
|
||||||
(*record)->xenstore_data = xen_string_string_map_alloc(0);
|
|
||||||
(*record)->hvm_shadow_multiplier = 1.000;
|
|
||||||
if (!xen_vm_create(((struct _xenapiPrivate *)(conn->privateData))->session,
|
|
||||||
vm, *record)) {
|
|
||||||
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < def->nnets; i++) {
|
|
||||||
if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE &&
|
|
||||||
def->nets[i]->data.bridge.brname) {
|
|
||||||
char *mac;
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(mac, VIR_MAC_STRING_BUFLEN) < 0)
|
|
||||||
goto error;
|
|
||||||
virMacAddrFormat(&def->nets[i]->mac, mac);
|
|
||||||
|
|
||||||
if (createVifNetwork(conn, *vm, device_number,
|
|
||||||
def->nets[i]->data.bridge.brname,
|
|
||||||
mac) < 0) {
|
|
||||||
VIR_FREE(mac);
|
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
device_number++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
xen_vm_record_free(*record);
|
|
||||||
return -1;
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* xenapi_utils.h: Xen API driver -- utils header
|
|
||||||
* Copyright (C) 2012, Red Hat, Inc.
|
|
||||||
* Copyright (C) 2009, 2010 Citrix Ltd.
|
|
||||||
*
|
|
||||||
* 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, see
|
|
||||||
* <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <xen/api/xen_all.h>
|
|
||||||
#include "internal.h"
|
|
||||||
#include "viruri.h"
|
|
||||||
#include "domain_conf.h"
|
|
||||||
|
|
||||||
#define NETWORK_DEVID_SIZE (12)
|
|
||||||
|
|
||||||
typedef uint64_t cpumap_t;
|
|
||||||
|
|
||||||
void
|
|
||||||
xenSessionFree(xen_session *session);
|
|
||||||
|
|
||||||
char *
|
|
||||||
xenapiUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
|
|
||||||
const char *hostname);
|
|
||||||
|
|
||||||
int
|
|
||||||
xenapiUtil_ParseQuery(virConnectPtr conn, virURIPtr uri, int *noVerify);
|
|
||||||
|
|
||||||
enum xen_on_normal_exit
|
|
||||||
actionShutdownLibvirt2XenapiEnum(virDomainLifecycleAction action);
|
|
||||||
|
|
||||||
enum xen_on_crash_behaviour
|
|
||||||
actionCrashLibvirt2XenapiEnum(virDomainLifecycleAction action);
|
|
||||||
|
|
||||||
char *
|
|
||||||
createXenAPIBootOrderString(int nboot, int *bootDevs);
|
|
||||||
|
|
||||||
virDomainBootOrder map2LibvirtBootOrder(char c);
|
|
||||||
|
|
||||||
virDomainLifecycleAction
|
|
||||||
xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action);
|
|
||||||
|
|
||||||
virDomainLifecycleAction
|
|
||||||
xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action);
|
|
||||||
|
|
||||||
void getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen);
|
|
||||||
|
|
||||||
int getStorageVolumeType(char *type);
|
|
||||||
|
|
||||||
char *returnErrorFromSession(xen_session *session);
|
|
||||||
|
|
||||||
virDomainState
|
|
||||||
mapPowerState(enum xen_vm_power_state state);
|
|
||||||
|
|
||||||
char *
|
|
||||||
mapDomainPinVcpu(unsigned char *cpumap, int maplen);
|
|
||||||
|
|
||||||
int
|
|
||||||
createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr defPtr,
|
|
||||||
xen_vm_record **record, xen_vm *vm);
|
|
||||||
|
|
||||||
int
|
|
||||||
allocStringMap (xen_string_string_map **strings, char *key, char *val);
|
|
@ -536,9 +536,6 @@ virshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
|
|||||||
#ifdef WITH_HYPERV
|
#ifdef WITH_HYPERV
|
||||||
vshPrint(ctl, " Hyper-V");
|
vshPrint(ctl, " Hyper-V");
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_XENAPI
|
|
||||||
vshPrint(ctl, " XenAPI");
|
|
||||||
#endif
|
|
||||||
#ifdef WITH_BHYVE
|
#ifdef WITH_BHYVE
|
||||||
vshPrint(ctl, " Bhyve");
|
vshPrint(ctl, " Bhyve");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user