From nobody Sun Apr 28 05:25:52 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519338053188142.47660935162344; Thu, 22 Feb 2018 14:20:53 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D17E7ECEA; Thu, 22 Feb 2018 22:20:51 +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 EC7F56012A; Thu, 22 Feb 2018 22:20:50 +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 E63B54A46C; Thu, 22 Feb 2018 22:20:49 +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 w1MMKmZp016540 for ; Thu, 22 Feb 2018 17:20:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id C0F34608F9; Thu, 22 Feb 2018 22:20:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B67F3608F5 for ; Thu, 22 Feb 2018 22:20:46 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2EF0F81DE2 for ; Thu, 22 Feb 2018 22:20:45 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Thu, 22 Feb 2018 15:20:42 -0700 From: Jim Fehlig To: libvir-list@redhat.com Date: Thu, 22 Feb 2018 15:20:33 -0700 Message-Id: <20180222222033.12128-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 22 Feb 2018 22:20:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 22 Feb 2018 22:20:45 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] libxl: don't hardcode scheduler weight 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: , MIME-Version: 1.0 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 22 Feb 2018 22:20:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Long ago in commit dfa1e1dd53 the scheduler weight was accidentally hardcoded to 1000. Weight is a setting with no unit since it is relative to the weight of other domains. If no weight is specified, libxl defaults to 256. Instead of hardcoding the weight to 1000, honor any specified in . libvirt's notion of shares is synonomous to libxl's scheduler weight setting. If shares is unspecified, defer default weight setting to libxl. Removing the hardcoded weight required some test fixup. While at it, add an explicit test for conversion to scheduler weight. Signed-off-by: Jim Fehlig Reviewed-by: John Ferlan --- Honoring specified by the user is certainly desirable, but I'm not sure about changing the default weight. One problematic scenario that came to mind: Several domains started by pre-patch libvirtd with weight=3D1000, update libvirtd with patch, start more domains with weight=3D256. The pre-patch domains unknowingly have a weight nearly 4 times that of post-patch domains. src/libxl/libxl_conf.c | 4 +- tests/libxlxml2domconfigdata/basic-hvm.json | 2 +- tests/libxlxml2domconfigdata/basic-pv.json | 2 +- tests/libxlxml2domconfigdata/cpu-shares-hvm.json | 89 ++++++++++++++++++= ++++ tests/libxlxml2domconfigdata/cpu-shares-hvm.xml | 39 ++++++++++ tests/libxlxml2domconfigdata/moredevs-hvm.json | 2 +- tests/libxlxml2domconfigdata/multiple-ip.json | 2 +- .../libxlxml2domconfigdata/variable-clock-hvm.json | 2 +- tests/libxlxml2domconfigdata/vnuma-hvm.json | 2 +- tests/libxlxml2domconfigtest.c | 1 + 10 files changed, 138 insertions(+), 7 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index dcd46873c..e40145cfa 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -366,7 +366,9 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } } =20 - b_info->sched_params.weight =3D 1000; + if (def->cputune.sharesSpecified) + b_info->sched_params.weight =3D def->cputune.shares; + b_info->max_memkb =3D virDomainDefGetMemoryInitial(def); b_info->target_memkb =3D def->mem.cur_balloon; if (hvm) { diff --git a/tests/libxlxml2domconfigdata/basic-hvm.json b/tests/libxlxml2d= omconfigdata/basic-hvm.json index 6fa41f34f..ccd585385 100644 --- a/tests/libxlxml2domconfigdata/basic-hvm.json +++ b/tests/libxlxml2domconfigdata/basic-hvm.json @@ -19,7 +19,7 @@ "device_model_version": "qemu_xen", "device_model": "/bin/true", "sched_params": { - "weight": 1000 + }, "type.hvm": { "pae": "True", diff --git a/tests/libxlxml2domconfigdata/basic-pv.json b/tests/libxlxml2do= mconfigdata/basic-pv.json index 7e1abd3d6..0f846daab 100644 --- a/tests/libxlxml2domconfigdata/basic-pv.json +++ b/tests/libxlxml2domconfigdata/basic-pv.json @@ -15,7 +15,7 @@ "max_memkb": 524288, "target_memkb": 524288, "sched_params": { - "weight": 1000 + }, "type.pv": { "bootloader": "pygrub" diff --git a/tests/libxlxml2domconfigdata/cpu-shares-hvm.json b/tests/libxl= xml2domconfigdata/cpu-shares-hvm.json new file mode 100644 index 000000000..2e647eada --- /dev/null +++ b/tests/libxlxml2domconfigdata/cpu-shares-hvm.json @@ -0,0 +1,89 @@ +{ + "c_info": { + "type": "hvm", + "name": "test-hvm", + "uuid": "2147d599-9cc6-c0dc-92ab-4064b5446e9b" + }, + "b_info": { + "max_vcpus": 4, + "avail_vcpus": [ + 0, + 1, + 2, + 3 + ], + "max_memkb": 1048576, + "target_memkb": 1048576, + "video_memkb": 8192, + "shadow_memkb": 12288, + "device_model_version": "qemu_xen", + "device_model": "/bin/true", + "sched_params": { + "weight": 1500 + }, + "type.hvm": { + "pae": "True", + "apic": "True", + "acpi": "True", + "vga": { + "kind": "cirrus" + }, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + }, + "spice": { + + }, + "boot": "c", + "rdm": { + + } + }, + "arch_arm": { + + } + }, + "disks": [ + { + "pdev_path": "/var/lib/xen/images/test-hvm.img", + "vdev": "hda", + "backend": "qdisk", + "format": "raw", + "removable": 1, + "readwrite": 1 + } + ], + "nics": [ + { + "devid": 0, + "mac": "00:16:3e:66:12:b4", + "bridge": "br0", + "script": "/etc/xen/scripts/vif-bridge", + "nictype": "vif_ioemu" + } + ], + "vfbs": [ + { + "devid": -1, + "vnc": { + "enable": "True", + "listen": "0.0.0.0", + "findunused": "False" + }, + "sdl": { + "enable": "False" + } + } + ], + "vkbs": [ + { + "devid": -1 + } + ], + "on_reboot": "restart" +} diff --git a/tests/libxlxml2domconfigdata/cpu-shares-hvm.xml b/tests/libxlx= ml2domconfigdata/cpu-shares-hvm.xml new file mode 100644 index 000000000..49085b4b7 --- /dev/null +++ b/tests/libxlxml2domconfigdata/cpu-shares-hvm.xml @@ -0,0 +1,39 @@ + + test-hvm + None + 2147d599-9cc6-c0dc-92ab-4064b5446e9b + 1048576 + 1048576 + 4 + + 1500 + + destroy + restart + destroy + + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + + + /bin/true + + + + + + + + +