您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ virGetLastError函数代码示例

51自学网 2021-06-03 09:42:08
  C++
这篇教程C++ virGetLastError函数代码示例写得很实用,希望能帮到您。

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

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

示例1: testStorageLookup

static inttestStorageLookup(const void *args){    const struct testLookupData *data = args;    int ret = 0;    const char *actualResult;    virStorageFileMetadataPtr actualMeta;    const char *actualParent;    /* This function is documented as giving results within chain, but     * as the same string may be duplicated into more than one field,     * we rely on STREQ rather than pointer equality.  Test twice to     * ensure optional parameters don't cause NULL deref.  */    actualResult = virStorageFileChainLookup(data->chain, data->name,                   NULL, NULL);    if (!data->expResult) {        if (!virGetLastError()) {            fprintf(stderr, "call should have failed/n");            ret = -1;        }        virResetLastError();    } else {        if (virGetLastError()) {            fprintf(stderr, "call should not have warned/n");            ret = -1;        }    }    if (STRNEQ_NULLABLE(data->expResult, actualResult)) {        fprintf(stderr, "result 1: expected %s, got %s/n",                NULLSTR(data->expResult), NULLSTR(actualResult));        ret = -1;    }    actualResult = virStorageFileChainLookup(data->chain, data->name,                   &actualMeta, &actualParent);    if (!data->expResult)        virResetLastError();    if (STRNEQ_NULLABLE(data->expResult, actualResult)) {        fprintf(stderr, "result 2: expected %s, got %s/n",                NULLSTR(data->expResult), NULLSTR(actualResult));        ret = -1;    }    if (data->expMeta != actualMeta) {        fprintf(stderr, "meta: expected %p, got %p/n",                data->expMeta, actualMeta);        ret = -1;    }    if (STRNEQ_NULLABLE(data->expParent, actualParent)) {        fprintf(stderr, "parent: expected %s, got %s/n",                NULLSTR(data->expParent), NULLSTR(actualParent));        ret = -1;    }    return ret;}
开发者ID:vikhyath,项目名称:libvirt-hyperv-r2-2012,代码行数:57,


示例2: qemuDomainReAttachHostdevDevices

void qemuDomainReAttachHostdevDevices(struct qemud_driver *driver,                                      const char *name,                                      virDomainHostdevDefPtr *hostdevs,                                      int nhostdevs){    pciDeviceList *pcidevs;    int i;    if (!(pcidevs = qemuGetActivePciHostDeviceList(driver,                                                   hostdevs,                                                   nhostdevs))) {        virErrorPtr err = virGetLastError();        VIR_ERROR(_("Failed to allocate pciDeviceList: %s"),                  err ? err->message : _("unknown error"));        virResetError(err);        return;    }    /* Again 3 loops; mark all devices as inactive before reset     * them and reset all the devices before re-attach */    for (i = 0; i < pciDeviceListCount(pcidevs); i++) {        pciDevice *dev = pciDeviceListGet(pcidevs, i);        pciDevice *activeDev = NULL;        /* Never delete the dev from list driver->activePciHostdevs         * if it's used by other domain.         */        activeDev = pciDeviceListFind(driver->activePciHostdevs, dev);        if (activeDev &&            STRNEQ_NULLABLE(name, pciDeviceGetUsedBy(activeDev))) {            pciDeviceListSteal(pcidevs, dev);            continue;        }        /* pciDeviceListFree() will take care of freeing the dev. */        pciDeviceListSteal(driver->activePciHostdevs, dev);    }    for (i = 0; i < pciDeviceListCount(pcidevs); i++) {        pciDevice *dev = pciDeviceListGet(pcidevs, i);        if (pciResetDevice(dev, driver->activePciHostdevs,                           driver->inactivePciHostdevs) < 0) {            virErrorPtr err = virGetLastError();            VIR_ERROR(_("Failed to reset PCI device: %s"),                      err ? err->message : _("unknown error"));            virResetError(err);        }    }    for (i = 0; i < pciDeviceListCount(pcidevs); i++) {        pciDevice *dev = pciDeviceListGet(pcidevs, i);        qemuReattachPciDevice(dev, driver);    }    pciDeviceListFree(pcidevs);}
开发者ID:ansisatteka,项目名称:libvirt-ovs,代码行数:56,


