From nobody Sat Feb 7 10:15:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629296271873118.0704275233536; Wed, 18 Aug 2021 07:17:51 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-198--QAs9AoYMD6mkFZaEvWoQA-1; Wed, 18 Aug 2021 10:17:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BA3F87D549; Wed, 18 Aug 2021 14:17:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 611435D9DE; Wed, 18 Aug 2021 14:17:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 090441821888; Wed, 18 Aug 2021 14:17:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17IEHfWC008858 for ; Wed, 18 Aug 2021 10:17:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0D775E5B35; Wed, 18 Aug 2021 14:17:41 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07C0BE5B16 for ; Wed, 18 Aug 2021 14:17:40 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8F1E106655A for ; Wed, 18 Aug 2021 14:17:40 +0000 (UTC) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-lLXJEGMlPmyA6yri9ST1qA-1; Wed, 18 Aug 2021 10:17:38 -0400 Received: by mail-pg1-f178.google.com with SMTP id y23so2381253pgi.7 for ; Wed, 18 Aug 2021 07:17:37 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id u10sm4628881pfg.168.2021.08.18.07.17.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 07:17:36 -0700 (PDT) X-MC-Unique: -QAs9AoYMD6mkFZaEvWoQA-1 X-MC-Unique: lLXJEGMlPmyA6yri9ST1qA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G2rpW0KW4mJNlsfw8ZmzjQvPNLw865jyAaLDrLcayhA=; b=i2j3VAUdMYMoLLiNw0oOfP5t2knrd/wwuRLWBMSLfqIgd413L2GhmBbEfhd5f9MwFr 3pnCyYVE1Caiog12VNVRJEA+Ap4Bj19xQeYsYMwZy7kAQGvh0BkYjyIfLycCZHH1zcoY 77318B67DCyLuyjJziLHlbS4zqH4eGk5pVoz7XtPCbCQS0vSpPxeBoZWUV1jbyl6Rbe3 uCYCoMBJ4R6hoC7VGYZchSnbWokab6TTrSY2kITX1/CsKINaNmI69GbWABd1cAXl5x/1 D3NENEcPMowQ2xiISEfqgoGQbzXFYUDl7LS2XEtTq6jv/xoWXxtYI1vy1LMk+1tgYlUa 71JQ== X-Gm-Message-State: AOAM5315NYJGngaD3uhGQOAnhiaObF36HPL5+vlIWtjtnXylImlyi1ta YQlx2/P02otAeDjVtDuGi59VVSfwMYetvRHStu4= X-Google-Smtp-Source: ABdhPJyZyTlPx4/2MzurYdpzAs3PuLw9aaulgODslRB3rDbgML0GCFOTaUu5OMaIUQXXrCIU77hzcQ== X-Received: by 2002:a62:e308:0:b0:3e1:4077:4fbd with SMTP id g8-20020a62e308000000b003e140774fbdmr9667631pfh.51.1629296256622; Wed, 18 Aug 2021 07:17:36 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 1/5] test_driver: Implement virDomainGetJobInfo Date: Wed, 18 Aug 2021 22:17:25 +0800 Message-Id: <20210818141729.191578-2-lukedyue@gmail.com> In-Reply-To: <20210818141729.191578-1-lukedyue@gmail.com> References: <20210818141729.191578-1-lukedyue@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1629296274261100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 89 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index b096d49ac6..ae6422c955 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -380,6 +380,10 @@ struct _testDomainObjPrivate { /* used by get/set time APIs */ long long seconds; unsigned int nseconds; + + /* used by Job Info APIs */ + unsigned int jobState; + unsigned int jobOperation; }; =20 =20 @@ -396,6 +400,9 @@ testDomainObjPrivateAlloc(void *opaque) priv->seconds =3D 627319920; priv->nseconds =3D 0; =20 + priv->jobState =3D VIR_DOMAIN_JOB_NONE; + priv->jobOperation =3D VIR_DOMAIN_JOB_OPERATION_UNKNOWN; + return priv; } =20 @@ -2674,6 +2681,87 @@ testDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED) return ret; } =20 +static int +testDomainGetJobInfoImpl(virDomainObj *dom, + virDomainJobInfoPtr info) +{ + testDomainObjPrivate *priv =3D dom->privateData; + + memset(info, 0, sizeof(*info)); + + info->type =3D priv->jobState; + + switch (priv->jobState) { + case VIR_DOMAIN_JOB_NONE: + break; + + case VIR_DOMAIN_JOB_BOUNDED: + info->dataTotal =3D 30 * 1024; + info->dataProcessed =3D 10 * 1024; + info->dataRemaining =3D 20 * 1024; + info->timeRemaining =3D 6000; + info->timeElapsed =3D 4000; + info->memTotal =3D 3 * 1024 * 1024; + info->memProcessed =3D 1024 * 1024; + info->memRemaining =3D 2 * 1024 * 1024; + info->fileTotal =3D 2 * 1024 * 1024; + info->fileProcessed =3D 1024 * 1024 / 2; + info->fileRemaining =3D 3 * 1024 * 1024 / 2; + break; + + case VIR_DOMAIN_JOB_UNBOUNDED: + info->dataTotal =3D 30 * 1024; + info->dataProcessed =3D 10 * 1024; + info->dataRemaining =3D 20 * 1024; + info->timeElapsed =3D 4000; + info->memTotal =3D 3 * 1024 * 1024; + info->memProcessed =3D 1024 * 1024; + info->memRemaining =3D 2 * 1024 * 1024; + info->fileTotal =3D 2 * 1024 * 1024; + info->fileProcessed =3D 1024 * 1024 / 2; + info->fileRemaining =3D 3 * 1024 * 1024 / 2; + break; + + case VIR_DOMAIN_JOB_COMPLETED: + info->timeElapsed =3D 10000; + info->dataTotal =3D 30 * 1024; + info->dataProcessed =3D 30 * 1024; + info->memTotal =3D 3 * 1024 * 1024; + info->memProcessed =3D 3 * 1024 * 1024; + info->fileTotal =3D 2 * 1024 * 1024; + info->fileProcessed =3D 2 * 1024 * 1024; + break; + + case VIR_DOMAIN_JOB_FAILED: + break; + + case VIR_DOMAIN_JOB_CANCELLED: + break; + } + + return 0; +} + +static int +testDomainGetJobInfo(virDomainPtr dom, + virDomainJobInfoPtr info) +{ + virDomainObj *vm; + int ret =3D -1; + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) + goto cleanup; + + ret =3D testDomainGetJobInfoImpl(vm, info); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + =20 static int testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED, @@ -9576,6 +9664,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainMemoryPeek =3D testDomainMemoryPeek, /* 5.4.0 */ .domainGetBlockInfo =3D testDomainGetBlockInfo, /* 5.7.0 */ .domainSetLifecycleAction =3D testDomainSetLifecycleAction, /* 5.7.0 */ + .domainGetJobInfo =3D testDomainGetJobInfo, /* 7.7.0 */ =20 .domainSnapshotNum =3D testDomainSnapshotNum, /* 1.1.4 */ .domainSnapshotListNames =3D testDomainSnapshotListNames, /* 1.1.4 */ --=20 2.32.0