当前位置: 首页>>代码示例>>C++>>正文


C++ virDomainDefFree函数代码示例

本文整理汇总了C++中virDomainDefFree函数的典型用法代码示例。如果您正苦于以下问题:C++ virDomainDefFree函数的具体用法?C++ virDomainDefFree怎么用?C++ virDomainDefFree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了virDomainDefFree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: xenInotifyXendDomainsDirLookup

static int
xenInotifyXendDomainsDirLookup(virConnectPtr conn,
                               const char *filename,
                               char **name,
                               unsigned char *uuid)
{
    size_t i;
    virDomainDefPtr def;
    const char *uuid_str;
    unsigned char rawuuid[VIR_UUID_BUFLEN];
    xenUnifiedPrivatePtr priv = conn->privateData;

    /* xend is managing domains. we will get
    * a filename in the manner:
    * /var/lib/xend/domains/<uuid>/
    */
    uuid_str = filename + strlen(XEND_DOMAINS_DIR) + 1;

    if (virUUIDParse(uuid_str, rawuuid) < 0) {
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       _("parsing uuid %s"), uuid_str);
        return -1;
    }
    /* call directly into xend here, as driver may not yet
       be set during open while we are building our
       initial list of domains */
    VIR_DEBUG("Looking for dom with uuid: %s", uuid_str);

    if (!(def = xenDaemonLookupByUUID(conn, rawuuid))) {
        /* If we are here, the domain has gone away.
           search for, and create a domain from the stored
           list info */
        for (i = 0; i < priv->configInfoList->count; i++) {
            if (!memcmp(rawuuid, priv->configInfoList->doms[i]->uuid, VIR_UUID_BUFLEN)) {
                if (VIR_STRDUP(*name, priv->configInfoList->doms[i]->name) < 0)
                    return -1;
                memcpy(uuid, priv->configInfoList->doms[i]->uuid, VIR_UUID_BUFLEN);
                VIR_DEBUG("Found dom on list");
                return 0;
            }
        }
        virReportError(VIR_ERR_INTERNAL_ERROR,
                       "%s", _("finding dom on config list"));
        return -1;
    }

    if (VIR_STRDUP(*name, def->name) < 0) {
        virDomainDefFree(def);
        return -1;
    }
    memcpy(uuid, def->uuid, VIR_UUID_BUFLEN);
    virDomainDefFree(def);
    /* succeeded too find domain by uuid */
    return 0;
}
开发者ID:miurahr,项目名称:libvirt,代码行数:55,代码来源:xen_inotify.c

示例2: bhyveParseCommandLineString

virDomainDefPtr
bhyveParseCommandLineString(const char* nativeConfig,
                            unsigned caps,
                            virDomainXMLOptionPtr xmlopt)
{
    virDomainDefPtr def = NULL;
    int bhyve_argc = 0;
    char **bhyve_argv = NULL;
    int loader_argc = 0;
    char **loader_argv = NULL;

    if (!(def = virDomainDefNew()))
        goto cleanup;

    /* Initialize defaults. */
    def->virtType = VIR_DOMAIN_VIRT_BHYVE;
    if (virUUIDGenerate(def->uuid) < 0) {
        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                       _("Failed to generate uuid"));
        virDomainDefFree(def);
        def = NULL;
        goto cleanup;
    }
    def->id = -1;
    def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;

    if (bhyveCommandLineToArgv(nativeConfig,
                               &loader_argc, &loader_argv,
                               &bhyve_argc, &bhyve_argv)) {
        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                       _("Failed to convert the command string to argv-lists"));
        goto error;
    }

    if (bhyveParseBhyveCommandLine(def, xmlopt, caps, bhyve_argc, bhyve_argv))
        goto error;
    if (loader_argv && STREQ(loader_argv[0], "/usr/sbin/bhyveload")) {
        if (bhyveParseBhyveLoadCommandLine(def, loader_argc, loader_argv))
            goto error;
    } else if (loader_argv) {
        if (bhyveParseCustomLoaderCommandLine(def, loader_argc, loader_argv))
            goto error;
    }

 cleanup:
    virStringFreeList(loader_argv);
    virStringFreeList(bhyve_argv);
    return def;
 error:
    virDomainDefFree(def);
    def = NULL;
    goto cleanup;
}
开发者ID:eskultety,项目名称:libvirt,代码行数:53,代码来源:bhyve_parse_command.c

