From nobody Sat Feb 7 08:44:03 2026 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 1629112445168840.0925021536735; Mon, 16 Aug 2021 04:14:05 -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-555-p-MP5iLlP0WLP1hSr2PnuA-1; Mon, 16 Aug 2021 07:14:03 -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 915D687D542; Mon, 16 Aug 2021 11:13:57 +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 735F660853; Mon, 16 Aug 2021 11:13:57 +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 3B135181A0F8; Mon, 16 Aug 2021 11:13:57 +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 17GBDqk6020880 for ; Mon, 16 Aug 2021 07:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52D312157F58; Mon, 16 Aug 2021 11:13:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B351215CDD1 for ; Mon, 16 Aug 2021 11:13:48 +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 D6E878007BB for ; Mon, 16 Aug 2021 11:13:48 +0000 (UTC) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-dhm1h0zzMTW4yaflmUxFSQ-1; Mon, 16 Aug 2021 07:13:46 -0400 Received: by mail-pj1-f54.google.com with SMTP id cp15-20020a17090afb8fb029017891959dcbso31771929pjb.2 for ; Mon, 16 Aug 2021 04:13:45 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id z13sm9092092pjd.44.2021.08.16.04.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 04:13:44 -0700 (PDT) X-MC-Unique: p-MP5iLlP0WLP1hSr2PnuA-1 X-MC-Unique: dhm1h0zzMTW4yaflmUxFSQ-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=ybbeXlu3K32AZh9owP81iqsqMeelaRD6lqAIQ+Vd2js=; b=Q7n2L+lvtNEbTSc//obCV6Z2txfjhNLNYL6kk/rOtEwTaL1h6Cp+iAZcz3MQ1lKA6H R/HQYB8Ccg/nA7fIE1GgaCgLDihQkAcbGGIShahqvXW9rJgJTn9oSoNzcWNIkKkbhONH SzHS229Lcgf7FFx3MnJxz+GeBruXUukix3g1UFRLJEsaswLgDD081IdTjP+MbattQ3Jz kuuj6FzRarFZzouLdRamaWsw8egN52qqija7NNEHcTdJF3BBE3m8y55Sp8reOt4VxXrV Z0uQBIZUxdB1aNoIEc3JqRzShhFEgZn4GSC3fxo8uCdbGmLiu8KIZxXY6MYFaqrmznBk wR3w== X-Gm-Message-State: AOAM5333LFXUXEZ2xuCJ6QlC8xSF7azIhuYgWAl0eM4jGQqkillIajYh 925Lho2YTUFeyTDqRIw/4VsZQk/CeXDi2Qy5/Q8= X-Google-Smtp-Source: ABdhPJwmXkUg1LhwhpyS7pcFGkoh2axzRETpn2pbaV4qFQ5jqF6lal2lN8Qi2GKgJp9ulOaB19ohRg== X-Received: by 2002:a63:496:: with SMTP id 144mr15487719pge.353.1629112424591; Mon, 16 Aug 2021 04:13:44 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 1/4] test_driver: Implement virDomainGetJobInfo Date: Mon, 16 Aug 2021 19:13:34 +0800 Message-Id: <20210816111337.112671-2-lukedyue@gmail.com> In-Reply-To: <20210816111337.112671-1-lukedyue@gmail.com> References: <20210816111337.112671-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.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: 1629112447897100001 Content-Type: text/plain; charset="utf-8" priv-jobState is used to store dummy job type, and priv->jobOperation is used to store dummy job operation, they are initialized to VIR_DOMAIN_JOB_NONE and VIR_DOMAIN_JOB_OPERATION_UNKNOWN, we can just change them in other job related APIs as there is no real job in test driver. Signed-off-by: Luke Yue Reviewed-by: Martin Kletzander --- 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 00cc13511a..9306f0e104 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 @@ -2681,6 +2688,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, @@ -9583,6 +9671,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