コード例 #1
0
ファイル: lxc_process.c プロジェクト: bigclouds/libvirt
static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon,
                                          virDomainObjPtr vm)
{
    virLXCDriverPtr driver = lxc_driver;
    virDomainEventPtr event = NULL;
    virLXCDomainObjPrivatePtr priv;

    VIR_DEBUG("mon=%p vm=%p", mon, vm);

    lxcDriverLock(driver);
    virObjectLock(vm);
    lxcDriverUnlock(driver);

    priv = vm->privateData;
    virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
    if (!priv->wantReboot) {
        virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
        if (!priv->doneStopEvent) {
            event = virDomainEventNewFromObj(vm,
                                             VIR_DOMAIN_EVENT_STOPPED,
                                             priv->stopReason);
            virDomainAuditStop(vm, "shutdown");
        } else {
            VIR_DEBUG("Stop event has already been sent");
        }
        if (!vm->persistent) {
            virDomainObjListRemove(driver->domains, vm);
            vm = NULL;
        }
    } else {
        int ret = virLXCProcessReboot(driver, vm);
        virDomainAuditStop(vm, "reboot");
        virDomainAuditStart(vm, "reboot", ret == 0);
        if (ret == 0) {
            event = virDomainEventRebootNewFromObj(vm);
        } else {
            event = virDomainEventNewFromObj(vm,
                                             VIR_DOMAIN_EVENT_STOPPED,
                                             priv->stopReason);
            if (!vm->persistent) {
                virDomainObjListRemove(driver->domains, vm);
                vm = NULL;
            }
        }
    }

    if (vm)
        virObjectUnlock(vm);
    if (event) {
        lxcDriverLock(driver);
        virDomainEventStateQueue(driver->domainEventState, event);
        lxcDriverUnlock(driver);
    }
}
コード例 #2
0
ファイル: lxc_conf.c プロジェクト: Archer-sys/libvirt
virLXCDriverConfigPtr virLXCDriverGetConfig(virLXCDriverPtr driver)
{
    virLXCDriverConfigPtr cfg;
    lxcDriverLock(driver);
    cfg = virObjectRef(driver->config);
    lxcDriverUnlock(driver);
    return cfg;
}
コード例 #3
0
ファイル: lxc_conf.c プロジェクト: Archer-sys/libvirt
/**
 * virLXCDriverGetCapabilities:
 *
 * Get a reference to the virCapsPtr instance for the
 * driver. If @refresh is true, the capabilities will be
 * rebuilt first
 *
 * The caller must release the reference with virObjetUnref
 *
 * Returns: a reference to a virCapsPtr instance or NULL
 */
virCapsPtr virLXCDriverGetCapabilities(virLXCDriverPtr driver,
                                       bool refresh)
{
    virCapsPtr ret;
    if (refresh) {
        virCapsPtr caps = NULL;
        if ((caps = virLXCDriverCapsInit(driver)) == NULL)
            return NULL;

        lxcDriverLock(driver);
        virObjectUnref(driver->caps);
        driver->caps = caps;
    } else {
        lxcDriverLock(driver);
    }

    ret = virObjectRef(driver->caps);
    lxcDriverUnlock(driver);
    return ret;
}
コード例 #4
0
ファイル: lxc_process.c プロジェクト: bigclouds/libvirt
void
virLXCProcessAutostartAll(virLXCDriverPtr driver)
{
    /* XXX: Figure out a better way todo this. The domain
     * startup code needs a connection handle in order
     * to lookup the bridge associated with a virtual
     * network
     */
    virConnectPtr conn = virConnectOpen("lxc:///");
    /* Ignoring NULL conn which is mostly harmless here */

    struct virLXCProcessAutostartData data = { driver, conn };

    lxcDriverLock(driver);
    virDomainObjListForEach(driver->domains,
                            virLXCProcessAutostartDomain,
                            &data);
    lxcDriverUnlock(driver);

    if (conn)
        virConnectClose(conn);
}