2006-06-06 03:32:51 +00:00
|
|
|
/*
|
|
|
|
* test.c: A "mock" hypervisor for use by application unit tests
|
|
|
|
*
|
2008-01-30 19:52:16 +00:00
|
|
|
* Copyright (C) 2006-2008 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"
|
2008-10-30 17:40:57 +00:00
|
|
|
#include "storage_conf.h"
|
2008-07-11 16:41:27 +00:00
|
|
|
#include "xml.h"
|
2007-04-04 14:19:49 +00:00
|
|
|
|
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 {
|
|
|
|
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];
|
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
|
|
|
};
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
#define GET_DOMAIN(dom, ret) \
|
|
|
|
testConnPtr privconn; \
|
2008-07-11 16:41:27 +00:00
|
|
|
virDomainObjPtr privdom; \
|
2007-07-27 23:23:00 +00:00
|
|
|
\
|
|
|
|
privconn = (testConnPtr)dom->conn->privateData; \
|
2008-07-11 16:41:27 +00:00
|
|
|
do { \
|
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
|
|
|
if ((privdom = virDomainFindByName(&privconn->domains, \
|
|
|
|
(dom)->name)) == NULL) { \
|
|
|
|
testError((dom)->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); \
|
2008-07-11 16:41:27 +00:00
|
|
|
return (ret); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
#define GET_NETWORK(net, ret) \
|
|
|
|
testConnPtr privconn; \
|
2008-07-11 16:39:08 +00:00
|
|
|
virNetworkObjPtr privnet; \
|
2007-07-27 23:23:00 +00:00
|
|
|
\
|
|
|
|
privconn = (testConnPtr)net->conn->privateData; \
|
2008-07-11 16:39:08 +00:00
|
|
|
do { \
|
2008-10-10 14:50:26 +00:00
|
|
|
if ((privnet = virNetworkFindByName(&privconn->networks, \
|
2008-07-11 16:39:08 +00:00
|
|
|
(net)->name)) == 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((net)->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); \
|
2008-07-11 16:39:08 +00:00
|
|
|
return (ret); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
#define GET_POOL(pool, ret) \
|
|
|
|
testConnPtr privconn; \
|
|
|
|
virStoragePoolObjPtr privpool; \
|
|
|
|
\
|
|
|
|
privconn = (testConnPtr)pool->conn->privateData; \
|
|
|
|
do { \
|
|
|
|
if ((privpool = virStoragePoolObjFindByName(&privconn->pools, \
|
|
|
|
(pool)->name)) == NULL) {\
|
|
|
|
testError((pool)->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); \
|
|
|
|
return (ret); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define GET_POOL_FROM_VOL(vol, ret) \
|
|
|
|
GET_POOL(testStoragePoolLookupByName((virConnectPtr) \
|
|
|
|
vol->conn, \
|
|
|
|
vol->pool), ret)
|
|
|
|
|
|
|
|
#define GET_VOL(vol, pool, ret) \
|
|
|
|
virStorageVolDefPtr privvol; \
|
|
|
|
\
|
|
|
|
privvol = virStorageVolDefFindByName(pool, vol->name); \
|
|
|
|
do { \
|
|
|
|
if (!privvol) { \
|
|
|
|
testError(vol->conn, VIR_ERR_INVALID_STORAGE_VOL, \
|
|
|
|
_("no storage vol with matching name '%s'"), \
|
|
|
|
vol->name); \
|
|
|
|
return (ret); \
|
|
|
|
} \
|
|
|
|
} while (0) \
|
|
|
|
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
#define GET_CONNECTION(conn) \
|
2007-07-27 23:23:00 +00:00
|
|
|
testConnPtr privconn; \
|
|
|
|
\
|
|
|
|
privconn = (testConnPtr)conn->privateData;
|
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
#define POOL_IS_ACTIVE(pool, ret) \
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) { \
|
|
|
|
testError(obj->conn, VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
_("storage pool '%s' is not active"), pool->def->name); \
|
|
|
|
return (ret); \
|
|
|
|
} \
|
|
|
|
|
|
|
|
#define POOL_IS_NOT_ACTIVE(pool, ret) \
|
|
|
|
if (virStoragePoolObjIsActive(pool)) { \
|
|
|
|
testError(obj->conn, VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
_("storage pool '%s' is already active"), pool->def->name); \
|
|
|
|
return (ret); \
|
|
|
|
} \
|
2007-07-27 23:23:00 +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
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
static virCapsPtr
|
|
|
|
testBuildCapabilities(virConnectPtr conn) {
|
|
|
|
virCapsPtr caps;
|
|
|
|
virCapsGuestPtr guest;
|
|
|
|
const char *const guest_types[] = { "hvm", "xen" };
|
|
|
|
int i;
|
|
|
|
GET_CONNECTION(conn);
|
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:
|
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_MEMORY, NULL);
|
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>";
|
|
|
|
|
|
|
|
static const unsigned long long defaultPoolCap = (100 * 1024 * 1024 * 1024ul);
|
|
|
|
static const unsigned long long defaultPoolAlloc = 0;
|
|
|
|
|
|
|
|
static int testStoragePoolObjSetDefaults(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) {
|
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_MEMORY, "testConn");
|
2007-07-27 23:23:00 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
conn->privateData = privconn;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
if (gettimeofday(&tv, NULL) < 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_INTERNAL_ERROR, "%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;
|
|
|
|
|
|
|
|
if (!(domdef = virDomainDefParseString(conn, privconn->caps, defaultDomainXML)))
|
|
|
|
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;
|
|
|
|
|
|
|
|
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-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;
|
|
|
|
}
|
|
|
|
if (testStoragePoolObjSetDefaults(poolobj) == -1)
|
|
|
|
goto error;
|
|
|
|
poolobj->active = 1;
|
|
|
|
|
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);
|
|
|
|
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) {
|
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_NO_MEMORY, "testConn");
|
2007-07-27 23:23:00 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
conn->privateData = privconn;
|
|
|
|
|
|
|
|
if (!(privconn->caps = testBuildCapabilities(conn)))
|
|
|
|
goto error;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
if ((fd = open(file, O_RDONLY)) < 0) {
|
2008-10-30 17:40:57 +00:00
|
|
|
testError(NULL, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("loading host definition file '%s': %s"),
|
|
|
|
file, strerror(errno));
|
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;
|
|
|
|
}
|
|
|
|
def = virDomainDefParseFile(conn, privconn->caps, absFile);
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(absFile);
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!def)
|
|
|
|
goto error;
|
|
|
|
} else {
|
|
|
|
if ((def = virDomainDefParseNode(conn, privconn->caps, xml, domains[i])) == NULL)
|
|
|
|
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;
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
2008-07-19 07:42:34 +00:00
|
|
|
if (domains != NULL)
|
2008-05-29 19:20:22 +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-07-19 07:42:34 +00:00
|
|
|
if (networks != NULL)
|
2008-07-11 16:39:08 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (testStoragePoolObjSetDefaults(pool) == -1)
|
|
|
|
goto error;
|
|
|
|
pool->active = 1;
|
|
|
|
}
|
|
|
|
if (pools != NULL)
|
|
|
|
VIR_FREE(pools);
|
|
|
|
|
2008-01-30 19:50:14 +00:00
|
|
|
xmlXPathFreeContext(ctxt);
|
2007-01-18 21:08:21 +00:00
|
|
|
xmlFreeDoc(xml);
|
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-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
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testOpen(virConnectPtr conn,
|
2007-11-14 11:40:57 +00:00
|
|
|
xmlURIPtr uri,
|
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
|
|
|
|
2007-11-14 11:40:57 +00:00
|
|
|
if (!uri)
|
2007-04-04 14:19:49 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
2006-06-06 03:32:51 +00:00
|
|
|
|
2008-05-14 19:51:24 +00:00
|
|
|
if (!uri->scheme || STRNEQ(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. */
|
2007-11-14 11:40:57 +00:00
|
|
|
if (uri->server)
|
2007-06-20 10:01:14 +00:00
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
2007-11-14 11:40:57 +00:00
|
|
|
if (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. */
|
|
|
|
if (!uri->path
|
|
|
|
|| uri->path[0] == '\0'
|
|
|
|
|| (uri->path[0] == '/' && 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
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
if (STREQ(uri->path, "/default"))
|
|
|
|
ret = testOpenDefault(conn);
|
|
|
|
else
|
2007-01-18 21:08:21 +00:00
|
|
|
ret = testOpenFromFile(conn,
|
|
|
|
uri->path);
|
|
|
|
|
|
|
|
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-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2008-10-10 14:50:26 +00:00
|
|
|
|
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);
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE (privconn);
|
2007-07-27 23:23:00 +00:00
|
|
|
conn->privateData = conn;
|
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
|
|
|
{
|
|
|
|
int r;
|
|
|
|
char hostname [HOST_NAME_MAX+1], *str;
|
|
|
|
|
|
|
|
r = gethostname (hostname, HOST_NAME_MAX+1);
|
|
|
|
if (r == -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 (conn, VIR_ERR_SYSTEM_ERROR, "%s",
|
2008-10-09 15:38:31 +00:00
|
|
|
strerror (errno));
|
2007-06-26 11:42:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
str = strdup (hostname);
|
|
|
|
if (str == 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_SYSTEM_ERROR, "%s",
|
2008-10-09 15:38:31 +00:00
|
|
|
strerror (errno));
|
2007-06-26 11:42:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static char * testGetURI (virConnectPtr conn)
|
2007-06-26 11:42:46 +00:00
|
|
|
{
|
|
|
|
char *uri;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-06-26 11:42:46 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
if (asprintf (&uri, "test://%s", privconn->path) == -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 (conn, VIR_ERR_SYSTEM_ERROR, "%s",
|
2008-10-09 15:38:31 +00:00
|
|
|
strerror (errno));
|
2007-06-26 11:42:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
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-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
memcpy(info, &privconn->nodeInfo, sizeof(virNodeInfo));
|
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-02-27 04:35:08 +00:00
|
|
|
char *xml;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2008-02-27 04:35:08 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if ((xml = virCapabilitiesFormatXML(privconn->caps)) == 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_MEMORY, NULL);
|
2008-07-11 16:41:27 +00:00
|
|
|
return NULL;
|
2008-04-08 09:26:24 +00:00
|
|
|
}
|
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-10-10 14:20:37 +00:00
|
|
|
unsigned int numActive = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
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-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-07-11 16:41:27 +00:00
|
|
|
virDomainPtr ret;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
virDomainObjPtr dom;
|
|
|
|
GET_CONNECTION(conn);
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if ((def = virDomainDefParseString(conn, privconn->caps, xml)) == NULL)
|
|
|
|
return NULL;
|
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);
|
|
|
|
return NULL;
|
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
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid);
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
ret->id = def->id;
|
|
|
|
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-07-11 16:41:27 +00:00
|
|
|
virDomainObjPtr dom = NULL;
|
|
|
|
virDomainPtr ret;
|
|
|
|
GET_CONNECTION(conn);
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-10-10 14:20:37 +00:00
|
|
|
if ((dom = virDomainFindByID(&privconn->domains, id)) == 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-07-11 16:41:27 +00:00
|
|
|
return NULL;
|
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);
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
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-07-11 16:41:27 +00:00
|
|
|
virDomainPtr ret;
|
|
|
|
virDomainObjPtr dom = NULL;
|
|
|
|
GET_CONNECTION(conn);
|
2007-07-06 14:56:15 +00:00
|
|
|
|
2008-10-10 14:20:37 +00:00
|
|
|
if ((dom = virDomainFindByUUID(&privconn->domains, uuid)) == 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);
|
2007-07-06 14:56:15 +00:00
|
|
|
return NULL;
|
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);
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
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-07-11 16:41:27 +00:00
|
|
|
virDomainPtr ret;
|
|
|
|
virDomainObjPtr dom = NULL;
|
|
|
|
GET_CONNECTION(conn);
|
2007-07-06 14:56:15 +00:00
|
|
|
|
2008-10-10 14:20:37 +00:00
|
|
|
if ((dom = virDomainFindByName(&privconn->domains, name)) == 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);
|
2007-07-06 14:56:15 +00:00
|
|
|
return NULL;
|
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);
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
ret->id = dom->def->id;
|
|
|
|
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-10-10 14:20:37 +00:00
|
|
|
unsigned int n = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-10-10 14:20:37 +00:00
|
|
|
for (i = 0 ; i < privconn->domains.count && n < maxids ; i++)
|
|
|
|
if (virDomainIsActive(privconn->domains.objs[i]))
|
|
|
|
ids[n++] = privconn->domains.objs[i]->def->id;
|
|
|
|
|
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
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_DOMAIN(domain, -1);
|
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;
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
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 int testResumeDomain (virDomainPtr domain)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_DOMAIN(domain, -1);
|
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);
|
2007-07-27 23:23:00 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_RUNNING;
|
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 int testPauseDomain (virDomainPtr domain)
|
2006-06-06 03:32:51 +00:00
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_DOMAIN(domain, -1);
|
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);
|
2007-07-27 23:23:00 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_PAUSED;
|
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 int testShutdownDomain (virDomainPtr domain)
|
2006-06-14 23:58:34 +00:00
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_DOMAIN(domain, -1);
|
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);
|
2007-07-27 23:23:00 +00:00
|
|
|
return -1;
|
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;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
return (0);
|
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
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_DOMAIN(domain, -1);
|
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
|
|
|
|
2007-01-18 21:08:21 +00:00
|
|
|
return (0);
|
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
|
|
|
{
|
2007-01-18 21:08:21 +00:00
|
|
|
struct timeval tv;
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_DOMAIN(domain, -1);
|
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"));
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
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));
|
2007-01-18 21:08:21 +00:00
|
|
|
return (0);
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static char *testDomainDumpXML(virDomainPtr domain, int flags);
|
2006-11-08 18:54:57 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
#define TEST_SAVE_MAGIC "TestGuestMagic"
|
|
|
|
|
|
|
|
static int testDomainSave(virDomainPtr domain,
|
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
char *xml;
|
|
|
|
int fd, len;
|
|
|
|
GET_DOMAIN(domain, -1);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
xml = testDomainDumpXML(domain, 0);
|
2008-01-30 19:52:16 +00:00
|
|
|
if (xml == 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(domain->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("saving domain '%s' failed to allocate space for metadata: %s"),
|
|
|
|
domain->name, strerror(errno));
|
2008-01-30 19:52:16 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 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,
|
|
|
|
_("saving domain '%s' to '%s': open failed: %s"),
|
|
|
|
domain->name, path, strerror(errno));
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
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) {
|
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,
|
|
|
|
_("saving domain '%s' to '%s': write failed: %s"),
|
|
|
|
domain->name, path, strerror(errno));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
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) {
|
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,
|
|
|
|
_("saving domain '%s' to '%s': write failed: %s"),
|
|
|
|
domain->name, path, strerror(errno));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
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) {
|
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,
|
|
|
|
_("saving domain '%s' to '%s': write failed: %s"),
|
|
|
|
domain->name, path, strerror(errno));
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(xml);
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(xml);
|
2007-07-27 23:23:00 +00:00
|
|
|
if (close(fd) < 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,
|
|
|
|
_("saving domain '%s' to '%s': write failed: %s"),
|
|
|
|
domain->name, path, strerror(errno));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
return 0;
|
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
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
char *xml;
|
|
|
|
char magic[15];
|
2008-07-11 16:41:27 +00:00
|
|
|
int fd, len;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
virDomainObjPtr dom;
|
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
if ((fd = open(path, O_RDONLY)) < 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(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", _("cannot read domain image"));
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
if (read(fd, magic, sizeof(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", _("incomplete save header"));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
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"));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (read(fd, (char*)&len, sizeof(len)) != sizeof(len)) {
|
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", _("failed to read metadata length"));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
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"));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
2008-05-29 19:20:22 +00:00
|
|
|
if (VIR_ALLOC_N(xml, len+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(conn, VIR_ERR_NO_MEMORY, "xml");
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (read(fd, xml, len) != len) {
|
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", _("incomplete metdata"));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
xml[len] = '\0';
|
|
|
|
close(fd);
|
2008-07-11 16:41:27 +00:00
|
|
|
|
|
|
|
def = virDomainDefParseString(conn, privconn->caps, xml);
|
2008-05-29 19:20:22 +00:00
|
|
|
VIR_FREE(xml);
|
2008-07-11 16:41:27 +00:00
|
|
|
if (!def)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((dom = virDomainAssignDef(conn, &privconn->domains,
|
|
|
|
def)) == NULL) {
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
dom->state = VIR_DOMAIN_RUNNING;
|
|
|
|
dom->def->id = privconn->nextDomID++;
|
|
|
|
return dom->def->id;
|
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
|
|
|
{
|
2007-07-27 23:23:00 +00:00
|
|
|
int fd;
|
|
|
|
GET_DOMAIN(domain, -1);
|
|
|
|
|
|
|
|
if ((fd = open(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 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,
|
|
|
|
_("domain '%s' coredump: failed to open %s: %s"),
|
|
|
|
domain->name, to, strerror (errno));
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
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) {
|
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' coredump: failed to write header to %s: %s"),
|
|
|
|
domain->name, to, strerror (errno));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
if (close(fd) < 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,
|
|
|
|
_("domain '%s' coredump: write failed: %s: %s"),
|
|
|
|
domain->name, to, strerror (errno));
|
2007-07-27 23:23:00 +00:00
|
|
|
close(fd);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
|
|
|
if (!privdom->persistent) {
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
static char *testGetOSType(virDomainPtr dom) {
|
|
|
|
char *ret = strdup("linux");
|
|
|
|
if (!ret)
|
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(dom->conn, VIR_ERR_NO_MEMORY, NULL);
|
2008-07-11 16:41:27 +00:00
|
|
|
return ret;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned long testGetMaxMemory(virDomainPtr domain) {
|
|
|
|
GET_DOMAIN(domain, -1);
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return privdom->def->maxmem;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testSetMaxMemory(virDomainPtr domain,
|
|
|
|
unsigned long memory)
|
|
|
|
{
|
|
|
|
GET_DOMAIN(domain, -1);
|
|
|
|
|
|
|
|
/* XXX validate not over host memory wrt to other domains */
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->maxmem = memory;
|
2007-01-18 21:08:21 +00:00
|
|
|
return (0);
|
2006-08-16 16:36:39 +00:00
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testSetMemory(virDomainPtr domain,
|
|
|
|
unsigned long memory)
|
|
|
|
{
|
|
|
|
GET_DOMAIN(domain, -1);
|
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__);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->memory = memory;
|
2007-07-27 23:23:00 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testSetVcpus(virDomainPtr domain,
|
|
|
|
unsigned int nrCpus) {
|
|
|
|
GET_DOMAIN(domain, -1);
|
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__);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2006-08-16 16:36:39 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->def->vcpus = nrCpus;
|
2007-01-18 21:08:21 +00:00
|
|
|
return (0);
|
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-07-11 16:41:27 +00:00
|
|
|
virDomainDefPtr def;
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_DOMAIN(domain, NULL);
|
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-07-11 16:41:27 +00:00
|
|
|
return virDomainDefFormat(domain->conn,
|
|
|
|
def,
|
|
|
|
flags);
|
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-10-10 14:20:37 +00:00
|
|
|
unsigned int numInactive = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
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
|
|
|
numInactive++;
|
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-10-10 14:20:37 +00:00
|
|
|
unsigned int n = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
memset(names, 0, sizeof(*names)*maxnames);
|
2008-10-10 14:20:37 +00:00
|
|
|
for (i = 0 ; i < privconn->domains.count && n < maxnames ; i++)
|
|
|
|
if (!virDomainIsActive(privconn->domains.objs[i]) &&
|
|
|
|
!(names[n++] = strdup(privconn->domains.objs[i]->def->name)))
|
2008-07-11 16:41:27 +00:00
|
|
|
goto no_memory;
|
2008-10-10 14:20:37 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
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_MEMORY, NULL);
|
2008-07-11 16:41:27 +00:00
|
|
|
for (n = 0 ; n < maxnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
|
|
|
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) {
|
|
|
|
virDomainPtr ret;
|
|
|
|
virDomainDefPtr def;
|
|
|
|
virDomainObjPtr dom;
|
|
|
|
GET_CONNECTION(conn);
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if ((def = virDomainDefParseString(conn, privconn->caps, xml)) == NULL)
|
|
|
|
return NULL;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
if ((dom = virDomainAssignDef(conn, &privconn->domains,
|
|
|
|
def)) == NULL) {
|
|
|
|
virDomainDefFree(def);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
dom->persistent = 1;
|
|
|
|
dom->def->id = -1;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
ret = virGetDomain(conn, def->name, def->uuid);
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
ret->id = -1;
|
|
|
|
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) {
|
|
|
|
int i, j;
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
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-04-04 07:31:24 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = startCell, j = 0;
|
|
|
|
(i < privconn->numCells && j < maxCells) ;
|
|
|
|
++i, ++j) {
|
|
|
|
freemems[j] = privconn->cells[i].mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDomainCreate(virDomainPtr domain) {
|
|
|
|
GET_DOMAIN(domain, -1);
|
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);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
domain->id = privdom->def->id = privconn->nextDomID++;
|
|
|
|
privdom->state = VIR_DOMAIN_RUNNING;
|
2007-01-18 21:08:21 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testDomainUndefine(virDomainPtr domain) {
|
|
|
|
GET_DOMAIN(domain, -1);
|
|
|
|
|
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);
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:27 +00:00
|
|
|
privdom->state = VIR_DOMAIN_SHUTOFF;
|
|
|
|
virDomainRemoveInactive(&privconn->domains,
|
|
|
|
privdom);
|
2007-01-18 21:08:21 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static int testDomainGetAutostart(virDomainPtr domain,
|
|
|
|
int *autostart)
|
|
|
|
{
|
|
|
|
GET_DOMAIN(domain, -1);
|
|
|
|
*autostart = privdom->autostart;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int testDomainSetAutostart(virDomainPtr domain,
|
|
|
|
int autostart)
|
|
|
|
{
|
|
|
|
GET_DOMAIN(domain, -1);
|
|
|
|
privdom->autostart = autostart ? 1 : 0;
|
|
|
|
return (0);
|
|
|
|
}
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
static char *testDomainGetSchedulerType(virDomainPtr domain,
|
|
|
|
int *nparams)
|
|
|
|
{
|
|
|
|
char *type;
|
|
|
|
*nparams = 1;
|
|
|
|
type = strdup("fair");
|
|
|
|
if (!type) {
|
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_NO_MEMORY, "schedular");
|
2007-07-27 23:23:00 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testDomainGetSchedulerParams(virDomainPtr domain,
|
|
|
|
virSchedParameterPtr params,
|
|
|
|
int *nparams)
|
|
|
|
{
|
|
|
|
GET_DOMAIN(domain, -1);
|
|
|
|
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");
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
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;
|
2007-07-27 23:23:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
GET_DOMAIN(domain, -1);
|
|
|
|
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");
|
2007-01-18 21:08:21 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
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");
|
2007-07-27 23:23:00 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
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");
|
2007-07-27 23:23:00 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2008-07-11 16:41:27 +00:00
|
|
|
/* XXX */
|
|
|
|
/*privdom->weight = params[0].value.ui;*/
|
2007-07-27 23:23:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virDrvOpenStatus testOpenNetwork(virConnectPtr conn,
|
2007-11-14 11:40:57 +00:00
|
|
|
xmlURIPtr uri ATTRIBUTE_UNUSED,
|
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-07-11 16:39:08 +00:00
|
|
|
virNetworkObjPtr net = NULL;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
if ((net = virNetworkFindByUUID(&privconn->networks, uuid)) == 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);
|
2007-07-27 23:23:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return virGetNetwork(conn, net->def->name, net->def->uuid);
|
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-07-11 16:39:08 +00:00
|
|
|
virNetworkObjPtr net = NULL;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
if ((net = virNetworkFindByName(&privconn->networks, name)) == 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);
|
2007-07-27 23:23:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return virGetNetwork(conn, net->def->name, net->def->uuid);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int testNumNetworks(virConnectPtr conn) {
|
2008-10-10 14:50:26 +00:00
|
|
|
int numActive = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
for (i = 0 ; i < privconn->networks.count ; i++)
|
|
|
|
if (virNetworkIsActive(privconn->networks.objs[i]))
|
2008-07-11 16:39:08 +00:00
|
|
|
numActive++;
|
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-10-10 14:50:26 +00:00
|
|
|
int n = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
2008-10-10 14:50:26 +00:00
|
|
|
for (i = 0 ; i < privconn->networks.count && n < nnames ; i++)
|
|
|
|
if (virNetworkIsActive(privconn->networks.objs[i]) &&
|
|
|
|
!(names[n++] = strdup(privconn->networks.objs[i]->def->name)))
|
2008-07-11 16:39:08 +00:00
|
|
|
goto no_memory;
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
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_MEMORY, NULL);
|
2008-07-11 16:39:08 +00:00
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
|
|
|
return (-1);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testNumDefinedNetworks(virConnectPtr conn) {
|
2008-10-10 14:50:26 +00:00
|
|
|
int numInactive = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-10-10 14:50:26 +00:00
|
|
|
for (i = 0 ; i < privconn->networks.count ; i++)
|
|
|
|
if (!virNetworkIsActive(privconn->networks.objs[i]))
|
2008-07-11 16:39:08 +00:00
|
|
|
numInactive++;
|
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-10-10 14:50:26 +00:00
|
|
|
int n = 0, i;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
2008-10-10 14:50:26 +00:00
|
|
|
for (i = 0 ; i < privconn->networks.count && n < nnames ; i++)
|
|
|
|
if (!virNetworkIsActive(privconn->networks.objs[i]) &&
|
|
|
|
!(names[n++] = strdup(privconn->networks.objs[i]->def->name)))
|
2008-07-11 16:39:08 +00:00
|
|
|
goto no_memory;
|
2008-10-10 14:50:26 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
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_MEMORY, NULL);
|
2008-07-11 16:39:08 +00:00
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
|
|
|
return (-1);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virNetworkPtr testNetworkCreate(virConnectPtr conn, const char *xml) {
|
2008-07-11 16:39:08 +00:00
|
|
|
virNetworkDefPtr def;
|
|
|
|
virNetworkObjPtr net;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
if ((def = virNetworkDefParseString(conn, xml)) == NULL)
|
|
|
|
return NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
if ((net = virNetworkAssignDef(conn, &privconn->networks,
|
|
|
|
def)) == NULL) {
|
|
|
|
virNetworkDefFree(def);
|
|
|
|
return NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-07-11 16:39:08 +00:00
|
|
|
net->active = 1;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return virGetNetwork(conn, def->name, def->uuid);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virNetworkPtr testNetworkDefine(virConnectPtr conn, const char *xml) {
|
2008-07-11 16:39:08 +00:00
|
|
|
virNetworkDefPtr def;
|
|
|
|
virNetworkObjPtr net;
|
2008-07-11 16:41:27 +00:00
|
|
|
GET_CONNECTION(conn);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
if ((def = virNetworkDefParseString(conn, xml)) == NULL)
|
|
|
|
return NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
if ((net = virNetworkAssignDef(conn, &privconn->networks,
|
|
|
|
def)) == NULL) {
|
|
|
|
virNetworkDefFree(def);
|
|
|
|
return NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
2008-07-11 16:39:08 +00:00
|
|
|
net->persistent = 1;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return virGetNetwork(conn, def->name, def->uuid);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkUndefine(virNetworkPtr network) {
|
|
|
|
GET_NETWORK(network, -1);
|
|
|
|
|
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);
|
2007-07-27 23:23:00 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
virNetworkRemoveInactive(&privconn->networks,
|
|
|
|
privnet);
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkStart(virNetworkPtr network) {
|
|
|
|
GET_NETWORK(network, -1);
|
|
|
|
|
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);
|
2007-07-27 23:23:00 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
privnet->active = 1;
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkDestroy(virNetworkPtr network) {
|
|
|
|
GET_NETWORK(network, -1);
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
privnet->active = 0;
|
|
|
|
if (!privnet->persistent) {
|
|
|
|
virNetworkRemoveInactive(&privconn->networks,
|
|
|
|
privnet);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *testNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_NETWORK(network, NULL);
|
|
|
|
|
2008-07-11 16:39:08 +00:00
|
|
|
return virNetworkDefFormat(network->conn, privnet->def);
|
2007-07-27 23:23:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *testNetworkGetBridgeName(virNetworkPtr network) {
|
2008-07-11 16:39:08 +00:00
|
|
|
char *bridge = NULL;
|
2007-07-27 23:23:00 +00:00
|
|
|
GET_NETWORK(network, NULL);
|
2008-07-11 16:39:08 +00:00
|
|
|
if (privnet->def->bridge &&
|
|
|
|
!(bridge = strdup(privnet->def->bridge))) {
|
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_NO_MEMORY, "network");
|
2007-07-27 23:23:00 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return bridge;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkGetAutostart(virNetworkPtr network,
|
|
|
|
int *autostart) {
|
|
|
|
GET_NETWORK(network, -1);
|
|
|
|
*autostart = privnet->autostart;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int testNetworkSetAutostart(virNetworkPtr network,
|
|
|
|
int autostart) {
|
|
|
|
GET_NETWORK(network, -1);
|
|
|
|
privnet->autostart = autostart ? 1 : 0;
|
2007-01-18 21:08:21 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2007-07-27 23:23:00 +00:00
|
|
|
|
2008-10-30 17:40:57 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Storage Driver routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int testStoragePoolObjSetDefaults(virStoragePoolObjPtr pool) {
|
|
|
|
|
|
|
|
pool->def->capacity = defaultPoolCap;
|
|
|
|
pool->def->allocation = defaultPoolAlloc;
|
|
|
|
pool->def->available = defaultPoolCap - defaultPoolAlloc;
|
|
|
|
|
|
|
|
pool->configFile = strdup("\0");
|
|
|
|
if (!pool->configFile) {
|
|
|
|
testError(NULL, VIR_ERR_NO_MEMORY, "configFile");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:53:34 +00:00
|
|
|
static virDrvOpenStatus testStorageOpen(virConnectPtr conn,
|
|
|
|
xmlURIPtr uri ATTRIBUTE_UNUSED,
|
|
|
|
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) {
|
|
|
|
virStoragePoolObjPtr pool = NULL;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
if ((pool = virStoragePoolObjFindByUUID(&privconn->pools, uuid)) == NULL) {
|
|
|
|
testError (conn, VIR_ERR_NO_STORAGE_POOL, NULL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolLookupByName(virConnectPtr conn,
|
|
|
|
const char *name) {
|
|
|
|
virStoragePoolObjPtr pool = NULL;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
if ((pool = virStoragePoolObjFindByName(&privconn->pools, name)) == NULL) {
|
|
|
|
testError (conn, VIR_ERR_NO_STORAGE_POOL, NULL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolLookupByVolume(virStorageVolPtr vol) {
|
|
|
|
return testStoragePoolLookupByName(vol->conn, vol->pool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageNumPools(virConnectPtr conn) {
|
|
|
|
|
|
|
|
int numActive = 0, i;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++)
|
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i]))
|
|
|
|
numActive++;
|
|
|
|
|
|
|
|
return numActive;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageListPools(virConnectPtr conn,
|
|
|
|
char **const names,
|
|
|
|
int nnames) {
|
|
|
|
int n = 0, i;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
|
|
|
for (i = 0 ; i < privconn->pools.count && n < nnames ; i++)
|
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i]) &&
|
|
|
|
!(names[n++] = strdup(privconn->pools.objs[i]->def->name)))
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
testError(conn, VIR_ERR_NO_MEMORY, NULL);
|
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageNumDefinedPools(virConnectPtr conn) {
|
|
|
|
|
|
|
|
int numInactive = 0, i;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++)
|
|
|
|
if (!virStoragePoolObjIsActive(privconn->pools.objs[i]))
|
|
|
|
numInactive++;
|
|
|
|
|
|
|
|
return numInactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageListDefinedPools(virConnectPtr conn,
|
|
|
|
char **const names,
|
|
|
|
int nnames) {
|
|
|
|
int n = 0, i;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
memset(names, 0, sizeof(*names)*nnames);
|
|
|
|
for (i = 0 ; i < privconn->pools.count && n < nnames ; i++)
|
|
|
|
if (!virStoragePoolObjIsActive(privconn->pools.objs[i]) &&
|
|
|
|
!(names[n++] = strdup(privconn->pools.objs[i]->def->name)))
|
|
|
|
goto no_memory;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
no_memory:
|
|
|
|
testError(conn, VIR_ERR_NO_MEMORY, NULL);
|
|
|
|
for (n = 0 ; n < nnames ; n++)
|
|
|
|
VIR_FREE(names[n]);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolRefresh(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED);
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolStart(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_NOT_ACTIVE(privpool, -1);
|
|
|
|
|
|
|
|
if (testStoragePoolRefresh(obj, 0) == 0)
|
|
|
|
return -1;
|
|
|
|
privpool->active = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
virStoragePoolDefPtr def;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (virStoragePoolObjFindByUUID(&privconn->pools, def->uuid) ||
|
|
|
|
virStoragePoolObjFindByName(&privconn->pools, def->name)) {
|
|
|
|
testError(conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("storage pool already exists"));
|
|
|
|
virStoragePoolDefFree(def);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def))) {
|
|
|
|
virStoragePoolDefFree(def);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (testStoragePoolObjSetDefaults(pool) == -1) {
|
|
|
|
virStoragePoolObjRemove(&privconn->pools, pool);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
pool->active = 1;
|
|
|
|
|
|
|
|
return virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
testStoragePoolDefine(virConnectPtr conn,
|
|
|
|
const char *xml,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
virStoragePoolDefPtr def;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
|
|
|
|
if (!(def = virStoragePoolDefParse(conn, xml, NULL)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
def->capacity = defaultPoolCap;
|
|
|
|
def->allocation = defaultPoolAlloc;
|
|
|
|
def->available = defaultPoolCap - defaultPoolAlloc;
|
|
|
|
|
|
|
|
if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def))) {
|
|
|
|
virStoragePoolDefFree(def);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (testStoragePoolObjSetDefaults(pool) == -1) {
|
|
|
|
virStoragePoolObjRemove(&privconn->pools, pool);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return virGetStoragePool(conn, pool->def->name, pool->def->uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolUndefine(virStoragePoolPtr obj) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_NOT_ACTIVE(privpool, -1);
|
|
|
|
|
|
|
|
virStoragePoolObjRemove(&privconn->pools, privpool);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolBuild(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_NOT_ACTIVE(privpool, -1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolDestroy(virStoragePoolPtr obj) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_ACTIVE(privpool, -1);
|
|
|
|
|
|
|
|
privpool->active = 0;
|
|
|
|
|
|
|
|
if (privpool->configFile == NULL)
|
|
|
|
virStoragePoolObjRemove(&privconn->pools, privpool);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolDelete(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_NOT_ACTIVE(privpool, -1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolRefresh(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_ACTIVE(privpool, -1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolGetInfo(virStoragePoolPtr obj,
|
|
|
|
virStoragePoolInfoPtr info) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
testStoragePoolDumpXML(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL(obj, NULL);
|
|
|
|
|
|
|
|
return virStoragePoolDefFormat(obj->conn, privpool->def);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolGetAutostart(virStoragePoolPtr obj,
|
|
|
|
int *autostart) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
|
|
|
|
if (!privpool->configFile) {
|
|
|
|
*autostart = 0;
|
|
|
|
} else {
|
|
|
|
*autostart = privpool->autostart;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolSetAutostart(virStoragePoolPtr obj,
|
|
|
|
int autostart) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
|
|
|
|
if (!privpool->configFile) {
|
|
|
|
testError(obj->conn, VIR_ERR_INVALID_ARG,
|
|
|
|
"%s", _("pool has no config file"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
autostart = (autostart != 0);
|
|
|
|
|
|
|
|
if (privpool->autostart == autostart)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
privpool->autostart = autostart;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolNumVolumes(virStoragePoolPtr obj) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_ACTIVE(privpool, -1);
|
|
|
|
|
|
|
|
return privpool->volumes.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStoragePoolListVolumes(virStoragePoolPtr obj,
|
|
|
|
char **const names,
|
|
|
|
int maxnames) {
|
|
|
|
GET_POOL(obj, -1);
|
|
|
|
POOL_IS_ACTIVE(privpool, -1);
|
|
|
|
int i = 0, n = 0;
|
|
|
|
|
|
|
|
memset(names, 0, maxnames);
|
|
|
|
for (i = 0 ; i < privpool->volumes.count && n < maxnames ; i++) {
|
|
|
|
if ((names[n++] = strdup(privpool->volumes.objs[i]->name)) == NULL) {
|
|
|
|
testError(obj->conn, VIR_ERR_NO_MEMORY, "%s", _("name"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
for (n = 0 ; n < maxnames ; n++)
|
|
|
|
VIR_FREE(names[i]);
|
|
|
|
|
|
|
|
memset(names, 0, maxnames);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
testStorageVolumeLookupByName(virStoragePoolPtr obj,
|
|
|
|
const char *name ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL(obj, NULL);
|
|
|
|
POOL_IS_ACTIVE(privpool, NULL);
|
|
|
|
virStorageVolDefPtr vol = virStorageVolDefFindByName(privpool, name);
|
|
|
|
|
|
|
|
if (!vol) {
|
|
|
|
testError(obj->conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"), name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return virGetStorageVol(obj->conn, privpool->def->name,
|
|
|
|
vol->name, vol->key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
testStorageVolumeLookupByKey(virConnectPtr conn,
|
|
|
|
const char *key) {
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++) {
|
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
|
|
|
|
virStorageVolDefPtr vol =
|
|
|
|
virStorageVolDefFindByKey(privconn->pools.objs[i], key);
|
|
|
|
|
|
|
|
if (vol)
|
|
|
|
return virGetStorageVol(conn,
|
|
|
|
privconn->pools.objs[i]->def->name,
|
|
|
|
vol->name,
|
|
|
|
vol->key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
testError(conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching key '%s'"), key);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
testStorageVolumeLookupByPath(virConnectPtr conn,
|
|
|
|
const char *path) {
|
|
|
|
GET_CONNECTION(conn);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < privconn->pools.count ; i++) {
|
|
|
|
if (virStoragePoolObjIsActive(privconn->pools.objs[i])) {
|
|
|
|
virStorageVolDefPtr vol =
|
|
|
|
virStorageVolDefFindByPath(privconn->pools.objs[i], path);
|
|
|
|
|
|
|
|
if (vol)
|
|
|
|
return virGetStorageVol(conn,
|
|
|
|
privconn->pools.objs[i]->def->name,
|
|
|
|
vol->name,
|
|
|
|
vol->key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
testError(conn, VIR_ERR_INVALID_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching path '%s'"), path);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
|
|
|
testStorageVolumeCreateXML(virStoragePoolPtr obj,
|
|
|
|
const char *xmldesc,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL(obj, NULL);
|
|
|
|
POOL_IS_ACTIVE(privpool, NULL);
|
|
|
|
virStorageVolDefPtr vol;
|
|
|
|
|
|
|
|
vol = virStorageVolDefParse(obj->conn, privpool->def, xmldesc, NULL);
|
|
|
|
if (vol == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (virStorageVolDefFindByName(privpool, vol->name)) {
|
|
|
|
testError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
|
|
|
|
"%s", _("storage vol already exists"));
|
|
|
|
virStorageVolDefFree(vol);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure enough space */
|
|
|
|
if ((privpool->def->allocation + vol->allocation) >
|
|
|
|
privpool->def->capacity) {
|
|
|
|
testError(obj->conn, VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Not enough free space in pool for volume '%s'"),
|
|
|
|
vol->name);
|
|
|
|
virStorageVolDefFree(vol);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
privpool->def->available = (privpool->def->capacity -
|
|
|
|
privpool->def->allocation);
|
|
|
|
|
|
|
|
if (VIR_REALLOC_N(privpool->volumes.objs,
|
|
|
|
privpool->volumes.count+1) < 0) {
|
|
|
|
testError(obj->conn, VIR_ERR_NO_MEMORY, NULL);
|
|
|
|
virStorageVolDefFree(vol);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(vol->target.path, strlen(privpool->def->target.path) +
|
|
|
|
1 + strlen(vol->name) + 1) < 0) {
|
|
|
|
virStorageVolDefFree(vol);
|
|
|
|
testError(obj->conn, VIR_ERR_NO_MEMORY, "%s", _("target"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(vol->target.path, privpool->def->target.path);
|
|
|
|
strcat(vol->target.path, "/");
|
|
|
|
strcat(vol->target.path, vol->name);
|
|
|
|
vol->key = strdup(vol->target.path);
|
|
|
|
if (vol->key == NULL) {
|
|
|
|
virStorageVolDefFree(vol);
|
|
|
|
testError(obj->conn, VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("storage vol key"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
privpool->def->allocation += vol->allocation;
|
|
|
|
privpool->def->available = (privpool->def->capacity -
|
|
|
|
privpool->def->allocation);
|
|
|
|
|
|
|
|
privpool->volumes.objs[privpool->volumes.count++] = vol;
|
|
|
|
|
|
|
|
return virGetStorageVol(obj->conn, privpool->def->name, vol->name,
|
|
|
|
vol->key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
testStorageVolumeDelete(virStorageVolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL_FROM_VOL(obj, -1);
|
|
|
|
POOL_IS_ACTIVE(privpool, -1);
|
|
|
|
GET_VOL(obj, privpool, -1);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
testStorageVolumeGetInfo(virStorageVolPtr obj,
|
|
|
|
virStorageVolInfoPtr info) {
|
|
|
|
GET_POOL_FROM_VOL(obj, -1);
|
|
|
|
POOL_IS_ACTIVE(privpool, -1);
|
|
|
|
GET_VOL(obj, privpool, -1);
|
|
|
|
|
|
|
|
memset(info, 0, sizeof(*info));
|
|
|
|
info->type = testStorageVolumeTypeForPool(privpool->def->type);
|
|
|
|
info->capacity = privvol->capacity;
|
|
|
|
info->allocation = privvol->allocation;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
testStorageVolumeGetXMLDesc(virStorageVolPtr obj,
|
|
|
|
unsigned int flags ATTRIBUTE_UNUSED) {
|
|
|
|
GET_POOL_FROM_VOL(obj, NULL);
|
|
|
|
POOL_IS_ACTIVE(privpool, NULL);
|
|
|
|
GET_VOL(obj, privpool, NULL);
|
|
|
|
|
|
|
|
return virStorageVolDefFormat(obj->conn, privpool->def, privvol);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
testStorageVolumeGetPath(virStorageVolPtr obj) {
|
|
|
|
GET_POOL_FROM_VOL(obj, NULL);
|
|
|
|
POOL_IS_ACTIVE(privpool, NULL);
|
|
|
|
GET_VOL(obj, privpool, NULL);
|
|
|
|
char *ret;
|
|
|
|
|
|
|
|
ret = strdup(privvol->target.path);
|
|
|
|
if (ret == NULL) {
|
|
|
|
testError(obj->conn, VIR_ERR_NO_MEMORY, "%s", _("path"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-07-27 23:23:00 +00:00
|
|
|
|
|
|
|
static virDriver testDriver = {
|
|
|
|
VIR_DRV_TEST,
|
|
|
|
"Test",
|
|
|
|
LIBVIR_VERSION_NUMBER,
|
2008-02-26 07:05:18 +00:00
|
|
|
NULL, /* probe */
|
2007-07-27 23:23:00 +00:00
|
|
|
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 */
|
|
|
|
testGetHostname, /* hostname */
|
|
|
|
testGetURI, /* URI */
|
|
|
|
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 */
|
|
|
|
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 */
|
2008-10-23 13:18:18 +00:00
|
|
|
NULL, /* domainEventRegister */
|
|
|
|
NULL, /* domainEventDeregister */
|
2008-11-14 08:42:47 +00:00
|
|
|
NULL, /* domainMigratePrepare2 */
|
|
|
|
NULL, /* domainMigrateFinish2 */
|
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
|
|
|
};
|
|
|
|
|
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;
|
2007-07-27 23:23:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|