From nobody Fri May 3 21:00:03 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 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 From nobody Fri May 3 21:00:03 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 1629112504480195.78995122828724; Mon, 16 Aug 2021 04:15:04 -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-72-7e0_Yv3WMwmqKMfmbHVnoA-1; Mon, 16 Aug 2021 07:14:01 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6AC14800EB8; Mon, 16 Aug 2021 11:13:54 +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 4363F60CCC; Mon, 16 Aug 2021 11:13: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 0C8044A7CD; Mon, 16 Aug 2021 11:13:54 +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 17GBDqqW020879 for ; Mon, 16 Aug 2021 07:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4FB6F2157F56; Mon, 16 Aug 2021 11:13:52 +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 492D121602B4 for ; Mon, 16 Aug 2021 11:13:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 E0232101A529 for ; Mon, 16 Aug 2021 11:13:50 +0000 (UTC) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-cr1T8AXgMwinZ-z5Enlrdw-1; Mon, 16 Aug 2021 07:13:48 -0400 Received: by mail-pj1-f51.google.com with SMTP id cp15-20020a17090afb8fb029017891959dcbso31772098pjb.2 for ; Mon, 16 Aug 2021 04:13:48 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id g19sm10868785pfc.168.2021.08.16.04.13.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 04:13:47 -0700 (PDT) X-MC-Unique: 7e0_Yv3WMwmqKMfmbHVnoA-1 X-MC-Unique: cr1T8AXgMwinZ-z5Enlrdw-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=SzWIXyM+pFn+9FF6Vv/O8+N4LLO7fUwUHraJAvyuc2Y=; b=e1e+bCp0i85sSOyuKoNLVih+8+XkYJ4B9TON8VwxNX6SuQbOaJ46Y8aPj1gG6mCjml 4h8/g8ngFOiOdnjDBibNizpOExHXwBZdXIhMFAxIx4jXWdtqkiiwBq+etR4/HhA7svRA 9D16A9fpDLYUXHLgdLp16Uwo67sXsHnepQTzBlClFZVXFEg3m9rfxbHXkBuxzzx+oAfm R5Rg2Mm6rRgpudONoEgD6mxhT8mP6g1rESw65qxIzlkt/7zbFfGcte1V+eG9bHRkj5VS fJqr6OQeaAtrB0kuA4JxHOQCD1pK2AZ7+/fJQAC9B8mguBgOzC6qJuBMR+E4OkfKShZT n8Ew== X-Gm-Message-State: AOAM533NlGRhbYiWPUtnSZMlusVIng9xqq8NnGPg24Y6NQfQpXiSQrdn mytT3+yR6Z3jOS1awF457BTXJ10HlVJvWZDdKyc= X-Google-Smtp-Source: ABdhPJxo7luXo8yoyKdcYj+UYmdfQ/Y58LdIJzlhbbCbY7VvfU98YyfumgQjnnToJ+0O7frommp+Kw== X-Received: by 2002:a17:90a:8909:: with SMTP id u9mr16815253pjn.9.1629112427507; Mon, 16 Aug 2021 04:13:47 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 2/4] test_driver: Implement virDomainGetJobStats Date: Mon, 16 Aug 2021 19:13:35 +0800 Message-Id: <20210816111337.112671-3-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.12 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: 1629112506415100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/test/test_driver.c | 105 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 9306f0e104..93aeec7105 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2769,6 +2769,110 @@ testDomainGetJobInfo(virDomainPtr dom, return ret; } =20 +static int +testDomainJobInfoToParams(testDomainObjPrivate *priv, + virDomainJobInfoPtr info, + int *type, + virTypedParameterPtr *params, + int *nparams) +{ + virTypedParameterPtr par =3D NULL; + int maxpar =3D 0; + int npar =3D 0; + + if (virTypedParamsAddInt(&par, &npar, &maxpar, + VIR_DOMAIN_JOB_OPERATION, + priv->jobOperation) < 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) < 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, params, nparam= s); + + if (completed && ret =3D=3D 0 && + !(flags & VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED)) { + priv->jobState =3D VIR_DOMAIN_JOB_NONE; + priv->jobOperation =3D VIR_DOMAIN_JOB_OPERATION_UNKNOWN; + } + + cleanup: + virDomainObjEndAPI(&dom); + + return ret; +} =20 static int testDomainGetLaunchSecurityInfo(virDomainPtr domain G_GNUC_UNUSED, @@ -9672,6 +9776,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 Fri May 3 21:00:03 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 1629112505723562.4237152396903; Mon, 16 Aug 2021 04:15: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-582-9UTGAs3ePi658xCsHuZlSg-1; Mon, 16 Aug 2021 07:14:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6AEE187D548; Mon, 16 Aug 2021 11:14:02 +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 452D919C59; Mon, 16 Aug 2021 11:14:02 +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 022F8181A12D; Mon, 16 Aug 2021 11:14:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17GBE0AN020919 for ; Mon, 16 Aug 2021 07:14:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F54310FFE72; Mon, 16 Aug 2021 11:14:00 +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 1A83C1005B78 for ; Mon, 16 Aug 2021 11:13:54 +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 AC7DC866DF5 for ; Mon, 16 Aug 2021 11:13:54 +0000 (UTC) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-TDJ3CS7kNB-bpC7kwLKVgg-1; Mon, 16 Aug 2021 07:13:52 -0400 Received: by mail-pl1-f177.google.com with SMTP id n12so19652746plf.4 for ; Mon, 16 Aug 2021 04:13:52 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id m23sm9195301pjr.38.2021.08.16.04.13.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 04:13:50 -0700 (PDT) X-MC-Unique: 9UTGAs3ePi658xCsHuZlSg-1 X-MC-Unique: TDJ3CS7kNB-bpC7kwLKVgg-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=fZqaVz01Bb1Gp7gTyXwkadGzux7y3bVsQQtOE3KyIg8=; b=TgCF0A03OPZL+SyR5mxLrapGXQ8PJAOVW2URn1z4ag1KCJcqpDa0JXJrSiEpuK3R+w jo2EZYpALueEiCOFbxl13fbKd8/oeN6oqt8K/8ABJl8MWO7pEpkDJHlHbNz+EczZpgBJ BMCWf68zHxdJHI7m9/FLK6NmDi6FCcnaQnFdQ0vIgZeGJxVPBMic/89wpbqoi5LN8q0t T6klYZlYn2qbeqB/hqIDCKZsOSHBHvBhXCLxWLTbDNIY26vN97k5XqenhFjeNULBqSFT sO6OfmQmBruQBUuRlo3kHW9pW4vH+kiS8dcurJH9nbTYtpXRIQcIcjqTMQjOrN8FY3n7 fErA== X-Gm-Message-State: AOAM5302H2/icCsJ2yfbjvQqMhqnDtZsmhER6Yet00ST7K9aO6CDYU8P xq4RpHiQ2Hz8F785bKRMBEsE/cWbM5muZkQm43I= X-Google-Smtp-Source: ABdhPJxnVFMDEgBGjxKTj4LxFNwgGFZjtQGNElprZKTt9VJfYHO9BefL07WGrNhBWAPq5AX9rQQL9w== X-Received: by 2002:a65:6149:: with SMTP id o9mr15564749pgv.422.1629112430949; Mon, 16 Aug 2021 04:13:50 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 3/4] test_driver: Implement virDomainAbortJob Date: Mon, 16 Aug 2021 19:13:36 +0800 Message-Id: <20210816111337.112671-4-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.3 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.23 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: 1629112506762100002 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 Reviewed-by: Martin Kletzander --- 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 93aeec7105..5043c57fe2 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2874,6 +2874,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, @@ -9777,6 +9805,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 Fri May 3 21:00:03 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 1629112446841651.5218872310506; Mon, 16 Aug 2021 04:14: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-584-nJax7iYmMFOvSrb0bwoA-g-1; Mon, 16 Aug 2021 07:14:04 -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 ADCE687D547; Mon, 16 Aug 2021 11:13:59 +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 90C9F60853; Mon, 16 Aug 2021 11:13:59 +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 32CF04A700; Mon, 16 Aug 2021 11:13:59 +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 17GBDvK9020903 for ; Mon, 16 Aug 2021 07:13:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A0D4200BCBC; Mon, 16 Aug 2021 11:13:57 +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 155892022EC4 for ; Mon, 16 Aug 2021 11:13:57 +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 F2864866DF1 for ; Mon, 16 Aug 2021 11:13:56 +0000 (UTC) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-308-C55Xrfc_OnWZephlcVv6mA-1; Mon, 16 Aug 2021 07:13:54 -0400 Received: by mail-pj1-f45.google.com with SMTP id u13-20020a17090abb0db0290177e1d9b3f7so31793342pjr.1 for ; Mon, 16 Aug 2021 04:13:54 -0700 (PDT) Received: from localhost ([103.138.53.99]) by smtp.gmail.com with ESMTPSA id b18sm11118547pfi.199.2021.08.16.04.13.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Aug 2021 04:13:53 -0700 (PDT) X-MC-Unique: nJax7iYmMFOvSrb0bwoA-g-1 X-MC-Unique: C55Xrfc_OnWZephlcVv6mA-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=TwOvYJClj1nDujuqborhkSBWzXWjU6dJC5TmvtzRcrM=; b=Io69sml3zgcAYm+vqQlZtd/ARQpv+xnU+bLk3xa7PWi0kxgO2PcoSHWMmKZHP8weQN yW1QD6jOGLNzgV0HVpFiXOWGT0nEazDYZtNQWCyV+q8/dAWzCpFsJQSuZEflosuBIorR d4iilMqhQa22JQ9ZZ0ykKNJX5OMgKMjV8YTNmjKKWQaQNPER6kLxtpFTwrrSzP0pC6/G i2HRt6dAEBpsW/KABw7WLUkThK+kyws4E1b8fjOqoQ1j59pXJ12yUeID27WH5NXi9Cq7 vUw9GxlhIP+236/3Gd6InTyX4zQVswLDT86XnQEkCi27A4fGyvrG1JZJf+pX69gfesbU R/Tw== X-Gm-Message-State: AOAM531L4GA5RC/i6jmmlV/XLlNhGe/uP4C/tp64SNx6x84kEh3w+jlr e1ZhF7g7lDifN9RrFw+M81qzw2qMLNQGa2XhTwQ= X-Google-Smtp-Source: ABdhPJxxSCYw7LzJZtRF9CxGvMbzZTNI1Np27DBqlGV+3TH0rKmx33blogAyqG3GZAxPoDamgi411Q== X-Received: by 2002:a63:5902:: with SMTP id n2mr13486967pgb.305.1629112433464; Mon, 16 Aug 2021 04:13:53 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 4/4] virshtest: add test for domjobinfo Date: Mon, 16 Aug 2021 19:13:37 +0800 Message-Id: <20210816111337.112671-5-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.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.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: 1629112448169100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- tests/virshtest.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/virshtest.c b/tests/virshtest.c index 53db2aa19a..0c46496c74 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -291,6 +291,13 @@ 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", NULL= }; + const char *exp =3D "Job type: None \n\n"; + return testCompareOutputLit(exp, NULL, argv); +} + struct testInfo { const char *const *argv; const char *result; @@ -383,6 +390,10 @@ mymain(void) testCompareDomControlInfoByName, NULL) !=3D 0) ret =3D -1; =20 + if (virTestRun("virsh domjobinfo (by name)", + testCompareDomJobInfoByName, 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