示例3: testCompareFiles

static inttestCompareFiles(const char *vmx, const char *xml){    int result = -1;    char *vmxData = NULL;    char *xmlData = NULL;    char *formatted = NULL;    virDomainDefPtr def = NULL;    virErrorPtr err = NULL;    if (virtTestLoadFile(vmx, &vmxData) < 0) {        goto failure;    }    if (virtTestLoadFile(xml, &xmlData) < 0) {        goto failure;    }    def = virVMXParseConfig(&ctx, xmlopt, vmxData);    if (def == NULL) {        err = virGetLastError();        fprintf(stderr, "ERROR: %s/n", err != NULL ? err->message : "<unknown>");        goto failure;    }    formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE);    if (formatted == NULL) {        err = virGetLastError();        fprintf(stderr, "ERROR: %s/n", err != NULL ? err->message : "<unknown>");        goto failure;    }    if (STRNEQ(xmlData, formatted)) {        virtTestDifference(stderr, xmlData, formatted);        goto failure;    }    result = 0;  failure:    VIR_FREE(vmxData);    VIR_FREE(xmlData);    VIR_FREE(formatted);    virDomainDefFree(def);    return result;}
开发者ID:kawamuray,项目名称:libvirt,代码行数:49,


示例4: mymain

static intmymain(void){    int ret = 0;    if (!(mgr = virSecurityManagerNew("selinux", "QEMU", false, true, false))) {        virErrorPtr err = virGetLastError();        if (err->code == VIR_ERR_CONFIG_UNSUPPORTED)            exit(EXIT_AM_SKIP);        fprintf(stderr, "Unable to initialize security driver: %s/n",                err->message);        exit(EXIT_FAILURE);    }    if ((caps = testQemuCapsInit()) == NULL)        exit(EXIT_FAILURE);#define DO_TEST_LABELING(name) /    if (virtTestRun("Labelling " # name, 1, testSELinuxLabeling, name) < 0) /        ret = -1;                                                       /    setcon((security_context_t)"system_r:system_u:libvirtd_t:s0:c0.c1023");    DO_TEST_LABELING("disks");    DO_TEST_LABELING("kernel");    DO_TEST_LABELING("chardev");    return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;}
开发者ID:bigclouds,项目名称:libvirt,代码行数:30,


示例5: qemuReattachPciDevice

void qemuReattachPciDevice(pciDevice *dev, struct qemud_driver *driver){    int retries = 100;    /* If the device is not managed and was attached to guest     * successfully, it must have been inactive.     */    if (!pciDeviceGetManaged(dev)) {        if (pciDeviceListAdd(driver->inactivePciHostdevs, dev) < 0)            pciFreeDevice(dev);        return;    }    while (pciWaitForDeviceCleanup(dev, "kvm_assigned_device")           && retries) {        usleep(100*1000);        retries--;    }    if (pciReAttachDevice(dev, driver->activePciHostdevs,                          driver->inactivePciHostdevs) < 0) {        virErrorPtr err = virGetLastError();        VIR_ERROR(_("Failed to re-attach PCI device: %s"),                  err ? err->message : _("unknown error"));        virResetError(err);    }    pciFreeDevice(dev);}
开发者ID:mithleshvrts,项目名称:libvirt-0.10.2,代码行数:28,


示例6: virshDomainState

/* --------------- * Misc utils * --------------- */intvirshDomainState(vshControl *ctl, virDomainPtr dom, int *reason){    virDomainInfo info;    virshControlPtr priv = ctl->privData;    if (reason)        *reason = -1;    if (!priv->useGetInfo) {        int state;        if (virDomainGetState(dom, &state, reason, 0) < 0) {            virErrorPtr err = virGetLastError();            if (err && err->code == VIR_ERR_NO_SUPPORT)                priv->useGetInfo = true;            else                return -1;        } else {            return state;        }    }    /* fall back to virDomainGetInfo if virDomainGetState is not supported */    if (virDomainGetInfo(dom, &info) < 0)        return -1;    else        return info.state;}
开发者ID:carriercomm,项目名称:libvirt,代码行数:32,


示例7: virConsoleShutdown

static voidvirConsoleShutdown(virConsolePtr con){    virErrorPtr err = virGetLastError();    if (con->error.code == VIR_ERR_OK && err)        virCopyLastError(&con->error);    if (con->st) {        virStreamEventRemoveCallback(con->st);        virStreamAbort(con->st);        virStreamFree(con->st);        con->st = NULL;    }    VIR_FREE(con->streamToTerminal.data);    VIR_FREE(con->terminalToStream.data);    if (con->stdinWatch != -1)        virEventRemoveHandle(con->stdinWatch);    if (con->stdoutWatch != -1)        virEventRemoveHandle(con->stdoutWatch);    con->stdinWatch = -1;    con->stdoutWatch = -1;    if (!con->quit) {        con->quit = true;        virCondSignal(&con->cond);    }}
开发者ID:libvirt,项目名称:libvirt,代码行数:27,


示例8: virLXCProcessAutostartDomain

static intvirLXCProcessAutostartDomain(virDomainObjPtr vm,                             void *opaque){    const struct virLXCProcessAutostartData *data = opaque;    int ret = 0;    virObjectLock(vm);    if (vm->autostart &&        !virDomainObjIsActive(vm)) {        ret = virLXCProcessStart(data->conn, data->driver, vm,                                 0, NULL, false,                                 VIR_DOMAIN_RUNNING_BOOTED);        virDomainAuditStart(vm, "booted", ret >= 0);        if (ret < 0) {            virErrorPtr err = virGetLastError();            VIR_ERROR(_("Failed to autostart VM '%s': %s"),                      vm->def->name,                      err ? err->message : "");        } else {            virObjectEventPtr event =                virDomainEventLifecycleNewFromObj(vm,                                         VIR_DOMAIN_EVENT_STARTED,                                         VIR_DOMAIN_EVENT_STARTED_BOOTED);            if (event)                virObjectEventStateQueue(data->driver->domainEventState, event);        }    }    virObjectUnlock(vm);    return ret;}
开发者ID:i-ninth,项目名称:libvirt,代码行数:31,


示例9: virNetMessageSaveError

void virNetMessageSaveError(virNetMessageErrorPtr rerr){    /* This func may be called several times & the first     * error is the one we want because we don't want     * cleanup code overwriting the first one.     */    if (rerr->code != VIR_ERR_OK)        return;    memset(rerr, 0, sizeof(*rerr));    virErrorPtr verr = virGetLastError();    if (verr) {        rerr->code = verr->code;        rerr->domain = verr->domain;        if (verr->message && VIR_ALLOC(rerr->message) == 0)            *rerr->message = strdup(verr->message);        rerr->level = verr->level;        if (verr->str1 && VIR_ALLOC(rerr->str1) == 0)            *rerr->str1 = strdup(verr->str1);        if (verr->str2 && VIR_ALLOC(rerr->str2) == 0)            *rerr->str2 = strdup(verr->str2);        if (verr->str3 && VIR_ALLOC(rerr->str3) == 0)            *rerr->str3 = strdup(verr->str3);        rerr->int1 = verr->int1;        rerr->int2 = verr->int2;    } else {        rerr->code = VIR_ERR_INTERNAL_ERROR;        rerr->domain = VIR_FROM_RPC;        if (VIR_ALLOC(rerr->message) == 0)            *rerr->message = strdup(_("Library function returned error but did not set virError"));        rerr->level = VIR_ERR_ERROR;    }}
开发者ID:emaste,项目名称:libvirt,代码行数:33,


示例10: testTypedParamsValidate

static inttestTypedParamsValidate(const void *opaque){    int rv;    TypedParameterTest *test = (TypedParameterTest *)opaque;    virErrorPtr errptr;    rv = virTypedParamsValidate(            test->params, test->nparams,            "foobar", VIR_TYPED_PARAM_STRING | test->foobar_flags,            "foo", VIR_TYPED_PARAM_INT,            "bar", VIR_TYPED_PARAM_UINT,            NULL);    if (test->expected_errcode) {        errptr = virGetLastError();        rv = (errptr == NULL) || ((rv < 0) &&                                  !(errptr->code == test->expected_errcode));        if (errptr && test->expected_errmessage) {            rv = STRNEQ(test->expected_errmessage, errptr->message);            if (rv)                printf("%s/n", errptr->message);        }    }    return rv;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:28,


示例11: get_domain_xml

static xmlDocPtrget_domain_xml (guestfs_h *g, virDomainPtr dom){  virErrorPtr err;  xmlDocPtr doc;  CLEANUP_FREE char *xml = virDomainGetXMLDesc (dom, 0);  if (!xml) {    err = virGetLastError ();    error (g, _("error reading libvirt XML information: %s"), err->message);    return NULL;  }  debug (g, "original domain XML:/n%s", xml);  /* Parse the domain XML into an XML document. */  doc = xmlReadMemory (xml, strlen (xml),                       NULL, NULL, XML_PARSE_NONET);  if (doc == NULL) {    error (g, _("unable to parse XML information returned by libvirt"));    return NULL;  }  return doc;}
开发者ID:rbuj,项目名称:libguestfs,代码行数:25,


示例12: virLXCProcessMonitorInitNotify

static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED,                                           pid_t initpid,                                           virDomainObjPtr vm){    virLXCDriverPtr driver = lxc_driver;    virLXCDomainObjPrivatePtr priv;    virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);    ino_t inode;    virObjectLock(vm);    priv = vm->privateData;    priv->initpid = initpid;    if (virLXCProcessGetNsInode(initpid, "pid", &inode) < 0) {        virErrorPtr err = virGetLastError();        VIR_WARN("Cannot obtain pid NS inode for %llu: %s",                 (unsigned long long)initpid,                 err && err->message ? err->message : "<unknown>");        virResetLastError();        inode = 0;    }    virDomainAuditInit(vm, initpid, inode);    if (virDomainSaveStatus(lxc_driver->xmlopt, cfg->stateDir, vm) < 0)        VIR_WARN("Cannot update XML with PID for LXC %s", vm->def->name);    virObjectUnlock(vm);    virObjectUnref(cfg);}
开发者ID:i-ninth,项目名称:libvirt,代码行数:30,


