From nobody Sat May 4 00:34:13 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=1562276219; cv=none; d=zoho.com; s=zohoarc; b=HH2OSDvNSdnWg03/2nmLocRJA7DSQyty/IdvFW92NnK1JAsTMk1S734Dr7t2AyKwbHdr2IjdThoLo0246SLJAgUB3CmAGo+HBc5vGhX4wOXe2685ryYstxxoRBtQu7B3fy+Fa7u+IbZK5X5ureWANnlWxziE5c01u7HFDzXMqaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562276219; 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=EGXK24XHxrnMgn+KhqOl0bccyGjCArd730BXREnos4Q=; b=YNa3Y4TEiWx/LObO8mI5tUPTf8utUUon36tP2PT6+n3pc2tkawh4vD+ai5E6cCfecxbk4nXC5hFecJKM/WdbJOS7AFCtiC19D8ZP9Rup81Kfhzeug9r2IxTnAEMExOMA6100AixxWFW0ujasH/u8gptv1w1ma4T/oaV9SWNQ1u8= 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 1562276219354448.03386616302373; Thu, 4 Jul 2019 14:36:59 -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 9E5555AFE9; Thu, 4 Jul 2019 21:36: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 7A55A16929; Thu, 4 Jul 2019 21:36: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 3F27618184B6; Thu, 4 Jul 2019 21:36:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64LasYg008555 for ; Thu, 4 Jul 2019 17:36:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 37F3118944; Thu, 4 Jul 2019 21:36:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32D281883F for ; Thu, 4 Jul 2019 21:36:52 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) (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 5754F308216C for ; Thu, 4 Jul 2019 21:36:40 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id a10so6776867wrp.9 for ; Thu, 04 Jul 2019 14:36:40 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id h133sm8208052wme.28.2019.07.04.14.36.37 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 04 Jul 2019 14:36:38 -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=8vwrXwppmU5KVyjMMA4S61LguRGuhrLFw43Lht1vCd0=; b=XX+ziJDcnQudMInp23brjatRh8iJLF6xethv9LnKxSO9tqoQn7Xo5Zv/WN5imKfJIi 4pFxe24ery0V5t72S+9tZ1RSKzRqI4Hl/iJK8Srm0v0s0LhdQOELLrPNHaM2JS2+hSnk wqduHqaOWjCfoshS6GJZtgcLajKbq4jt1w5WmeI+zj7ow5WwiRDYsd1BeLBtFpBEowph 99Wr9G21/OuV0CxWXs2mQFQBn5LgX2cujnYwYosjnecFU4CUMGgtTctCma5Kwd4ZyMox 6pJmQJE7vHMTBQw6cg00UOLJciY4pQb91w56GmROrL9VH9QKeqrNeOiDZUUWtFT/m0IM 0ykw== 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=8vwrXwppmU5KVyjMMA4S61LguRGuhrLFw43Lht1vCd0=; b=PYi3SaTCgPLYMrDe5zJpG4YnrvBrUbZB/f7KBHLc0wNbM+f4Xb+Qj6oQC5n/05jzND gvPIapdNJnEOoIS8HkZlqRdG7VTe+BInfur4ezZY+UwuvxzaOLRZYKRCUVZQNYVj7u4H zk4MLXZWvRMN9IJHmX77jtTrWrn+l71EOTSgvK/glquVlOI0KJEloLw5vBe8WihPbdLq dSyo96B8rZg5jYbQJk8SYULmsAfEJM0CS641KgX4Sy1a2iDISoV9yJqrJxxj2X/SRaV/ QLxigWaojbvgex0vezSW+IttokB3vAbOP0FWxwmNhsikaUQiXoT5PxORuzq2v1q+Xsct A+ug== X-Gm-Message-State: APjAAAVBBArU0N7aE7JRZdV2U0EvbOhDnfEyHjuAyl+UP2/xpMR2gdel bhkncp+0lbZuC59yjpZDM89RChzWBA8= X-Google-Smtp-Source: APXvYqxs4Q+7dAPbL8I6KQW/B/5mpWfNHf0tZKcwoYWSCi+GAd4mSOoJ87BoGphcXfw0sya5HiW/Cw== X-Received: by 2002:a5d:4751:: with SMTP id o17mr351974wrs.127.1562276198767; Thu, 04 Jul 2019 14:36:38 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 23:36:35 +0200 Message-Id: <20190704213635.8663-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.42]); Thu, 04 Jul 2019 21:36:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 04 Jul 2019 21:36:40 +0000 (UTC) for IP:'209.85.221.67' DOMAIN:'mail-wr1-f67.google.com' HELO:'mail-wr1-f67.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.214 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, T_PDS_NO_HELO_DNS) 209.85.221.67 mail-wr1-f67.google.com 209.85.221.67 mail-wr1-f67.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] test_driver: implement virDomainSetMemoryParameters 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.39]); Thu, 04 Jul 2019 21:36:58 +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 | 85 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c14603e3af..2f4f94968b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2861,6 +2861,90 @@ static char *testDomainGetXMLDesc(virDomainPtr domai= n, unsigned int flags) virTypedParameterAssign(¶ms[index], name, type, value) < 0) \ goto cleanup + +static int +testDomainSetMemoryParameters(virDomainPtr dom, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virDomainObjPtr vm =3D NULL; + virDomainDefPtr def =3D NULL; + unsigned long long swap_hard_limit =3D 0; + unsigned long long hard_limit =3D 0; + unsigned long long soft_limit =3D 0; + bool set_swap_hard_limit =3D false; + bool set_hard_limit =3D false; + bool set_soft_limit =3D false; + int rc; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (virTypedParamsValidate(params, nparams, + VIR_DOMAIN_MEMORY_HARD_LIMIT, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_MEMORY_SOFT_LIMIT, + VIR_TYPED_PARAM_ULLONG, + VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT, + VIR_TYPED_PARAM_ULLONG, + NULL) < 0) + return -1; + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (!(def =3D virDomainObjGetOneDef(vm, flags))) + goto cleanup; + +#define VIR_GET_LIMIT_PARAMETER(PARAM, VALUE) \ + if ((rc =3D virTypedParamsGetULLong(params, nparams, PARAM, &VALUE)) <= 0) \ + goto cleanup; \ + \ + if (rc =3D=3D 1) \ + set_ ## VALUE =3D true; + + VIR_GET_LIMIT_PARAMETER(VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT, swap_hard_l= imit) + VIR_GET_LIMIT_PARAMETER(VIR_DOMAIN_MEMORY_HARD_LIMIT, hard_limit) + VIR_GET_LIMIT_PARAMETER(VIR_DOMAIN_MEMORY_SOFT_LIMIT, soft_limit) + +#undef VIR_GET_LIMIT_PARAMETER + + if (set_swap_hard_limit || set_hard_limit) { + unsigned long long mem_limit =3D vm->def->mem.hard_limit; + unsigned long long swap_limit =3D vm->def->mem.swap_hard_limit; + + if (set_swap_hard_limit) + swap_limit =3D swap_hard_limit; + + if (set_hard_limit) + mem_limit =3D hard_limit; + + if (mem_limit > swap_limit) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("memory hard_limit tunable value must be lowe= r " + "than or equal to swap_hard_limit")); + goto cleanup; + } + } + + if (set_soft_limit) + def->mem.soft_limit =3D soft_limit; + + if (set_hard_limit) + def->mem.hard_limit =3D hard_limit; + + if (set_swap_hard_limit) + def->mem.swap_hard_limit =3D swap_hard_limit; + + ret =3D 0; + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static int testDomainGetMemoryParameters(virDomainPtr dom, virTypedParameterPtr params, @@ -7615,6 +7699,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainGetVcpuPinInfo =3D testDomainGetVcpuPinInfo, /* 1.2.18 */ .domainGetMaxVcpus =3D testDomainGetMaxVcpus, /* 0.7.3 */ .domainGetXMLDesc =3D testDomainGetXMLDesc, /* 0.1.4 */ + .domainSetMemoryParameters =3D testDomainSetMemoryParameters, /* 5.6.0= */ .domainGetMemoryParameters =3D testDomainGetMemoryParameters, /* 5.6.0= */ .domainGetNumaParameters =3D testDomainGetNumaParameters, /* 5.6.0 */ .domainGetInterfaceParameters =3D testDomainGetInterfaceParameters, /*= 5.6.0 */ -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list