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
|
|
|
*
|
2015-05-08 16:55:00 +00:00
|
|
|
* Copyright (C) 2007-2015 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"
|
2016-01-11 11:40:32 +00:00
|
|
|
#include "xen_common.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"
|
2017-03-07 09:34:47 +00:00
|
|
|
#include "virfdstream.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"
|
2016-04-13 17:53:02 +00:00
|
|
|
#include "virhostmem.h"
|
2012-12-04 10:00:02 +00:00
|
|
|
#include "configmake.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2013-04-23 10:56:22 +00:00
|
|
|
#include "viraccessapicheck.h"
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_XEN
|
2014-02-28 12:16:17 +00:00
|
|
|
|
|
|
|
VIR_LOG_INIT("xen.xen_driver");
|
|
|
|
|
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);
|
2013-08-06 11:28:58 +00:00
|
|
|
|
2007-10-31 09:39:13 +00:00
|
|
|
static int
|
2013-08-06 11:28:58 +00:00
|
|
|
xenUnifiedDomainGetVcpusFlagsInternal(virDomainPtr dom,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2007-10-31 09:39:13 +00:00
|
|
|
static int
|
2013-08-06 11:28:58 +00:00
|
|
|
xenUnifiedDomainGetVcpusInternal(virDomainPtr dom,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
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
|
|
|
|
2014-10-28 18:38:04 +00:00
|
|
|
static bool is_privileged;
|
|
|
|
static virSysinfoDefPtr hostsysinfo;
|
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)
|
|
|
|
{
|
|
|
|
virDomainDefPtr ret;
|
|
|
|
|
|
|
|
ret = xenDaemonLookupByName(conn, name);
|
|
|
|
|
|
|
|
if (!ret && virGetLastError() == NULL)
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN, __FUNCTION__);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virDomainDefPtr xenGetDomainDefForUUID(virConnectPtr conn, const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
virDomainDefPtr ret;
|
|
|
|
|
|
|
|
ret = xenHypervisorLookupDomainByUUID(conn, uuid);
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
/* Try xend for inactive domains. */
|
|
|
|
if (!ret)
|
|
|
|
ret = xenDaemonLookupByUUID(conn, uuid);
|
2013-05-01 09:31:23 +00:00
|
|
|
|
|
|
|
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
|
2014-03-18 08:14:16 +00:00
|
|
|
xenNumaInit(virConnectPtr conn)
|
|
|
|
{
|
2007-10-22 20:28:55 +00:00
|
|
|
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
|
2013-08-06 11:28:58 +00:00
|
|
|
* @def: the domain definition
|
2007-10-31 09:39:13 +00:00
|
|
|
*
|
|
|
|
* 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 *
|
2013-08-06 11:28:58 +00:00
|
|
|
xenDomainUsedCpus(virDomainPtr dom, virDomainDefPtr def)
|
2007-10-31 09:39:13 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
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;
|
2013-08-06 11:28:58 +00:00
|
|
|
nb_vcpu = xenUnifiedDomainGetVcpusFlagsInternal(dom, def,
|
|
|
|
(VIR_DOMAIN_VCPU_LIVE |
|
|
|
|
VIR_DOMAIN_VCPU_MAXIMUM));
|
2007-10-31 09:39:13 +00:00
|
|
|
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
|
|
|
|
2013-07-04 10:18:49 +00:00
|
|
|
if (!(cpulist = virBitmapNew(priv->nbNodeCpus)))
|
2007-10-31 09:39:13 +00:00
|
|
|
goto done;
|
2013-07-04 10:18:49 +00:00
|
|
|
if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0)
|
2007-10-31 09:39:13 +00:00
|
|
|
goto done;
|
|
|
|
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
|
2008-06-06 11:09:57 +00:00
|
|
|
if (xalloc_oversized(nb_vcpu, cpumaplen) ||
|
2013-07-04 10:18:49 +00:00
|
|
|
VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0)
|
2007-10-31 09:39:13 +00:00
|
|
|
goto done;
|
|
|
|
|
2013-08-06 11:28:58 +00:00
|
|
|
if ((ncpus = xenUnifiedDomainGetVcpusInternal(dom, def, 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++) {
|
2015-03-11 15:41:57 +00:00
|
|
|
if (!virBitmapIsBitSet(cpulist, m) &&
|
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
|
|
|
}
|
|
|
|
|
2014-03-25 06:54:51 +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 */
|
2013-06-12 17:21:21 +00:00
|
|
|
if (privileged) {
|
2013-04-30 13:41:48 +00:00
|
|
|
is_privileged = true;
|
2013-06-12 17:21:21 +00:00
|
|
|
hostsysinfo = virSysinfoRead();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedStateCleanup(void)
|
|
|
|
{
|
|
|
|
virSysinfoDefFree(hostsysinfo);
|
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,
|
2013-06-12 17:21:21 +00:00
|
|
|
.stateCleanup = xenUnifiedStateCleanup,
|
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
|
2014-02-20 00:32:19 +00:00
|
|
|
static bool
|
2012-10-17 09:23:12 +00:00
|
|
|
xenUnifiedXendProbe(void)
|
2011-02-10 22:42:34 +00:00
|
|
|
{
|
2014-02-20 00:32:19 +00:00
|
|
|
bool ret = false;
|
2011-02-10 22:42:34 +00:00
|
|
|
|
2014-04-28 18:35:44 +00:00
|
|
|
if (virFileExists("/usr/sbin/xend")) {
|
|
|
|
virCommandPtr cmd;
|
|
|
|
|
|
|
|
cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) == 0)
|
|
|
|
ret = true;
|
|
|
|
virCommandFree(cmd);
|
|
|
|
}
|
2011-02-10 22:42:34 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
|
2013-03-13 20:39:34 +00:00
|
|
|
static int
|
|
|
|
xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
maint: avoid 'const fooPtr' in domain_conf
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/conf/domain_conf, and their fallout.
Several things to note: virObjectLock() requires a non-const
argument; if this were C++, we could treat the locking field
as 'mutable' and allow locking an otherwise 'const' object, but
that is a more invasive change, so I instead dropped attempts
to be const-correct on domain lookup. virXMLPropString and
friends require a non-const xmlNodePtr - this is because libxml2
is not a const-correct library. We could make the src/util/virxml
wrappers cast away const, but I figured it was easier to not
try to mark xmlNodePtr as const. Finally, virDomainDeviceDefCopy
was a rather hard conversion - it calls virDomainDeviceDefPostParse,
which in turn in the xen driver was actually modifying the domain
outside of the current device being visited. We should not be
adding a device on the first per-device callback, but waiting until
after all per-device callbacks are complete.
* src/conf/domain_conf.h (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainObjAssignDef, virDomainObjListAdd): Drop attempt at
const.
(virDomainDeviceDefCopy): Use intended type.
(virDomainDeviceDefParse, virDomainDeviceDefPostParseCallback)
(virDomainVideoDefaultType, virDomainVideoDefaultRAM)
(virDomainChrGetDomainPtrs): Make const-correct.
* src/conf/domain_conf.c (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainDeviceDefCopy, virDomainObjListAdd)
(virDomainObjAssignDef, virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciOrigStatesDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevSubsysScsiDefParseXML)
(virDomainControllerModelTypeFromString)
(virDomainTPMDefParseXML, virDomainTimerDefParseXML)
(virDomainSoundCodecDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainRNGDefParseXML)
(virDomainMemballoonDefParseXML, virDomainNVRAMDefParseXML)
(virSysinfoParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevDefParseXML)
(virDomainRedirdevDefParseXML)
(virDomainRedirFilterUsbDevDefParseXML)
(virDomainRedirFilterDefParseXML, virDomainIdMapEntrySort)
(virDomainIdmapDefParseXML, virDomainVcpuPinDefParseXML)
(virDiskNameToBusDeviceIndex, virDomainDeviceDefCopy)
(virDomainVideoDefaultType, virDomainHostdevAssignAddress)
(virDomainDeviceDefPostParseInternal, virDomainDeviceDefPostParse)
(virDomainChrGetDomainPtrs, virDomainControllerSCSINextUnit)
(virDomainSCSIDriveAddressIsUsed)
(virDomainDriveAddressIsUsedByDisk)
(virDomainDriveAddressIsUsedByHostdev): Fix fallout.
* src/openvz/openvz_driver.c (openvzDomainDeviceDefPostParse):
Likewise.
* src/libxl/libxl_domain.c (libxlDomainDeviceDefPostParse):
Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDefaultNetModel): Likewise.
* src/lxc/lxc_domain.c (virLXCDomainDeviceDefPostParse):
Likewise.
* src/uml/uml_driver.c (umlDomainDeviceDefPostParse): Likewise.
* src/xen/xen_driver.c (xenDomainDeviceDefPostParse): Split...
(xenDomainDefPostParse): ...since per-device callback is not the
time to be adding a device.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-08 15:08:25 +00:00
|
|
|
const virDomainDef *def,
|
2013-03-13 20:39:34 +00:00
|
|
|
virCapsPtr caps ATTRIBUTE_UNUSED,
|
2016-01-08 13:00:56 +00:00
|
|
|
unsigned int parseFlags ATTRIBUTE_UNUSED,
|
2016-09-23 08:53:38 +00:00
|
|
|
void *opaque ATTRIBUTE_UNUSED,
|
|
|
|
void *parseOpaque ATTRIBUTE_UNUSED)
|
2013-03-13 20:39:34 +00:00
|
|
|
{
|
|
|
|
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 &&
|
2015-04-17 00:11:06 +00:00
|
|
|
def->os.type != VIR_DOMAIN_OSTYPE_HVM)
|
2013-03-13 20:39:34 +00:00
|
|
|
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
|
|
|
|
2014-06-25 06:45:59 +00:00
|
|
|
/* forbid capabilities mode hostdev in this kind of hypervisor */
|
|
|
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV &&
|
|
|
|
dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("hostdev mode 'capabilities' is not "
|
|
|
|
"supported in %s"),
|
|
|
|
virDomainVirtTypeToString(def->virtType));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-09-19 16:13:40 +00:00
|
|
|
if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && dev->data.video->vram == 0) {
|
|
|
|
switch (dev->data.video->type) {
|
|
|
|
case VIR_DOMAIN_VIDEO_TYPE_VGA:
|
|
|
|
case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
|
|
|
|
case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
|
2014-11-24 10:58:53 +00:00
|
|
|
dev->data.video->vram = 16 * 1024;
|
2014-09-19 16:13:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_VIDEO_TYPE_XEN:
|
|
|
|
/* Original Xen PVFB hardcoded to 4 MB */
|
|
|
|
dev->data.video->vram = 4 * 1024;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIR_DOMAIN_VIDEO_TYPE_QXL:
|
|
|
|
/* Use 64M as the minimal video video memory for qxl device */
|
|
|
|
return 64 * 1024;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
maint: avoid 'const fooPtr' in domain_conf
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/conf/domain_conf, and their fallout.
Several things to note: virObjectLock() requires a non-const
argument; if this were C++, we could treat the locking field
as 'mutable' and allow locking an otherwise 'const' object, but
that is a more invasive change, so I instead dropped attempts
to be const-correct on domain lookup. virXMLPropString and
friends require a non-const xmlNodePtr - this is because libxml2
is not a const-correct library. We could make the src/util/virxml
wrappers cast away const, but I figured it was easier to not
try to mark xmlNodePtr as const. Finally, virDomainDeviceDefCopy
was a rather hard conversion - it calls virDomainDeviceDefPostParse,
which in turn in the xen driver was actually modifying the domain
outside of the current device being visited. We should not be
adding a device on the first per-device callback, but waiting until
after all per-device callbacks are complete.
* src/conf/domain_conf.h (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainObjAssignDef, virDomainObjListAdd): Drop attempt at
const.
(virDomainDeviceDefCopy): Use intended type.
(virDomainDeviceDefParse, virDomainDeviceDefPostParseCallback)
(virDomainVideoDefaultType, virDomainVideoDefaultRAM)
(virDomainChrGetDomainPtrs): Make const-correct.
* src/conf/domain_conf.c (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainDeviceDefCopy, virDomainObjListAdd)
(virDomainObjAssignDef, virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciOrigStatesDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevSubsysScsiDefParseXML)
(virDomainControllerModelTypeFromString)
(virDomainTPMDefParseXML, virDomainTimerDefParseXML)
(virDomainSoundCodecDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainRNGDefParseXML)
(virDomainMemballoonDefParseXML, virDomainNVRAMDefParseXML)
(virSysinfoParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevDefParseXML)
(virDomainRedirdevDefParseXML)
(virDomainRedirFilterUsbDevDefParseXML)
(virDomainRedirFilterDefParseXML, virDomainIdMapEntrySort)
(virDomainIdmapDefParseXML, virDomainVcpuPinDefParseXML)
(virDiskNameToBusDeviceIndex, virDomainDeviceDefCopy)
(virDomainVideoDefaultType, virDomainHostdevAssignAddress)
(virDomainDeviceDefPostParseInternal, virDomainDeviceDefPostParse)
(virDomainChrGetDomainPtrs, virDomainControllerSCSINextUnit)
(virDomainSCSIDriveAddressIsUsed)
(virDomainDriveAddressIsUsedByDisk)
(virDomainDriveAddressIsUsedByHostdev): Fix fallout.
* src/openvz/openvz_driver.c (openvzDomainDeviceDefPostParse):
Likewise.
* src/libxl/libxl_domain.c (libxlDomainDeviceDefPostParse):
Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDefaultNetModel): Likewise.
* src/lxc/lxc_domain.c (virLXCDomainDeviceDefPostParse):
Likewise.
* src/uml/uml_driver.c (umlDomainDeviceDefPostParse): Likewise.
* src/xen/xen_driver.c (xenDomainDeviceDefPostParse): Split...
(xenDomainDefPostParse): ...since per-device callback is not the
time to be adding a device.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-08 15:08:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenDomainDefPostParse(virDomainDefPtr def,
|
|
|
|
virCapsPtr caps ATTRIBUTE_UNUSED,
|
2016-01-08 13:00:56 +00:00
|
|
|
unsigned int parseFlags ATTRIBUTE_UNUSED,
|
2016-09-22 14:41:33 +00:00
|
|
|
void *opaque ATTRIBUTE_UNUSED,
|
|
|
|
void *parseOpaque ATTRIBUTE_UNUSED)
|
maint: avoid 'const fooPtr' in domain_conf
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/conf/domain_conf, and their fallout.
Several things to note: virObjectLock() requires a non-const
argument; if this were C++, we could treat the locking field
as 'mutable' and allow locking an otherwise 'const' object, but
that is a more invasive change, so I instead dropped attempts
to be const-correct on domain lookup. virXMLPropString and
friends require a non-const xmlNodePtr - this is because libxml2
is not a const-correct library. We could make the src/util/virxml
wrappers cast away const, but I figured it was easier to not
try to mark xmlNodePtr as const. Finally, virDomainDeviceDefCopy
was a rather hard conversion - it calls virDomainDeviceDefPostParse,
which in turn in the xen driver was actually modifying the domain
outside of the current device being visited. We should not be
adding a device on the first per-device callback, but waiting until
after all per-device callbacks are complete.
* src/conf/domain_conf.h (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainObjAssignDef, virDomainObjListAdd): Drop attempt at
const.
(virDomainDeviceDefCopy): Use intended type.
(virDomainDeviceDefParse, virDomainDeviceDefPostParseCallback)
(virDomainVideoDefaultType, virDomainVideoDefaultRAM)
(virDomainChrGetDomainPtrs): Make const-correct.
* src/conf/domain_conf.c (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainDeviceDefCopy, virDomainObjListAdd)
(virDomainObjAssignDef, virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciOrigStatesDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevSubsysScsiDefParseXML)
(virDomainControllerModelTypeFromString)
(virDomainTPMDefParseXML, virDomainTimerDefParseXML)
(virDomainSoundCodecDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainRNGDefParseXML)
(virDomainMemballoonDefParseXML, virDomainNVRAMDefParseXML)
(virSysinfoParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevDefParseXML)
(virDomainRedirdevDefParseXML)
(virDomainRedirFilterUsbDevDefParseXML)
(virDomainRedirFilterDefParseXML, virDomainIdMapEntrySort)
(virDomainIdmapDefParseXML, virDomainVcpuPinDefParseXML)
(virDiskNameToBusDeviceIndex, virDomainDeviceDefCopy)
(virDomainVideoDefaultType, virDomainHostdevAssignAddress)
(virDomainDeviceDefPostParseInternal, virDomainDeviceDefPostParse)
(virDomainChrGetDomainPtrs, virDomainControllerSCSINextUnit)
(virDomainSCSIDriveAddressIsUsed)
(virDomainDriveAddressIsUsedByDisk)
(virDomainDriveAddressIsUsedByHostdev): Fix fallout.
* src/openvz/openvz_driver.c (openvzDomainDeviceDefPostParse):
Likewise.
* src/libxl/libxl_domain.c (libxlDomainDeviceDefPostParse):
Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDefaultNetModel): Likewise.
* src/lxc/lxc_domain.c (virLXCDomainDeviceDefPostParse):
Likewise.
* src/uml/uml_driver.c (umlDomainDeviceDefPostParse): Likewise.
* src/xen/xen_driver.c (xenDomainDeviceDefPostParse): Split...
(xenDomainDefPostParse): ...since per-device callback is not the
time to be adding a device.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-08 15:08:25 +00:00
|
|
|
{
|
2013-08-17 00:33:23 +00:00
|
|
|
if (!def->memballoon) {
|
|
|
|
virDomainMemballoonDefPtr memballoon;
|
|
|
|
if (VIR_ALLOC(memballoon) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_XEN;
|
|
|
|
def->memballoon = memballoon;
|
|
|
|
}
|
|
|
|
|
2016-01-11 11:40:32 +00:00
|
|
|
/* add implicit input device */
|
|
|
|
if (xenDomainDefAddImplicitInputDevice(def) <0)
|
|
|
|
return -1;
|
|
|
|
|
2013-03-13 20:39:34 +00:00
|
|
|
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,
|
maint: avoid 'const fooPtr' in domain_conf
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up offenders in src/conf/domain_conf, and their fallout.
Several things to note: virObjectLock() requires a non-const
argument; if this were C++, we could treat the locking field
as 'mutable' and allow locking an otherwise 'const' object, but
that is a more invasive change, so I instead dropped attempts
to be const-correct on domain lookup. virXMLPropString and
friends require a non-const xmlNodePtr - this is because libxml2
is not a const-correct library. We could make the src/util/virxml
wrappers cast away const, but I figured it was easier to not
try to mark xmlNodePtr as const. Finally, virDomainDeviceDefCopy
was a rather hard conversion - it calls virDomainDeviceDefPostParse,
which in turn in the xen driver was actually modifying the domain
outside of the current device being visited. We should not be
adding a device on the first per-device callback, but waiting until
after all per-device callbacks are complete.
* src/conf/domain_conf.h (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainObjAssignDef, virDomainObjListAdd): Drop attempt at
const.
(virDomainDeviceDefCopy): Use intended type.
(virDomainDeviceDefParse, virDomainDeviceDefPostParseCallback)
(virDomainVideoDefaultType, virDomainVideoDefaultRAM)
(virDomainChrGetDomainPtrs): Make const-correct.
* src/conf/domain_conf.c (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainDeviceDefCopy, virDomainObjListAdd)
(virDomainObjAssignDef, virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciOrigStatesDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevSubsysScsiDefParseXML)
(virDomainControllerModelTypeFromString)
(virDomainTPMDefParseXML, virDomainTimerDefParseXML)
(virDomainSoundCodecDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainRNGDefParseXML)
(virDomainMemballoonDefParseXML, virDomainNVRAMDefParseXML)
(virSysinfoParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevDefParseXML)
(virDomainRedirdevDefParseXML)
(virDomainRedirFilterUsbDevDefParseXML)
(virDomainRedirFilterDefParseXML, virDomainIdMapEntrySort)
(virDomainIdmapDefParseXML, virDomainVcpuPinDefParseXML)
(virDiskNameToBusDeviceIndex, virDomainDeviceDefCopy)
(virDomainVideoDefaultType, virDomainHostdevAssignAddress)
(virDomainDeviceDefPostParseInternal, virDomainDeviceDefPostParse)
(virDomainChrGetDomainPtrs, virDomainControllerSCSINextUnit)
(virDomainSCSIDriveAddressIsUsed)
(virDomainDriveAddressIsUsedByDisk)
(virDomainDriveAddressIsUsedByHostdev): Fix fallout.
* src/openvz/openvz_driver.c (openvzDomainDeviceDefPostParse):
Likewise.
* src/libxl/libxl_domain.c (libxlDomainDeviceDefPostParse):
Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDefaultNetModel): Likewise.
* src/lxc/lxc_domain.c (virLXCDomainDeviceDefPostParse):
Likewise.
* src/uml/uml_driver.c (umlDomainDeviceDefPostParse): Likewise.
* src/xen/xen_driver.c (xenDomainDeviceDefPostParse): Split...
(xenDomainDefPostParse): ...since per-device callback is not the
time to be adding a device.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-08 15:08:25 +00:00
|
|
|
.domainPostParseCallback = xenDomainDefPostParse,
|
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,
|
2017-06-01 22:44:46 +00:00
|
|
|
NULL, NULL, NULL, NULL);
|
2013-03-13 20:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-17 21:26:16 +00:00
|
|
|
static virDrvOpenStatus
|
2016-06-03 17:01:27 +00:00
|
|
|
xenUnifiedConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|
|
|
virConfPtr conf ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2007-04-10 11:17:34 +00:00
|
|
|
xenUnifiedPrivatePtr priv;
|
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;
|
|
|
|
|
2013-07-26 16:28:02 +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
|
|
|
|
|
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;
|
|
|
|
|
2013-07-26 16:28:02 +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
|
|
|
|
|
|
|
/* 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
|
|
|
|
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
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectOpenEnsureACL(conn) < 0)
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
|
2007-04-10 11:17:34 +00:00
|
|
|
/* Allocate per-connection private data. */
|
2013-07-04 10:18:49 +00:00
|
|
|
if (VIR_ALLOC(priv) < 0)
|
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
|
|
|
|
2013-11-21 10:43:10 +00:00
|
|
|
if (!(priv->domainEvents = virObjectEventStateNew())) {
|
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->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;
|
|
|
|
|
|
|
|
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) {
|
2016-06-07 15:59:58 +00:00
|
|
|
virReportSystemError(errno, _("Errored to create save dir '%s'"),
|
|
|
|
priv->saveDir);
|
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
|
|
|
|
2014-03-25 06:54:51 +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);
|
2016-10-11 07:48:36 +00:00
|
|
|
virObjectUnref(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
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define HV_VERSION ((DOM0_INTERFACE_VERSION >> 24) * 1000000 + \
|
|
|
|
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 + \
|
2008-11-28 12:03:20 +00:00
|
|
|
(DOM0_INTERFACE_VERSION & 0xFFFF))
|
|
|
|
|
|
|
|
unsigned long xenUnifiedVersion(void)
|
|
|
|
{
|
|
|
|
return HV_VERSION;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
static const char *
|
2013-04-23 10:56:22 +00:00
|
|
|
xenUnifiedConnectGetType(virConnectPtr conn)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectGetTypeEnsureACL(conn) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
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 10:56:22 +00:00
|
|
|
xenUnifiedConnectSupportsFeature(virConnectPtr conn, int feature)
|
2007-08-21 09:31:12 +00:00
|
|
|
{
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2018-03-08 12:20:24 +00:00
|
|
|
switch ((virDrvFeature) feature) {
|
2009-09-17 17:10:04 +00:00
|
|
|
case VIR_DRV_FEATURE_MIGRATION_V1:
|
|
|
|
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
|
|
|
|
return 1;
|
2018-03-08 12:20:24 +00:00
|
|
|
case VIR_DRV_FEATURE_MIGRATION_V2:
|
|
|
|
case VIR_DRV_FEATURE_MIGRATION_V3:
|
|
|
|
case VIR_DRV_FEATURE_MIGRATION_P2P:
|
|
|
|
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
|
|
|
|
case VIR_DRV_FEATURE_FD_PASSING:
|
|
|
|
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
|
|
|
|
case VIR_DRV_FEATURE_XML_MIGRATABLE:
|
|
|
|
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
|
|
|
|
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
|
|
|
|
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
|
|
|
|
case VIR_DRV_FEATURE_REMOTE:
|
|
|
|
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
|
|
|
|
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
|
2009-09-17 17:10:04 +00:00
|
|
|
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-23 10:56:22 +00:00
|
|
|
if (virConnectGetVersionEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
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
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
static char *xenUnifiedConnectGetHostname(virConnectPtr conn)
|
2013-04-26 16:39:11 +00:00
|
|
|
{
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectGetHostnameEnsureACL(conn) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
2013-04-26 16:39:11 +00:00
|
|
|
return virGetHostname();
|
|
|
|
}
|
|
|
|
|
2013-06-12 17:21:21 +00:00
|
|
|
static char *
|
|
|
|
xenUnifiedConnectGetSysinfo(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
|
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectGetSysinfoEnsureACL(conn) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
2013-06-12 17:21:21 +00:00
|
|
|
if (!hostsysinfo) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Host SMBIOS information is not available"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virSysinfoFormat(&buf, hostsysinfo) < 0)
|
|
|
|
return NULL;
|
2014-06-27 08:40:15 +00:00
|
|
|
if (virBufferCheckError(&buf) < 0)
|
2013-06-12 17:21:21 +00:00
|
|
|
return NULL;
|
|
|
|
return virBufferContentAndReset(&buf);
|
|
|
|
}
|
2013-04-26 16:39:11 +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
|
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
|
|
|
{
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectGetMaxVcpusEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
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-23 10:56:22 +00:00
|
|
|
if (virNodeGetInfoEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
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;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectGetCapabilitiesEnsureACL(conn) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
2014-06-27 07:55:44 +00:00
|
|
|
return virCapabilitiesFormatXML(priv->caps);
|
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-23 10:56:22 +00:00
|
|
|
if (virConnectListDomainsEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
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-23 10:56:22 +00:00
|
|
|
if (virConnectNumOfDomainsEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
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;
|
2014-11-18 17:34:42 +00:00
|
|
|
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
2013-05-01 13:15:10 +00:00
|
|
|
|
2014-11-18 17:34:42 +00:00
|
|
|
virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL);
|
|
|
|
|
|
|
|
if (flags & VIR_DOMAIN_START_VALIDATE)
|
2016-05-24 15:20:20 +00:00
|
|
|
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
|
2016-09-22 15:14:17 +00:00
|
|
|
NULL, parse_flags)))
|
2013-05-01 13:15:10 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainCreateXMLEnsureACL(conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (xenDaemonCreateXML(conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-03-28 15:08:03 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid, def->id);
|
2013-05-01 13:15:10 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 13:15:10 +00:00
|
|
|
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-04-23 10:56:22 +00:00
|
|
|
if (virDomainLookupByIDEnsureACL(conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-03-28 15:08:03 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid, def->id);
|
2013-05-01 09:31:23 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:31:23 +00:00
|
|
|
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-04-23 10:56:22 +00:00
|
|
|
if (virDomainLookupByUUIDEnsureACL(conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-03-28 15:08:03 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid, def->id);
|
2013-04-30 14:05:10 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:31:23 +00:00
|
|
|
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-04-23 10:56:22 +00:00
|
|
|
if (virDomainLookupByNameEnsureACL(conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-03-28 15:08:03 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid, def->id);
|
2013-04-30 14:05:10 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:31:23 +00:00
|
|
|
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
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:31:23 +00:00
|
|
|
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);
|
2013-07-04 10:18:49 +00:00
|
|
|
if (virAsprintf(&path, "%s/%s", XEND_DOMAINS_DIR, uuidstr) < 0)
|
2013-05-01 09:31:23 +00:00
|
|
|
goto cleanup;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:31:23 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainSuspendEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
ret = xenDaemonDomainSuspend(dom->conn, def);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:54:30 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainResumeEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
ret = xenDaemonDomainResume(dom->conn, def);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:54:30 +00:00
|
|
|
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;
|
|
|
|
|
api: require write permission for guest agent interaction
I noticed that we allow virDomainGetVcpusFlags even for read-only
connections, but that with a flag, it can require guest agent
interaction. It is feasible that a malicious guest could
intentionally abuse the replies it sends over the guest agent
connection to possibly trigger a bug in libvirt's JSON parser,
or withhold an answer so as to prevent the use of the agent
in a later command such as a shutdown request. Although we
don't know of any such exploits now (and therefore don't mind
posting this patch publicly without trying to get a CVE assigned),
it is better to err on the side of caution and explicitly require
full access to any domain where the API requires guest interaction
to operate correctly.
I audited all commands that are marked as conditionally using a
guest agent. Note that at least virDomainFSTrim is documented
as needing a guest agent, but that such use is unconditional
depending on the hypervisor (so the existing domain:fs_trim ACL
should be sufficient there, rather than also requirng domain:write).
But when designing future APIs, such as the plans for obtaining
a domain's IP addresses, we should copy the approach of this patch
in making interaction with the guest be specified via a flag, and
use that flag to also require stricter access checks.
* src/libvirt.c (virDomainGetVcpusFlags): Forbid guest interaction
on read-only connection.
(virDomainShutdownFlags, virDomainReboot): Improve docs on agent
interaction.
* src/remote/remote_protocol.x
(REMOTE_PROC_DOMAIN_SNAPSHOT_CREATE_XML)
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS, REMOTE_PROC_DOMAIN_REBOOT)
(REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS): Require domain:write for any
conditional use of a guest agent.
* src/xen/xen_driver.c: Fix clients.
* src/libxl/libxl_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-21 17:37:29 +00:00
|
|
|
if (virDomainShutdownFlagsEnsureACL(dom->conn, def, flags) < 0)
|
2013-04-23 10:56:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
ret = xenDaemonDomainShutdown(dom->conn, def);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:54:30 +00:00
|
|
|
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;
|
|
|
|
|
api: require write permission for guest agent interaction
I noticed that we allow virDomainGetVcpusFlags even for read-only
connections, but that with a flag, it can require guest agent
interaction. It is feasible that a malicious guest could
intentionally abuse the replies it sends over the guest agent
connection to possibly trigger a bug in libvirt's JSON parser,
or withhold an answer so as to prevent the use of the agent
in a later command such as a shutdown request. Although we
don't know of any such exploits now (and therefore don't mind
posting this patch publicly without trying to get a CVE assigned),
it is better to err on the side of caution and explicitly require
full access to any domain where the API requires guest interaction
to operate correctly.
I audited all commands that are marked as conditionally using a
guest agent. Note that at least virDomainFSTrim is documented
as needing a guest agent, but that such use is unconditional
depending on the hypervisor (so the existing domain:fs_trim ACL
should be sufficient there, rather than also requirng domain:write).
But when designing future APIs, such as the plans for obtaining
a domain's IP addresses, we should copy the approach of this patch
in making interaction with the guest be specified via a flag, and
use that flag to also require stricter access checks.
* src/libvirt.c (virDomainGetVcpusFlags): Forbid guest interaction
on read-only connection.
(virDomainShutdownFlags, virDomainReboot): Improve docs on agent
interaction.
* src/remote/remote_protocol.x
(REMOTE_PROC_DOMAIN_SNAPSHOT_CREATE_XML)
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS, REMOTE_PROC_DOMAIN_REBOOT)
(REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS): Require domain:write for any
conditional use of a guest agent.
* src/xen/xen_driver.c: Fix clients.
* src/libxl/libxl_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-21 17:37:29 +00:00
|
|
|
if (virDomainRebootEnsureACL(dom->conn, def, flags) < 0)
|
2013-04-23 10:56:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
ret = xenDaemonDomainReboot(dom->conn, def);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:54:30 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainDestroyFlagsEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 09:54:30 +00:00
|
|
|
ret = xenDaemonDomainDestroy(dom->conn, def);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 09:54:30 +00:00
|
|
|
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-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-04-23 10:56:22 +00:00
|
|
|
if (virDomainGetOSTypeEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (def->id < 0)
|
|
|
|
ret = xenDaemonDomainGetOSType(dom->conn, def);
|
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorDomainGetOSType(dom->conn, def);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 10:29:08 +00:00
|
|
|
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-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-04-23 10:56:22 +00:00
|
|
|
if (virDomainGetMaxMemoryEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (def->id < 0)
|
|
|
|
ret = xenDaemonDomainGetMaxMemory(dom->conn, def);
|
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorGetMaxMemory(dom->conn, def);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 10:29:08 +00:00
|
|
|
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-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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainSetMaxMemoryEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (def->id < 0)
|
|
|
|
ret = xenDaemonDomainSetMaxMemory(dom->conn, def, memory);
|
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorSetMaxMemory(dom->conn, def, memory);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 10:29:08 +00:00
|
|
|
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-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-04-23 10:56:22 +00:00
|
|
|
if (virDomainSetMemoryEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainSetMemory(dom->conn, def, memory);
|
2013-05-01 10:29:08 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 10:29:08 +00:00
|
|
|
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-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-04-23 10:56:22 +00:00
|
|
|
if (virDomainGetInfoEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (def->id < 0)
|
|
|
|
ret = xenDaemonDomainGetInfo(dom->conn, def, info);
|
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorGetDomainInfo(dom->conn, def, info);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 10:29:08 +00:00
|
|
|
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)
|
|
|
|
{
|
2015-12-04 21:06:10 +00:00
|
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainGetStateEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (def->id < 0)
|
|
|
|
ret = xenDaemonDomainGetState(dom->conn, def, state, reason);
|
|
|
|
else
|
2013-05-01 10:29:08 +00:00
|
|
|
ret = xenHypervisorGetDomainState(dom->conn, def, state, reason);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 10:29:08 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainSaveFlagsEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
ret = xenDaemonDomainSave(dom->conn, def, to);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 13:03:26 +00:00
|
|
|
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-07-04 10:18:49 +00:00
|
|
|
if (virAsprintf(&ret, "%s/%s.save", priv->saveDir, def->name) < 0)
|
2012-12-04 10:00:02 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainManagedSaveEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
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
|
|
|
|
2014-03-25 06:54:51 +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
|
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainHasManagedSaveImageEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
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
|
|
|
|
2014-03-25 06:54:51 +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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainManagedSaveRemoveEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
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
|
|
|
|
2014-03-25 06:54:51 +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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainCoreDumpEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-02 10:26:40 +00:00
|
|
|
ret = xenDaemonDomainCoreDump(dom->conn, def, to, flags);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:26:40 +00:00
|
|
|
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-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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainSetVcpusFlagsEnsureACL(dom->conn, def, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainSetVcpusFlags(dom->conn, def, nvcpus, flags);
|
2013-05-01 17:37:29 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 17:37:29 +00:00
|
|
|
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
|
|
|
{
|
2015-12-04 21:06:10 +00:00
|
|
|
unsigned int flags;
|
2010-10-14 22:17:18 +00:00
|
|
|
|
|
|
|
/* Per the documented API, it is hypervisor-dependent whether this
|
2015-12-04 21:06:10 +00:00
|
|
|
* affects just _LIVE or _LIVE|_CONFIG; in xen's case, both are
|
|
|
|
* affected. */
|
|
|
|
flags = VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG;
|
2013-04-30 16:25:27 +00:00
|
|
|
|
|
|
|
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-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-23 10:56:22 +00:00
|
|
|
if (virDomainPinVcpuEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (dom->id < 0)
|
|
|
|
ret = xenDaemonDomainPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
|
|
|
|
else
|
2013-05-01 17:37:29 +00:00
|
|
|
ret = xenHypervisorPinVcpu(dom->conn, def, vcpu, cpumap, maplen);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 17:37:29 +00:00
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-08-06 11:28:58 +00:00
|
|
|
xenUnifiedDomainGetVcpusInternal(virDomainPtr dom,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
virVcpuInfoPtr info,
|
|
|
|
int maxinfo,
|
|
|
|
unsigned char *cpumaps,
|
|
|
|
int maplen)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 17:37:29 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
2013-04-30 16:25:27 +00:00
|
|
|
if (dom->id < 0) {
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainGetVcpus(dom->conn, def, info, maxinfo,
|
|
|
|
cpumaps, maplen);
|
2013-04-30 16:25:27 +00:00
|
|
|
} else {
|
2013-08-06 11:28:58 +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
|
|
|
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-08-06 11:28:58 +00:00
|
|
|
xenUnifiedDomainGetVcpus(virDomainPtr dom,
|
|
|
|
virVcpuInfoPtr info, int maxinfo,
|
|
|
|
unsigned char *cpumaps, int maplen)
|
2007-04-04 14:19:49 +00:00
|
|
|
{
|
2013-05-01 17:37:29 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-05-01 17:37:29 +00:00
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-08-06 11:28:58 +00:00
|
|
|
if (virDomainGetVcpusEnsureACL(dom->conn, def) < 0)
|
2013-04-23 10:56:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-08-06 11:28:58 +00:00
|
|
|
ret = xenUnifiedDomainGetVcpusInternal(dom, def, info, maxinfo, cpumaps,
|
|
|
|
maplen);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-08-06 11:28:58 +00:00
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedDomainGetVcpusFlagsInternal(virDomainPtr dom,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
2013-04-30 16:25:27 +00:00
|
|
|
if (dom->id < 0) {
|
2015-12-04 21:06:10 +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
|
|
|
|
2013-08-06 11:28:58 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
xenUnifiedDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
|
|
|
{
|
|
|
|
virDomainDefPtr def = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
|
|
|
|
VIR_DOMAIN_VCPU_CONFIG |
|
|
|
|
VIR_DOMAIN_VCPU_MAXIMUM, -1);
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
api: require write permission for guest agent interaction
I noticed that we allow virDomainGetVcpusFlags even for read-only
connections, but that with a flag, it can require guest agent
interaction. It is feasible that a malicious guest could
intentionally abuse the replies it sends over the guest agent
connection to possibly trigger a bug in libvirt's JSON parser,
or withhold an answer so as to prevent the use of the agent
in a later command such as a shutdown request. Although we
don't know of any such exploits now (and therefore don't mind
posting this patch publicly without trying to get a CVE assigned),
it is better to err on the side of caution and explicitly require
full access to any domain where the API requires guest interaction
to operate correctly.
I audited all commands that are marked as conditionally using a
guest agent. Note that at least virDomainFSTrim is documented
as needing a guest agent, but that such use is unconditional
depending on the hypervisor (so the existing domain:fs_trim ACL
should be sufficient there, rather than also requirng domain:write).
But when designing future APIs, such as the plans for obtaining
a domain's IP addresses, we should copy the approach of this patch
in making interaction with the guest be specified via a flag, and
use that flag to also require stricter access checks.
* src/libvirt.c (virDomainGetVcpusFlags): Forbid guest interaction
on read-only connection.
(virDomainShutdownFlags, virDomainReboot): Improve docs on agent
interaction.
* src/remote/remote_protocol.x
(REMOTE_PROC_DOMAIN_SNAPSHOT_CREATE_XML)
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS, REMOTE_PROC_DOMAIN_REBOOT)
(REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS): Require domain:write for any
conditional use of a guest agent.
* src/xen/xen_driver.c: Fix clients.
* src/libxl/libxl_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/lxc/lxc_driver.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-21 17:37:29 +00:00
|
|
|
if (virDomainGetVcpusFlagsEnsureACL(dom->conn, def, flags) < 0)
|
2013-08-06 11:28:58 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenUnifiedDomainGetVcpusFlagsInternal(dom, def, flags);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 17:37:29 +00:00
|
|
|
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;
|
2015-12-04 21:06:10 +00:00
|
|
|
char *cpus = NULL;
|
2013-05-01 13:15:10 +00:00
|
|
|
|
|
|
|
if (!(minidef = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainGetXMLDescEnsureACL(dom->conn, minidef, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
cpus = xenDomainUsedCpus(dom, minidef);
|
|
|
|
xenUnifiedUnlock(priv);
|
|
|
|
def = xenDaemonDomainGetXMLDesc(dom->conn, minidef, cpus);
|
2013-05-01 13:15:10 +00:00
|
|
|
|
|
|
|
if (def)
|
2016-02-03 21:40:35 +00:00
|
|
|
ret = virDomainDefFormat(def, priv->caps,
|
2014-11-18 16:44:00 +00:00
|
|
|
virDomainDefFormatConvertXMLFlags(flags));
|
2013-05-01 13:15:10 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2015-12-04 21:06:10 +00:00
|
|
|
VIR_FREE(cpus);
|
2013-05-01 13:15:10 +00:00
|
|
|
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);
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectDomainXMLFromNativeEnsureACL(conn) < 0)
|
|
|
|
return 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)) {
|
2017-08-07 15:12:02 +00:00
|
|
|
conf = virConfReadString(config, 0);
|
2009-05-21 14:14:01 +00:00
|
|
|
if (!conf)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-05 02:11:39 +00:00
|
|
|
def = xenParseXM(conf, priv->caps, priv->xmlopt);
|
2009-05-21 14:14:01 +00:00
|
|
|
} else if (STREQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
|
2015-12-15 02:31:39 +00:00
|
|
|
if (xenGetDomIdFromSxprString(config, &id) < 0)
|
2013-09-25 08:31:30 +00:00
|
|
|
goto cleanup;
|
2011-02-21 13:40:08 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
tty = xenStoreDomainGetConsolePath(conn, id);
|
|
|
|
vncport = xenStoreDomainGetVNCPort(conn, id);
|
|
|
|
xenUnifiedUnlock(priv);
|
2015-12-15 02:31:39 +00:00
|
|
|
def = xenParseSxprString(config, tty,
|
2015-11-28 04:33:55 +00:00
|
|
|
vncport, priv->caps, priv->xmlopt);
|
2009-05-21 14:14:01 +00:00
|
|
|
}
|
|
|
|
if (!def)
|
|
|
|
goto cleanup;
|
|
|
|
|
2016-02-03 21:40:35 +00:00
|
|
|
ret = virDomainDefFormat(def, priv->caps, 0);
|
2009-05-21 14:14:01 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2009-05-21 14:14:01 +00:00
|
|
|
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);
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
|
|
|
|
return 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,
|
2016-09-22 15:14:17 +00:00
|
|
|
NULL,
|
2014-11-18 16:44:00 +00:00
|
|
|
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
2009-05-21 14:14:01 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {
|
|
|
|
int len = MAX_CONFIG_SIZE;
|
2015-12-05 02:11:39 +00:00
|
|
|
conf = xenFormatXM(conn, def);
|
2009-05-21 14:14:01 +00:00
|
|
|
if (!conf)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-07-04 10:18:49 +00:00
|
|
|
if (VIR_ALLOC_N(ret, len) < 0)
|
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)) {
|
2015-12-15 02:31:39 +00:00
|
|
|
ret = xenFormatSxpr(conn, def);
|
2009-05-21 14:14:01 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2009-05-21 14:14:01 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainMigratePerformEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
ret = xenDaemonDomainMigratePerform(dom->conn, def,
|
|
|
|
cookie, cookielen, uri,
|
|
|
|
flags, dname, resource);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 13:15:10 +00:00
|
|
|
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
|
|
|
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
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainMigrateFinishEnsureACL(dconn, minidef) < 0)
|
|
|
|
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
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (xenDaemonDomainDefineXML(dconn, def) < 0)
|
|
|
|
goto cleanup;
|
2009-11-12 15:04:43 +00:00
|
|
|
}
|
|
|
|
|
2017-03-28 15:08:03 +00:00
|
|
|
ret = virGetDomain(dconn, minidef->name, minidef->uuid, minidef->id);
|
2009-11-12 15:04:43 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 13:15:10 +00:00
|
|
|
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-23 10:56:22 +00:00
|
|
|
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
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-23 10:56:22 +00:00
|
|
|
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainCreateWithFlagsEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-01 13:03:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainCreate(dom->conn, def);
|
2013-05-01 13:03:26 +00:00
|
|
|
|
|
|
|
if (ret >= 0)
|
|
|
|
dom->id = def->id;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2014-03-25 06:54:51 +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
|
2014-11-18 14:19:38 +00:00
|
|
|
xenUnifiedDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
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;
|
2014-11-18 17:34:42 +00:00
|
|
|
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2014-11-18 17:34:42 +00:00
|
|
|
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
|
|
|
|
|
|
|
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
2016-05-24 15:20:20 +00:00
|
|
|
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
|
2014-11-18 14:19:38 +00:00
|
|
|
|
2013-05-01 13:15:10 +00:00
|
|
|
if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
|
2016-09-22 15:14:17 +00:00
|
|
|
NULL, parse_flags)))
|
2013-05-01 13:15:10 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2016-11-11 09:17:37 +00:00
|
|
|
if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2014-11-18 14:19:38 +00:00
|
|
|
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
2013-04-23 10:56:22 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (xenDaemonDomainDefineXML(conn, def) < 0)
|
|
|
|
goto cleanup;
|
2017-03-28 15:08:03 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid, -1);
|
2013-05-01 13:15:10 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 13:15:10 +00:00
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2014-11-18 14:19:38 +00:00
|
|
|
static virDomainPtr
|
|
|
|
xenUnifiedDomainDefineXML(virConnectPtr conn, const char *xml)
|
|
|
|
{
|
|
|
|
return xenUnifiedDomainDefineXMLFlags(conn, xml, 0);
|
|
|
|
}
|
|
|
|
|
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-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-23 10:56:22 +00:00
|
|
|
if (virDomainUndefineFlagsEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainUndefine(dom->conn, def);
|
2013-05-01 13:15:10 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-01 13:15:10 +00:00
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-04-04 14:19:49 +00:00
|
|
|
}
|
|
|
|
|
2011-07-20 03:08:21 +00:00
|
|
|
static int
|
2014-03-18 08:14:16 +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
|
|
|
{
|
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
|
|
|
/*
|
2015-12-04 21:06:10 +00:00
|
|
|
* HACK: xend does not support changing live config without also touching
|
|
|
|
* persistent config. We add the extra flag here to make this API work
|
2010-10-01 14:45:55 +00:00
|
|
|
*/
|
2015-12-04 21:06:10 +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-23 10:56:22 +00:00
|
|
|
if (virDomainAttachDeviceEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
|
2010-01-14 01:44:26 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 09:56:31 +00:00
|
|
|
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-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-23 10:56:22 +00:00
|
|
|
if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonAttachDeviceFlags(dom->conn, def, xml, flags);
|
2013-05-02 09:56:31 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 09:56:31 +00:00
|
|
|
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
|
|
|
{
|
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
|
|
|
/*
|
2015-12-04 21:06:10 +00:00
|
|
|
* HACK: xend does not support changing live config without also touching
|
|
|
|
* persistent config. We add the extra flag here to make this API work
|
2010-10-01 14:45:55 +00:00
|
|
|
*/
|
2015-12-04 21:06:10 +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-23 10:56:22 +00:00
|
|
|
if (virDomainDetachDeviceEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
|
2013-05-02 09:56:31 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 09:56:31 +00:00
|
|
|
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-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-23 10:56:22 +00:00
|
|
|
if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDetachDeviceFlags(dom->conn, def, xml, flags);
|
2013-05-02 09:56:31 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 09:56:31 +00:00
|
|
|
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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, def, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-02 09:56:31 +00:00
|
|
|
ret = xenDaemonUpdateDeviceFlags(dom->conn, def, xml, flags);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 09:56:31 +00:00
|
|
|
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-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-04-23 10:56:22 +00:00
|
|
|
if (virDomainGetAutostartEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainGetAutostart(dom->conn, def, autostart);
|
2013-05-02 10:05:55 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:05:55 +00:00
|
|
|
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-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-04-23 10:56:22 +00:00
|
|
|
if (virDomainSetAutostartEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainSetAutostart(dom->conn, def, autostart);
|
2013-05-02 10:05:55 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:05:55 +00:00
|
|
|
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-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
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (dom->id < 0)
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenDaemonGetSchedulerType(dom->conn, nparams);
|
2015-12-04 21:06:10 +00:00
|
|
|
else
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenHypervisorGetSchedulerType(dom->conn, nparams);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:13:39 +00:00
|
|
|
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-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-23 10:56:22 +00:00
|
|
|
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (dom->id < 0)
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenDaemonGetSchedulerParameters(dom->conn, def, params, nparams);
|
2015-12-04 21:06:10 +00:00
|
|
|
else
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenHypervisorGetSchedulerParameters(dom->conn, def, params, nparams);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:13:39 +00:00
|
|
|
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-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-23 10:56:22 +00:00
|
|
|
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, def, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
if (dom->id < 0)
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenDaemonSetSchedulerParameters(dom->conn, def, params, nparams);
|
2015-12-04 21:06:10 +00:00
|
|
|
else
|
2013-05-02 10:13:39 +00:00
|
|
|
ret = xenHypervisorSetSchedulerParameters(dom->conn, def, params, nparams);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:13:39 +00:00
|
|
|
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,
|
2014-09-16 13:19:46 +00:00
|
|
|
virDomainBlockStatsPtr 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;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainBlockStatsEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-05-02 10:24:49 +00:00
|
|
|
ret = xenHypervisorDomainBlockStats(dom->conn, def, path, stats);
|
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:24:49 +00:00
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
2007-08-21 10:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-10-13 20:25:42 +00:00
|
|
|
xenUnifiedDomainInterfaceStats(virDomainPtr dom, const char *device,
|
2014-09-16 13:19:45 +00:00
|
|
|
virDomainInterfaceStatsPtr stats)
|
2007-08-21 10:08:12 +00:00
|
|
|
{
|
2013-05-02 10:24:49 +00:00
|
|
|
virDomainDefPtr def = NULL;
|
2017-10-13 20:40:47 +00:00
|
|
|
virDomainNetDefPtr net = NULL;
|
2013-05-02 10:24:49 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!(def = xenGetDomainDefForDom(dom)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virDomainInterfaceStatsEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-10-13 20:25:42 +00:00
|
|
|
if (!(net = virDomainNetFind(def, device)))
|
2017-10-13 20:40:47 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = xenHypervisorDomainInterfaceStats(def, net->ifname, stats);
|
2013-05-02 10:24:49 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:24:49 +00:00
|
|
|
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-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-23 10:56:22 +00:00
|
|
|
if (virDomainBlockPeekEnsureACL(dom->conn, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2015-12-04 21:06:10 +00:00
|
|
|
ret = xenDaemonDomainBlockPeek(dom->conn, def, path, offset, size, buffer);
|
2013-05-02 10:24:49 +00:00
|
|
|
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2013-05-02 10:24:49 +00:00
|
|
|
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-23 10:56:22 +00:00
|
|
|
if (virNodeGetCellsFreeMemoryEnsureACL(conn) < 0)
|
|
|
|
return 0;
|
|
|
|
|
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-23 10:56:22 +00:00
|
|
|
if (virNodeGetFreeMemoryEnsureACL(conn) < 0)
|
|
|
|
return 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;
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
int ret = 0;
|
2013-04-23 10:56:22 +00:00
|
|
|
|
|
|
|
if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
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) {
|
2013-12-20 01:38:59 +00:00
|
|
|
virReportUnsupportedError();
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
2008-11-25 10:44:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
if (virDomainEventStateRegister(conn, priv->domainEvents,
|
|
|
|
callback, opaque, freefunc) < 0)
|
|
|
|
ret = -1;
|
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
|
|
|
{
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
int ret = 0;
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2013-04-23 10:56:22 +00:00
|
|
|
|
|
|
|
if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
if (priv->xsWatch == -1) {
|
2013-12-20 01:38:59 +00:00
|
|
|
virReportUnsupportedError();
|
2009-01-21 18:11:14 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
2008-11-25 10:44:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
if (virDomainEventStateDeregister(conn,
|
|
|
|
priv->domainEvents,
|
|
|
|
callback) < 0)
|
|
|
|
ret = -1;
|
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;
|
2013-04-23 10:56:22 +00:00
|
|
|
|
|
|
|
if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2010-03-18 14:47:07 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
|
|
|
|
if (priv->xsWatch == -1) {
|
2013-12-20 01:38:59 +00:00
|
|
|
virReportUnsupportedError();
|
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
|
|
|
{
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
int ret = 0;
|
2013-04-30 12:32:48 +00:00
|
|
|
xenUnifiedPrivatePtr priv = conn->privateData;
|
2013-04-23 10:56:22 +00:00
|
|
|
|
|
|
|
if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2010-03-18 14:47:07 +00:00
|
|
|
xenUnifiedLock(priv);
|
|
|
|
|
|
|
|
if (priv->xsWatch == -1) {
|
2013-12-20 01:38:59 +00:00
|
|
|
virReportUnsupportedError();
|
2010-03-18 14:47:07 +00:00
|
|
|
xenUnifiedUnlock(priv);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
if (virObjectEventStateDeregisterID(conn,
|
|
|
|
priv->domainEvents,
|
2017-06-14 11:32:15 +00:00
|
|
|
callbackID, true) < 0)
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
ret = -1;
|
2010-03-18 14:47:07 +00:00
|
|
|
|
|
|
|
xenUnifiedUnlock(priv);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-03 12:38:52 +00:00
|
|
|
static int
|
2014-03-13 11:59:32 +00:00
|
|
|
xenUnifiedNodeDeviceGetPCIInfo(virNodeDevicePtr dev,
|
2012-10-17 09:23:12 +00:00
|
|
|
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) {
|
2015-05-08 16:55:00 +00:00
|
|
|
if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
2009-04-03 12:38:52 +00:00
|
|
|
*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;
|
2014-03-25 06:54:51 +00:00
|
|
|
out:
|
2009-04-03 12:38:52 +00:00
|
|
|
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);
|
|
|
|
|
2014-03-13 11:59:32 +00:00
|
|
|
if (xenUnifiedNodeDeviceGetPCIInfo(dev, &domain, &bus, &slot, &function) < 0)
|
2009-04-03 12:38:52 +00:00
|
|
|
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) {
|
2015-10-23 09:54:07 +00:00
|
|
|
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
|
2013-04-24 18:06:42 +00:00
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unknown driver name '%s'"), driverName);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2013-05-30 18:14:46 +00:00
|
|
|
if (virPCIDeviceDetach(pci, NULL, NULL) < 0)
|
2009-04-03 12:38:52 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = 0;
|
2014-03-25 06:54:51 +00:00
|
|
|
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;
|
Convert 'int i' to 'size_t i' in src/{xen,xenapi,xenxs} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
int ret = -1;
|
|
|
|
size_t i;
|
2011-04-27 12:09:12 +00:00
|
|
|
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);
|
2014-11-13 14:29:45 +00:00
|
|
|
if (numdomains < 0)
|
2011-04-27 12:09:12 +00:00
|
|
|
return ret;
|
2014-08-20 11:00:30 +00:00
|
|
|
if (numdomains > 0) {
|
2013-07-04 10:18:49 +00:00
|
|
|
if (VIR_ALLOC_N(ids, numdomains) < 0)
|
2011-04-27 12:09:12 +00:00
|
|
|
goto out;
|
2014-11-13 14:29:45 +00:00
|
|
|
if ((numdomains = xenUnifiedConnectListDomains(conn, &ids[0], numdomains)) < 0)
|
2011-04-27 12:09:12 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get pci bdf */
|
2014-03-13 11:59:32 +00:00
|
|
|
if (xenUnifiedNodeDeviceGetPCIInfo(dev, &domain, &bus, &slot, &function) < 0)
|
2011-04-27 12:09:12 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (virAsprintf(&bdf, "%04x:%02x:%02x.%0x",
|
2013-07-04 10:18:49 +00:00
|
|
|
domain, bus, slot, function) < 0)
|
2011-04-27 12:09:12 +00:00
|
|
|
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);
|
2014-03-25 06:54:51 +00:00
|
|
|
out:
|
2011-04-27 12:09:12 +00:00
|
|
|
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
|
|
|
|
2014-03-13 11:59:32 +00:00
|
|
|
if (xenUnifiedNodeDeviceGetPCIInfo(dev, &domain, &bus, &slot, &function) < 0)
|
2009-04-03 12:38:52 +00:00
|
|
|
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;
|
2014-03-25 06:54:51 +00:00
|
|
|
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;
|
|
|
|
|
2014-03-13 11:59:32 +00:00
|
|
|
if (xenUnifiedNodeDeviceGetPCIInfo(dev, &domain, &bus, &slot, &function) < 0)
|
2009-04-03 12:38:52 +00:00
|
|
|
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;
|
2014-03-25 06:54:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:45:54 +00:00
|
|
|
if (chr->source->type != VIR_DOMAIN_CHR_TYPE_PTY) {
|
2012-07-18 13:48:05 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2015-06-15 13:58:36 +00:00
|
|
|
_("character device %s is not using a PTY"),
|
|
|
|
dev_name ? dev_name : NULLSTR(chr->info.alias));
|
2010-10-22 13:40:26 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:45:54 +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;
|
2014-03-25 06:54:51 +00:00
|
|
|
cleanup:
|
2010-10-22 13:40:26 +00:00
|
|
|
virDomainDefFree(def);
|
|
|
|
return ret;
|
|
|
|
}
|
2013-04-26 17:21:58 +00:00
|
|
|
|
|
|
|
static int
|
2013-04-23 10:56:22 +00:00
|
|
|
xenUnifiedNodeGetMemoryParameters(virConnectPtr conn,
|
2013-04-26 17:21:58 +00:00
|
|
|
virTypedParameterPtr params,
|
|
|
|
int *nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virNodeGetMemoryParametersEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2016-04-13 17:16:16 +00:00
|
|
|
return virHostMemGetParameters(params, nparams, flags);
|
2013-04-26 17:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-23 10:56:22 +00:00
|
|
|
xenUnifiedNodeSetMemoryParameters(virConnectPtr conn,
|
2013-04-26 17:21:58 +00:00
|
|
|
virTypedParameterPtr params,
|
|
|
|
int nparams,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virNodeSetMemoryParametersEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2016-04-13 17:16:16 +00:00
|
|
|
return virHostMemSetParameters(params, nparams, flags);
|
2013-04-26 17:21:58 +00:00
|
|
|
}
|
|
|
|
|
2013-04-29 09:16:56 +00:00
|
|
|
|
|
|
|
static int
|
2013-04-23 10:56:22 +00:00
|
|
|
xenUnifiedNodeSuspendForDuration(virConnectPtr conn,
|
2013-04-29 09:16:56 +00:00
|
|
|
unsigned int target,
|
|
|
|
unsigned long long duration,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2013-04-23 10:56:22 +00:00
|
|
|
if (virNodeSuspendForDurationEnsureACL(conn) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2017-03-07 09:44:06 +00:00
|
|
|
return virNodeSuspend(target, duration, flags);
|
2013-04-29 09:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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. */
|
2015-01-20 16:16:26 +00:00
|
|
|
static virHypervisorDriver xenUnifiedHypervisorDriver = {
|
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
|
|
|
.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-06-25 13:25:29 +00:00
|
|
|
.connectGetSysinfo = xenUnifiedConnectGetSysinfo, /* 1.1.0 */
|
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 */
|
2014-11-18 14:19:38 +00:00
|
|
|
.domainDefineXMLFlags = xenUnifiedDomainDefineXMLFlags, /* 1.2.12 */
|
2011-05-13 13:35:01 +00:00
|
|
|
.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
|
|
|
};
|
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
|
|
|
|
static virConnectDriver xenUnifiedConnectDriver = {
|
|
|
|
.hypervisorDriver = &xenUnifiedHypervisorDriver,
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
return virRegisterConnectDriver(&xenUnifiedConnectDriver,
|
|
|
|
true);
|
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)
|
|
|
|
{
|
Convert 'int i' to 'size_t i' in src/{xen,xenapi,xenxs} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2009-01-15 01:21:36 +00:00
|
|
|
|
|
|
|
if (list == NULL)
|
|
|
|
return;
|
|
|
|
|
2014-01-20 11:27:29 +00:00
|
|
|
for (i = 0; i < list->count; i++) {
|
2008-11-25 10:44:52 +00:00
|
|
|
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 */
|
2014-01-20 11:27:29 +00:00
|
|
|
for (n = 0; n < list->count; n++) {
|
2008-11-25 10:44:52 +00:00
|
|
|
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)
|
2013-07-04 10:18:49 +00:00
|
|
|
goto 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 */
|
2014-03-07 08:33:31 +00:00
|
|
|
if (VIR_APPEND_ELEMENT(list->doms, list->count, info) < 0)
|
2013-07-04 10:18:49 +00:00
|
|
|
goto error;
|
2008-11-25 10:44:52 +00:00
|
|
|
|
|
|
|
return 0;
|
2014-03-25 06:54:51 +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)
|
|
|
|
{
|
Convert 'int i' to 'size_t i' in src/{xen,xenapi,xenxs} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t 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]);
|
|
|
|
|
2014-03-07 08:33:31 +00:00
|
|
|
VIR_DELETE_ELEMENT(list->doms, i, list->count);
|
2008-11-25 10:44:52 +00:00
|
|
|
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,
|
2013-11-22 14:38:05 +00:00
|
|
|
virObjectEventPtr 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
|
|
|
|
2013-11-21 10:43:10 +00:00
|
|
|
virObjectEventStateQueue(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
|
|
|
}
|