示例13: virGetLastError

void StoragePoolControlThread::sendGlobalErrors(){    virtErrors = virGetLastError();    if ( virtErrors!=NULL && virtErrors->code>0 )        emit errorMsg( QString("VirtError(%1) : %2").arg(virtErrors->code)                       .arg(QString().fromUtf8(virtErrors->message)) );    virResetLastError();}
开发者ID:benklop,项目名称:qt-virt-manager,代码行数:8,


示例14: ruby_libvirt_raise_error_if

void ruby_libvirt_raise_error_if(const int condition, VALUE error,                                 const char *method, virConnectPtr conn){    VALUE ruby_errinfo;    virErrorPtr err;    char *msg;    int rc;    struct rb_exc_new2_arg arg;    int exception = 0;    if (!condition) {        return;    }    if (conn == NULL) {        err = virGetLastError();    }    else {        err = virConnGetLastError(conn);    }    if (err != NULL && err->message != NULL) {        rc = asprintf(&msg, "Call to %s failed: %s", method, err->message);    }    else {        rc = asprintf(&msg, "Call to %s failed", method);    }    if (rc < 0) {        /* there's not a whole lot we can do here; try to raise an         * out-of-memory message */        rb_memerror();    }    arg.error = error;    arg.msg = msg;    ruby_errinfo = rb_protect(ruby_libvirt_exc_new2_wrap, (VALUE)&arg,                              &exception);    free(msg);    if (exception) {        rb_jump_tag(exception);    }    rb_iv_set(ruby_errinfo, "@libvirt_function_name", rb_str_new2(method));    if (err != NULL) {        rb_iv_set(ruby_errinfo, "@libvirt_code", INT2NUM(err->code));        rb_iv_set(ruby_errinfo, "@libvirt_component", INT2NUM(err->domain));        rb_iv_set(ruby_errinfo, "@libvirt_level", INT2NUM(err->level));        if (err->message != NULL) {            rb_iv_set(ruby_errinfo, "@libvirt_message",                      rb_str_new2(err->message));        }    }    rb_exc_raise(ruby_errinfo);};
开发者ID:agx,项目名称:ruby-libvirt,代码行数:57,


