本文整理汇总了C++中ARRAY_CARDINALITY函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY_CARDINALITY函数的具体用法?C++ ARRAY_CARDINALITY怎么用?C++ ARRAY_CARDINALITY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ARRAY_CARDINALITY函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: testQemuAddArmGuest
static int testQemuAddArmGuest(virCapsPtr caps)
{
static const char *machines[] = { "vexpress-a9",
"vexpress-a15",
"versatilepb" };
virCapsGuestMachinePtr *capsmachines = NULL;
virCapsGuestPtr guest;
capsmachines = virCapabilitiesAllocMachines(machines,
ARRAY_CARDINALITY(machines));
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_ARMV7L,
"/usr/bin/qemu-system-arm", NULL,
ARRAY_CARDINALITY(machines),
capsmachines);
if (!guest)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL))
goto error;
return 0;
error:
virCapabilitiesFreeMachines(capsmachines, ARRAY_CARDINALITY(machines));
return -1;
}
开发者ID:ryanmiao,项目名称:libvirt,代码行数:29,代码来源:testutilsqemu.c
示例2: testQemuAddS390Guest
static int testQemuAddS390Guest(virCapsPtr caps)
{
static const char *s390_machines[] = { "s390-virtio",
"s390-ccw-virtio" };
virCapsGuestMachinePtr *machines = NULL;
virCapsGuestPtr guest;
machines = virCapabilitiesAllocMachines(s390_machines,
ARRAY_CARDINALITY(s390_machines));
if (!machines)
goto error;
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_S390X,
"/usr/bin/qemu-system-s390x", NULL,
ARRAY_CARDINALITY(s390_machines),
machines);
if (!guest)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
goto error;
return 0;
error:
virCapabilitiesFreeMachines(machines, ARRAY_CARDINALITY(s390_machines));
return -1;
}
开发者ID:feli5,项目名称:libvirt,代码行数:28,代码来源:testutilsqemu.c
示例3: testAddCPUModels
static int
testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
{
const char *newModels[] = {
"Opteron_G3", "Opteron_G2", "Opteron_G1",
"Nehalem", "Penryn", "Conroe",
};
const char *legacyModels[] = {
"n270", "athlon", "pentium3", "pentium2", "pentium",
"486", "coreduo", "kvm32", "qemu32", "kvm64",
"core2duo", "phenom", "qemu64",
};
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(newModels); i++) {
if (virQEMUCapsAddCPUDefinition(caps, newModels[i]) < 0)
return -1;
}
if (skipLegacy)
return 0;
for (i = 0; i < ARRAY_CARDINALITY(legacyModels); i++) {
if (virQEMUCapsAddCPUDefinition(caps, legacyModels[i]) < 0)
return -1;
}
return 0;
}
开发者ID:djs55,项目名称:libvirt,代码行数:26,代码来源:qemuxml2argvtest.c
示例4: testQemuAddAARCH64Guest
static int testQemuAddAARCH64Guest(virCapsPtr caps)
{
static const char *machines[] = { "virt"};
virCapsGuestMachinePtr *capsmachines = NULL;
virCapsGuestPtr guest;
capsmachines = virCapabilitiesAllocMachines(machines,
ARRAY_CARDINALITY(machines));
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_AARCH64,
"/usr/bin/qemu-system-aarch64", NULL,
ARRAY_CARDINALITY(machines),
capsmachines);
if (!guest)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
goto error;
return 0;
error:
virCapabilitiesFreeMachines(capsmachines, ARRAY_CARDINALITY(machines));
return -1;
}
开发者ID:feli5,项目名称:libvirt,代码行数:27,代码来源:testutilsqemu.c
示例5: testQemuAddArmGuest
static int testQemuAddArmGuest(virCapsPtr caps)
{
static const char *machines[] = { "vexpress-a9",
"vexpress-a15",
"versatilepb" };
virCapsGuestMachinePtr *capsmachines = NULL;
virCapsGuestPtr guest;
capsmachines = virCapabilitiesAllocMachines(machines,
ARRAY_CARDINALITY(machines));
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_ARMV7L,
QEMUBinList[TEST_UTILS_QEMU_BIN_ARM],
NULL,
ARRAY_CARDINALITY(machines),
capsmachines);
if (!guest)
goto error;
if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL))
goto error;
return 0;
error:
virCapabilitiesFreeMachines(capsmachines, ARRAY_CARDINALITY(machines));
return -1;
}
开发者ID:aruiz,项目名称:libvirt,代码行数:30,代码来源:testutilsqemu.c
示例6: qemuTestCapsCacheInsert
int qemuTestCapsCacheInsert(virQEMUCapsCachePtr cache,
virQEMUCapsPtr caps)
{
size_t i;
virQEMUCapsPtr tmpCaps;
if (caps) {
tmpCaps = caps;
} else {
if (!(tmpCaps = virQEMUCapsNew()))
return -ENOMEM;
}
for (i = 0; i < ARRAY_CARDINALITY(QEMUBinList); i++) {
virObjectRef(tmpCaps);
if (virHashUpdateEntry(cache->binaries,
QEMUBinList[i],
tmpCaps) < 0) {
virObjectUnref(tmpCaps);
return -1;
}
}
if (!caps)
virObjectUnref(tmpCaps);
return 0;
}
开发者ID:aruiz,项目名称:libvirt,代码行数:28,代码来源:testutilsqemu.c
示例7: gather_capability
static int
gather_capability(LibHalContext *ctx, const char *udi,
const char *cap_name,
virNodeDevCapsDefPtr *caps_p)
{
caps_tbl_entry *entry;
entry = bsearch(&cap_name, caps_tbl, ARRAY_CARDINALITY(caps_tbl),
sizeof(caps_tbl[0]), cmpstringp);
if (entry) {
virNodeDevCapsDefPtr caps;
if (VIR_ALLOC(caps) < 0)
return ENOMEM;
caps->type = entry->type;
if (entry->gather_fn) {
int rv = (*entry->gather_fn)(ctx, udi, &caps->data);
if (rv != 0) {
virNodeDevCapsDefFree(caps);
return rv;
}
}
caps->next = *caps_p;
*caps_p = caps;
}
return 0;
}
开发者ID:ISI-apex,项目名称:libvirt-ARM,代码行数:28,代码来源:node_device_hal.c
示例8: virCapabilitiesAllocMachines
static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
{
virCapsGuestMachinePtr *machines;
static const char *const x86_machines[] = {
"pc", "isapc"
};
machines = virCapabilitiesAllocMachines(x86_machines,
ARRAY_CARDINALITY(x86_machines));
if (machines == NULL)
return NULL;
*nmachines = ARRAY_CARDINALITY(x86_machines);
return machines;
}
开发者ID:feli5,项目名称:libvirt,代码行数:16,代码来源:testutilsqemu.c
示例9: read_bd_stat
static int64_t
read_bd_stat(int device, int domid, const char *str)
{
static const char *paths[] = {
"/sys/bus/xen-backend/devices/vbd-%d-%d/statistics/%s",
"/sys/bus/xen-backend/devices/tap-%d-%d/statistics/%s",
"/sys/devices/xen-backend/vbd-%d-%d/statistics/%s",
"/sys/devices/xen-backend/tap-%d-%d/statistics/%s"
};
int i;
char *path;
int64_t r;
for (i = 0; i < ARRAY_CARDINALITY(paths); ++i) {
if (virAsprintf(&path, paths[i], domid, device, str) < 0) {
virReportOOMError();
return -1;
}
r = read_stat(path);
VIR_FREE(path);
if (r >= 0) {
return r;
}
}
return -1;
}
开发者ID:rbu,项目名称:libvirt,代码行数:31,代码来源:block_stats.c
示例10: mymain
static int
mymain(void)
{
int ret = 0;
int i;
const char *nodeData[] = {
"test1",
# if !(defined(__powerpc__) || \
defined(__powerpc64__))
"test2",
"test3",
"test4",
"test5",
"test6",
# endif
};
if (virInitialize() < 0)
return EXIT_FAILURE;
for (i = 0 ; i < ARRAY_CARDINALITY(nodeData); i++)
if (virtTestRun(nodeData[i], 1, linuxTestNodeInfo, nodeData[i]) != 0)
ret = -1;
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
开发者ID:mohankku,项目名称:libvirt,代码行数:26,代码来源:nodeinfotest.c
示例11: lxcContainerPopulateDevices
static int lxcContainerPopulateDevices(void)
{
int i;
const struct {
int maj;
int min;
mode_t mode;
const char *path;
} devs[] = {
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL, 0666, "/dev/null" },
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO, 0666, "/dev/zero" },
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL, 0666, "/dev/full" },
{ LXC_DEV_MAJ_TTY, LXC_DEV_MIN_CONSOLE, 0600, "/dev/console" },
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM, 0666, "/dev/random" },
{ LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM, 0666, "/dev/urandom" },
};
/* Populate /dev/ with a few important bits */
for (i = 0 ; i < ARRAY_CARDINALITY(devs) ; i++) {
dev_t dev = makedev(devs[i].maj, devs[i].min);
if (mknod(devs[i].path, S_IFCHR, dev) < 0 ||
chmod(devs[i].path, devs[i].mode)) {
virReportSystemError(errno,
_("Failed to make device %s"),
devs[i].path);
return -1;
}
}
if (access("/dev/pts/ptmx", W_OK) == 0) {
if (symlink("/dev/pts/ptmx", "/dev/ptmx") < 0) {
virReportSystemError(errno, "%s",
_("Failed to create symlink /dev/ptmx to /dev/pts/ptmx"));
return -1;
}
} else {
dev_t dev = makedev(LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX);
if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 ||
chmod("/dev/ptmx", 0666)) {
virReportSystemError(errno, "%s",
_("Failed to make device /dev/ptmx"));
return -1;
}
}
/* XXX we should allow multiple consoles per container
* for tty2, tty3, etc, but the domain XML does not
* handle this yet
*/
if (symlink("/dev/pts/0", "/dev/tty1") < 0) {
virReportSystemError(errno, "%s",
_("Failed to symlink /dev/pts/0 to /dev/tty1"));
return -1;
}
return 0;
}
开发者ID:amery,项目名称:libvirt-vserver,代码行数:57,代码来源:lxc_container.c
示例12: lxcContainerMountBasicFS
static int lxcContainerMountBasicFS(virDomainFSDefPtr root)
{
const struct {
const char *src;
const char *dst;
const char *type;
} mnts[] = {
{ "/dev", "/dev", "tmpfs" },
{ "/proc", "/proc", "proc" },
{ "/sys", "/sys", "sysfs" },
#if WITH_SELINUX
{ "none", "/selinux", "selinuxfs" },
#endif
};
int i, rc = -1;
char *devpts;
if (virAsprintf(&devpts, "/.oldroot%s/dev/pts", root->src) < 0) {
virReportOOMError();
return rc;
}
for (i = 0 ; i < ARRAY_CARDINALITY(mnts) ; i++) {
if (virFileMakePath(mnts[i].dst) != 0) {
virReportSystemError(errno,
_("Failed to mkdir %s"),
mnts[i].src);
goto cleanup;
}
if (mount(mnts[i].src, mnts[i].dst, mnts[i].type, 0, NULL) < 0) {
virReportSystemError(errno,
_("Failed to mount %s on %s"),
mnts[i].type, mnts[i].type);
goto cleanup;
}
}
if ((rc = virFileMakePath("/dev/pts") != 0)) {
virReportSystemError(rc, "%s",
_("Cannot create /dev/pts"));
goto cleanup;
}
VIR_DEBUG("Trying to move %s to %s", devpts, "/dev/pts");
if ((rc = mount(devpts, "/dev/pts", NULL, MS_MOVE, NULL)) < 0) {
virReportSystemError(errno, "%s",
_("Failed to mount /dev/pts in container"));
goto cleanup;
}
rc = 0;
cleanup:
VIR_FREE(devpts);
return rc;
}
开发者ID:amery,项目名称:libvirt-vserver,代码行数:57,代码来源:lxc_container.c
示例13: testHashInit
static virHashTablePtr
testHashInit(int size)
{
virHashTablePtr hash;
ssize_t i;
if (!(hash = virHashCreate(size, NULL)))
return NULL;
/* entires are added in reverse order so that they will be linked in
* collision list in the same order as in the uuids array
*/
for (i = ARRAY_CARDINALITY(uuids) - 1; i >= 0; i--) {
ssize_t oldsize = virHashTableSize(hash);
if (virHashAddEntry(hash, uuids[i], (void *) uuids[i]) < 0) {
virHashFree(hash);
return NULL;
}
if (virHashTableSize(hash) != oldsize && virTestGetDebug()) {
VIR_WARN("hash grown from %zd to %zd",
(size_t)oldsize, (size_t)virHashTableSize(hash));
}
}
for (i = 0; i < ARRAY_CARDINALITY(uuids); i++) {
if (!virHashLookup(hash, uuids[i])) {
if (virTestGetVerbose()) {
VIR_WARN("\nentry \"%s\" could not be found\n",
uuids[i]);
}
virHashFree(hash);
return NULL;
}
}
if (size && size != virHashTableSize(hash) && virTestGetDebug())
fprintf(stderr, "\n");
return hash;
}
开发者ID:bigclouds,项目名称:libvirt,代码行数:41,代码来源:virhashtest.c
示例14: VBoxCGlueInit
/**
* Tries to locate and load VBoxXPCOMC.so/dylib/dll, resolving all the related
* function pointers.
*
* @returns 0 on success, -1 on failure.
*/
int
VBoxCGlueInit(unsigned int *version)
{
int i;
static const char *knownDirs[] = {
"/usr/lib/virtualbox",
"/usr/lib/virtualbox-ose",
"/usr/lib64/virtualbox",
"/usr/lib64/virtualbox-ose",
"/usr/lib/VirtualBox",
"/opt/virtualbox",
"/opt/VirtualBox",
"/opt/virtualbox/i386",
"/opt/VirtualBox/i386",
"/opt/virtualbox/amd64",
"/opt/VirtualBox/amd64",
"/usr/local/lib/virtualbox",
"/usr/local/lib/VirtualBox",
"/Applications/VirtualBox.app/Contents/MacOS"
};
const char *home = getenv("VBOX_APP_HOME");
/* If the user specifies the location, try only that. */
if (home != NULL) {
if (tryLoadOne(home, false, false, version) < 0) {
return -1;
}
}
/* Try the additionally configured location. */
if (VBOX_XPCOMC_DIR[0] != '\0') {
if (tryLoadOne(VBOX_XPCOMC_DIR, true, true, version) >= 0) {
return 0;
}
}
/* Try the known locations. */
for (i = 0; i < ARRAY_CARDINALITY(knownDirs); ++i) {
if (tryLoadOne(knownDirs[i], true, true, version) >= 0) {
return 0;
}
}
/* Finally try the dynamic linker search path. */
if (tryLoadOne(NULL, false, true, version) >= 0) {
return 0;
}
/* No luck, return failure. */
return -1;
}
开发者ID:bigclouds,项目名称:libvirt,代码行数:57,代码来源:vbox_XPCOMCGlue.c
示例15: testRemoveCommonRules
static void testRemoveCommonRules(char *rules)
{
size_t i;
char *offset = rules;
for (i = 0; i < ARRAY_CARDINALITY(commonRules); i++) {
char *tmp = strstr(offset, commonRules[i]);
size_t len = strlen(commonRules[i]);
if (tmp) {
memmove(tmp, tmp + len, (strlen(tmp) + 1) - len);
offset = tmp;
}
}
}
开发者ID:aruiz,项目名称:libvirt,代码行数:14,代码来源:nwfilterxml2firewalltest.c
示例16: virNumaGetPages
/*
* TODO: Adapt virNumaGetHugePageInfo{Path,Dir} to use sysfs so that the
* paths can be modified and this function can be thrown away and instead we'd
* have copied info from /sys (as we do with /sys/devices/system).
*/
int
virNumaGetPages(int node,
unsigned int **pages_size,
unsigned int **pages_avail,
unsigned int **pages_free,
size_t *npages)
{
const int pages_def[] = { 4, 2 * 1024, 1 * 1024 * 1024};
const int npages_def = ARRAY_CARDINALITY(pages_def);
size_t i = 0;
if (pages_size)
*pages_size = NULL;
if (pages_avail)
*pages_avail = NULL;
if (pages_free)
*pages_free = NULL;
*npages = 0;
if ((pages_size && VIR_ALLOC_N(*pages_size, npages_def) < 0) ||
(pages_avail && VIR_ALLOC_N(*pages_avail, npages_def) < 0) ||
(pages_free && VIR_ALLOC_N(*pages_free, npages_def) < 0)) {
VIR_FREE(*pages_size);
VIR_FREE(*pages_avail);
return -1;
}
*npages = npages_def;
if (pages_size)
memcpy(*pages_size, pages_def, sizeof(pages_def));
node++;
if (node <= 0)
node = 32;
if (pages_avail || pages_free) {
for (i = 0; i < *npages; i++) {
if (pages_avail)
(*pages_avail)[i] = (node + i) * 2 << 10;
if (pages_free)
(*pages_free)[i] = (node + i) * 1 << 10;
}
}
return 0;
}
开发者ID:aruiz,项目名称:libvirt,代码行数:54,代码来源:virnumamock.c
示例17: cpuGetSubDriverByName
static struct cpuArchDriver *
cpuGetSubDriverByName(const char *name)
{
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(drivers); i++) {
if (STREQ_NULLABLE(name, drivers[i]->name))
return drivers[i];
}
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU driver '%s' does not exist"),
name);
return NULL;
}
开发者ID:RWTH-OS,项目名称:libvirt,代码行数:15,代码来源:cpu.c
示例18: skipws
static char *errtok(char *s, int *err) {
char *t = skipws(s);
s = findws(t);
if (s == t) {
*err = AUG_NOERROR;
return s;
}
for (*err = 0; *err < ARRAY_CARDINALITY(errtokens); *err += 1) {
const char *e = errtokens[*err];
if (strlen(e) == s - t && STREQLEN(e, t, s - t))
return s;
}
fprintf(stderr, "errtok: '%s'\n", t);
die("unknown error code");
}
开发者ID:afcady,项目名称:augeas,代码行数:15,代码来源:test-run.c
示例19: virDomainSnapshotObjListGetNames
int
virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots,
virDomainMomentObjPtr from,
char **const names,
int maxnames,
unsigned int flags)
{
/* Convert public flags into common flags */
unsigned int moment_flags = 0;
struct { int snap_flag; int moment_flag; } map[] = {
{ VIR_DOMAIN_SNAPSHOT_LIST_ROOTS,
VIR_DOMAIN_MOMENT_LIST_ROOTS, },
{ VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL,
VIR_DOMAIN_MOMENT_LIST_TOPOLOGICAL, },
{ VIR_DOMAIN_SNAPSHOT_LIST_LEAVES,
VIR_DOMAIN_MOMENT_LIST_LEAVES, },
{ VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES,
VIR_DOMAIN_MOMENT_LIST_NO_LEAVES, },
{ VIR_DOMAIN_SNAPSHOT_LIST_METADATA,
VIR_DOMAIN_MOMENT_LIST_METADATA, },
{ VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA,
VIR_DOMAIN_MOMENT_LIST_NO_METADATA, },
};
size_t i;
for (i = 0; i < ARRAY_CARDINALITY(map); i++) {
if (flags & map[i].snap_flag) {
flags &= ~map[i].snap_flag;
moment_flags |= map[i].moment_flag;
}
}
/* For ease of coding the visitor, it is easier to zero each group
* where all of the bits are set. */
if ((flags & VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES) ==
VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES)
flags &= ~VIR_DOMAIN_SNAPSHOT_FILTERS_LEAVES;
if ((flags & VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS) ==
VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS)
flags &= ~VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS;
if ((flags & VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION) ==
VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION)
flags &= ~VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION;
return virDomainMomentObjListGetNames(snapshots->base, from, names,
maxnames, moment_flags,
virDomainSnapshotFilter, flags);
}
开发者ID:libvirt,项目名称:libvirt,代码行数:47,代码来源:virdomainsnapshotobjlist.c
示例20: virSecurityDriverLookup
virSecurityDriverPtr virSecurityDriverLookup(const char *name,
const char *virtDriver)
{
virSecurityDriverPtr drv = NULL;
size_t i;
VIR_DEBUG("name=%s", NULLSTR(name));
for (i = 0; i < ARRAY_CARDINALITY(security_drivers) && !drv; i++) {
virSecurityDriverPtr tmp = security_drivers[i];
if (name &&
STRNEQ(tmp->name, name))
continue;
switch (tmp->probe(virtDriver)) {
case SECURITY_DRIVER_ENABLE:
VIR_DEBUG("Probed name=%s", tmp->name);
drv = tmp;
break;
case SECURITY_DRIVER_DISABLE:
VIR_DEBUG("Not enabled name=%s", tmp->name);
if (name && STREQ(tmp->name, name)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Security driver %s not enabled"),
name);
return NULL;
}
break;
case SECURITY_DRIVER_ERROR:
default:
return NULL;
}
}
if (!drv) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Security driver %s not found"),
NULLSTR(name));
return NULL;
}
return drv;
}
开发者ID:libvirt,项目名称:libvirt,代码行数:46,代码来源:security_driver.c
注:本文中的ARRAY_CARDINALITY函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论