示例3: lightosDomainDefineXML

static virDomainPtr
lightosDomainDefineXML(virConnectPtr conn,const char * xml)
{
    lightosConnPtr privconn = conn->privateData;
    virDomainPtr dom = NULL;
    virDomainDefPtr def = NULL;
    virDomainDefPtr oldDef = NULL;
    virDomainObjPtr vm = NULL;

    if((def = virDomainDefParseString(xml,privconn->caps,privconn->xmlopt,
                                    1<<VIR_DOMAIN_VIRT_LIGHTOS,
                                     VIR_DOMAIN_XML_INACTIVE)) == NULL)
    {
        goto cleanup;
    }

    if(!(vm = virDomainObjListAdd(privconn->domains,def,privconn->xmlopt,
                                0,&olddef)))
        goto cleanup;

    def = NULL;
    vm->persistent = 1;

    dom = virGetDomain(conn,vm->def->name,vm->def->uuid);
    if(dom)
        dom->id = vm->def->id;
    if(virDomainSaveConfig(LIGHTOS_CONFIG_DIR,vm->def)<0)
        goto cleanup;

cleanup:
    virDomainDefFree(def);
    virObjectUnlock(vm);

    return dom;
}
开发者ID:lzjqsdd,项目名称:lightos,代码行数:35,代码来源:lightos_driver.c

示例4: xenParseXL

virDomainDefPtr
xenParseXL(virConfPtr conf, virCapsPtr caps, int xendConfigVersion)
{
    virDomainDefPtr def = NULL;

    if (!(def = virDomainDefNew()))
        return NULL;

    def->virtType = VIR_DOMAIN_VIRT_XEN;
    def->id = -1;

    if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0)
        goto cleanup;

    if (xenParseXLOS(conf, def, caps) < 0)
        goto cleanup;

    if (xenParseXLDisk(conf, def) < 0)
        goto cleanup;

    if (xenParseXLSpice(conf, def) < 0)
        goto cleanup;

    if (xenParseXLInputDevs(conf, def) < 0)
        goto cleanup;

    return def;

 cleanup:
    virDomainDefFree(def);
    return NULL;
}
开发者ID:AGSaidi,项目名称:hacked-libvirt,代码行数:32,代码来源:xen_xl.c

示例5: libxlDomainMigrationPrepareDef

virDomainDefPtr
libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver,
                               const char *dom_xml,
                               const char *dname)
{
    libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
    virDomainDefPtr def;
    char *name = NULL;

    if (!dom_xml) {
        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                       _("no domain XML passed"));
        return NULL;
    }

    if (!(def = virDomainDefParseString(dom_xml, cfg->caps, driver->xmlopt,
                                        1 << VIR_DOMAIN_VIRT_XEN,
                                        VIR_DOMAIN_XML_INACTIVE)))
        goto cleanup;

    if (dname) {
        name = def->name;
        if (VIR_STRDUP(def->name, dname) < 0) {
            virDomainDefFree(def);
            def = NULL;
        }
    }

 cleanup:
    virObjectUnref(cfg);
    VIR_FREE(name);
    return def;
}
开发者ID:aurex-linux,项目名称:libvirt,代码行数:33,代码来源:libxl_migration.c

示例6: testCompareXMLToXMLFiles

