2012-07-31 18:56:05 +00:00
|
|
|
/*
|
|
|
|
* parallels_driver.c: core driver functions for managing
|
|
|
|
* Parallels Cloud Server hosts
|
|
|
|
*
|
2015-01-15 14:02:44 +00:00
|
|
|
* Copyright (C) 2014-2015 Red Hat, Inc.
|
2012-07-31 18:56:05 +00:00
|
|
|
* Copyright (C) 2012 Parallels, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-31 18:56:05 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/poll.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <paths.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/statvfs.h>
|
|
|
|
|
|
|
|
#include "datatypes.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
#include "vircommand.h"
|
2012-07-31 18:56:05 +00:00
|
|
|
#include "configmake.h"
|
2013-05-09 18:59:04 +00:00
|
|
|
#include "virfile.h"
|
2012-12-13 15:25:48 +00:00
|
|
|
#include "virstoragefile.h"
|
2012-07-31 18:56:05 +00:00
|
|
|
#include "nodeinfo.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2014-06-05 05:50:05 +00:00
|
|
|
#include "cpu/cpu.h"
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
#include "parallels_driver.h"
|
2012-07-31 18:56:07 +00:00
|
|
|
#include "parallels_utils.h"
|
2014-09-11 16:24:03 +00:00
|
|
|
#include "parallels_sdk.h"
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_PARALLELS
|
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("parallels.parallels_driver");
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
#define PRLCTL "prlctl"
|
2012-07-31 18:56:07 +00:00
|
|
|
#define PRLSRVCTL "prlsrvctl"
|
2012-07-31 18:56:05 +00:00
|
|
|
|
2013-04-23 12:50:18 +00:00
|
|
|
static int parallelsConnectClose(virConnectPtr conn);
|
2012-07-31 18:56:05 +00:00
|
|
|
|
2012-08-01 03:46:22 +00:00
|
|
|
void
|
2012-07-31 18:56:05 +00:00
|
|
|
parallelsDriverLock(parallelsConnPtr driver)
|
|
|
|
{
|
|
|
|
virMutexLock(&driver->lock);
|
|
|
|
}
|
|
|
|
|
2012-08-01 03:46:22 +00:00
|
|
|
void
|
2012-07-31 18:56:05 +00:00
|
|
|
parallelsDriverUnlock(parallelsConnPtr driver)
|
|
|
|
{
|
|
|
|
virMutexUnlock(&driver->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static virCapsPtr
|
|
|
|
parallelsBuildCapabilities(void)
|
|
|
|
{
|
2014-06-05 05:50:06 +00:00
|
|
|
virCapsPtr caps = NULL;
|
|
|
|
virCPUDefPtr cpu = NULL;
|
|
|
|
virCPUDataPtr data = NULL;
|
2012-07-31 18:56:05 +00:00
|
|
|
virCapsGuestPtr guest;
|
2014-06-05 05:50:06 +00:00
|
|
|
virNodeInfo nodeinfo;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
2012-12-10 22:28:09 +00:00
|
|
|
if ((caps = virCapabilitiesNew(virArchFromHost(),
|
2014-07-14 12:56:13 +00:00
|
|
|
false, false)) == NULL)
|
2013-07-04 10:13:24 +00:00
|
|
|
return NULL;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
if (nodeCapsInitNUMA(caps) < 0)
|
2013-07-04 10:13:24 +00:00
|
|
|
goto error;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
2012-12-10 22:28:09 +00:00
|
|
|
VIR_ARCH_X86_64,
|
|
|
|
"parallels",
|
2012-07-31 18:56:05 +00:00
|
|
|
NULL, 0, NULL)) == NULL)
|
2013-07-04 10:13:24 +00:00
|
|
|
goto error;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
|
2015-03-10 19:32:50 +00:00
|
|
|
VIR_ARCH_I686,
|
|
|
|
"parallels",
|
|
|
|
NULL, 0, NULL)) == NULL)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"parallels", NULL, NULL, 0, NULL) == NULL)
|
2013-07-04 10:13:24 +00:00
|
|
|
goto error;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
2015-04-17 22:09:16 +00:00
|
|
|
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
|
2012-12-10 22:28:09 +00:00
|
|
|
VIR_ARCH_X86_64,
|
|
|
|
"parallels",
|
2012-09-10 15:22:42 +00:00
|
|
|
NULL, 0, NULL)) == NULL)
|
2013-07-04 10:13:24 +00:00
|
|
|
goto error;
|
2012-09-10 15:22:42 +00:00
|
|
|
|
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"parallels", NULL, NULL, 0, NULL) == NULL)
|
2013-07-04 10:13:24 +00:00
|
|
|
goto error;
|
2012-09-10 15:22:42 +00:00
|
|
|
|
2014-06-09 07:36:30 +00:00
|
|
|
if (nodeGetInfo(&nodeinfo))
|
2014-06-05 05:50:06 +00:00
|
|
|
goto error;
|
|
|
|
|
2014-06-09 07:36:30 +00:00
|
|
|
if (VIR_ALLOC(cpu) < 0)
|
2014-06-05 05:50:06 +00:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
cpu->arch = caps->host.arch;
|
|
|
|
cpu->type = VIR_CPU_TYPE_HOST;
|
|
|
|
cpu->sockets = nodeinfo.sockets;
|
|
|
|
cpu->cores = nodeinfo.cores;
|
|
|
|
cpu->threads = nodeinfo.threads;
|
|
|
|
|
|
|
|
caps->host.cpu = cpu;
|
|
|
|
|
|
|
|
if (!(data = cpuNodeData(cpu->arch))
|
|
|
|
|| cpuDecode(cpu, data, NULL, 0, NULL) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
cpuDataFree(data);
|
2012-07-31 18:56:05 +00:00
|
|
|
return caps;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
error:
|
2013-02-01 12:26:18 +00:00
|
|
|
virObjectUnref(caps);
|
2014-06-05 05:50:06 +00:00
|
|
|
goto cleanup;
|
2012-07-31 18:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectGetCapabilities(virConnectPtr conn)
|
2012-07-31 18:56:05 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
char *xml;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2014-06-27 07:55:44 +00:00
|
|
|
xml = virCapabilitiesFormatXML(privconn->caps);
|
2012-07-31 18:56:05 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
return xml;
|
|
|
|
}
|
|
|
|
|
2014-10-06 15:28:46 +00:00
|
|
|
static int
|
2014-08-11 15:40:32 +00:00
|
|
|
parallelsDomainDefPostParse(virDomainDefPtr def,
|
2014-10-06 15:28:46 +00:00
|
|
|
virCapsPtr caps ATTRIBUTE_UNUSED,
|
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2014-08-11 15:40:32 +00:00
|
|
|
/* memory hotplug tunables are not supported by this driver */
|
|
|
|
if (virDomainDefCheckUnsupportedMemoryHotplug(def) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2014-10-06 15:28:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-03-18 08:33:55 +00:00
|
|
|
parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
2015-04-07 20:35:06 +00:00
|
|
|
const virDomainDef *def,
|
2014-10-06 15:28:46 +00:00
|
|
|
virCapsPtr caps ATTRIBUTE_UNUSED,
|
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2015-03-18 08:33:55 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
|
|
|
|
(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
|
|
|
|
dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
|
|
|
|
!dev->data.net->model &&
|
2015-04-17 00:11:06 +00:00
|
|
|
def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
|
2015-03-18 08:33:55 +00:00
|
|
|
VIR_STRDUP(dev->data.net->model, "e1000") < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
return ret;
|
2014-10-06 15:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-15 14:44:12 +00:00
|
|
|
virDomainDefParserConfig parallelsDomainDefParserConfig = {
|
|
|
|
.macPrefix = {0x42, 0x1C, 0x00},
|
2014-10-06 15:28:46 +00:00
|
|
|
.devicesPostParseCallback = parallelsDomainDeviceDefPostParse,
|
|
|
|
.domainPostParseCallback = parallelsDomainDefPostParse,
|
2013-03-15 14:44:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
static int
|
|
|
|
parallelsOpenDefault(virConnectPtr conn)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn;
|
|
|
|
|
2013-07-04 10:13:24 +00:00
|
|
|
if (VIR_ALLOC(privconn) < 0)
|
2012-07-31 18:56:05 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
if (virMutexInit(&privconn->lock) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("cannot initialize mutex"));
|
2014-09-11 16:24:03 +00:00
|
|
|
goto err_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prlsdkInit(privconn)) {
|
|
|
|
VIR_DEBUG("%s", _("Can't initialize Parallels SDK"));
|
|
|
|
goto err_free;
|
2012-07-31 18:56:05 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 16:24:03 +00:00
|
|
|
if (prlsdkConnect(privconn) < 0)
|
|
|
|
goto err_free;
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
if (!(privconn->caps = parallelsBuildCapabilities()))
|
|
|
|
goto error;
|
|
|
|
|
2013-03-15 14:44:12 +00:00
|
|
|
if (!(privconn->xmlopt = virDomainXMLOptionNew(¶llelsDomainDefParserConfig,
|
|
|
|
NULL, NULL)))
|
2013-03-05 15:17:24 +00:00
|
|
|
goto error;
|
|
|
|
|
2013-01-11 16:04:47 +00:00
|
|
|
if (!(privconn->domains = virDomainObjListNew()))
|
2012-07-31 18:56:05 +00:00
|
|
|
goto error;
|
|
|
|
|
2014-12-01 15:38:50 +00:00
|
|
|
if (!(privconn->domainEventState = virObjectEventStateNew()))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (prlsdkSubscribeToPCSEvents(privconn))
|
|
|
|
goto error;
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
conn->privateData = privconn;
|
|
|
|
|
2014-12-01 15:38:48 +00:00
|
|
|
if (prlsdkLoadDomains(privconn))
|
2012-07-31 18:56:07 +00:00
|
|
|
goto error;
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
error:
|
2013-01-11 13:54:15 +00:00
|
|
|
virObjectUnref(privconn->domains);
|
2013-02-01 12:26:18 +00:00
|
|
|
virObjectUnref(privconn->caps);
|
2012-07-31 18:56:05 +00:00
|
|
|
virStoragePoolObjListFree(&privconn->pools);
|
2014-12-01 15:38:50 +00:00
|
|
|
virObjectEventStateFree(privconn->domainEventState);
|
2014-09-11 16:24:03 +00:00
|
|
|
prlsdkDisconnect(privconn);
|
|
|
|
prlsdkDeinit();
|
|
|
|
err_free:
|
2012-07-31 18:56:05 +00:00
|
|
|
VIR_FREE(privconn);
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virDrvOpenStatus
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectOpen(virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
2012-07-31 18:56:05 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
|
|
|
|
|
|
|
if (!conn->uri)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "parallels"))
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
/* Remote driver should handle these. */
|
|
|
|
if (conn->uri->server)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
/* From this point on, the connection is for us. */
|
2012-08-13 15:50:13 +00:00
|
|
|
if (!STREQ_NULLABLE(conn->uri->path, "/system")) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Unexpected Parallels URI path '%s', try parallels:///system"),
|
|
|
|
conn->uri->path);
|
2012-07-31 18:56:05 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
if ((ret = parallelsOpenDefault(conn)) != VIR_DRV_OPEN_SUCCESS ||
|
|
|
|
(ret = parallelsStorageOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS ||
|
2015-02-26 16:13:53 +00:00
|
|
|
(ret = parallelsNetworkOpen(conn, flags)) != VIR_DRV_OPEN_SUCCESS) {
|
|
|
|
parallelsConnectClose(conn);
|
2012-07-31 18:56:05 +00:00
|
|
|
return ret;
|
2015-02-26 16:13:53 +00:00
|
|
|
}
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectClose(virConnectPtr conn)
|
2012-07-31 18:56:05 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
|
2015-02-26 16:13:53 +00:00
|
|
|
if (!privconn)
|
|
|
|
return 0;
|
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
parallelsNetworkClose(conn);
|
|
|
|
parallelsStorageClose(conn);
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
parallelsDriverLock(privconn);
|
2014-12-01 15:38:50 +00:00
|
|
|
prlsdkUnsubscribeFromPCSEvents(privconn);
|
2013-02-01 12:26:18 +00:00
|
|
|
virObjectUnref(privconn->caps);
|
2013-03-31 18:03:42 +00:00
|
|
|
virObjectUnref(privconn->xmlopt);
|
2013-01-11 13:54:15 +00:00
|
|
|
virObjectUnref(privconn->domains);
|
2014-12-01 15:38:50 +00:00
|
|
|
virObjectEventStateFree(privconn->domainEventState);
|
2014-09-11 16:24:03 +00:00
|
|
|
prlsdkDisconnect(privconn);
|
2012-07-31 18:56:05 +00:00
|
|
|
conn->privateData = NULL;
|
2014-09-11 16:24:03 +00:00
|
|
|
prlsdkDeinit();
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
virMutexDestroy(&privconn->lock);
|
|
|
|
|
|
|
|
VIR_FREE(privconn);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned long *hvVer)
|
2012-07-31 18:56:05 +00:00
|
|
|
{
|
2012-07-31 18:56:07 +00:00
|
|
|
char *output, *sVer, *tmp;
|
|
|
|
const char *searchStr = "prlsrvctl version ";
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
output = parallelsGetOutput(PRLSRVCTL, "--help", NULL);
|
|
|
|
|
|
|
|
if (!output) {
|
|
|
|
parallelsParseError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(sVer = strstr(output, searchStr))) {
|
|
|
|
parallelsParseError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
sVer = sVer + strlen(searchStr);
|
|
|
|
|
|
|
|
/* parallels server has versions number like 6.0.17977.782218,
|
|
|
|
* so libvirt can handle only first two numbers. */
|
|
|
|
if (!(tmp = strchr(sVer, '.'))) {
|
|
|
|
parallelsParseError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(tmp = strchr(tmp + 1, '.'))) {
|
|
|
|
parallelsParseError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp[0] = '\0';
|
|
|
|
if (virParseVersionString(sVer, hvVer, true) < 0) {
|
|
|
|
parallelsParseError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
VIR_FREE(output);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-04-26 16:39:11 +00:00
|
|
|
|
|
|
|
static char *parallelsConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return virGetHostname();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-31 18:56:07 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectListDomains(virConnectPtr conn, int *ids, int maxids)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-06-24 16:49:47 +00:00
|
|
|
n = virDomainObjListGetActiveIDs(privconn->domains, ids, maxids,
|
|
|
|
NULL, NULL);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectNumOfDomains(virConnectPtr conn)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-06-24 16:49:47 +00:00
|
|
|
count = virDomainObjListNumOfDomains(privconn->domains, true,
|
|
|
|
NULL, NULL);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
|
|
|
memset(names, 0, sizeof(*names) * maxnames);
|
2013-01-11 16:04:47 +00:00
|
|
|
n = virDomainObjListGetInactiveNames(privconn->domains, names,
|
2013-06-24 16:49:47 +00:00
|
|
|
maxnames, NULL, NULL);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectNumOfDefinedDomains(virConnectPtr conn)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-06-24 16:49:47 +00:00
|
|
|
count = virDomainObjListNumOfDomains(privconn->domains, false,
|
|
|
|
NULL, NULL);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsConnectListAllDomains(virConnectPtr conn,
|
|
|
|
virDomainPtr **domains,
|
|
|
|
unsigned int flags)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
int ret = -1;
|
|
|
|
|
2012-08-03 15:48:05 +00:00
|
|
|
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverLock(privconn);
|
2013-06-24 16:49:47 +00:00
|
|
|
ret = virDomainObjListExport(privconn->domains, conn, domains,
|
|
|
|
NULL, flags);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsDomainLookupByID(virConnectPtr conn, int id)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainObjPtr dom;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
dom = virDomainObjListFindByID(privconn->domains, id);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (dom == NULL) {
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN, NULL);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
|
|
|
|
if (ret)
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (dom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(dom);
|
2012-07-31 18:56:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainObjPtr dom;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
dom = virDomainObjListFindByUUID(privconn->domains, uuid);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (dom == NULL) {
|
|
|
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
|
|
|
virUUIDFormat(uuid, uuidstr);
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN,
|
|
|
|
_("no domain with matching uuid '%s'"), uuidstr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
|
|
|
|
if (ret)
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (dom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(dom);
|
2012-07-31 18:56:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virDomainPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsDomainLookupByName(virConnectPtr conn, const char *name)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainObjPtr dom;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
dom = virDomainObjListFindByName(privconn->domains, name);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (dom == NULL) {
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN,
|
|
|
|
_("no domain with matching name '%s'"), name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
|
|
|
|
if (ret)
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (dom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(dom);
|
2012-07-31 18:56:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->state = virDomainObjGetState(privdom, NULL);
|
|
|
|
info->memory = privdom->def->mem.cur_balloon;
|
2015-02-17 17:01:09 +00:00
|
|
|
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
|
2012-07-31 18:56:07 +00:00
|
|
|
info->nrVirtCpu = privdom->def->vcpus;
|
|
|
|
info->cpuTime = 0;
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(privdom);
|
2012-07-31 18:56:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
parallelsDomainGetOSType(virDomainPtr domain)
|
2012-07-31 18:56:07 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
|
|
|
|
|
|
|
char *ret = NULL;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-17 00:11:06 +00:00
|
|
|
ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(privdom->def->os.type)));
|
2012-07-31 18:56:07 +00:00
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(privdom);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parallelsDomainIsPersistent(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(privdom);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parallelsDomainGetState(virDomainPtr domain,
|
|
|
|
int *state, int *reason, unsigned int flags)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
|
|
|
int ret = -1;
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*state = virDomainObjGetState(privdom, reason);
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(privdom);
|
2012-07-31 18:56:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
parallelsDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
virDomainObjPtr privdom;
|
|
|
|
char *ret = NULL;
|
|
|
|
|
|
|
|
/* Flags checked by virDomainDefFormat */
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
def = (flags & VIR_DOMAIN_XML_INACTIVE) &&
|
|
|
|
privdom->newDef ? privdom->newDef : privdom->def;
|
|
|
|
|
|
|
|
ret = virDomainDefFormat(def, flags);
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(privdom);
|
2012-07-31 18:56:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parallelsDomainGetAutostart(virDomainPtr domain, int *autostart)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
2013-01-11 16:04:47 +00:00
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
2012-07-31 18:56:07 +00:00
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
*autostart = privdom->autostart;
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2012-07-31 18:56:07 +00:00
|
|
|
if (privdom)
|
2013-01-09 21:00:32 +00:00
|
|
|
virObjectUnlock(privdom);
|
2012-07-31 18:56:07 +00:00
|
|
|
return ret;
|
2012-07-31 18:56:05 +00:00
|
|
|
}
|
|
|
|
|
2012-07-31 18:56:11 +00:00
|
|
|
static virDomainPtr
|
2014-11-18 14:19:38 +00:00
|
|
|
parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
2012-07-31 18:56:11 +00:00
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
2014-12-01 15:38:54 +00:00
|
|
|
virDomainPtr retdom = NULL;
|
2012-07-31 18:56:11 +00:00
|
|
|
virDomainDefPtr def;
|
2014-04-23 14:35:02 +00:00
|
|
|
virDomainObjPtr olddom = NULL;
|
2014-11-18 17:34:42 +00:00
|
|
|
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
2012-07-31 18:56:11 +00:00
|
|
|
|
2014-11-18 17:34:42 +00:00
|
|
|
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
|
|
|
|
|
|
|
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
|
|
|
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
2014-11-18 14:19:38 +00:00
|
|
|
|
2012-07-31 18:56:11 +00:00
|
|
|
parallelsDriverLock(privconn);
|
2013-03-28 13:55:55 +00:00
|
|
|
if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
|
|
|
|
1 << VIR_DOMAIN_VIRT_PARALLELS,
|
2014-11-18 17:34:42 +00:00
|
|
|
parse_flags)) == NULL)
|
2012-07-31 18:56:11 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
Merge virDomainObjListIsDuplicate into virDomainObjListAdd
The duplicate VM checking should be done atomically with
virDomainObjListAdd, so shoud not be a separate function.
Instead just use flags to indicate what kind of checks are
required.
This pair, used in virDomainCreateXML:
if (virDomainObjListIsDuplicate(privconn->domains, def, 1) < 0)
goto cleanup;
if (!(dom = virDomainObjListAdd(privconn->domains,
privconn->caps,
def, false)))
goto cleanup;
Changes to
if (!(dom = virDomainObjListAdd(privconn->domains,
privconn->caps,
def,
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
NULL)))
goto cleanup;
This pair, used in virDomainRestoreFlags:
if (virDomainObjListIsDuplicate(privconn->domains, def, 1) < 0)
goto cleanup;
if (!(dom = virDomainObjListAdd(privconn->domains,
privconn->caps,
def, true)))
goto cleanup;
Changes to
if (!(dom = virDomainObjListAdd(privconn->domains,
privconn->caps,
def,
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
NULL)))
goto cleanup;
This pair, used in virDomainDefineXML:
if (virDomainObjListIsDuplicate(privconn->domains, def, 0) < 0)
goto cleanup;
if (!(dom = virDomainObjListAdd(privconn->domains,
privconn->caps,
def, false)))
goto cleanup;
Changes to
if (!(dom = virDomainObjListAdd(privconn->domains,
privconn->caps,
def,
0, NULL)))
goto cleanup;
2013-01-14 14:46:58 +00:00
|
|
|
olddom = virDomainObjListFindByUUID(privconn->domains, def->uuid);
|
|
|
|
if (olddom == NULL) {
|
|
|
|
virResetLastError();
|
2015-04-17 00:11:06 +00:00
|
|
|
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
2014-12-01 15:38:53 +00:00
|
|
|
if (prlsdkCreateVm(conn, def))
|
2012-09-12 12:40:54 +00:00
|
|
|
goto cleanup;
|
2015-04-17 00:11:06 +00:00
|
|
|
} else if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
|
2014-12-01 15:38:53 +00:00
|
|
|
if (prlsdkCreateCt(conn, def))
|
2012-09-12 12:40:54 +00:00
|
|
|
goto cleanup;
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
2015-04-17 00:11:06 +00:00
|
|
|
_("Unsupported OS type: %s"),
|
|
|
|
virDomainOSTypeToString(def->os.type));
|
2012-07-31 18:56:11 +00:00
|
|
|
goto cleanup;
|
2012-09-12 12:40:54 +00:00
|
|
|
}
|
2014-12-01 15:38:54 +00:00
|
|
|
|
|
|
|
olddom = prlsdkAddDomain(privconn, def->uuid);
|
|
|
|
if (!olddom)
|
2012-07-31 18:56:13 +00:00
|
|
|
goto cleanup;
|
2014-12-01 15:38:54 +00:00
|
|
|
} else {
|
2015-04-07 20:35:13 +00:00
|
|
|
int state, reason;
|
|
|
|
|
|
|
|
state = virDomainObjGetState(olddom, &reason);
|
|
|
|
|
|
|
|
if (state == VIR_DOMAIN_SHUTOFF &&
|
|
|
|
reason == VIR_DOMAIN_SHUTOFF_SAVED) {
|
|
|
|
|
|
|
|
/* PCS doesn't store domain config in managed save state file.
|
|
|
|
* It's forbidden to change config for VMs in this state.
|
|
|
|
* It's possible to change config for containers, but after
|
|
|
|
* restoring domain will have that new config, not a config,
|
|
|
|
* which domain had at the moment of virDomainManagedSave.
|
|
|
|
*
|
|
|
|
* So forbid this operation, if config is changed. If it's
|
|
|
|
* not changed - just do nothing. */
|
|
|
|
|
|
|
|
if (!virDomainDefCheckABIStability(olddom->def, def)) {
|
|
|
|
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
|
|
|
_("Can't change domain configuration "
|
|
|
|
"in managed save state"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (prlsdkApplyConfig(conn, olddom, def))
|
|
|
|
goto cleanup;
|
2012-07-31 18:56:11 +00:00
|
|
|
|
2015-04-07 20:35:13 +00:00
|
|
|
if (prlsdkUpdateDomain(privconn, olddom))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-12-04 13:43:12 +00:00
|
|
|
}
|
|
|
|
|
2014-12-01 15:38:54 +00:00
|
|
|
retdom = virGetDomain(conn, def->name, def->uuid);
|
|
|
|
if (retdom)
|
|
|
|
retdom->id = def->id;
|
2012-07-31 18:56:11 +00:00
|
|
|
|
2014-03-25 06:57:01 +00:00
|
|
|
cleanup:
|
2014-12-01 15:38:54 +00:00
|
|
|
if (olddom)
|
|
|
|
virObjectUnlock(olddom);
|
2012-07-31 18:56:11 +00:00
|
|
|
virDomainDefFree(def);
|
|
|
|
parallelsDriverUnlock(privconn);
|
2014-12-01 15:38:54 +00:00
|
|
|
return retdom;
|
2012-07-31 18:56:11 +00:00
|
|
|
}
|
|
|
|
|
2014-11-18 14:19:38 +00:00
|
|
|
static virDomainPtr
|
|
|
|
parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
|
|
|
|
{
|
|
|
|
return parallelsDomainDefineXMLFlags(conn, xml, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-26 17:21:58 +00:00
|
|
|
static int
|
|
|
|
parallelsNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virNodeInfoPtr nodeinfo)
|
|
|
|
{
|
|
|
|
return nodeGetInfo(nodeinfo);
|
|
|
|
}
|
|
|
|
|
2014-04-23 14:35:03 +00:00
|
|
|
static int parallelsConnectIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* Encryption is not relevant / applicable to way we talk to PCS */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parallelsConnectIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* We run CLI tools directly so this is secure */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parallelsConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-04-26 17:21:58 +00:00
|
|
|
|
2014-06-05 05:50:05 +00:00
|
|
|
static char *
|
|
|
|
parallelsConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
const char **xmlCPUs,
|
|
|
|
unsigned int ncpus,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL);
|
|
|
|
|
|
|
|
return cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-05 05:50:04 +00:00
|
|
|
static int
|
|
|
|
parallelsDomainGetVcpus(virDomainPtr domain,
|
|
|
|
virVcpuInfoPtr info,
|
|
|
|
int maxinfo,
|
|
|
|
unsigned char *cpumaps,
|
|
|
|
int maplen)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom = NULL;
|
|
|
|
size_t i;
|
|
|
|
int v, maxcpu, hostcpus;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
parallelsDriverLock(privconn);
|
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
|
|
|
parallelsDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!virDomainObjIsActive(privdom)) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
"%s",
|
|
|
|
_("cannot list vcpu pinning for an inactive domain"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((hostcpus = nodeGetCPUCount()) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
maxcpu = maplen * 8;
|
|
|
|
if (maxcpu > hostcpus)
|
|
|
|
maxcpu = hostcpus;
|
|
|
|
|
|
|
|
if (maxinfo >= 1) {
|
|
|
|
if (info != NULL) {
|
|
|
|
memset(info, 0, sizeof(*info) * maxinfo);
|
|
|
|
for (i = 0; i < maxinfo; i++) {
|
|
|
|
info[i].number = i;
|
|
|
|
info[i].state = VIR_VCPU_RUNNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cpumaps != NULL) {
|
|
|
|
unsigned char *tmpmap = NULL;
|
|
|
|
int tmpmapLen = 0;
|
|
|
|
|
|
|
|
memset(cpumaps, 0, maplen * maxinfo);
|
2015-03-10 20:12:19 +00:00
|
|
|
virBitmapToData(privdom->def->cpumask, &tmpmap, &tmpmapLen);
|
2014-06-05 05:50:04 +00:00
|
|
|
if (tmpmapLen > maplen)
|
|
|
|
tmpmapLen = maplen;
|
|
|
|
|
|
|
|
for (v = 0; v < maxinfo; v++) {
|
|
|
|
unsigned char *cpumap = VIR_GET_CPUMAP(cpumaps, maplen, v);
|
|
|
|
memcpy(cpumap, tmpmap, tmpmapLen);
|
|
|
|
}
|
|
|
|
VIR_FREE(tmpmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = maxinfo;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (privdom)
|
|
|
|
virObjectUnlock(privdom);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-22 11:04:43 +00:00
|
|
|
static int
|
|
|
|
parallelsNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
unsigned char **cpumap,
|
|
|
|
unsigned int *online,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
return nodeGetCPUMap(cpumap, online, flags);
|
|
|
|
}
|
|
|
|
|
2014-12-01 15:38:50 +00:00
|
|
|
static int
|
|
|
|
parallelsConnectDomainEventRegisterAny(virConnectPtr conn,
|
|
|
|
virDomainPtr domain,
|
|
|
|
int eventID,
|
|
|
|
virConnectDomainEventGenericCallback callback,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freecb)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
if (virDomainEventStateRegisterID(conn,
|
|
|
|
privconn->domainEventState,
|
|
|
|
domain, eventID,
|
|
|
|
callback, opaque, freecb, &ret) < 0)
|
|
|
|
ret = -1;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parallelsConnectDomainEventDeregisterAny(virConnectPtr conn,
|
|
|
|
int callbackID)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = conn->privateData;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (virObjectEventStateDeregisterID(conn,
|
|
|
|
privconn->domainEventState,
|
|
|
|
callbackID) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
return ret;
|
|
|
|
}
|
2014-08-22 11:04:43 +00:00
|
|
|
|
2014-12-01 15:38:51 +00:00
|
|
|
static int parallelsDomainSuspend(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
return prlsdkDomainChangeState(domain, prlsdkPause);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parallelsDomainResume(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
return prlsdkDomainChangeState(domain, prlsdkResume);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parallelsDomainCreate(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
return prlsdkDomainChangeState(domain, prlsdkStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parallelsDomainDestroy(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
return prlsdkDomainChangeState(domain, prlsdkKill);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int parallelsDomainShutdown(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
return prlsdkDomainChangeState(domain, prlsdkStop);
|
|
|
|
}
|
|
|
|
|
2014-12-01 15:38:55 +00:00
|
|
|
static int parallelsDomainIsActive(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr dom = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
|
|
|
if (dom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = virDomainObjIsActive(dom);
|
|
|
|
virObjectUnlock(dom);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-01 15:38:56 +00:00
|
|
|
static int
|
|
|
|
parallelsDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
|
|
|
|
{
|
|
|
|
/* we don't support any create flags */
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
return parallelsDomainCreate(domain);
|
|
|
|
}
|
|
|
|
|
2014-12-01 15:38:58 +00:00
|
|
|
static int
|
|
|
|
parallelsDomainUndefineFlags(virDomainPtr domain,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr dom = NULL;
|
2015-03-13 15:40:41 +00:00
|
|
|
int ret;
|
2014-12-01 15:38:58 +00:00
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
|
|
|
if (dom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-03-13 15:40:41 +00:00
|
|
|
ret = prlsdkUnregisterDomain(privconn, dom);
|
|
|
|
if (ret)
|
|
|
|
virObjectUnlock(dom);
|
|
|
|
|
|
|
|
return ret;
|
2014-12-01 15:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parallelsDomainUndefine(virDomainPtr domain)
|
|
|
|
{
|
|
|
|
return parallelsDomainUndefineFlags(domain, 0);
|
|
|
|
}
|
|
|
|
|
2015-01-15 14:02:44 +00:00
|
|
|
static int
|
|
|
|
parallelsDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr dom = NULL;
|
2015-04-07 20:35:02 +00:00
|
|
|
int state, reason;
|
|
|
|
int ret = 0;
|
2015-01-15 14:02:44 +00:00
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
|
|
|
if (dom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-04-07 20:35:02 +00:00
|
|
|
state = virDomainObjGetState(dom, &reason);
|
|
|
|
if (state == VIR_DOMAIN_SHUTOFF && reason == VIR_DOMAIN_SHUTOFF_SAVED)
|
|
|
|
ret = 1;
|
2015-03-10 20:12:20 +00:00
|
|
|
virObjectUnlock(dom);
|
|
|
|
|
2015-04-07 20:35:02 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parallelsDomainManagedSave(virDomainPtr domain, unsigned int flags)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr dom = NULL;
|
|
|
|
int state, reason;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(VIR_DOMAIN_SAVE_RUNNING |
|
|
|
|
VIR_DOMAIN_SAVE_PAUSED, -1);
|
|
|
|
|
|
|
|
dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
|
|
|
if (dom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = virDomainObjGetState(dom, &reason);
|
|
|
|
|
|
|
|
if (state == VIR_DOMAIN_RUNNING && (flags & VIR_DOMAIN_SAVE_PAUSED)) {
|
|
|
|
ret = prlsdkDomainChangeStateLocked(privconn, dom, prlsdkPause);
|
|
|
|
if (ret)
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = prlsdkDomainChangeStateLocked(privconn, dom, prlsdkSuspend);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virObjectUnlock(dom);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parallelsDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags)
|
|
|
|
{
|
|
|
|
parallelsConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr dom = NULL;
|
|
|
|
int state, reason;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
dom = virDomainObjListFindByUUID(privconn->domains, domain->uuid);
|
|
|
|
if (dom == NULL) {
|
|
|
|
parallelsDomNotFoundError(domain);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = virDomainObjGetState(dom, &reason);
|
|
|
|
|
|
|
|
if (!(state == VIR_DOMAIN_SHUTOFF && reason == VIR_DOMAIN_SHUTOFF_SAVED))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = prlsdkDomainManagedSaveRemove(privconn, dom);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virObjectUnlock(dom);
|
|
|
|
return ret;
|
2015-01-15 14:02:44 +00:00
|
|
|
}
|
|
|
|
|
2015-04-13 14:55:27 +00:00
|
|
|
static int parallelsDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
parallelsConnPtr privconn = dom->conn->privateData;
|
|
|
|
virDomainDeviceDefPtr dev = NULL;
|
|
|
|
virDomainObjPtr privdom = NULL;
|
|
|
|
bool domactive = false;
|
|
|
|
|
|
|
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
|
|
|
VIR_DOMAIN_AFFECT_CONFIG, -1);
|
|
|
|
|
|
|
|
privdom = virDomainObjListFindByUUID(privconn->domains, dom->uuid);
|
|
|
|
if (privdom == NULL) {
|
|
|
|
parallelsDomNotFoundError(dom);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & VIR_DOMAIN_AFFECT_CONFIG)) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("device attach needs VIR_DOMAIN_AFFECT_CONFIG "
|
|
|
|
"flag to be set"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
domactive = virDomainObjIsActive(privdom);
|
|
|
|
if (!domactive && (flags & VIR_DOMAIN_AFFECT_LIVE)) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("cannot do live update a device on "
|
|
|
|
"inactive domain"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
if (domactive && !(flags & VIR_DOMAIN_AFFECT_LIVE)) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("Updates on a running domain need "
|
|
|
|
"VIR_DOMAIN_AFFECT_LIVE flag"));
|
|
|
|
}
|
|
|
|
|
|
|
|
dev = virDomainDeviceDefParse(xml, privdom->def, privconn->caps,
|
|
|
|
privconn->xmlopt, VIR_DOMAIN_XML_INACTIVE);
|
|
|
|
if (dev == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
switch (dev->type) {
|
|
|
|
case VIR_DOMAIN_DEVICE_DISK:
|
|
|
|
ret = prlsdkAttachVolume(dom->conn, privdom, dev->data.disk);
|
|
|
|
if (ret) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("disk attach failed"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
|
|
|
_("device type '%s' cannot be detached"),
|
|
|
|
virDomainDeviceTypeToString(dev->type));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-09 10:42:00 +00:00
|
|
|
static int parallelsDomainAttachDevice(virDomainPtr dom, const char *xml)
|
|
|
|
{
|
|
|
|
return parallelsDomainAttachDeviceFlags(dom, xml,
|
|
|
|
VIR_DOMAIN_AFFECT_CONFIG | VIR_DOMAIN_AFFECT_LIVE);
|
|
|
|
}
|
|
|
|
|
2014-10-16 09:25:59 +00:00
|
|
|
static virHypervisorDriver parallelsDriver = {
|
2012-07-31 18:56:05 +00:00
|
|
|
.name = "Parallels",
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectOpen = parallelsConnectOpen, /* 0.10.0 */
|
|
|
|
.connectClose = parallelsConnectClose, /* 0.10.0 */
|
|
|
|
.connectGetVersion = parallelsConnectGetVersion, /* 0.10.0 */
|
2013-04-26 16:39:11 +00:00
|
|
|
.connectGetHostname = parallelsConnectGetHostname, /* 0.10.0 */
|
2013-04-26 17:21:58 +00:00
|
|
|
.nodeGetInfo = parallelsNodeGetInfo, /* 0.10.0 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectGetCapabilities = parallelsConnectGetCapabilities, /* 0.10.0 */
|
2014-06-05 05:50:05 +00:00
|
|
|
.connectBaselineCPU = parallelsConnectBaselineCPU, /* 1.2.6 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectListDomains = parallelsConnectListDomains, /* 0.10.0 */
|
|
|
|
.connectNumOfDomains = parallelsConnectNumOfDomains, /* 0.10.0 */
|
|
|
|
.connectListDefinedDomains = parallelsConnectListDefinedDomains, /* 0.10.0 */
|
|
|
|
.connectNumOfDefinedDomains = parallelsConnectNumOfDefinedDomains, /* 0.10.0 */
|
|
|
|
.connectListAllDomains = parallelsConnectListAllDomains, /* 0.10.0 */
|
|
|
|
.domainLookupByID = parallelsDomainLookupByID, /* 0.10.0 */
|
|
|
|
.domainLookupByUUID = parallelsDomainLookupByUUID, /* 0.10.0 */
|
|
|
|
.domainLookupByName = parallelsDomainLookupByName, /* 0.10.0 */
|
|
|
|
.domainGetOSType = parallelsDomainGetOSType, /* 0.10.0 */
|
|
|
|
.domainGetInfo = parallelsDomainGetInfo, /* 0.10.0 */
|
2012-07-31 18:56:07 +00:00
|
|
|
.domainGetState = parallelsDomainGetState, /* 0.10.0 */
|
|
|
|
.domainGetXMLDesc = parallelsDomainGetXMLDesc, /* 0.10.0 */
|
|
|
|
.domainIsPersistent = parallelsDomainIsPersistent, /* 0.10.0 */
|
|
|
|
.domainGetAutostart = parallelsDomainGetAutostart, /* 0.10.0 */
|
2014-06-05 05:50:04 +00:00
|
|
|
.domainGetVcpus = parallelsDomainGetVcpus, /* 1.2.6 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.domainSuspend = parallelsDomainSuspend, /* 0.10.0 */
|
|
|
|
.domainResume = parallelsDomainResume, /* 0.10.0 */
|
|
|
|
.domainDestroy = parallelsDomainDestroy, /* 0.10.0 */
|
|
|
|
.domainShutdown = parallelsDomainShutdown, /* 0.10.0 */
|
2012-07-31 18:56:08 +00:00
|
|
|
.domainCreate = parallelsDomainCreate, /* 0.10.0 */
|
2014-12-01 15:38:56 +00:00
|
|
|
.domainCreateWithFlags = parallelsDomainCreateWithFlags, /* 1.2.10 */
|
2012-07-31 18:56:11 +00:00
|
|
|
.domainDefineXML = parallelsDomainDefineXML, /* 0.10.0 */
|
2014-11-18 14:19:38 +00:00
|
|
|
.domainDefineXMLFlags = parallelsDomainDefineXMLFlags, /* 1.2.12 */
|
2014-12-01 15:38:58 +00:00
|
|
|
.domainUndefine = parallelsDomainUndefine, /* 1.2.10 */
|
|
|
|
.domainUndefineFlags = parallelsDomainUndefineFlags, /* 1.2.10 */
|
2015-04-09 10:42:00 +00:00
|
|
|
.domainAttachDevice = parallelsDomainAttachDevice, /* 1.2.15 */
|
2015-04-13 14:55:27 +00:00
|
|
|
.domainAttachDeviceFlags = parallelsDomainAttachDeviceFlags, /* 1.2.15 */
|
2014-12-01 15:38:55 +00:00
|
|
|
.domainIsActive = parallelsDomainIsActive, /* 1.2.10 */
|
2014-12-01 15:38:50 +00:00
|
|
|
.connectDomainEventRegisterAny = parallelsConnectDomainEventRegisterAny, /* 1.2.10 */
|
|
|
|
.connectDomainEventDeregisterAny = parallelsConnectDomainEventDeregisterAny, /* 1.2.10 */
|
2014-08-22 11:04:43 +00:00
|
|
|
.nodeGetCPUMap = parallelsNodeGetCPUMap, /* 1.2.8 */
|
2014-04-23 14:35:03 +00:00
|
|
|
.connectIsEncrypted = parallelsConnectIsEncrypted, /* 1.2.5 */
|
|
|
|
.connectIsSecure = parallelsConnectIsSecure, /* 1.2.5 */
|
|
|
|
.connectIsAlive = parallelsConnectIsAlive, /* 1.2.5 */
|
2015-01-15 14:02:44 +00:00
|
|
|
.domainHasManagedSaveImage = parallelsDomainHasManagedSaveImage, /* 1.2.13 */
|
2015-04-07 20:35:02 +00:00
|
|
|
.domainManagedSave = parallelsDomainManagedSave, /* 1.2.14 */
|
|
|
|
.domainManagedSaveRemove = parallelsDomainManagedSaveRemove, /* 1.2.14 */
|
2012-07-31 18:56:05 +00:00
|
|
|
};
|
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
static virConnectDriver parallelsConnectDriver = {
|
|
|
|
.hypervisorDriver = ¶llelsDriver,
|
|
|
|
.storageDriver = ¶llelsStorageDriver,
|
|
|
|
.networkDriver = ¶llelsNetworkDriver,
|
|
|
|
};
|
|
|
|
|
2012-07-31 18:56:05 +00:00
|
|
|
/**
|
|
|
|
* parallelsRegister:
|
|
|
|
*
|
|
|
|
* Registers the parallels driver
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
parallelsRegister(void)
|
|
|
|
{
|
|
|
|
char *prlctl_path;
|
|
|
|
|
|
|
|
prlctl_path = virFindFileInPath(PRLCTL);
|
|
|
|
if (!prlctl_path) {
|
|
|
|
VIR_DEBUG("%s", _("Can't find prlctl command in the PATH env"));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_FREE(prlctl_path);
|
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
if (virRegisterConnectDriver(¶llelsConnectDriver, false) < 0)
|
2012-12-11 10:59:45 +00:00
|
|
|
return -1;
|
2012-07-31 18:56:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|