From nobody Sun Apr 28 21:00:09 2024 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 From nobody Sun Apr 28 21:00:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629296286664547.6687275123118; Wed, 18 Aug 2021 07:18:06 -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-315-CyurBH9NOLuG-Wvh8Ue8DQ-1; Wed, 18 Aug 2021 10:18:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 533EA100A611; Wed, 18 Aug 2021 14:17:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2BE641036D20; Wed, 18 Aug 2021 14:17:56 +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 E5FE44A7CA; Wed, 18 Aug 2021 14:17:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17IEHpSE008904 for ; Wed, 18 Aug 2021 10:17:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id E32BC2166BDE; Wed, 18 Aug 2021 14:17:50 +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 DD2292166B48 for ; Wed, 18 Aug 2021 14:17:43 +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 3DF0C101A54C for ; Wed, 18 Aug 2021 14:17:43 +0000 (UTC) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-If2fUo4JPtKXnq8AXCK5Lg-1; Wed, 18 Aug 2021 10:17:41 -0400 Received: by mail-pl1-f180.google.com with SMTP id c4so1884227plh.7 for ; Wed, 18 Aug 2021 07:17:40 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id c2sm6648717pfp.138.2021.08.18.07.17.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 07:17:39 -0700 (PDT) X-MC-Unique: CyurBH9NOLuG-Wvh8Ue8DQ-1 X-MC-Unique: If2fUo4JPtKXnq8AXCK5Lg-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=ttGqW4VcWxmXGVOaQrNNorYfNEHaMm/+rQPhKL5/JXA=; b=rmuBLttG2Cbr7RknmBPVhiuvJt11XDqzsq0FxAEgCbsRD/HrAMl95mZRkcFeO00n4y sP5JHTMo7HETHE+piEthClGgmdOfeU9aFcfbiH8hr2BVLqWR/KdvriPX3mxhhREUhpT6 5B8tWmW5LzYCkstzuN+biwhr6OdBR/7heqgJz7S9G5nC1+CS/B16mLeeJI3UScfBQfvA KtI0LSk4bSxhcRSqv3RY0roF/9vvb9wPQFfSVdEYrFsCYPs6rYVj8p3d7XusPqu648cq l642nyAnFAKWp3fcsBLryO6OgD8gC7VLCXi0YGditsSqPy/j5/HLk5XrmRc94WvZcByK hMDQ== X-Gm-Message-State: AOAM532PUPaO/58QfuJTShs/kG+K53Cfu31Ok2qG8+58fDjR0vAx0dbR fbwVTH3IFC/0EEDgkNBcTgvRnaadsiImEFs71xY= X-Google-Smtp-Source: ABdhPJy+QPBslHVRMbHYcZpOT/SeQiSGT51ah8s02QK3T74DkLImVewJs3SgzGP/NHmfAbOQRBkStw== X-Received: by 2002:a17:902:e744:b029:12d:6479:83a3 with SMTP id p4-20020a170902e744b029012d647983a3mr7422174plf.30.1629296259546; Wed, 18 Aug 2021 07:17:39 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 2/5] test_driver: Implement virDomainGetJobStats Date: Wed, 18 Aug 2021 22:17:26 +0800 Message-Id: <20210818141729.191578-3-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.78 on 10.11.54.6 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.84 on 10.5.11.22 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: 1629296288162100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 135 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 131 insertions(+), 4 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ae6422c955..9899976966 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -384,6 +384,8 @@ struct _testDomainObjPrivate { /* used by Job Info APIs */ unsigned int jobState; unsigned int jobOperation; + bool hasCompletedJob; + unsigned int jobCompleted; }; =20 =20 @@ -402,6 +404,8 @@ testDomainObjPrivateAlloc(void *opaque) =20 priv->jobState =3D VIR_DOMAIN_JOB_NONE; priv->jobOperation =3D VIR_DOMAIN_JOB_OPERATION_UNKNOWN; + priv->hasCompletedJob =3D true; + priv->jobCompleted =3D VIR_DOMAIN_JOB_OPERATION_START; =20 return priv; } @@ -2683,15 +2687,24 @@ testDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED) =20 static int testDomainGetJobInfoImpl(virDomainObj *dom, - virDomainJobInfoPtr info) + virDomainJobInfoPtr info, + bool completed) { testDomainObjPrivate *priv =3D dom->privateData; =20 memset(info, 0, sizeof(*info)); =20 - info->type =3D priv->jobState; + if (completed) { + if (priv->hasCompletedJob) { + info->type =3D VIR_DOMAIN_JOB_COMPLETED; + } else { + info->type =3D VIR_DOMAIN_JOB_NONE; + } + } else { + info->type =3D priv->jobState; + } =20 - switch (priv->jobState) { + switch (info->type) { case VIR_DOMAIN_JOB_NONE: break; =20 @@ -2755,13 +2768,126 @@ testDomainGetJobInfo(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto cleanup; =20 - ret =3D testDomainGetJobInfoImpl(vm, info); + ret =3D testDomainGetJobInfoImpl(vm, info, false); =20 cleanup: virDomainObjEndAPI(&vm); return ret; } =20 +static int +testDomainJobInfoToParams(testDomainObjPrivate *priv, + virDomainJobInfoPtr info, + int *type, + bool completed, + virTypedParameterPtr *params, + int *nparams) +{ + virTypedParameterPtr par =3D NULL; + int maxpar =3D 0; + int npar =3D 0; + unsigned int operation =3D VIR_DOMAIN_JOB_OPERATION_UNKNOWN; + + if (completed) { + operation =3D priv->jobCompleted; + } else { + operation =3D priv->jobOperation; + } + + if (virTypedParamsAddInt(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_OPERATION, + operation) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_DATA_TOTAL, + info->dataTotal) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_DATA_PROCESSED, + info->dataProcessed) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_DATA_REMAINING, + info->dataRemaining) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_TIME_ELAPSED, + info->timeElapsed) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_TIME_REMAINING, + info->timeRemaining) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_MEMORY_TOTAL, + info->memTotal) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_MEMORY_PROCESSED, + info->memProcessed) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_MEMORY_REMAINING, + info->memRemaining) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_DISK_TOTAL, + info->fileTotal) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_DISK_PROCESSED, + info->fileProcessed) < 0 || + virTypedParamsAddULLong(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_DISK_REMAINING, + info->fileRemaining) < 0) + goto error; + + *type =3D info->type; + *params =3D par; + *nparams =3D npar; + return 0; + + error: + virTypedParamsFree(par, npar); + return -1; +} + +static int +testDomainGetJobStats(virDomainPtr domain, + int *type, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + virDomainJobInfo jobInfo; + virDomainObj *dom; + testDomainObjPrivate *priv; + bool completed =3D flags & VIR_DOMAIN_JOB_STATS_COMPLETED; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_JOB_STATS_COMPLETED | + VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED, -1); + + if (!(dom =3D testDomObjFromDomain(domain))) + return -1; + + priv =3D dom->privateData; + + if (testDomainGetJobInfoImpl(dom, &jobInfo, completed) < 0) + goto cleanup; + + if (jobInfo.type =3D=3D VIR_DOMAIN_JOB_NONE) { + *type =3D VIR_DOMAIN_JOB_NONE; + *params =3D NULL; + *nparams =3D 0; + ret =3D 0; + goto cleanup; + } + + ret =3D testDomainJobInfoToParams(priv, &jobInfo, type, + completed, params, nparams); + + if (completed && ret =3D=3D 0 && + !(flags & VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED)) { + priv->hasCompletedJob =3D false; + priv->jobCompleted =3D VIR_DOMAIN_JOB_OPERATION_UNKNOWN; + } + + cleanup: + virDomainObjEndAPI(&dom); + + return ret; +} =20 static int testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED, @@ -9665,6 +9791,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetBlockInfo =3D testDomainGetBlockInfo, /* 5.7.0 */ .domainSetLifecycleAction =3D testDomainSetLifecycleAction, /* 5.7.0 */ .domainGetJobInfo =3D testDomainGetJobInfo, /* 7.7.0 */ + .domainGetJobStats =3D testDomainGetJobStats, /* 7.7.0 */ =20 .domainSnapshotNum =3D testDomainSnapshotNum, /* 1.1.4 */ .domainSnapshotListNames =3D testDomainSnapshotListNames, /* 1.1.4 */ --=20 2.32.0 From nobody Sun Apr 28 21:00:09 2024 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 162929629066233.5733190269176; Wed, 18 Aug 2021 07:18:10 -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-214-5uF-hGK6NvmOAUnrRqzgmw-1; Wed, 18 Aug 2021 10:18:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E7B992502; Wed, 18 Aug 2021 14:17:59 +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 EFFF75C1A3; Wed, 18 Aug 2021 14:17:58 +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 B95D2182188C; Wed, 18 Aug 2021 14:17:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17IEHnGZ008888 for ; Wed, 18 Aug 2021 10:17:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2801F2077FDC; Wed, 18 Aug 2021 14:17:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22A262077FDE for ; Wed, 18 Aug 2021 14:17:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 68D5E1801386 for ; Wed, 18 Aug 2021 14:17:46 +0000 (UTC) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-1r56qy5bNM--tGm4qeoSxA-1; Wed, 18 Aug 2021 10:17:44 -0400 Received: by mail-pg1-f182.google.com with SMTP id k14so2384464pga.13 for ; Wed, 18 Aug 2021 07:17:43 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id z13sm5311950pjd.44.2021.08.18.07.17.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 07:17:42 -0700 (PDT) X-MC-Unique: 5uF-hGK6NvmOAUnrRqzgmw-1 X-MC-Unique: 1r56qy5bNM--tGm4qeoSxA-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=tlY/hZgD+O2e5/fmu+JBdH3G/XSzdRjWjJFqNixJLVc=; b=JgzdF8+KGCgWAzAs18aWjTNZk9J2wiu08XCv81d6B+P5UVh3NDaosTlDHL+CT6/5dQ 1KcWhYLdEvy0jvOi4/KVX4LLwVyCj0Ut8uCNCH5GYDkqH6fJOnSyGSEfRlEhOEZ6NVHV dDa+jtAkhiloJBXVw2TMjjEdSmpNG7H2hIZCV+CSkfZ4GBZgJQoPJohXaBcSpy10gzWd cilIA1f1I7uoSWEWyvuzL6m0bDKSs4Tr+j1bStPZS/fDqKFQcc2tW7tpcGcScES6pa4R Jne+h+2JI8hkXKl1Jvw7OAjGGklGL5w/giFIIN7c7McT4e5msn8yaiK/cUJykz+NNTSN 0x9A== X-Gm-Message-State: AOAM530j+vIBraqNL4+/OJszLdn2JdLyP2tCOroJsRUyMy9rU7XT68mU bRaHQ4JzwdyZaro3LnHQvyCOw9Ol+pyL9JMGXMA= X-Google-Smtp-Source: ABdhPJyYGg6fv8JPG9Ew1k8OaVHH383T8DsLWZDsbwGHLXUnhdgE/9KB0QNpgGyuLnJCnJzEbIgRYQ== X-Received: by 2002:a65:508a:: with SMTP id r10mr9173199pgp.96.1629296262544; Wed, 18 Aug 2021 07:17:42 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 3/5] test_driver: Implement virDomainAbortJob Date: Wed, 18 Aug 2021 22:17:27 +0800 Message-Id: <20210818141729.191578-4-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.78 on 10.11.54.4 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.16 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: 1629296292823100003 Content-Type: text/plain; charset="utf-8" As we are using jobState to store dummy job type, so just change it to VIR_DOMAIN_JOB_CANCELLED when try to abort a job. Signed-off-by: Luke Yue --- src/test/test_driver.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 9899976966..35350edda9 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2889,6 +2889,34 @@ testDomainGetJobStats(virDomainPtr domain, return ret; } =20 +static int +testDomainAbortJob(virDomainPtr dom) +{ + virDomainObj *vm; + int ret =3D -1; + testDomainObjPrivate *priv; + + if (!(vm =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) + goto cleanup; + + priv =3D vm->privateData; + + if (priv->jobState =3D=3D VIR_DOMAIN_JOB_NONE) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("no job is active on the domain")); + } else { + priv->jobState =3D VIR_DOMAIN_JOB_CANCELLED; + ret =3D 0; + } + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + static int testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED, virTypedParameterPtr *params G_GNUC_UNUSED, @@ -9792,6 +9820,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainSetLifecycleAction =3D testDomainSetLifecycleAction, /* 5.7.0 */ .domainGetJobInfo =3D testDomainGetJobInfo, /* 7.7.0 */ .domainGetJobStats =3D testDomainGetJobStats, /* 7.7.0 */ + .domainAbortJob =3D testDomainAbortJob, /* 7.7.0 */ =20 .domainSnapshotNum =3D testDomainSnapshotNum, /* 1.1.4 */ .domainSnapshotListNames =3D testDomainSnapshotListNames, /* 1.1.4 */ --=20 2.32.0 From nobody Sun Apr 28 21:00:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629296280163986.4810201989721; Wed, 18 Aug 2021 07:18:00 -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-473-AmKqAQm4PaiZcS9V7BT-aA-1; Wed, 18 Aug 2021 10:17:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9D4C100A606; Wed, 18 Aug 2021 14:17:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D0FD369A; Wed, 18 Aug 2021 14:17:50 +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 178964BB7C; Wed, 18 Aug 2021 14:17:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17IEHm8Y008885 for ; Wed, 18 Aug 2021 10:17:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id D875A21EE573; Wed, 18 Aug 2021 14:17:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0F362166B25 for ; Wed, 18 Aug 2021 14:17:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 B215E85828D for ; Wed, 18 Aug 2021 14:17:48 +0000 (UTC) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-KounW4xdN7yNzXpLDJkU6A-1; Wed, 18 Aug 2021 10:17:46 -0400 Received: by mail-pj1-f48.google.com with SMTP id nt11so2719555pjb.2 for ; Wed, 18 Aug 2021 07:17:46 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id k197sm6954419pfd.190.2021.08.18.07.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 07:17:44 -0700 (PDT) X-MC-Unique: AmKqAQm4PaiZcS9V7BT-aA-1 X-MC-Unique: KounW4xdN7yNzXpLDJkU6A-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=CtoAt0SRO05d/IWEDtAQbdV6UM8j3+pFH+F2EhdABbU=; b=FSXVMH7ZHsv9u+G0WkJnTVZld4B3xQWVB6nE+C294hN58UN4dd7LzuzRzwaiVAv3zQ 3jgsyzymtJ2nJA50sPq3bhiI1BGV2GDchMZMYxPyT6N7/xcX36QZJ+QCt2ccfcMhdJjp sQ3TWd+OAsP5r2hMoR+tSnf0rXBXSHfbDJYEv2+gjyDv2sbeDg+e95W+d12eUKEOVh4+ uCvVafqmoP4wiAEHMHqCjEd/ihKJ16T8zFj1ZgPBcvZzwPZ1IguSlO9tNg6Nn44Cbkdb EobM3jbnzQhHIPPNSrusRhXHEjFjBveldbqA1drix6SsT/D86Li2NQ/rQav+pv56cYJ5 jgrA== X-Gm-Message-State: AOAM5332x2QQfYD5O18/EkkNF1NX1C4na1SpA8+xh6LslUJ3nCJGsLts /VnORSpSC8TNfMvRdPPA46MY0ACcz3xI0Apuvps= X-Google-Smtp-Source: ABdhPJyRjafn63Iw/PfUcCFVBvNbylB5PBMy9kEIiSTsjL80JoYotWLUIoYVF24t1TqrSyXRZlAWKA== X-Received: by 2002:a17:90a:2802:: with SMTP id e2mr9776164pjd.215.1629296265351; Wed, 18 Aug 2021 07:17:45 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 4/5] test_driver: Introduce testDomainSetDummyData Date: Wed, 18 Aug 2021 22:17:28 +0800 Message-Id: <20210818141729.191578-5-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.78 on 10.11.54.6 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.11 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: 1629296281083100003 Content-Type: text/plain; charset="utf-8" We can't adjust all info of a domain in XML and it's hard to adjust some with current API coverage, so use this function to set some dummy data to specific domains, thus we can get different results in virsh tests. Currently, only domain fc5's priv->jobState and priv->jobOperation are being changed, in order to test virDomainGetJobInfo and virDomainGetJobStats (domjobinfo in virsh). Signed-off-by: Luke Yue --- src/test/test_driver.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 35350edda9..372de8ba53 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -663,6 +663,32 @@ testDomObjFromDomain(virDomainPtr domain) return vm; } =20 +/** + * We can't adjust all info of a domain in XML and it's hard to + * adjust some with current API coverage, so use this function to + * set some dummy data to specific domains, thus we can get different + * results in virshtest. + */ +static int +testDomainSetDummyData(virDomainObj *obj) +{ + virDomainDef *def; + testDomainObjPrivate *priv; + + priv =3D obj->privateData; + + if (!(def =3D virDomainObjGetOneDef(obj, VIR_DOMAIN_AFFECT_LIVE))) + return -1; + + if (STREQ(def->name, "fc5")) { + /* For testing domjobinfo */ + priv->jobState =3D VIR_DOMAIN_JOB_BOUNDED; + priv->jobOperation =3D VIR_DOMAIN_JOB_OPERATION_BACKUP; + } + + return 0; +} + static char * testDomainGenerateIfname(virDomainDef *domdef) { @@ -1055,6 +1081,9 @@ testParseDomains(testDriver *privconn, =20 testDomainObjCheckTaint(obj); =20 + if (testDomainSetDummyData(obj) < 0) + VIR_DEBUG("Failed to set dummy data"); + virDomainObjEndAPI(&obj); } =20 --=20 2.32.0 From nobody Sun Apr 28 21:00:09 2024 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 1629296282715732.8680716171219; Wed, 18 Aug 2021 07:18:02 -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-60-t0M9AQUOMDOdeiZ8zoKpEg-1; Wed, 18 Aug 2021 10:17:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69E0F801AC0; Wed, 18 Aug 2021 14:17:54 +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 4D2EC60916; Wed, 18 Aug 2021 14:17:54 +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 1171B182188B; Wed, 18 Aug 2021 14:17:54 +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 17IEHruu008916 for ; Wed, 18 Aug 2021 10:17:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1C816E5B0F; Wed, 18 Aug 2021 14:17:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17E10E5B36 for ; Wed, 18 Aug 2021 14:17:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 009AD967600 for ; Wed, 18 Aug 2021 14:17:53 +0000 (UTC) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38-38E3rtU3NM2IU-bVsuA85g-1; Wed, 18 Aug 2021 10:17:49 -0400 Received: by mail-pg1-f171.google.com with SMTP id t1so2389589pgv.3 for ; Wed, 18 Aug 2021 07:17:49 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id f5sm6121141pfe.128.2021.08.18.07.17.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 07:17:47 -0700 (PDT) X-MC-Unique: t0M9AQUOMDOdeiZ8zoKpEg-1 X-MC-Unique: 38E3rtU3NM2IU-bVsuA85g-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=K3Rs0u3dLQgVHO38wAHHosduLdbFp99YJSS9f1Ck43U=; b=HMp18AkUxuWu1XSX8yLkF2V6ck0ILIzTazPam1ZY+/VrXflzFaUT7a3UFJKfU4z252 cz/2nCl6a1xeay5Th/SAgQfSjFFChU915uu4nks+BJLs32caYYjL3S5erGe6G3iMhNxv 5BWqlHIX0WRM9siImKvrmQ6FvsYq1S0Bbm0iX0ujLL+OBM1dTI1sjBaTkwdoKHfn5cZW lofVYzJykpyrSmk8oi8kvkBh6pw408FAX8G2E2Ml3g/ghwS8lkdvS8iPtMuMUZnrljss 5NGREIXifGRgZrGonsQtgJK8AU+Hod7D62CHhtm/jLg6miLh9KwvfjGkdn++IbbDMySw uv8A== X-Gm-Message-State: AOAM5300uyPr1mcbHk9qEw89nR78DcA9iQjATVCU0ye3UnCef8t5yfHO Z2XVWH4ENm98UycDGp+jPkujCrFqDlpLTy/Q2CY= X-Google-Smtp-Source: ABdhPJyemKMCgZTUGa9FIwLKZ8baRtFxwCvH7EX+Mwcdhq8mk93HxXUBP++fDNf1BaeJbrXqgejn+Q== X-Received: by 2002:a65:6214:: with SMTP id d20mr9168862pgv.62.1629296268181; Wed, 18 Aug 2021 07:17:48 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v3 5/5] virshtest: add test for domjobinfo and domjobabort Date: Wed, 18 Aug 2021 22:17:29 +0800 Message-Id: <20210818141729.191578-6-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.13 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: 1629296283590100001 Content-Type: text/plain; charset="utf-8" In testCompareDomJobInfoByName, we should get different jobinfo for fc4 and fc5, as we set different jobinfo value for fc5 in testDomainSetDummyData. And when use "--completed --keep-completed" flags, the completed job info should be preserved, with only "--completed" flag, the completed job info should be deleted, so should get none next time. In testCompareDomJobAbortByName, domjobabort should set type to cancelled and preserve the operation. Signed-off-by: Luke Yue --- tests/virshtest.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/virshtest.c b/tests/virshtest.c index 751e8ffc49..4e2efcb69a 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -291,6 +291,87 @@ static int testCompareDomControlInfoByName(const void = *data G_GNUC_UNUSED) return testCompareOutputLit(exp, NULL, argv); } =20 +static int testCompareDomJobInfoByName(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "domjobinfo fc4;\ + domjobinfo fc5;\ + domjobinfo fc5 --completed --keep-complet= ed;\ + domjobinfo fc5 --completed;\ + domjobinfo fc5 --completed", NULL }; + const char *exp =3D "\ +Job type: None \n\ +\n\ +Job type: Bounded \n\ +Operation: Backup \n\ +Time elapsed: 4000 ms\n\ +Time remaining: 6000 ms\n\ +Data processed: 10.000 KiB\n\ +Data remaining: 20.000 KiB\n\ +Data total: 30.000 KiB\n\ +Memory processed: 1.000 MiB\n\ +Memory remaining: 2.000 MiB\n\ +Memory total: 3.000 MiB\n\ +File processed: 512.000 KiB\n\ +File remaining: 1.500 MiB\n\ +File total: 2.000 MiB\n\ +\n\ +Job type: Completed \n\ +Operation: Start \n\ +Time elapsed: 10000 ms\n\ +Data processed: 30.000 KiB\n\ +Data remaining: 0.000 B\n\ +Data total: 30.000 KiB\n\ +Memory processed: 3.000 MiB\n\ +Memory remaining: 0.000 B\n\ +Memory total: 3.000 MiB\n\ +File processed: 2.000 MiB\n\ +File remaining: 0.000 B\n\ +File total: 2.000 MiB\n\ +\n\ +Job type: Completed \n\ +Operation: Start \n\ +Time elapsed: 10000 ms\n\ +Data processed: 30.000 KiB\n\ +Data remaining: 0.000 B\n\ +Data total: 30.000 KiB\n\ +Memory processed: 3.000 MiB\n\ +Memory remaining: 0.000 B\n\ +Memory total: 3.000 MiB\n\ +File processed: 2.000 MiB\n\ +File remaining: 0.000 B\n\ +File total: 2.000 MiB\n\ +\n\ +Job type: None \n\ +\n"; + return testCompareOutputLit(exp, NULL, argv); +} + +static int testCompareDomJobAbortByName(const void *data G_GNUC_UNUSED) +{ + const char *const argv[] =3D { VIRSH_CUSTOM, "domjobinfo fc5;\ + domjobabort fc5; domjobinfo fc5", NULL }; + const char *exp =3D "\ +Job type: Bounded \n\ +Operation: Backup \n\ +Time elapsed: 4000 ms\n\ +Time remaining: 6000 ms\n\ +Data processed: 10.000 KiB\n\ +Data remaining: 20.000 KiB\n\ +Data total: 30.000 KiB\n\ +Memory processed: 1.000 MiB\n\ +Memory remaining: 2.000 MiB\n\ +Memory total: 3.000 MiB\n\ +File processed: 512.000 KiB\n\ +File remaining: 1.500 MiB\n\ +File total: 2.000 MiB\n\ +\n\ +\n\ +Job type: Cancelled \n\ +Operation: Backup \n\ +\n"; + return testCompareOutputLit(exp, NULL, argv); +} + struct testInfo { const char *const *argv; const char *result; @@ -383,6 +464,14 @@ mymain(void) testCompareDomControlInfoByName, NULL) !=3D 0) ret =3D -1; =20 + if (virTestRun("virsh domjobinfo (by name)", + testCompareDomJobInfoByName, NULL) !=3D 0) + ret =3D -1; + + if (virTestRun("virsh domjobabort (by name)", + testCompareDomJobAbortByName, NULL) !=3D 0) + ret =3D -1; + /* It's a bit awkward listing result before argument, but that's a * limitation of C99 vararg macros. */ # define DO_TEST(i, result, ...) \ --=20 2.32.0