From nobody Sun May 5 14:46:16 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=1561648497; cv=none; d=zoho.com; s=zohoarc; b=QwtDBi7tW1nGmUeu/XLBbqWcaVmmNaYhqBSu7RmrUg5w6CrDyDT+m1RSrQxedUET50NbUv//SLFwFnj/w21wLLe9UhoMafFlpaPZK8sFBekx3FnexDg4JGl10bUStQysoZ4Kdsfmn4EmUDz1NsSpeT0J7GCBMa8D3CVTjcpoVas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561648497; 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=Ef0HhljzY1DglZ+E7pou7hpBPOhyLLEof2uAQjMk6ds=; b=F1HtxgUxJrA+9b3HRm54P3TI6zVDEDuO3X4ElEUvJr+SqAXWMQskDla+1aUk717e6uR6fbieyVUOaWxGekbXWQ7gwvXpSabWLYB1DG1T8WN0o0LQtupg04g67LnY5dNa5JDSwnBPGF7no6BphF6fFRim1tzoa8t/ZMtoODRozqU= 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 1561648497859369.4357800068881; Thu, 27 Jun 2019 08:14:57 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id A7611308FBAC; Thu, 27 Jun 2019 15:14:28 +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 1F8BE5DA35; Thu, 27 Jun 2019 15:14:19 +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 0ABB51806B18; Thu, 27 Jun 2019 15:14:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5RFE0uB030186 for ; Thu, 27 Jun 2019 11:14:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 259CF608CA; Thu, 27 Jun 2019 15:14:00 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F4F960856 for ; Thu, 27 Jun 2019 15:13:57 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (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 7973285543 for ; Thu, 27 Jun 2019 15:13:46 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id p11so3004599wre.7 for ; Thu, 27 Jun 2019 08:13:46 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id v204sm6732459wma.20.2019.06.27.08.13.43 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 08:13:43 -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=2KJfjzawOiC9Cu1nf/VWoRKVhetxh4L1+VlHnfwDyTE=; b=gVQNyz1jtuTi7J4lMeQH/3pajmCCSwUfHodrN6oFndXkOoLMBukWeP67CLss4bpTtQ 9mgs2yF1lVvcrVnuVP2xfqXCaCVrl8oAsYvVcD+tcneuyQAelpXEN3UAXhUrDYrphvL5 2TCmnQMaIN0+HfsiRQ0ReN3Yp8KUI/lS96smuJgv+Y0XSX4gwN92w6ClAfoBCr3h7Kn/ aZX5mbt49N+xbOz12mL8ucSJ9SEkvvo73XSg41/yys4AvMDCqqRUIlPzDEpqiOFACEFP Y0TNS4fFTj+eLjn91spxKtcCpABDsegKIem52Qo9WNDe94aeKEVkYVn6SZKXpdclbDLN ZW+A== 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=2KJfjzawOiC9Cu1nf/VWoRKVhetxh4L1+VlHnfwDyTE=; b=m4FGUp63KfUjPx2Kgy+Gk9VIuFiAYrAb8PBthMSIk6WHRO3GEEY/+iSm05LE1rj+IH 2EtL0u2nvrBXAo9oe8PyODtkkD0fIKNYorI9Y8HzJLLg8k7bjgy5o85WN+Btl4Fua0Eg K2qkhlodHuUYWe1JpP4uMm+y2qxfdnvHRIyMpxhNM+QN1WMBPU9DrNHT/9Hf9xql5wxB azVO7fZjS5+2A44uqCtalglRCwL6bS/rXmkNqJF2cbASSHS9oHebpSJavs/NnvxPtz9t AruTV2udD+cyLVCMQNFuDxNm4c+M1mz0UpcF9dbiqmE93HZtcsBEwUc29itOL7heCm5Q /Uhg== X-Gm-Message-State: APjAAAVI7afsXQHHXUvLjPgMbBsmhSp6yHz0+0ZhRn3sunIiYGNfSwaZ 8JiCRYVqRBSMxEDXFuJI7lAxwIkArALMAw== X-Google-Smtp-Source: APXvYqw3B7jrJ8RY8u7uKQ7Bl1gIdEmt23RyOObd/NNVpRsYOEfzTGLROB2htimwfABWxc4TTYUVgA== X-Received: by 2002:a5d:46cb:: with SMTP id g11mr3718898wrs.253.1561648424697; Thu, 27 Jun 2019 08:13:44 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Thu, 27 Jun 2019 17:13:41 +0200 Message-Id: <20190627151341.29941-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.28]); Thu, 27 Jun 2019 15:13:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 27 Jun 2019 15:13:46 +0000 (UTC) for IP:'209.85.221.66' DOMAIN:'mail-wr1-f66.google.com' HELO:'mail-wr1-f66.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.221.66 mail-wr1-f66.google.com 209.85.221.66 mail-wr1-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 27 Jun 2019 15:14:47 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis --- This is almost identical to the QEMU's driver implementation. I wonder if we can somehow avoid copying that much code. src/test/test_driver.c | 100 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4b1f2724a0..37634dd771 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1964,6 +1964,105 @@ 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; + 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 (!(net =3D virDomainNetFind(vm->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 +7357,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