示例15: virGetLastError

void VM_Viewer::sendGlobalErrors(){    virtErrors = virGetLastError();    if ( virtErrors!=NULL && virtErrors->code>0 ) {        QString msg = QString("VirtError(%1) : %2").arg(virtErrors->code)                .arg(QString().fromUtf8(virtErrors->message));        emit errorMsg( msg );    };    virResetLastError();}
开发者ID:Dravigon,项目名称:qt-virt-manager,代码行数:10,


示例16: testSELinuxGenLabel

static inttestSELinuxGenLabel(const void *opaque){    const struct testSELinuxGenLabelData *data = opaque;    int ret = -1;    virDomainDefPtr def;    context_t con = NULL;    context_t imgcon = NULL;    if (setcon_raw((security_context_t)data->pidcon) < 0) {        perror("Cannot set process security context");        return -1;    }    if (!(def = testBuildDomainDef(data->dynamic,                                   data->label,                                   data->baselabel)))        goto cleanup;    if (virSecurityManagerGenLabel(data->mgr, def) < 0) {        virErrorPtr err = virGetLastError();        fprintf(stderr, "Cannot generate label: %s/n", err->message);        goto cleanup;    }    VIR_DEBUG("label=%s imagelabel=%s",              def->seclabels[0]->label, def->seclabels[0]->imagelabel);    if (!(con = context_new(def->seclabels[0]->label)))        goto cleanup;    if (!(imgcon = context_new(def->seclabels[0]->imagelabel)))        goto cleanup;    if (!testSELinuxCheckCon(con,                             data->user, data->role, data->type,                             data->sensMin, data->sensMax,                             data->catMin, data->catMax))        goto cleanup;    if (!testSELinuxCheckCon(imgcon,                             data->user, data->imagerole, data->imagetype,                             data->sensMin, data->sensMax,                             data->catMin, data->catMax))        goto cleanup;    ret = 0;cleanup:    context_free(con);    context_free(imgcon);    virDomainDefFree(def);    return ret;}
开发者ID:hzguanqiang,项目名称:libvirt,代码行数:53,


