40
40
#include "xm_internal.h"
44
45
#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt,__VA_ARGS__)
45
46
#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg)
172
173
if (xenUnifiedNodeGetInfo(dom->conn, &nodeinfo) < 0)
175
cpulist = calloc(nb_cpu, sizeof(*cpulist));
176
if (VIR_ALLOC_N(cpulist, nb_cpu) < 0)
178
cpuinfo = malloc(sizeof(*cpuinfo) * nb_vcpu);
178
if (VIR_ALLOC_N(cpuinfo, nb_vcpu) < 0)
181
180
cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
182
cpumap = (unsigned char *) calloc(nb_vcpu, cpumaplen);
181
if (xalloc_oversized(nb_vcpu, cpumaplen) ||
182
VIR_ALLOC_N(cpumap, nb_vcpu * cpumaplen) < 0)
186
185
if ((ncpus = xenUnifiedDomainGetVcpus(dom, cpuinfo, nb_vcpu,
187
186
cpumap, cpumaplen)) >= 0) {
188
for (n = 0 ; n < ncpus ; n++) {
189
for (m = 0 ; m < nb_cpu; m++) {
190
if ((cpulist[m] == 0) &&
191
(VIR_CPU_USABLE(cpumap, cpumaplen, n, m))) {
194
/* if all CPU are used just return NULL */
187
for (n = 0 ; n < ncpus ; n++) {
188
for (m = 0 ; m < nb_cpu; m++) {
189
if ((cpulist[m] == 0) &&
190
(VIR_CPU_USABLE(cpumap, cpumaplen, n, m))) {
193
/* if all CPU are used just return NULL */
201
200
res = virSaveCpuSet(dom->conn, cpulist, nb_cpu);
246
245
/* Refuse any scheme which isn't "xen://" or "http://". */
247
246
if (uri->scheme &&
248
strcasecmp(uri->scheme, "xen") != 0 &&
249
strcasecmp(uri->scheme, "http") != 0)
247
STRCASENEQ(uri->scheme, "xen") &&
248
STRCASENEQ(uri->scheme, "http"))
250
249
return VIR_DRV_OPEN_DECLINED;
252
251
/* xmlParseURI will parse a naked string like "foo" as a URI with
258
257
return VIR_DRV_OPEN_DECLINED;
260
259
/* Refuse any xen:// URI with a server specified - allow remote to do it */
261
if (uri->scheme && strcasecmp(uri->scheme, "xen") == 0 && uri->server)
260
if (uri->scheme && STRCASEEQ(uri->scheme, "xen") && uri->server)
262
261
return VIR_DRV_OPEN_DECLINED;
264
263
/* Allocate per-connection private data. */
265
priv = calloc (1, sizeof *priv);
264
if (VIR_ALLOC(priv) < 0) {
267
265
xenUnifiedError (NULL, VIR_ERR_NO_MEMORY, "allocating private data");
268
266
return VIR_DRV_OPEN_ERROR;
1130
xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
1132
GET_PRIVATE(dom->conn);
1135
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
1136
if (priv->opened[i] && drivers[i]->domainGetAutostart &&
1137
drivers[i]->domainGetAutostart (dom, autostart) == 0)
1144
xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
1146
GET_PRIVATE(dom->conn);
1149
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
1150
if (priv->opened[i] && drivers[i]->domainSetAutostart &&
1151
drivers[i]->domainSetAutostart (dom, autostart) == 0)
1132
1158
xenUnifiedDomainGetSchedulerType (virDomainPtr dom, int *nparams)
1138
1164
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; i++) {
1139
1165
if (priv->opened[i] && drivers[i]->domainGetSchedulerType) {
1140
1166
schedulertype = drivers[i]->domainGetSchedulerType (dom, nparams);
1141
if (schedulertype != NULL)
1142
return(schedulertype);
1167
if (schedulertype != NULL)
1168
return(schedulertype);
1236
xenUnifiedDomainBlockPeek (virDomainPtr dom, const char *path,
1237
unsigned long long offset, size_t size,
1238
void *buffer, unsigned int flags ATTRIBUTE_UNUSED)
1241
GET_PRIVATE (dom->conn);
1243
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
1244
r = xenDaemonDomainBlockPeek (dom, path, offset, size, buffer);
1245
if (r != -2) return r;
1246
/* r == -2 means declined, so fall through to XM driver ... */
1249
if (priv->opened[XEN_UNIFIED_XM_OFFSET]) {
1250
if (xenXMDomainBlockPeek (dom, path, offset, size, buffer) == 0)
1254
xenUnifiedError (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
1210
1259
xenUnifiedNodeGetCellsFreeMemory (virConnectPtr conn, unsigned long long *freeMems,
1211
1260
int startCell, int maxCells)
1230
1279
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
1231
1280
ret = xenHypervisorNodeGetCellsFreeMemory (conn, &freeMem,
1238
1287
xenUnifiedError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
1291
1340
.domainUndefine = xenUnifiedDomainUndefine,
1292
1341
.domainAttachDevice = xenUnifiedDomainAttachDevice,
1293
1342
.domainDetachDevice = xenUnifiedDomainDetachDevice,
1343
.domainGetAutostart = xenUnifiedDomainGetAutostart,
1344
.domainSetAutostart = xenUnifiedDomainSetAutostart,
1294
1345
.domainGetSchedulerType = xenUnifiedDomainGetSchedulerType,
1295
1346
.domainGetSchedulerParameters = xenUnifiedDomainGetSchedulerParameters,
1296
1347
.domainSetSchedulerParameters = xenUnifiedDomainSetSchedulerParameters,
1299
1350
.domainMigrateFinish = xenUnifiedDomainMigrateFinish,
1300
1351
.domainBlockStats = xenUnifiedDomainBlockStats,
1301
1352
.domainInterfaceStats = xenUnifiedDomainInterfaceStats,
1353
.domainBlockPeek = xenUnifiedDomainBlockPeek,
1302
1354
.nodeGetCellsFreeMemory = xenUnifiedNodeGetCellsFreeMemory,
1303
1355
.getFreeMemory = xenUnifiedNodeGetFreeMemory,