From patchwork Mon Oct 16 15:24:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10008831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B1D88601D5 for ; Mon, 16 Oct 2017 15:26:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1D90285ED for ; Mon, 16 Oct 2017 15:26:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9687B28600; Mon, 16 Oct 2017 15:26:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0C01C285ED for ; Mon, 16 Oct 2017 15:26:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e47G8-0001oB-05; Mon, 16 Oct 2017 15:24:52 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e47G6-0001np-Mk for xen-devel@lists.xenproject.org; Mon, 16 Oct 2017 15:24:50 +0000 Received: from [85.158.143.35] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta-6.messagelabs.com id 4B/C9-30254-24FC4E95; Mon, 16 Oct 2017 15:24:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRWlGSWpSXmKPExsXS6fjDS9fx/JN IgxWHpCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxtx7awFHyTrph7eS9LA+M3kS5GTg4hgTyJ c6eeM4HYvAJ2EqeenmcBsSUEDCVOL7wJZrMIqEp83fOFEcRmE1CXaHu2nbWLkYNDRMBA4tzRJ JAws4C/RM+8pWwgtjCQPf/QD2aQEl4BQYm/O4QhSrQkHv66xQJha0ssW/garIRZQFpi+T+OCY w8sxAaZiFpmIWkYRZCwwJGllWMGsWpRWWpRbqGZnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYl JxXrJ+bmbGIGhxAAEOxjvbww4xCjJwaQkyuts+CRSiC8pP6UyI7E4I76oNCe1+BCjDAeHkgTv 2nNAOcGi1PTUirTMHGBQw6QlOHiURHi7QNK8xQWJucWZ6RCpU4y6HB037/5hEmLJy89LlRLn7 QUpEgApyijNgxsBi7BLjLJSwryMQEcJ8RSkFuVmlqDKv2IU52BUEuZdBjKFJzOvBG7TK6AjmI COWOcEdkRJIkJKqoFxSvepS62HZ2lGrfpbszDpm7SY6tWFt/x/6m3wV4r9GProhuifH/NSq+8 9yU263BLyO9Do/U0RtXtysu7TNX/vNlOPSAteoWapFeGy00stQi9y3dxJ8go8M+d2X9vRocDw 9gLjNMPVfGvLbKM/Ha4q875svsQ1PXL5iXmV8V5FMU7yV26FXRJSYinOSDTUYi4qTgQAGtXhx KsCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1508167487!70755570!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35802 invoked from network); 16 Oct 2017 15:24:49 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-14.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Oct 2017 15:24:49 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 16 Oct 2017 09:24:46 -0600 Message-Id: <59E4EB5C0200007800186CF8@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.2 Date: Mon, 16 Oct 2017 09:24:44 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Content-Disposition: inline Cc: Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH] libxc: don't fail domain creation when unpacking initrd fails X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP At least Linux kernels have been able to work with gzip-ed initrd for quite some time; initrd compressed with other methods aren't even being attempted to unpack. Furthermore the unzip-ing routine used here isn't capable of dealing with various forms of concatenated files, each of which was gzip-ed separately (it is this particular case which has been the source of observed VM creation failures). Hence, if unpacking fails, simply hand the the compressed blob to the guest as is. Signed-off-by: Jan Beulich --- I'm not intending to request this to go into 4.10, but I certainly wouldn't mind. I would appreciate though if I could at least get some initial feedback earlier than when 4.10 branches off, as we will want to use a backport of this in our trees, which I'd prefer to be in line with what is eventually going to go into master. --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -291,7 +291,6 @@ int xc_dom_mem_init(struct xc_dom_image int xc_dom_kernel_check_size(struct xc_dom_image *dom, size_t sz); int xc_dom_kernel_max_size(struct xc_dom_image *dom, size_t sz); -int xc_dom_ramdisk_check_size(struct xc_dom_image *dom, size_t sz); int xc_dom_ramdisk_max_size(struct xc_dom_image *dom, size_t sz); int xc_dom_devicetree_max_size(struct xc_dom_image *dom, size_t sz); --- a/tools/libxc/xc_dom_core.c +++ b/tools/libxc/xc_dom_core.c @@ -314,7 +314,8 @@ int xc_dom_kernel_check_size(struct xc_d return 0; } -int xc_dom_ramdisk_check_size(struct xc_dom_image *dom, size_t sz) +static int xc_dom_ramdisk_check_size(struct xc_dom_image *dom, size_t sz, + size_t raw) { /* No limit */ if ( !dom->max_ramdisk_size ) @@ -322,8 +323,9 @@ int xc_dom_ramdisk_check_size(struct xc_ if ( sz > dom->max_ramdisk_size ) { - xc_dom_panic(dom->xch, XC_INVALID_KERNEL, - "ramdisk image too large"); + if ( raw > dom->max_ramdisk_size ) + xc_dom_panic(dom->xch, XC_INVALID_KERNEL, + "ramdisk image too large"); return 1; } @@ -999,13 +1001,13 @@ static int xc_dom_build_ramdisk(struct x { unziplen = xc_dom_check_gzip(dom->xch, dom->ramdisk_blob, dom->ramdisk_size); - if ( xc_dom_ramdisk_check_size(dom, unziplen) != 0 ) + if ( xc_dom_ramdisk_check_size(dom, unziplen, dom->ramdisk_size) != 0 ) unziplen = 0; } else unziplen = 0; - ramdisklen = unziplen ? unziplen : dom->ramdisk_size; + ramdisklen = max(unziplen, dom->ramdisk_size); if ( xc_dom_alloc_segment(dom, &dom->ramdisk_seg, "ramdisk", dom->ramdisk_seg.vstart, ramdisklen) != 0 ) @@ -1017,14 +1019,15 @@ static int xc_dom_build_ramdisk(struct x __FUNCTION__); goto err; } - if ( unziplen ) + if ( !unziplen || + xc_dom_do_gunzip(dom->xch, dom->ramdisk_blob, dom->ramdisk_size, + ramdiskmap, unziplen) == -1 ) { - if ( xc_dom_do_gunzip(dom->xch, dom->ramdisk_blob, dom->ramdisk_size, - ramdiskmap, ramdisklen) == -1 ) - goto err; - } - else memcpy(ramdiskmap, dom->ramdisk_blob, dom->ramdisk_size); + if ( unziplen > dom->ramdisk_size ) + memset(ramdiskmap + dom->ramdisk_size, 0, + unziplen - dom->ramdisk_size); + } return 0;