2006-06-06 03:32:51 +00:00
|
|
|
/*
|
|
|
|
* test.c: A "mock" hypervisor for use by application unit tests
|
|
|
|
*
|
2009-02-03 13:08:07 +00:00
|
|
|
* Copyright (C) 2006-2009 Red Hat, Inc.
|
2007-01-18 21:08:21 +00:00
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
2006-06-06 03:32:51 +00:00
|
|
|
*
|
2007-01-18 21:08:21 +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
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2006-06-06 03:32:51 +00:00
|
|
|
*
|
|
|
|
* Daniel Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2008-01-29 18:15:54 +00:00
|
|
|
#include <config.h>
|
2007-11-26 11:50:16 +00:00
|
|
|
|
2006-06-06 03:32:51 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/time.h>
|
2006-08-16 16:36:39 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2007-12-07 14:45:39 +00:00
|
|
|
#include <sys/stat.h>
|
2008-10-30 17:40:57 +00:00
|
|
|
#include <libxml/xmlsave.h>
|
2007-12-07 14:45:39 +00:00
|
|
|
|
2008-11-04 22:30:33 +00:00
|
|
|
|
|
|
|
#include "virterror_internal.h"
|
2008-11-04 23:22:06 +00:00
|
|
|
#include "datatypes.h"
|
2006-06-06 03:32:51 +00:00
|
|
|
#include "test.h"
|
2007-06-26 22:33:22 +00:00
|
|
|
#include "buf.h"
|
Use safewrite in place of write, in many cases.
Also add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
* Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
* .x-sc_avoid_write: New file. Record two legitimate exemptions.
* qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
* src/conf.c (__virConfWriteFile): Likewise.
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD): Likewise.
* proxy/libvirt_proxy.c: Include "util.h".
(proxyWriteClientSocket): Use safewrite.
* src/test.c (testDomainSave, testDomainCoreDump): Likewise.
* src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
* src/virsh.c: Include "util-lib.h".
(vshOutputLogFile): Use safewrite.
* src/console.c: Include "util-lib.h".
(vshRunConsole): Use safewrite.
2008-02-22 15:55:04 +00:00
|
|
|
#include "util.h"
|
2007-08-09 20:19:12 +00:00
|
|
|
#include "uuid.h"
|
2008-02-27 04:35:08 +00:00
|
|
|
#include "capabilities.h"
|
2008-05-29 19:20:22 +00:00
|
|
|
#include "memory.h"
|
2008-07-11 16:39:08 +00:00
|
|
|
#include "network_conf.h"
|
2008-07-11 16:41:27 +00:00
|
|
|
#include "domain_conf.h"
|
2009-01-20 20:23:53 +00:00
|
|
|
#include "domain_event.h"
|
|
|
|
#include "event.h"
|
2008-10-30 17:40:57 +00:00
|
|
|
#include "storage_conf.h"
|
2008-07-11 16:41:27 +00:00
|
|
|
#include "xml.h"
|
2009-01-15 19:56:05 +00:00
|
|
|
#include "threads.h"
|
2009-01-20 20:23:53 +00:00
|
|
|
#include "logging.h"
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_TEST
|
|
|
|
|
2008-04-04 07:31:24 +00:00
|
|
|
#define MAX_CPUS 128
|
|
|
|
|
|
|
|
struct _testCell {
|
|
|
|
unsigned long mem;
|
|
|
|
int numCpus;
|
|
|
|
int cpus[MAX_CPUS];
|
|
|
|
};
|
|
|
|
typedef struct _testCell testCell;
|
|
|
|
typedef struct _testCell *testCellPtr;
|
|
|
|
|
|
|
|
#define MAX_CELLS 128
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
struct _testConn {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 20:59:06 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
char path[PATH_MAX];
|
|
|
|
int nextDomID;
|
2008-07-11 16:41:27 +00:00
|
|
|
virCapsPtr caps;
|
2007-01-18 21:08:21 +00:00
|
|
|
virNodeInfo nodeInfo;
|
2008-10-10 14:20:37 +00:00
|
|
|
virDomainObjList domains;
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjList networks;
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolObjList pools;
|
2008-04-04 07:31:24 +00:00
|
|
|
int numCells;
|
|
|
|
testCell cells[MAX_CELLS];
|
2009-01-20 20:23:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* An array of callbacks */
|
|
|
|
virDomainEventCallbackListPtr domainEventCallbacks;
|
|
|
|
virDomainEventQueuePtr domainEventQueue;
|
|
|
|
int domainEventTimer;
|
|
|
|
int domainEventDispatching;
|
2007-07-27 23:23:00 +00:00
|
|
|
};
|
|
|
|
typedef struct _testConn testConn;
|
|
|
|
typedef struct _testConn *testConnPtr;
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2007-03-15 17:24:56 +00:00
|
|
|
#define TEST_MODEL "i686"
|
2008-02-27 04:35:08 +00:00
|
|
|
#define TEST_MODEL_WORDSIZE 32
|
2008-07-11 16:41:27 +00:00
|
|
|
#define TEST_EMULATOR "/usr/bin/test-hv"
|
2007-03-15 17:24:56 +00:00
|
|
|
|
2006-08-16 16:36:39 +00:00
|
|
|
static const virNodeInfo defaultNodeInfo = {
|
2007-03-15 17:24:56 +00:00
|
|
|
TEST_MODEL,
|
2007-01-18 21:08:21 +00:00
|
|
|
1024*1024*3, /* 3 GB */
|
|
|
|
16,
|
|
|
|
1400,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
2,
|
2006-06-06 03:32:51 +00:00
|
|
|
};
|
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
#define testError(conn, code, fmt...) \
|
2008-11-04 22:30:33 +00:00
|
|
|
virReportErrorHelper(conn, VIR_FROM_TEST, code, __FILE__, \
|
2008-10-09 15:38:31 +00:00
|
|
|
__FUNCTION__, __LINE__, fmt)
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2009-01-20 20:23:53 +00:00
|
|
|
static int testClose(virConnectPtr conn);
|
|
|
|
static void testDomainEventFlush(int timer, void *opaque);
|
|
|
|
static void testDomainEventQueue(testConnPtr driver,
|
|
|
|
virDomainEventPtr event);
|
|
|
|
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
static void testDriverLock(testConnPtr driver)
|
|
|
|
{
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&driver->lock);
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void testDriverUnlock(testConnPtr driver)
|
|
|
|
{
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&driver->lock);
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
static virCapsPtr
|
|
|
|
testBuildCapabilities(virConnectPtr conn) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-07-11 16:41:27 +00:00
|
|
|
virCapsPtr caps;
|
|
|
|
virCapsGuestPtr guest;
|
|
|
|
const char *const guest_types[] = { "hvm", "xen" };
|
|
|
|
int i;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if ((caps = virCapabilitiesNew(TEST_MODEL, 0, 0)) == NULL)
|
|
|
|
goto no_memory;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (virCapabilitiesAddHostFeature(caps, "pae") < 0)
|
|
|
|
goto no_memory;
|
|
|
|
if (virCapabilitiesAddHostFeature(caps ,"nonpae") < 0)
|
|
|
|
goto no_memory;
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
for (i = 0; i < privconn->numCells; i++) {
|
|
|
|
if (virCapabilitiesAddHostNUMACell(caps, i, privconn->cells[i].numCpus,
|
|
|
|
privconn->cells[i].cpus) < 0)
|
|
|
|
goto no_memory;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
for (i = 0; i < ARRAY_CARDINALITY(guest_types) ; i++) {
|
|
|
|
if ((guest = virCapabilitiesAddGuest(caps,
|
|
|
|
guest_types[i],
|
|
|
|
TEST_MODEL,
|
|
|
|
TEST_MODEL_WORDSIZE,
|
|
|
|
TEST_EMULATOR,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL)) == NULL)
|
|
|
|
goto no_memory;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (virCapabilitiesAddGuestDomain(guest,
|
|
|
|
"test",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL) == NULL)
|
|
|
|
goto no_memory;
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (virCapabilitiesAddGuestFeature(guest, "pae", 1, 1) == NULL)
|
|
|
|
goto no_memory;
|
|
|
|
if (virCapabilitiesAddGuestFeature(guest ,"nonpae", 1, 1) == NULL)
|
|
|
|
goto no_memory;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return caps;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
no_memory:
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-07-11 16:41:27 +00:00
|
|
|
virCapabilitiesFree(caps);
|
|
|
|
return NULL;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
static const char *defaultDomainXML =
|
|
|
|
"<domain type='test'>"
|
|
|
|
" <name>test</name>"
|
|
|
|
" <memory>8388608</memory>"
|
|
|
|
" <currentMemory>2097152</currentMemory>"
|
|
|
|
" <vcpu>2</vcpu>"
|
|
|
|
" <os>"
|
|
|
|
" <type>hvm</type>"
|
|
|
|
" </os>"
|
|
|
|
"</domain>";
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
static const char *defaultNetworkXML =
|
|
|
|
"<network>"
|
|
|
|
" <name>default</name>"
|
|
|
|
" <bridge name='virbr0' />"
|
|
|
|
" <forward/>"
|
|
|
|
" <ip address='192.168.122.1' netmask='255.255.255.0'>"
|
|
|
|
" <dhcp>"
|
|
|
|
" <range start='192.168.122.2' end='192.168.122.254' />"
|
|
|
|
" </dhcp>"
|
|
|
|
" </ip>"
|
|
|
|
"</network>";
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
static const char *defaultPoolXML =
|
|
|
|
"<pool type='dir'>"
|
|
|
|
" <name>default-pool</name>"
|
|
|
|
" <target>"
|
|
|
|
" <path>/default-pool</path>"
|
|
|
|
" </target>"
|
|
|
|
"</pool>";
|
|
|
|
|
2008-12-07 20:45:28 +00:00
|
|
|
static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ull);
|
2008-10-30 17:40:57 +00:00
|
|
|
static const unsigned long long defaultPoolAlloc = 0;
|
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
static int testStoragePoolObjSetDefaults(virConnectPtr conn, virStoragePoolObjPtr pool);
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testOpenDefault(virConnectPtr conn) {
|
2007-01-18 21:08:21 +00:00
|
|
|
int u;
|
|
|
|
struct timeval tv;
|
2008-05-29 19:20:22 +00:00
|
|
|
testConnPtr privconn;
|
2008-07-11 16:41:27 +00:00
|
|
|
virDomainDefPtr domdef = NULL;
|
|
|
|
virDomainObjPtr domobj = NULL;
|
|
|
|
virNetworkDefPtr netdef = NULL;
|
|
|
|
virNetworkObjPtr netobj = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolDefPtr pooldef = NULL;
|
|
|
|
virStoragePoolObjPtr poolobj = NULL;
|
2008-07-11 16:39:08 +00:00
|
|
|
|
2008-05-29 19:20:22 +00:00
|
|
|
if (VIR_ALLOC(privconn) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2009-01-15 19:56:05 +00:00
|
|
|
if (virMutexInit(&privconn->lock) < 0) {
|
|
|
|
testError(conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("cannot initialize mutex"));
|
|
|
|
VIR_FREE(privconn);
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2009-01-15 19:56:05 +00:00
|
|
|
conn->privateData = privconn;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
if (gettimeofday(&tv, NULL) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(conn, errno,
|
|
|
|
"%s", _("getting time of day"));
|
2008-07-11 16:41:27 +00:00
|
|
|
goto error;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo));
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-04-04 07:31:24 +00:00
|
|
|
// Numa setup
|
|
|
|
privconn->numCells = 2;
|
|
|
|
for (u = 0; u < 2; ++u) {
|
|
|
|
privconn->cells[u].numCpus = 8;
|
|
|
|
privconn->cells[u].mem = (u + 1) * 2048 * 1024;
|
|
|
|
}
|
|
|
|
for (u = 0 ; u < 16 ; u++) {
|
|
|
|
privconn->cells[u % 2].cpus[(u / 2)] = u;
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!(privconn->caps = testBuildCapabilities(conn)))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
privconn->nextDomID = 1;
|
|
|
|
|
2009-01-08 13:54:20 +00:00
|
|
|
if (!(domdef = virDomainDefParseString(conn, privconn->caps,
|
|
|
|
defaultDomainXML,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE)))
|
2008-07-11 16:41:27 +00:00
|
|
|
goto error;
|
|
|
|
if (!(domobj = virDomainAssignDef(conn, &privconn->domains, domdef))) {
|
|
|
|
virDomainDefFree(domdef);
|
|
|
|
goto error;
|
|
|
|
}
|
2008-07-25 13:27:12 +00:00
|
|
|
domobj->def->id = privconn->nextDomID++;
|
2008-07-11 16:41:27 +00:00
|
|
|
domobj->state = VIR_DOMAIN_RUNNING;
|
|
|
|
domobj->persistent = 1;
|
2008-12-04 20:59:06 +00:00
|
|
|
virDomainObjUnlock(domobj);
|
2008-07-11 16:41:27 +00:00
|
|
|
|
|
|
|
if (!(netdef = virNetworkDefParseString(conn, defaultNetworkXML)))
|
|
|
|
goto error;
|
|
|
|
if (!(netobj = virNetworkAssignDef(conn, &privconn->networks, netdef))) {
|
|
|
|
virNetworkDefFree(netdef);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
netobj->active = 1;
|
|
|
|
netobj->persistent = 1;
|
2008-12-04 20:59:06 +00:00
|
|
|
virNetworkObjUnlock(netobj);
|
2008-07-11 16:41:27 +00:00
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
if (!(pooldef = virStoragePoolDefParse(conn, defaultPoolXML, NULL)))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!(poolobj = virStoragePoolObjAssignDef(conn, &privconn->pools,
|
|
|
|
pooldef))) {
|
|
|
|
virStoragePoolDefFree(pooldef);
|
|
|
|
goto error;
|
|
|
|
}
|
2008-12-04 20:59:06 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
if (testStoragePoolObjSetDefaults(conn, poolobj) == -1) {
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(poolobj);
|
2008-10-30 17:40:57 +00:00
|
|
|
goto error;
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
poolobj->active = 1;
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(poolobj);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2009-01-15 19:56:05 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
|
|
|
|
error:
|
2008-10-10 14:20:37 +00:00
|
|
|
virDomainObjListFree(&privconn->domains);
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjListFree(&privconn->networks);
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolObjListFree(&privconn->pools);
|
2008-07-11 16:41:27 +00:00
|
|
|
virCapabilitiesFree(privconn->caps);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2009-01-15 19:56:05 +00:00
|
|
|
conn->privateData = NULL;
|
2008-07-11 16:41:27 +00:00
|
|
|
VIR_FREE(privconn);
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *testBuildFilename(const char *relativeTo,
|
2007-01-18 21:08:21 +00:00
|
|
|
const char *filename) {
|
|
|
|
char *offset;
|
|
|
|
int baseLen;
|
|
|
|
if (!filename || filename[0] == '\0')
|
|
|
|
return (NULL);
|
|
|
|
if (filename[0] == '/')
|
|
|
|
return strdup(filename);
|
|
|
|
|
2007-06-15 13:44:19 +00:00
|
|
|
offset = strrchr(relativeTo, '/');
|
2007-01-18 21:08:21 +00:00
|
|
|
if ((baseLen = (offset-relativeTo+1))) {
|
2008-05-29 19:20:22 +00:00
|
|
|
char *absFile;
|
|
|
|
if (VIR_ALLOC_N(absFile, baseLen + strlen(filename) + 1) < 0)
|
|
|
|
return NULL;
|
2007-01-18 21:08:21 +00:00
|
|
|
strncpy(absFile, relativeTo, baseLen);
|
|
|
|
absFile[baseLen] = '\0';
|
|
|
|
strcat(absFile, filename);
|
|
|
|
return absFile;
|
|
|
|
} else {
|
|
|
|
return strdup(filename);
|
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testOpenFromFile(virConnectPtr conn,
|
2007-01-18 21:08:21 +00:00
|
|
|
const char *file) {
|
2007-07-27 23:23:00 +00:00
|
|
|
int fd = -1, i, ret;
|
2007-04-06 15:34:09 +00:00
|
|
|
long l;
|
|
|
|
char *str;
|
2007-07-27 23:23:00 +00:00
|
|
|
xmlDocPtr xml = NULL;
|
2007-01-18 21:08:21 +00:00
|
|
|
xmlNodePtr root = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
xmlNodePtr *domains = NULL, *networks = NULL, *pools = NULL;
|
2007-01-18 21:08:21 +00:00
|
|
|
xmlXPathContextPtr ctxt = NULL;
|
|
|
|
virNodeInfoPtr nodeInfo;
|
2008-07-11 16:41:27 +00:00
|
|
|
virNetworkObjPtr net;
|
|
|
|
virDomainObjPtr dom;
|
2008-05-29 19:20:22 +00:00
|
|
|
testConnPtr privconn;
|
|
|
|
if (VIR_ALLOC(privconn) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2009-01-15 19:56:05 +00:00
|
|
|
if (virMutexInit(&privconn->lock) < 0) {
|
|
|
|
testError(conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("cannot initialize mutex"));
|
|
|
|
VIR_FREE(privconn);
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2009-01-15 19:56:05 +00:00
|
|
|
conn->privateData = privconn;
|
2008-07-11 16:41:27 +00:00
|
|
|
|
|
|
|
if (!(privconn->caps = testBuildCapabilities(conn)))
|
|
|
|
goto error;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
if ((fd = open(file, O_RDONLY)) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(NULL, errno,
|
|
|
|
_("loading host definition file '%s'"),
|
|
|
|
file);
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
if (!(xml = xmlReadFd(fd, file, NULL,
|
|
|
|
XML_PARSE_NOENT | XML_PARSE_NONET |
|
|
|
|
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("host"));
|
2007-01-18 21:08:21 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
root = xmlDocGetRootElement(xml);
|
|
|
|
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "node"))) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node"));
|
2007-01-18 21:08:21 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
ctxt = xmlXPathNewContext(xml);
|
|
|
|
if (ctxt == NULL) {
|
2008-10-30 17:40:57 +00:00
|
|
|
testError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("creating xpath context"));
|
2007-01-18 21:08:21 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
privconn->nextDomID = 1;
|
2008-04-04 07:31:24 +00:00
|
|
|
privconn->numCells = 0;
|
2007-07-27 23:23:00 +00:00
|
|
|
strncpy(privconn->path, file, PATH_MAX-1);
|
|
|
|
privconn->path[PATH_MAX-1] = '\0';
|
|
|
|
memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo));
|
|
|
|
|
|
|
|
nodeInfo = &privconn->nodeInfo;
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathLong(conn, "string(/node/cpu/nodes[1])", ctxt, &l);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
nodeInfo->nodes = l;
|
|
|
|
} else if (ret == -2) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node cpu numa nodes"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathLong(conn, "string(/node/cpu/sockets[1])", ctxt, &l);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
nodeInfo->sockets = l;
|
|
|
|
} else if (ret == -2) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node cpu sockets"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathLong(conn, "string(/node/cpu/cores[1])", ctxt, &l);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
nodeInfo->cores = l;
|
|
|
|
} else if (ret == -2) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node cpu cores"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathLong(conn, "string(/node/cpu/threads[1])", ctxt, &l);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
nodeInfo->threads = l;
|
|
|
|
} else if (ret == -2) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node cpu threads"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-04-06 15:34:09 +00:00
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
nodeInfo->cpus = nodeInfo->cores * nodeInfo->threads * nodeInfo->sockets * nodeInfo->nodes;
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathLong(conn, "string(/node/cpu/active[1])", ctxt, &l);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
if (l < nodeInfo->cpus) {
|
2007-07-27 23:23:00 +00:00
|
|
|
nodeInfo->cpus = l;
|
|
|
|
}
|
2007-04-06 15:34:09 +00:00
|
|
|
} else if (ret == -2) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node active cpu"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2007-04-06 15:34:09 +00:00
|
|
|
}
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathLong(conn, "string(/node/cpu/mhz[1])", ctxt, &l);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
nodeInfo->mhz = l;
|
|
|
|
} else if (ret == -2) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node cpu mhz"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2007-04-06 15:34:09 +00:00
|
|
|
}
|
|
|
|
|
2008-07-25 14:27:25 +00:00
|
|
|
str = virXPathString(conn, "string(/node/cpu/model[1])", ctxt);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (str != NULL) {
|
|
|
|
strncpy(nodeInfo->model, str, sizeof(nodeInfo->model)-1);
|
2007-01-18 21:08:21 +00:00
|
|
|
nodeInfo->model[sizeof(nodeInfo->model)-1] = '\0';
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(str);
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathLong(conn, "string(/node/memory[1])", ctxt, &l);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
nodeInfo->memory = l;
|
|
|
|
} else if (ret == -2) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node memory"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathNodeSet(conn, "/node/domain", ctxt, &domains);
|
2007-04-06 15:34:09 +00:00
|
|
|
if (ret < 0) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node domain list"));
|
2007-01-18 21:08:21 +00:00
|
|
|
goto error;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2007-04-06 15:34:09 +00:00
|
|
|
for (i = 0 ; i < ret ; i++) {
|
2008-07-11 16:41:27 +00:00
|
|
|
virDomainDefPtr def;
|
|
|
|
char *relFile = virXMLPropString(domains[i], "file");
|
|
|
|
if (relFile != NULL) {
|
|
|
|
char *absFile = testBuildFilename(file, relFile);
|
|
|
|
VIR_FREE(relFile);
|
|
|
|
if (!absFile) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("resolving domain filename"));
|
2008-07-11 16:41:27 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2008-12-04 12:02:59 +00:00
|
|
|
def = virDomainDefParseFile(conn, privconn->caps, absFile,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE);
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(absFile);
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!def)
|
|
|
|
goto error;
|
|
|
|
} else {
|
2008-12-04 12:02:59 +00:00
|
|
|
if ((def = virDomainDefParseNode(conn, privconn->caps, xml, domains[i],
|
|
|
|
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
2008-07-11 16:41:27 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(dom = virDomainAssignDef(conn, &privconn->domains, def))) {
|
|
|
|
virDomainDefFree(def);
|
2007-01-18 21:08:21 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
|
|
|
|
dom->state = VIR_DOMAIN_RUNNING;
|
|
|
|
dom->def->id = privconn->nextDomID++;
|
|
|
|
dom->persistent = 1;
|
2008-12-04 20:59:06 +00:00
|
|
|
virDomainObjUnlock(dom);
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
2009-02-03 13:08:07 +00:00
|
|
|
VIR_FREE(domains);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-25 14:27:25 +00:00
|
|
|
ret = virXPathNodeSet(conn, "/node/network", ctxt, &networks);
|
2008-07-11 16:39:08 +00:00
|
|
|
if (ret < 0) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node network list"));
|
2008-07-11 16:39:08 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
for (i = 0 ; i < ret ; i++) {
|
|
|
|
virNetworkDefPtr def;
|
|
|
|
char *relFile = virXMLPropString(networks[i], "file");
|
|
|
|
if (relFile != NULL) {
|
|
|
|
char *absFile = testBuildFilename(file, relFile);
|
|
|
|
VIR_FREE(relFile);
|
2007-07-27 23:23:00 +00:00
|
|
|
if (!absFile) {
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
testError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("resolving network filename"));
|
2007-07-27 23:23:00 +00:00
|
|
|
goto error;
|
|
|
|
}
|
2008-07-11 16:39:08 +00:00
|
|
|
|
|
|
|
def = virNetworkDefParseFile(conn, absFile);
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(absFile);
|
2008-07-11 16:39:08 +00:00
|
|
|
if (!def)
|
|
|
|
goto error;
|
|
|
|
} else {
|
|
|
|
if ((def = virNetworkDefParseNode(conn, xml, networks[i])) == NULL)
|
|
|
|
goto error;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-07-11 16:39:08 +00:00
|
|
|
if (!(net = virNetworkAssignDef(conn, &privconn->networks,
|
|
|
|
def))) {
|
|
|
|
virNetworkDefFree(def);
|
|
|
|
goto error;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-07-11 16:39:08 +00:00
|
|
|
net->persistent = 1;
|
2008-12-04 20:59:06 +00:00
|
|
|
virNetworkObjUnlock(net);
|
2008-07-11 16:39:08 +00:00
|
|
|
}
|
2009-02-03 13:08:07 +00:00
|
|
|
VIR_FREE(networks);
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
/* Parse Storage Pool list */
|
|
|
|
ret = virXPathNodeSet(conn, "/node/pool", ctxt, &pools);
|
|
|
|
if (ret < 0) {
|
|
|
|
testError(NULL, VIR_ERR_XML_ERROR, "%s", _("node pool list"));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
for (i = 0 ; i < ret ; i++) {
|
|
|
|
virStoragePoolDefPtr def;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
char *relFile = virXMLPropString(pools[i], "file");
|
|
|
|
if (relFile != NULL) {
|
|
|
|
char *absFile = testBuildFilename(file, relFile);
|
|
|
|
VIR_FREE(relFile);
|
|
|
|
if (!absFile) {
|
|
|
|
testError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("resolving pool filename"));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
def = virStoragePoolDefParse(conn, NULL, absFile);
|
|
|
|
VIR_FREE(absFile);
|
|
|
|
if (!def)
|
|
|
|
goto error;
|
|
|
|
} else {
|
|
|
|
xmlBufferPtr buf;
|
|
|
|
xmlSaveCtxtPtr sctxt;
|
|
|
|
|
|
|
|
buf = xmlBufferCreate();
|
|
|
|
sctxt = xmlSaveToBuffer(buf, NULL, 0);
|
|
|
|
xmlSaveTree(sctxt, pools[i]);
|
|
|
|
xmlSaveClose(sctxt);
|
|
|
|
if ((def = virStoragePoolDefParse(conn,
|
|
|
|
(const char *) buf->content,
|
|
|
|
NULL)) == NULL) {
|
|
|
|
xmlBufferFree(buf);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools,
|
|
|
|
def))) {
|
|
|
|
virStoragePoolDefFree(def);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
if (testStoragePoolObjSetDefaults(conn, pool) == -1) {
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-10-30 17:40:57 +00:00
|
|
|
goto error;
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
pool->active = 1;
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
2009-02-03 13:08:07 +00:00
|
|
|
VIR_FREE(pools);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-01-30 19:50:14 +00:00
|
|
|
xmlXPathFreeContext(ctxt);
|
2007-01-18 21:08:21 +00:00
|
|
|
xmlFreeDoc(xml);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
return (0);
|
2006-08-16 16:36:39 +00:00
|
|
|
|
|
|
|
error:
|
2008-01-30 19:50:14 +00:00
|
|
|
xmlXPathFreeContext(ctxt);
|
2008-07-11 16:41:27 +00:00
|
|
|
xmlFreeDoc(xml);
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(domains);
|
|
|
|
VIR_FREE(networks);
|
2008-10-30 17:40:57 +00:00
|
|
|
VIR_FREE(pools);
|
2007-01-18 21:08:21 +00:00
|
|
|
if (fd != -1)
|
|
|
|
close(fd);
|
2008-10-10 14:20:37 +00:00
|
|
|
virDomainObjListFree(&privconn->domains);
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjListFree(&privconn->networks);
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolObjListFree(&privconn->pools);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(privconn);
|
2007-07-27 23:23:00 +00:00
|
|
|
conn->privateData = NULL;
|
2007-04-04 14:19:49 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2008-12-17 21:26:16 +00:00
|
|
|
static virDrvOpenStatus testOpen(virConnectPtr conn,
|
2007-12-05 18:28:05 +00:00
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
2007-07-27 23:23:00 +00:00
|
|
|
int flags ATTRIBUTE_UNUSED)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
int ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
if (!conn->uri)
|
2007-04-04 14:19:49 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
if (!conn->uri->scheme || STRNEQ(conn->uri->scheme, "test"))
|
2007-04-04 14:19:49 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2007-06-20 10:01:14 +00:00
|
|
|
/* Remote driver should handle these. */
|
2008-11-17 11:44:51 +00:00
|
|
|
if (conn->uri->server)
|
2007-06-20 10:01:14 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
if (conn->uri->server)
|
2007-06-26 22:57:41 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2007-04-18 10:14:07 +00:00
|
|
|
/* From this point on, the connection is for us. */
|
2008-11-17 11:44:51 +00:00
|
|
|
if (!conn->uri->path
|
|
|
|
|| conn->uri->path[0] == '\0'
|
|
|
|
|| (conn->uri->path[0] == '/' && conn->uri->path[1] == '\0')) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError (NULL, VIR_ERR_INVALID_ARG,
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
"%s", _("testOpen: supply a path or use test:///default"));
|
2007-04-18 10:14:07 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2008-11-17 11:44:51 +00:00
|
|
|
if (STREQ(conn->uri->path, "/default"))
|
2007-07-27 23:23:00 +00:00
|
|
|
ret = testOpenDefault(conn);
|
|
|
|
else
|
2007-01-18 21:08:21 +00:00
|
|
|
ret = testOpenFromFile(conn,
|
2008-11-17 11:44:51 +00:00
|
|
|
conn->uri->path);
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2009-01-20 20:23:53 +00:00
|
|
|
if (ret == VIR_DRV_OPEN_SUCCESS) {
|
|
|
|
testConnPtr privconn = conn->privateData;
|
|
|
|
/* Init callback list */
|
|
|
|
if (VIR_ALLOC(privconn->domainEventCallbacks) < 0 ||
|
|
|
|
!(privconn->domainEventQueue = virDomainEventQueueNew())) {
|
|
|
|
virReportOOMError(NULL);
|
|
|
|
testClose(conn);
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((privconn->domainEventTimer =
|
|
|
|
virEventAddTimeout(-1, testDomainEventFlush, privconn, NULL)) < 0)
|
|
|
|
DEBUG0("virEventAddTimeout failed: No addTimeoutImpl defined. "
|
|
|
|
"continuing without events.");
|
|
|
|
}
|
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
return (ret);
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testClose(virConnectPtr conn)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-07-11 16:41:27 +00:00
|
|
|
virCapabilitiesFree(privconn->caps);
|
2008-10-10 14:20:37 +00:00
|
|
|
virDomainObjListFree(&privconn->domains);
|
2008-10-10 14:50:26 +00:00
|
|
|
virNetworkObjListFree(&privconn->networks);
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolObjListFree(&privconn->pools);
|
2009-01-20 20:23:53 +00:00
|
|
|
|
|
|
|
virDomainEventCallbackListFree(privconn->domainEventCallbacks);
|
|
|
|
virDomainEventQueueFree(privconn->domainEventQueue);
|
|
|
|
|
|
|
|
if (privconn->domainEventTimer != -1)
|
|
|
|
virEventRemoveTimeout(privconn->domainEventTimer);
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexDestroy(&privconn->lock);
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE (privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
conn->privateData = NULL;
|
2007-04-04 14:19:49 +00:00
|
|
|
return 0;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
unsigned long *hvVer)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2007-01-18 21:08:21 +00:00
|
|
|
*hvVer = 2;
|
|
|
|
return (0);
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static char *testGetHostname (virConnectPtr conn)
|
2007-06-26 11:42:46 +00:00
|
|
|
{
|
2009-01-07 10:43:16 +00:00
|
|
|
char *result;
|
2007-06-26 11:42:46 +00:00
|
|
|
|
2009-01-07 10:43:16 +00:00
|
|
|
result = virGetHostname();
|
|
|
|
if (result == NULL) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(conn, errno,
|
|
|
|
"%s", _("cannot lookup hostname"));
|
2007-06-26 11:42:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-01-07 10:43:16 +00:00
|
|
|
/* Caller frees this string. */
|
|
|
|
return result;
|
2007-06-26 11:42:46 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
const char *type ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testNodeGetInfo(virConnectPtr conn,
|
|
|
|
virNodeInfoPtr info)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2007-07-27 23:23:00 +00:00
|
|
|
memcpy(info, &privconn->nodeInfo, sizeof(virNodeInfo));
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (0);
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static char *testGetCapabilities (virConnectPtr conn)
|
2007-03-15 17:24:56 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-02-27 04:35:08 +00:00
|
|
|
char *xml;
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
if ((xml = virCapabilitiesFormatXML(privconn->caps)) == NULL)
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-02-27 04:35:08 +00:00
|
|
|
return xml;
|
2007-03-15 17:24:56 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testNumOfDomains(virConnectPtr conn)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:20:37 +00:00
|
|
|
unsigned int numActive = 0, i;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-10 14:20:37 +00:00
|
|
|
for (i = 0 ; i < privconn->domains.count ; i++)
|
|
|
|
if (virDomainIsActive(privconn->domains.objs[i]))
|
2008-07-11 16:41:27 +00:00
|
|
|
numActive++;
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:20:37 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return numActive;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static virDomainPtr
|
2008-10-10 09:32:27 +00:00
|
|
|
testDomainCreateXML(virConnectPtr conn, const char *xml,
|
2007-01-18 21:08:21 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED)
|
2006-08-16 16:36:39 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virDomainPtr ret = NULL;
|
2008-07-11 16:41:27 +00:00
|
|
|
virDomainDefPtr def;
|
2008-12-04 20:59:06 +00:00
|
|
|
virDomainObjPtr dom = NULL;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2009-01-08 13:54:20 +00:00
|
|
|
if ((def = virDomainDefParseString(conn, privconn->caps, xml,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if ((dom = virDomainAssignDef(conn, &privconn->domains,
|
|
|
|
def)) == NULL) {
|
|
|
|
virDomainDefFree(def);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
dom->state = VIR_DOMAIN_RUNNING;
|
|
|
|
dom->def->id = privconn->nextDomID++;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(dom,
|
|
|
|
VIR_DOMAIN_EVENT_STARTED,
|
|
|
|
VIR_DOMAIN_EVENT_STARTED_BOOTED);
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid);
|
2008-12-04 20:57:47 +00:00
|
|
|
if (ret)
|
|
|
|
ret->id = def->id;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainObjUnlock(dom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-07-11 16:41:27 +00:00
|
|
|
return ret;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static virDomainPtr testLookupDomainByID(virConnectPtr conn,
|
|
|
|
int id)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainObjPtr dom;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
dom = virDomainFindByID(&privconn->domains, id);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (dom == NULL) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError (conn, VIR_ERR_NO_DOMAIN, NULL);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
|
2008-12-04 20:57:47 +00:00
|
|
|
if (ret)
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainObjUnlock(dom);
|
2008-07-11 16:41:27 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static virDomainPtr testLookupDomainByUUID(virConnectPtr conn,
|
|
|
|
const unsigned char *uuid)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainObjPtr dom ;
|
2007-07-06 14:56:15 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
dom = virDomainFindByUUID(&privconn->domains, uuid);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (dom == NULL) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError (conn, VIR_ERR_NO_DOMAIN, NULL);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-06 14:56:15 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
|
2008-12-04 20:57:47 +00:00
|
|
|
if (ret)
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainObjUnlock(dom);
|
2008-07-11 16:41:27 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static virDomainPtr testLookupDomainByName(virConnectPtr conn,
|
|
|
|
const char *name)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virDomainPtr ret = NULL;
|
|
|
|
virDomainObjPtr dom;
|
2007-07-06 14:56:15 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
dom = virDomainFindByName(&privconn->domains, name);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (dom == NULL) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError (conn, VIR_ERR_NO_DOMAIN, NULL);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-06 14:56:15 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
|
2008-12-04 20:57:47 +00:00
|
|
|
if (ret)
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainObjUnlock(dom);
|
2008-07-11 16:41:27 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testListDomains (virConnectPtr conn,
|
|
|
|
int *ids,
|
|
|
|
int maxids)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:20:37 +00:00
|
|
|
unsigned int n = 0, i;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
for (i = 0 ; i < privconn->domains.count && n < maxids ; i++) {
|
|
|
|
virDomainObjLock(privconn->domains.objs[i]);
|
2008-10-10 14:20:37 +00:00
|
|
|
if (virDomainIsActive(privconn->domains.objs[i]))
|
|
|
|
ids[n++] = privconn->domains.objs[i]->def->id;
|
2008-12-04 20:59:06 +00:00
|
|
|
virDomainObjUnlock(privconn->domains.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:20:37 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return n;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDestroyDomain (virDomainPtr domain)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2008-07-25 13:27:12 +00:00
|
|
|
privdom->def->id = -1;
|
|
|
|
domain->id = -1;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2008-12-04 20:59:06 +00:00
|
|
|
privdom = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
|
2009-01-20 20:23:53 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testResumeDomain (virDomainPtr domain)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (privdom->state != VIR_DOMAIN_PAUSED) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn,
|
|
|
|
VIR_ERR_INTERNAL_ERROR, _("domain '%s' not paused"),
|
|
|
|
domain->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_RUNNING;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_RESUMED,
|
|
|
|
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event) {
|
|
|
|
testDriverLock(privconn);
|
|
|
|
testDomainEventQueue(privconn, event);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testPauseDomain (virDomainPtr domain)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (privdom->state == VIR_DOMAIN_SHUTOFF ||
|
|
|
|
privdom->state == VIR_DOMAIN_PAUSED) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn,
|
|
|
|
VIR_ERR_INTERNAL_ERROR, _("domain '%s' not running"),
|
|
|
|
domain->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_PAUSED;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_SUSPENDED,
|
|
|
|
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
|
|
|
|
if (event) {
|
|
|
|
testDriverLock(privconn);
|
|
|
|
testDomainEventQueue(privconn, event);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testShutdownDomain (virDomainPtr domain)
|
2006-06-14 23:58:34 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (privdom->state == VIR_DOMAIN_SHUTOFF) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("domain '%s' not running"), domain->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2006-06-14 23:58:34 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2007-01-22 16:25:27 +00:00
|
|
|
domain->id = -1;
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->id = -1;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
|
|
|
privdom = NULL;
|
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-06-14 23:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Similar behaviour as shutdown */
|
2008-07-11 16:41:27 +00:00
|
|
|
static int testRebootDomain (virDomainPtr domain,
|
|
|
|
unsigned int action ATTRIBUTE_UNUSED)
|
2006-06-14 23:58:34 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTDOWN;
|
|
|
|
switch (privdom->def->onReboot) {
|
|
|
|
case VIR_DOMAIN_LIFECYCLE_DESTROY:
|
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2007-07-27 23:23:00 +00:00
|
|
|
domain->id = -1;
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->id = -1;
|
2007-01-18 21:08:21 +00:00
|
|
|
break;
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
case VIR_DOMAIN_LIFECYCLE_RESTART:
|
|
|
|
privdom->state = VIR_DOMAIN_RUNNING;
|
2007-01-18 21:08:21 +00:00
|
|
|
break;
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
case VIR_DOMAIN_LIFECYCLE_PRESERVE:
|
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2007-07-27 23:23:00 +00:00
|
|
|
domain->id = -1;
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->id = -1;
|
2007-01-18 21:08:21 +00:00
|
|
|
break;
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME:
|
|
|
|
privdom->state = VIR_DOMAIN_RUNNING;
|
2007-01-18 21:08:21 +00:00
|
|
|
break;
|
2006-06-14 23:58:34 +00:00
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
default:
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2007-07-27 23:23:00 +00:00
|
|
|
domain->id = -1;
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->id = -1;
|
2007-01-18 21:08:21 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-06-14 23:58:34 +00:00
|
|
|
|
2009-01-20 20:23:53 +00:00
|
|
|
if (privdom->state == VIR_DOMAIN_SHUTOFF) {
|
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
|
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
|
|
|
privdom = NULL;
|
|
|
|
}
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-06-14 23:58:34 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testGetDomainInfo (virDomainPtr domain,
|
|
|
|
virDomainInfoPtr info)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
2007-01-18 21:08:21 +00:00
|
|
|
struct timeval tv;
|
2008-12-04 20:56:10 +00:00
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
if (gettimeofday(&tv, NULL) < 0) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INTERNAL_ERROR,
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
"%s", _("getting time of day"));
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
info->state = privdom->state;
|
|
|
|
info->memory = privdom->def->memory;
|
|
|
|
info->maxMem = privdom->def->maxmem;
|
|
|
|
info->nrVirtCpu = privdom->def->vcpus;
|
|
|
|
info->cpuTime = ((tv.tv_sec * 1000ll * 1000ll * 1000ll) + (tv.tv_usec * 1000ll));
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
#define TEST_SAVE_MAGIC "TestGuestMagic"
|
|
|
|
|
|
|
|
static int testDomainSave(virDomainPtr domain,
|
|
|
|
const char *path)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
char *xml = NULL;
|
|
|
|
int fd = -1;
|
|
|
|
int len;
|
2008-12-04 20:56:10 +00:00
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2009-03-16 17:14:34 +00:00
|
|
|
xml = virDomainDefFormat(domain->conn,
|
|
|
|
privdom->def,
|
|
|
|
VIR_DOMAIN_XML_SECURE);
|
|
|
|
|
2008-01-30 19:52:16 +00:00
|
|
|
if (xml == NULL) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("saving domain '%s' failed to allocate space for metadata"),
|
|
|
|
domain->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-01-30 19:52:16 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("saving domain '%s' to '%s': open failed"),
|
|
|
|
domain->name, path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
len = strlen(xml);
|
Use safewrite in place of write, in many cases.
Also add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
* Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
* .x-sc_avoid_write: New file. Record two legitimate exemptions.
* qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
* src/conf.c (__virConfWriteFile): Likewise.
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD): Likewise.
* proxy/libvirt_proxy.c: Include "util.h".
(proxyWriteClientSocket): Use safewrite.
* src/test.c (testDomainSave, testDomainCoreDump): Likewise.
* src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
* src/virsh.c: Include "util-lib.h".
(vshOutputLogFile): Use safewrite.
* src/console.c: Include "util-lib.h".
(vshRunConsole): Use safewrite.
2008-02-22 15:55:04 +00:00
|
|
|
if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("saving domain '%s' to '%s': write failed"),
|
|
|
|
domain->name, path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
Use safewrite in place of write, in many cases.
Also add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
* Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
* .x-sc_avoid_write: New file. Record two legitimate exemptions.
* qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
* src/conf.c (__virConfWriteFile): Likewise.
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD): Likewise.
* proxy/libvirt_proxy.c: Include "util.h".
(proxyWriteClientSocket): Use safewrite.
* src/test.c (testDomainSave, testDomainCoreDump): Likewise.
* src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
* src/virsh.c: Include "util-lib.h".
(vshOutputLogFile): Use safewrite.
* src/console.c: Include "util-lib.h".
(vshRunConsole): Use safewrite.
2008-02-22 15:55:04 +00:00
|
|
|
if (safewrite(fd, (char*)&len, sizeof(len)) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("saving domain '%s' to '%s': write failed"),
|
|
|
|
domain->name, path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
Use safewrite in place of write, in many cases.
Also add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
* Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
* .x-sc_avoid_write: New file. Record two legitimate exemptions.
* qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
* src/conf.c (__virConfWriteFile): Likewise.
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD): Likewise.
* proxy/libvirt_proxy.c: Include "util.h".
(proxyWriteClientSocket): Use safewrite.
* src/test.c (testDomainSave, testDomainCoreDump): Likewise.
* src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
* src/virsh.c: Include "util-lib.h".
(vshOutputLogFile): Use safewrite.
* src/console.c: Include "util-lib.h".
(vshRunConsole): Use safewrite.
2008-02-22 15:55:04 +00:00
|
|
|
if (safewrite(fd, xml, len) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("saving domain '%s' to '%s': write failed"),
|
|
|
|
domain->name, path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
if (close(fd) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("saving domain '%s' to '%s': write failed"),
|
|
|
|
domain->name, path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
fd = -1;
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED_SAVED);
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2008-12-04 20:59:06 +00:00
|
|
|
privdom = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(xml);
|
|
|
|
|
|
|
|
/* Don't report failure in close or unlink, because
|
|
|
|
* in either case we're already in a failure scenario
|
|
|
|
* and have reported a earlier error */
|
|
|
|
if (ret != 0) {
|
|
|
|
if (fd != -1)
|
|
|
|
close(fd);
|
|
|
|
unlink(path);
|
|
|
|
}
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDomainRestore(virConnectPtr conn,
|
|
|
|
const char *path)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
char *xml = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
char magic[15];
|
2008-12-04 20:57:47 +00:00
|
|
|
int fd = -1;
|
|
|
|
int len;
|
|
|
|
virDomainDefPtr def = NULL;
|
2008-12-04 20:59:06 +00:00
|
|
|
virDomainObjPtr dom = NULL;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
if ((fd = open(path, O_RDONLY)) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(conn, errno,
|
|
|
|
_("cannot read domain image '%s'"),
|
|
|
|
path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2009-01-20 17:13:33 +00:00
|
|
|
if (saferead(fd, magic, sizeof(magic)) != sizeof(magic)) {
|
|
|
|
virReportSystemError(conn, errno,
|
|
|
|
_("incomplete save header in '%s'"),
|
|
|
|
path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
if (memcmp(magic, TEST_SAVE_MAGIC, sizeof(magic))) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(conn, VIR_ERR_INTERNAL_ERROR,
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
"%s", _("mismatched header magic"));
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2009-01-20 17:13:33 +00:00
|
|
|
if (saferead(fd, (char*)&len, sizeof(len)) != sizeof(len)) {
|
|
|
|
virReportSystemError(conn, errno,
|
|
|
|
_("failed to read metadata length in '%s'"),
|
|
|
|
path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
if (len < 1 || len > 8192) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(conn, VIR_ERR_INTERNAL_ERROR,
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
"%s", _("length of metadata out of range"));
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-05-29 19:20:22 +00:00
|
|
|
if (VIR_ALLOC_N(xml, len+1) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2009-01-20 17:13:33 +00:00
|
|
|
if (saferead(fd, xml, len) != len) {
|
|
|
|
virReportSystemError(conn, errno,
|
|
|
|
_("incomplete metdata in '%s'"), path);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
xml[len] = '\0';
|
2008-07-11 16:41:27 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2009-01-08 13:54:20 +00:00
|
|
|
def = virDomainDefParseString(conn, privconn->caps, xml,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE);
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!def)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-07-11 16:41:27 +00:00
|
|
|
|
|
|
|
if ((dom = virDomainAssignDef(conn, &privconn->domains,
|
2008-12-04 20:57:47 +00:00
|
|
|
def)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
dom->state = VIR_DOMAIN_RUNNING;
|
|
|
|
dom->def->id = privconn->nextDomID++;
|
2008-12-04 20:57:47 +00:00
|
|
|
def = NULL;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(dom,
|
|
|
|
VIR_DOMAIN_EVENT_STARTED,
|
|
|
|
VIR_DOMAIN_EVENT_STARTED_RESTORED);
|
2009-04-03 14:14:05 +00:00
|
|
|
ret = 0;
|
2008-12-04 20:57:47 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
|
|
|
VIR_FREE(xml);
|
|
|
|
if (fd != -1)
|
|
|
|
close(fd);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainObjUnlock(dom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDomainCoreDump(virDomainPtr domain,
|
|
|
|
const char *to,
|
|
|
|
int flags ATTRIBUTE_UNUSED)
|
2006-08-16 16:36:39 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
int fd = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
if ((fd = open(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("domain '%s' coredump: failed to open %s"),
|
|
|
|
domain->name, to);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
Use safewrite in place of write, in many cases.
Also add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
* Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
* .x-sc_avoid_write: New file. Record two legitimate exemptions.
* qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
* src/conf.c (__virConfWriteFile): Likewise.
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD): Likewise.
* proxy/libvirt_proxy.c: Include "util.h".
(proxyWriteClientSocket): Use safewrite.
* src/test.c (testDomainSave, testDomainCoreDump): Likewise.
* src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
* src/virsh.c: Include "util-lib.h".
(vshOutputLogFile): Use safewrite.
* src/console.c: Include "util-lib.h".
(vshRunConsole): Use safewrite.
2008-02-22 15:55:04 +00:00
|
|
|
if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("domain '%s' coredump: failed to write header to %s"),
|
|
|
|
domain->name, to);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
if (close(fd) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportSystemError(domain->conn, errno,
|
|
|
|
_("domain '%s' coredump: write failed: %s"),
|
|
|
|
domain->name, to);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED,
|
|
|
|
VIR_DOMAIN_EVENT_STOPPED_CRASHED);
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2008-12-04 20:59:06 +00:00
|
|
|
privdom = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (fd != -1)
|
|
|
|
close(fd);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
static char *testGetOSType(virDomainPtr dom) {
|
|
|
|
char *ret = strdup("linux");
|
|
|
|
if (!ret)
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(dom->conn);
|
2008-07-11 16:41:27 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long testGetMaxMemory(virDomainPtr domain) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-18 12:08:05 +00:00
|
|
|
unsigned long ret = 0;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = privdom->def->maxmem;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testSetMaxMemory(virDomainPtr domain,
|
|
|
|
unsigned long memory)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
/* XXX validate not over host memory wrt to other domains */
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->maxmem = memory;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testSetMemory(virDomainPtr domain,
|
|
|
|
unsigned long memory)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (memory > privdom->def->maxmem) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn,
|
2008-07-11 16:41:27 +00:00
|
|
|
VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->memory = memory;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testSetVcpus(virDomainPtr domain,
|
|
|
|
unsigned int nrCpus) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
/* We allow more cpus in guest than host */
|
|
|
|
if (nrCpus > 32) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->vcpus = nrCpus;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
static char *testDomainDumpXML(virDomainPtr domain, int flags)
|
2006-08-16 16:36:39 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
2008-07-11 16:41:27 +00:00
|
|
|
virDomainDefPtr def;
|
2008-12-04 20:56:10 +00:00
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
char *ret = NULL;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
def = (flags & VIR_DOMAIN_XML_INACTIVE) &&
|
|
|
|
privdom->newDef ? privdom->newDef : privdom->def;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virDomainDefFormat(domain->conn,
|
|
|
|
def,
|
|
|
|
flags);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2006-06-06 03:32:51 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testNumOfDefinedDomains(virConnectPtr conn) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:20:37 +00:00
|
|
|
unsigned int numInactive = 0, i;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
for (i = 0 ; i < privconn->domains.count ; i++) {
|
|
|
|
virDomainObjLock(privconn->domains.objs[i]);
|
2008-10-10 14:20:37 +00:00
|
|
|
if (!virDomainIsActive(privconn->domains.objs[i]))
|
2008-07-11 16:41:27 +00:00
|
|
|
numInactive++;
|
2008-12-04 20:59:06 +00:00
|
|
|
virDomainObjUnlock(privconn->domains.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:20:37 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return numInactive;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testListDefinedDomains(virConnectPtr conn,
|
|
|
|
char **const names,
|
|
|
|
int maxnames) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:20:37 +00:00
|
|
|
unsigned int n = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-07-11 16:41:27 +00:00
|
|
|
memset(names, 0, sizeof(*names)*maxnames);
|
2008-12-04 20:59:06 +00:00
|
|
|
for (i = 0 ; i < privconn->domains.count && n < maxnames ; i++) {
|
|
|
|
virDomainObjLock(privconn->domains.objs[i]);
|
2008-10-10 14:20:37 +00:00
|
|
|
if (!virDomainIsActive(privconn->domains.objs[i]) &&
|
2008-12-04 20:59:06 +00:00
|
|
|
!(names[n++] = strdup(privconn->domains.objs[i]->def->name))) {
|
|
|
|
virDomainObjUnlock(privconn->domains.objs[i]);
|
2008-07-11 16:41:27 +00:00
|
|
|
goto no_memory;
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
virDomainObjUnlock(privconn->domains.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:20:37 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-07-11 16:41:27 +00:00
|
|
|
for (n = 0 ; n < maxnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-07-11 16:41:27 +00:00
|
|
|
return -1;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static virDomainPtr testDomainDefineXML(virConnectPtr conn,
|
2008-07-11 16:41:27 +00:00
|
|
|
const char *xml) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virDomainPtr ret = NULL;
|
2008-07-11 16:41:27 +00:00
|
|
|
virDomainDefPtr def;
|
2008-12-04 20:59:06 +00:00
|
|
|
virDomainObjPtr dom = NULL;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2009-01-08 13:54:20 +00:00
|
|
|
if ((def = virDomainDefParseString(conn, privconn->caps, xml,
|
|
|
|
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if ((dom = virDomainAssignDef(conn, &privconn->domains,
|
|
|
|
def)) == NULL) {
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-07-11 16:41:27 +00:00
|
|
|
}
|
|
|
|
dom->persistent = 1;
|
|
|
|
dom->def->id = -1;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(dom,
|
|
|
|
VIR_DOMAIN_EVENT_DEFINED,
|
|
|
|
VIR_DOMAIN_EVENT_DEFINED_ADDED);
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid);
|
2008-12-04 20:57:47 +00:00
|
|
|
def = NULL;
|
|
|
|
if (ret)
|
|
|
|
ret->id = -1;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virDomainDefFree(def);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (dom)
|
|
|
|
virDomainObjUnlock(dom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-07-11 16:41:27 +00:00
|
|
|
return ret;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2008-04-04 07:31:24 +00:00
|
|
|
static int testNodeGetCellsFreeMemory(virConnectPtr conn,
|
|
|
|
unsigned long long *freemems,
|
|
|
|
int startCell, int maxCells) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-04-04 07:31:24 +00:00
|
|
|
int i, j;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-04-04 07:31:24 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-04-04 07:31:24 +00:00
|
|
|
if (startCell > privconn->numCells) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(conn, VIR_ERR_INVALID_ARG,
|
avoid many format string warnings
Building with --disable-nls exposed many new warnings like these:
virsh.c:4952: warning: format not a string literal and no format ...
util.c:163: warning: format not a string literal and no format arguments
All but one of the following changes add a "%s" argument before
the offending _(...) argument.
This was the only manual change:
* src/lxc_driver.c (lxcVersion): Use %s and strerror(errno)
rather than %m, to avoid a warning from gcc -Wformat-security.
Add "%s" before each warned about format-string-with-no-%-directive:
* src/domain_conf.c (virDomainHostdevSubsysUsbDefParseXML)
(virDomainDefParseString, virDomainDefParseFile):
* src/hash.c (virGetConnect, __virGetDomain, virReleaseDomain)
(__virGetNetwork, virReleaseNetwork, __virGetStoragePool)
(virReleaseStoragePool, __virGetStorageVol, virReleaseStorageVol):
* src/lxc_container.c (lxcContainerChild):
* src/lxc_driver.c (lxcDomainDefine, lxcDomainUndefine)
(lxcDomainGetInfo, lxcGetOSType, lxcDomainDumpXML)
(lxcSetupInterfaces, lxcDomainStart, lxcDomainCreateAndStart)
(lxcVersion, lxcGetSchedulerParameters):
* src/network_conf.c (virNetworkDefParseString)
(virNetworkDefParseFile):
* src/openvz_conf.c (openvzReadNetworkConf, openvzLoadDomains):
* src/openvz_driver.c (openvzDomainDefineCmd)
(openvzDomainGetInfo, openvzDomainDumpXML, openvzDomainShutdown)
(openvzDomainReboot, ADD_ARG_LIT, openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainCreate, openvzDomainUndefine)
(openvzDomainSetAutostart, openvzDomainGetAutostart)
(openvzDomainSetVcpus):
* src/qemu_driver.c (qemudDomainBlockPeek, qemudDomainMemoryPeek):
* src/remote_internal.c (remoteDomainBlockPeek)
(remoteDomainMemoryPeek, remoteAuthPolkit):
* src/sexpr.c (sexpr_new, _string2sexpr):
* src/storage_backend_disk.c (virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol):
* src/storage_backend_fs.c
(virStorageBackendFileSystemNetFindPoolSources):
* src/storage_backend_logical.c (virStorageBackendLogicalFindLVs)
(virStorageBackendLogicalFindPoolSources):
* src/test.c (testOpenDefault, testOpenFromFile, testOpen)
(testGetDomainInfo, testDomainRestore)
(testNodeGetCellsFreeMemory):
* src/util.c (virExec):
* src/virsh.c (cmdAttachDevice, cmdDetachDevice)
(cmdAttachInterface, cmdDetachInterface, cmdAttachDisk)
(cmdDetachDisk, cmdEdit):
* src/xend_internal.c (do_connect, wr_sync, xend_op_ext)
(urlencode, xenDaemonDomainCreateXML)
(xenDaemonDomainLookupByName_ids, xenDaemonDomainLookupByID)
(xenDaemonParseSxprOS, xend_parse_sexp_desc_char)
(xenDaemonParseSxprChar, xenDaemonParseSxprDisks)
(xenDaemonParseSxpr, sexpr_to_xend_topology, sexpr_to_domain)
(xenDaemonDomainFetch, xenDaemonDomainGetAutostart)
(xenDaemonDomainSetAutostart, xenDaemonDomainMigratePerform)
(xenDaemonDomainDefineXML, xenDaemonGetSchedulerType)
(xenDaemonGetSchedulerParameters)
(xenDaemonSetSchedulerParameters, xenDaemonDomainBlockPeek)
(xenDaemonFormatSxprChr, virDomainXMLDevID):
* src/xm_internal.c (xenXMConfigCacheRefresh, xenXMDomainPinVcpu)
(xenXMDomainCreate, xenXMDomainDefineXML)
(xenXMDomainAttachDevice, xenXMDomainDetachDevice):
* src/xml.c (virXPathString, virXPathNumber, virXPathLong)
(virXPathULong, virXPathBoolean, virXPathNode, virXPathNodeSet):
* src/xs_internal.c (xenStoreOpen):
2008-10-13 16:46:28 +00:00
|
|
|
"%s", _("Range exceeds available cells"));
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-04-04 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = startCell, j = 0;
|
|
|
|
(i < privconn->numCells && j < maxCells) ;
|
|
|
|
++i, ++j) {
|
|
|
|
freemems[j] = privconn->cells[i].mem;
|
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = j;
|
2008-04-04 07:31:24 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-04-04 07:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDomainCreate(virDomainPtr domain) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (privdom->state != VIR_DOMAIN_SHUTOFF) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Domain '%s' is already running"), domain->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
domain->id = privdom->def->id = privconn->nextDomID++;
|
|
|
|
privdom->state = VIR_DOMAIN_RUNNING;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_STARTED,
|
|
|
|
VIR_DOMAIN_EVENT_STARTED_BOOTED);
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testDomainUndefine(virDomainPtr domain) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2009-01-20 20:23:53 +00:00
|
|
|
virDomainEventPtr event = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if (privdom->state != VIR_DOMAIN_SHUTOFF) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Domain '%s' is still running"), domain->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
2009-01-20 20:23:53 +00:00
|
|
|
event = virDomainEventNewFromObj(privdom,
|
|
|
|
VIR_DOMAIN_EVENT_UNDEFINED,
|
|
|
|
VIR_DOMAIN_EVENT_UNDEFINED_REMOVED);
|
2008-07-11 16:41:27 +00:00
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2008-12-04 20:59:06 +00:00
|
|
|
privdom = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2009-01-20 20:23:53 +00:00
|
|
|
if (event)
|
|
|
|
testDomainEventQueue(privconn, event);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDomainGetAutostart(virDomainPtr domain,
|
|
|
|
int *autostart)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
*autostart = privdom->autostart;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int testDomainSetAutostart(virDomainPtr domain,
|
|
|
|
int autostart)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
privdom->autostart = autostart ? 1 : 0;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static char *testDomainGetSchedulerType(virDomainPtr domain,
|
|
|
|
int *nparams)
|
|
|
|
{
|
2008-12-04 20:57:47 +00:00
|
|
|
char *type = NULL;
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
*nparams = 1;
|
|
|
|
type = strdup("fair");
|
2008-12-04 20:57:47 +00:00
|
|
|
if (!type)
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(domain->conn);
|
2008-12-04 20:57:47 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testDomainGetSchedulerParams(virDomainPtr domain,
|
|
|
|
virSchedParameterPtr params,
|
|
|
|
int *nparams)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
if (*nparams != 1) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, "nparams");
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
strcpy(params[0].field, "weight");
|
|
|
|
params[0].type = VIR_DOMAIN_SCHED_FIELD_UINT;
|
2008-07-11 16:41:27 +00:00
|
|
|
/* XXX */
|
|
|
|
/*params[0].value.ui = privdom->weight;*/
|
|
|
|
params[0].value.ui = 50;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDomainSetSchedulerParams(virDomainPtr domain,
|
|
|
|
virSchedParameterPtr params,
|
|
|
|
int nparams)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = domain->conn->privateData;
|
|
|
|
virDomainObjPtr privdom;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privdom = virDomainFindByName(&privconn->domains,
|
|
|
|
domain->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privdom == NULL) {
|
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
if (nparams != 1) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, "nparams");
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
if (STRNEQ(params[0].field, "weight")) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, "field");
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
if (params[0].type != VIR_DOMAIN_SCHED_FIELD_UINT) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(domain->conn, VIR_ERR_INVALID_ARG, "type");
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
/* XXX */
|
|
|
|
/*privdom->weight = params[0].value.ui;*/
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privdom)
|
|
|
|
virDomainObjUnlock(privdom);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virDrvOpenStatus testOpenNetwork(virConnectPtr conn,
|
2007-12-05 18:28:05 +00:00
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
2007-07-27 23:23:00 +00:00
|
|
|
int flags ATTRIBUTE_UNUSED) {
|
|
|
|
if (STRNEQ(conn->driver->name, "Test"))
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
conn->networkPrivateData = conn->privateData;
|
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testCloseNetwork(virConnectPtr conn) {
|
|
|
|
conn->networkPrivateData = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virNetworkPtr testLookupNetworkByUUID(virConnectPtr conn,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
|
|
|
virNetworkObjPtr net;
|
2008-12-04 20:57:47 +00:00
|
|
|
virNetworkPtr ret = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
net = virNetworkFindByUUID(&privconn->networks, uuid);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (net == NULL) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError (conn, VIR_ERR_NO_NETWORK, NULL);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetNetwork(conn, net->def->name, net->def->uuid);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (net)
|
|
|
|
virNetworkObjUnlock(net);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static virNetworkPtr testLookupNetworkByName(virConnectPtr conn,
|
2008-07-11 16:39:08 +00:00
|
|
|
const char *name)
|
2007-07-27 23:23:00 +00:00
|
|
|
{
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virNetworkObjPtr net;
|
|
|
|
virNetworkPtr ret = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
net = virNetworkFindByName(&privconn->networks, name);
|
|
|
|
testDriverUnlock(privconn);
|
|
|
|
|
|
|
|
if (net == NULL) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError (conn, VIR_ERR_NO_NETWORK, NULL);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetNetwork(conn, net->def->name, net->def->uuid);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (net)
|
|
|
|
virNetworkObjUnlock(net);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int testNumNetworks(virConnectPtr conn) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:50:26 +00:00
|
|
|
int numActive = 0, i;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
for (i = 0 ; i < privconn->networks.count ; i++) {
|
|
|
|
virNetworkObjLock(privconn->networks.objs[i]);
|
2008-10-10 14:50:26 +00:00
|
|
|
if (virNetworkIsActive(privconn->networks.objs[i]))
|
2008-07-11 16:39:08 +00:00
|
|
|
numActive++;
|
2008-12-04 20:59:06 +00:00
|
|
|
virNetworkObjUnlock(privconn->networks.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return numActive;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testListNetworks(virConnectPtr conn, char **const names, int nnames) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:50:26 +00:00
|
|
|
int n = 0, i;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-07-11 16:39:08 +00:00
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
2008-12-04 20:59:06 +00:00
|
|
|
for (i = 0 ; i < privconn->networks.count && n < nnames ; i++) {
|
|
|
|
virNetworkObjLock(privconn->networks.objs[i]);
|
2008-10-10 14:50:26 +00:00
|
|
|
if (virNetworkIsActive(privconn->networks.objs[i]) &&
|
2008-12-04 20:59:06 +00:00
|
|
|
!(names[n++] = strdup(privconn->networks.objs[i]->def->name))) {
|
|
|
|
virNetworkObjUnlock(privconn->networks.objs[i]);
|
2008-07-11 16:39:08 +00:00
|
|
|
goto no_memory;
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
virNetworkObjUnlock(privconn->networks.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-07-11 16:39:08 +00:00
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return -1;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testNumDefinedNetworks(virConnectPtr conn) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:50:26 +00:00
|
|
|
int numInactive = 0, i;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
for (i = 0 ; i < privconn->networks.count ; i++) {
|
|
|
|
virNetworkObjLock(privconn->networks.objs[i]);
|
2008-10-10 14:50:26 +00:00
|
|
|
if (!virNetworkIsActive(privconn->networks.objs[i]))
|
2008-07-11 16:39:08 +00:00
|
|
|
numInactive++;
|
2008-12-04 20:59:06 +00:00
|
|
|
virNetworkObjUnlock(privconn->networks.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return numInactive;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-10 14:50:26 +00:00
|
|
|
int n = 0, i;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-07-11 16:39:08 +00:00
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
2008-12-04 20:59:06 +00:00
|
|
|
for (i = 0 ; i < privconn->networks.count && n < nnames ; i++) {
|
|
|
|
virNetworkObjLock(privconn->networks.objs[i]);
|
2008-10-10 14:50:26 +00:00
|
|
|
if (!virNetworkIsActive(privconn->networks.objs[i]) &&
|
2008-12-04 20:59:06 +00:00
|
|
|
!(names[n++] = strdup(privconn->networks.objs[i]->def->name))) {
|
|
|
|
virNetworkObjUnlock(privconn->networks.objs[i]);
|
2008-07-11 16:39:08 +00:00
|
|
|
goto no_memory;
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
virNetworkObjUnlock(privconn->networks.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-07-11 16:39:08 +00:00
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return -1;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virNetworkPtr testNetworkCreate(virConnectPtr conn, const char *xml) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-07-11 16:39:08 +00:00
|
|
|
virNetworkDefPtr def;
|
2008-12-04 20:59:06 +00:00
|
|
|
virNetworkObjPtr net = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
virNetworkPtr ret = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-07-11 16:39:08 +00:00
|
|
|
if ((def = virNetworkDefParseString(conn, xml)) == NULL)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2009-02-13 18:11:03 +00:00
|
|
|
if ((net = virNetworkAssignDef(conn, &privconn->networks, def)) == NULL)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
|
|
|
def = NULL;
|
2009-02-13 18:11:03 +00:00
|
|
|
net->active = 1;
|
2008-12-04 20:57:47 +00:00
|
|
|
|
2009-02-13 18:11:03 +00:00
|
|
|
ret = virGetNetwork(conn, net->def->name, net->def->uuid);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
|
|
|
virNetworkDefFree(def);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (net)
|
|
|
|
virNetworkObjUnlock(net);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virNetworkPtr testNetworkDefine(virConnectPtr conn, const char *xml) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-07-11 16:39:08 +00:00
|
|
|
virNetworkDefPtr def;
|
2008-12-04 20:59:06 +00:00
|
|
|
virNetworkObjPtr net = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
virNetworkPtr ret = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-07-11 16:39:08 +00:00
|
|
|
if ((def = virNetworkDefParseString(conn, xml)) == NULL)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2009-02-13 18:11:03 +00:00
|
|
|
if ((net = virNetworkAssignDef(conn, &privconn->networks, def)) == NULL)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
|
|
|
def = NULL;
|
2009-02-13 18:11:03 +00:00
|
|
|
net->persistent = 1;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2009-02-13 18:11:03 +00:00
|
|
|
ret = virGetNetwork(conn, net->def->name, net->def->uuid);
|
2008-12-04 20:57:47 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virNetworkDefFree(def);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (net)
|
|
|
|
virNetworkObjUnlock(net);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkUndefine(virNetworkPtr network) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = network->conn->privateData;
|
|
|
|
virNetworkObjPtr privnet;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privnet = virNetworkFindByName(&privconn->networks,
|
|
|
|
network->name);
|
|
|
|
|
|
|
|
if (privnet == NULL) {
|
|
|
|
testError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
if (virNetworkIsActive(privnet)) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(network->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Network '%s' is still running"), network->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
virNetworkRemoveInactive(&privconn->networks,
|
|
|
|
privnet);
|
2008-12-04 20:59:06 +00:00
|
|
|
privnet = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privnet)
|
|
|
|
virNetworkObjUnlock(privnet);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkStart(virNetworkPtr network) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = network->conn->privateData;
|
|
|
|
virNetworkObjPtr privnet;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privnet = virNetworkFindByName(&privconn->networks,
|
|
|
|
network->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privnet == NULL) {
|
|
|
|
testError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
if (virNetworkIsActive(privnet)) {
|
testError format strings: explicitly include domain and network names
This repairs the "make check" failure of tests/undefine.
* src/test.c (testResumeDomain, testPauseDomain): Likewise.
(testShutdownDomain, testGetDomainInfo, ): Likewise.
(testSetMemory, testSetVcpus, testDomainCreate, testDomainUndefine)
(testDomainGetSchedulerType, testDomainGetSchedulerParams): Likewise.
(testDomainSetSchedulerParams, testNetworkUndefine): Likewise.
(testNetworkStart, testNetworkGetBridgeName): Likewise.
(testDomainCoreDump, testDomainSave): Likewise, and...
Name the file upon failed open or write.
Use strerror(errno) in diagnostics.
* tests/undefine: Adjust expected output.
test.c (testError): Remove now-ignored dom and net parameters.
This is a sytnax-only change: removing the two unused parameters
and updating all callers:
* src/test.c (GET_DOMAIN, GET_NETWORK, testError)
(testBuildCapabilities, testOpenDefault, testOpenFromFile)
(testOpen, testGetHostname, testGetURI, testGetCapabilities)
(testLookupDomainByID, testLookupDomainByUUID)
(testLookupDomainByName, testResumeDomain, testPauseDomain)
(testShutdownDomain, testGetDomainInfo, testDomainSave)
(testDomainRestore, testDomainCoreDump, testGetOSType)
(testSetMemory, testSetVcpus, testListDefinedDomains)
(testNodeGetCellsFreeMemory, testDomainCreate)
(testDomainUndefine, testDomainGetSchedulerType)
(testDomainGetSchedulerParams, testDomainSetSchedulerParams)
(testLookupNetworkByUUID, testLookupNetworkByName)
(testListNetworks, testListDefinedNetworks, testNetworkUndefine)
(testNetworkStart, testNetworkGetBridgeName): Update callers.
2008-10-11 07:24:49 +00:00
|
|
|
testError(network->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Network '%s' is already running"), network->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
privnet->active = 1;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privnet)
|
|
|
|
virNetworkObjUnlock(privnet);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkDestroy(virNetworkPtr network) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = network->conn->privateData;
|
|
|
|
virNetworkObjPtr privnet;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privnet = virNetworkFindByName(&privconn->networks,
|
|
|
|
network->name);
|
|
|
|
|
|
|
|
if (privnet == NULL) {
|
|
|
|
testError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
privnet->active = 0;
|
|
|
|
if (!privnet->persistent) {
|
|
|
|
virNetworkRemoveInactive(&privconn->networks,
|
|
|
|
privnet);
|
2008-12-04 20:59:06 +00:00
|
|
|
privnet = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privnet)
|
|
|
|
virNetworkObjUnlock(privnet);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *testNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = network->conn->privateData;
|
|
|
|
virNetworkObjPtr privnet;
|
2008-12-04 20:57:47 +00:00
|
|
|
char *ret = NULL;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privnet = virNetworkFindByName(&privconn->networks,
|
|
|
|
network->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privnet == NULL) {
|
|
|
|
testError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virNetworkDefFormat(network->conn, privnet->def);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privnet)
|
|
|
|
virNetworkObjUnlock(privnet);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *testNetworkGetBridgeName(virNetworkPtr network) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = network->conn->privateData;
|
2008-07-11 16:39:08 +00:00
|
|
|
char *bridge = NULL;
|
2008-12-04 20:56:10 +00:00
|
|
|
virNetworkObjPtr privnet;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privnet = virNetworkFindByName(&privconn->networks,
|
|
|
|
network->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privnet == NULL) {
|
|
|
|
testError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
if (privnet->def->bridge &&
|
|
|
|
!(bridge = strdup(privnet->def->bridge))) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(network->conn);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privnet)
|
|
|
|
virNetworkObjUnlock(privnet);
|
2007-07-27 23:23:00 +00:00
|
|
|
return bridge;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkGetAutostart(virNetworkPtr network,
|
|
|
|
int *autostart) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = network->conn->privateData;
|
|
|
|
virNetworkObjPtr privnet;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privnet = virNetworkFindByName(&privconn->networks,
|
|
|
|
network->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privnet == NULL) {
|
|
|
|
testError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
*autostart = privnet->autostart;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privnet)
|
|
|
|
virNetworkObjUnlock(privnet);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkSetAutostart(virNetworkPtr network,
|
|
|
|
int autostart) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = network->conn->privateData;
|
|
|
|
virNetworkObjPtr privnet;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privnet = virNetworkFindByName(&privconn->networks,
|
|
|
|
network->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privnet == NULL) {
|
|
|
|
testError(network->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
privnet->autostart = autostart ? 1 : 0;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privnet)
|
|
|
|
virNetworkObjUnlock(privnet);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2007-01-18 21:08:21 +00:00
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Storage Driver routines
|
|
|
|
*/
|
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
static int testStoragePoolObjSetDefaults(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool) {
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
pool->def->capacity = defaultPoolCap;
|
|
|
|
pool->def->allocation = defaultPoolAlloc;
|
|
|
|
pool->def->available = defaultPoolCap - defaultPoolAlloc;
|
|
|
|
|
|
|
|
pool->configFile = strdup("\0");
|
|
|
|
if (!pool->configFile) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-10-30 17:40:57 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:53:34 +00:00
|
|
|
static virDrvOpenStatus testStorageOpen(virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
|
|
|
int flags ATTRIBUTE_UNUSED) {
|
|
|
|
if (STRNEQ(conn->driver->name, "Test"))
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
conn->storagePrivateData = conn->privateData;
|
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testStorageClose(virConnectPtr conn) {
|
|
|
|
conn->storagePrivateData = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolLookupByUUID(virConnectPtr conn,
|
|
|
|
const unsigned char *uuid) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&privconn->pools, uuid);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (pool == NULL) {
|
2008-10-30 17:40:57 +00:00
|
|
|
testError (conn, VIR_ERR_NO_STORAGE_POOL, NULL);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolLookupByName(virConnectPtr conn,
|
|
|
|
const char *name) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
pool = virStoragePoolObjFindByName(&privconn->pools, name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (pool == NULL) {
|
2008-10-30 17:40:57 +00:00
|
|
|
testError (conn, VIR_ERR_NO_STORAGE_POOL, NULL);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolLookupByVolume(virStorageVolPtr vol) {
|
|
|
|
return testStoragePoolLookupByName(vol->conn, vol->pool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageNumPools(virConnectPtr conn) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
int numActive = 0, i;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++)
|
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i]))
|
|
|
|
numActive++;
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
return numActive;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageListPools(virConnectPtr conn,
|
|
|
|
char **const names,
|
|
|
|
int nnames) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
int n = 0, i;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
2008-12-04 20:59:06 +00:00
|
|
|
for (i = 0 ; i < privconn->pools.count && n < nnames ; i++) {
|
|
|
|
virStoragePoolObjLock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i]) &&
|
2008-12-04 20:59:06 +00:00
|
|
|
!(names[n++] = strdup(privconn->pools.objs[i]->def->name))) {
|
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
goto no_memory;
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-10-30 17:40:57 +00:00
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return -1;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageNumDefinedPools(virConnectPtr conn) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
int numInactive = 0, i;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++) {
|
|
|
|
virStoragePoolObjLock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
if (!virStoragePoolObjIsActive(privconn->pools.objs[i]))
|
|
|
|
numInactive++;
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
return numInactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageListDefinedPools(virConnectPtr conn,
|
|
|
|
char **const names,
|
|
|
|
int nnames) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
int n = 0, i;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
2008-12-04 20:59:06 +00:00
|
|
|
for (i = 0 ; i < privconn->pools.count && n < nnames ; i++) {
|
|
|
|
virStoragePoolObjLock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
if (!virStoragePoolObjIsActive(privconn->pools.objs[i]) &&
|
2008-12-04 20:59:06 +00:00
|
|
|
!(names[n++] = strdup(privconn->pools.objs[i]->def->name))) {
|
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
goto no_memory;
|
2008-12-04 20:59:06 +00:00
|
|
|
}
|
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
|
|
|
}
|
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(conn);
|
2008-10-30 17:40:57 +00:00
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return -1;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolStart(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
if (virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is already active"), pool->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
privpool->active = 1;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
testStorageFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
const char *type ATTRIBUTE_UNUSED,
|
|
|
|
const char *srcSpec ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolCreate(virConnectPtr conn,
|
|
|
|
const char *xml,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolDefPtr def;
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjPtr pool = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&privconn->pools, def->uuid);
|
|
|
|
if (!pool)
|
|
|
|
pool = virStoragePoolObjFindByName(&privconn->pools, def->name);
|
|
|
|
if (pool) {
|
2008-10-30 17:40:57 +00:00
|
|
|
testError(conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("storage pool already exists"));
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2009-02-13 18:11:03 +00:00
|
|
|
if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def)))
|
2008-12-04 20:59:06 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:57:47 +00:00
|
|
|
def = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
if (testStoragePoolObjSetDefaults(conn, pool) == -1) {
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolObjRemove(&privconn->pools, pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
pool = NULL;
|
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
pool->active = 1;
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virStoragePoolDefFree(def);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolDefine(virConnectPtr conn,
|
|
|
|
const char *xml,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolDefPtr def;
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjPtr pool = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
def->capacity = defaultPoolCap;
|
|
|
|
def->allocation = defaultPoolAlloc;
|
|
|
|
def->available = defaultPoolCap - defaultPoolAlloc;
|
|
|
|
|
2009-02-13 18:11:03 +00:00
|
|
|
if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def)))
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
|
|
|
def = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
if (testStoragePoolObjSetDefaults(conn, pool) == -1) {
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolObjRemove(&privconn->pools, pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
pool = NULL;
|
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virStoragePoolDefFree(def);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolUndefine(virStoragePoolPtr pool) {
|
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
if (virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is already active"), pool->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
virStoragePoolObjRemove(&privconn->pools, privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolBuild(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
if (virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is already active"), pool->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-12-07 14:08:37 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolDestroy(virStoragePoolPtr pool) {
|
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), pool->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
privpool->active = 0;
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool->configFile == NULL) {
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolObjRemove(&privconn->pools, privpool);
|
2008-12-04 20:59:06 +00:00
|
|
|
privpool = NULL;
|
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolDelete(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is already active"), pool->name);
|
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolRefresh(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), pool->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolGetInfo(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
virStoragePoolInfoPtr info) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
memset(info, 0, sizeof(virStoragePoolInfo));
|
|
|
|
if (privpool->active)
|
|
|
|
info->state = VIR_STORAGE_POOL_RUNNING;
|
|
|
|
else
|
|
|
|
info->state = VIR_STORAGE_POOL_INACTIVE;
|
|
|
|
info->capacity = privpool->def->capacity;
|
|
|
|
info->allocation = privpool->def->allocation;
|
|
|
|
info->available = privpool->def->available;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolDumpXML(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
char *ret = NULL;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virStoragePoolDefFormat(pool->conn, privpool->def);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolGetAutostart(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
int *autostart) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
if (!privpool->configFile) {
|
|
|
|
*autostart = 0;
|
|
|
|
} else {
|
|
|
|
*autostart = privpool->autostart;
|
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolSetAutostart(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
int autostart) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
if (!privpool->configFile) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG,
|
2008-10-30 17:40:57 +00:00
|
|
|
"%s", _("pool has no config file"));
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
autostart = (autostart != 0);
|
|
|
|
privpool->autostart = autostart;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolNumVolumes(virStoragePoolPtr pool) {
|
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), pool->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = privpool->volumes.count;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStoragePoolListVolumes(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
char **const names,
|
|
|
|
int maxnames) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-10-30 17:40:57 +00:00
|
|
|
int i = 0, n = 0;
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
memset(names, 0, maxnames * sizeof(*names));
|
2008-12-04 20:59:06 +00:00
|
|
|
|
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), pool->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
for (i = 0 ; i < privpool->volumes.count && n < maxnames ; i++) {
|
|
|
|
if ((names[n++] = strdup(privpool->volumes.objs[i]->name)) == NULL) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(pool->conn);
|
2008-10-30 17:40:57 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-10-30 17:40:57 +00:00
|
|
|
return n;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
for (n = 0 ; n < maxnames ; n++)
|
|
|
|
VIR_FREE(names[i]);
|
|
|
|
|
2008-12-02 15:59:14 +00:00
|
|
|
memset(names, 0, maxnames * sizeof(*names));
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-10-30 17:40:57 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2008-12-04 20:56:10 +00:00
|
|
|
testStorageVolumeLookupByName(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
const char *name ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
|
|
|
virStorageVolDefPtr privvol;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStorageVolPtr ret = NULL;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), pool->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
privvol = virStorageVolDefFindByName(privpool, name);
|
|
|
|
|
|
|
|
if (!privvol) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_STORAGE_VOL,
|
2008-10-30 17:40:57 +00:00
|
|
|
_("no storage vol with matching name '%s'"), name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetStorageVol(pool->conn, privpool->def->name,
|
|
|
|
privvol->name, privvol->key);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
testStorageVolumeLookupByKey(virConnectPtr conn,
|
|
|
|
const char *key) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int i;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStorageVolPtr ret = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++) {
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjLock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
|
2008-12-04 20:56:10 +00:00
|
|
|
virStorageVolDefPtr privvol =
|
2008-10-30 17:40:57 +00:00
|
|
|
virStorageVolDefFindByKey(privconn->pools.objs[i], key);
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
if (privvol) {
|
|
|
|
ret = virGetStorageVol(conn,
|
|
|
|
privconn->pools.objs[i]->def->name,
|
|
|
|
privvol->name,
|
|
|
|
privvol->key);
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
2008-12-04 20:57:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
if (!ret)
|
|
|
|
testError(conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching key '%s'"), key);
|
|
|
|
|
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
testStorageVolumeLookupByPath(virConnectPtr conn,
|
|
|
|
const char *path) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = conn->privateData;
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int i;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStorageVolPtr ret = NULL;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++) {
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjLock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
|
2008-12-04 20:56:10 +00:00
|
|
|
virStorageVolDefPtr privvol =
|
2008-10-30 17:40:57 +00:00
|
|
|
virStorageVolDefFindByPath(privconn->pools.objs[i], path);
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
if (privvol) {
|
|
|
|
ret = virGetStorageVol(conn,
|
|
|
|
privconn->pools.objs[i]->def->name,
|
|
|
|
privvol->name,
|
|
|
|
privvol->key);
|
2008-12-04 20:59:06 +00:00
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
2008-12-04 20:57:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
2008-12-11 15:04:09 +00:00
|
|
|
virStoragePoolObjUnlock(privconn->pools.objs[i]);
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
if (!ret)
|
|
|
|
testError(conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching path '%s'"), path);
|
|
|
|
|
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2008-12-04 20:56:10 +00:00
|
|
|
testStorageVolumeCreateXML(virStoragePoolPtr pool,
|
2008-10-30 17:40:57 +00:00
|
|
|
const char *xmldesc,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = pool->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
2008-12-04 20:57:47 +00:00
|
|
|
virStorageVolDefPtr privvol = NULL;
|
|
|
|
virStorageVolPtr ret = NULL;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
pool->name);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(pool->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), pool->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
privvol = virStorageVolDefParse(pool->conn, privpool->def, xmldesc, NULL);
|
|
|
|
if (privvol == NULL)
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (virStorageVolDefFindByName(privpool, privvol->name)) {
|
2009-05-05 14:19:59 +00:00
|
|
|
testError(pool->conn, VIR_ERR_INVALID_STORAGE_VOL,
|
2008-10-30 17:40:57 +00:00
|
|
|
"%s", _("storage vol already exists"));
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure enough space */
|
2008-12-04 20:56:10 +00:00
|
|
|
if ((privpool->def->allocation + privvol->allocation) >
|
2008-10-30 17:40:57 +00:00
|
|
|
privpool->def->capacity) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testError(pool->conn, VIR_ERR_INTERNAL_ERROR,
|
2008-10-30 17:40:57 +00:00
|
|
|
_("Not enough free space in pool for volume '%s'"),
|
2008-12-04 20:56:10 +00:00
|
|
|
privvol->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_REALLOC_N(privpool->volumes.objs,
|
|
|
|
privpool->volumes.count+1) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(pool->conn);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
if (VIR_ALLOC_N(privvol->target.path,
|
|
|
|
strlen(privpool->def->target.path) +
|
|
|
|
1 + strlen(privvol->name) + 1) < 0) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(pool->conn);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
strcpy(privvol->target.path, privpool->def->target.path);
|
|
|
|
strcat(privvol->target.path, "/");
|
|
|
|
strcat(privvol->target.path, privvol->name);
|
|
|
|
privvol->key = strdup(privvol->target.path);
|
|
|
|
if (privvol->key == NULL) {
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(pool->conn);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool->def->allocation += privvol->allocation;
|
2008-10-30 17:40:57 +00:00
|
|
|
privpool->def->available = (privpool->def->capacity -
|
|
|
|
privpool->def->allocation);
|
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool->volumes.objs[privpool->volumes.count++] = privvol;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virGetStorageVol(pool->conn, privpool->def->name,
|
|
|
|
privvol->name, privvol->key);
|
2008-12-07 20:45:28 +00:00
|
|
|
privvol = NULL;
|
2008-12-04 20:57:47 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virStorageVolDefFree(privvol);
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStorageVolumeDelete(virStorageVolPtr vol,
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = vol->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
|
|
|
virStorageVolDefPtr privvol;
|
2008-10-30 17:40:57 +00:00
|
|
|
int i;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
vol->pool);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
privvol = virStorageVolDefFindByName(privpool, vol->name);
|
|
|
|
|
|
|
|
if (privvol == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
vol->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(vol->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), vol->pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
privpool->def->allocation -= privvol->allocation;
|
|
|
|
privpool->def->available = (privpool->def->capacity -
|
|
|
|
privpool->def->allocation);
|
|
|
|
|
|
|
|
for (i = 0 ; i < privpool->volumes.count ; i++) {
|
|
|
|
if (privpool->volumes.objs[i] == privvol) {
|
|
|
|
virStorageVolDefFree(privvol);
|
|
|
|
|
|
|
|
if (i < (privpool->volumes.count - 1))
|
|
|
|
memmove(privpool->volumes.objs + i,
|
|
|
|
privpool->volumes.objs + i + 1,
|
|
|
|
sizeof(*(privpool->volumes.objs)) *
|
|
|
|
(privpool->volumes.count - (i + 1)));
|
|
|
|
|
|
|
|
if (VIR_REALLOC_N(privpool->volumes.objs,
|
|
|
|
privpool->volumes.count - 1) < 0) {
|
|
|
|
; /* Failure to reduce memory allocation isn't fatal */
|
|
|
|
}
|
|
|
|
privpool->volumes.count--;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int testStorageVolumeTypeForPool(int pooltype) {
|
|
|
|
|
|
|
|
switch(pooltype) {
|
|
|
|
case VIR_STORAGE_POOL_DIR:
|
|
|
|
case VIR_STORAGE_POOL_FS:
|
|
|
|
case VIR_STORAGE_POOL_NETFS:
|
|
|
|
return VIR_STORAGE_VOL_FILE;
|
|
|
|
default:
|
|
|
|
return VIR_STORAGE_VOL_BLOCK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-12-04 20:56:10 +00:00
|
|
|
testStorageVolumeGetInfo(virStorageVolPtr vol,
|
2008-10-30 17:40:57 +00:00
|
|
|
virStorageVolInfoPtr info) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = vol->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
|
|
|
virStorageVolDefPtr privvol;
|
2008-12-04 20:57:47 +00:00
|
|
|
int ret = -1;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
vol->pool);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
privvol = virStorageVolDefFindByName(privpool, vol->name);
|
|
|
|
|
|
|
|
if (privvol == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
vol->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(vol->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), vol->pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
memset(info, 0, sizeof(*info));
|
|
|
|
info->type = testStorageVolumeTypeForPool(privpool->def->type);
|
|
|
|
info->capacity = privvol->capacity;
|
|
|
|
info->allocation = privvol->allocation;
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = 0;
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2008-12-04 20:56:10 +00:00
|
|
|
testStorageVolumeGetXMLDesc(virStorageVolPtr vol,
|
2008-10-30 17:40:57 +00:00
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
2008-12-04 20:56:10 +00:00
|
|
|
testConnPtr privconn = vol->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
|
|
|
virStorageVolDefPtr privvol;
|
2008-12-04 20:57:47 +00:00
|
|
|
char *ret = NULL;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
vol->pool);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
privvol = virStorageVolDefFindByName(privpool, vol->name);
|
|
|
|
|
|
|
|
if (privvol == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
vol->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
2008-10-30 17:40:57 +00:00
|
|
|
|
2008-12-04 20:56:10 +00:00
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(vol->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), vol->pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 20:57:47 +00:00
|
|
|
ret = virStorageVolDefFormat(vol->conn, privpool->def, privvol);
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-12-04 20:57:47 +00:00
|
|
|
return ret;
|
2008-10-30 17:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2008-12-04 20:56:10 +00:00
|
|
|
testStorageVolumeGetPath(virStorageVolPtr vol) {
|
|
|
|
testConnPtr privconn = vol->conn->privateData;
|
|
|
|
virStoragePoolObjPtr privpool;
|
|
|
|
virStorageVolDefPtr privvol;
|
2008-12-04 20:57:47 +00:00
|
|
|
char *ret = NULL;
|
2008-12-04 20:56:10 +00:00
|
|
|
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverLock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
privpool = virStoragePoolObjFindByName(&privconn->pools,
|
|
|
|
vol->pool);
|
2008-12-04 20:59:06 +00:00
|
|
|
testDriverUnlock(privconn);
|
2008-12-04 20:56:10 +00:00
|
|
|
|
|
|
|
if (privpool == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
privvol = virStorageVolDefFindByName(privpool, vol->name);
|
|
|
|
|
|
|
|
if (privvol == NULL) {
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
vol->name);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(privpool)) {
|
|
|
|
testError(vol->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage pool '%s' is not active"), vol->pool);
|
2008-12-04 20:57:47 +00:00
|
|
|
goto cleanup;
|
2008-12-04 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
ret = strdup(privvol->target.path);
|
2008-12-04 20:57:47 +00:00
|
|
|
if (ret == NULL)
|
2009-01-20 17:13:33 +00:00
|
|
|
virReportOOMError(vol->conn);
|
2008-12-04 20:57:47 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 20:59:06 +00:00
|
|
|
if (privpool)
|
|
|
|
virStoragePoolObjUnlock(privpool);
|
2008-10-30 17:40:57 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-12-04 21:00:50 +00:00
|
|
|
static virDrvOpenStatus testDevMonOpen(virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
|
|
|
int flags ATTRIBUTE_UNUSED) {
|
|
|
|
if (STRNEQ(conn->driver->name, "Test"))
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
conn->devMonPrivateData = conn->privateData;
|
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testDevMonClose(virConnectPtr conn) {
|
|
|
|
conn->devMonPrivateData = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-20 20:23:53 +00:00
|
|
|
static int
|
|
|
|
testDomainEventRegister (virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freecb)
|
|
|
|
{
|
|
|
|
testConnPtr driver = conn->privateData;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
testDriverLock(driver);
|
|
|
|
ret = virDomainEventCallbackListAdd(conn, driver->domainEventCallbacks,
|
|
|
|
callback, opaque, freecb);
|
|
|
|
testDriverUnlock(driver);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testDomainEventDeregister (virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback)
|
|
|
|
{
|
|
|
|
testConnPtr driver = conn->privateData;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
testDriverLock(driver);
|
|
|
|
if (driver->domainEventDispatching)
|
|
|
|
ret = virDomainEventCallbackListMarkDelete(conn, driver->domainEventCallbacks,
|
|
|
|
callback);
|
|
|
|
else
|
|
|
|
ret = virDomainEventCallbackListRemove(conn, driver->domainEventCallbacks,
|
|
|
|
callback);
|
|
|
|
testDriverUnlock(driver);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testDomainEventDispatchFunc(virConnectPtr conn,
|
|
|
|
virDomainEventPtr event,
|
|
|
|
virConnectDomainEventCallback cb,
|
|
|
|
void *cbopaque,
|
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
testConnPtr driver = opaque;
|
|
|
|
|
|
|
|
/* Drop the lock whle dispatching, for sake of re-entrancy */
|
|
|
|
testDriverUnlock(driver);
|
|
|
|
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
|
|
|
|
testDriverLock(driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
|
|
|
|
{
|
|
|
|
testConnPtr driver = opaque;
|
|
|
|
virDomainEventQueue tempQueue;
|
|
|
|
|
|
|
|
testDriverLock(driver);
|
|
|
|
|
|
|
|
driver->domainEventDispatching = 1;
|
|
|
|
|
|
|
|
/* Copy the queue, so we're reentrant safe */
|
|
|
|
tempQueue.count = driver->domainEventQueue->count;
|
|
|
|
tempQueue.events = driver->domainEventQueue->events;
|
|
|
|
driver->domainEventQueue->count = 0;
|
|
|
|
driver->domainEventQueue->events = NULL;
|
|
|
|
|
|
|
|
virEventUpdateTimeout(driver->domainEventTimer, -1);
|
|
|
|
virDomainEventQueueDispatch(&tempQueue,
|
|
|
|
driver->domainEventCallbacks,
|
|
|
|
testDomainEventDispatchFunc,
|
|
|
|
driver);
|
|
|
|
|
|
|
|
/* Purge any deleted callbacks */
|
|
|
|
virDomainEventCallbackListPurgeMarked(driver->domainEventCallbacks);
|
|
|
|
|
|
|
|
driver->domainEventDispatching = 0;
|
|
|
|
testDriverUnlock(driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* driver must be locked before calling */
|
|
|
|
static void testDomainEventQueue(testConnPtr driver,
|
|
|
|
virDomainEventPtr event)
|
|
|
|
{
|
|
|
|
if (driver->domainEventTimer < 0) {
|
|
|
|
virDomainEventFree(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virDomainEventQueuePush(driver->domainEventQueue,
|
|
|
|
event) < 0)
|
|
|
|
virDomainEventFree(event);
|
|
|
|
|
|
|
|
if (driver->domainEventQueue->count == 1)
|
|
|
|
virEventUpdateTimeout(driver->domainEventTimer, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static virDriver testDriver = {
|
|
|
|
VIR_DRV_TEST,
|
|
|
|
"Test",
|
|
|
|
testOpen, /* open */
|
|
|
|
testClose, /* close */
|
2007-08-21 09:03:55 +00:00
|
|
|
NULL, /* supports_feature */
|
2007-07-27 23:23:00 +00:00
|
|
|
NULL, /* type */
|
|
|
|
testGetVersion, /* version */
|
2009-03-31 15:47:16 +00:00
|
|
|
testGetHostname, /* getHostname */
|
2007-07-27 23:23:00 +00:00
|
|
|
testGetMaxVCPUs, /* getMaxVcpus */
|
|
|
|
testNodeGetInfo, /* nodeGetInfo */
|
|
|
|
testGetCapabilities, /* getCapabilities */
|
|
|
|
testListDomains, /* listDomains */
|
|
|
|
testNumOfDomains, /* numOfDomains */
|
2008-10-10 09:32:27 +00:00
|
|
|
testDomainCreateXML, /* domainCreateXML */
|
2007-07-27 23:23:00 +00:00
|
|
|
testLookupDomainByID, /* domainLookupByID */
|
|
|
|
testLookupDomainByUUID, /* domainLookupByUUID */
|
|
|
|
testLookupDomainByName, /* domainLookupByName */
|
|
|
|
testPauseDomain, /* domainSuspend */
|
|
|
|
testResumeDomain, /* domainResume */
|
|
|
|
testShutdownDomain, /* domainShutdown */
|
|
|
|
testRebootDomain, /* domainReboot */
|
|
|
|
testDestroyDomain, /* domainDestroy */
|
|
|
|
testGetOSType, /* domainGetOSType */
|
|
|
|
testGetMaxMemory, /* domainGetMaxMemory */
|
|
|
|
testSetMaxMemory, /* domainSetMaxMemory */
|
|
|
|
testSetMemory, /* domainSetMemory */
|
|
|
|
testGetDomainInfo, /* domainGetInfo */
|
|
|
|
testDomainSave, /* domainSave */
|
|
|
|
testDomainRestore, /* domainRestore */
|
|
|
|
testDomainCoreDump, /* domainCoreDump */
|
|
|
|
testSetVcpus, /* domainSetVcpus */
|
|
|
|
NULL, /* domainPinVcpu */
|
|
|
|
NULL, /* domainGetVcpus */
|
|
|
|
NULL, /* domainGetMaxVcpus */
|
2009-03-03 09:14:28 +00:00
|
|
|
NULL, /* domainGetSecurityLabel */
|
|
|
|
NULL, /* nodeGetSecurityModel */
|
2007-07-27 23:23:00 +00:00
|
|
|
testDomainDumpXML, /* domainDumpXML */
|
|
|
|
testListDefinedDomains, /* listDefinedDomains */
|
|
|
|
testNumOfDefinedDomains, /* numOfDefinedDomains */
|
|
|
|
testDomainCreate, /* domainCreate */
|
|
|
|
testDomainDefineXML, /* domainDefineXML */
|
|
|
|
testDomainUndefine, /* domainUndefine */
|
|
|
|
NULL, /* domainAttachDevice */
|
|
|
|
NULL, /* domainDetachDevice */
|
|
|
|
testDomainGetAutostart, /* domainGetAutostart */
|
|
|
|
testDomainSetAutostart, /* domainSetAutostart */
|
|
|
|
testDomainGetSchedulerType, /* domainGetSchedulerType */
|
|
|
|
testDomainGetSchedulerParams, /* domainGetSchedulerParameters */
|
|
|
|
testDomainSetSchedulerParams, /* domainSetSchedulerParameters */
|
2007-08-21 09:31:12 +00:00
|
|
|
NULL, /* domainMigratePrepare */
|
|
|
|
NULL, /* domainMigratePerform */
|
|
|
|
NULL, /* domainMigrateFinish */
|
2007-08-21 10:08:12 +00:00
|
|
|
NULL, /* domainBlockStats */
|
|
|
|
NULL, /* domainInterfaceStats */
|
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
|
|
|
NULL, /* domainBlockPeek */
|
2008-06-10 10:43:28 +00:00
|
|
|
NULL, /* domainMemoryPeek */
|
2008-04-04 07:31:24 +00:00
|
|
|
testNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
|
2007-09-30 13:09:07 +00:00
|
|
|
NULL, /* getFreeMemory */
|
2009-01-20 20:23:53 +00:00
|
|
|
testDomainEventRegister, /* domainEventRegister */
|
|
|
|
testDomainEventDeregister, /* domainEventDeregister */
|
2008-11-14 08:42:47 +00:00
|
|
|
NULL, /* domainMigratePrepare2 */
|
|
|
|
NULL, /* domainMigrateFinish2 */
|
2009-03-31 15:47:16 +00:00
|
|
|
NULL, /* nodeDeviceDettach */
|
2009-03-02 16:25:13 +00:00
|
|
|
NULL, /* nodeDeviceReAttach */
|
|
|
|
NULL, /* nodeDeviceReset */
|
2007-07-27 23:23:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static virNetworkDriver testNetworkDriver = {
|
|
|
|
"Test",
|
|
|
|
testOpenNetwork, /* open */
|
|
|
|
testCloseNetwork, /* close */
|
|
|
|
testNumNetworks, /* numOfNetworks */
|
|
|
|
testListNetworks, /* listNetworks */
|
|
|
|
testNumDefinedNetworks, /* numOfDefinedNetworks */
|
|
|
|
testListDefinedNetworks, /* listDefinedNetworks */
|
|
|
|
testLookupNetworkByUUID, /* networkLookupByUUID */
|
|
|
|
testLookupNetworkByName, /* networkLookupByName */
|
|
|
|
testNetworkCreate, /* networkCreateXML */
|
|
|
|
testNetworkDefine, /* networkDefineXML */
|
|
|
|
testNetworkUndefine, /* networkUndefine */
|
|
|
|
testNetworkStart, /* networkCreate */
|
|
|
|
testNetworkDestroy, /* networkDestroy */
|
|
|
|
testNetworkDumpXML, /* networkDumpXML */
|
|
|
|
testNetworkGetBridgeName, /* networkGetBridgeName */
|
|
|
|
testNetworkGetAutostart, /* networkGetAutostart */
|
|
|
|
testNetworkSetAutostart, /* networkSetAutostart */
|
|
|
|
};
|
|
|
|
|
2008-02-20 15:53:34 +00:00
|
|
|
static virStorageDriver testStorageDriver = {
|
|
|
|
.name = "Test",
|
|
|
|
.open = testStorageOpen,
|
|
|
|
.close = testStorageClose,
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
.numOfPools = testStorageNumPools,
|
|
|
|
.listPools = testStorageListPools,
|
|
|
|
.numOfDefinedPools = testStorageNumDefinedPools,
|
|
|
|
.listDefinedPools = testStorageListDefinedPools,
|
|
|
|
.findPoolSources = testStorageFindPoolSources,
|
|
|
|
.poolLookupByName = testStoragePoolLookupByName,
|
|
|
|
.poolLookupByUUID = testStoragePoolLookupByUUID,
|
|
|
|
.poolLookupByVolume = testStoragePoolLookupByVolume,
|
|
|
|
.poolCreateXML = testStoragePoolCreate,
|
|
|
|
.poolDefineXML = testStoragePoolDefine,
|
|
|
|
.poolBuild = testStoragePoolBuild,
|
|
|
|
.poolUndefine = testStoragePoolUndefine,
|
|
|
|
.poolCreate = testStoragePoolStart,
|
|
|
|
.poolDestroy = testStoragePoolDestroy,
|
|
|
|
.poolDelete = testStoragePoolDelete,
|
|
|
|
.poolRefresh = testStoragePoolRefresh,
|
|
|
|
.poolGetInfo = testStoragePoolGetInfo,
|
|
|
|
.poolGetXMLDesc = testStoragePoolDumpXML,
|
|
|
|
.poolGetAutostart = testStoragePoolGetAutostart,
|
|
|
|
.poolSetAutostart = testStoragePoolSetAutostart,
|
|
|
|
.poolNumOfVolumes = testStoragePoolNumVolumes,
|
|
|
|
.poolListVolumes = testStoragePoolListVolumes,
|
|
|
|
|
|
|
|
.volLookupByName = testStorageVolumeLookupByName,
|
|
|
|
.volLookupByKey = testStorageVolumeLookupByKey,
|
|
|
|
.volLookupByPath = testStorageVolumeLookupByPath,
|
|
|
|
.volCreateXML = testStorageVolumeCreateXML,
|
|
|
|
.volDelete = testStorageVolumeDelete,
|
|
|
|
.volGetInfo = testStorageVolumeGetInfo,
|
|
|
|
.volGetXMLDesc = testStorageVolumeGetXMLDesc,
|
|
|
|
.volGetPath = testStorageVolumeGetPath,
|
2008-02-20 15:53:34 +00:00
|
|
|
};
|
|
|
|
|
2008-12-04 21:00:50 +00:00
|
|
|
static virDeviceMonitor testDevMonitor = {
|
|
|
|
.name = "Test",
|
|
|
|
.open = testDevMonOpen,
|
|
|
|
.close = testDevMonClose,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
/**
|
|
|
|
* testRegister:
|
|
|
|
*
|
|
|
|
* Registers the test driver
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
testRegister(void)
|
|
|
|
{
|
|
|
|
if (virRegisterDriver(&testDriver) < 0)
|
|
|
|
return -1;
|
|
|
|
if (virRegisterNetworkDriver(&testNetworkDriver) < 0)
|
|
|
|
return -1;
|
2008-02-20 15:53:34 +00:00
|
|
|
if (virRegisterStorageDriver(&testStorageDriver) < 0)
|
|
|
|
return -1;
|
2008-12-04 21:00:50 +00:00
|
|
|
if (virRegisterDeviceMonitor(&testDevMonitor) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|