static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
{
    char *inXmlData = NULL;
    char *outXmlData = NULL;
    char *actual = NULL;
    int ret = -1;
    virDomainDefPtr def = NULL;

    if (virtTestLoadFile(inxml, &inXmlData) < 0)
        goto fail;
    if (virtTestLoadFile(outxml, &outXmlData) < 0)
        goto fail;

    if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt,
                                        QEMU_EXPECTED_VIRT_TYPES,
                                        live ? 0 : VIR_DOMAIN_XML_INACTIVE)))
        goto fail;

    if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
        goto fail;

    if (STRNEQ(outXmlData, actual)) {
        virtTestDifference(stderr, outXmlData, actual);
        goto fail;
    }

    ret = 0;
 fail:
    VIR_FREE(inXmlData);
    VIR_FREE(outXmlData);
    VIR_FREE(actual);
    virDomainDefFree(def);
    return ret;
}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:35,代码来源:qemuxml2xmltest.c

示例7: testCompareXMLToXMLFiles

static int testCompareXMLToXMLFiles(const char *xml) {
    char xmlData[MAX_FILE];
    char *xmlPtr = &(xmlData[0]);
    char *actual = NULL;
    int ret = -1;
    virDomainDefPtr vmdef = NULL;

    if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
        goto fail;

    if (!(vmdef = virDomainDefParseString(driver.caps, xmlData,
                                          VIR_DOMAIN_XML_INACTIVE)))
        goto fail;

    if (!(actual = virDomainDefFormat(vmdef, 0)))
        goto fail;

    if (STRNEQ(xmlData, actual)) {
        virtTestDifference(stderr, xmlData, actual);
        goto fail;
    }

    ret = 0;

 fail:
    free(actual);
    virDomainDefFree(vmdef);
    return ret;
}
开发者ID:hjwsm1989,项目名称:libvirt,代码行数:29,代码来源:qemuxml2xmltest.c

示例8: testBuildDomainDef

static virDomainDefPtr
testBuildDomainDef(bool dynamic,
                   const char *label,
                   const char *baselabel)
{
    virDomainDefPtr def;
    virSecurityLabelDefPtr secdef;

    if (VIR_ALLOC(def) < 0)
        goto error;

    if (VIR_ALLOC_N(def->seclabels, 1) < 0)
        goto error;

    if (VIR_ALLOC(secdef) < 0)
        goto error;

    def->virtType = VIR_DOMAIN_VIRT_KVM;
    def->seclabels[0] = secdef;
    def->seclabels[0]->type = dynamic ? VIR_DOMAIN_SECLABEL_DYNAMIC : VIR_DOMAIN_SECLABEL_STATIC;

    if (label &&
        VIR_STRDUP(def->seclabels[0]->label, label) < 0)
        goto error;

    if (baselabel &&
        VIR_STRDUP(def->seclabels[0]->baselabel, baselabel) < 0)
        goto error;

    return def;

error:
    virDomainDefFree(def);
    return NULL;
}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:35,代码来源:securityselinuxtest.c

示例9: vmwareDomainXMLFromNative

static char *
vmwareDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
                          const char *nativeConfig,
                          unsigned int flags)
{
    struct vmware_driver *driver = conn->privateData;
    virVMXContext ctx;
    virDomainDefPtr def = NULL;
    char *xml = NULL;

    virCheckFlags(0, NULL);

    if (STRNEQ(nativeFormat, "vmware-vmx")) {
        virReportError(VIR_ERR_INVALID_ARG,
                       _("Unsupported config format '%s'"), nativeFormat);
        return NULL;
    }

    ctx.parseFileName = vmwareCopyVMXFileName;

    def = virVMXParseConfig(&ctx, driver->caps, nativeConfig);

    if (def != NULL)
        xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);

    virDomainDefFree(def);

    return xml;
}
开发者ID:bigclouds,项目名称:libvirt,代码行数:29,代码来源:vmware_driver.c

示例10: testCompareFiles

