2007-04-04 14:19:49 +00:00
|
|
|
/*
|
Move xen driver code into src/xen/ directory
* src/Makefile.am, src/proxy_internal.c, src/proxy_internal.h
src/sexpr.c, src/sexpr.h, src/xen_unified.c, src/xen_unified.h,
src/xen_internal.c, src/xen_internal.h, src/xen_inotify.c,
src/xen_inotify.h, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h, src/xs_internal.c,
src/xs_internal.h: Move to src/xen/ directory
* proxy/Makefile.am, proxy/libvirt_proxy.c, src/Makefile.am,
src/libvirt.c, tests/sexpr2xmltest.c, tests/statstest.c,
tests/xencapstest.c, tests/xmconfigtest.c, tests/xml2sexprtest.c:
Adapt to changed xen location
* src/stats_linux.h, src/stats_linux.c: Remove xen specific block
stats APIs
* src/qemu_driver.c, src/uml_driver.c: Add missing sys/un.h include
uncovered after change to stats_linux.h
* src/xen/block_stats.h, src/xen/block_stats.c: Add xen specific
block stats APIs
2009-09-15 15:38:33 +00:00
|
|
|
* xen_driver.c: Unified Xen driver.
|
2007-04-04 14:19:49 +00:00
|
|
|
*
|
2013-04-24 18:06:42 +00:00
|
|
|
* Copyright (C) 2007-2013 Red Hat, Inc.
|
2007-04-04 14:19:49 +00:00
|
|
|
*
|
2012-07-27 09:39:53 +00:00
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-27 09:39:53 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2007-04-04 14:19:49 +00:00
|
|
|
*
|
|
|
|
* Richard W.M. Jones <rjones@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2008-01-29 18:15:54 +00:00
|
|
|
#include <config.h>
|
Wed Dec 5 13:48:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* python/libvir.c, python/libvirt_wrap.h, qemud/qemud.c,
qemud/remote.c, src/internal.h, src/openvz_conf.c,
src/openvz_driver.c, src/proxy_internal.h, src/qemu_conf.c,
src/qemu_driver.c, src/remote_internal.h, src/test.h, src/util.c,
src/xen_unified.c, src/xen_unified.h, tests/nodeinfotest.c,
tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c, tests/reconnect.c,
tests/sexpr2xmltest.c, tests/virshtest.c, tests/xencapstest.c,
tests/xmconfigtest.c, tests/xml2sexprtest.c:
Change #include <> to #include "" for local includes.
Removed many includes from src/internal.h and put them in
the C files which actually use them.
Removed <ansidecl.h> - unused.
Added a comment around __func__.
Removed a clashing redefinition of VERSION symbol.
All limits (PATH_MAX etc) now done in src/internal.h, so we
don't need to include those headers in other files.
2007-12-05 13:56:22 +00:00
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
/* Note:
|
|
|
|
*
|
|
|
|
* This driver provides a unified interface to the five
|
2010-11-08 16:32:02 +00:00
|
|
|
* separate underlying Xen drivers (xen_internal,
|
2007-04-04 14:19:49 +00:00
|
|
|
* xend_internal, xs_internal and xm_internal). Historically
|
|
|
|
* the body of libvirt.c handled the five Xen drivers,
|
|
|
|
* and contained Xen-specific code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <unistd.h>
|
2007-06-15 15:24:20 +00:00
|
|
|
#include <string.h>
|
2007-06-26 11:42:46 +00:00
|
|
|
#include <errno.h>
|
2007-04-04 14:19:49 +00:00
|
|
|
#include <sys/types.h>
|
2010-10-22 13:40:26 +00:00
|
|
|
#include <fcntl.h>
|
2007-04-04 14:19:49 +00:00
|
|
|
#include <xen/dom0_ops.h>
|
|
|
|
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2008-11-04 23:22:06 +00:00
|
|
|
#include "datatypes.h"
|
Move xen driver code into src/xen/ directory
* src/Makefile.am, src/proxy_internal.c, src/proxy_internal.h
src/sexpr.c, src/sexpr.h, src/xen_unified.c, src/xen_unified.h,
src/xen_internal.c, src/xen_internal.h, src/xen_inotify.c,
src/xen_inotify.h, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h, src/xs_internal.c,
src/xs_internal.h: Move to src/xen/ directory
* proxy/Makefile.am, proxy/libvirt_proxy.c, src/Makefile.am,
src/libvirt.c, tests/sexpr2xmltest.c, tests/statstest.c,
tests/xencapstest.c, tests/xmconfigtest.c, tests/xml2sexprtest.c:
Adapt to changed xen location
* src/stats_linux.h, src/stats_linux.c: Remove xen specific block
stats APIs
* src/qemu_driver.c, src/uml_driver.c: Add missing sys/un.h include
uncovered after change to stats_linux.h
* src/xen/block_stats.h, src/xen/block_stats.c: Add xen specific
block stats APIs
2009-09-15 15:38:33 +00:00
|
|
|
#include "xen_driver.h"
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2011-02-21 13:40:08 +00:00
|
|
|
#include "xen_sxpr.h"
|
2011-02-21 13:40:10 +00:00
|
|
|
#include "xen_xm.h"
|
Move xen driver code into src/xen/ directory
* src/Makefile.am, src/proxy_internal.c, src/proxy_internal.h
src/sexpr.c, src/sexpr.h, src/xen_unified.c, src/xen_unified.h,
src/xen_internal.c, src/xen_internal.h, src/xen_inotify.c,
src/xen_inotify.h, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h, src/xs_internal.c,
src/xs_internal.h: Move to src/xen/ directory
* proxy/Makefile.am, proxy/libvirt_proxy.c, src/Makefile.am,
src/libvirt.c, tests/sexpr2xmltest.c, tests/statstest.c,
tests/xencapstest.c, tests/xmconfigtest.c, tests/xml2sexprtest.c:
Adapt to changed xen location
* src/stats_linux.h, src/stats_linux.c: Remove xen specific block
stats APIs
* src/qemu_driver.c, src/uml_driver.c: Add missing sys/un.h include
uncovered after change to stats_linux.h
* src/xen/block_stats.h, src/xen/block_stats.c: Add xen specific
block stats APIs
2009-09-15 15:38:33 +00:00
|
|
|
#include "xen_hypervisor.h"
|
2007-04-04 14:19:49 +00:00
|
|
|
#include "xend_internal.h"
|
|
|
|
#include "xs_internal.h"
|
|
|
|
#include "xm_internal.h"
|
2008-11-25 10:44:52 +00:00
|
|
|
#if WITH_XEN_INOTIFY
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "xen_inotify.h"
|
2008-11-25 10:44:52 +00:00
|
|
|
#endif
|
2012-12-13 18:13:21 +00:00
|
|
|
#include "virxml.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2009-04-03 12:38:52 +00:00
|
|
|
#include "node_device_conf.h"
|
2012-12-13 14:52:25 +00:00
|
|
|
#include "virpci.h"
|
2012-12-13 18:01:25 +00:00
|
|
|
#include "viruuid.h"
|
2010-10-22 13:40:26 +00:00
|
|
|
#include "fdstream.h"
|
2011-07-19 18:32:58 +00:00
|
|
|
#include "virfile.h"
|
2012-02-24 18:48:55 +00:00
|
|
|
#include "viruri.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
#include "vircommand.h"
|
Implement the core API to suspend/resume the host
Add the core functions that implement the functionality of the API.
Suspend is done by using an asynchronous mechanism so that we can return
the status to the caller before the host gets suspended. This asynchronous
operation is achieved by suspending the host in a separate thread of
execution. However, returning the status to the caller is only best-effort,
but not guaranteed.
To resume the host, an RTC alarm is set up (based on how long we want to
suspend) before suspending the host. When this alarm fires, the host
gets woken up.
Suspend-to-RAM operation on a host running Linux can take upto more than 20
seconds, depending on the load of the system. (Freezing of tasks, an operation
preceding any suspend operation, is given up after a 20 second timeout).
And Suspend-to-Disk can take even more time, considering the time required
for compaction, creating the memory image and writing it to disk etc.
So, we do not allow the user to specify a suspend duration of less than 60
seconds, to be on the safer side, since we don't want to prematurely declare
failure when we only had to wait for some more time.
2011-11-29 09:07:38 +00:00
|
|
|
#include "virnodesuspend.h"
|
2012-09-14 14:42:17 +00:00
|
|
|
#include "nodeinfo.h"
|
2012-12-04 10:00:02 +00:00
|
|
|
#include "configmake.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_XEN
|
2012-12-04 10:00:02 +00:00
|
|
|
#define XEN_SAVE_DIR LOCALSTATEDIR "/lib/libvirt/xen/save"
|
2009-01-20 17:13:33 +00:00
|
|
|
|
2007-10-22 20:28:55 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
|
2007-10-31 09:39:13 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetMaxVcpus(virDomainPtr dom);
|
2007-10-31 09:39:13 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetVcpus(virDomainPtr dom,
|
|
|
|
virVcpuInfoPtr info, int maxinfo,
|
|
|
|
unsigned char *cpumaps, int maplen);
|
2011-12-13 10:39:17 +00:00
|
|
|
|
2007-10-22 20:28:55 +00:00
|
|
|
|
2013-04-30 13:41:48 +00:00
|
|
|
static bool is_privileged = false;
|
2009-01-22 17:49:41 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
static virDomainDefPtr xenGetDomainDefForID(virConnectPtr conn, int id)
|
|
|
|
{
|
|
|
|
virDomainDefPtr ret;
|
|
|
|
|
|
|
|
ret = xenHypervisorLookupDomainByID(conn, id);
|
|
|
|
|
|
|
|
if (!ret && virGetLastError() == NULL)
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virDomainDefPtr xenGetDomainDefForName(virConnectPtr conn, const char *name)
|
|
|
|
{
|
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
|
|
|
virDomainDefPtr ret;
|
|
|
|
|
|
|
|
ret = xenDaemonLookupByName(conn, name);
|
|
|
|
|
|
|
|
/* Try XM for inactive domains. */
|
|
|
|
if (!ret &&
|
|
|
|
priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3)
|
|
|
|
ret = xenXMDomainLookupByName(conn, name);
|
|
|
|
|
|
|
|
if (!ret && virGetLastError() == NULL)
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virDomainDefPtr xenGetDomainDefForUUID(virConnectPtr conn, const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
|
|
|
virDomainDefPtr ret;
|
|
|
|
|
|
|
|
ret = xenHypervisorLookupDomainByUUID(conn, uuid);
|
|
|
|
|
|
|
|
/* Try XM for inactive domains. */
|
|
|
|
if (!ret) {
|
|
|
|
if (priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3)
|
|
|
|
ret = xenXMDomainLookupByUUID(conn, uuid);
|
|
|
|
else
|
|
|
|
ret = xenDaemonLookupByUUID(conn, uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret && virGetLastError() == NULL)
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
static virDomainDefPtr xenGetDomainDefForDom(virDomainPtr dom)
|
|
|
|
{
|
|
|
|
/* UUID lookup is more efficient than name lookup */
|
|
|
|
return xenGetDomainDefForUUID(dom->conn, dom->uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-22 20:28:55 +00:00
|
|
|
/**
|
|
|
|
* xenNumaInit:
|
|
|
|
* @conn: pointer to the hypervisor connection
|
|
|
|
*
|
|
|
|
* Initializer for previous variables. We currently assume that
|
2008-02-27 10:37:19 +00:00
|
|
|
* the number of physical CPU and the number of NUMA cell is fixed
|
2007-10-22 20:28:55 +00:00
|
|
|
* until reboot which might be false in future Xen implementations.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
xenNumaInit(virConnectPtr conn) {
|
|
|
|
virNodeInfo nodeInfo;
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedPrivatePtr priv;
|
2007-10-22 20:28:55 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = xenUnifiedNodeGetInfo(conn, &nodeInfo);
|
|
|
|
if (ret < 0)
|
|
|
|
return;
|
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
priv = conn->privateData;
|
2007-10-22 20:28:55 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
priv->nbNodeCells = nodeInfo.nodes;
|
|
|
|
priv->nbNodeCpus = nodeInfo.cpus;
|
2007-10-22 20:28:55 +00:00
|
|
|
}
|
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
|
2007-10-31 09:39:13 +00:00
|
|
|
/**
|
|
|
|
* xenDomainUsedCpus:
|
|
|
|
* @dom: the domain
|
|
|
|
*
|
|
|
|
* Analyze which set of CPUs are used by the domain and
|
|
|
|
* return a string providing the ranges.
|
|
|
|
*
|
|
|
|
* Returns the string which needs to be freed by the caller or
|
|
|
|
* NULL if the domain uses all CPU or in case of error.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
xenDomainUsedCpus(virDomainPtr dom)
|
|
|
|
{
|
|
|
|
char *res = NULL;
|
2009-01-21 18:11:14 +00:00
|
|
|
int ncpus;
|
2007-10-31 09:39:13 +00:00
|
|
|
int nb_vcpu;
|
2012-09-17 18:38:20 +00:00
|
|
|
virBitmapPtr cpulist = NULL;
|
2007-10-31 09:39:13 +00:00
|
|
|
unsigned char *cpumap = NULL;
|
|
|
|
size_t cpumaplen;
|
|
|
|
int nb = 0;
|
|
|
|
int n, m;
|
|
|
|
virVcpuInfoPtr cpuinfo = NULL;
|
|
|
|
virNodeInfo nodeinfo;
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedPrivatePtr priv;
|
2007-10-31 09:39:13 +00:00
|
|
|
|
|
|
|
if (!VIR_IS_CONNECTED_DOMAIN(dom))
|
2012-03-22 11:33:35 +00:00
|
|
|
return NULL;
|
2007-10-31 09:39:13 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
priv = dom->conn->privateData;
|
|
|
|
|
|
|
|
if (priv->nbNodeCpus <= 0)
|
2012-03-22 11:33:35 +00:00
|
|
|
return NULL;
|
2007-10-31 09:39:13 +00:00
|
|
|
nb_vcpu = xenUnifiedDomainGetMaxVcpus(dom);
|
|
|
|
if (nb_vcpu <= 0)
|
2012-03-22 11:33:35 +00:00
|
|
|
return NULL;
|
2007-10-31 09:39:13 +00:00
|
|
|
if (xenUnifiedNodeGetInfo(dom->conn, &nodeinfo) < 0)
|
2012-03-22 11:33:35 +00:00
|
|
|
return NULL;
|
2007-10-31 09:39:13 +00:00
|
|
|
|
2012-09-17 18:38:20 +00:00
|
|
|
if (!(cpulist = virBitmapNew(priv->nbNodeCpus))) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2007-10-31 09:39:13 +00:00
|
|
|
goto done;
|
2009-11-08 21:08:54 +00:00
|
|
|
}
|
|
|
|
if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2007-10-31 09:39:13 +00:00
|
|
|
goto done;
|
2009-11-08 21:08:54 +00:00
|
|
|
}
|
2007-10-31 09:39:13 +00:00
|
|
|
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
|
2008-06-06 11:09:57 +00:00
|
|
|
if (xalloc_oversized(nb_vcpu, cpumaplen) ||
|
2009-11-08 21:08:54 +00:00
|
|
|
VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2007-10-31 09:39:13 +00:00
|
|
|
goto done;
|
2009-11-08 21:08:54 +00:00
|
|
|
}
|
2007-10-31 09:39:13 +00:00
|
|
|
|
|
|
|
if ((ncpus = xenUnifiedDomainGetVcpus(dom, cpuinfo, nb_vcpu,
|
|
|
|
cpumap, cpumaplen)) >= 0) {
|
2013-05-21 07:21:21 +00:00
|
|
|
for (n = 0; n < ncpus; n++) {
|
|
|
|
for (m = 0; m < priv->nbNodeCpus; m++) {
|
2012-09-17 18:38:20 +00:00
|
|
|
bool used;
|
|
|
|
ignore_value(virBitmapGetBit(cpulist, m, &used));
|
|
|
|
if ((!used) &&
|
2008-04-10 16:54:54 +00:00
|
|
|
(VIR_CPU_USABLE(cpumap, cpumaplen, n, m))) {
|
2012-09-17 18:38:20 +00:00
|
|
|
ignore_value(virBitmapSetBit(cpulist, m));
|
2008-04-10 16:54:54 +00:00
|
|
|
nb++;
|
|
|
|
/* if all CPU are used just return NULL */
|
2009-01-21 18:11:14 +00:00
|
|
|
if (nb == priv->nbNodeCpus)
|
2008-04-10 16:54:54 +00:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-17 18:38:20 +00:00
|
|
|
res = virBitmapFormat(cpulist);
|
2007-10-31 09:39:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2012-09-17 18:38:20 +00:00
|
|
|
virBitmapFree(cpulist);
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(cpumap);
|
|
|
|
VIR_FREE(cpuinfo);
|
2012-03-22 11:33:35 +00:00
|
|
|
return res;
|
2007-10-31 09:39:13 +00:00
|
|
|
}
|
|
|
|
|
2009-01-22 17:49:41 +00:00
|
|
|
static int
|
2013-04-30 13:41:48 +00:00
|
|
|
xenUnifiedStateInitialize(bool privileged,
|
2013-04-23 12:50:18 +00:00
|
|
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
2009-01-22 17:49:41 +00:00
|
|
|
{
|
2013-04-30 13:41:48 +00:00
|
|
|
/* Don't allow driver to work in non-root libvirtd */
|
|
|
|
if (privileged)
|
|
|
|
is_privileged = true;
|
2009-01-22 17:49:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStateDriver state_driver = {
|
Fix return value in virStateInitialize impl for LXC
The LXC driver was mistakenly returning -1 for lxcStartup()
in scenarios that are not an error. This caused the libvirtd
to quit for unprivileged users. This fixes the return code
of LXC driver, and also adds a "name" field to the virStateDriver
struct and logging to make it easier to find these problems
in the future
* src/driver.h: Add a 'name' field to state driver to allow
easy identification during failures
* src/libvirt.c: Log name of failed driver for virStateInit
failures
* src/lxc/lxc_driver.c: Don't return a failure code for
lxcStartup() if LXC is not available on this host, simply
disable the driver.
* src/network/bridge_driver.c, src/node_device/node_device_devkit.c,
src/node_device/node_device_hal.c, src/opennebula/one_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/secret/secret_driver.c, src/storage/storage_driver.c,
src/uml/uml_driver.c, src/xen/xen_driver.c: Fill in name
field in virStateDriver struct
2009-11-02 23:18:19 +00:00
|
|
|
.name = "Xen",
|
2013-04-23 12:50:18 +00:00
|
|
|
.stateInitialize = xenUnifiedStateInitialize,
|
2009-01-22 17:49:41 +00:00
|
|
|
};
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
/*----- Dispatch functions. -----*/
|
|
|
|
|
|
|
|
/* These dispatch functions follow the model used historically
|
|
|
|
* by libvirt.c -- trying each low-level Xen driver in turn
|
|
|
|
* until one succeeds. However since we know what low-level
|
|
|
|
* drivers can perform which functions, it is probably better
|
|
|
|
* in future to optimise these dispatch functions to just call
|
|
|
|
* the single function (or small number of appropriate functions)
|
|
|
|
* in the low level drivers directly.
|
|
|
|
*/
|
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedProbe(void)
|
2008-02-26 07:05:18 +00:00
|
|
|
{
|
|
|
|
#ifdef __linux__
|
|
|
|
if (virFileExists("/proc/xen"))
|
2008-11-17 11:44:51 +00:00
|
|
|
return 1;
|
2008-02-26 07:05:18 +00:00
|
|
|
#endif
|
2008-12-17 21:31:51 +00:00
|
|
|
#ifdef __sun
|
2010-11-17 02:13:29 +00:00
|
|
|
int fd;
|
2008-02-26 07:05:18 +00:00
|
|
|
|
2010-11-17 02:13:29 +00:00
|
|
|
if ((fd = open("/dev/xen/domcaps", O_RDONLY)) >= 0) {
|
|
|
|
VIR_FORCE_CLOSE(fd);
|
2008-11-17 11:44:51 +00:00
|
|
|
return 1;
|
2008-02-26 07:05:18 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-11-17 11:44:51 +00:00
|
|
|
return 0;
|
2008-02-26 07:05:18 +00:00
|
|
|
}
|
|
|
|
|
2011-02-10 22:42:34 +00:00
|
|
|
#ifdef WITH_LIBXL
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedXendProbe(void)
|
2011-02-10 22:42:34 +00:00
|
|
|
{
|
|
|
|
virCommandPtr cmd;
|
|
|
|
int status;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL);
|
|
|
|
if (virCommandRun(cmd, &status) == 0 && status == 0)
|
|
|
|
ret = 1;
|
|
|
|
virCommandFree(cmd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
|
2013-03-13 20:39:34 +00:00
|
|
|
static int
|
|
|
|
xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
virCapsPtr caps ATTRIBUTE_UNUSED,
|
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
|
|
|
|
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
|
|
|
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
|
|
|
|
STRNEQ(def->os.type, "hvm"))
|
|
|
|
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-15 14:44:12 +00:00
|
|
|
virDomainDefParserConfig xenDomainDefParserConfig = {
|
|
|
|
.macPrefix = { 0x00, 0x16, 0x3e },
|
2013-03-13 20:39:34 +00:00
|
|
|
.devicesPostParseCallback = xenDomainDeviceDefPostParse,
|
2013-03-15 14:44:12 +00:00
|
|
|
};
|
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
|
2013-03-13 20:39:34 +00:00
|
|
|
virDomainXMLOptionPtr
|
|
|
|
xenDomainXMLConfInit(void)
|
|
|
|
{
|
|
|
|
return virDomainXMLOptionNew(&xenDomainDefParserConfig,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-17 21:26:16 +00:00
|
|
|
static virDrvOpenStatus
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2007-04-10 11:17:34 +00:00
|
|
|
xenUnifiedPrivatePtr priv;
|
2012-12-04 10:00:02 +00:00
|
|
|
char ebuf[1024];
|
2007-06-20 10:01:14 +00:00
|
|
|
|
2009-01-22 17:49:41 +00:00
|
|
|
/*
|
|
|
|
* Only the libvirtd instance can open this driver.
|
|
|
|
* Everything else falls back to the remote driver.
|
|
|
|
*/
|
2013-04-30 13:41:48 +00:00
|
|
|
if (!is_privileged)
|
2009-01-22 17:49:41 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
if (conn->uri == NULL) {
|
|
|
|
if (!xenUnifiedProbe())
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
Centralize error reporting for URI parsing/formatting problems
Move error reporting out of the callers, into virURIParse
and virURIFormat, to get consistency.
* include/libvirt/virterror.h, src/util/virterror.c: Add VIR_FROM_URI
* src/util/viruri.c, src/util/viruri.h: Add error reporting
* src/esx/esx_driver.c, src/libvirt.c, src/libxl/libxl_driver.c,
src/lxc/lxc_driver.c, src/openvz/openvz_driver.c,
src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/vmx/vmx.c, src/xen/xen_driver.c,
src/xen/xend_internal.c, tests/viruritest.c: Remove error
reporting
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-03-20 12:16:54 +00:00
|
|
|
if (!(conn->uri = virURIParse("xen:///")))
|
2008-11-17 11:44:51 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
2009-06-12 12:06:15 +00:00
|
|
|
} else {
|
|
|
|
if (conn->uri->scheme) {
|
|
|
|
/* Decline any scheme which isn't "xen://" or "http://". */
|
|
|
|
if (STRCASENEQ(conn->uri->scheme, "xen") &&
|
|
|
|
STRCASENEQ(conn->uri->scheme, "http"))
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
|
|
|
|
/* Return an error if the path isn't '' or '/' */
|
|
|
|
if (conn->uri->path &&
|
|
|
|
STRNEQ(conn->uri->path, "") &&
|
|
|
|
STRNEQ(conn->uri->path, "/")) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unexpected Xen URI path '%s', try xen:///"),
|
|
|
|
conn->uri->path);
|
2009-06-12 12:06:15 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2007-06-20 17:25:39 +00:00
|
|
|
|
2009-06-12 12:06:15 +00:00
|
|
|
/* Decline any xen:// URI with a server specified, allowing remote
|
|
|
|
* driver to handle, but keep any http:/// URIs */
|
|
|
|
if (STRCASEEQ(conn->uri->scheme, "xen") &&
|
|
|
|
conn->uri->server)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
} else {
|
2011-10-13 10:49:45 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
2009-06-12 12:06:15 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-20 10:01:14 +00:00
|
|
|
|
2011-02-10 22:42:34 +00:00
|
|
|
#ifdef WITH_LIBXL
|
|
|
|
/* Decline xen:// URI if xend is not running and libxenlight
|
|
|
|
* driver is potentially available. */
|
|
|
|
if (!xenUnifiedXendProbe())
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
#endif
|
|
|
|
|
2009-06-12 12:06:15 +00:00
|
|
|
/* We now know the URI is definitely for this driver, so beyond
|
|
|
|
* here, don't return DECLINED, always use ERROR */
|
2007-04-10 11:17:34 +00:00
|
|
|
|
|
|
|
/* Allocate per-connection private data. */
|
2008-06-06 11:09:57 +00:00
|
|
|
if (VIR_ALLOC(priv) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2007-04-10 11:17:34 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2009-01-21 18:11:14 +00:00
|
|
|
if (virMutexInit(&priv->lock) < 0) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("cannot initialize mutex"));
|
2009-01-21 18:11:14 +00:00
|
|
|
VIR_FREE(priv);
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2007-04-10 11:17:34 +00:00
|
|
|
|
2011-12-14 00:25:58 +00:00
|
|
|
if (!(priv->domainEvents = virDomainEventStateNew())) {
|
2009-01-21 18:11:14 +00:00
|
|
|
virMutexDestroy(&priv->lock);
|
|
|
|
VIR_FREE(priv);
|
2008-11-25 10:44:52 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2009-01-21 18:11:14 +00:00
|
|
|
conn->privateData = priv;
|
|
|
|
|
2007-04-10 11:17:34 +00:00
|
|
|
priv->handle = -1;
|
|
|
|
priv->xendConfigVersion = -1;
|
|
|
|
priv->xshandle = NULL;
|
|
|
|
|
|
|
|
|
2013-04-30 13:41:48 +00:00
|
|
|
/* Hypervisor required to succeed */
|
|
|
|
VIR_DEBUG("Trying hypervisor sub-driver");
|
|
|
|
if (xenHypervisorOpen(conn, auth, flags) < 0)
|
|
|
|
goto error;
|
|
|
|
VIR_DEBUG("Activated hypervisor sub-driver");
|
|
|
|
priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] = 1;
|
2007-04-10 11:17:34 +00:00
|
|
|
|
2013-04-30 13:41:48 +00:00
|
|
|
/* XenD is required to succeed */
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Trying XenD sub-driver");
|
2013-04-30 13:41:48 +00:00
|
|
|
if (xenDaemonOpen(conn, auth, flags) < 0)
|
|
|
|
goto error;
|
|
|
|
VIR_DEBUG("Activated XenD sub-driver");
|
|
|
|
priv->opened[XEN_UNIFIED_XEND_OFFSET] = 1;
|
|
|
|
|
|
|
|
/* For old XenD, the XM driver is required to succeed */
|
|
|
|
if (priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3) {
|
|
|
|
VIR_DEBUG("Trying XM sub-driver");
|
|
|
|
if (xenXMOpen(conn, auth, flags) < 0)
|
|
|
|
goto error;
|
|
|
|
VIR_DEBUG("Activated XM sub-driver");
|
|
|
|
priv->opened[XEN_UNIFIED_XM_OFFSET] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_DEBUG("Trying XS sub-driver");
|
|
|
|
if (xenStoreOpen(conn, auth, flags) < 0)
|
|
|
|
goto error;
|
|
|
|
VIR_DEBUG("Activated XS sub-driver");
|
|
|
|
priv->opened[XEN_UNIFIED_XS_OFFSET] = 1;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
xenNumaInit(conn);
|
|
|
|
|
2008-09-05 11:35:43 +00:00
|
|
|
if (!(priv->caps = xenHypervisorMakeCapabilities(conn))) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Failed to make capabilities");
|
2013-04-30 13:41:48 +00:00
|
|
|
goto error;
|
2008-07-25 13:17:27 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 20:39:34 +00:00
|
|
|
if (!(priv->xmlopt = xenDomainXMLConfInit()))
|
2013-04-30 13:41:48 +00:00
|
|
|
goto error;
|
2013-03-05 15:17:24 +00:00
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
#if WITH_XEN_INOTIFY
|
2013-04-30 13:41:48 +00:00
|
|
|
VIR_DEBUG("Trying Xen inotify sub-driver");
|
|
|
|
if (xenInotifyOpen(conn, auth, flags) < 0)
|
|
|
|
goto error;
|
|
|
|
VIR_DEBUG("Activated Xen inotify sub-driver");
|
|
|
|
priv->opened[XEN_UNIFIED_INOTIFY_OFFSET] = 1;
|
2008-11-25 10:44:52 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-03 12:51:25 +00:00
|
|
|
if (VIR_STRDUP(priv->saveDir, XEN_SAVE_DIR) < 0)
|
2013-04-30 13:41:48 +00:00
|
|
|
goto error;
|
2012-12-04 10:00:02 +00:00
|
|
|
|
|
|
|
if (virFileMakePath(priv->saveDir) < 0) {
|
2013-04-30 13:41:48 +00:00
|
|
|
VIR_ERROR(_("Errored to create save dir '%s': %s"), priv->saveDir,
|
2012-12-04 10:00:02 +00:00
|
|
|
virStrerror(errno, ebuf, sizeof(ebuf)));
|
2013-04-30 13:41:48 +00:00
|
|
|
goto error;
|
2012-12-04 10:00:02 +00:00
|
|
|
}
|
|
|
|
|
2007-04-10 11:17:34 +00:00
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
2008-03-17 17:30:48 +00:00
|
|
|
|
2013-04-30 13:41:48 +00:00
|
|
|
error:
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Failed to activate a mandatory sub-driver");
|
2013-04-30 13:41:48 +00:00
|
|
|
#if WITH_XEN_INOTIFY
|
|
|
|
if (priv->opened[XEN_UNIFIED_INOTIFY_OFFSET])
|
|
|
|
xenInotifyClose(conn);
|
|
|
|
#endif
|
|
|
|
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
|
|
|
|
xenXMClose(conn);
|
|
|
|
if (priv->opened[XEN_UNIFIED_XS_OFFSET])
|
|
|
|
xenStoreClose(conn);
|
|
|
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
|
|
|
xenDaemonClose(conn);
|
|
|
|
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET])
|
|
|
|
xenHypervisorClose(conn);
|
2009-01-21 18:11:14 +00:00
|
|
|
virMutexDestroy(&priv->lock);
|
2012-12-04 17:39:07 +00:00
|
|
|
VIR_FREE(priv->saveDir);
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(priv);
|
2009-01-21 18:11:14 +00:00
|
|
|
conn->privateData = NULL;
|
2013-04-30 13:41:48 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectClose(virConnectPtr conn)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-02-01 12:26:18 +00:00
|
|
|
virObjectUnref(priv->caps);
|
2013-03-31 18:03:42 +00:00
|
|
|
virObjectUnref(priv->xmlopt);
|
2011-12-13 10:39:17 +00:00
|
|
|
virDomainEventStateFree(priv->domainEvents);
|
2008-11-25 10:44:52 +00:00
|
|
|
|
2013-04-30 13:41:48 +00:00
|
|
|
#if WITH_XEN_INOTIFY
|
|
|
|
if (priv->opened[XEN_UNIFIED_INOTIFY_OFFSET])
|
|
|
|
xenInotifyClose(conn);
|
|
|
|
#endif
|
|
|
|
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
|
|
|
|
xenXMClose(conn);
|
|
|
|
if (priv->opened[XEN_UNIFIED_XS_OFFSET])
|
|
|
|
xenStoreClose(conn);
|
|
|
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET])
|
|
|
|
xenDaemonClose(conn);
|
|
|
|
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET])
|
|
|
|
xenHypervisorClose(conn);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2012-12-04 10:00:02 +00:00
|
|
|
VIR_FREE(priv->saveDir);
|
2009-01-21 18:11:14 +00:00
|
|
|
virMutexDestroy(&priv->lock);
|
|
|
|
VIR_FREE(conn->privateData);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2007-04-10 11:17:34 +00:00
|
|
|
return 0;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2008-11-28 12:03:20 +00:00
|
|
|
|
|
|
|
#define HV_VERSION ((DOM0_INTERFACE_VERSION >> 24) * 1000000 + \
|
|
|
|
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 + \
|
|
|
|
(DOM0_INTERFACE_VERSION & 0xFFFF))
|
|
|
|
|
|
|
|
unsigned long xenUnifiedVersion(void)
|
|
|
|
{
|
|
|
|
return HV_VERSION;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static const char *
|
2013-04-30 13:51:40 +00:00
|
|
|
xenUnifiedConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 13:51:40 +00:00
|
|
|
return "Xen";
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2007-08-21 09:31:12 +00:00
|
|
|
/* Which features are supported by this driver? */
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
|
2007-08-21 09:31:12 +00:00
|
|
|
{
|
|
|
|
switch (feature) {
|
2009-09-17 17:10:04 +00:00
|
|
|
case VIR_DRV_FEATURE_MIGRATION_V1:
|
|
|
|
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
2007-08-21 09:31:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectGetVersion(virConnectPtr conn, unsigned long *hvVer)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 13:53:50 +00:00
|
|
|
return xenHypervisorGetVersion(conn, hvVer);
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-26 16:39:11 +00:00
|
|
|
|
|
|
|
static char *xenUnifiedConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return virGetHostname();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectIsSecure(virConnectPtr conn)
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
/* All drivers are secure, except for XenD over TCP */
|
|
|
|
if (priv->opened[XEN_UNIFIED_XEND_OFFSET] &&
|
|
|
|
priv->addrfamily != AF_UNIX)
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-09-23 06:56:13 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
|
2011-09-23 06:56:13 +00:00
|
|
|
{
|
|
|
|
/* XenD reconnects for each request */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-10-14 22:17:18 +00:00
|
|
|
int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectGetMaxVcpus(virConnectPtr conn, const char *type)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2012-10-17 09:23:12 +00:00
|
|
|
if (type && STRCASENEQ(type, "Xen")) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
|
Fri Jul 6 16:08:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/proxy_internal.c, src/proxy_internal.h,
src.xen_internal.c, src/xen_internal.h,
src/xen_unified.c, src/xen_unified.h,
src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h,
src/xs_internal.c, src/xs_internal.h: The interface
between xen_unified.c and its underlying driver now uses
a custom structure (struct xenUnifiedDriver) instead
of reusing virDriver.
* src/xen_unified.c: virDomainLookup* functions in Xen
now throw VIR_ERR_NO_DOMAIN if the domain does not exist.
* src/xs_internal.c: Fix indentation.
2007-07-06 15:11:22 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-30 13:57:03 +00:00
|
|
|
return xenHypervisorGetMaxVcpus(conn, type);
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 13:57:03 +00:00
|
|
|
return xenDaemonNodeGetInfo(conn, info);
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectGetCapabilities(virConnectPtr conn)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
|
|
|
char *xml;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
if (!(xml = virCapabilitiesFormatXML(priv->caps))) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2009-01-21 18:11:14 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
return xml;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectListDomains(virConnectPtr conn, int *ids, int maxids)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 14:00:13 +00:00
|
|
|
return xenStoreListDomains(conn, ids, maxids);
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectNumOfDomains(virConnectPtr conn)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 14:00:13 +00:00
|
|
|
return xenStoreNumOfDomains(conn);
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainCreateXML(virConnectPtr conn,
|
2013-05-01 13:15:10 +00:00
|
|
|
const char *xml,
|
|
|
|
unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 13:15:10 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
|
2013-04-30 14:01:22 +00:00
|
|
|
virCheckFlags(0, NULL);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
|
|
|
|
1 << VIR_DOMAIN_VIRT_XEN,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (xenDaemonCreateXML(conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = virGetDomain(conn, def->name, def->uuid);
|
|
|
|
if (ret)
|
|
|
|
ret->id = def->id;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainLookupByID(virConnectPtr conn, int id)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 14:05:10 +00:00
|
|
|
virDomainPtr ret = NULL;
|
2013-05-01 09:31:23 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
Fri Jul 6 16:08:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/proxy_internal.c, src/proxy_internal.h,
src.xen_internal.c, src/xen_internal.h,
src/xen_unified.c, src/xen_unified.h,
src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h,
src/xs_internal.c, src/xs_internal.h: The interface
between xen_unified.c and its underlying driver now uses
a custom structure (struct xenUnifiedDriver) instead
of reusing virDriver.
* src/xen_unified.c: virDomainLookup* functions in Xen
now throw VIR_ERR_NO_DOMAIN if the domain does not exist.
* src/xs_internal.c: Fix indentation.
2007-07-06 15:11:22 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
if (!(def = xenGetDomainDefForID(conn, id)))
|
|
|
|
goto cleanup;
|
2007-08-10 18:25:15 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
if (!(ret = virGetDomain(conn, def->name, def->uuid)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
ret->id = def->id;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
2013-04-30 14:05:10 +00:00
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainLookupByUUID(virConnectPtr conn,
|
|
|
|
const unsigned char *uuid)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 09:31:23 +00:00
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
if (!(def = xenGetDomainDefForUUID(conn, uuid)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
if (!(ret = virGetDomain(conn, def->name, def->uuid)))
|
|
|
|
goto cleanup;
|
Fri Jul 6 16:08:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/proxy_internal.c, src/proxy_internal.h,
src.xen_internal.c, src/xen_internal.h,
src/xen_unified.c, src/xen_unified.h,
src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h,
src/xs_internal.c, src/xs_internal.h: The interface
between xen_unified.c and its underlying driver now uses
a custom structure (struct xenUnifiedDriver) instead
of reusing virDriver.
* src/xen_unified.c: virDomainLookup* functions in Xen
now throw VIR_ERR_NO_DOMAIN if the domain does not exist.
* src/xs_internal.c: Fix indentation.
2007-07-06 15:11:22 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
ret->id = def->id;
|
2013-04-30 14:05:10 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
2013-04-30 14:05:10 +00:00
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainLookupByName(virConnectPtr conn,
|
|
|
|
const char *name)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 09:31:23 +00:00
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
if (!(def = xenGetDomainDefForName(conn, name)))
|
|
|
|
goto cleanup;
|
Fri Jul 6 16:08:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/proxy_internal.c, src/proxy_internal.h,
src.xen_internal.c, src/xen_internal.h,
src/xen_unified.c, src/xen_unified.h,
src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h,
src/xs_internal.c, src/xs_internal.h: The interface
between xen_unified.c and its underlying driver now uses
a custom structure (struct xenUnifiedDriver) instead
of reusing virDriver.
* src/xen_unified.c: virDomainLookup* functions in Xen
now throw VIR_ERR_NO_DOMAIN if the domain does not exist.
* src/xs_internal.c: Fix indentation.
2007-07-06 15:11:22 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
if (!(ret = virGetDomain(conn, def->name, def->uuid)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
ret->id = def->id;
|
2013-04-30 14:05:10 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
2013-04-30 14:05:10 +00:00
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedDomainIsActive(virDomainPtr dom)
|
|
|
|
{
|
2013-05-01 09:31:23 +00:00
|
|
|
virDomainDefPtr def;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
if (!(def = xenGetDomainDefForUUID(dom->conn, dom->uuid)))
|
|
|
|
goto cleanup;
|
2013-04-30 14:05:10 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
ret = def->id == -1 ? 0 : 1;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-11-24 07:43:15 +00:00
|
|
|
xenUnifiedDomainIsPersistent(virDomainPtr dom)
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 09:31:23 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (priv->opened[XEN_UNIFIED_XM_OFFSET]) {
|
|
|
|
/* Old Xen, pre-inactive domain management.
|
|
|
|
* If the XM driver can see the guest, it is definitely persistent */
|
2013-05-01 09:31:23 +00:00
|
|
|
def = xenXMDomainLookupByUUID(dom->conn, dom->uuid);
|
|
|
|
if (def)
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
ret = 1;
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
} else {
|
|
|
|
/* New Xen with inactive domain management */
|
2013-05-01 09:31:23 +00:00
|
|
|
def = xenDaemonLookupByUUID(dom->conn, dom->uuid);
|
|
|
|
if (def) {
|
|
|
|
if (def->id == -1) {
|
2013-04-30 14:12:47 +00:00
|
|
|
/* If its inactive, then trivially, it must be persistent */
|
|
|
|
ret = 1;
|
|
|
|
} else {
|
|
|
|
char *path;
|
|
|
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
|
|
|
|
|
|
/* If its running there's no official way to tell, so we
|
|
|
|
* go behind xend's back & look at the config dir */
|
|
|
|
virUUIDFormat(dom->uuid, uuidstr);
|
|
|
|
if (virAsprintf(&path, "%s/%s", XEND_DOMAINS_DIR, uuidstr) < 0) {
|
|
|
|
virReportOOMError();
|
2013-05-01 09:31:23 +00:00
|
|
|
goto cleanup;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
}
|
2013-04-30 14:12:47 +00:00
|
|
|
if (access(path, R_OK) == 0)
|
|
|
|
ret = 1;
|
|
|
|
else if (errno == ENOENT)
|
|
|
|
ret = 0;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-01 09:31:23 +00:00
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-11-24 07:43:15 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainSuspend(virDomainPtr dom)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 09:54:30 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainSuspend(dom->conn, def);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainResume(virDomainPtr dom)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 09:54:30 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainResume(dom->conn, def);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-10-05 17:31:55 +00:00
|
|
|
xenUnifiedDomainShutdownFlags(virDomainPtr dom,
|
|
|
|
unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 09:54:30 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
2011-10-05 17:31:55 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainShutdown(dom->conn, def);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2011-10-05 17:31:55 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainShutdown(virDomainPtr dom)
|
|
|
|
{
|
|
|
|
return xenUnifiedDomainShutdownFlags(dom, 0);
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainReboot(virDomainPtr dom, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 09:54:30 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
2013-04-30 14:38:32 +00:00
|
|
|
virCheckFlags(0, -1);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainReboot(dom->conn, def);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 08:19:59 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainDestroyFlags(virDomainPtr dom,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2013-05-01 09:54:30 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
2011-07-21 08:19:59 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainDestroy(dom->conn, def);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2011-07-21 08:19:59 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 19:41:15 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainDestroy(virDomainPtr dom)
|
|
|
|
{
|
|
|
|
return xenUnifiedDomainDestroyFlags(dom, 0);
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static char *
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetOSType(virDomainPtr dom)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 10:29:08 +00:00
|
|
|
char *ret = NULL;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 10:29:08 +00:00
|
|
|
if (def->id < 0) {
|
2013-04-30 15:04:36 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Unable to query OS type for inactive domain"));
|
|
|
|
return NULL;
|
|
|
|
} else {
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenDaemonDomainGetOSType(dom->conn, def);
|
2007-04-10 11:17:34 +00:00
|
|
|
}
|
2013-04-30 15:04:36 +00:00
|
|
|
} else {
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorDomainGetOSType(dom->conn, def);
|
2013-04-30 15:04:36 +00:00
|
|
|
}
|
2013-05-01 10:29:08 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:04:36 +00:00
|
|
|
|
xml: use long long internally, to centralize overflow checks
On 64-bit platforms, unsigned long and unsigned long long are
identical, so we don't have to worry about overflow checks.
On 32-bit platforms, anywhere we narrow unsigned long long back
to unsigned long, we have to worry about overflow; it's easier
to do this in one place by having most of the code use the same
or wider types, and only doing the narrowing at the last minute.
Therefore, the memory set commands remain unsigned long, and
the memory get command now centralizes the overflow check into
libvirt.c, so that drivers don't have to repeat the work.
This also fixes a bug where xen returned the wrong value on
failure (most APIs return -1 on failure, but getMaxMemory
must return 0 on failure).
* src/driver.h (virDrvDomainGetMaxMemory): Use long long.
* src/libvirt.c (virDomainGetMaxMemory): Raise overflow.
* src/test/test_driver.c (testGetMaxMemory): Fix driver.
* src/rpc/gendispatch.pl (name_to_ProcName): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorGetMaxMemory): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainGetMaxMemory): Likewise.
* src/xen/xend_internal.c (xenDaemonDomainGetMaxMemory):
Likewise.
* src/xen/xend_internal.h (xenDaemonDomainGetMaxMemory):
Likewise.
* src/xen/xm_internal.c (xenXMDomainGetMaxMemory): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetMaxMemory): Likewise.
* src/xen/xs_internal.c (xenStoreDomainGetMaxMemory): Likewise.
* src/xen/xs_internal.h (xenStoreDomainGetMaxMemory): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainGetMaxMemory):
Likewise.
* src/esx/esx_driver.c (esxDomainGetMaxMemory): Likewise.
* src/libxl/libxl_driver.c (libxlDomainGetMaxMemory): Likewise.
* src/qemu/qemu_driver.c (qemudDomainGetMaxMemory): Likewise.
* src/lxc/lxc_driver.c (lxcDomainGetMaxMemory): Likewise.
* src/uml/uml_driver.c (umlDomainGetMaxMemory): Likewise.
2012-03-03 00:47:16 +00:00
|
|
|
static unsigned long long
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetMaxMemory(virDomainPtr dom)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 10:29:08 +00:00
|
|
|
unsigned long long ret = 0;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 10:29:08 +00:00
|
|
|
if (def->id < 0) {
|
2013-04-30 15:31:33 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenXMDomainGetMaxMemory(dom->conn, def);
|
2013-04-30 15:31:33 +00:00
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenDaemonDomainGetMaxMemory(dom->conn, def);
|
2013-04-30 15:31:33 +00:00
|
|
|
} else {
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorGetMaxMemory(dom->conn, def);
|
2013-04-30 15:31:33 +00:00
|
|
|
}
|
2013-05-01 10:29:08 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainSetMaxMemory(virDomainPtr dom, unsigned long memory)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 10:29:08 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 10:29:08 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (def->id < 0) {
|
2013-04-30 15:31:33 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenXMDomainSetMaxMemory(dom->conn, def, memory);
|
2013-04-30 15:31:33 +00:00
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenDaemonDomainSetMaxMemory(dom->conn, def, memory);
|
2013-04-30 15:31:33 +00:00
|
|
|
} else {
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorSetMaxMemory(dom->conn, def, memory);
|
2008-11-27 16:16:13 +00:00
|
|
|
}
|
2013-05-01 10:29:08 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainSetMemory(virDomainPtr dom, unsigned long memory)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 10:29:08 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 10:29:08 +00:00
|
|
|
if (def->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
|
|
|
ret = xenXMDomainSetMemory(dom->conn, def, memory);
|
2013-04-30 15:31:33 +00:00
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenDaemonDomainSetMemory(dom->conn, def, memory);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 10:29:08 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 10:29:08 +00:00
|
|
|
if (def->id < 0) {
|
2013-04-30 15:42:29 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenXMDomainGetInfo(dom->conn, def, info);
|
2013-04-30 15:42:29 +00:00
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenDaemonDomainGetInfo(dom->conn, def, info);
|
2013-04-30 15:42:29 +00:00
|
|
|
} else {
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorGetDomainInfo(dom->conn, def, info);
|
2013-04-30 15:42:29 +00:00
|
|
|
}
|
2013-05-01 10:29:08 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2011-05-02 09:35:29 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainGetState(virDomainPtr dom,
|
|
|
|
int *state,
|
|
|
|
int *reason,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 10:29:08 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
2011-05-02 09:35:29 +00:00
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-01 10:29:08 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (def->id < 0) {
|
2013-04-30 15:42:29 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenXMDomainGetState(dom->conn, def, state, reason);
|
2013-04-30 15:42:29 +00:00
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenDaemonDomainGetState(dom->conn, def, state, reason);
|
2013-04-30 15:42:29 +00:00
|
|
|
} else {
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorGetDomainState(dom->conn, def, state, reason);
|
2011-05-02 09:35:29 +00:00
|
|
|
}
|
2013-05-01 10:29:08 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2011-05-02 09:35:29 +00:00
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
xenUnifiedDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
|
|
|
|
unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 13:03:26 +00:00
|
|
|
int ret = -1;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
virCheckFlags(0, -1);
|
2013-05-01 13:03:26 +00:00
|
|
|
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
if (dxml) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
|
|
|
_("xml modification unsupported"));
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainSave(dom->conn, def, to);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
xenUnifiedDomainSave(virDomainPtr dom, const char *to)
|
|
|
|
{
|
|
|
|
return xenUnifiedDomainSaveFlags(dom, to, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2012-12-04 10:00:02 +00:00
|
|
|
static char *
|
2013-05-01 13:03:26 +00:00
|
|
|
xenUnifiedDomainManagedSavePath(xenUnifiedPrivatePtr priv,
|
|
|
|
virDomainDefPtr def)
|
2012-12-04 10:00:02 +00:00
|
|
|
{
|
|
|
|
char *ret;
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
if (virAsprintf(&ret, "%s/%s.save", priv->saveDir, def->name) < 0) {
|
2012-12-04 10:00:02 +00:00
|
|
|
virReportOOMError();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_DEBUG("managed save image: %s", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 13:03:26 +00:00
|
|
|
char *name = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
2012-12-04 10:00:02 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
|
2012-12-04 10:00:02 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
ret = xenDaemonDomainSave(dom->conn, def, name);
|
2012-12-04 10:00:02 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(name);
|
2013-05-01 13:03:26 +00:00
|
|
|
virDomainDefFree(def);
|
2012-12-04 10:00:02 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
|
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 13:03:26 +00:00
|
|
|
char *name = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
2012-12-04 10:00:02 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
|
|
|
|
goto cleanup;
|
2012-12-04 10:00:02 +00:00
|
|
|
|
|
|
|
ret = virFileExists(name);
|
2013-05-01 13:03:26 +00:00
|
|
|
|
|
|
|
cleanup:
|
2012-12-04 10:00:02 +00:00
|
|
|
VIR_FREE(name);
|
2013-05-01 13:03:26 +00:00
|
|
|
virDomainDefFree(def);
|
2012-12-04 10:00:02 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
|
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 13:03:26 +00:00
|
|
|
char *name = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
2012-12-04 10:00:02 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
|
|
|
|
goto cleanup;
|
2012-12-04 10:00:02 +00:00
|
|
|
|
|
|
|
ret = unlink(name);
|
2013-05-01 13:03:26 +00:00
|
|
|
|
|
|
|
cleanup:
|
2012-12-04 10:00:02 +00:00
|
|
|
VIR_FREE(name);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainRestoreFlags(virConnectPtr conn, const char *from,
|
|
|
|
const char *dxml, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
if (dxml) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
|
|
|
_("xml modification unsupported"));
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-04-30 15:44:21 +00:00
|
|
|
return xenDaemonDomainRestore(conn, from);
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainRestore(virConnectPtr conn, const char *from)
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
{
|
|
|
|
return xenUnifiedDomainRestoreFlags(conn, from, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-02 10:26:40 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainCoreDump(dom->conn, def, to, flags);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|
|
|
unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 17:37:29 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2010-10-14 22:17:18 +00:00
|
|
|
virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
|
|
|
|
VIR_DOMAIN_VCPU_CONFIG |
|
|
|
|
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
|
|
|
|
|
|
|
/* At least one of LIVE or CONFIG must be set. MAXIMUM cannot be
|
|
|
|
* mixed with LIVE. */
|
|
|
|
if ((flags & (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG)) == 0 ||
|
|
|
|
(flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) ==
|
|
|
|
(VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("invalid flag combination: (0x%x)"), flags);
|
2010-10-14 22:17:18 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (!nvcpus || (unsigned short) nvcpus != nvcpus) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("argument out of range: %d"), nvcpus);
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-05-01 17:37:29 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2007-04-10 11:17:34 +00:00
|
|
|
/* Try non-hypervisor methods first, then hypervisor direct method
|
|
|
|
* as a last resort.
|
|
|
|
*/
|
2013-04-30 16:25:27 +00:00
|
|
|
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenXMDomainSetVcpusFlags(dom->conn, def, nvcpus, flags);
|
2013-04-30 16:25:27 +00:00
|
|
|
else
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenDaemonDomainSetVcpusFlags(dom->conn, def, nvcpus, flags);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
{
|
2013-04-30 16:25:27 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2010-10-14 22:17:18 +00:00
|
|
|
unsigned int flags = VIR_DOMAIN_VCPU_LIVE;
|
|
|
|
|
|
|
|
/* Per the documented API, it is hypervisor-dependent whether this
|
|
|
|
* affects just _LIVE or _LIVE|_CONFIG; in xen's case, that
|
|
|
|
* depends on xendConfigVersion. */
|
2013-04-30 16:25:27 +00:00
|
|
|
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
|
|
|
|
flags |= VIR_DOMAIN_VCPU_CONFIG;
|
|
|
|
|
|
|
|
return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainPinVcpu(virDomainPtr dom, unsigned int vcpu,
|
|
|
|
unsigned char *cpumap, int maplen)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 17:37:29 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-30 16:25:27 +00:00
|
|
|
if (dom->id < 0) {
|
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenXMDomainPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
|
2013-04-30 16:25:27 +00:00
|
|
|
else
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenDaemonDomainPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
|
2013-04-30 16:25:27 +00:00
|
|
|
} else {
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenHypervisorPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
|
2013-04-30 16:25:27 +00:00
|
|
|
}
|
2013-05-01 17:37:29 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetVcpus(virDomainPtr dom,
|
|
|
|
virVcpuInfoPtr info, int maxinfo,
|
|
|
|
unsigned char *cpumaps, int maplen)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 17:37:29 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:25:27 +00:00
|
|
|
if (dom->id < 0) {
|
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Cannot get VCPUs of inactive domain"));
|
2013-05-01 17:37:29 +00:00
|
|
|
goto cleanup;
|
2013-04-30 16:25:27 +00:00
|
|
|
} else {
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenDaemonDomainGetVcpus(dom->conn, def, info, maxinfo, cpumaps, maplen);
|
2007-04-13 00:43:57 +00:00
|
|
|
}
|
2013-04-30 16:25:27 +00:00
|
|
|
} else {
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenHypervisorGetVcpus(dom->conn, def, info, maxinfo, cpumaps, maplen);
|
2013-04-30 16:25:27 +00:00
|
|
|
}
|
2013-05-01 17:37:29 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 17:37:29 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2010-10-06 23:54:41 +00:00
|
|
|
virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
|
|
|
|
VIR_DOMAIN_VCPU_CONFIG |
|
|
|
|
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
|
|
|
|
2013-05-01 17:37:29 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:25:27 +00:00
|
|
|
if (dom->id < 0) {
|
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenXMDomainGetVcpusFlags(dom->conn, def, flags);
|
2013-04-30 16:25:27 +00:00
|
|
|
else
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenDaemonDomainGetVcpusFlags(dom->conn, def, flags);
|
2013-04-30 16:25:27 +00:00
|
|
|
} else {
|
|
|
|
if (flags == (VIR_DOMAIN_VCPU_CONFIG | VIR_DOMAIN_VCPU_MAXIMUM))
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenHypervisorGetVcpuMax(dom->conn, def);
|
2013-04-30 16:25:27 +00:00
|
|
|
else
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenDaemonDomainGetVcpusFlags(dom->conn, def, flags);
|
2010-10-06 23:54:41 +00:00
|
|
|
}
|
2013-05-01 17:37:29 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetMaxVcpus(virDomainPtr dom)
|
vcpu: make old API trivially wrap to new API
Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API. On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.
* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.
2010-09-27 22:37:53 +00:00
|
|
|
{
|
|
|
|
return xenUnifiedDomainGetVcpusFlags(dom, (VIR_DOMAIN_VCPU_LIVE |
|
|
|
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static char *
|
2011-07-06 20:40:19 +00:00
|
|
|
xenUnifiedDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 13:15:10 +00:00
|
|
|
virDomainDefPtr minidef = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
|
|
|
|
if (!(minidef = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-30 16:26:30 +00:00
|
|
|
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
2013-05-01 13:15:10 +00:00
|
|
|
def = xenXMDomainGetXMLDesc(dom->conn, minidef);
|
2007-10-31 09:39:13 +00:00
|
|
|
} else {
|
2013-05-01 13:15:10 +00:00
|
|
|
char *cpus;
|
2013-04-30 16:26:30 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
cpus = xenDomainUsedCpus(dom);
|
|
|
|
xenUnifiedUnlock(priv);
|
2013-05-01 13:15:10 +00:00
|
|
|
def = xenDaemonDomainGetXMLDesc(dom->conn, minidef, cpus);
|
2013-04-30 16:26:30 +00:00
|
|
|
VIR_FREE(cpus);
|
2008-02-05 19:27:37 +00:00
|
|
|
}
|
2013-05-01 13:15:10 +00:00
|
|
|
|
|
|
|
if (def)
|
|
|
|
ret = virDomainDefFormat(def, flags);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
virDomainDefFree(minidef);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2009-05-21 14:14:01 +00:00
|
|
|
|
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectDomainXMLFromNative(virConnectPtr conn,
|
|
|
|
const char *format,
|
|
|
|
const char *config,
|
|
|
|
unsigned int flags)
|
2009-05-21 14:14:01 +00:00
|
|
|
{
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virConfPtr conf = NULL;
|
2011-02-21 13:40:08 +00:00
|
|
|
int id;
|
|
|
|
char * tty;
|
|
|
|
int vncport;
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2009-05-21 14:14:01 +00:00
|
|
|
|
xen: reject unknown flags
Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.
2011-07-06 23:15:33 +00:00
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
2009-05-21 14:14:01 +00:00
|
|
|
if (STRNEQ(format, XEN_CONFIG_FORMAT_XM) &&
|
|
|
|
STRNEQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unsupported config type %s"), format);
|
2009-05-21 14:14:01 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {
|
2009-06-19 12:34:30 +00:00
|
|
|
conf = virConfReadMem(config, strlen(config), 0);
|
2009-05-21 14:14:01 +00:00
|
|
|
if (!conf)
|
|
|
|
goto cleanup;
|
|
|
|
|
2011-02-21 13:40:12 +00:00
|
|
|
def = xenParseXM(conf, priv->xendConfigVersion, priv->caps);
|
2009-05-21 14:14:01 +00:00
|
|
|
} else if (STREQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
|
2011-02-21 13:40:08 +00:00
|
|
|
id = xenGetDomIdFromSxprString(config, priv->xendConfigVersion);
|
|
|
|
xenUnifiedLock(priv);
|
|
|
|
tty = xenStoreDomainGetConsolePath(conn, id);
|
|
|
|
vncport = xenStoreDomainGetVNCPort(conn, id);
|
|
|
|
xenUnifiedUnlock(priv);
|
2011-02-21 13:40:12 +00:00
|
|
|
def = xenParseSxprString(config, priv->xendConfigVersion, tty,
|
2011-02-21 13:40:08 +00:00
|
|
|
vncport);
|
2009-05-21 14:14:01 +00:00
|
|
|
}
|
|
|
|
if (!def)
|
|
|
|
goto cleanup;
|
|
|
|
|
2010-02-09 18:58:01 +00:00
|
|
|
ret = virDomainDefFormat(def, 0);
|
2009-05-21 14:14:01 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
2010-01-18 17:02:17 +00:00
|
|
|
if (conf)
|
|
|
|
virConfFree(conf);
|
2009-05-21 14:14:01 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_CONFIG_SIZE (1024 * 65)
|
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectDomainXMLToNative(virConnectPtr conn,
|
|
|
|
const char *format,
|
|
|
|
const char *xmlData,
|
|
|
|
unsigned int flags)
|
2009-05-21 14:14:01 +00:00
|
|
|
{
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
virConfPtr conf = NULL;
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2009-05-21 14:14:01 +00:00
|
|
|
|
xen: reject unknown flags
Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.
2011-07-06 23:15:33 +00:00
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
2009-05-21 14:14:01 +00:00
|
|
|
if (STRNEQ(format, XEN_CONFIG_FORMAT_XM) &&
|
|
|
|
STRNEQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unsupported config type %s"), format);
|
2009-05-21 14:14:01 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-03-28 13:55:55 +00:00
|
|
|
if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlopt,
|
|
|
|
1 << VIR_DOMAIN_VIRT_XEN, 0)))
|
2009-05-21 14:14:01 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {
|
|
|
|
int len = MAX_CONFIG_SIZE;
|
2011-02-21 13:40:12 +00:00
|
|
|
conf = xenFormatXM(conn, def, priv->xendConfigVersion);
|
2009-05-21 14:14:01 +00:00
|
|
|
if (!conf)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(ret, len) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2009-05-21 14:14:01 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virConfWriteMem(ret, &len, conf) < 0) {
|
|
|
|
VIR_FREE(ret);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else if (STREQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
|
2011-02-21 13:40:12 +00:00
|
|
|
ret = xenFormatSxpr(conn, def, priv->xendConfigVersion);
|
2009-05-21 14:14:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
if (conf)
|
|
|
|
virConfFree(conf);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-21 09:31:12 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainMigratePrepare(virConnectPtr dconn,
|
|
|
|
char **cookie,
|
|
|
|
int *cookielen,
|
|
|
|
const char *uri_in,
|
|
|
|
char **uri_out,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *dname,
|
|
|
|
unsigned long resource)
|
2007-08-21 09:31:12 +00:00
|
|
|
{
|
xen: reject unknown flags
Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.
2011-07-06 23:15:33 +00:00
|
|
|
virCheckFlags(XEN_MIGRATION_FLAGS, -1);
|
|
|
|
|
2013-04-30 16:27:59 +00:00
|
|
|
return xenDaemonDomainMigratePrepare(dconn, cookie, cookielen,
|
|
|
|
uri_in, uri_out,
|
|
|
|
flags, dname, resource);
|
2007-08-21 09:31:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainMigratePerform(virDomainPtr dom,
|
|
|
|
const char *cookie,
|
|
|
|
int cookielen,
|
|
|
|
const char *uri,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *dname,
|
|
|
|
unsigned long resource)
|
2007-08-21 09:31:12 +00:00
|
|
|
{
|
2013-05-01 13:15:10 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
xen: reject unknown flags
Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.
2011-07-06 23:15:33 +00:00
|
|
|
virCheckFlags(XEN_MIGRATION_FLAGS, -1);
|
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonDomainMigratePerform(dom->conn, def,
|
|
|
|
cookie, cookielen, uri,
|
|
|
|
flags, dname, resource);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-08-21 09:31:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainMigrateFinish(virConnectPtr dconn,
|
|
|
|
const char *dname,
|
|
|
|
const char *cookie ATTRIBUTE_UNUSED,
|
|
|
|
int cookielen ATTRIBUTE_UNUSED,
|
|
|
|
const char *uri ATTRIBUTE_UNUSED,
|
|
|
|
unsigned long flags)
|
2007-08-21 09:31:12 +00:00
|
|
|
{
|
2013-05-01 13:15:10 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dconn->privateData;
|
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainDefPtr minidef = NULL;
|
|
|
|
virDomainDefPtr def = NULL;
|
2009-11-12 15:04:43 +00:00
|
|
|
|
xen: reject unknown flags
Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.
2011-07-06 23:15:33 +00:00
|
|
|
virCheckFlags(XEN_MIGRATION_FLAGS, NULL);
|
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (!(minidef = xenGetDomainDefForName(dconn, dname)))
|
|
|
|
goto cleanup;
|
2009-11-12 15:04:43 +00:00
|
|
|
|
|
|
|
if (flags & VIR_MIGRATE_PERSIST_DEST) {
|
2013-05-01 13:15:10 +00:00
|
|
|
if (!(def = xenDaemonDomainGetXMLDesc(dconn, minidef, NULL)))
|
|
|
|
goto cleanup;
|
2009-11-12 15:04:43 +00:00
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
if (xenXMDomainDefineXML(dconn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
} else {
|
|
|
|
if (xenDaemonDomainDefineXML(dconn, def) < 0)
|
|
|
|
goto cleanup;
|
2009-11-12 15:04:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
ret = virGetDomain(dconn, minidef->name, minidef->uuid);
|
|
|
|
if (ret)
|
|
|
|
ret->id = minidef->id;
|
2009-11-12 15:04:43 +00:00
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
virDomainDefFree(minidef);
|
|
|
|
return ret;
|
2007-08-21 09:31:12 +00:00
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectListDefinedDomains(virConnectPtr conn, char **const names,
|
|
|
|
int maxnames)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-30 16:31:40 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
return xenXMListDefinedDomains(conn, names, maxnames);
|
|
|
|
} else {
|
|
|
|
return xenDaemonListDefinedDomains(conn, names, maxnames);
|
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectNumOfDefinedDomains(virConnectPtr conn)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-30 16:31:40 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
return xenXMNumOfDefinedDomains(conn);
|
|
|
|
} else {
|
|
|
|
return xenDaemonNumOfDefinedDomains(conn);
|
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2012-12-04 10:00:02 +00:00
|
|
|
int ret = -1;
|
2013-05-01 13:03:26 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
2012-12-04 10:00:02 +00:00
|
|
|
char *name = NULL;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2010-06-10 15:55:36 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (!(name = xenUnifiedDomainManagedSavePath(priv, def)))
|
2012-12-04 10:00:02 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virFileExists(name)) {
|
2013-04-30 16:33:48 +00:00
|
|
|
ret = xenDaemonDomainRestore(dom->conn, name);
|
|
|
|
if (ret == 0)
|
|
|
|
unlink(name);
|
2012-12-04 10:00:02 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-04-30 16:33:48 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 13:03:26 +00:00
|
|
|
ret = xenXMDomainCreate(dom->conn, def);
|
2013-04-30 16:33:48 +00:00
|
|
|
else
|
2013-05-01 13:03:26 +00:00
|
|
|
ret = xenDaemonDomainCreate(dom->conn, def);
|
|
|
|
|
|
|
|
if (ret >= 0)
|
|
|
|
dom->id = def->id;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2012-12-04 10:00:02 +00:00
|
|
|
cleanup:
|
2013-05-01 13:03:26 +00:00
|
|
|
virDomainDefFree(def);
|
2012-12-04 10:00:02 +00:00
|
|
|
VIR_FREE(name);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2010-06-10 15:55:36 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainCreate(virDomainPtr dom)
|
2010-06-10 15:55:36 +00:00
|
|
|
{
|
|
|
|
return xenUnifiedDomainCreateWithFlags(dom, 0);
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static virDomainPtr
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainDefineXML(virConnectPtr conn, const char *xml)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2013-05-01 13:15:10 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
virDomainPtr ret = NULL;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
|
|
|
|
1 << VIR_DOMAIN_VIRT_XEN,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
if (xenXMDomainDefineXML(conn, def) < 0)
|
|
|
|
goto cleanup;
|
2013-05-23 15:07:36 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid);
|
2013-05-01 13:15:10 +00:00
|
|
|
def = NULL; /* XM driver owns it now */
|
|
|
|
} else {
|
|
|
|
if (xenDaemonDomainDefineXML(conn, def) < 0)
|
|
|
|
goto cleanup;
|
2013-05-23 15:07:36 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid);
|
2013-05-01 13:15:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
ret->id = -1;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-01 13:15:10 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2011-07-20 03:08:21 +00:00
|
|
|
virCheckFlags(0, -1);
|
2013-05-01 13:15:10 +00:00
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:39:29 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-01 13:15:10 +00:00
|
|
|
ret = xenXMDomainUndefine(dom->conn, def);
|
2013-04-30 16:39:29 +00:00
|
|
|
else
|
2013-05-01 13:15:10 +00:00
|
|
|
ret = xenDaemonDomainUndefine(dom->conn, def);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2011-07-20 03:08:21 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainUndefine(virDomainPtr dom) {
|
2011-07-20 03:08:21 +00:00
|
|
|
return xenUnifiedDomainUndefineFlags(dom, 0);
|
|
|
|
}
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainAttachDevice(virDomainPtr dom, const char *xml)
|
2010-01-14 01:44:26 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2010-10-01 14:45:55 +00:00
|
|
|
unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
|
2013-05-02 09:56:31 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2010-01-14 01:44:26 +00:00
|
|
|
|
2010-10-01 14:45:55 +00:00
|
|
|
/*
|
|
|
|
* HACK: xend with xendConfigVersion >= 3 does not support changing live
|
|
|
|
* config without touching persistent config, we add the extra flag here
|
|
|
|
* to make this API work
|
|
|
|
*/
|
2013-04-30 16:43:07 +00:00
|
|
|
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
|
2010-10-01 14:45:55 +00:00
|
|
|
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
|
2010-01-14 01:44:26 +00:00
|
|
|
|
2013-05-02 09:56:31 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:43:07 +00:00
|
|
|
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenXMDomainAttachDeviceFlags(dom->conn, def, xml, flags);
|
2013-04-30 16:43:07 +00:00
|
|
|
else
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
|
2010-01-14 01:44:26 +00:00
|
|
|
|
2013-05-02 09:56:31 +00:00
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2010-01-14 01:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
|
|
|
|
unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 09:56:31 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-30 16:43:07 +00:00
|
|
|
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenXMDomainAttachDeviceFlags(dom->conn, def, xml, flags);
|
2013-04-30 16:43:07 +00:00
|
|
|
else
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainDetachDevice(virDomainPtr dom, const char *xml)
|
2010-01-14 01:44:26 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2010-10-01 14:45:55 +00:00
|
|
|
unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_LIVE;
|
2013-05-02 09:56:31 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2010-01-14 01:44:26 +00:00
|
|
|
|
2010-10-01 14:45:55 +00:00
|
|
|
/*
|
|
|
|
* HACK: xend with xendConfigVersion >= 3 does not support changing live
|
|
|
|
* config without touching persistent config, we add the extra flag here
|
|
|
|
* to make this API work
|
|
|
|
*/
|
2013-04-30 16:43:07 +00:00
|
|
|
if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
|
2010-10-01 14:45:55 +00:00
|
|
|
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
|
2010-01-14 01:44:26 +00:00
|
|
|
|
2013-05-02 09:56:31 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:43:07 +00:00
|
|
|
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenXMDomainDetachDeviceFlags(dom->conn, def, xml, flags);
|
2013-04-30 16:43:07 +00:00
|
|
|
else
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2010-01-14 01:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
|
|
|
|
unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 09:56:31 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-30 16:43:07 +00:00
|
|
|
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenXMDomainDetachDeviceFlags(dom->conn, def, xml, flags);
|
2013-04-30 16:43:07 +00:00
|
|
|
else
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2010-03-22 13:13:53 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
|
|
|
|
unsigned int flags)
|
2010-03-22 13:13:53 +00:00
|
|
|
{
|
2013-05-02 09:56:31 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenDaemonUpdateDeviceFlags(dom->conn, def, xml, flags);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2010-03-22 13:13:53 +00:00
|
|
|
}
|
|
|
|
|
2008-05-09 08:17:18 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetAutostart(virDomainPtr dom, int *autostart)
|
2008-05-09 08:17:18 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 10:05:55 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2008-05-09 08:17:18 +00:00
|
|
|
|
2013-05-02 13:36:45 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-02 10:05:55 +00:00
|
|
|
ret = xenXMDomainGetAutostart(def, autostart);
|
2013-05-02 13:36:45 +00:00
|
|
|
else
|
2013-05-02 10:05:55 +00:00
|
|
|
ret = xenDaemonDomainGetAutostart(dom->conn, def, autostart);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2008-05-09 08:17:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainSetAutostart(virDomainPtr dom, int autostart)
|
2008-05-09 08:17:18 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 10:05:55 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2008-05-09 08:17:18 +00:00
|
|
|
|
2013-05-02 13:36:45 +00:00
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-02 10:05:55 +00:00
|
|
|
ret = xenXMDomainSetAutostart(def, autostart);
|
2013-05-02 13:36:45 +00:00
|
|
|
else
|
2013-05-02 10:05:55 +00:00
|
|
|
ret = xenDaemonDomainSetAutostart(dom->conn, def, autostart);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2008-05-09 08:17:18 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 12:06:08 +00:00
|
|
|
static char *
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainGetSchedulerType(virDomainPtr dom, int *nparams)
|
2007-06-05 12:06:08 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 10:13:39 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2013-04-30 16:52:19 +00:00
|
|
|
|
|
|
|
if (dom->id < 0) {
|
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Cannot change scheduler parameters"));
|
2013-05-02 10:13:39 +00:00
|
|
|
goto cleanup;
|
2007-06-05 12:06:08 +00:00
|
|
|
}
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenDaemonGetSchedulerType(dom->conn, nparams);
|
2013-04-30 16:52:19 +00:00
|
|
|
} else {
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenHypervisorGetSchedulerType(dom->conn, nparams);
|
2007-06-05 12:06:08 +00:00
|
|
|
}
|
2013-05-02 10:13:39 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-06-05 12:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-05-17 22:33:53 +00:00
|
|
|
xenUnifiedDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int *nparams,
|
|
|
|
unsigned int flags)
|
2007-06-05 12:06:08 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 10:13:39 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2007-06-05 12:06:08 +00:00
|
|
|
|
2011-05-17 22:33:53 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-02 10:13:39 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:52:19 +00:00
|
|
|
if (dom->id < 0) {
|
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Cannot change scheduler parameters"));
|
2013-05-02 10:13:39 +00:00
|
|
|
goto cleanup;
|
2008-04-10 16:54:54 +00:00
|
|
|
}
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenDaemonGetSchedulerParameters(dom->conn, def, params, nparams);
|
2013-04-30 16:52:19 +00:00
|
|
|
} else {
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenHypervisorGetSchedulerParameters(dom->conn, def, params, nparams);
|
2007-06-05 12:06:08 +00:00
|
|
|
}
|
2013-05-02 10:13:39 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-06-05 12:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-05-17 22:33:53 +00:00
|
|
|
xenUnifiedDomainGetSchedulerParameters(virDomainPtr dom,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int *nparams)
|
|
|
|
{
|
|
|
|
return xenUnifiedDomainGetSchedulerParametersFlags(dom, params,
|
|
|
|
nparams, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int nparams,
|
|
|
|
unsigned int flags)
|
2007-06-05 12:06:08 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 10:13:39 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2007-06-05 12:06:08 +00:00
|
|
|
|
2011-05-17 22:33:53 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-02 10:13:39 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:52:19 +00:00
|
|
|
if (dom->id < 0) {
|
|
|
|
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Cannot change scheduler parameters"));
|
2013-05-02 10:13:39 +00:00
|
|
|
goto cleanup;
|
2008-04-10 16:54:54 +00:00
|
|
|
}
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenDaemonSetSchedulerParameters(dom->conn, def, params, nparams);
|
2013-04-30 16:52:19 +00:00
|
|
|
} else {
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenHypervisorSetSchedulerParameters(dom->conn, def, params, nparams);
|
2007-06-05 12:06:08 +00:00
|
|
|
}
|
2013-05-02 10:13:39 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-06-05 12:06:08 +00:00
|
|
|
}
|
|
|
|
|
2011-05-17 22:33:53 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainSetSchedulerParameters(virDomainPtr dom,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int nparams)
|
|
|
|
{
|
|
|
|
return xenUnifiedDomainSetSchedulerParametersFlags(dom, params,
|
|
|
|
nparams, 0);
|
|
|
|
}
|
|
|
|
|
2007-08-21 10:08:12 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainBlockStats(virDomainPtr dom, const char *path,
|
|
|
|
struct _virDomainBlockStats *stats)
|
2007-08-21 10:08:12 +00:00
|
|
|
{
|
2013-05-02 10:24:49 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenHypervisorDomainBlockStats(dom->conn, def, path, stats);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-08-21 10:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainInterfaceStats(virDomainPtr dom, const char *path,
|
|
|
|
struct _virDomainInterfaceStats *stats)
|
2007-08-21 10:08:12 +00:00
|
|
|
{
|
2013-05-02 10:24:49 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenHypervisorDomainInterfaceStats(def, path, stats);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-08-21 10:08:12 +00:00
|
|
|
}
|
|
|
|
|
virDomainBlockPeek call
* configure.in: Document AC_SYS_LARGEFILE.
* docs/hvsupport.html.in: Document HV support for virDomainBlockPeek.
* include/libvirt/libvirt.h.in, src/driver.h, src/libvirt.c,
src/libvirt_sym.version: Add virDomainBlockPeek infrastructure.
* src/qemu_driver.c, src/test.c: Null versions of this call.
* src/xen_unified.c, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h: Xen implementation.
* tests/sexpr2xmldata/sexpr2xml-curmem.xml,
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml: XML output
has been reordered slightly in the Xen driver, but should be
functionally the same.
2008-06-05 13:17:45 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedDomainBlockPeek(virDomainPtr dom, const char *path,
|
|
|
|
unsigned long long offset, size_t size,
|
|
|
|
void *buffer, unsigned int flags)
|
virDomainBlockPeek call
* configure.in: Document AC_SYS_LARGEFILE.
* docs/hvsupport.html.in: Document HV support for virDomainBlockPeek.
* include/libvirt/libvirt.h.in, src/driver.h, src/libvirt.c,
src/libvirt_sym.version: Add virDomainBlockPeek infrastructure.
* src/qemu_driver.c, src/test.c: Null versions of this call.
* src/xen_unified.c, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h: Xen implementation.
* tests/sexpr2xmldata/sexpr2xml-curmem.xml,
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml: XML output
has been reordered slightly in the Xen driver, but should be
functionally the same.
2008-06-05 13:17:45 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
2013-05-02 10:24:49 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
virDomainBlockPeek call
* configure.in: Document AC_SYS_LARGEFILE.
* docs/hvsupport.html.in: Document HV support for virDomainBlockPeek.
* include/libvirt/libvirt.h.in, src/driver.h, src/libvirt.c,
src/libvirt_sym.version: Add virDomainBlockPeek infrastructure.
* src/qemu_driver.c, src/test.c: Null versions of this call.
* src/xen_unified.c, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h: Xen implementation.
* tests/sexpr2xmldata/sexpr2xml-curmem.xml,
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml: XML output
has been reordered slightly in the Xen driver, but should be
functionally the same.
2008-06-05 13:17:45 +00:00
|
|
|
|
xen: reject unknown flags
Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.
2011-07-06 23:15:33 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2013-05-02 10:24:49 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-30 16:55:18 +00:00
|
|
|
if (dom->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
2013-05-02 10:24:49 +00:00
|
|
|
ret = xenXMDomainBlockPeek(dom->conn, def, path, offset, size, buffer);
|
2013-04-30 16:55:18 +00:00
|
|
|
else
|
2013-05-02 10:24:49 +00:00
|
|
|
ret = xenDaemonDomainBlockPeek(dom->conn, def, path, offset, size, buffer);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
virDomainBlockPeek call
* configure.in: Document AC_SYS_LARGEFILE.
* docs/hvsupport.html.in: Document HV support for virDomainBlockPeek.
* include/libvirt/libvirt.h.in, src/driver.h, src/libvirt.c,
src/libvirt_sym.version: Add virDomainBlockPeek infrastructure.
* src/qemu_driver.c, src/test.c: Null versions of this call.
* src/xen_unified.c, src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h: Xen implementation.
* tests/sexpr2xmldata/sexpr2xml-curmem.xml,
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml: XML output
has been reordered slightly in the Xen driver, but should be
functionally the same.
2008-06-05 13:17:45 +00:00
|
|
|
}
|
|
|
|
|
2007-09-28 14:28:12 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems,
|
|
|
|
int startCell, int maxCells)
|
2007-09-28 14:28:12 +00:00
|
|
|
{
|
2013-04-30 16:55:18 +00:00
|
|
|
return xenHypervisorNodeGetCellsFreeMemory(conn, freeMems,
|
|
|
|
startCell, maxCells);
|
2007-09-28 14:28:12 +00:00
|
|
|
}
|
|
|
|
|
2007-09-30 13:09:07 +00:00
|
|
|
static unsigned long long
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeGetFreeMemory(virConnectPtr conn)
|
2007-09-30 13:09:07 +00:00
|
|
|
{
|
|
|
|
unsigned long long freeMem = 0;
|
|
|
|
|
2013-04-30 16:55:18 +00:00
|
|
|
if (xenHypervisorNodeGetCellsFreeMemory(conn, &freeMem, -1, 1) < 0)
|
|
|
|
return 0;
|
|
|
|
return freeMem;
|
2007-09-30 13:09:07 +00:00
|
|
|
}
|
|
|
|
|
2010-03-18 14:47:07 +00:00
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectDomainEventRegister(virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freefunc)
|
2008-11-25 10:44:52 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2009-01-21 18:11:14 +00:00
|
|
|
|
2009-01-15 01:18:37 +00:00
|
|
|
int ret;
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedLock(priv);
|
2009-01-15 01:18:37 +00:00
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
if (priv->xsWatch == -1) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
2008-11-25 10:44:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
ret = virDomainEventStateRegister(conn, priv->domainEvents,
|
|
|
|
callback, opaque, freefunc);
|
2009-01-15 01:18:37 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
2012-03-22 11:33:35 +00:00
|
|
|
return ret;
|
2008-11-25 10:44:52 +00:00
|
|
|
}
|
|
|
|
|
2010-03-18 14:47:07 +00:00
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectDomainEventDeregister(virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback)
|
2008-11-25 10:44:52 +00:00
|
|
|
{
|
|
|
|
int ret;
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
if (priv->xsWatch == -1) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
2008-11-25 10:44:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
ret = virDomainEventStateDeregister(conn,
|
|
|
|
priv->domainEvents,
|
|
|
|
callback);
|
2009-01-15 01:18:37 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
2008-11-25 10:44:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-04-03 12:38:52 +00:00
|
|
|
|
2010-03-18 14:47:07 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectDomainEventRegisterAny(virConnectPtr conn,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int eventID,
|
|
|
|
virConnectDomainEventGenericCallback callback,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freefunc)
|
2010-03-18 14:47:07 +00:00
|
|
|
{
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2010-03-18 14:47:07 +00:00
|
|
|
|
|
|
|
int ret;
|
|
|
|
xenUnifiedLock(priv);
|
|
|
|
|
|
|
|
if (priv->xsWatch == -1) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
2010-03-18 14:47:07 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-12-13 11:14:46 +00:00
|
|
|
if (virDomainEventStateRegisterID(conn, priv->domainEvents,
|
|
|
|
dom, eventID,
|
|
|
|
callback, opaque, freefunc, &ret) < 0)
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
ret = -1;
|
2010-03-18 14:47:07 +00:00
|
|
|
|
|
|
|
xenUnifiedUnlock(priv);
|
2012-03-22 11:33:35 +00:00
|
|
|
return ret;
|
2010-03-18 14:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
xenUnifiedConnectDomainEventDeregisterAny(virConnectPtr conn,
|
|
|
|
int callbackID)
|
2010-03-18 14:47:07 +00:00
|
|
|
{
|
|
|
|
int ret;
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2010-03-18 14:47:07 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
|
|
|
|
if (priv->xsWatch == -1) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
2010-03-18 14:47:07 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
ret = virDomainEventStateDeregisterID(conn,
|
|
|
|
priv->domainEvents,
|
|
|
|
callbackID);
|
2010-03-18 14:47:07 +00:00
|
|
|
|
|
|
|
xenUnifiedUnlock(priv);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-03 12:38:52 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeDeviceGetPciInfo(virNodeDevicePtr dev,
|
|
|
|
unsigned *domain,
|
|
|
|
unsigned *bus,
|
|
|
|
unsigned *slot,
|
|
|
|
unsigned *function)
|
2009-04-03 12:38:52 +00:00
|
|
|
{
|
|
|
|
virNodeDeviceDefPtr def = NULL;
|
|
|
|
virNodeDevCapsDefPtr cap;
|
|
|
|
char *xml = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
xml = virNodeDeviceGetXMLDesc(dev, 0);
|
|
|
|
if (!xml)
|
|
|
|
goto out;
|
|
|
|
|
2012-02-10 04:51:47 +00:00
|
|
|
def = virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL);
|
2009-04-03 12:38:52 +00:00
|
|
|
if (!def)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
cap = def->caps;
|
|
|
|
while (cap) {
|
|
|
|
if (cap->type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
|
|
|
*domain = cap->data.pci_dev.domain;
|
|
|
|
*bus = cap->data.pci_dev.bus;
|
|
|
|
*slot = cap->data.pci_dev.slot;
|
|
|
|
*function = cap->data.pci_dev.function;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cap = cap->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cap) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("device %s is not a PCI device"), dev->name);
|
2009-04-03 12:38:52 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
out:
|
|
|
|
virNodeDeviceDefFree(def);
|
|
|
|
VIR_FREE(xml);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-24 18:06:42 +00:00
|
|
|
xenUnifiedNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
|
|
|
const char *driverName,
|
|
|
|
unsigned int flags)
|
2009-04-03 12:38:52 +00:00
|
|
|
{
|
2013-01-14 22:11:44 +00:00
|
|
|
virPCIDevicePtr pci;
|
2009-04-03 12:38:52 +00:00
|
|
|
unsigned domain, bus, slot, function;
|
|
|
|
int ret = -1;
|
|
|
|
|
2013-04-24 18:06:42 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2009-04-03 12:38:52 +00:00
|
|
|
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
2009-04-03 12:38:52 +00:00
|
|
|
if (!pci)
|
|
|
|
return -1;
|
|
|
|
|
2013-04-24 18:06:42 +00:00
|
|
|
if (!driverName) {
|
|
|
|
virPCIDeviceSetStubDriver(pci, "pciback");
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unknown driver name '%s'"), driverName);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virPCIDeviceDetach(pci, NULL, NULL, NULL) < 0)
|
2009-04-03 12:38:52 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
out:
|
2013-01-14 22:11:44 +00:00
|
|
|
virPCIDeviceFree(pci);
|
2009-04-03 12:38:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-04-24 18:06:42 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
|
|
|
|
{
|
|
|
|
return xenUnifiedNodeDeviceDetachFlags(dev, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2011-04-27 12:09:12 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev)
|
2011-04-27 12:09:12 +00:00
|
|
|
{
|
|
|
|
int numdomains;
|
|
|
|
int ret = -1, i;
|
|
|
|
int *ids = NULL;
|
|
|
|
char *bdf = NULL;
|
|
|
|
char *xref = NULL;
|
|
|
|
unsigned int domain, bus, slot, function;
|
|
|
|
virConnectPtr conn = dev->conn;
|
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
|
|
|
|
|
|
|
/* Get active domains */
|
2013-04-23 12:50:18 +00:00
|
|
|
numdomains = xenUnifiedConnectNumOfDomains(conn);
|
2011-04-27 12:09:12 +00:00
|
|
|
if (numdomains < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (numdomains > 0){
|
|
|
|
if (VIR_ALLOC_N(ids, numdomains) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto out;
|
|
|
|
}
|
2013-04-23 12:50:18 +00:00
|
|
|
if ((numdomains = xenUnifiedConnectListDomains(conn, &ids[0], numdomains)) < 0) {
|
2011-04-27 12:09:12 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get pci bdf */
|
|
|
|
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (virAsprintf(&bdf, "%04x:%02x:%02x.%0x",
|
|
|
|
domain, bus, slot, function) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
xenUnifiedLock(priv);
|
|
|
|
/* Check if bdf is assigned to one of active domains */
|
2012-10-17 09:23:12 +00:00
|
|
|
for (i = 0; i < numdomains; i++) {
|
2011-04-27 12:09:12 +00:00
|
|
|
xref = xenStoreDomainGetPCIID(conn, ids[i], bdf);
|
|
|
|
if (xref == NULL) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
ret = ids[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xenUnifiedUnlock(priv);
|
|
|
|
|
|
|
|
VIR_FREE(xref);
|
|
|
|
VIR_FREE(bdf);
|
|
|
|
out:
|
|
|
|
VIR_FREE(ids);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-04-03 12:38:52 +00:00
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeDeviceReAttach(virNodeDevicePtr dev)
|
2009-04-03 12:38:52 +00:00
|
|
|
{
|
2013-01-14 22:11:44 +00:00
|
|
|
virPCIDevicePtr pci;
|
2009-04-03 12:38:52 +00:00
|
|
|
unsigned domain, bus, slot, function;
|
|
|
|
int ret = -1;
|
2011-04-27 12:09:12 +00:00
|
|
|
int domid;
|
2009-04-03 12:38:52 +00:00
|
|
|
|
|
|
|
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
2009-04-03 12:38:52 +00:00
|
|
|
if (!pci)
|
|
|
|
return -1;
|
|
|
|
|
2011-04-27 12:09:12 +00:00
|
|
|
/* Check if device is assigned to an active guest */
|
|
|
|
if ((domid = xenUnifiedNodeDeviceAssignedDomainId(dev)) >= 0) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Device %s has been assigned to guest %d"),
|
|
|
|
dev->name, domid);
|
2011-04-27 12:09:12 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
pci: autolearn name of stub driver, remove from arglist
virPCIDeviceReattach and virPCIDeviceUnbindFromStub (called by
virPCIDeviceReattach) had previously required the name of the stub
driver as input. This is unnecessary, because the name of the driver
the device is currently bound to can be found by looking at the link:
/sys/bus/pci/dddd:bb:ss.ff/driver
Instead of requiring that the name of the expected stub driver name
and only unbinding if that one name is matched, we no longer take a
driver name in the arglist for either of these
functions. virPCIDeviceUnbindFromStub just compares the name of the
currently bound driver to a list of "well known" stubs (right now
contains "pci-stub" and "vfio-pci" for qemu, and "pciback" for xen),
and only performs the unbind if it's one of those devices.
This allows virsh nodedevice-reattach to work properly across a
libvirtd restart, and fixes a couple of cases where we were
erroneously still hard-coding "pci-stub" as the drive name.
For some unknown reason, virPCIDeviceReattach had been calling
modprobe on the stub driver prior to unbinding the device. This was
problematic because we no longer know the name of the stub driver in
that function. However, it is pointless to probe for the stub driver
at that time anyway - because the device is bound to the stub driver,
we are guaranteed that it is already loaded, and so that call to
modprobe has been removed.
2013-05-01 18:44:10 +00:00
|
|
|
if (virPCIDeviceReattach(pci, NULL, NULL) < 0)
|
2009-04-03 12:38:52 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
out:
|
2013-01-14 22:11:44 +00:00
|
|
|
virPCIDeviceFree(pci);
|
2009-04-03 12:38:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedNodeDeviceReset(virNodeDevicePtr dev)
|
2009-04-03 12:38:52 +00:00
|
|
|
{
|
2013-01-14 22:11:44 +00:00
|
|
|
virPCIDevicePtr pci;
|
2009-04-03 12:38:52 +00:00
|
|
|
unsigned domain, bus, slot, function;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
pci = virPCIDeviceNew(domain, bus, slot, function);
|
2009-04-03 12:38:52 +00:00
|
|
|
if (!pci)
|
|
|
|
return -1;
|
|
|
|
|
2013-01-14 22:11:44 +00:00
|
|
|
if (virPCIDeviceReset(pci, NULL, NULL) < 0)
|
2009-04-03 12:38:52 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
out:
|
2013-01-14 22:11:44 +00:00
|
|
|
virPCIDeviceFree(pci);
|
2009-04-03 12:38:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-22 13:40:26 +00:00
|
|
|
static int
|
|
|
|
xenUnifiedDomainOpenConsole(virDomainPtr dom,
|
2011-09-16 12:05:58 +00:00
|
|
|
const char *dev_name,
|
2010-10-22 13:40:26 +00:00
|
|
|
virStreamPtr st,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
virDomainChrDefPtr chr = NULL;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
if (dom->id == -1) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
"%s", _("domain is not running"));
|
2010-10-22 13:40:26 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-09-16 12:05:58 +00:00
|
|
|
if (dev_name) {
|
2010-10-22 13:40:26 +00:00
|
|
|
/* XXX support device aliases in future */
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Named device aliases are not supported"));
|
2010-10-22 13:40:26 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
def = xenDaemonDomainFetch(dom->conn, dom->id, dom->name, NULL);
|
|
|
|
if (!def)
|
|
|
|
goto cleanup;
|
|
|
|
|
Allow multiple consoles per virtual guest
While Xen only has a single paravirt console, UML, and
QEMU both support multiple paravirt consoles. The LXC
driver can also be trivially made to support multiple
consoles. This patch extends the XML to allow multiple
<console> elements in the XML. It also makes the UML
and QEMU drivers support this config.
* src/conf/domain_conf.c, src/conf/domain_conf.h: Allow
multiple <console> devices
* src/lxc/lxc_driver.c, src/xen/xen_driver.c,
src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c: Update for
internal API changes
* src/security/security_selinux.c, src/security/virt-aa-helper.c:
Only label consoles that aren't a copy of the serial device
* src/qemu/qemu_command.c, src/qemu/qemu_driver.c,
src/qemu/qemu_process.c, src/uml/uml_conf.c,
src/uml/uml_driver.c: Support multiple console devices
* tests/qemuxml2xmltest.c, tests/qemuxml2argvtest.c: Extra
tests for multiple virtio consoles. Set QEMU_CAPS_CHARDEV
for all console /channel tests
* tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.args,
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.args
tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args: Update
for correct chardev syntax
* tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.args,
tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml: New
test file
2011-02-23 18:27:23 +00:00
|
|
|
if (def->nconsoles)
|
|
|
|
chr = def->consoles[0];
|
2010-10-22 13:40:26 +00:00
|
|
|
else if (def->nserials)
|
|
|
|
chr = def->serials[0];
|
|
|
|
|
|
|
|
if (!chr) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("cannot find default console device"));
|
2010-10-22 13:40:26 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
domain_conf: split source data out from ChrDef
This opens up the possibility of reusing the smaller ChrSourceDef
for both qemu monitor and a passthrough smartcard device.
* src/conf/domain_conf.h (_virDomainChrDef): Factor host
details...
(_virDomainChrSourceDef): ...into new struct.
(virDomainChrSourceDefFree): New prototype.
* src/conf/domain_conf.c (virDomainChrDefFree)
(virDomainChrDefParseXML, virDomainChrDefFormat): Split...
(virDomainChrSourceDefClear, virDomainChrSourceDefFree)
(virDomainChrSourceDefParseXML, virDomainChrSourceDefFormat):
...into new functions.
(virDomainChrDefParseTargetXML): Update clients to reflect type
split.
* src/vmx/vmx.c (virVMXParseSerial, virVMXParseParallel)
(virVMXFormatSerial, virVMXFormatParallel): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.
* src/xen/xend_internal.c (xenDaemonParseSxprChar)
(xenDaemonFormatSxprChr): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainDumpXML, vboxAttachSerial)
(vboxAttachParallel): Likewise.
* src/security/security_dac.c (virSecurityDACSetChardevLabel)
(virSecurityDACSetChardevCallback)
(virSecurityDACRestoreChardevLabel)
(virSecurityDACRestoreChardevCallback): Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback)
(SELinuxRestoreSecurityChardevLabel)
(SELinuxSetSecurityChardevCallback): Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
* src/lxc/lxc_driver.c (lxcVmStart, lxcDomainOpenConsole):
Likewise.
* src/uml/uml_conf.c (umlBuildCommandLineChr): Likewise.
* src/uml/uml_driver.c (umlIdentifyOneChrPTY, umlIdentifyChrPTY)
(umlDomainOpenConsole): Likewise.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildChrArgStr, qemuBuildCommandLine)
(qemuParseCommandLineChr): Likewise.
* src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLFormat)
(qemuDomainObjPrivateXMLParse): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupChardevCgroup): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/qemu/qemu_driver.c (qemudFindCharDevicePTYsMonitor)
(qemudFindCharDevicePTYs, qemuPrepareChardevDevice)
(qemuPrepareMonitorChr, qemudShutdownVMDaemon)
(qemuDomainOpenConsole): Likewise.
* src/qemu/qemu_command.h (qemuBuildChrChardevStr)
(qemuBuildChrArgStr): Delete, now that they are static.
* src/libvirt_private.syms (domain_conf.h): New exports.
* cfg.mk (useless_free_options): Update list.
* tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Update
tests.
2011-01-07 22:45:01 +00:00
|
|
|
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("character device %s is not using a PTY"), dev_name);
|
2010-10-22 13:40:26 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2011-04-05 10:27:35 +00:00
|
|
|
if (virFDStreamOpenFile(st, chr->source.data.file.path,
|
2011-08-02 17:19:53 +00:00
|
|
|
0, 0, O_RDWR) < 0)
|
2010-10-22 13:40:26 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
|
|
|
}
|
2013-04-26 17:21:58 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedNodeGetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int *nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
return nodeGetMemoryParameters(params, nparams, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedNodeSetMemoryParameters(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virTypedParameterPtr params,
|
|
|
|
int nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
return nodeSetMemoryParameters(params, nparams, flags);
|
|
|
|
}
|
|
|
|
|
2013-04-29 09:16:56 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedNodeSuspendForDuration(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int target,
|
|
|
|
unsigned long long duration,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
return nodeSuspendForDuration(target, duration, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-07 15:12:02 +00:00
|
|
|
/*----- Register with libvirt.c, and initialize Xen drivers. -----*/
|
2007-04-04 14:19:49 +00:00
|
|
|
|
|
|
|
/* The interface which we export upwards to libvirt.c. */
|
|
|
|
static virDriver xenUnifiedDriver = {
|
Convert all driver struct intializers to C99 style
Change all the driver struct initializers to use the
C99 style, leaving out unused fields. This will make
it possible to add new APIs without changing every
driver. eg change:
qemudDomainResume, /* domainResume */
qemudDomainShutdown, /* domainShutdown */
NULL, /* domainReboot */
qemudDomainDestroy, /* domainDestroy */
to
.domainResume = qemudDomainResume,
.domainShutdown = qemudDomainShutdown,
.domainDestroy = qemudDomainDestroy,
And get rid of any existing C99 style initializersr which
set NULL, eg change
.listPools = vboxStorageListPools,
.numOfDefinedPools = NULL,
.listDefinedPools = NULL,
.findPoolSources = NULL,
.poolLookupByName = vboxStoragePoolLookupByName,
to
.listPools = vboxStorageListPools,
.poolLookupByName = vboxStoragePoolLookupByName,
2011-05-13 10:16:31 +00:00
|
|
|
.no = VIR_DRV_XEN_UNIFIED,
|
|
|
|
.name = "Xen",
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectOpen = xenUnifiedConnectOpen, /* 0.0.3 */
|
|
|
|
.connectClose = xenUnifiedConnectClose, /* 0.0.3 */
|
|
|
|
.connectSupportsFeature = xenUnifiedConnectSupportsFeature, /* 0.3.2 */
|
|
|
|
.connectGetType = xenUnifiedConnectGetType, /* 0.0.3 */
|
|
|
|
.connectGetVersion = xenUnifiedConnectGetVersion, /* 0.0.3 */
|
2013-04-26 16:39:11 +00:00
|
|
|
.connectGetHostname = xenUnifiedConnectGetHostname, /* 0.7.3 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectGetMaxVcpus = xenUnifiedConnectGetMaxVcpus, /* 0.2.1 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.nodeGetInfo = xenUnifiedNodeGetInfo, /* 0.1.0 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectGetCapabilities = xenUnifiedConnectGetCapabilities, /* 0.2.1 */
|
|
|
|
.connectListDomains = xenUnifiedConnectListDomains, /* 0.0.3 */
|
|
|
|
.connectNumOfDomains = xenUnifiedConnectNumOfDomains, /* 0.0.3 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainCreateXML = xenUnifiedDomainCreateXML, /* 0.0.3 */
|
|
|
|
.domainLookupByID = xenUnifiedDomainLookupByID, /* 0.0.3 */
|
|
|
|
.domainLookupByUUID = xenUnifiedDomainLookupByUUID, /* 0.0.5 */
|
|
|
|
.domainLookupByName = xenUnifiedDomainLookupByName, /* 0.0.3 */
|
|
|
|
.domainSuspend = xenUnifiedDomainSuspend, /* 0.0.3 */
|
|
|
|
.domainResume = xenUnifiedDomainResume, /* 0.0.3 */
|
|
|
|
.domainShutdown = xenUnifiedDomainShutdown, /* 0.0.3 */
|
2011-10-05 17:31:55 +00:00
|
|
|
.domainShutdownFlags = xenUnifiedDomainShutdownFlags, /* 0.9.10 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainReboot = xenUnifiedDomainReboot, /* 0.1.0 */
|
|
|
|
.domainDestroy = xenUnifiedDomainDestroy, /* 0.0.3 */
|
2011-07-21 08:19:59 +00:00
|
|
|
.domainDestroyFlags = xenUnifiedDomainDestroyFlags, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainGetOSType = xenUnifiedDomainGetOSType, /* 0.0.3 */
|
|
|
|
.domainGetMaxMemory = xenUnifiedDomainGetMaxMemory, /* 0.0.3 */
|
|
|
|
.domainSetMaxMemory = xenUnifiedDomainSetMaxMemory, /* 0.0.3 */
|
|
|
|
.domainSetMemory = xenUnifiedDomainSetMemory, /* 0.1.1 */
|
|
|
|
.domainGetInfo = xenUnifiedDomainGetInfo, /* 0.0.3 */
|
|
|
|
.domainGetState = xenUnifiedDomainGetState, /* 0.9.2 */
|
|
|
|
.domainSave = xenUnifiedDomainSave, /* 0.0.3 */
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
.domainSaveFlags = xenUnifiedDomainSaveFlags, /* 0.9.4 */
|
2012-12-04 10:00:02 +00:00
|
|
|
.domainManagedSave = xenUnifiedDomainManagedSave, /* 1.0.1 */
|
|
|
|
.domainHasManagedSaveImage = xenUnifiedDomainHasManagedSaveImage, /* 1.0.1 */
|
|
|
|
.domainManagedSaveRemove = xenUnifiedDomainManagedSaveRemove, /* 1.0.1 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainRestore = xenUnifiedDomainRestore, /* 0.0.3 */
|
save: wire up trivial save/restore flags implementations
For all hypervisors that support save and restore, the new API
now performs the same functions as the old.
VBox is excluded from this list, because its existing domainsave
is broken (there is no corresponding domainrestore, and there
is no control over the filename used in the save). A later
patch should change vbox to use its implementation for
managedsave, and teach start to use managedsave results.
* src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
(libxlDomainSaveFlags): ...to new function.
(libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
(testDomainRestore, testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSave)
(xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
Rename and move guts.
(qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
(qemuDomainRestoreFlags): ...here.
(qemudDomainSaveFlag): Rename...
(qemuDomainSaveInternal): ...to this, and update callers.
2011-07-09 02:55:29 +00:00
|
|
|
.domainRestoreFlags = xenUnifiedDomainRestoreFlags, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainCoreDump = xenUnifiedDomainCoreDump, /* 0.1.9 */
|
|
|
|
.domainSetVcpus = xenUnifiedDomainSetVcpus, /* 0.1.4 */
|
|
|
|
.domainSetVcpusFlags = xenUnifiedDomainSetVcpusFlags, /* 0.8.5 */
|
|
|
|
.domainGetVcpusFlags = xenUnifiedDomainGetVcpusFlags, /* 0.8.5 */
|
|
|
|
.domainPinVcpu = xenUnifiedDomainPinVcpu, /* 0.1.4 */
|
|
|
|
.domainGetVcpus = xenUnifiedDomainGetVcpus, /* 0.1.4 */
|
|
|
|
.domainGetMaxVcpus = xenUnifiedDomainGetMaxVcpus, /* 0.2.1 */
|
|
|
|
.domainGetXMLDesc = xenUnifiedDomainGetXMLDesc, /* 0.0.3 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectDomainXMLFromNative = xenUnifiedConnectDomainXMLFromNative, /* 0.6.4 */
|
|
|
|
.connectDomainXMLToNative = xenUnifiedConnectDomainXMLToNative, /* 0.6.4 */
|
|
|
|
.connectListDefinedDomains = xenUnifiedConnectListDefinedDomains, /* 0.1.1 */
|
|
|
|
.connectNumOfDefinedDomains = xenUnifiedConnectNumOfDefinedDomains, /* 0.1.5 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainCreate = xenUnifiedDomainCreate, /* 0.1.1 */
|
|
|
|
.domainCreateWithFlags = xenUnifiedDomainCreateWithFlags, /* 0.8.2 */
|
|
|
|
.domainDefineXML = xenUnifiedDomainDefineXML, /* 0.1.1 */
|
|
|
|
.domainUndefine = xenUnifiedDomainUndefine, /* 0.1.1 */
|
2011-07-20 03:08:21 +00:00
|
|
|
.domainUndefineFlags = xenUnifiedDomainUndefineFlags, /* 0.9.4 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainAttachDevice = xenUnifiedDomainAttachDevice, /* 0.1.9 */
|
|
|
|
.domainAttachDeviceFlags = xenUnifiedDomainAttachDeviceFlags, /* 0.7.7 */
|
|
|
|
.domainDetachDevice = xenUnifiedDomainDetachDevice, /* 0.1.9 */
|
|
|
|
.domainDetachDeviceFlags = xenUnifiedDomainDetachDeviceFlags, /* 0.7.7 */
|
|
|
|
.domainUpdateDeviceFlags = xenUnifiedDomainUpdateDeviceFlags, /* 0.8.0 */
|
|
|
|
.domainGetAutostart = xenUnifiedDomainGetAutostart, /* 0.4.4 */
|
|
|
|
.domainSetAutostart = xenUnifiedDomainSetAutostart, /* 0.4.4 */
|
|
|
|
.domainGetSchedulerType = xenUnifiedDomainGetSchedulerType, /* 0.2.3 */
|
|
|
|
.domainGetSchedulerParameters = xenUnifiedDomainGetSchedulerParameters, /* 0.2.3 */
|
2011-05-17 22:33:53 +00:00
|
|
|
.domainGetSchedulerParametersFlags = xenUnifiedDomainGetSchedulerParametersFlags, /* 0.9.2 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainSetSchedulerParameters = xenUnifiedDomainSetSchedulerParameters, /* 0.2.3 */
|
2011-05-17 22:33:53 +00:00
|
|
|
.domainSetSchedulerParametersFlags = xenUnifiedDomainSetSchedulerParametersFlags, /* 0.9.2 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainMigratePrepare = xenUnifiedDomainMigratePrepare, /* 0.3.2 */
|
|
|
|
.domainMigratePerform = xenUnifiedDomainMigratePerform, /* 0.3.2 */
|
|
|
|
.domainMigrateFinish = xenUnifiedDomainMigrateFinish, /* 0.3.2 */
|
|
|
|
.domainBlockStats = xenUnifiedDomainBlockStats, /* 0.3.2 */
|
|
|
|
.domainInterfaceStats = xenUnifiedDomainInterfaceStats, /* 0.3.2 */
|
|
|
|
.domainBlockPeek = xenUnifiedDomainBlockPeek, /* 0.4.4 */
|
|
|
|
.nodeGetCellsFreeMemory = xenUnifiedNodeGetCellsFreeMemory, /* 0.3.3 */
|
|
|
|
.nodeGetFreeMemory = xenUnifiedNodeGetFreeMemory, /* 0.3.3 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectDomainEventRegister = xenUnifiedConnectDomainEventRegister, /* 0.5.0 */
|
|
|
|
.connectDomainEventDeregister = xenUnifiedConnectDomainEventDeregister, /* 0.5.0 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.nodeDeviceDettach = xenUnifiedNodeDeviceDettach, /* 0.6.1 */
|
2013-04-24 18:06:42 +00:00
|
|
|
.nodeDeviceDetachFlags = xenUnifiedNodeDeviceDetachFlags, /* 1.0.5 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.nodeDeviceReAttach = xenUnifiedNodeDeviceReAttach, /* 0.6.1 */
|
|
|
|
.nodeDeviceReset = xenUnifiedNodeDeviceReset, /* 0.6.1 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectIsEncrypted = xenUnifiedConnectIsEncrypted, /* 0.7.3 */
|
|
|
|
.connectIsSecure = xenUnifiedConnectIsSecure, /* 0.7.3 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainIsActive = xenUnifiedDomainIsActive, /* 0.7.3 */
|
|
|
|
.domainIsPersistent = xenUnifiedDomainIsPersistent, /* 0.7.3 */
|
|
|
|
.domainIsUpdated = xenUnifiedDomainIsUpdated, /* 0.8.6 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectDomainEventRegisterAny = xenUnifiedConnectDomainEventRegisterAny, /* 0.8.0 */
|
|
|
|
.connectDomainEventDeregisterAny = xenUnifiedConnectDomainEventDeregisterAny, /* 0.8.0 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.domainOpenConsole = xenUnifiedDomainOpenConsole, /* 0.8.6 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectIsAlive = xenUnifiedConnectIsAlive, /* 0.9.8 */
|
2013-04-29 09:16:56 +00:00
|
|
|
.nodeSuspendForDuration = xenUnifiedNodeSuspendForDuration, /* 0.9.8 */
|
2013-04-26 17:21:58 +00:00
|
|
|
.nodeGetMemoryParameters = xenUnifiedNodeGetMemoryParameters, /* 0.10.2 */
|
|
|
|
.nodeSetMemoryParameters = xenUnifiedNodeSetMemoryParameters, /* 0.10.2 */
|
2007-04-04 14:19:49 +00:00
|
|
|
};
|
|
|
|
|
2007-04-10 13:00:26 +00:00
|
|
|
/**
|
2008-11-21 12:16:08 +00:00
|
|
|
* xenRegister:
|
2007-04-10 13:00:26 +00:00
|
|
|
*
|
|
|
|
* Register xen related drivers
|
|
|
|
*
|
|
|
|
* Returns the driver priority or -1 in case of error.
|
|
|
|
*/
|
2007-04-04 14:19:49 +00:00
|
|
|
int
|
2012-10-17 09:23:12 +00:00
|
|
|
xenRegister(void)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2012-10-17 09:23:12 +00:00
|
|
|
if (virRegisterStateDriver(&state_driver) == -1) return -1;
|
2009-01-22 17:49:41 +00:00
|
|
|
|
2012-10-17 09:23:12 +00:00
|
|
|
return virRegisterDriver(&xenUnifiedDriver);
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
/**
|
|
|
|
* xenUnifiedDomainInfoListFree:
|
|
|
|
*
|
|
|
|
* Free the Domain Info List
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr list)
|
|
|
|
{
|
|
|
|
int i;
|
2009-01-15 01:21:36 +00:00
|
|
|
|
|
|
|
if (list == NULL)
|
|
|
|
return;
|
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
for (i=0; i<list->count; i++) {
|
|
|
|
VIR_FREE(list->doms[i]->name);
|
|
|
|
VIR_FREE(list->doms[i]);
|
|
|
|
}
|
2010-07-29 13:41:33 +00:00
|
|
|
VIR_FREE(list->doms);
|
2008-11-25 10:44:52 +00:00
|
|
|
VIR_FREE(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xenUnifiedAddDomainInfo:
|
|
|
|
*
|
|
|
|
* Add name and uuid to the domain info list
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr list,
|
|
|
|
int id, char *name,
|
|
|
|
unsigned char *uuid)
|
|
|
|
{
|
|
|
|
xenUnifiedDomainInfoPtr info;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* check if we already have this callback on our list */
|
|
|
|
for (n=0; n < list->count; n++) {
|
|
|
|
if (STREQ(list->doms[n]->name, name) &&
|
|
|
|
!memcmp(list->doms[n]->uuid, uuid, VIR_UUID_BUFLEN)) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("WARNING: dom already tracked");
|
2008-11-25 10:44:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC(info) < 0)
|
|
|
|
goto memory_error;
|
2013-05-03 12:51:25 +00:00
|
|
|
if (VIR_STRDUP(info->name, name) < 0)
|
|
|
|
goto error;
|
2008-11-25 10:44:52 +00:00
|
|
|
|
|
|
|
memcpy(info->uuid, uuid, VIR_UUID_BUFLEN);
|
|
|
|
info->id = id;
|
|
|
|
|
|
|
|
/* Make space on list */
|
|
|
|
n = list->count;
|
|
|
|
if (VIR_REALLOC_N(list->doms, n + 1) < 0) {
|
|
|
|
goto memory_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
list->doms[n] = info;
|
|
|
|
list->count++;
|
|
|
|
return 0;
|
|
|
|
memory_error:
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2013-05-03 12:51:25 +00:00
|
|
|
error:
|
2008-11-25 10:44:52 +00:00
|
|
|
if (info)
|
|
|
|
VIR_FREE(info->name);
|
|
|
|
VIR_FREE(info);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xenUnifiedRemoveDomainInfo:
|
|
|
|
*
|
|
|
|
* Removes name and uuid to the domain info list
|
|
|
|
*
|
|
|
|
* Returns: 0 on success, -1 on failure
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
xenUnifiedRemoveDomainInfo(xenUnifiedDomainInfoListPtr list,
|
|
|
|
int id, char *name,
|
|
|
|
unsigned char *uuid)
|
|
|
|
{
|
|
|
|
int i;
|
2013-05-21 07:21:21 +00:00
|
|
|
for (i = 0; i < list->count; i++) {
|
2012-10-17 09:23:12 +00:00
|
|
|
if (list->doms[i]->id == id &&
|
2008-11-25 10:44:52 +00:00
|
|
|
STREQ(list->doms[i]->name, name) &&
|
|
|
|
!memcmp(list->doms[i]->uuid, uuid, VIR_UUID_BUFLEN)) {
|
|
|
|
|
|
|
|
VIR_FREE(list->doms[i]->name);
|
|
|
|
VIR_FREE(list->doms[i]);
|
|
|
|
|
|
|
|
if (i < (list->count - 1))
|
|
|
|
memmove(list->doms + i,
|
|
|
|
list->doms + i + 1,
|
|
|
|
sizeof(*(list->doms)) *
|
|
|
|
(list->count - (i + 1)));
|
|
|
|
|
|
|
|
if (VIR_REALLOC_N(list->doms,
|
|
|
|
list->count - 1) < 0) {
|
|
|
|
; /* Failure to reduce memory allocation isn't fatal */
|
|
|
|
}
|
|
|
|
list->count--;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
/**
|
|
|
|
* xenUnifiedDomainEventDispatch:
|
2009-01-21 18:11:14 +00:00
|
|
|
* @priv: the connection to dispatch events on
|
|
|
|
* @event: the event to dispatch
|
2008-11-25 10:44:52 +00:00
|
|
|
*
|
|
|
|
* Dispatch domain events to registered callbacks
|
|
|
|
*
|
2009-01-21 18:11:14 +00:00
|
|
|
* The caller must hold the lock in 'priv' before invoking
|
|
|
|
*
|
2008-11-25 10:44:52 +00:00
|
|
|
*/
|
2012-10-17 09:23:12 +00:00
|
|
|
void xenUnifiedDomainEventDispatch(xenUnifiedPrivatePtr priv,
|
2008-12-04 21:09:20 +00:00
|
|
|
virDomainEventPtr event)
|
2008-11-25 10:44:52 +00:00
|
|
|
{
|
2009-01-21 18:11:14 +00:00
|
|
|
if (!priv)
|
2008-12-04 21:09:20 +00:00
|
|
|
return;
|
2008-11-25 10:44:52 +00:00
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
virDomainEventStateQueue(priv->domainEvents, event);
|
2009-01-21 18:11:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void xenUnifiedLock(xenUnifiedPrivatePtr priv)
|
|
|
|
{
|
|
|
|
virMutexLock(&priv->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void xenUnifiedUnlock(xenUnifiedPrivatePtr priv)
|
|
|
|
{
|
|
|
|
virMutexUnlock(&priv->lock);
|
2008-11-25 10:44:52 +00:00
|
|
|
}
|