示例17: virGetLastError

QString _VirtThread::sendGlobalErrors(){    QString msg;    virtErrors = virGetLastError();    if ( virtErrors!=nullptr && virtErrors->code>0 ) {        msg = QString("VirtError(%1) : %2").arg(virtErrors->code)                .arg(QString().fromUtf8(virtErrors->message));        emit errorMsg( msg, number );    };    virResetLastError();    return msg;}
开发者ID:cheliequan,项目名称:qt-virt-manager,代码行数:12,


示例18: virErrorPreserveLast

/** * virErrorPreserveLast: * @saveerr: pointer to virErrorPtr for storing last error object * * Preserves the currently set last error (for the thread) into @saveerr so that * it can be restored via virErrorRestore(). @saveerr must be passed to * virErrorRestore() */voidvirErrorPreserveLast(virErrorPtr *saveerr){    int saved_errno = errno;    virErrorPtr lasterr = virGetLastError();    *saveerr = NULL;    if (lasterr)        *saveerr = virErrorCopyNew(lasterr);    errno = saved_errno;}
开发者ID:libvirt,项目名称:libvirt,代码行数:21,


示例19: virLXCDomainObjPrivateXMLParse

static int virLXCDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data){    virLXCDomainObjPrivatePtr priv = data;    unsigned long long thepid;    if (virXPathULongLong("string(./init[1]/@pid)", ctxt, &thepid) < 0) {        virErrorPtr err = virGetLastError();        VIR_WARN("Failed to load init pid from state %s", err ? err->message : "null");        priv->initpid = 0;    } else {        priv->initpid = thepid;    }    return 0;}
开发者ID:avdv,项目名称:libvirt,代码行数:15,


示例20: testTLSContextInit