static int
testCompareFiles(const char *vmx, const char *xml)
{
    int ret = -1;
    char *vmxData = NULL;
    char *formatted = NULL;
    virDomainDefPtr def = NULL;

    if (virtTestLoadFile(vmx, &vmxData) < 0)
        goto cleanup;

    if (!(def = virVMXParseConfig(&ctx, xmlopt, vmxData)))
        goto cleanup;

    if (!virDomainDefCheckABIStability(def, def)) {
        fprintf(stderr, "ABI stability check failed on %s", vmx);
        goto cleanup;
    }

    if (!(formatted = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE)))
        goto cleanup;

    if (virtTestCompareToFile(formatted, xml) < 0)
        goto cleanup;

    ret = 0;

 cleanup:
    VIR_FREE(vmxData);
    VIR_FREE(formatted);
    virDomainDefFree(def);

    return ret;
}
开发者ID:carriercomm,项目名称:libvirt,代码行数:34,代码来源:vmx2xmltest.c

示例11: testCompareXMLToXMLFiles

static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
    char *inXmlData = NULL;
    char *outXmlData = NULL;
    char *actual = NULL;
    int ret = -1;
    virDomainDefPtr def = NULL;

    if (virtTestLoadFile(inxml, &inXmlData) < 0)
        goto fail;
    if (virtTestLoadFile(outxml, &outXmlData) < 0)
        goto fail;

    if (!(def = virDomainDefParseString(driver.caps, inXmlData,
                                          VIR_DOMAIN_XML_INACTIVE)))
        goto fail;

    if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
        goto fail;


    if (STRNEQ(outXmlData, actual)) {
        virtTestDifference(stderr, outXmlData, actual);
        goto fail;
    }

    ret = 0;
 fail:
    free(inXmlData);
    free(outXmlData);
    free(actual);
    virDomainDefFree(def);
    return ret;
}
开发者ID:hw-claudio,项目名称:libvirt,代码行数:35,代码来源:qemuxml2xmltest.c

示例12: testCompareFiles

static int
testCompareFiles(const char *xml, const char *sexpr)
{
    char *gotsexpr = NULL;
    int ret = -1;
    virDomainDefPtr def = NULL;

    if (!(def = virDomainDefParseFile(xml, caps, xmlopt, NULL,
                                      VIR_DOMAIN_DEF_PARSE_INACTIVE)))
        goto fail;

    if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
        fprintf(stderr, "ABI stability check failed on %s", xml);
        goto fail;
    }

    if (!(gotsexpr = xenFormatSxpr(NULL, def)))
        goto fail;

    if (virTestCompareToFile(gotsexpr, sexpr) < 0)
        goto fail;

    ret = 0;

 fail:
    VIR_FREE(gotsexpr);
    virDomainDefFree(def);

    return ret;
}
开发者ID:Antique,项目名称:libvirt,代码行数:30,代码来源:xml2sexprtest.c

示例13: xenParseXM

/*
 * Convert an XM config record into a virDomainDef object.
 */
virDomainDefPtr
xenParseXM(virConfPtr conf,
           virCapsPtr caps,
           virDomainXMLOptionPtr xmlopt)
{
    virDomainDefPtr def = NULL;

    if (!(def = virDomainDefNew()))
        return NULL;

    def->virtType = VIR_DOMAIN_VIRT_XEN;
    def->id = -1;

    if (xenParseConfigCommon(conf, def, caps) < 0)
        goto cleanup;

    if (xenParseXMOS(conf, def) < 0)
         goto cleanup;

    if (xenParseXMDisk(conf, def) < 0)
         goto cleanup;

    if (xenParseXMInputDevs(conf, def) < 0)
         goto cleanup;

    if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
                              xmlopt) < 0)
        goto cleanup;

    return def;

 cleanup:
    virDomainDefFree(def);
    return NULL;
}
开发者ID:eight-pack-abdominals,项目名称:libvirt,代码行数:38,代码来源:xen_xm.c

