From nobody Sun Feb 8 12:58:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552345357423104.07560772785484; Mon, 11 Mar 2019 16:02:37 -0700 (PDT) Received: from localhost ([127.0.0.1]:41668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3TwG-0002CZ-QC for importer@patchew.org; Mon, 11 Mar 2019 19:02:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Tu4-0000lV-6A for qemu-devel@nongnu.org; Mon, 11 Mar 2019 19:00:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3Tra-0004Ka-VU for qemu-devel@nongnu.org; Mon, 11 Mar 2019 18:57:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52028 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3Tra-0004JT-2A for qemu-devel@nongnu.org; Mon, 11 Mar 2019 18:57:42 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2BMsjNg101179 for ; Mon, 11 Mar 2019 18:57:41 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2r5x8w6e18-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Mar 2019 18:57:40 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 11 Mar 2019 22:57:39 -0000 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 11 Mar 2019 22:57:37 -0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2BMvZ6d20644090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2019 22:57:36 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD721AE060; Mon, 11 Mar 2019 22:57:35 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6C9FAE05C; Mon, 11 Mar 2019 22:57:34 +0000 (GMT) Received: from maxibm.ibmmodules.com (unknown [9.85.200.192]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 11 Mar 2019 22:57:34 +0000 (GMT) From: "Maxiwell S. Garcia" To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2019 19:57:08 -0300 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190311225709.5535-1-maxiwell@linux.ibm.com> References: <20190311225709.5535-1-maxiwell@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 19031122-0072-0000-0000-0000040936E7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010741; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01173014; UDB=6.00613263; IPR=6.00953667; MB=3.00025936; MTD=3.00000008; XFM=3.00000015; UTC=2019-03-11 22:57:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031122-0073-0000-0000-00004B750D96 Message-Id: <20190311225709.5535-2-maxiwell@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-11_16:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1810050000 definitions=main-1903110156 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v5 1/2] spapr: helper functions to get valid host fields X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, "Maxiwell S. Garcia" , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The pseries options 'host-serial' and 'host-model' accepts 'none', 'passthrough', or content. The helper functions in this commit return a valid host field based on user options. Signed-off-by: Maxiwell S. Garcia --- hw/ppc/spapr.c | 58 ++++++++++++++++++++++++++---------------- include/hw/ppc/spapr.h | 3 +++ 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9e01226e18..a3078f0261 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1202,6 +1202,34 @@ static void spapr_dt_chosen(sPAPRMachineState *spapr= , void *fdt) g_free(bootlist); } =20 +char *spapr_get_valid_host_serial(sPAPRMachineState *spapr) +{ + char *host_serial =3D NULL; + if (spapr->host_serial && !g_str_equal(spapr->host_serial, "none")) { + if (g_str_equal(spapr->host_serial, "passthrough")) { + /* -M host-serial=3Dpassthrough */ + kvmppc_get_host_serial(&host_serial); + } else { + host_serial =3D g_strdup(spapr->host_serial); + } + } + return host_serial; +} + +char *spapr_get_valid_host_model(sPAPRMachineState *spapr) +{ + char *host_model =3D NULL; + if (spapr->host_model && !g_str_equal(spapr->host_model, "none")) { + if (g_str_equal(spapr->host_model, "passthrough")) { + /* -M host-model=3Dpassthrough */ + kvmppc_get_host_model(&host_model); + } else { + host_model =3D g_strdup(spapr->host_model); + } + } + return host_model; +} + static void spapr_dt_hypervisor(sPAPRMachineState *spapr, void *fdt) { /* The /hypervisor node isn't in PAPR - this is a hack to allow PR @@ -1247,30 +1275,16 @@ static void *spapr_build_fdt(sPAPRMachineState *spa= pr) * Add info to guest to indentify which host is it being run on * and what is the uuid of the guest */ - if (spapr->host_model && !g_str_equal(spapr->host_model, "none")) { - if (g_str_equal(spapr->host_model, "passthrough")) { - /* -M host-model=3Dpassthrough */ - if (kvmppc_get_host_model(&buf)) { - _FDT(fdt_setprop_string(fdt, 0, "host-model", buf)); - g_free(buf); - } - } else { - /* -M host-model=3D */ - _FDT(fdt_setprop_string(fdt, 0, "host-model", spapr->host_mode= l)); - } + buf =3D spapr_get_valid_host_model(spapr); + if (buf) { + _FDT(fdt_setprop_string(fdt, 0, "host-model", buf)); + g_free(buf); } =20 - if (spapr->host_serial && !g_str_equal(spapr->host_serial, "none")) { - if (g_str_equal(spapr->host_serial, "passthrough")) { - /* -M host-serial=3Dpassthrough */ - if (kvmppc_get_host_serial(&buf)) { - _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf)); - g_free(buf); - } - } else { - /* -M host-serial=3D */ - _FDT(fdt_setprop_string(fdt, 0, "host-serial", spapr->host_ser= ial)); - } + buf =3D spapr_get_valid_host_serial(spapr); + if (buf) { + _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf)); + g_free(buf); } =20 buf =3D qemu_uuid_unparse_strdup(&qemu_uuid); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 59073a7579..f7ea99dc69 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -842,6 +842,9 @@ int spapr_caps_post_migration(sPAPRMachineState *spapr); =20 void spapr_check_pagesize(sPAPRMachineState *spapr, hwaddr pagesize, Error **errp); + +char *spapr_get_valid_host_serial(sPAPRMachineState *spapr); +char *spapr_get_valid_host_model(sPAPRMachineState *spapr); /* * XIVE definitions */ --=20 2.20.1