From nobody Wed May 1 06:40:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599470918; cv=none; d=zohomail.com; s=zohoarc; b=EPApxL6hCLes+6AStG+jt9rCjJrSOnEx2aq1BHTzKX72qvWFzGA7Udl0zjtRgrLtTlR+UlMpbPJceB3n9pO6HDr9LG0cHWDZ5us41GD70CO6uJbRNYpuQWgIiVDBmE0ls8YdLDuA2BDqaekSb7HtMRu0Lg58QRDYU5wfCI8bNF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599470918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=xo6bv48hH09WDdwDkH4nKVl3IpCFoqDfyqZt4dQRDv8=; b=NxrGiOFdBoHxZ1orWwgTGgKWpanWjxzHp801C2ToH2YfS/bEKbLaRcuRh6ymGljrx6Y4ZnRo6kHKF2ScCqPQr6OjqAZBDaWz2BRNPUPVviYRlY6SJTsAPtrS8foA/+3SrkrCzVVaT9c+SBHNn3IQ0NwWbSEhFUKey8/SHp/ABrY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599470918630720.0852850049738; Mon, 7 Sep 2020 02:28:38 -0700 (PDT) Received: from localhost ([::1]:50790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFDS1-0007Hr-22 for importer@patchew.org; Mon, 07 Sep 2020 05:28:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFDRM-0006cv-0f for qemu-devel@nongnu.org; Mon, 07 Sep 2020 05:27:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kFDRK-0003sp-HF for qemu-devel@nongnu.org; Mon, 07 Sep 2020 05:27:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-4Faf8ilDPt-BZEApUHPJMA-1; Mon, 07 Sep 2020 05:27:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D8A8800460; Mon, 7 Sep 2020 09:27:50 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-154.ams2.redhat.com [10.36.114.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A6C410013D7; Mon, 7 Sep 2020 09:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599470873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xo6bv48hH09WDdwDkH4nKVl3IpCFoqDfyqZt4dQRDv8=; b=ZFbVAUtAHYW5HSfZtCGn0o5B9g1DW2Tv2ej8vwjjDY+nYsnvFN3/DjeSsenCSsSRE8Awoc 6k+WZx6NspgS0K/lx+bywHyRxT5niH6agenZrB0nep740AUo1iA+eAQ42Z+GrsHioMkA2o tSpv9xLLhqY3PVSC2bQMz0WuqjTupy4= X-MC-Unique: 4Faf8ilDPt-BZEApUHPJMA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PATCH] file-win32: Fix "locking" option Date: Mon, 7 Sep 2020 11:27:39 +0200 Message-Id: <20200907092739.9988-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/07 05:27:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.099, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, sw@weilnetz.de, luoyonggang@gmail.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The intended behaviour was that locking=3Doff/auto work and have no effect (to remain compatible with file-posix), whereas locking=3Don would return an error. Unfortunately, the code forgot to remove "locking" from the options QDict, so any attempt to use the option would fail. Replace the option parsing code for "locking" with something that is part of the raw_runtime_opts QemuOptsList (so it is properly removed from the QDict) and looks more like file-posix. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- block/file-win32.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/block/file-win32.c b/block/file-win32.c index ab69bd811a..e2900c3a51 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -299,6 +299,11 @@ static QemuOptsList raw_runtime_opts =3D { .type =3D QEMU_OPT_STRING, .help =3D "host AIO implementation (threads, native)", }, + { + .name =3D "locking", + .type =3D QEMU_OPT_STRING, + .help =3D "file locking mode (on/off/auto, default: auto)", + }, { /* end of list */ } }, }; @@ -333,6 +338,7 @@ static int raw_open(BlockDriverState *bs, QDict *option= s, int flags, Error *local_err =3D NULL; const char *filename; bool use_aio; + OnOffAuto locking; int ret; =20 s->type =3D FTYPE_FILE; @@ -343,10 +349,24 @@ static int raw_open(BlockDriverState *bs, QDict *opti= ons, int flags, goto fail; } =20 - if (qdict_get_try_bool(options, "locking", false)) { + locking =3D qapi_enum_parse(&OnOffAuto_lookup, + qemu_opt_get(opts, "locking"), + ON_OFF_AUTO_AUTO, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret =3D -EINVAL; + goto fail; + } + switch (locking) { + case ON_OFF_AUTO_ON: error_setg(errp, "locking=3Don is not supported on Windows"); ret =3D -EINVAL; goto fail; + case ON_OFF_AUTO_OFF: + case ON_OFF_AUTO_AUTO: + break; + default: + g_assert_not_reached(); } =20 filename =3D qemu_opt_get(opts, "filename"); --=20 2.25.4