{"id":2197762,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2197762/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260218132633.29748-16-hreitz@redhat.com>","date":"2026-02-18T13:26:24","name":"[v4,15/24] block: Move qemu_fcntl_addfl() into osdep.c","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b3d745861990d6127793f2c6c64c7d18f7199362","submitter":{"id":82279,"url":"http://patchwork.ozlabs.org/api/1.0/people/82279/?format=json","name":"Hanna Czenczek","email":"hreitz@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260218132633.29748-16-hreitz@redhat.com/mbox/","series":[{"id":492547,"url":"http://patchwork.ozlabs.org/api/1.0/series/492547/?format=json","date":"2026-02-18T13:26:09","name":"export/fuse: Use coroutines and multi-threading","version":4,"mbox":"http://patchwork.ozlabs.org/series/492547/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2197762/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=NIgSMuTf;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=Qdk6/Xq3;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fGHbg35K8z1xpY\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 19 Feb 2026 00:36:31 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vshfg-0004HK-KN; Wed, 18 Feb 2026 08:32:52 -0500","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <hreitz@redhat.com>) id 1vshfZ-000465-Fi\n for qemu-devel@nongnu.org; Wed, 18 Feb 2026 08:32:46 -0500","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <hreitz@redhat.com>) id 1vshfL-0005eo-7y\n for qemu-devel@nongnu.org; Wed, 18 Feb 2026 08:32:45 -0500","from mail-wm1-f69.google.com (mail-wm1-f69.google.com\n [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-250-6VMkZD4ZOeuX7w_UEyMf9g-1; Wed, 18 Feb 2026 08:27:22 -0500","by mail-wm1-f69.google.com with SMTP id\n 5b1f17b1804b1-4806cfffca6so59699385e9.2\n for <qemu-devel@nongnu.org>; Wed, 18 Feb 2026 05:27:22 -0800 (PST)","from localhost\n (p200300cfd737d029edef7b8da7441ac2.dip0.t-ipconnect.de.\n [2003:cf:d737:d029:edef:7b8d:a744:1ac2])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48387ab1974sm207441865e9.3.2026.02.18.05.27.19\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 18 Feb 2026 05:27:20 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1771421550;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=8xXGf9wQuXiSKLxPb3FYIBG/K87QsiFd36ndnCqGkII=;\n b=NIgSMuTfWBwOHSm+OI3lXnF7gfZ/gVy+USj69XECvqFltayaAS34yyAIAD0AeT1/ERUE4z\n m+WGmFxqfRgUOWX4/80SKcI+MtVqflFo53aLpbhJfOo8ZF7YBf3+YeWCsYe6fGhj4arXYx\n W91cBcwT/zPkmfTcCGeLhGFnFdVjkSQ=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1771421241; x=1772026041; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=8xXGf9wQuXiSKLxPb3FYIBG/K87QsiFd36ndnCqGkII=;\n b=Qdk6/Xq3YbV9wEOTk9iRs6ZRws1ySI+DzBuDN31fixqmL/uuEygtbxJqjnjDUKNVhn\n UPvnNoK29mG0Ptva0deMWrGlJWCUEpBqVIdT0VBd2pEi9udEYlOmrNHp0WRzV4REnHLZ\n EIykGYM1fRFrHZW/xMslxXcISCqkAF6z/jru19rbnom0dQdCU/8tUnEYXGLU1vrx/gUZ\n NzS/gqYLWFxoN04kO6IHb30dKdFpDE61ifM4HH4c9YlWsHvDNAH8UnqanOsRTDSgXwpt\n lpSfkpdbCjTsbdoJ+oPsi1O1tAVh6/iN3R97VFuRjfPfQhs4vQ3BrYL3WCMrbBTo79x6\n iSSw=="],"X-MC-Unique":"6VMkZD4ZOeuX7w_UEyMf9g-1","X-Mimecast-MFC-AGG-ID":"6VMkZD4ZOeuX7w_UEyMf9g_1771421242","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1771421241; x=1772026041;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=8xXGf9wQuXiSKLxPb3FYIBG/K87QsiFd36ndnCqGkII=;\n b=DKiudhNuaFgmmcJ6sJJss8j9sw+xaOC1ecdDFuij8Cne70tbL43jAL4U0awEy+EGEa\n OfXYQ7ecRrkdJR+g5TqKStBUzHaY/LPrxO/mrtBsEoOFFzT2UECvibi+u3Fc+LMzEf49\n 9qpslpYEAZS9HZNmXHLW1p6zLxfNHQIe6so7CqOcwQ6Nvg3qEt8TAWSYsPYNzpwg4neR\n bTm7L4qT5b4w7R+yaydOSkAw3dvYEYSqotRDDbZ/SSVlLZWJKXHGlQ/6IB5fZlMy85II\n zxqGPpnKM70e1TpSY/LzA+1pDWzmqwVsecJ02SSdM4vn3c+XchDgOLRw4NWAU/XIy55s\n Kt+Q==","X-Gm-Message-State":"AOJu0Yy/QciD5a7wUl5jgXnz1+S9KbFzXHjEIqiT8fb68JxxkwpOMCXZ\n wyjilA8B+FpnPgI2PRwUfjhzRsr87pR5vIHdQScq9zcuTWlXXGk6eCoARKktdmTC6Bk2mw1mSUx\n YfFWISL98pxP3bYuXrOr8AOfFge0HORWjZClb4MePc2Zi4LSS0fXva6LM","X-Gm-Gg":"AZuq6aICf+0FDJ6nVviPyFVeTZizsP8w8LAXysbNVmBX3tfiXqaQem1ISDBEwElLDUQ\n AfaQmkbytfTAGmlmqSLbBm4yvT9oemjhLZLTb22bx87m3W2EfFuSoDR16rqtGsSDRxQ1HddS+15\n qaBq93BrT/4BDyWsLWP2sCQzYGkM3nqtk3ZsdEfWPvzneSfkUp3u2H84TQQ9YwpM+rHzJSMm2oA\n k7U5iNo+aB6k/Yb3K76txDtCX4F7HQ88u290p+MYbML35qPIHO7M6XaMrIHOW9JrKNI9cQhWhIG\n hVj6dCS9coOvoHEAsjOXLYvLps1uUvH4ihdesX+rlOEBo/LKZPFrtrqM4Xo5eekhBq+5xQ248yg\n trfjP8yiEzheYs1S4OoksfNVZnT7WA5HJWbSjA5o/8C/3TTJaJXc5hCTlpzRlUDM5ux2U0h3Eio\n MSkIZu","X-Received":["by 2002:a05:600c:148f:b0:483:7f7c:ad89 with SMTP id\n 5b1f17b1804b1-4837f7cb108mr162399005e9.37.1771421241476;\n Wed, 18 Feb 2026 05:27:21 -0800 (PST)","by 2002:a05:600c:148f:b0:483:7f7c:ad89 with SMTP id\n 5b1f17b1804b1-4837f7cb108mr162398695e9.37.1771421241028;\n Wed, 18 Feb 2026 05:27:21 -0800 (PST)"],"From":"Hanna Czenczek <hreitz@redhat.com>","To":"qemu-block@nongnu.org","Cc":"qemu-devel@nongnu.org, Hanna Czenczek <hreitz@redhat.com>,\n Kevin Wolf <kwolf@redhat.com>, Brian Song <hibriansong@gmail.com>","Subject":"[PATCH v4 15/24] block: Move qemu_fcntl_addfl() into osdep.c","Date":"Wed, 18 Feb 2026 14:26:24 +0100","Message-ID":"<20260218132633.29748-16-hreitz@redhat.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260218132633.29748-1-hreitz@redhat.com>","References":"<20260218132633.29748-1-hreitz@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Move file-posix's helper to add a flag (or a set of flags) to an FD's\nexisting set of flags into osdep.c for other places to use.\n\nSuggested-by: Eric Blake <eblake@redhat.com>\nSigned-off-by: Hanna Czenczek <hreitz@redhat.com>\n---\n include/qemu/osdep.h |  1 +\n block/file-posix.c   | 17 +----------------\n util/osdep.c         | 18 ++++++++++++++++++\n 3 files changed, 20 insertions(+), 16 deletions(-)","diff":"diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h\nindex b384b5b506..f151578b5c 100644\n--- a/include/qemu/osdep.h\n+++ b/include/qemu/osdep.h\n@@ -633,6 +633,7 @@ int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive);\n int qemu_unlock_fd(int fd, int64_t start, int64_t len);\n int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive);\n bool qemu_has_ofd_lock(void);\n+int qemu_fcntl_addfl(int fd, int flag);\n #endif\n \n bool qemu_has_direct_io(void);\ndiff --git a/block/file-posix.c b/block/file-posix.c\nindex 6265d2e248..e49b13d6ab 100644\n--- a/block/file-posix.c\n+++ b/block/file-posix.c\n@@ -1056,21 +1056,6 @@ static int raw_handle_perm_lock(BlockDriverState *bs,\n     return ret;\n }\n \n-/* Sets a specific flag */\n-static int fcntl_setfl(int fd, int flag)\n-{\n-    int flags;\n-\n-    flags = fcntl(fd, F_GETFL);\n-    if (flags == -1) {\n-        return -errno;\n-    }\n-    if (fcntl(fd, F_SETFL, flags | flag) == -1) {\n-        return -errno;\n-    }\n-    return 0;\n-}\n-\n static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,\n                                  int *open_flags, uint64_t perm, Error **errp)\n {\n@@ -1109,7 +1094,7 @@ static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,\n         /* dup the original fd */\n         fd = qemu_dup(s->fd);\n         if (fd >= 0) {\n-            ret = fcntl_setfl(fd, *open_flags);\n+            ret = qemu_fcntl_addfl(fd, *open_flags);\n             if (ret) {\n                 qemu_close(fd);\n                 fd = -1;\ndiff --git a/util/osdep.c b/util/osdep.c\nindex 770369831b..000e7daac8 100644\n--- a/util/osdep.c\n+++ b/util/osdep.c\n@@ -280,6 +280,24 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive)\n         return fl.l_type == F_UNLCK ? 0 : -EAGAIN;\n     }\n }\n+\n+/**\n+ * Set the given flag(s) (fcntl GETFL/SETFL) on the given FD, while retaining\n+ * other flags.\n+ */\n+int qemu_fcntl_addfl(int fd, int flag)\n+{\n+    int flags;\n+\n+    flags = fcntl(fd, F_GETFL);\n+    if (flags == -1) {\n+        return -errno;\n+    }\n+    if (fcntl(fd, F_SETFL, flags | flag) == -1) {\n+        return -errno;\n+    }\n+    return 0;\n+}\n #endif\n \n bool qemu_has_direct_io(void)\n","prefixes":["v4","15/24"]}