/* * This tests sanity checking of our own certificates * * This code is done when libvirtd starts up, or before * a libvirt client connects. The test is ensuring that * the creation of virNetTLSContextPtr fails if we * give bogus certs, or succeeds for good certs */static int testTLSContextInit(const void *opaque){    struct testTLSContextData *data = (struct testTLSContextData *)opaque;    virNetTLSContextPtr ctxt = NULL;    int ret = -1;    if (data->isServer) {        ctxt = virNetTLSContextNewServer(data->cacrt,                                         NULL,                                         data->crt,                                         KEYFILE,                                         NULL,                                         true,                                         true);    } else {        ctxt = virNetTLSContextNewClient(data->cacrt,                                         NULL,                                         data->crt,                                         KEYFILE,                                         true,                                         true);    }    if (ctxt) {        if (data->expectFail) {            VIR_WARN("Expected failure %s against %s",                     data->cacrt, data->crt);            goto cleanup;        }    } else {        virErrorPtr err = virGetLastError();        if (!data->expectFail) {            VIR_WARN("Unexpected failure %s against %s",                     data->cacrt, data->crt);            goto cleanup;        }        VIR_DEBUG("Got error %s", err ? err->message : "<unknown>");    }    ret = 0;cleanup:    virObjectUnref(ctxt);    return ret;}
开发者ID:cardoe,项目名称:libvirt,代码行数:53,


示例21: testCompareXMLToXMLFiles

static inttestCompareXMLToXMLFiles(const char *inxml, const char *outxml,                         bool expect_error){    char *inXmlData = NULL;    char *outXmlData = NULL;    char *actual = NULL;    int ret = -1;    virNWFilterDefPtr dev = NULL;    if (virtTestLoadFile(inxml, &inXmlData) < 0)        goto fail;    if (virtTestLoadFile(outxml, &outXmlData) < 0)        goto fail;    virResetLastError();    if (!(dev = virNWFilterDefParseString(NULL, inXmlData)))        goto fail;    if (!!virGetLastError() != expect_error)        goto fail;    if (expect_error) {        /* need to suppress the errors */        virResetLastError();    }    if (!(actual = virNWFilterDefFormat(dev)))        goto fail;    if (STRNEQ(outXmlData, actual)) {        virtTestDifference(stderr, outXmlData, actual);        goto fail;    }    ret = 0; fail:    VIR_FREE(inXmlData);    VIR_FREE(outXmlData);    VIR_FREE(actual);    virNWFilterDefFree(dev);    return ret;}
开发者ID:danwent,项目名称:libvirt-ovs,代码行数:45,


示例22: set_root_priv

void VirshType::Connect(){	priv_state priv = set_root_priv();	if ( m_libvirt_connection )	{		virConnectClose( m_libvirt_connection );	}    m_libvirt_connection = virConnectOpen( m_sessionID.c_str() );    set_priv(priv);  	if( m_libvirt_connection == NULL )    {		virErrorPtr err = virGetLastError();		EXCEPT("Failed to create libvirt connection: %s", (err ? err->message : "No reason found"));    }}
开发者ID:emaste,项目名称:htcondor,代码行数:18,


示例23: testSELinuxLabeling