示例14: bhyveConnectDomainXMLToNative

static char *
bhyveConnectDomainXMLToNative(virConnectPtr conn,
                              const char *format,
                              const char *xmlData,
                              unsigned int flags)
{
    virBuffer buf = VIR_BUFFER_INITIALIZER;
    bhyveConnPtr privconn = conn->privateData;
    virDomainDefPtr def = NULL;
    virCommandPtr cmd = NULL, loadcmd = NULL;
    virCapsPtr caps = NULL;
    char *ret = NULL;

    virCheckFlags(0, NULL);

    if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
        goto cleanup;

    if (STRNEQ(format, BHYVE_CONFIG_FORMAT_ARGV)) {
        virReportError(VIR_ERR_INVALID_ARG,
                       _("Unsupported config type %s"), format);
        goto cleanup;
    }

    if (!(caps = bhyveDriverGetCapabilities(privconn)))
        goto cleanup;

    if (!(def = virDomainDefParseString(xmlData, caps, privconn->xmlopt,
                                  1 << VIR_DOMAIN_VIRT_BHYVE,
                                  VIR_DOMAIN_XML_INACTIVE)))
        goto cleanup;

    if (bhyveDomainAssignAddresses(def, NULL) < 0)
        goto cleanup;

    if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def)))
        goto cleanup;

    if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
        goto cleanup;

    virBufferAdd(&buf, virCommandToString(loadcmd), -1);
    virBufferAddChar(&buf, '\n');
    virBufferAdd(&buf, virCommandToString(cmd), -1);

    if (virBufferError(&buf)) {
        virReportOOMError();
        goto cleanup;
    }

    ret = virBufferContentAndReset(&buf);

 cleanup:
    virCommandFree(loadcmd);
    virCommandFree(cmd);
    virDomainDefFree(def);
    virObjectUnref(caps);
    return ret;
}
开发者ID:hitchiker42,项目名称:libvirt,代码行数:59,代码来源:bhyve_driver.c

示例15: testCompareParseXML

static int
testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
{
    char *xmlData = NULL;
    char *xmcfgData = NULL;
    char *gotxmcfgData = NULL;
    virConfPtr conf = NULL;
    int ret = -1;
    virConnectPtr conn = NULL;
    int wrote = 4096;
    struct _xenUnifiedPrivate priv;
    virDomainDefPtr def = NULL;

    if (VIR_ALLOC_N(gotxmcfgData, wrote) < 0)
        goto fail;

    conn = virGetConnect();
    if (!conn) goto fail;

    if (virtTestLoadFile(xml, &xmlData) < 0)
        goto fail;

    if (virtTestLoadFile(xmcfg, &xmcfgData) < 0)
        goto fail;

    /* Many puppies died to bring you this code. */
    priv.xendConfigVersion = xendConfigVersion;
    priv.caps = caps;
    conn->privateData = &priv;

    if (!(def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_XEN,
                                        VIR_DOMAIN_XML_INACTIVE)))
        goto fail;

    if (!(conf = xenFormatXM(conn, def, xendConfigVersion)))
        goto fail;

    if (virConfWriteMem(gotxmcfgData, &wrote, conf) < 0)
        goto fail;
    gotxmcfgData[wrote] = '\0';

    if (STRNEQ(xmcfgData, gotxmcfgData)) {
        virtTestDifference(stderr, xmcfgData, gotxmcfgData);
        goto fail;
    }

    ret = 0;

 fail:
    free(xmlData);
    free(xmcfgData);
    free(gotxmcfgData);
    if (conf)
        virConfFree(conf);
    virDomainDefFree(def);
    virUnrefConnect(conn);

    return ret;
}
开发者ID:ansisatteka,项目名称:libvirt-ovs,代码行数:59,代码来源:xmconfigtest.c


注:本文中的virDomainDefFree函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。