From nobody Wed May 1 22:40:15 2024 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; dmarc=fail(p=none dis=none) header.from=163.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 154483740560493.6919001542783; Fri, 14 Dec 2018 17:30:05 -0800 (PST) Received: from localhost ([::1]:37128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXymF-000778-Pq for importer@patchew.org; Fri, 14 Dec 2018 20:29:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXykZ-0005B0-8N for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXykU-0003Me-92 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:15 -0500 Received: from m12-13.163.com ([220.181.12.13]:55494) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXykT-0003L4-Cb for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:10 -0500 Received: from localhost.localdomain (unknown [183.134.170.47]) by smtp9 (Coremail) with SMTP id DcCowABHyuiIWBRcdawzAA--.1809S3; Sat, 15 Dec 2018 09:27:43 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=9uiheijUBL6iX8+Kle gwuTrISrnD/t5S19mVFL7vMfY=; b=TD0AKobg32tEVdqoez3l3Oz4iTw6Ta2i0+ pz4ojhPzc/SH/H3l9U5xVDBqQX4+Wdo32qgNX3IN3vIw/IbF6klBpalM/zUCqgQN Di/HtAWlo2Bcm52QV2BFQmJj9VVpQ4GFdxlDZ/VMnVHSvAVlkgIKlzSDO5q2ev1X R33JCUfNY= From: Li Qiang To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, mst@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, jasowang@redhat.com Date: Fri, 14 Dec 2018 17:26:23 -0800 Message-Id: <20181215012625.73315-2-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181215012625.73315-1-liq3ea@163.com> References: <20181215012625.73315-1-liq3ea@163.com> X-CM-TRANSID: DcCowABHyuiIWBRcdawzAA--.1809S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrZF45AF4xJw1kKFWkGw47twb_yoWxtrg_Za 13XFs7Wr47Cr1Y9r45Xw45AF43Jay7JF1xZa4ftFy7GF47tw13Ja1v9rn7JFyfWa13JF9F vws5tr10kF42qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjG2MUUUUUU== X-Originating-IP: [183.134.170.47] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBaw8ebVettPeCLQAAsB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH 1/3] tests: vhost-user-test: initialize 'fd' in chr_read 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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currentyly when processing VHOST_USER_SET_VRING_CALL if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will be a stack uninitialized value. Signed-off-by: Li Qiang --- tests/vhost-user-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 45d58d8ea2..86039e61e0 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t *buf, = int size) CharBackend *chr =3D &s->chr; VhostUserMsg msg; uint8_t *p =3D (uint8_t *) &msg; - int fd; + int fd =3D -1; =20 if (s->test_fail) { qemu_chr_fe_disconnect(chr); --=20 2.17.1 From nobody Wed May 1 22:40:15 2024 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; dmarc=fail(p=none dis=none) header.from=163.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544837405606737.8797936319252; Fri, 14 Dec 2018 17:30:05 -0800 (PST) Received: from localhost ([::1]:37126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXymB-00075m-25 for importer@patchew.org; Fri, 14 Dec 2018 20:29:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXykZ-0005Az-8H for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXykU-0003Mk-9f for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:15 -0500 Received: from m12-13.163.com ([220.181.12.13]:55608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXykT-0003Lz-K4 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:10 -0500 Received: from localhost.localdomain (unknown [183.134.170.47]) by smtp9 (Coremail) with SMTP id DcCowABHyuiIWBRcdawzAA--.1809S4; Sat, 15 Dec 2018 09:27:45 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=36hz3coVG0bJudF+fD pvL6mTiTtrlQ25CeShgRqagiU=; b=njkB0ZjXPT4uPLy/yfsPPOjSwNwqrsyYel nBduBu+fpQmG+eYAgP3c8guhHc5aDSpuhLZvjNyOsnBM+1ZWeYl8tX0uc4sLewVL 646lj6cx1SNW0x3AHuzwIQ8frX22FrafndjzO2HOn+Ps6sdKebpBLAS4+uS7TWMc UbNB0FZQA= From: Li Qiang To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, mst@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, jasowang@redhat.com Date: Fri, 14 Dec 2018 17:26:24 -0800 Message-Id: <20181215012625.73315-3-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181215012625.73315-1-liq3ea@163.com> References: <20181215012625.73315-1-liq3ea@163.com> X-CM-TRANSID: DcCowABHyuiIWBRcdawzAA--.1809S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xr1kKryUtFyUGFy5XFWDArb_yoWkJrg_Aa 17JFZ7WFyUXF1q9ayUAw4FqrW3Ka13JF18XayrAF4xZryUKw13Gan5Zrn5Aay5ursrur93 ZrykAryUWr1akjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUji0eJUUUUU== X-Originating-IP: [183.134.170.47] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBoREebVQHC1ED4QAAso X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH 2/3] vhost-user: add fds inf 'vhost_set_vring_file' in qtest 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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently, the vhost-user-test assumes the eventfd is available. However it's not true because the accel is qtest. So the 'vhost_set_vring_file' will not add fds to the msg and the server side of vhost-user-test will be broken. This patch avoid this. Signed-off-by: Li Qiang --- hw/virtio/vhost-user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e09bed0e4a..3b666f093c 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -23,6 +23,7 @@ #include "migration/migration.h" #include "migration/postcopy-ram.h" #include "trace.h" +#include "sysemu/qtest.h" =20 #include #include @@ -742,7 +743,7 @@ static int vhost_set_vring_file(struct vhost_dev *dev, .hdr.size =3D sizeof(msg.payload.u64), }; =20 - if (ioeventfd_enabled() && file->fd > 0) { + if ((qtest_enabled() || ioeventfd_enabled()) && file->fd > 0) { fds[fd_num++] =3D file->fd; } else { msg.payload.u64 |=3D VHOST_USER_VRING_NOFD_MASK; --=20 2.17.1 From nobody Wed May 1 22:40:15 2024 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; dmarc=fail(p=none dis=none) header.from=163.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544837407010838.0125548303486; Fri, 14 Dec 2018 17:30:07 -0800 (PST) Received: from localhost ([::1]:37127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXymC-00076L-2w for importer@patchew.org; Fri, 14 Dec 2018 20:29:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXykZ-0005B1-8L for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXykV-0003Nd-P6 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:15 -0500 Received: from m12-13.163.com ([220.181.12.13]:55668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXykV-0003MW-1v for qemu-devel@nongnu.org; Fri, 14 Dec 2018 20:28:11 -0500 Received: from localhost.localdomain (unknown [183.134.170.47]) by smtp9 (Coremail) with SMTP id DcCowABHyuiIWBRcdawzAA--.1809S5; Sat, 15 Dec 2018 09:27:46 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=HyQk4ackbckjxRsWO3 np1LMqXrC1YBfoAnh8qIKzdxY=; b=m2EeCJKs/RqffsbD8XNYQCNe+VLYDJP4T4 8xANKrF8XBRVG4GYgaDH/Z40I6sDVZNMuyBsF41gauisR3OSaqfmgOtNbA4f2obc RPzlWbVd+eyiYQ/xcv/cPqYkZvcs5L3xl9bwr3T67jv5TndAnf/90BWI0/yABHJq eKssT7dYw= From: Li Qiang To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, mst@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, jasowang@redhat.com Date: Fri, 14 Dec 2018 17:26:25 -0800 Message-Id: <20181215012625.73315-4-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181215012625.73315-1-liq3ea@163.com> References: <20181215012625.73315-1-liq3ea@163.com> X-CM-TRANSID: DcCowABHyuiIWBRcdawzAA--.1809S5 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jw1kKF4kKw4fGr45KFyUJrb_yoW3uwc_GF W2yrs5XFyUZ3ySya4qg3y5AFZagrWrGrWxZF1aqryfXrn8u3Z8GF4UZryrWrsxWayxX3WU C34I9F43CFnxtjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU820P3UUUUU== X-Originating-IP: [183.134.170.47] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiKRIebVXlo--C1AAAsy X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH 3/3] util: check the return value of fcntl in qemu_set_{block, nonblock} 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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Assert that the return value is not an error. This is like commit 7e6478e7d4f for qemu_set_cloexec. Signed-off-by: Li Qiang --- util/oslib-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index c1bee2a581..4ce1ba9ca4 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -233,14 +233,18 @@ void qemu_set_block(int fd) { int f; f =3D fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f !=3D -1); + f =3D fcntl(fd, F_SETFL, f & ~O_NONBLOCK); + assert(f !=3D -1); } =20 void qemu_set_nonblock(int fd) { int f; f =3D fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f !=3D -1); + f =3D fcntl(fd, F_SETFL, f | O_NONBLOCK); + assert(f !=3D -1); } =20 int socket_set_fast_reuse(int fd) --=20 2.17.1