这篇教程C++ virConfGetValue函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中virConfGetValue函数的典型用法代码示例。如果您正苦于以下问题:C++ virConfGetValue函数的具体用法?C++ virConfGetValue怎么用?C++ virConfGetValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了virConfGetValue函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: lxcSetMemTunestatic intlxcSetMemTune(virDomainDefPtr def, virConfPtr properties){ virConfValuePtr value; unsigned long long size = 0; if ((value = virConfGetValue(properties, "lxc.cgroup.memory.limit_in_bytes")) && value->str && STRNEQ(value->str, "-1")) { if (lxcConvertSize(value->str, &size) < 0) return -1; size = size / 1024; virDomainDefSetMemoryTotal(def, size); def->mem.hard_limit = virMemoryLimitTruncate(size); } if ((value = virConfGetValue(properties, "lxc.cgroup.memory.soft_limit_in_bytes")) && value->str && STRNEQ(value->str, "-1")) { if (lxcConvertSize(value->str, &size) < 0) return -1; def->mem.soft_limit = virMemoryLimitTruncate(size / 1024); } if ((value = virConfGetValue(properties, "lxc.cgroup.memory.memsw.limit_in_bytes")) && value->str && STRNEQ(value->str, "-1")) { if (lxcConvertSize(value->str, &size) < 0) return -1; def->mem.swap_hard_limit = virMemoryLimitTruncate(size / 1024); } return 0;}
开发者ID:tdaajames,项目名称:libvirt,代码行数:35,
示例2: lxcSetCpuTunestatic intlxcSetCpuTune(virDomainDefPtr def, virConfPtr properties){ virConfValuePtr value; if ((value = virConfGetValue(properties, "lxc.cgroup.cpu.shares")) && value->str) { if (virStrToLong_ul(value->str, NULL, 10, &def->cputune.shares) < 0) goto error; def->cputune.sharesSpecified = true; } if ((value = virConfGetValue(properties, "lxc.cgroup.cpu.cfs_quota_us")) && value->str && virStrToLong_ll(value->str, NULL, 10, &def->cputune.quota) < 0) goto error; if ((value = virConfGetValue(properties, "lxc.cgroup.cpu.cfs_period_us")) && value->str && virStrToLong_ull(value->str, NULL, 10, &def->cputune.period) < 0) goto error; return 0; error: virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse integer: '%s'"), value->str); return -1;}
开发者ID:tdaajames,项目名称:libvirt,代码行数:31,
示例3: lxcSetCpusetTunestatic intlxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties){ virConfValuePtr value; virBitmapPtr nodeset = NULL; if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.cpus")) && value->str) { if (virBitmapParse(value->str, 0, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) return -1; def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC; } if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.mems")) && value->str) { if (virBitmapParse(value->str, 0, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) return -1; if (virDomainNumatuneSet(def->numa, def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC, VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC, VIR_DOMAIN_NUMATUNE_MEM_STRICT, nodeset) < 0) { virBitmapFree(nodeset); return -1; } virBitmapFree(nodeset); } return 0;}
开发者ID:tdaajames,项目名称:libvirt,代码行数:33,
示例4: virLXCLoadDriverConfigintvirLXCLoadDriverConfig(virLXCDriverConfigPtr cfg, const char *filename){ virConfPtr conf; virConfValuePtr p; /* Avoid error from non-existent or unreadable file. */ if (access(filename, R_OK) == -1) goto done; conf = virConfReadFile(filename, 0); if (!conf) goto done;#define CHECK_TYPE(name, typ) if (p && p->type != (typ)) { / virReportError(VIR_ERR_INTERNAL_ERROR, / "%s: %s: expected type " #typ, / filename, (name)); / virConfFree(conf); / return -1; / } p = virConfGetValue(conf, "log_with_libvirtd"); CHECK_TYPE("log_with_libvirtd", VIR_CONF_ULONG); if (p) cfg->log_libvirtd = p->l; p = virConfGetValue(conf, "security_driver"); CHECK_TYPE("security_driver", VIR_CONF_STRING); if (p && p->str) { if (VIR_STRDUP(cfg->securityDriverName, p->str) < 0) { virConfFree(conf); return -1; } } p = virConfGetValue(conf, "security_default_confined"); CHECK_TYPE("security_default_confined", VIR_CONF_ULONG); if (p) cfg->securityDefaultConfined = p->l; p = virConfGetValue(conf, "security_require_confined"); CHECK_TYPE("security_require_confined", VIR_CONF_ULONG); if (p) cfg->securityRequireConfined = p->l;#undef CHECK_TYPE virConfFree(conf); done: return 0;}
开发者ID:lixingchen12138,项目名称:libvmi-volatility-master,代码行数:51,
示例5: virConfGetValueString/** * virConfGetValueString: * @conf: the config object * @setting: the config entry name * @value: pointer to hold string value * * Get the string value of the config name @setting, storing * it in @value. If the config entry is not present, then * @value will be unmodified. * * Reports an error if the config entry is set but has * an unexpected type. * * Returns: 1 if the value was present, 0 if missing, -1 on error */int virConfGetValueString(virConfPtr conf, const char *setting, char **value){ virConfValuePtr cval = virConfGetValue(conf, setting); VIR_DEBUG("Get value string %p %d", cval, cval ? cval->type : VIR_CONF_NONE); if (!cval) return 0; if (cval->type != VIR_CONF_STRING) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: expected a string for '%s' parameter"), conf->filename, setting); return -1; } VIR_FREE(*value); if (VIR_STRDUP(*value, cval->str) < 0) return -1; return 1;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:40,
示例6: virConfGetValueLLong/** * virConfGetValueLLong: * @conf: the config object * @setting: the config entry name * @value: pointer to hold integer value * * Get the integer value of the config name @setting, storing * it in @value. If the config entry is not present, then * @value will be unmodified. * * Reports an error if the config entry is set but has * an unexpected type, or if the value is outside the * range that can be stored in an 'long long' * * Returns: 1 if the value was present, 0 if missing, -1 on error */int virConfGetValueLLong(virConfPtr conf, const char *setting, long long *value){ virConfValuePtr cval = virConfGetValue(conf, setting); VIR_DEBUG("Get value long long %p %d", cval, cval ? cval->type : VIR_CONF_NONE); if (!cval) return 0; if (cval->type == VIR_CONF_ULLONG) { if (((unsigned long long)cval->l) > LLONG_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: value for '%s' parameter must be in range %lld:%lld"), conf->filename, setting, LLONG_MIN, LLONG_MAX); return -1; } } else if (cval->type != VIR_CONF_LLONG) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: expected a signed integer for '%s' parameter"), conf->filename, setting); return -1; } *value = cval->l; return 1;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:46,
示例7: virConfGetValueSizeT/** * virConfGetValueSizeT: * @conf: the config object * @setting: the config entry name * @value: pointer to hold integer value * * Get the integer value of the config name @setting, storing * it in @value. If the config entry is not present, then * @value will be unmodified. * * Reports an error if the config entry is set but has * an unexpected type, or if the value is outside the * range that can be stored in a 'size_t' * * Returns: 1 if the value was present, 0 if missing, -1 on error */int virConfGetValueSizeT(virConfPtr conf, const char *setting, size_t *value){ virConfValuePtr cval = virConfGetValue(conf, setting); VIR_DEBUG("Get value size_t %p %d", cval, cval ? cval->type : VIR_CONF_NONE); if (!cval) return 0; if (cval->type != VIR_CONF_ULLONG) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: expected an unsigned integer for '%s' parameter"), conf->filename, setting); return -1; }#if ULLONG_MAX > SIZE_MAX if (((unsigned long long)cval->l) > SIZE_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: value for '%s' parameter must be in range 0:%zu"), conf->filename, setting, SIZE_MAX); return -1; }#endif *value = (size_t)cval->l; return 1;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:48,
示例8: virConfGetValueUInt/** * virConfGetValueUInt: * @conf: the config object * @setting: the config entry name * @value: pointer to hold integer value * * Get the unsigned integer value of the config name @setting, storing * it in @value. If the config entry is not present, then * @value will be unmodified. * * Reports an error if the config entry is set but has * an unexpected type, or if the value is outside the * range that can be stored in an 'unsigned int' * * Returns: 1 if the value was present, 0 if missing, -1 on error */int virConfGetValueUInt(virConfPtr conf, const char *setting, unsigned int *value){ virConfValuePtr cval = virConfGetValue(conf, setting); VIR_DEBUG("Get value uint %p %d", cval, cval ? cval->type : VIR_CONF_NONE); if (!cval) return 0; if (cval->type != VIR_CONF_ULLONG) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: expected an unsigned integer for '%s' parameter"), conf->filename, setting); return -1; } if (((unsigned long long)cval->l) > UINT_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: value for '%s' parameter must be in range 0:%u"), conf->filename, setting, UINT_MAX); return -1; } *value = (unsigned int)cval->l; return 1;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:46,
示例9: virConfGetValueInt/** * virConfGetValueInt: * @conf: the config object * @setting: the config entry name * @value: pointer to hold integer value * * Get the integer value of the config name @setting, storing * it in @value. If the config entry is not present, then * @value will be unmodified. * * Reports an error if the config entry is set but has * an unexpected type, or if the value is outside the * range that can be stored in an 'int' * * Returns: 1 if the value was present, 0 if missing, -1 on error */int virConfGetValueInt(virConfPtr conf, const char *setting, int *value){ virConfValuePtr cval = virConfGetValue(conf, setting); VIR_DEBUG("Get value int %p %d", cval, cval ? cval->type : VIR_CONF_NONE); if (!cval) return 0; if (cval->type != VIR_CONF_LLONG && cval->type != VIR_CONF_ULLONG) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: expected a signed integer for '%s' parameter"), conf->filename, setting); return -1; } if (cval->l > INT_MAX || cval->l < INT_MIN) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: value for '%s' parameter must be in range %d:%d"), conf->filename, setting, INT_MIN, INT_MAX); return -1; } *value = (int)cval->l; return 1;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:47,
示例10: virAdmGetDefaultURIstatic const char *virAdmGetDefaultURI(virConfPtr conf){ virConfValuePtr value = NULL; const char *uristr = NULL; uristr = virGetEnvAllowSUID("LIBVIRT_ADMIN_DEFAULT_URI"); if (uristr && *uristr) { VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", uristr); } else if ((value = virConfGetValue(conf, "admin_uri_default"))) { if (value->type != VIR_CONF_STRING) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Expected a string for 'admin_uri_default' config " "parameter")); return NULL; } VIR_DEBUG("Using config file uri '%s'", value->str); uristr = value->str; } else { /* Since we can't probe connecting via any hypervisor driver as libvirt * does, if no explicit URI was given and neither the environment * variable, nor the configuration parameter had previously been set, * we set the default admin server URI to 'libvirtd://system'. */ uristr = "libvirtd:///system"; } return uristr;}
开发者ID:joe-nas,项目名称:libvirt,代码行数:30,
示例11: virConfGetValueBool/** * virConfGetValueBool: * @conf: the config object * @setting: the config entry name * @value: pointer to hold boolean value * * Get the boolean value of the config name @setting, storing * it in @value. If the config entry is not present, then * @value will be unmodified. * * Reports an error if the config entry is set but has * an unexpected type, or if the value set is not 1 or 0. * * Returns: 1 if the value was present, 0 if missing, -1 on error */int virConfGetValueBool(virConfPtr conf, const char *setting, bool *value){ virConfValuePtr cval = virConfGetValue(conf, setting); VIR_DEBUG("Get value bool %p %d", cval, cval ? cval->type : VIR_CONF_NONE); if (!cval) return 0; if (cval->type != VIR_CONF_ULLONG) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: expected a bool for '%s' parameter"), conf->filename, setting); return -1; } if (((unsigned long long)cval->l) > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: value for '%s' parameter must be 0 or 1"), conf->filename, setting); return -1; } *value = cval->l == 1; return 1;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:45,
示例12: remoteConfigGetAuthstatic int remoteConfigGetAuth(virConfPtr conf, const char *key, int *auth, const char *filename) { virConfValuePtr p; p = virConfGetValue(conf, key); if (!p) return 0; if (checkType(p, filename, key, VIR_CONF_STRING) < 0) return -1; if (!p->str) return 0; if (STREQ(p->str, "none")) { *auth = VIR_NET_SERVER_SERVICE_AUTH_NONE;#if HAVE_SASL } else if (STREQ(p->str, "sasl")) { *auth = VIR_NET_SERVER_SERVICE_AUTH_SASL;#endif } else if (STREQ(p->str, "polkit")) { *auth = VIR_NET_SERVER_SERVICE_AUTH_POLKIT; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("remoteReadConfigFile: %s: %s: unsupported auth %s"), filename, key, p->str); return -1; } return 0;}
开发者ID:emaste,项目名称:libvirt,代码行数:30,
示例13: virConfGetValueType/** * virConfGetValueType: * @conf: the config object * @setting: the config entry name * * Query the type of the configuration entry @setting. * * Returns: the entry type, or VIR_CONF_NONE if not set. */virConfType virConfGetValueType(virConfPtr conf, const char *setting){ virConfValuePtr cval = virConfGetValue(conf, setting); if (!cval) return VIR_CONF_NONE; return cval->type;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:18,
示例14: virLoginShellAllowedUserstatic int virLoginShellAllowedUser(virConfPtr conf, const char *name, gid_t *groups){ virConfValuePtr p; int ret = -1; char *ptr = NULL; size_t i; char *gname = NULL; p = virConfGetValue(conf, "allowed_users"); if (p && p->type == VIR_CONF_LIST) { virConfValuePtr pp; /* Calc length and check items */ for (pp = p->list; pp; pp = pp->next) { if (pp->type != VIR_CONF_STRING) { virReportSystemError(EINVAL, "%s", _("shell must be a list of strings")); goto cleanup; } else { /* If string begins with a % this indicates a linux group. Check to see if the user is in the Linux Group. */ if (pp->str[0] == '%') { ptr = &pp->str[1]; if (!*ptr) continue; for (i = 0; groups[i]; i++) { if (!(gname = virGetGroupName(groups[i]))) continue; if (fnmatch(ptr, gname, 0) == 0) { ret = 0; goto cleanup; } VIR_FREE(gname); } continue; } if (fnmatch(pp->str, name, 0) == 0) { ret = 0; goto cleanup; } } } } virReportSystemError(EPERM, _("%s not matched against 'allowed_users' in %s"), name, conf_file); cleanup: VIR_FREE(gname); return ret;}
开发者ID:6WIND,项目名称:libvirt,代码行数:54,
示例15: xenParseXLInputDevsstatic intxenParseXLInputDevs(virConfPtr conf, virDomainDefPtr def){ const char *str; virConfValuePtr val; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { val = virConfGetValue(conf, "usbdevice"); /* usbdevice can be defined as either a single string or a list */ if (val && val->type == VIR_CONF_LIST) {#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST val = val->list;#else virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("multiple USB devices not supported")); return -1;#endif } /* otherwise val->next is NULL, so can be handled by the same code */ while (val) { if (val->type != VIR_CONF_STRING) { virReportError(VIR_ERR_INTERNAL_ERROR, _("config value %s was malformed"), "usbdevice"); return -1; } str = val->str; if (str && (STREQ(str, "tablet") || STREQ(str, "mouse") || STREQ(str, "keyboard"))) { virDomainInputDefPtr input; if (VIR_ALLOC(input) < 0) return -1; input->bus = VIR_DOMAIN_INPUT_BUS_USB; if (STREQ(str, "mouse")) input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE; else if (STREQ(str, "tablet")) input->type = VIR_DOMAIN_INPUT_TYPE_TABLET; else if (STREQ(str, "keyboard")) input->type = VIR_DOMAIN_INPUT_TYPE_KBD; if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { virDomainInputDefFree(input); return -1; } } val = val->next; } } return 0;}
开发者ID:Lantame,项目名称:libvirt,代码行数:53,
示例16: lxcSetBlkioTunestatic intlxcSetBlkioTune(virDomainDefPtr def, virConfPtr properties){ virConfValuePtr value; if ((value = virConfGetValue(properties, "lxc.cgroup.blkio.weight")) && value->str && virStrToLong_ui(value->str, NULL, 10, &def->blkio.weight) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse integer: '%s'"), value->str); return -1; } if (virConfWalk(properties, lxcBlkioDeviceWalkCallback, def) < 0) return -1; return 0;}
开发者ID:tdaajames,项目名称:libvirt,代码行数:18,
示例17: lxcSetCapDropstatic voidlxcSetCapDrop(virDomainDefPtr def, virConfPtr properties){ virConfValuePtr value; char **toDrop = NULL; const char *capString; size_t i; if ((value = virConfGetValue(properties, "lxc.cap.drop")) && value->str) toDrop = virStringSplit(value->str, " ", 0); for (i = 0; i < VIR_DOMAIN_CAPS_FEATURE_LAST; i++) { capString = virDomainCapsFeatureTypeToString(i); if (toDrop != NULL && virStringArrayHasString(toDrop, capString)) def->caps_features[i] = VIR_TRISTATE_SWITCH_OFF; } def->features[VIR_DOMAIN_FEATURE_CAPABILITIES] = VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW; virStringFreeList(toDrop);}
开发者ID:tdaajames,项目名称:libvirt,代码行数:21,
示例18: lxcSetRootfsstatic intlxcSetRootfs(virDomainDefPtr def, virConfPtr properties){ int type = VIR_DOMAIN_FS_TYPE_MOUNT; virConfValuePtr value; if (!(value = virConfGetValue(properties, "lxc.rootfs")) || !value->str) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Missing lxc.rootfs configuration")); return -1; } if (STRPREFIX(value->str, "/dev/")) type = VIR_DOMAIN_FS_TYPE_BLOCK; if (lxcAddFSDef(def, type, value->str, "/", false, 0) < 0) return -1; return 0;}
开发者ID:tdaajames,项目名称:libvirt,代码行数:22,
示例19: lxcCreateConsolesstatic intlxcCreateConsoles(virDomainDefPtr def, virConfPtr properties){ virConfValuePtr value; int nbttys = 0; virDomainChrDefPtr console; size_t i; if (!(value = virConfGetValue(properties, "lxc.tty")) || !value->str) return 0; if (virStrToLong_i(value->str, NULL, 10, &nbttys) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse int: '%s'"), value->str); return -1; } if (VIR_ALLOC_N(def->consoles, nbttys) < 0) return -1; def->nconsoles = nbttys; for (i = 0; i < nbttys; i++) { if (!(console = virDomainChrDefNew())) goto error; console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; console->target.port = i; console->source.type = VIR_DOMAIN_CHR_TYPE_PTY; def->consoles[i] = console; } return 0; error: virDomainChrDefFree(console); return -1;}
开发者ID:tdaajames,项目名称:libvirt,代码行数:39,
示例20: virConfGetValueSSizeT/** * virConfGetValueSSizeT: * @conf: the config object * @setting: the config entry name * @value: pointer to hold integer value * * Get the integer value of the config name @setting, storing * it in @value. If the config entry is not present, then * @value will be unmodified. * * Reports an error if the config entry is set but has * an unexpected type, or if the value is outside the * range that can be stored in an 'ssize_t' * * Returns: 1 if the value was present, 0 if missing, -1 on error */int virConfGetValueSSizeT(virConfPtr conf, const char *setting, ssize_t *value){ virConfValuePtr cval = virConfGetValue(conf, setting); VIR_DEBUG("Get value ssize_t %p %d", cval, cval ? cval->type : VIR_CONF_NONE); if (!cval) return 0; if (cval->type == VIR_CONF_ULLONG) { if (((unsigned long long)cval->l) > SSIZE_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: value for '%s' parameter must be in range %zd:%zd"), conf->filename, setting, (ssize_t)-SSIZE_MAX - 1, (ssize_t)SSIZE_MAX); return -1; } } else if (cval->type == VIR_CONF_LLONG) {#if SSIZE_MAX < LLONG_MAX if (cval->l < (-SSIZE_MAX - 1) || cval->l > SSIZE_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: value for '%s' parameter must be in range %zd:%zd"), conf->filename, setting, (ssize_t)-SSIZE_MAX - 1, (ssize_t)SSIZE_MAX); return -1; }#endif } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("%s: expected a signed integer for '%s' parameter"), conf->filename, setting); return -1; } *value = (ssize_t)cval->l; return 1;}
开发者ID:MountainWei,项目名称:libvirt,代码行数:55,
示例21: SELinuxLXCInitializestatic intSELinuxLXCInitialize(virSecurityManagerPtr mgr){ virConfValuePtr scon = NULL; virConfValuePtr tcon = NULL; virConfValuePtr dcon = NULL; virConfPtr selinux_conf; virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(mgr); selinux_conf = virConfReadFile(selinux_lxc_contexts_path(), 0); if (!selinux_conf) { virReportSystemError(errno, _("cannot open SELinux lxc contexts file '%s'"), selinux_lxc_contexts_path()); return -1; } scon = virConfGetValue(selinux_conf, "process"); if (! scon || scon->type != VIR_CONF_STRING || (! scon->str)) { virReportSystemError(errno, _("cannot read 'process' value from selinux lxc contexts file '%s'"), selinux_lxc_contexts_path()); goto error; } tcon = virConfGetValue(selinux_conf, "file"); if (! tcon || tcon->type != VIR_CONF_STRING || (! tcon->str)) { virReportSystemError(errno, _("cannot read 'file' value from selinux lxc contexts file '%s'"), selinux_lxc_contexts_path()); goto error; } dcon = virConfGetValue(selinux_conf, "content"); if (! dcon || dcon->type != VIR_CONF_STRING || (! dcon->str)) { virReportSystemError(errno, _("cannot read 'file' value from selinux lxc contexts file '%s'"), selinux_lxc_contexts_path()); goto error; } data->domain_context = strdup(scon->str); data->file_context = strdup(tcon->str); data->content_context = strdup(dcon->str); if (!data->domain_context || !data->file_context || !data->content_context) { virReportSystemError(errno, _("cannot allocate memory for LXC SELinux contexts '%s'"), selinux_lxc_contexts_path()); goto error; } virConfFree(selinux_conf); return 0;error: virConfFree(selinux_conf); VIR_FREE(data->domain_context); VIR_FREE(data->file_context); VIR_FREE(data->content_context); return -1;}
开发者ID:intgr,项目名称:libvirt,代码行数:62,
示例22: virLockManagerSanlockLoadConfig/* * sanlock plugin for the libvirt virLockManager API */static int virLockManagerSanlockLoadConfig(const char *configFile){ virConfPtr conf; virConfValuePtr p; char *tmp; if (access(configFile, R_OK) == -1) { if (errno != ENOENT) { virReportSystemError(errno, _("Unable to access config file %s"), configFile); return -1; } return 0; } if (!(conf = virConfReadFile(configFile, 0))) return -1;#define CHECK_TYPE(name,typ) if (p && p->type != (typ)) { / virReportError(VIR_ERR_INTERNAL_ERROR, / "%s: %s: expected type " #typ, / configFile, (name)); / virConfFree(conf); / return -1; / } p = virConfGetValue(conf, "auto_disk_leases"); CHECK_TYPE("auto_disk_leases", VIR_CONF_LONG); if (p) driver->autoDiskLease = p->l; p = virConfGetValue(conf, "disk_lease_dir"); CHECK_TYPE("disk_lease_dir", VIR_CONF_STRING); if (p && p->str) { VIR_FREE(driver->autoDiskLeasePath); if (!(driver->autoDiskLeasePath = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; } } p = virConfGetValue(conf, "host_id"); CHECK_TYPE("host_id", VIR_CONF_LONG); if (p) driver->hostID = p->l; p = virConfGetValue(conf, "require_lease_for_disks"); CHECK_TYPE("require_lease_for_disks", VIR_CONF_LONG); if (p) driver->requireLeaseForDisks = p->l; else driver->requireLeaseForDisks = !driver->autoDiskLease; p = virConfGetValue(conf, "user"); CHECK_TYPE("user", VIR_CONF_STRING); if (p) { if (!(tmp = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; } if (virGetUserID(tmp, &driver->user) < 0) { VIR_FREE(tmp); virConfFree(conf); return -1; } VIR_FREE(tmp); } p = virConfGetValue (conf, "group"); CHECK_TYPE ("group", VIR_CONF_STRING); if (p) { if (!(tmp = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; } if (virGetGroupID(tmp, &driver->group) < 0) { VIR_FREE(tmp); virConfFree(conf); return -1; } VIR_FREE(tmp); } virConfFree(conf); return 0;}
开发者ID:mithleshvrts,项目名称:libvirt-0.10.2,代码行数:92,
示例23: xenParseXLUSBstatic intxenParseXLUSB(virConfPtr conf, virDomainDefPtr def){ virConfValuePtr list = virConfGetValue(conf, "usbdev"); virDomainHostdevDefPtr hostdev = NULL; if (list && list->type == VIR_CONF_LIST) { list = list->list; while (list) { char bus[3]; char device[3]; char *key; int busNum; int devNum; bus[0] = device[0] = '/0'; if ((list->type != VIR_CONF_STRING) || (list->str == NULL)) goto skipusb; /* usbdev=['hostbus=1,hostaddr=3'] */ key = list->str; while (key) { char *data; char *nextkey = strchr(key, ','); if (!(data = strchr(key, '='))) goto skipusb; data++; if (STRPREFIX(key, "hostbus=")) { int len = nextkey ? (nextkey - data) : sizeof(bus) - 1; if (virStrncpy(bus, data, len, sizeof(bus)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("bus %s too big for destination"), data); goto skipusb; } } else if (STRPREFIX(key, "hostaddr=")) { int len = nextkey ? (nextkey - data) : sizeof(device) - 1; if (virStrncpy(device, data, len, sizeof(device)) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("device %s too big for destination"), data); goto skipusb; } } while (nextkey && (nextkey[0] == ',' || nextkey[0] == ' ' || nextkey[0] == '/t')) nextkey++; key = nextkey; } if (virStrToLong_i(bus, NULL, 16, &busNum) < 0) goto skipusb; if (virStrToLong_i(device, NULL, 16, &devNum) < 0) goto skipusb; if (!(hostdev = virDomainHostdevDefAlloc(NULL))) return -1; hostdev->managed = false; hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB; hostdev->source.subsys.u.usb.bus = busNum; hostdev->source.subsys.u.usb.device = devNum; if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0) { virDomainHostdevDefFree(hostdev); return -1; } skipusb: list = list->next; } } return 0;}
开发者ID:Lantame,项目名称:libvirt,代码行数:78,
示例24: xenParseXLDisk/* * For details on xl disk config syntax, see * docs/misc/xl-disk-configuration.txt in the Xen sources. The important * section of text is: * * More formally, the string is a series of comma-separated keyword/value * pairs, flags and positional parameters. Parameters which are not bare * keywords and which do not contain "=" symbols are assigned to the * so-far-unspecified positional parameters, in the order below. The * positional parameters may also be specified explicitly by name. * * Each parameter may be specified at most once, either as a positional * parameter or a named parameter. Default values apply if the parameter * is not specified, or if it is specified with an empty value (whether * positionally or explicitly). * * Whitespace may appear before each parameter and will be ignored. * * The order of the positional parameters mentioned in the quoted text is: * * target,format,vdev,access * * The following options must be specified by key=value: * * devtype=<devtype> * backendtype=<backend-type> * * The following options are currently not supported: * * backend=<domain-name> * script=<script> * direct-io-safe * */static intxenParseXLDisk(virConfPtr conf, virDomainDefPtr def){ int ret = -1; virConfValuePtr list = virConfGetValue(conf, "disk"); XLU_Config *xluconf; libxl_device_disk *libxldisk; virDomainDiskDefPtr disk = NULL; if (VIR_ALLOC(libxldisk) < 0) return -1; if (!(xluconf = xlu_cfg_init(stderr, "command line"))) goto cleanup; if (list && list->type == VIR_CONF_LIST) { list = list->list; while (list) { const char *disk_spec = list->str; if (list->type != VIR_CONF_STRING || list->str == NULL) goto skipdisk; libxl_device_disk_init(libxldisk); if (xlu_disk_parse(xluconf, 1, &disk_spec, libxldisk)) goto fail; if (!(disk = virDomainDiskDefNew(NULL))) goto fail; if (xenParseXLDiskSrc(disk, libxldisk->pdev_path) < 0) goto fail; if (VIR_STRDUP(disk->dst, libxldisk->vdev) < 0) goto fail; disk->src->readonly = !libxldisk->readwrite; disk->removable = libxldisk->removable; if (libxldisk->is_cdrom) { if (virDomainDiskSetDriver(disk, "qemu") < 0) goto fail; virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE); disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM; if (!disk->src->path || STREQ(disk->src->path, "")) disk->src->format = VIR_STORAGE_FILE_NONE; else disk->src->format = VIR_STORAGE_FILE_RAW; } else { switch (libxldisk->format) { case LIBXL_DISK_FORMAT_QCOW: disk->src->format = VIR_STORAGE_FILE_QCOW; break; case LIBXL_DISK_FORMAT_QCOW2: disk->src->format = VIR_STORAGE_FILE_QCOW2; break; case LIBXL_DISK_FORMAT_VHD: disk->src->format = VIR_STORAGE_FILE_VHD; break; case LIBXL_DISK_FORMAT_RAW: case LIBXL_DISK_FORMAT_UNKNOWN://.........这里部分代码省略.........
开发者ID:Lantame,项目名称:libvirt,代码行数:101,
示例25: virQEMUDriverConfigLoadFileint virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, const char *filename){ virConfPtr conf = NULL; virConfValuePtr p; int ret = -1; size_t i; char *stdioHandler = NULL; /* Just check the file is readable before opening it, otherwise * libvirt emits an error. */ if (access(filename, R_OK) == -1) { VIR_INFO("Could not read qemu config file %s", filename); return 0; } if (!(conf = virConfReadFile(filename, 0))) goto cleanup;#define CHECK_TYPE(name, typ) / if (p && p->type != (typ)) { / virReportError(VIR_ERR_INTERNAL_ERROR, / "%s: %s: expected type " #typ, / filename, (name)); / goto cleanup; / }#define CHECK_TYPE_ALT(name, type1, type2) / if (p && (p->type != (type1) && p->type != (type2))) { / virReportError(VIR_ERR_INTERNAL_ERROR, / "%s: %s: expected type " #type1, / filename, (name)); / goto cleanup; / }#define GET_VALUE_LONG(NAME, VAR) / p = virConfGetValue(conf, NAME); / CHECK_TYPE_ALT(NAME, VIR_CONF_LONG, VIR_CONF_ULONG); / if (p) / VAR = p->l;#define GET_VALUE_ULONG(NAME, VAR) / p = virConfGetValue(conf, NAME); / CHECK_TYPE(NAME, VIR_CONF_ULONG); / if (p) / VAR = p->l;#define GET_VALUE_BOOL(NAME, VAR) / p = virConfGetValue(conf, NAME); / CHECK_TYPE(NAME, VIR_CONF_ULONG); / if (p) / VAR = p->l != 0;#define GET_VALUE_STR(NAME, VAR) / p = virConfGetValue(conf, NAME); / CHECK_TYPE(NAME, VIR_CONF_STRING); / if (p && p->str) { / VIR_FREE(VAR); / if (VIR_STRDUP(VAR, p->str) < 0) / goto cleanup; / } GET_VALUE_BOOL("vnc_auto_unix_socket", cfg->vncAutoUnixSocket); GET_VALUE_BOOL("vnc_tls", cfg->vncTLS); GET_VALUE_BOOL("vnc_tls_x509_verify", cfg->vncTLSx509verify); GET_VALUE_STR("vnc_tls_x509_cert_dir", cfg->vncTLSx509certdir); GET_VALUE_STR("vnc_listen", cfg->vncListen); GET_VALUE_STR("vnc_password", cfg->vncPassword); GET_VALUE_BOOL("vnc_sasl", cfg->vncSASL); GET_VALUE_STR("vnc_sasl_dir", cfg->vncSASLdir); GET_VALUE_BOOL("vnc_allow_host_audio", cfg->vncAllowHostAudio); GET_VALUE_BOOL("nographics_allow_host_audio", cfg->nogfxAllowHostAudio); p = virConfGetValue(conf, "security_driver"); if (p && p->type == VIR_CONF_LIST) { size_t len, j; virConfValuePtr pp; /* Calc length and check items */ for (len = 0, pp = p->list; pp; len++, pp = pp->next) { if (pp->type != VIR_CONF_STRING) { virReportError(VIR_ERR_CONF_SYNTAX, "%s", _("security_driver must be a list of strings")); goto cleanup; } } if (VIR_ALLOC_N(cfg->securityDriverNames, len + 1) < 0) goto cleanup; for (i = 0, pp = p->list; pp; i++, pp = pp->next) { for (j = 0; j < i; j++) { if (STREQ(pp->str, cfg->securityDriverNames[j])) { virReportError(VIR_ERR_CONF_SYNTAX, _("Duplicate security driver %s"), pp->str); goto cleanup; } } if (VIR_STRDUP(cfg->securityDriverNames[i], pp->str) < 0)//.........这里部分代码省略.........
开发者ID:Lantame,项目名称:libvirt,代码行数:101,
示例26: virLockManagerLockDaemonLoadConfigstatic int virLockManagerLockDaemonLoadConfig(const char *configFile){ virConfPtr conf; virConfValuePtr p; if (access(configFile, R_OK) == -1) { if (errno != ENOENT) { virReportSystemError(errno, _("Unable to access config file %s"), configFile); return -1; } return 0; } if (!(conf = virConfReadFile(configFile, 0))) return -1;#define CHECK_TYPE(name,typ) if (p && p->type != (typ)) { / virReportError(VIR_ERR_INTERNAL_ERROR, / "%s: %s: expected type " #typ, / configFile, (name)); / virConfFree(conf); / return -1; / } p = virConfGetValue(conf, "auto_disk_leases"); CHECK_TYPE("auto_disk_leases", VIR_CONF_LONG); if (p) driver->autoDiskLease = p->l; p = virConfGetValue(conf, "file_lockspace_dir"); CHECK_TYPE("file_lockspace_dir", VIR_CONF_STRING); if (p && p->str) { VIR_FREE(driver->fileLockSpaceDir); if (!(driver->fileLockSpaceDir = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; } } p = virConfGetValue(conf, "lvm_lockspace_dir"); CHECK_TYPE("lvm_lockspace_dir", VIR_CONF_STRING); if (p && p->str) { VIR_FREE(driver->lvmLockSpaceDir); if (!(driver->lvmLockSpaceDir = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; } } p = virConfGetValue(conf, "scsi_lockspace_dir"); CHECK_TYPE("scsi_lockspace_dir", VIR_CONF_STRING); if (p && p->str) { VIR_FREE(driver->scsiLockSpaceDir); if (!(driver->scsiLockSpaceDir = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; } } p = virConfGetValue(conf, "require_lease_for_disks"); CHECK_TYPE("require_lease_for_disks", VIR_CONF_LONG); if (p) driver->requireLeaseForDisks = p->l; else driver->requireLeaseForDisks = !driver->autoDiskLease; virConfFree(conf); return 0;}
开发者ID:avdv,项目名称:libvirt,代码行数:73,
示例27: remoteConfigGetStringList/* Allocate an array of malloc'd strings from the config file, filename * (used only in diagnostics), using handle "conf". Upon error, return -1 * and free any allocated memory. Otherwise, save the array in *list_arg * and return 0. */static intremoteConfigGetStringList(virConfPtr conf, const char *key, char ***list_arg, const char *filename){ char **list; virConfValuePtr p = virConfGetValue(conf, key); if (!p) return 0; switch (p->type) { case VIR_CONF_STRING: if (VIR_ALLOC_N(list, 2) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("failed to allocate memory for %s config list"), key); return -1; } list[0] = strdup(p->str); list[1] = NULL; if (list[0] == NULL) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("failed to allocate memory for %s config list value"), key); VIR_FREE(list); return -1; } break; case VIR_CONF_LIST: { int i, len = 0; virConfValuePtr pp; for (pp = p->list; pp; pp = pp->next) len++; if (VIR_ALLOC_N(list, 1+len) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("failed to allocate memory for %s config list"), key); return -1; } for (i = 0, pp = p->list; pp; ++i, pp = pp->next) { if (pp->type != VIR_CONF_STRING) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("remoteReadConfigFile: %s: %s:" " must be a string or list of strings"), filename, key); VIR_FREE(list); return -1; } list[i] = strdup(pp->str); if (list[i] == NULL) { int j; for (j = 0 ; j < i ; j++) VIR_FREE(list[j]); VIR_FREE(list); virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("failed to allocate memory for %s config list value"), key); return -1; } } list[i] = NULL; break; } default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("remoteReadConfigFile: %s: %s:" " must be a string or list of strings"), filename, key); return -1; } *list_arg = list; return 0;}
开发者ID:emaste,项目名称:libvirt,代码行数:81,
示例28: lxcParseConfigStringvirDomainDefPtrlxcParseConfigString(const char *config, virCapsPtr caps, virDomainXMLOptionPtr xmlopt){ virDomainDefPtr vmdef = NULL; virConfPtr properties = NULL; virConfValuePtr value; if (!(properties = virConfReadMem(config, 0, VIR_CONF_FLAG_LXC_FORMAT))) return NULL; if (!(vmdef = virDomainDefNew())) goto error; if (virUUIDGenerate(vmdef->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to generate uuid")); goto error; } vmdef->id = -1; virDomainDefSetMemoryTotal(vmdef, 64 * 1024); vmdef->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART; vmdef->onCrash = VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; vmdef->onPoweroff = VIR_DOMAIN_LIFECYCLE_DESTROY; vmdef->virtType = VIR_DOMAIN_VIRT_LXC; /* Value not handled by the LXC driver, setting to * minimum required to make XML parsing pass */ if (virDomainDefSetVcpusMax(vmdef, 1) < 0) goto error; if (virDomainDefSetVcpus(vmdef, 1) < 0) goto error; vmdef->nfss = 0; vmdef->os.type = VIR_DOMAIN_OSTYPE_EXE; if ((value = virConfGetValue(properties, "lxc.arch")) && value->str) { virArch arch = virArchFromString(value->str); if (arch == VIR_ARCH_NONE && STREQ(value->str, "x86")) arch = VIR_ARCH_I686; else if (arch == VIR_ARCH_NONE && STREQ(value->str, "amd64")) arch = VIR_ARCH_X86_64; vmdef->os.arch = arch; } if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0) goto error; if (!(value = virConfGetValue(properties, "lxc.utsname")) || !value->str || (VIR_STRDUP(vmdef->name, value->str) < 0)) goto error; if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0)) goto error; if (lxcSetRootfs(vmdef, properties) < 0) goto error; /* Look for fstab: we shouldn't have it */ if (virConfGetValue(properties, "lxc.mount")) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("lxc.mount found, use lxc.mount.entry lines instead")); goto error; } /* Loop over lxc.mount.entry to add filesystem devices for them */ if (virConfWalk(properties, lxcFstabWalkCallback, vmdef) < 0) goto error; /* Network configuration */ if (lxcConvertNetworkSettings(vmdef, properties) < 0) goto error; /* Consoles */ if (lxcCreateConsoles(vmdef, properties) < 0) goto error; /* lxc.id_map */ if (virConfWalk(properties, lxcIdmapWalkCallback, vmdef) < 0) goto error; /* lxc.cgroup.memory.* */ if (lxcSetMemTune(vmdef, properties) < 0) goto error; /* lxc.cgroup.cpu.* */ if (lxcSetCpuTune(vmdef, properties) < 0) goto error; /* lxc.cgroup.cpuset.* */ if (lxcSetCpusetTune(vmdef, properties) < 0) goto error; /* lxc.cgroup.blkio.* */ if (lxcSetBlkioTune(vmdef, properties) < 0) goto error;//.........这里部分代码省略.........
开发者ID:tdaajames,项目名称:libvirt,代码行数:101,
示例29: qemudLoadDriverConfigint qemudLoadDriverConfig(struct qemud_driver *driver, const char *filename) { virConfPtr conf; virConfValuePtr p; char *user; char *group; int i; /* Setup critical defaults */ driver->dynamicOwnership = 1; driver->clearEmulatorCapabilities = 1; if (!(driver->vncListen = strdup("127.0.0.1"))) { virReportOOMError(); return -1; } if (!(driver->vncTLSx509certdir = strdup(SYSCONFDIR "/pki/libvirt-vnc"))) { virReportOOMError(); return -1; } if (!(driver->spiceListen = strdup("127.0.0.1"))) { virReportOOMError(); return -1; } if (!(driver->spiceTLSx509certdir = strdup(SYSCONFDIR "/pki/libvirt-spice"))) { virReportOOMError(); return -1; }#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R /* For privileged driver, try and find hugepage mount automatically. * Non-privileged driver requires admin to create a dir for the * user, chown it, and then let user configure it manually */ if (driver->privileged && !(driver->hugetlbfs_mount = virFileFindMountPoint("hugetlbfs"))) { if (errno != ENOENT) { virReportSystemError(errno, "%s", _("unable to find hugetlbfs mountpoint")); return -1; } }#endif /* Just check the file is readable before opening it, otherwise * libvirt emits an error. */ if (access (filename, R_OK) == -1) { VIR_INFO("Could not read qemu config file %s", filename); return 0; } conf = virConfReadFile (filename, 0); if (!conf) { return -1; }#define CHECK_TYPE(name,typ) if (p && p->type != (typ)) { / qemuReportError(VIR_ERR_INTERNAL_ERROR, / "%s: %s: expected type " #typ, / filename, (name)); / virConfFree(conf); / return -1; / } p = virConfGetValue (conf, "vnc_auto_unix_socket"); CHECK_TYPE ("vnc_auto_unix_socket", VIR_CONF_LONG); if (p) driver->vncAutoUnixSocket = p->l; p = virConfGetValue (conf, "vnc_tls"); CHECK_TYPE ("vnc_tls", VIR_CONF_LONG); if (p) driver->vncTLS = p->l; p = virConfGetValue (conf, "vnc_tls_x509_verify"); CHECK_TYPE ("vnc_tls_x509_verify", VIR_CONF_LONG); if (p) driver->vncTLSx509verify = p->l; p = virConfGetValue (conf, "vnc_tls_x509_cert_dir"); CHECK_TYPE ("vnc_tls_x509_cert_dir", VIR_CONF_STRING); if (p && p->str) { VIR_FREE(driver->vncTLSx509certdir); if (!(driver->vncTLSx509certdir = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; } } p = virConfGetValue (conf, "vnc_listen"); CHECK_TYPE ("vnc_listen", VIR_CONF_STRING); if (p && p->str) { VIR_FREE(driver->vncListen); if (!(driver->vncListen = strdup(p->str))) { virReportOOMError(); virConfFree(conf); return -1; }//.........这里部分代码省略.........
开发者ID:rbu,项目名称:libvirt,代码行数:101,
示例30: virQEMUDriverConfigLoadFileint virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, const char *filename){ virConfPtr conf = NULL; virConfValuePtr p; int ret = -1; size_t i; /* Just check the file is readable before opening it, otherwise * libvirt emits an error. */ if (access(filename, R_OK) == -1) { VIR_INFO("Could not read qemu config file %s", filename); return 0; } if (!(conf = virConfReadFile(filename, 0))) goto cleanup;#define CHECK_TYPE(name,typ) / if (p && p->type != (typ)) { / virReportError(VIR_ERR_INTERNAL_ERROR, / "%s: %s: expected type " #typ, / filename, (name)); / goto cleanup; / }#define GET_VALUE_LONG(NAME, VAR) / p = virConfGetValue(conf, NAME); / CHECK_TYPE(NAME, VIR_CONF_LONG); / if (p) / VAR = p->l;#define GET_VALUE_BOOL(NAME, VAR) / p = virConfGetValue(conf, NAME); / CHECK_TYPE(NAME, VIR_CONF_LONG); / if (p) / VAR = p->l != 0;#define GET_VALUE_STR(NAME, VAR) / p = virConfGetValue(conf, NAME); / CHECK_TYPE(NAME, VIR_CONF_STRING); / if (p && p->str) { / VIR_FREE(VAR); / if (VIR_STRDUP(VAR, p->str) < 0) / goto cleanup; / } GET_VALUE_BOOL("vnc_auto_unix_socket", cfg->vncAutoUnixSocket); GET_VALUE_BOOL("vnc_tls", cfg->vncTLS); GET_VALUE_BOOL("vnc_tls_x509_verify", cfg->vncTLSx509verify); GET_VALUE_STR("vnc_tls_x509_cert_dir", cfg->vncTLSx509certdir); GET_VALUE_STR("vnc_listen", cfg->vncListen); GET_VALUE_STR("vnc_password", cfg->vncPassword); GET_VALUE_BOOL("vnc_sasl", cfg->vncSASL); GET_VALUE_STR("vnc_sasl_dir", cfg->vncSASLdir); GET_VALUE_BOOL("vnc_allow_host_audio", cfg->vncAllowHostAudio); GET_VALUE_BOOL("nographics_allow_host_audio", cfg->nogfxAllowHostAudio); p = virConfGetValue(conf, "security_driver"); if (p && p->type == VIR_CONF_LIST) { size_t len; virConfValuePtr pp; /* Calc length and check items */ for (len = 0, pp = p->list; pp; len++, pp = pp->next) { if (pp->type != VIR_CONF_STRING) { virReportError(VIR_ERR_CONF_SYNTAX, "%s", _("security_driver must be a list of strings")); goto cleanup; } } if (VIR_ALLOC_N(cfg->securityDriverNames, len + 1) < 0) goto cleanup; for (i = 0, pp = p->list; pp; i++, pp = pp->next) { if (VIR_STRDUP(cfg->securityDriverNames[i], pp->str) < 0) goto cleanup; } cfg->securityDriverNames[len] = NULL; } else { CHECK_TYPE("security_driver", VIR_CONF_STRING); if (p && p->str) { if (VIR_ALLOC_N(cfg->securityDriverNames, 2) < 0) goto cleanup; if (VIR_STRDUP(cfg->securityDriverNames[0], p->str) < 0) goto cleanup; cfg->securityDriverNames[1] = NULL; } } GET_VALUE_BOOL("security_default_confined", cfg->securityDefaultConfined); GET_VALUE_BOOL("security_require_confined", cfg->securityRequireConfined); GET_VALUE_BOOL("spice_tls", cfg->spiceTLS); GET_VALUE_STR("spice_tls_x509_cert_dir", cfg->spiceTLSx509certdir); GET_VALUE_BOOL("spice_sasl", cfg->spiceSASL); GET_VALUE_STR("spice_sasl_dir", cfg->spiceSASLdir);//.........这里部分代码省略.........
开发者ID:TelekomCloud,项目名称:libvirt,代码行数:101,
注:本文中的virConfGetValue函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ virConnectClose函数代码示例 C++ virCommandSetOutputBuffer函数代码示例 |