From nobody Mon Feb 9 23:01:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529377872584216.50468673095088; Mon, 18 Jun 2018 20:11:12 -0700 (PDT) Received: from localhost ([::1]:38923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV72z-0002FN-VS for importer@patchew.org; Mon, 18 Jun 2018 23:11:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jQ-0002z2-V8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jQ-0000nU-0n for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:53 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:43937) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jP-0000nI-Rp; Mon, 18 Jun 2018 21:46:51 -0400 Received: by mail-oi0-x22e.google.com with SMTP id t133-v6so16697998oif.10; Mon, 18 Jun 2018 18:46:51 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s22-v6sm10292724ote.14.2018.06.18.18.46.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fdNqkFcsS1Ole0HvZZCC/+O6h6J/pwPhpCO2sqQl6Uo=; b=YQ7Q+MTbt5T3mn8Hlhes5Ocrpw7f5oU8u93DABV6uNPz0H9uZzQBPXCHKZGlVpxvXv ZvluCJcrnVFnHW3ZB0JOT1kipTnXYxMp0lYC6nlD0pBqt9R5mRM66lgm0aFyELNTbTdM it5B5Io0C8yBm69hyX2smuGOSFha3SaQS8A9xgSw7Hp/za9LWlV8BMiDcC0Olc+7eejh eTwLWVCo41P2o2moP33b7jwGMqopfHuUErowHSgKxVB96uqFv71vsg5QwLEcnr2A/GCD ThOf8TGh8eNRVWV7m1Mu1lSNk1/eWIYFFKY+ffIFCyUGCr0POYF++Ld/M3R5wnILb1/q Qjxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=fdNqkFcsS1Ole0HvZZCC/+O6h6J/pwPhpCO2sqQl6Uo=; b=EeZZcxS7r62g1AszWQ0Y/X6kjYUtzahdneVHG3/McqENUWA2OJVupXrjb6D0esRuT+ G4S4YDzOWEW2dPE8efZ3HH2OLwrg4YXmA6dHCUzj6iDpGo0EluWvy2u+2S56yvXJ+Tue VjkwhTHFN2Qmhjmj+s2iXqAClYEP5OnKzMTu22sr4t6WgePCnvjkO0NinfB6K0rR6YIQ PpoWY1/mo7sCt+ArixbBWif05iIVHQbEqeKpHvR87vhyIlLMNC7aC/2tBzQapJ2BScDS CeUldxP7cjw3O94ztziVwxY/7xrDnqa7IbeT9OBTxeqopAFsjYQfJThIeviPc7nQki2x 4HMA== X-Gm-Message-State: APt69E0q8AFB86LR88gYohH7lLuyCZO2W1KdaLXuY6SfHlzNJCtXvatr wjpkTuuWBSEeaAoncqCIJlvRLTU1kWU= X-Google-Smtp-Source: ADUXVKLV8x2zm78eigCDPkwpos0/Q+1jULQX6xXVh4W+kPtveznDsASRdlIjyKaYg6eM5eVvua9EgQ== X-Received: by 2002:aca:496:: with SMTP id 144-v6mr8625291oie.275.1529372810725; Mon, 18 Jun 2018 18:46:50 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:39 -0500 Message-Id: <20180619014319.28272-74-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22e Subject: [Qemu-devel] [PATCH 073/113] qemu-img: Use only string options in img_open_opts 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-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Max Reitz img_open_opts() takes a QemuOpts and converts them to a QDict, so all values therein are strings. Then it may try to call qdict_get_bool(), however, which will fail with a segmentation fault every time: $ ./qemu-img info -U --image-opts \ driver=3Dfile,filename=3D/dev/null,force-share=3Doff [1] 27869 segmentation fault (core dumped) ./qemu-img info -U --image-opts driver=3Dfile,filename=3D/dev/null,force-share=3Doff Fix this by using qdict_get_str() and comparing the value as a string. Also, when adding a force-share value to the QDict, add it as a string so it fits the rest of the dict. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180502202051.15493-3-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz (cherry picked from commit 4615f87832d2fcb7a544bedeece2741bf8c21f94) Signed-off-by: Michael Roth --- qemu-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 03da42dae2..86060aab71 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -276,12 +276,12 @@ static BlockBackend *img_open_opts(const char *optstr, options =3D qemu_opts_to_qdict(opts, NULL); if (force_share) { if (qdict_haskey(options, BDRV_OPT_FORCE_SHARE) - && !qdict_get_bool(options, BDRV_OPT_FORCE_SHARE)) { + && strcmp(qdict_get_str(options, BDRV_OPT_FORCE_SHARE), "on"))= { error_report("--force-share/-U conflicts with image options"); QDECREF(options); return NULL; } - qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true); + qdict_put_str(options, BDRV_OPT_FORCE_SHARE, "on"); } blk =3D blk_new_open(NULL, NULL, options, flags, &local_err); if (!blk) { --=20 2.11.0