コード例 #1
0
ファイル: virportallocator.c プロジェクト: Antique/libvirt
static int
virPortAllocatorOnceInit(void)
{
    if (!VIR_CLASS_NEW(virPortAllocator, virClassForObjectLockable()))
        return -1;

    if (!(virPortAllocatorInstance = virPortAllocatorNew()))
        return -1;

    return 0;
}
コード例 #2
0
# else

#  include "virutil.h"
#  include "virerror.h"
#  include "viralloc.h"
#  include "virlog.h"
#  include "virportallocator.h"
#  include "virstring.h"

#  define VIR_FROM_THIS VIR_FROM_RPC

VIR_LOG_INIT("tests.portallocatortest");

static int testAllocAll(const void *args ATTRIBUTE_UNUSED)
{
    virPortAllocatorPtr alloc = virPortAllocatorNew("test", 5900, 5909, 0);
    int ret = -1;
    unsigned short p1, p2, p3, p4, p5, p6, p7;

    if (!alloc)
        return -1;

    if (virPortAllocatorAcquire(alloc, &p1) < 0)
        goto cleanup;
    if (p1 != 5901) {
        VIR_TEST_DEBUG("Expected 5901, got %d", p1);
        goto cleanup;
    }

    if (virPortAllocatorAcquire(alloc, &p2) < 0)
        goto cleanup;