From patchwork Thu Sep 6 09:37:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 966879 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=208.118.235.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=igalia.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="lrGGVXWG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 425b9V02nvz9s9N for ; Thu, 6 Sep 2018 19:38:38 +1000 (AEST) Received: from localhost ([::1]:60443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxqkF-0005zu-M5 for incoming@patchwork.ozlabs.org; Thu, 06 Sep 2018 05:38:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxqjK-0005j8-Mh for qemu-devel@nongnu.org; Thu, 06 Sep 2018 05:37:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxqjG-0003ac-Qp for qemu-devel@nongnu.org; Thu, 06 Sep 2018 05:37:38 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:54012) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fxqjG-0003Q7-3g; Thu, 06 Sep 2018 05:37:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=cRlBNSZr71aDonFrZWIiaueFM8Gns1d/odRdrwRPHYQ=; b=lrGGVXWGobXqsO76QglqY3ASVwfctRj5qOPDJUyZvZ5aPdTiDiJzxTvYA1z3jTKZWhTyiO3SWbwqtLoeuNWCxSV5qZSmSjQKVWVVGKQq35lmqn2/1pZzHcBJA9irBL6/byCtx2xmGvN2GieHyQZSMFpcqO48NC3g35WBig9LD9Ap4RMq7xYrnArUyKAKZzwSakDqTYL43GtDZ94FquxPWHvbwce1unpMdS88xuFOj+NyRKEu90UJ7kACRMxqbF09+MrcAqFGTdmwH+GE8C9C8G3IUKdb1DXrb6ddr/WKnNsDKlEvQxI1ZpkgSA6Op9iXnWgz+3UHgo1kN3+AIk7xTQ==; Received: from 91-158-71-53.elisa-laajakaista.fi ([91.158.71.53] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fxqjD-00049x-Ii; Thu, 06 Sep 2018 11:37:31 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fxqiz-0001o7-3Z; Thu, 06 Sep 2018 12:37:17 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 6 Sep 2018 12:37:08 +0300 Message-Id: <4e73b26693677b6067545590708adcba66da1c06.1536226505.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v3 08/10] block: Allow changing 'discard' on reopen 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 'discard' is one of the basic BlockdevOptions available for all drivers, but it's not handled by bdrv_reopen_prepare() so any attempt to change it results in an error: (qemu) qemu-io virtio0 "reopen -o discard=on" Cannot change the option 'discard' Since there's no reason why we shouldn't allow changing it and the implementation is simple let's just do it. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block.c b/block.c index 1c0f72454a..bd8467bed8 100644 --- a/block.c +++ b/block.c @@ -3155,6 +3155,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, BlockDriver *drv; QemuOpts *opts; QDict *orig_reopen_opts; + char *discard = NULL; bool read_only; assert(reopen_state != NULL); @@ -3177,6 +3178,15 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, update_flags_from_options(&reopen_state->flags, opts); + discard = qemu_opt_get_del(opts, "discard"); + if (discard != NULL) { + if (bdrv_parse_discard_flags(discard, &reopen_state->flags) != 0) { + error_setg(errp, "Invalid discard option"); + ret = -EINVAL; + goto error; + } + } + /* All other options (including node-name and driver) must be unchanged. * Put them back into the QDict, so that they are checked at the end * of this function. */ @@ -3290,6 +3300,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, error: qemu_opts_del(opts); qobject_unref(orig_reopen_opts); + g_free(discard); return ret; }