From nobody Mon May 6 09:41:35 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=1563977275; cv=none; d=zoho.com; s=zohoarc; b=PrlQbyZmFxk9stlRmM3QSnDgSTYxs+535iq92vKeSva0DmaiGQbpuhkq+Kyv5h5UEgFvy5gEED8rVo/CL+nvZCGcSOGiO2Bm9ovUFsmHeKvKOR8m5kyRMFdJO20UCwl9QKlw0CxoyW3h5EAjwhb9dZQwRRj2Gj5w2oP+gzoHNSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563977275; 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=nz2bS4kX2G6Glf510QwwgHdMeRwDgUrr7RftNknPe+M=; b=FUMn80qW5M6J+bOmYYQCw6CVjqqoM9tzutOvwl9LrDtzPpi6LFb+ddp/b313X0eock5vza56c3TAfBHhhaAEVikFrmfFPhYEzwh9LXjNeJBCZ/zHpGjndT3/BnMaRyqt4jIlOtgVuKYXvLnxd8F2gIwPg5cHzprUonPJOF6AxQs= 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 1563977275276966.1798948107311; Wed, 24 Jul 2019 07:07:55 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F0B422F8BDB; Wed, 24 Jul 2019 14:07:51 +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 C34AC10190A9; Wed, 24 Jul 2019 14:07:49 +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 60EA71800202; Wed, 24 Jul 2019 14:07:46 +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 x6OE7iOO030880 for ; Wed, 24 Jul 2019 10:07:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D7DF60605; Wed, 24 Jul 2019 14:07:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5787B60603 for ; Wed, 24 Jul 2019 14:07:41 +0000 (UTC) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.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 E28CB30860BB for ; Wed, 24 Jul 2019 14:07:40 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id s3so41970664wms.2 for ; Wed, 24 Jul 2019 07:07:40 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id c1sm99344996wrh.1.2019.07.24.07.07.36 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 07:07:36 -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=R0ogVgkmKoGavZfvZA2kysBU/lQV9gbcCVsng6UpBy0=; b=WCFrWxNTEVYj5TMrxZi8PLBmoRF6frXq8M6qLAJIz/wVBBH/5Ul8lY3JA8scl0JWJx wihouFLAnFidWy4hMubckgh1cIxMUHG2xwnHYOeLpq2vUQQCWwRHUBtyV9vcv/O+h0xq gBBb3FwC8q8iRlJnlmzLmiyyr9fGpU6D/jh5nvMn/EjH2TKXq/GIr6ZYR/Fnf7LAh4fw ymKz5YlYZHgzVqpxOWdUh2Exs4+Ih5NzdEDBCaSteVMd/0v1Phw3MSpzX3IzuQUY5ODq TIt3R4+uLtxQYQx9lHF52yJbghgwCKhiX4eQaczrrKkjNvlKwiq4QzIvxehREvPSGe/d WdxA== 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=R0ogVgkmKoGavZfvZA2kysBU/lQV9gbcCVsng6UpBy0=; b=U1wdqSwEasC+GVx20yWyyqb32enpePFxMxVE9bHBc1HqU9gbWOmWNgH4zD/1+yy92p RmNUM6odNxbi6tNR/siKJNoaQdCc3d14LcIJ4Xk6Ip5h4kzc2dTvYuEfzlsSK45glo3f MMgQLBlKckvy9GiP+F5wmJZGCwpeCLFcDwwx07FYf4a+VJkLqarcZWvSqSPo6815JTJi gIFtN28yp+45ESO9xU5wLoMcHD6MVFmULG9caCrkKwBElvRH4xW0jXvW9dNuuGEmpfCg n/V+unDGUm7m2Rb5SzlFVrtiz3Y1yL3dSMDYfHvE8mGTNuj5WGsRxLZ7EFmtVq/RsbLM 9fug== X-Gm-Message-State: APjAAAXH6bkjVH5WKncoA3mquiyzGPBfNFvAXSYL/8R7C5QuzDg36z9+ 1IGkfyDaAWNt02x7p3jk0YZHq4QEldSHhg== X-Google-Smtp-Source: APXvYqxfqsypPIsH7J80C8Xmps0wnAd2fsbSg+/+4qp52M5bk0TVLIYUyUfEkvopHi8G9vAiVdUhDA== X-Received: by 2002:a1c:e710:: with SMTP id e16mr76846444wmh.38.1563977259056; Wed, 24 Jul 2019 07:07:39 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Wed, 24 Jul 2019 16:07:29 +0200 Message-Id: <20190724140729.16304-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.44]); Wed, 24 Jul 2019 14:07:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 24 Jul 2019 14:07:41 +0000 (UTC) for IP:'209.85.128.65' DOMAIN:'mail-wm1-f65.google.com' HELO:'mail-wm1-f65.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.099 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 209.85.128.65 mail-wm1-f65.google.com 209.85.128.65 mail-wm1-f65.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] implement virDomainSetInterfaceParameters 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 24 Jul 2019 14:07:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 106 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7cf92e78a7..fce38acc17 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3108,6 +3108,111 @@ testDomainGetNumaParameters(virDomainPtr dom, } +static int +testDomainSetInterfaceParameters(virDomainPtr dom, + const char *device, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virDomainObjPtr vm =3D NULL; + virDomainDefPtr def; + virDomainNetDefPtr net =3D NULL; + virNetDevBandwidthPtr bandwidth =3D NULL; + bool inboundSpecified =3D false; + bool outboundSpecified =3D false; + size_t i; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (virTypedParamsValidate(params, nparams, + VIR_DOMAIN_BANDWIDTH_IN_AVERAGE, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_BANDWIDTH_IN_PEAK, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_BANDWIDTH_IN_BURST, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_BANDWIDTH_IN_FLOOR, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_BANDWIDTH_OUT_PEAK, + VIR_TYPED_PARAM_UINT, + VIR_DOMAIN_BANDWIDTH_OUT_BURST, + VIR_TYPED_PARAM_UINT, + NULL) < 0) + return -1; + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (!(def =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + + if (!(net =3D virDomainNetFind(def, device))) + goto cleanup; + + if ((VIR_ALLOC(bandwidth) < 0) || + (VIR_ALLOC(bandwidth->in) < 0) || + (VIR_ALLOC(bandwidth->out) < 0)) + goto cleanup; + + for (i =3D 0; i < nparams; i++) { + virTypedParameterPtr param =3D ¶ms[i]; + + if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_AVERAGE)) { + bandwidth->in->average =3D param->value.ui; + inboundSpecified =3D true; + } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_PEAK)) { + bandwidth->in->peak =3D param->value.ui; + } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_BURST)) { + bandwidth->in->burst =3D param->value.ui; + } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_FLOOR)) { + bandwidth->in->floor =3D param->value.ui; + inboundSpecified =3D true; + } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE)) { + bandwidth->out->average =3D param->value.ui; + outboundSpecified =3D true; + } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_PEAK)) { + bandwidth->out->peak =3D param->value.ui; + } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_BURST)) { + bandwidth->out->burst =3D param->value.ui; + } + } + + /* average or floor are mandatory, peak and burst are optional */ + if (!bandwidth->in->average && !bandwidth->in->floor) + VIR_FREE(bandwidth->in); + if (!bandwidth->out->average) + VIR_FREE(bandwidth->out); + + if (!net->bandwidth) { + VIR_STEAL_PTR(net->bandwidth, bandwidth); + } else { + if (bandwidth->in) { + VIR_FREE(net->bandwidth->in); + VIR_STEAL_PTR(net->bandwidth->in, bandwidth->in); + } else if (inboundSpecified) { + VIR_FREE(net->bandwidth->in); + } + if (bandwidth->out) { + VIR_FREE(net->bandwidth->out); + VIR_STEAL_PTR(net->bandwidth->out, bandwidth->out); + } else if (outboundSpecified) { + VIR_FREE(net->bandwidth->out); + } + } + + ret =3D 0; + cleanup: + virNetDevBandwidthFree(bandwidth); + virDomainObjEndAPI(&vm); + return ret; +} + + static int testDomainGetInterfaceParameters(virDomainPtr dom, const char *device, @@ -7813,6 +7918,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainSetMemoryParameters =3D testDomainSetMemoryParameters, /* 5.6.0= */ .domainGetMemoryParameters =3D testDomainGetMemoryParameters, /* 5.6.0= */ .domainGetNumaParameters =3D testDomainGetNumaParameters, /* 5.6.0 */ + .domainSetInterfaceParameters =3D testDomainSetInterfaceParameters, /*= 5.6.0 */ .domainGetInterfaceParameters =3D testDomainGetInterfaceParameters, /*= 5.6.0 */ .connectListDefinedDomains =3D testConnectListDefinedDomains, /* 0.1.1= 1 */ .connectNumOfDefinedDomains =3D testConnectNumOfDefinedDomains, /* 0.1= .11 */ -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list