static inttestSELinuxLabeling(const void *opaque){    const char *testname = opaque;    int ret = -1;    testSELinuxFile *files = NULL;    size_t nfiles = 0;    size_t i;    virDomainDefPtr def = NULL;    if (testSELinuxLoadFileList(testname, &files, &nfiles) < 0)        goto cleanup;    if (testSELinuxCreateDisks(files, nfiles) < 0)        goto cleanup;    if (!(def = testSELinuxLoadDef(testname)))        goto cleanup;    if (virSecurityManagerSetAllLabel(mgr, def, NULL) < 0)        goto cleanup;    if (testSELinuxCheckLabels(files, nfiles) < 0)        goto cleanup;    ret = 0; cleanup:    if (testSELinuxDeleteDisks(files, nfiles) < 0)        VIR_WARN("unable to fully clean up");    virDomainDefFree(def);    for (i = 0; i < nfiles; i++) {        VIR_FREE(files[i].file);        VIR_FREE(files[i].context);    }    VIR_FREE(files);    if (ret < 0) {        virErrorPtr err = virGetLastError();        VIR_TEST_VERBOSE("%s/n", err ? err->message : "<unknown>");    }    return ret;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:43,


示例24: bhyveAutostartDomain

static intbhyveAutostartDomain(virDomainObjPtr vm, void *opaque){    const struct bhyveAutostartData *data = opaque;    int ret = 0;    virObjectLock(vm);    if (vm->autostart && !virDomainObjIsActive(vm)) {        virResetLastError();        ret = virBhyveProcessStart(data->conn, data->driver, vm,                                   VIR_DOMAIN_RUNNING_BOOTED, 0);        if (ret < 0) {            virErrorPtr err = virGetLastError();            VIR_ERROR(_("Failed to autostart VM '%s': %s"),                      vm->def->name, err ? err->message : _("unknown error"));        }    }    virObjectUnlock(vm);    return ret;}
开发者ID:hitchiker42,项目名称:libvirt,代码行数:19,


示例25: mymain

static intmymain(void){    int ret = 0;    char *filedata = NULL;    char *filename = NULL;    size_t i;    size_t *params = NULL;    if (virAsprintf(&filename, "%s/../daemon/libvirtd.conf",                    abs_srcdir) < 0) {        perror("Format filename");        return EXIT_FAILURE;    }    if (virFileReadAll(filename, 1024*1024, &filedata) < 0) {        virErrorPtr err = virGetLastError();        fprintf(stderr, "Cannot load %s for testing: %s", filename, err->message);        ret = -1;        goto cleanup;    }    if (uncomment_all_params(filedata, &params) < 0) {        perror("Find params");        ret = -1;        goto cleanup;    }    VIR_DEBUG("Initial config [%s]", filedata);    for (i = 0; params[i] != 0; i++) {        const struct testCorruptData data = { params, filedata, filename, i };        /* Skip now ignored config param */        if (STRPREFIX(filedata + params[i], "log_buffer_size"))            continue;        if (virtTestRun("Test corruption", testCorrupt, &data) < 0)            ret = -1;    }cleanup:    VIR_FREE(filename);    VIR_FREE(filedata);    VIR_FREE(params);    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;}
开发者ID:6WIND,项目名称:libvirt,代码行数:43,


示例26: mymain

static intmymain(void){    int ret = 0;    int rc = testUserXattrEnabled();    if (rc < 0)        return EXIT_FAILURE;    if (!rc)        return EXIT_AM_SKIP;    if (!(mgr = virSecurityManagerNew("selinux", "QEMU",                                      VIR_SECURITY_MANAGER_DEFAULT_CONFINED |                                      VIR_SECURITY_MANAGER_PRIVILEGED))) {        virErrorPtr err = virGetLastError();        VIR_TEST_VERBOSE("Unable to initialize security driver: %s/n",                err->message);        return EXIT_FAILURE;    }    if ((caps = testQemuCapsInit()) == NULL)        return EXIT_FAILURE;    if (qemuTestDriverInit(&driver) < 0)        return EXIT_FAILURE;#define DO_TEST_LABELING(name)                                           /    if (virtTestRun("Labelling " # name, testSELinuxLabeling, name) < 0) /        ret = -1;    setcon((security_context_t)"system_r:system_u:libvirtd_t:s0:c0.c1023");    DO_TEST_LABELING("disks");    DO_TEST_LABELING("kernel");    DO_TEST_LABELING("chardev");    DO_TEST_LABELING("nfs");    qemuTestDriverFree(&driver);    return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;}
开发者ID:FrankYu,项目名称:libvirt,代码行数:41,


示例27: virLockManagerLockDaemonSetupLockspace

static int virLockManagerLockDaemonSetupLockspace(const char *path){    virNetClientPtr client;    virNetClientProgramPtr program = NULL;    virLockSpaceProtocolCreateLockSpaceArgs args;    int rv = -1;    int counter = 0;    memset(&args, 0, sizeof(args));    args.path = (char*)path;    if (!(client = virLockManagerLockDaemonConnectionNew(getuid() == 0, &program)))        return -1;    if (virNetClientProgramCall(program,                                client,                                counter++,                                VIR_LOCK_SPACE_PROTOCOL_PROC_CREATE_LOCKSPACE,                                0, NULL, NULL, NULL,                                (xdrproc_t)xdr_virLockSpaceProtocolCreateLockSpaceArgs, (char*)&args,                                (xdrproc_t)xdr_void, NULL) < 0) {        virErrorPtr err = virGetLastError();        if (err && err->code == VIR_ERR_OPERATION_INVALID) {            /* The lockspace already exists */            virResetLastError();            rv = 0;        } else {            goto cleanup;        }    }    rv = 0;cleanup:    virObjectUnref(program);    virNetClientClose(client);    virObjectUnref(client);    return rv;}
开发者ID:avdv,项目名称:libvirt,代码行数:39,



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


C++ virJSONValueFree函数代码示例
C++ virFileExists函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。