From nobody Sun Feb 8 12:19:10 2026 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=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1570622624; cv=none; d=zoho.com; s=zohoarc; b=iaLwQ7wer2PTNUFRa4aU0TPCsBTSZ0RlFDd/+Ma4KLP5JS/rBVapv5WT2WTu5GryAjGVM4AWdUpVxNHjqsKpLaZ1lPChbTeE2ZLL3UC9a2rp8sWxBeYqYXplCMh35ICIHgzi1ee8SDVgPeyn6Tit3snhWxW/DoylpXAEkKaNlEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570622624; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s2wH573KyAroJqZQflKHlND2WjKRVK1nYO7zaxLghI8=; b=CKUtruWmHV4x3lKs8fbST+q1hROeogv16lCvFQ44RE4zGZDhqESojFcUUs85/5bR40dIiVgeywE1I1RTnByj6nMWXpg+UX+iFpElGT4xfsqONEDBv8Oqm7VwcvKmZ/wq1HvF+OLQ6nfQ2k+NAB7e1wr3W/iAtdTpC9BcrbAJ6rw= ARC-Authentication-Results: i=1; mx.zoho.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=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 1570622624198219.02507889117794; Wed, 9 Oct 2019 05:03:44 -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 88244309DEE5; Wed, 9 Oct 2019 12:03:42 +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 5918060C05; Wed, 9 Oct 2019 12:03:42 +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 0056B180085A; Wed, 9 Oct 2019 12:03:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x98Gl8nd010530 for ; Tue, 8 Oct 2019 12:47:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1ECB219C7F; Tue, 8 Oct 2019 16:47:08 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 199FE19C69 for ; Tue, 8 Oct 2019 16:47:05 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 B11B4302246D for ; Tue, 8 Oct 2019 16:47:04 +0000 (UTC) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x98GChib041509 for ; Tue, 8 Oct 2019 12:47:04 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vepu16bw7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 08 Oct 2019 12:47:03 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x98GG8iP026511 for ; Tue, 8 Oct 2019 16:47:03 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma03dal.us.ibm.com with ESMTP id 2vejt79d8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 08 Oct 2019 16:47:03 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x98Gl2uN51511788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 8 Oct 2019 16:47:02 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0816C112062 for ; Tue, 8 Oct 2019 16:47:02 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C46A112065 for ; Tue, 8 Oct 2019 16:47:01 +0000 (GMT) Received: from farosas.linux.ibm.com.br.ibm.com (unknown [9.86.27.34]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP for ; Tue, 8 Oct 2019 16:47:01 +0000 (GMT) From: Fabiano Rosas To: libvir-list@redhat.com Date: Tue, 8 Oct 2019 13:46:57 -0300 Message-Id: <20191008164657.4286-3-farosas@linux.ibm.com> In-Reply-To: <20191008164657.4286-1-farosas@linux.ibm.com> References: <20191008164657.4286-1-farosas@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-10-08_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910080138 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 08 Oct 2019 16:47:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 08 Oct 2019 16:47:04 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'farosas@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 09 Oct 2019 08:03:35 -0400 Subject: [libvirt] [PATCH 2/2] qemu: Add support for pseries 'host-model' machine parameter 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.45]); Wed, 09 Oct 2019 12:03:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Since QEMU v4.0.0, the host's model is no longer automatically exposed to the guest via /proc/device-tree/host-model. There is now a machine option 'host-model' that allows an arbitrary string to be used as the host model [1]. This patch adds support for exposing the real host model string from /proc/cpuinfo (also found on /proc/device-tree/model) to the guest via -machine pseries,host-model=3D by setting in the domain XML file: The functionality is disabled by default to avoid leaking host information to the guest. 1 - https://git.qemu.org/?p=3Dqemu.git;a=3Dcommitdiff;h=3D0a794529bd11 Signed-off-by: Fabiano Rosas --- docs/formatdomain.html.in | 9 ++++++ docs/schemas/domaincommon.rng | 5 ++++ src/conf/domain_conf.c | 4 +++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 25 ++++++++++++++-- src/qemu/qemu_domain.c | 1 + tests/qemuxml2argvdata/pseries-features.args | 3 +- tests/qemuxml2argvdata/pseries-features.xml | 1 + tests/qemuxml2argvtest.c | 30 ++++++++++++++++++- tests/qemuxml2xmloutdata/pseries-features.xml | 1 + 10 files changed, 75 insertions(+), 5 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 647f96f651..b613f61f23 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2357,6 +2357,15 @@ will not be ignored. Since 5.1.0 (bhyve only) +
host-model-passthrough
+
Configure the passthrough of the host's model string to + pSeries guests. The host model will be present in the guest at + /proc/device-tree/host-model. + Possible values for the state attribute are + on and off. If the attribute is + not defined, the default value (off) is assumed. + Since 5.8.0 (QEMU/KVM only) +
=20

Time keeping

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 40eb4a2d75..0d505bb38a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5117,6 +5117,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a53cd6a725..9803f18389 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -171,6 +171,7 @@ VIR_ENUM_IMPL(virDomainFeature, "htm", "nested-hv", "msrs", + "host-model-passthrough", ); =20 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, @@ -20396,6 +20397,7 @@ virDomainDefParseXML(xmlDocPtr xml, =20 case VIR_DOMAIN_FEATURE_HTM: case VIR_DOMAIN_FEATURE_NESTED_HV: + case VIR_DOMAIN_FEATURE_HOST_MODEL_PASSTHROUGH: if (!(tmp =3D virXMLPropString(nodes[i], "state"))) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("missing state attribute '%s' of feature = '%s'"), @@ -22621,6 +22623,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefP= tr src, case VIR_DOMAIN_FEATURE_VMCOREINFO: case VIR_DOMAIN_FEATURE_HTM: case VIR_DOMAIN_FEATURE_NESTED_HV: + case VIR_DOMAIN_FEATURE_HOST_MODEL_PASSTHROUGH: if (src->features[i] !=3D dst->features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of feature '%s' differs: " @@ -28187,6 +28190,7 @@ virDomainDefFormatFeatures(virBufferPtr buf, case VIR_DOMAIN_FEATURE_VMPORT: case VIR_DOMAIN_FEATURE_HTM: case VIR_DOMAIN_FEATURE_NESTED_HV: + case VIR_DOMAIN_FEATURE_HOST_MODEL_PASSTHROUGH: switch ((virTristateSwitch) def->features[i]) { case VIR_TRISTATE_SWITCH_LAST: case VIR_TRISTATE_SWITCH_ABSENT: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2884af49d8..ba32116e90 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1755,6 +1755,7 @@ typedef enum { VIR_DOMAIN_FEATURE_HTM, VIR_DOMAIN_FEATURE_NESTED_HV, VIR_DOMAIN_FEATURE_MSRS, + VIR_DOMAIN_FEATURE_HOST_MODEL_PASSTHROUGH, =20 VIR_DOMAIN_FEATURE_LAST } virDomainFeature; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cbf25d5f07..bdb4461282 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7110,7 +7110,6 @@ qemuAppendLoadparmMachineParm(virBuffer *buf, } } =20 - static int qemuBuildNameCommandLine(virCommandPtr cmd, virQEMUDriverConfigPtr cfg, @@ -7140,14 +7139,16 @@ qemuBuildNameCommandLine(virCommandPtr cmd, =20 static int qemuBuildMachineCommandLine(virCommandPtr cmd, - virQEMUDriverConfigPtr cfg, + virQEMUDriverPtr driver, const virDomainDef *def, virQEMUCapsPtr qemuCaps) { virTristateSwitch vmport =3D def->features[VIR_DOMAIN_FEATURE_VMPORT]; virTristateSwitch smm =3D def->features[VIR_DOMAIN_FEATURE_SMM]; virCPUDefPtr cpu =3D def->cpu; + virSysinfoDefPtr hostinfo =3D driver->hostsysinfo; VIR_AUTOCLEAN(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D virQEMUDriverGetConfig(d= river); size_t i; =20 /* This should *never* be NULL, since we always provide @@ -7409,6 +7410,24 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, virBufferAsprintf(&buf, ",cap-nested-hv=3D%s", str); } =20 + if (def->features[VIR_DOMAIN_FEATURE_HOST_MODEL_PASSTHROUGH] =3D=3D VI= R_TRISTATE_SWITCH_ON) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_HOST_MODEL= )) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Host model passthrough is not supported by " + "this QEMU binary")); + return -1; + } + + if (!hostinfo || !hostinfo->system) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Host model information is not available")); + return -1; + } + + virBufferAddLit(&buf, ",host-model=3D"); + virQEMUBuildBufferEscapeComma(&buf, hostinfo->system->serial); + } + if (cpu && cpu->model && cpu->mode =3D=3D VIR_CPU_MODE_HOST_MODEL && qemuDomainIsPSeries(def) && @@ -10309,7 +10328,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (enableFips) virCommandAddArg(cmd, "-enable-fips"); =20 - if (qemuBuildMachineCommandLine(cmd, cfg, def, qemuCaps) < 0) + if (qemuBuildMachineCommandLine(cmd, driver, def, qemuCaps) < 0) return NULL; =20 qemuBuildTSEGCommandLine(cmd, def); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b4175a846e..a310ab828e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4730,6 +4730,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def, case VIR_DOMAIN_FEATURE_HPT: case VIR_DOMAIN_FEATURE_HTM: case VIR_DOMAIN_FEATURE_NESTED_HV: + case VIR_DOMAIN_FEATURE_HOST_MODEL_PASSTHROUGH: if (def->features[i] !=3D VIR_TRISTATE_SWITCH_ABSENT && !qemuDomainIsPSeries(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/tests/qemuxml2argvdata/pseries-features.args b/tests/qemuxml2a= rgvdata/pseries-features.args index 9fde54b37a..931645cba6 100644 --- a/tests/qemuxml2argvdata/pseries-features.args +++ b/tests/qemuxml2argvdata/pseries-features.args @@ -11,7 +11,8 @@ QEMU_AUDIO_DRV=3Dnone \ -name guest \ -S \ -machine pseries,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,resize-hpt=3D= required,\ -cap-hpt-max-page-size=3D1048576k,cap-htm=3Don,cap-nested-hv=3Doff \ +cap-hpt-max-page-size=3D1048576k,cap-htm=3Don,cap-nested-hv=3Doff,\ +host-model=3Dfake_model \ -m 512 \ -realtime mlock=3Doff \ -smp 1,sockets=3D1,cores=3D1,threads=3D1 \ diff --git a/tests/qemuxml2argvdata/pseries-features.xml b/tests/qemuxml2ar= gvdata/pseries-features.xml index 6f7d32b065..8dd222c562 100644 --- a/tests/qemuxml2argvdata/pseries-features.xml +++ b/tests/qemuxml2argvdata/pseries-features.xml @@ -12,6 +12,7 @@ +
/usr/bin/qemu-system-ppc64 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db79301f0e..1d00068d2b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -95,6 +95,30 @@ static virSecretDriver fakeSecretDriver =3D { .secretUndefine =3D NULL, }; =20 +static void +testSetHostSysinfo(virSysinfoDefPtr sysinfo) +{ + if (!sysinfo) { + virSysinfoDefFree(driver.hostsysinfo); + return; + } + + driver.hostsysinfo =3D sysinfo; +} + +static virSysinfoDefPtr +fakeVirSysinfoReadPPC(void) +{ + virSysinfoDefPtr sysinfo =3D NULL; + + if (VIR_ALLOC(sysinfo) < 0 || VIR_ALLOC(sysinfo->system) < 0) { + virSysinfoDefFree(sysinfo); + return NULL; + } + + ignore_value(VIR_STRDUP(sysinfo->system->serial, "fake_model")); + return sysinfo; +} =20 # define STORAGE_POOL_XML_PATH "storagepoolxml2xmlout/" static const unsigned char fakeUUID[VIR_UUID_BUFLEN] =3D "fakeuuid"; @@ -1955,12 +1979,16 @@ mymain(void) QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VFIO_PCI); =20 + testSetHostSysinfo(fakeVirSysinfoReadPPC()); DO_TEST("pseries-features", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE, QEMU_CAPS_MACHINE_PSERIES_CAP_HTM, QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, - QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT); + QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT, + QEMU_CAPS_MACHINE_PSERIES_HOST_MODEL); + testSetHostSysinfo(NULL); + DO_TEST_FAILURE("pseries-features", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); DO_TEST_PARSE_ERROR("pseries-features-invalid-machine", NONE); diff --git a/tests/qemuxml2xmloutdata/pseries-features.xml b/tests/qemuxml2= xmloutdata/pseries-features.xml index 7e12bc9c03..0d0277280d 100644 --- a/tests/qemuxml2xmloutdata/pseries-features.xml +++ b/tests/qemuxml2xmloutdata/pseries-features.xml @@ -14,6 +14,7 @@ +
destroy --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list