From patchwork Thu Mar 14 16:29:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maxiwell S. Garcia" X-Patchwork-Id: 1056607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44KvhW5yx9z9s55 for ; Fri, 15 Mar 2019 03:45:15 +1100 (AEDT) Received: from localhost ([127.0.0.1]:41391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4TTl-0003B4-NH for incoming@patchwork.ozlabs.org; Thu, 14 Mar 2019 12:45:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4TPd-0000Qg-RF for qemu-devel@nongnu.org; Thu, 14 Mar 2019 12:41:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4TGI-0005X0-Fy for qemu-devel@nongnu.org; Thu, 14 Mar 2019 12:31:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h4TGH-0005Vj-WB for qemu-devel@nongnu.org; Thu, 14 Mar 2019 12:31:18 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2EGTqWI140160 for ; Thu, 14 Mar 2019 12:31:16 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2r7rypwj2p-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Mar 2019 12:31:16 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Mar 2019 16:31:15 -0000 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 14 Mar 2019 16:31:13 -0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2EGVCek25755900 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Mar 2019 16:31:12 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54AEABE04F; Thu, 14 Mar 2019 16:31:12 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C4E7BE05B; Thu, 14 Mar 2019 16:31:11 +0000 (GMT) Received: from maxibm.br.ibm.com (unknown [9.18.235.41]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 14 Mar 2019 16:31:10 +0000 (GMT) From: "Maxiwell S. Garcia" To: qemu-devel@nongnu.org Date: Thu, 14 Mar 2019 13:29:48 -0300 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190314162949.29428-1-maxiwell@linux.ibm.com> References: <20190314162949.29428-1-maxiwell@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19031416-0016-0000-0000-000009903363 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010757; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01174303; UDB=6.00614043; IPR=6.00954967; MB=3.00025978; MTD=3.00000008; XFM=3.00000015; UTC=2019-03-14 16:31:15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031416-0017-0000-0000-00004272F354 Message-Id: <20190314162949.29428-2-maxiwell@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-14_06:, , 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-1903140117 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v6 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, groug@kaod.org, "Maxiwell S. Garcia" , david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 48 +++++++++++++++++++++++------------------- include/hw/ppc/spapr.h | 4 ++++ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6c16d6cfaf..3e2d5fe438 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1211,6 +1211,24 @@ static void spapr_dt_chosen(SpaprMachineState *spapr, void *fdt) g_free(bootlist); } +#define SPAPR_GET_VALID_HOST(attr) \ +char *spapr_get_valid_host_##attr(SpaprMachineState *spapr) \ +{ \ + char *buf = NULL; \ + if (spapr->host_##attr && \ + !g_str_equal(spapr->host_##attr, "none")) { \ + if (g_str_equal(spapr->host_##attr, "passthrough")) { \ + kvmppc_get_host_##attr(&buf); \ + } else { \ + buf = g_strdup(spapr->host_##attr); \ + } \ + } \ + return buf; \ +} + +SPAPR_GET_VALID_HOST(serial); +SPAPR_GET_VALID_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 @@ -1256,30 +1274,16 @@ static void *spapr_build_fdt(SpaprMachineState *spapr) * 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=passthrough */ - if (kvmppc_get_host_model(&buf)) { - _FDT(fdt_setprop_string(fdt, 0, "host-model", buf)); - g_free(buf); - } - } else { - /* -M host-model= */ - _FDT(fdt_setprop_string(fdt, 0, "host-model", spapr->host_model)); - } + buf = spapr_get_valid_host_model(spapr); + if (buf) { + _FDT(fdt_setprop_string(fdt, 0, "host-model", buf)); + g_free(buf); } - if (spapr->host_serial && !g_str_equal(spapr->host_serial, "none")) { - if (g_str_equal(spapr->host_serial, "passthrough")) { - /* -M host-serial=passthrough */ - if (kvmppc_get_host_serial(&buf)) { - _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf)); - g_free(buf); - } - } else { - /* -M host-serial= */ - _FDT(fdt_setprop_string(fdt, 0, "host-serial", spapr->host_serial)); - } + buf = spapr_get_valid_host_serial(spapr); + if (buf) { + _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf)); + g_free(buf); } buf = qemu_uuid_unparse_strdup(&qemu_uuid); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 2b4c05a2ec..5e0a1b2a8a 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -856,6 +856,10 @@ int spapr_caps_post_migration(SpaprMachineState *spapr); 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 */