From nobody Fri Apr 26 01:00:58 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1558011087; cv=none; d=zoho.com; s=zohoarc; b=JwwHFPlrgE6DojXTu3pAEVLL0ElSAJDVxJMyUS9UeuOnTmTIB6KibFYllE4k/3vkQM2w11F+hsRS6+BSdS5D81Nlqi9YyORYj/qxGYWpz/Si4qOt0gbAJ4jMOez3Ken3StjEsKDRH3Tk+iK+J6Jm/Vp4iv8Soqrh3H9azs79CTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558011087; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=iprBO+4FO0qi8l5ob/9bazEefPy+SMRaEUx/M5uzOSM=; b=jop/3HrAlb4ZyVAlTtSRKIM8pgBBDzqz9+9ELhrjLLiCWySykcwXt+Dy7RdaOU30mM8pvSDDZONrd49yEx3whLhFizbOSItVq1fykBW3D5ZQs23VKiGVHVa25hMQpSfYF6JYv3xBEsUjrNWZw898GE4LyeIKpxdl9Djc7xZ7mrc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1558011086433194.2517867482186; Thu, 16 May 2019 05:51:26 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hRFpv-0002uh-1X; Thu, 16 May 2019 12:50:15 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hRFpt-0002ub-2f for xen-devel@lists.xenproject.org; Thu, 16 May 2019 12:50:13 +0000 Received: from mo6-p00-ob.smtp.rzone.de (unknown [2a01:238:20a:202:5300::8]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 238bbd68-77d9-11e9-8980-bc764e045a96; Thu, 16 May 2019 12:50:11 +0000 (UTC) Received: from sender by smtp.strato.de (RZmta 44.20 AUTH) with ESMTPSA id U080cav4GCo2F3Q (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 16 May 2019 14:50:02 +0200 (CEST) X-Inumbo-ID: 238bbd68-77d9-11e9-8980-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1558011009; s=strato-dkim-0002; d=aepfle.de; h=Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=R2xFGHzGrUdY25+2IMW08TcDWTvg0a/q4oZBaCxtm4U=; b=qBgCIw+Bo+32eElEtYMzZ24B8lBkQJmgEqk3KUPC26gL/uYHnfKjPMhII2EpYh97a8 o98opkroxvKF4QepvzKUJHIxF7XHcIP4imzoRZ3MYR2BJSZ+bVq9owjuKnrNSdXh8oku r5d66xCd+hio+br+l3coBEiB0NTlRRZxtGNcMh+wA6MDoEWMC8QJkFQY0Te1x/xQWakJ /w+7FbUkWD6bPFREzr7iREMRZxbDOJmXKc4kn75gAM2Esg0aoWV7Ei+feWmW7zYwPnbB eBU/W3APZuQVSY8hznb/voicYVvyFWkM5U2NoPQgsnAMDO+ZPSid+9mECBcQkjd+pDF7 Tm1A== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuznLRsvz6zGrN/JP2665" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: xen-devel@lists.xenproject.org Date: Thu, 16 May 2019 14:50:00 +0200 Message-Id: <20190516125000.23559-1-olaf@aepfle.de> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v1] libxl: fix device_model_version related assert X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Olaf Hering , Ian Jackson Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In commit 3802ecbaa9 ("libxl: add helper function to set device_model_version") an assert was added to libxl__domain_build_info_setdefault to make sure callers provide complete info to this function. This unveiled a flaw in the way how libxl_domain_build_info is passed to libxl. The public API libxl_domain_need_memory passes an incomplete libxl_domain_build_info to libxl__domain_build_info_setdefault, which triggers the assert. Prior to the change above, device_model_version was hardcoded to QEMU_XEN which lead to the bugs described in that changeset. A new libxl API would need to be created to fully populate libxl_domain_build_info with missing defaults. For existing, unchanged consumers of libxl the assumption about QEMU_XEN needs to be restored within this function to properly populate the amount of required memory. Signed-off-by: Olaf Hering Reported-by: Juergen Gross --- tools/libxl/libxl_create.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 89f99f7f44..030851fb28 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -123,6 +123,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info) { int i, rc; + libxl_device_model_version device_model_version; =20 if (b_info->type !=3D LIBXL_DOMAIN_TYPE_HVM && b_info->type !=3D LIBXL_DOMAIN_TYPE_PV && @@ -131,7 +132,9 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, return ERROR_INVAL; } =20 - assert(b_info->device_model_version); + device_model_version =3D b_info->device_model_version; + if (!device_model_version) + device_model_version =3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN; =20 /* Copy deprecated options to it's new position. */ rc =3D libxl__domain_build_info_copy_deprecated(CTX, b_info); @@ -149,7 +152,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, =20 if (b_info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { if (!b_info->u.hvm.bios) - switch (b_info->device_model_version) { + switch (device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: b_info->u.hvm.bios =3D LIBXL_BIOS_TYPE_ROMBIOS; break; case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: @@ -160,7 +163,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, } =20 /* Enforce BIOS<->Device Model version relationship */ - switch (b_info->device_model_version) { + switch (device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: if (b_info->u.hvm.bios !=3D LIBXL_BIOS_TYPE_ROMBIOS) { LOG(ERROR, "qemu-xen-traditional requires bios=3Drombios."= ); @@ -186,7 +189,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, } =20 if (b_info->type =3D=3D LIBXL_DOMAIN_TYPE_HVM && - b_info->device_model_version !=3D + device_model_version !=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL && libxl_defbool_val(b_info->device_model_stubdomain)) { LOG(ERROR, @@ -259,7 +262,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, if (!b_info->u.hvm.hdtype) b_info->u.hvm.hdtype =3D LIBXL_HDTYPE_IDE; =20 - switch (b_info->device_model_version) { + switch (device_model_version) { case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: switch (b_info->u.hvm.vga.kind) { case LIBXL_VGA_INTERFACE_TYPE_NONE: _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel