From nobody Sat May 4 17:14:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561752100; cv=none; d=zoho.com; s=zohoarc; b=kFoPwYuiqAb47aeRovB7y9BWodxDKK8NPPJ6d48ZJOCZt3r+/F1yucMHVinWkhe04HUHfk/4LLn8EYHN61wstIZehRcCn3lD50SAcrDXvgfonB7msqNHMjzcMwzGijWSTWrzeroDxf2jSalzQZcFLEHxTzbKOixH+tzbm0R+BP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561752100; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=qkNmTCo7IlS6g5WOHfVLE9SS45iFW/8r8XaKMiYGGvQ=; b=UAS9F2Tj12znUeKuQoX5I8FbbYbqWRnhFRe5MVUfESEwzNVNcnb2ueXGHtnCRadLdnHc8XbJpwJ+AHONhWLUedP76Mz17ixH9Gc+prjJC9Och6HmBAol/jXf7l3x9y5BKqc6B6rtrTWQ99tVox6YoFd6ZzHpV12r1nN4SzqH3RM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1561752100890970.4092862184642; Fri, 28 Jun 2019 13:01:40 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id E565690C87; Fri, 28 Jun 2019 20:01:37 +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 AC6D160BE0; Fri, 28 Jun 2019 20:01:35 +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 4B7BD1806B16; Fri, 28 Jun 2019 20:01:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5SK1VTY004465 for ; Fri, 28 Jun 2019 16:01:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id E579B6013A; Fri, 28 Jun 2019 20:01:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0A566012D for ; Fri, 28 Jun 2019 20:01:29 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A3062E95B0 for ; Fri, 28 Jun 2019 20:01:23 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id x17so7445310wrl.9 for ; Fri, 28 Jun 2019 13:01:23 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id v12sm2126343wrr.41.2019.06.28.13.01.20 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 13:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CNdY3iS8XHQ4HeFNmyiWcf+KtztTT4g5z55UYTNaLDo=; b=iP8+bRU1kx0U6LirJKmO0xxtFOEX6gbFm2WihhMFYou5SeUyVifzRw8tFmhOgHs194 EnOAv8tNu+m+zMFhfu9XlGwvMkSa9GSf3HLVr6dDweqhBIk7VT9Y15vmpYbgp6bJNOuR FpOdNjB6Z0qTi737VqDcYK/SWtyJFW4WMCaFUZfysgsBFnFjt761VZuI27Kb7JpCWqqQ MnpXH9zjvWwgwXTh5lPuKgMwBQ8i0fovgdaRcCJpvy/VA0UENcG0955sT5g6nEzhdbEk MkttPa0x/HyS/I4R1hZ4U1VbWakI2b3jjm+2L2+ucvjoU46O66g8PcbeM2cJyB+E96iU ELqA== 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:mime-version :content-transfer-encoding; bh=CNdY3iS8XHQ4HeFNmyiWcf+KtztTT4g5z55UYTNaLDo=; b=ilvSPq07sVz2dkTRMo1hwhwMuxXfWTBF57w3TotNMzUF/LgYbZpVSWNIp6tdzVOCdP IfvrRNnP/Jjj0O7IIqdsygbx4uIFxybIqMl8cWaGiG4WpEwm4dGFrWZZzbTDUk7IbWCr g0aK7QJpQADCO9NSVneStvn2QFzk/eHBlMQb5Ue/R2yC/1TRCl9rmUIh0xIu0jYwBJXa hIdeHj+Ofqb1Nr8KwZotxHvsomwTiI7OuaT7gKkTEPZL4ZLh6CN0A5Lm1fto+6L83nU3 TUxoBO+X4fL5zQRYoFxlpPQEz5G0Ju+tmkB74tX3ezA4cy7jJyHTEsqNn8/KldCCUGFU Jo/A== X-Gm-Message-State: APjAAAUVhG2NMqFccAvRSPk63MvI0a8FmdxFwk3tG5S5isZkTnvJf/8Z HoyXQhyA6/bVPd2dGSckloNv51BAXy7jYw== X-Google-Smtp-Source: APXvYqyZbLxQQYscO2U+YycGDfxfJ673BR6RYNEYyIpfzMy5fOrkQyYH0JXV9rEHf9CCvQ7lE8t1bg== X-Received: by 2002:adf:ff84:: with SMTP id j4mr8704705wrr.71.1561752081396; Fri, 28 Jun 2019 13:01:21 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Fri, 28 Jun 2019 22:01:04 +0200 Message-Id: <20190628200103.6919-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Jun 2019 20:01:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Jun 2019 20:01:23 +0000 (UTC) for IP:'209.85.221.65' DOMAIN:'mail-wr1-f65.google.com' HELO:'mail-wr1-f65.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.109 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.221.65 mail-wr1-f65.google.com 209.85.221.65 mail-wr1-f65.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] test_driver: implement virDomainGetInterfaceParameters 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 28 Jun 2019 20:01:38 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis --- The only thing changed since v1 is calling virDomainObjGetOneDef to get the appropriate def pointer. src/test/test_driver.c | 104 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4b1f2724a0..dd756ed8bd 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1964,6 +1964,109 @@ static int testDomainGetInfo(virDomainPtr domain, return ret; } + +static int +testDomainGetInterfaceParameters(virDomainPtr dom, + const char *device, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) +{ + size_t i; + virDomainObjPtr vm =3D NULL; + virDomainDefPtr def =3D NULL; + virDomainNetDefPtr net =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG | + VIR_TYPED_PARAM_STRING_OKAY, -1); + + if ((*nparams) =3D=3D 0) { + *nparams =3D 7; + return 0; + } + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (!(def =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + if (!(net =3D virDomainNetFind(def, device))) + goto cleanup; + + for (i =3D 0; i < *nparams && i < 7; i++) { + switch (i) { + case 0: /* inbound.average */ + if (virTypedParameterAssign(¶ms[i], + VIR_DOMAIN_BANDWIDTH_IN_AVERAGE, + VIR_TYPED_PARAM_UINT, 0) < 0) + goto cleanup; + if (net->bandwidth && net->bandwidth->in) + params[i].value.ui =3D net->bandwidth->in->average; + break; + case 1: /* inbound.peak */ + if (virTypedParameterAssign(¶ms[i], + VIR_DOMAIN_BANDWIDTH_IN_PEAK, + VIR_TYPED_PARAM_UINT, 0) < 0) + goto cleanup; + if (net->bandwidth && net->bandwidth->in) + params[i].value.ui =3D net->bandwidth->in->peak; + break; + case 2: /* inbound.burst */ + if (virTypedParameterAssign(¶ms[i], + VIR_DOMAIN_BANDWIDTH_IN_BURST, + VIR_TYPED_PARAM_UINT, 0) < 0) + goto cleanup; + if (net->bandwidth && net->bandwidth->in) + params[i].value.ui =3D net->bandwidth->in->burst; + break; + case 3: /* inbound.floor */ + if (virTypedParameterAssign(¶ms[i], + VIR_DOMAIN_BANDWIDTH_IN_FLOOR, + VIR_TYPED_PARAM_UINT, 0) < 0) + goto cleanup; + if (net->bandwidth && net->bandwidth->in) + params[i].value.ui =3D net->bandwidth->in->floor; + break; + case 4: /* outbound.average */ + if (virTypedParameterAssign(¶ms[i], + VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE, + VIR_TYPED_PARAM_UINT, 0) < 0) + goto cleanup; + if (net->bandwidth && net->bandwidth->out) + params[i].value.ui =3D net->bandwidth->out->average; + break; + case 5: /* outbound.peak */ + if (virTypedParameterAssign(¶ms[i], + VIR_DOMAIN_BANDWIDTH_OUT_PEAK, + VIR_TYPED_PARAM_UINT, 0) < 0) + goto cleanup; + if (net->bandwidth && net->bandwidth->out) + params[i].value.ui =3D net->bandwidth->out->peak; + break; + case 6: /* outbound.burst */ + if (virTypedParameterAssign(¶ms[i], + VIR_DOMAIN_BANDWIDTH_OUT_BURST, + VIR_TYPED_PARAM_UINT, 0) < 0) + goto cleanup; + if (net->bandwidth && net->bandwidth->out) + params[i].value.ui =3D net->bandwidth->out->burst; + break; + } + } + + if (*nparams > 7) + *nparams =3D 7; + + ret =3D 0; + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static int testDomainGetState(virDomainPtr domain, int *state, @@ -7258,6 +7361,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainSetMemory =3D testDomainSetMemory, /* 0.1.4 */ .domainGetHostname =3D testDomainGetHostname, /* 5.5.0 */ .domainGetInfo =3D testDomainGetInfo, /* 0.1.1 */ + .domainGetInterfaceParameters =3D testDomainGetInterfaceParameters, /*= 5.6.0 */ .domainGetState =3D testDomainGetState, /* 0.9.2 */ .domainGetTime =3D testDomainGetTime, /* 5.4.0 */ .domainSave =3D testDomainSave, /* 0.3.2 */ -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list