From nobody Tue Jul 15 01:17:10 2025 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528360695348384.10163535201184; Thu, 7 Jun 2018 01:38:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D6C683F46; Thu, 7 Jun 2018 08:38:13 +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 4C38A5E1D3; Thu, 7 Jun 2018 08:38:13 +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 CBCF54CA86; Thu, 7 Jun 2018 08:38:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w578bvZU016599 for ; Thu, 7 Jun 2018 04:37:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9EDFB6B5B7; Thu, 7 Jun 2018 08:37:57 +0000 (UTC) Received: from caroline (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C68986B5B8; Thu, 7 Jun 2018 08:37:54 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline (Postfix) with ESMTP id A913212006C; Thu, 7 Jun 2018 10:37:53 +0200 (CEST) From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 7 Jun 2018 10:37:43 +0200 Message-Id: <6001953bee45739a0b802f22ac157e5972d7b9cb.1528360378.git.mkletzan@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Laszlo Ersek Subject: [libvirt] [PATCH 4/4] qemu: Add support for setting the TSEG size 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 07 Jun 2018 08:38:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The default is stable per machine type so there should be no need to keep t= hat. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1469338 Signed-off-by: Martin Kletzander Reviewed-by: J=EF=BF=BDn Tomko --- src/conf/domain_conf.c | 3 +- src/qemu/qemu_command.c | 18 ++++++++ src/qemu/qemu_domain.c | 35 ++++++++++++++ .../tseg-explicit-size.x86_64-latest.args | 35 ++++++++++++++ tests/qemuxml2argvdata/tseg-explicit-size.xml | 23 ++++++++++ tests/qemuxml2argvdata/tseg-i440fx.xml | 23 ++++++++++ tests/qemuxml2argvdata/tseg-invalid-size.xml | 23 ++++++++++ tests/qemuxml2argvtest.c | 25 ++++++++++ .../qemuxml2xmloutdata/tseg-explicit-size.xml | 46 +++++++++++++++++++ .../tseg-old-machine-type.xml | 44 ++++++++++++++++++ tests/qemuxml2xmloutdata/tseg.xml | 44 ++++++++++++++++++ tests/qemuxml2xmltest.c | 9 ++++ 12 files changed, 327 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest= .args create mode 100644 tests/qemuxml2argvdata/tseg-explicit-size.xml create mode 100644 tests/qemuxml2argvdata/tseg-i440fx.xml create mode 100644 tests/qemuxml2argvdata/tseg-invalid-size.xml create mode 100644 tests/qemuxml2xmloutdata/tseg-explicit-size.xml create mode 100644 tests/qemuxml2xmloutdata/tseg-old-machine-type.xml create mode 100644 tests/qemuxml2xmloutdata/tseg.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 62bf6bb803bb..e83487d6b0de 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22043,7 +22043,8 @@ virDomainDefFeaturesCheckABIStability(virDomainDefP= tr src, return false; } =20 - if (src->tseg_size !=3D dst->tseg_size) { + if (src->tseg_specified && + src->tseg_size !=3D dst->tseg_size) { const char *unit_src, *unit_dst; unsigned long long short_size_src =3D virFormatIntPretty(src->= tseg_size, &unit_s= rc); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6bc9bf5ffab8..4a87b892b7c5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7295,6 +7295,22 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, return ret; } =20 + +static void +qemuBuildTSEGCommandLine(virCommandPtr cmd, + const virDomainDef *def) +{ + if (!def->tseg_size) + return; + + virCommandAddArg(cmd, "-global"); + + /* PostParse callback guarantees that the size is divisible by 1 MiB */ + virCommandAddArgFormat(cmd, "mch.extended-tseg-mbytes=3D%llu", + def->tseg_size >> 20); +} + + static int qemuBuildSmpCommandLine(virCommandPtr cmd, virDomainDefPtr def) @@ -10108,6 +10124,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildMachineCommandLine(cmd, cfg, def, qemuCaps) < 0) goto error; =20 + qemuBuildTSEGCommandLine(cmd, def); + if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0) goto error; =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a2c4d3a36090..643fca52c17b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3632,6 +3632,38 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def) } =20 =20 +static int +qemuDomainDefTsegPostParse(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) +{ + if (def->features[VIR_DOMAIN_FEATURE_SMM] !=3D VIR_TRISTATE_SWITCH_ON) + return 0; + + if (!def->tseg_size) + return 0; + + if (!qemuDomainIsQ35(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("SMM TSEG is only supported with q35 machine type= ")); + return -1; + } + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Setting TSEG size is not supported with this QEM= U binary")); + return -1; + } + + if (def->tseg_size & ((1 << 20) - 1)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("SMM TSEG size must be divisible by 1 MiB")); + return -1; + } + + return 0; +} + + static int qemuDomainDefPostParseBasic(virDomainDefPtr def, virCapsPtr caps, @@ -3702,6 +3734,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuDomainDefCPUPostParse(def) < 0) goto cleanup; =20 + if (qemuDomainDefTsegPostParse(def, qemuCaps) < 0) + goto cleanup; + ret =3D 0; cleanup: virObjectUnref(cfg); diff --git a/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args b= /tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args new file mode 100644 index 000000000000..110761b96e0e --- /dev/null +++ b/tests/qemuxml2argvdata/tseg-explicit-size.x86_64-latest.args @@ -0,0 +1,35 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc-q35-2.10,accel=3Dtcg,usb=3Doff,smm=3Don,dump-guest-core=3Doff \ +-global mch.extended-tseg-mbytes=3D48 \ +-m 214 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device pcie-root-port,port=3D0x8,chassis=3D1,id=3Dpci.1,bus=3Dpcie.0,mult= ifunction=3Don,\ +addr=3D0x1 \ +-device pcie-root-port,port=3D0x9,chassis=3D2,id=3Dpci.2,bus=3Dpcie.0,addr= =3D0x1.0x1 \ +-device pcie-root-port,port=3D0xa,chassis=3D3,id=3Dpci.3,bus=3Dpcie.0,addr= =3D0x1.0x2 \ +-device qemu-xhci,id=3Dusb,bus=3Dpci.1,addr=3D0x0 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.2,addr=3D0x0 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/tseg-explicit-size.xml b/tests/qemuxml2= argvdata/tseg-explicit-size.xml new file mode 100644 index 000000000000..ae3121048495 --- /dev/null +++ b/tests/qemuxml2argvdata/tseg-explicit-size.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + 48 + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/qemuxml2argvdata/tseg-i440fx.xml b/tests/qemuxml2argvdat= a/tseg-i440fx.xml new file mode 100644 index 000000000000..5bd832d50829 --- /dev/null +++ b/tests/qemuxml2argvdata/tseg-i440fx.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + 48 + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/qemuxml2argvdata/tseg-invalid-size.xml b/tests/qemuxml2a= rgvdata/tseg-invalid-size.xml new file mode 100644 index 000000000000..3ac8069a81ce --- /dev/null +++ b/tests/qemuxml2argvdata/tseg-invalid-size.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + 12345 + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index cd103b650627..5cdf8bd9fd60 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2852,6 +2852,31 @@ mymain(void) =20 DO_TEST_CAPS_LATEST("disk-virtio-scsi-reservations"); =20 + DO_TEST_CAPS_LATEST("tseg-explicit-size"); + DO_TEST_PARSE_ERROR("tseg-i440fx", + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_ICH9_AHCI, + QEMU_CAPS_MACHINE_SMM_OPT, + QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES); + DO_TEST_PARSE_ERROR("tseg-explicit-size", + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_ICH9_AHCI, + QEMU_CAPS_MACHINE_SMM_OPT, + QEMU_CAPS_VIRTIO_SCSI); + DO_TEST_PARSE_ERROR("tseg-invalid-size", + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_ICH9_AHCI, + QEMU_CAPS_MACHINE_SMM_OPT, + QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES); + /* Test disks with format probing enabled for legacy reasons. * New tests should not go in this section. */ driver.config->allowDiskFormatProbing =3D true; diff --git a/tests/qemuxml2xmloutdata/tseg-explicit-size.xml b/tests/qemuxm= l2xmloutdata/tseg-explicit-size.xml new file mode 100644 index 000000000000..e1a6e15b610e --- /dev/null +++ b/tests/qemuxml2xmloutdata/tseg-explicit-size.xml @@ -0,0 +1,46 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + 48 + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/tseg-old-machine-type.xml b/tests/qem= uxml2xmloutdata/tseg-old-machine-type.xml new file mode 100644 index 000000000000..594c5c025d2e --- /dev/null +++ b/tests/qemuxml2xmloutdata/tseg-old-machine-type.xml @@ -0,0 +1,44 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/tseg.xml b/tests/qemuxml2xmloutdata/t= seg.xml new file mode 100644 index 000000000000..ad80648c73e4 --- /dev/null +++ b/tests/qemuxml2xmloutdata/tseg.xml @@ -0,0 +1,44 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 115db6e64bf6..6d3d8c781999 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1184,6 +1184,15 @@ mymain(void) QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW, QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW); =20 + DO_TEST("tseg-explicit-size", + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_ICH9_AHCI, + QEMU_CAPS_MACHINE_SMM_OPT, + QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES); + /* Test disks with format probing enabled for legacy reasons. * New tests should not go in this section. */ driver.config->allowDiskFormatProbing =3D true; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list