From nobody Sun May 5 14:21:27 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=1605479337; cv=none; d=zohomail.com; s=zohoarc; b=mlM1LgWbOMmZ4bHugBAg7NvNDJlZj1Zi3mfoGAVodGHSSMa5a5HHWsLnlxod09rzXRjxeiMJxMpls+vQMmcdOkXKlm6AO5b5Lp1p2Xih/9M72jdATaCwcrcxA9L3t+Su4KctybWYxQR4opVWm3RMCESlxcR/KeXtX3NT9SbHEXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479337; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sut9Fzws5tusu6SI48So6UTIt/7CxEKNGpGPWzrkgbI=; b=AOAvnrXLPWZRMpflSjoT7cQabEw5400V/khpNw2fd9GFA0UfJmyQfNY3w8sI9v5bclHxCYWdYk/fy4JflPmOVPdCa6ZwcGVioVTXIa3w+Y2UeHglVepxC0sP1LZZxsUBxOaEVFhZ1jInlXxSIECrn42MabJLoTS6NEtf+TZvkiA= 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 160547933778894.96171743962043; Sun, 15 Nov 2020 14:28:57 -0800 (PST) Received: from localhost ([::1]:59044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQVy-0001cy-Ld for importer@patchew.org; Sun, 15 Nov 2020 17:28:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUU-0008Qx-6m for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUQ-0001Xk-3u for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:21 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-284-2Vgj7XAZMAiAbYun4g4r8w-1; Sun, 15 Nov 2020 17:27:14 -0500 Received: by mail-wr1-f71.google.com with SMTP id w5so7727220wrm.22 for ; Sun, 15 Nov 2020 14:27:14 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id c8sm19306759wrv.26.2020.11.15.14.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479237; 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: in-reply-to:in-reply-to:references:references; bh=Sut9Fzws5tusu6SI48So6UTIt/7CxEKNGpGPWzrkgbI=; b=eGskbal9uJi1wiAM4iDaDnPGRQ5PQlv3Ye4a5F7okWsOP3vug0ZQR9mcF6LHpFB0lo4Qus PtEjtA63+pLnXTSeMC8qgZW360TGCcDXseDu/0STXtvrtwC5JSWlIEoj8Xi8GLhmv1/R/0 nR9wg8PNjZliJshGn73ysOvKtQVFOwY= X-MC-Unique: 2Vgj7XAZMAiAbYun4g4r8w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Sut9Fzws5tusu6SI48So6UTIt/7CxEKNGpGPWzrkgbI=; b=HEja4vkY18UwT3HgYdR240dPecUpamG4QX/JJEtbyX8j7TmuWaIpVgfsflh+aSLATj 9XJZKrmbPSkJvO7pVgRL33bivti6LgKfXj+UyW+B25O8BPk/JVR6/IjkM+5ootMs1GnT Cu2fD+saQiJUUTdvMZMW/Jd6VUlKSGkSiuGEGzsvJ7falBHzGCBRFw11QTCqr0YH4D2N F3V/sInEM3M4vfYKVHJLkhFstIX5TY5oorRNCTsHHIJEq8bbEdTQhuEGwrqvbU9THcd6 oLiLVZBzauoYaRhNA9/D8ZXnFjIH0fclZOespREXM41O+IPRvF2hZTxjiW1f+/20+aWx 1dZg== X-Gm-Message-State: AOAM531+2gq6vatds9urslHsuMFW9XZRWwUZ07r0RdjdGtlqOnVX4hqV T15LKUnPi4R8pvLyqSSDakRw31FRbD6a0mqBC9oje1qXhKMlLWieR6SmTWJKY4W/dunVaBKekr7 n5Mubxtl0Kwo7scK+aqgrCy/V5Uc2HTIN6ex/d41qnKLPOfCoFo6mUsWkemRv X-Received: by 2002:adf:e607:: with SMTP id p7mr15578431wrm.93.1605479233267; Sun, 15 Nov 2020 14:27:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7lFqC02l6oIJYz5BVUD12zuDh8Eu7bQGMBxFHvmK48jnVJK4If9GT/3iOOv2UfPG9cUdQmQ== X-Received: by 2002:adf:e607:: with SMTP id p7mr15578413wrm.93.1605479233027; Sun, 15 Nov 2020 14:27:13 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/17] vhost-user: fix VHOST_USER_ADD/REM_MEM_REG truncation Message-ID: <20201115220740.488850-2-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=ham 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: Peter Maydell , Cornelia Huck , Christian Borntraeger , Stefan Hajnoczi , Raphael Norwitz 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi QEMU currently truncates the mmap_offset field when sending VHOST_USER_ADD_MEM_REG and VHOST_USER_REM_MEM_REG messages. The struct layout looks like this: typedef struct VhostUserMemoryRegion { uint64_t guest_phys_addr; uint64_t memory_size; uint64_t userspace_addr; uint64_t mmap_offset; } VhostUserMemoryRegion; typedef struct VhostUserMemRegMsg { uint32_t padding; /* WARNING: there is a 32-bit hole here! */ VhostUserMemoryRegion region; } VhostUserMemRegMsg; The payload size is calculated as follows when sending the message in hw/virtio/vhost-user.c: msg->hdr.size =3D sizeof(msg->payload.mem_reg.padding) + sizeof(VhostUserMemoryRegion); This calculation produces an incorrect result of only 36 bytes. sizeof(VhostUserMemRegMsg) is actually 40 bytes. The consequence of this is that the final field, mmap_offset, is truncated. This breaks x86_64 TCG guests on s390 hosts. Other guest/host combinations may get lucky if either of the following holds: 1. The guest memory layout does not need mmap_offset !=3D 0. 2. The host is little-endian and mmap_offset <=3D 0xffffffff so the truncation has no effect. Fix this by extending the existing 32-bit padding field to 64-bit. Now the padding reflects the actual compiler padding. This can be verified using pahole(1). Also document the layout properly in the vhost-user specification. The vhost-user spec did not document the exact layout. It would be impossible to implement the spec without looking at the QEMU source code. Existing vhost-user frontends and device backends continue to work after this fix has been applied. The only change in the wire protocol is that QEMU now sets hdr.size to 40 instead of 36. If a vhost-user implementation has a hardcoded size check for 36 bytes, then it will fail with new QEMUs. Both QEMU and DPDK/SPDK don't check the exact payload size, so they continue to work. Fixes: f1aeb14b0809e313c74244d838645ed25e85ea63 ("Transmit vhost-user memor= y regions individually") Cc: Raphael Norwitz Cc: Cornelia Huck Cc: Michael S. Tsirkin Cc: Christian Borntraeger Signed-off-by: Stefan Hajnoczi Message-Id: <20201109174355.1069147-1-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Fixes: f1aeb14b0809 ("Transmit vhost-user memory regions individually") Reviewed-by: Cornelia Huck Reviewed-by: Raphael Norwitz --- contrib/libvhost-user/libvhost-user.h | 2 +- hw/virtio/vhost-user.c | 5 ++--- docs/interop/vhost-user.rst | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/= libvhost-user.h index a1539dbb69..7d47f1364a 100644 --- a/contrib/libvhost-user/libvhost-user.h +++ b/contrib/libvhost-user/libvhost-user.h @@ -136,7 +136,7 @@ typedef struct VhostUserMemory { } VhostUserMemory; =20 typedef struct VhostUserMemRegMsg { - uint32_t padding; + uint64_t padding; VhostUserMemoryRegion region; } VhostUserMemRegMsg; =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 9c5b4f7fbc..2fdd5daf74 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -149,7 +149,7 @@ typedef struct VhostUserMemory { } VhostUserMemory; =20 typedef struct VhostUserMemRegMsg { - uint32_t padding; + uint64_t padding; VhostUserMemoryRegion region; } VhostUserMemRegMsg; =20 @@ -800,8 +800,7 @@ static int vhost_user_add_remove_regions(struct vhost_d= ev *dev, uint64_t shadow_pcb[VHOST_USER_MAX_RAM_SLOTS] =3D {}; int nr_add_reg, nr_rem_reg; =20 - msg->hdr.size =3D sizeof(msg->payload.mem_reg.padding) + - sizeof(VhostUserMemoryRegion); + msg->hdr.size =3D sizeof(msg->payload.mem_reg); =20 /* Find the regions which need to be removed or added. */ scrub_shadow_regions(dev, add_reg, &nr_add_reg, rem_reg, &nr_rem_reg, diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 988f154144..6d4025ba6a 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -131,6 +131,23 @@ A region is: =20 :mmap offset: 64-bit offset where region starts in the mapped memory =20 +Single memory region description +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ++---------+---------------+------+--------------+-------------+ +| padding | guest address | size | user address | mmap offset | ++---------+---------------+------+--------------+-------------+ + +:padding: 64-bit + +:guest address: a 64-bit guest address of the region + +:size: a 64-bit size + +:user address: a 64-bit user address + +:mmap offset: 64-bit offset where region starts in the mapped memory + Log description ^^^^^^^^^^^^^^^ =20 @@ -1281,7 +1298,7 @@ Master message types ``VHOST_USER_ADD_MEM_REG`` :id: 37 :equivalent ioctl: N/A - :slave payload: memory region + :slave payload: single memory region description =20 When the ``VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS`` protocol feature has been successfully negotiated, this message is submitted @@ -1296,7 +1313,7 @@ Master message types ``VHOST_USER_REM_MEM_REG`` :id: 38 :equivalent ioctl: N/A - :slave payload: memory region + :slave payload: single memory region description =20 When the ``VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS`` protocol feature has been successfully negotiated, this message is submitted --=20 MST From nobody Sun May 5 14:21:27 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=1605479516; cv=none; d=zohomail.com; s=zohoarc; b=nJE5fpVEPcm+dwsU/+sjiQhSf0f4nlfLWdChw4cwHYTDBm70K6hpEYawIvD63dMb9TX0hhWw7u/BsjhDpkq8aG1VTNXkx8IhgtEnOymEB+YQGT+1CMouy/41XsIGBUHTqKaTyXluNfU4vzGXfcaq86A1a7zbxoAkAx7ByTDnbKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479516; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0RnLT5+JMl+oOfkBbmmWTI1h88S6MNDyRCGrZS7inZw=; b=EvCB44xvC7XoOpmqwqvH0pK6TB5oK/fR5FphCTnQ4d1rPMst08qamrO7jnEK6SgNFPrS5p7IjINTMiT/rVlOA9US7IN4pP6wjAr7chMnEXmN9eCfOj4zMngmdAmzcX7Oyi3/zcWDihx+l2nAn92qYNeZs14zBZLD6YIJ6V+/mgA= 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 1605479516947393.65878273193186; Sun, 15 Nov 2020 14:31:56 -0800 (PST) Received: from localhost ([::1]:39294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQYt-0005Je-R3 for importer@patchew.org; Sun, 15 Nov 2020 17:31:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUU-0008R3-IW for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUS-0001Xo-72 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:22 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-JUK-hhzkOVqCEZHCfoe0ng-1; Sun, 15 Nov 2020 17:27:17 -0500 Received: by mail-wr1-f69.google.com with SMTP id n4so9008188wrt.8 for ; Sun, 15 Nov 2020 14:27:17 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id k16sm3935270wro.79.2020.11.15.14.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479239; 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: in-reply-to:in-reply-to:references:references; bh=0RnLT5+JMl+oOfkBbmmWTI1h88S6MNDyRCGrZS7inZw=; b=BRjwneLJfYPWiNvYee+wZFVMesLzLCXzY0YJIeC0ObPSQMqJJjJiQhAY9K9UTAvtcoNFcO zYePjVLHbvzXx+JaxIOjekrl+hq/1779DDTq7Cb9ULtQu36pNuaB3EOYWkBqicxB8wUGP4 oDJqbpZgJFpSNR48+GssUq1BFBaQV7g= X-MC-Unique: JUK-hhzkOVqCEZHCfoe0ng-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=0RnLT5+JMl+oOfkBbmmWTI1h88S6MNDyRCGrZS7inZw=; b=FIVBYcBou6az5ioT20fzUYWmU83oDebYTUvDeGq1L9rMwrzGLz4ysF40+DItKJMLUl sZCr2hOebllu0IkXmn0Pj8+1aZtpbckpqvCkjaXK81SmF/vWH4wCy4f4tm59uDMkbbqq r+AJaurnSADn8PRDYL7x+0uBJ7ru83ZSm+GS9k0G1DDxCz3fYrxsgvTh7OkRWSeIpf/U VQLzL1zNap1c/ASYZ4GZUGoK9U1+4T7jFuxsGdqK65dbYWT67YZnoSenHnlRknk/iOXX TBY7e0suHtl9olZnDE6HwyQUnlrvu/aBbIBgJYT8NJchtkdPeJVZFCZDIcyvHPMPgVTv 8hrg== X-Gm-Message-State: AOAM530q9ckkuSvebpnuC00wQ8ntRhzS45NsqxeNhDPMhg+1KCTxC3Nr 2LfTM43zOT8gEJ6nu0ozN+yddpCAye/OUjZfdAy4TAohOSB9CZqxPmFRJ0kYpZFijgbp32cDywv HM3QxYDeK7eM+WQcLVxnS2GPPqdQByN3J26Ls7oxj2xhVWuauSBb5CIUiPT69 X-Received: by 2002:a1c:7202:: with SMTP id n2mr11963835wmc.38.1605479236117; Sun, 15 Nov 2020 14:27:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqdb1PvLzSSn/9gIBrz03kfxm0hlTdYB2WLYo3u/LyJCFsCUaCNfPJ8mZt2GeMYhebXigOCw== X-Received: by 2002:a1c:7202:: with SMTP id n2mr11963813wmc.38.1605479235866; Sun, 15 Nov 2020 14:27:15 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/17] meson: move vhost_user_blk_server to meson.build Message-ID: <20201115220740.488850-3-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=ham 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: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Stefan Hajnoczi The --enable/disable-vhost-user-blk-server options were implemented in ./configure. There has been confusion about them and part of the problem is that the shell syntax used for setting the default value is not easy to read. Move the option over to meson where the conditions are easier to understand: have_vhost_user_blk_server =3D (targetos =3D=3D 'linux') if get_option('vhost_user_blk_server').enabled() if targetos !=3D 'linux' error('vhost_user_blk_server requires linux') endif elif get_option('vhost_user_blk_server').disabled() or not have_system have_vhost_user_blk_server =3D false endif This patch does not change behavior. Signed-off-by: Stefan Hajnoczi Message-Id: <20201110171121.1265142-2-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Philippe Mathieu-Daud=C3=A9 --- meson_options.txt | 2 ++ configure | 16 ++++------------ block/export/meson.build | 5 ++++- meson.build | 12 ++++++++++++ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index b4f1801875..f6f64785fe 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -64,6 +64,8 @@ option('xkbcommon', type : 'feature', value : 'auto', description: 'xkbcommon support') option('virtiofsd', type: 'feature', value: 'auto', description: 'build virtiofs daemon (virtiofsd)') +option('vhost_user_blk_server', type: 'feature', value: 'auto', + description: 'build vhost-user-blk server') =20 option('capstone', type: 'combo', value: 'auto', choices: ['disabled', 'enabled', 'auto', 'system', 'internal'], diff --git a/configure b/configure index 4cef321d9d..516f28a088 100755 --- a/configure +++ b/configure @@ -329,7 +329,7 @@ vhost_crypto=3D"" vhost_scsi=3D"" vhost_vsock=3D"" vhost_user=3D"" -vhost_user_blk_server=3D"" +vhost_user_blk_server=3D"auto" vhost_user_fs=3D"" kvm=3D"auto" hax=3D"auto" @@ -1247,9 +1247,9 @@ for opt do ;; --enable-vhost-vsock) vhost_vsock=3D"yes" ;; - --disable-vhost-user-blk-server) vhost_user_blk_server=3D"no" + --disable-vhost-user-blk-server) vhost_user_blk_server=3D"disabled" ;; - --enable-vhost-user-blk-server) vhost_user_blk_server=3D"yes" + --enable-vhost-user-blk-server) vhost_user_blk_server=3D"enabled" ;; --disable-vhost-user-fs) vhost_user_fs=3D"no" ;; @@ -2390,12 +2390,6 @@ if test "$vhost_net" =3D ""; then test "$vhost_kernel" =3D "yes" && vhost_net=3Dyes fi =20 -# libvhost-user is Linux-only -test "$vhost_user_blk_server" =3D "" && vhost_user_blk_server=3D$linux -if test "$vhost_user_blk_server" =3D "yes" && test "$linux" =3D "no"; then - error_exit "--enable-vhost-user-blk-server is only available on Linux" -fi - ########################################## # pkg-config probe =20 @@ -6289,9 +6283,6 @@ fi if test "$vhost_vdpa" =3D "yes" ; then echo "CONFIG_VHOST_VDPA=3Dy" >> $config_host_mak fi -if test "$vhost_user_blk_server" =3D "yes" ; then - echo "CONFIG_VHOST_USER_BLK_SERVER=3Dy" >> $config_host_mak -fi if test "$vhost_user_fs" =3D "yes" ; then echo "CONFIG_VHOST_USER_FS=3Dy" >> $config_host_mak fi @@ -7012,6 +7003,7 @@ NINJA=3D$ninja $meson setup \ -Dcapstone=3D$capstone -Dslirp=3D$slirp -Dfdt=3D$fdt \ -Diconv=3D$iconv -Dcurses=3D$curses -Dlibudev=3D$libudev\ -Ddocs=3D$docs -Dsphinx_build=3D$sphinx_build -Dinstall_blobs=3D$b= lobs \ + -Dvhost_user_blk_server=3D$vhost_user_blk_server \ $cross_arg \ "$PWD" "$source_path" =20 diff --git a/block/export/meson.build b/block/export/meson.build index 19526435d8..135b356775 100644 --- a/block/export/meson.build +++ b/block/export/meson.build @@ -1,2 +1,5 @@ blockdev_ss.add(files('export.c')) -blockdev_ss.add(when: 'CONFIG_VHOST_USER_BLK_SERVER', if_true: files('vhos= t-user-blk-server.c')) + +if have_vhost_user_blk_server + blockdev_ss.add(files('vhost-user-blk-server.c')) +endif diff --git a/meson.build b/meson.build index b473620321..4b789f18c1 100644 --- a/meson.build +++ b/meson.build @@ -751,6 +751,16 @@ statx_test =3D ''' =20 has_statx =3D cc.links(statx_test) =20 +have_vhost_user_blk_server =3D (targetos =3D=3D 'linux') + +if get_option('vhost_user_blk_server').enabled() + if targetos !=3D 'linux' + error('vhost_user_blk_server requires linux') + endif +elif get_option('vhost_user_blk_server').disabled() or not have_system + have_vhost_user_blk_server =3D false +endif + ################# # config-host.h # ################# @@ -775,6 +785,7 @@ config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersi= st_new_api) config_host_data.set('CONFIG_CURSES', curses.found()) config_host_data.set('CONFIG_SDL', sdl.found()) config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found()) +config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_s= erver) config_host_data.set('CONFIG_VNC', vnc.found()) config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) config_host_data.set('CONFIG_VNC_PNG', png.found()) @@ -2103,6 +2114,7 @@ summary_info +=3D {'vhost-crypto support': config_hos= t.has_key('CONFIG_VHOST_CRYPT summary_info +=3D {'vhost-scsi support': config_host.has_key('CONFIG_VHOST= _SCSI')} summary_info +=3D {'vhost-vsock support': config_host.has_key('CONFIG_VHOS= T_VSOCK')} summary_info +=3D {'vhost-user support': config_host.has_key('CONFIG_VHOST= _KERNEL')} +summary_info +=3D {'vhost-user-blk server support': have_vhost_user_blk_se= rver} summary_info +=3D {'vhost-user-fs support': config_host.has_key('CONFIG_VH= OST_USER_FS')} summary_info +=3D {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST= _VDPA')} summary_info +=3D {'Trace backends': config_host['TRACE_BACKENDS']} --=20 MST From nobody Sun May 5 14:21:27 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=1605479339; cv=none; d=zohomail.com; s=zohoarc; b=kzYRJnIvMy8mI+9vgDmws6lHtsvCLt26VAVAxDJAsVfzSJG+Y4Sa6b8ZnOp3Bl4hseGT+QhLrVEMCOMqcD+mIL5EV8Z9cUU3QXTzU6LbCEhRXJELTBhSmlFD7KprZCWmrEFLKo0bskDdRrPtSFtytaj6/NKeoXmDmIsiQDhs/uE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479339; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yB+iWwjcAdJo3aku5jv0oHVt9QpfV3gRJttPbNSWZik=; b=IExivTwCK1oDvKxtEncuY0WIhnrxmt+bxv54zWRSKAddGqIu1JaCwg3hEfAwDk7N4j4+kSn51Ot5nToUuTNB2VU8AheeXWIkEBKF5zpLZ41ZPzK47nTPLPp9qKU/R74GJiVcBqDiCpRqiNokBPj4Sy6Qm8QdKh720B6ZYZANUAQ= 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 160547933957733.884881758908705; Sun, 15 Nov 2020 14:28:59 -0800 (PST) Received: from localhost ([::1]:59334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQW2-0001l3-De for importer@patchew.org; Sun, 15 Nov 2020 17:28:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUW-0008UD-Pm for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUV-0001Y2-19 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:24 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-C3CztIHIPbSdhyFvh4mIFg-1; Sun, 15 Nov 2020 17:27:20 -0500 Received: by mail-wr1-f72.google.com with SMTP id h11so9777976wrq.20 for ; Sun, 15 Nov 2020 14:27:20 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n6sm20409305wrj.60.2020.11.15.14.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479242; 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: in-reply-to:in-reply-to:references:references; bh=yB+iWwjcAdJo3aku5jv0oHVt9QpfV3gRJttPbNSWZik=; b=ClWzk40Qxo4j5cGKJg0ichNouMcZkcuvverhPr08PNFQC6sBWoURO3qXQov5AEtkKoAT/l bKWkLwoQCxFeztmmPHBMVzxS6JjvXoiujw50M+Sa808WQ36t3n61ArsS9A9UuxZOEqtjh0 N/Gu6bkq8SpCxDgcVKOmXT76hW1ZgHg= X-MC-Unique: C3CztIHIPbSdhyFvh4mIFg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=yB+iWwjcAdJo3aku5jv0oHVt9QpfV3gRJttPbNSWZik=; b=BDrL8FuDzb6EOpe6XltzABvfV2EGD+S+WTZKN9f8ncf7/poYpl1ZAjMdVFya/DO7qU vN/aWydzV7yXxomsgivDCpjAoiy0s7lO8lfyahCzcZ7lf5NhlTwGckc+SdJKKU0vjDg4 zw4yWuuCZqUYlu33YSsT5PiPBbP+UMSSh12c/MLLStype6Er+s/yHKIKxkZlGaHu+7XZ XAPF2csNz2FL4R71Z0bLiTuXZyCFBGtQW+1XTVeQsB41YpmTdK1eS4bBUxmRFmAqZp1K BbaBxPR5fhVdEpr+UpKPNO9Oq/sotLcIYaIzc6cD2yOFElcKyvo8XRCBIINgNLar083C GaUQ== X-Gm-Message-State: AOAM530hYKOJlIdJTW8Art+Dc1V91/xaMYwS+xlwgR5qjaEDiiJ01B9n pUh1KeGUFcba8LaD5llosSMJlR/dOylPohTIwYba0pJ/xEJZdA/gMoR1lMQKfr2poVdR6LalRCX PqpkS3/jcDZgeNnAC0YM6kx4mR1cA+gV4LBmUmibcDA8QqqNbaXrzZDIje9gE X-Received: by 2002:adf:fcc8:: with SMTP id f8mr15991538wrs.331.1605479238795; Sun, 15 Nov 2020 14:27:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxP8AC7wfYNNL/G+KjhvQibXRTYJumgUzI8WVNUe3/7H7/wHq6fe57oAyGhp18FC8tvvsv30w== X-Received: by 2002:adf:fcc8:: with SMTP id f8mr15991514wrs.331.1605479238519; Sun, 15 Nov 2020 14:27:18 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/17] vhost-user-blk-server: depend on CONFIG_VHOST_USER Message-ID: <20201115220740.488850-4-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Richard Henderson , Stefan Hajnoczi , Paolo Bonzini , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Alex =?utf-8?Q?Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Stefan Hajnoczi I interpreted CONFIG_VHOST_USER as controlling only QEMU's vhost-user device frontends. However, virtiofsd and contrib/ vhost-user device backends are also controlled by CONFIG_VHOST_USER. Make the vhost-user-blk server depend on CONFIG_VHOST_USER for consistency. Now the following error is printed when the vhost-user-blk server is enabled without CONFIG_VHOST_USER: $ ./configure --disable-vhost-user --enable-vhost-user-blk ... ../meson.build:761:8: ERROR: Problem encountered: vhost_user_blk_server r= equires vhost-user support Suggested-by: Philippe Mathieu-Daud=C3=A9 Suggested-by: Alex Benn=C3=A9e Signed-off-by: Stefan Hajnoczi Message-Id: <20201110171121.1265142-3-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 4b789f18c1..7fd874eec7 100644 --- a/meson.build +++ b/meson.build @@ -751,11 +751,14 @@ statx_test =3D ''' =20 has_statx =3D cc.links(statx_test) =20 -have_vhost_user_blk_server =3D (targetos =3D=3D 'linux') +have_vhost_user_blk_server =3D (targetos =3D=3D 'linux' and + 'CONFIG_VHOST_USER' in config_host) =20 if get_option('vhost_user_blk_server').enabled() if targetos !=3D 'linux' error('vhost_user_blk_server requires linux') + elif 'CONFIG_VHOST_USER' not in config_host + error('vhost_user_blk_server requires vhost-user support') endif elif get_option('vhost_user_blk_server').disabled() or not have_system have_vhost_user_blk_server =3D false --=20 MST From nobody Sun May 5 14:21:27 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=1605480071; cv=none; d=zohomail.com; s=zohoarc; b=ccCCpJ8lnDreHYY3lxm5KawWwg0Ic3kRJly06T2frMIarEbI1hO2a124JKACfhlrJyAxsh5h0gkYaX9QbKao/aC7334Vxt1dhSHEFv3sVLM5Io0A5DIB/jzDJio/qbKssPsWMdjT86I/g1F0LmkjhQZIY1JolR4Rt97LKb084Vw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605480071; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WW3ubRoSnF3KNEtPsddWc59JkzXMJ/9aeihwbTBzIG0=; b=FMjVvTJ3LROK1exAn5IQ+vQ/5IfT4SFlyf24QOleV1VmDpcjkEvzDVDHa1EjW0cxw2URV/qTI6mR81EuqJRIgBxaipFZng5r7XEjWhzLoIkLKwGVf+a367skqUxn0atj2kV7D816eQeDws6o4XzBAPix1TyhD4jJH+rKzYYexzE= 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 1605480071551803.2367535360205; Sun, 15 Nov 2020 14:41:11 -0800 (PST) Received: from localhost ([::1]:56982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQhq-0004UZ-EU for importer@patchew.org; Sun, 15 Nov 2020 17:41:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQX7-00040z-Lz for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:30:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24163) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQX5-0001ir-LR for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:30:05 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-KeQr4k6fO_KLrKfwUIEF9w-1; Sun, 15 Nov 2020 17:27:23 -0500 Received: by mail-wm1-f72.google.com with SMTP id h9so7809289wmf.8 for ; Sun, 15 Nov 2020 14:27:22 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id e3sm3367424wro.90.2020.11.15.14.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479402; 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: in-reply-to:in-reply-to:references:references; bh=WW3ubRoSnF3KNEtPsddWc59JkzXMJ/9aeihwbTBzIG0=; b=YTOd1bAyGTdZWAUfOHL0k/Pp5674lroDVUT1ghUbY4pNX9XRtnvCaUJFPJQITv5mt8Iyx2 ciZjO+glvCseG5shLbmK4V8Seibe59mAcbHHmurXstpl+4bJ+L5JJqVwo5Zf4RdLutm1wn 4W/Z/5CXyy3g0xS7t5PaBYpJgY0EXgk= X-MC-Unique: KeQr4k6fO_KLrKfwUIEF9w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=WW3ubRoSnF3KNEtPsddWc59JkzXMJ/9aeihwbTBzIG0=; b=no5T8zRYAg4lyiK8WREnHOiVOvyTrbawvrxS521VuwVEsFGr9YhJEr7TWoJohkMerA aJxeNOFnSdRC24cX2l1qnb+UnJoU/PWqw8Kfb6q4wADb63l6byaLnU6/gVD5iOPhmjHJ I9MJOBZqX0gzUap4Opd7WxILrKARxD6O3EECanx8GOycduPQWhLdOVW/SePqayP76DKB Kyaqs17oCNSsub/lnUSRsodl/hl5AGDRyroE/t+m9B1w2AT3i5tzVzLRyD+Pn7mBhwNU rz0MJ7hbJkDP4ycKI9YLMR8Zw/E1qDWCtAxQM/J1cAauCjaMh1Se6cD7Oi5PDQCzWZ+/ DDhw== X-Gm-Message-State: AOAM531iXGEWRn+fduxLGgZ29mRghOKWqjUzpaMQh/dS0h018QjMpCdI uYhaUlOsN5ZTNi7PflKDBIQe3e1rvoyHq05mQ7JmTqiK7aTwnTlKqdcYYt6zmz6E6Cgkxm9R/FV QMmrSuBsJ/iRdLv58grO9MF9Uronr4yj0ZSRbptXlDNwF+gykm1l8b0Osc1YR X-Received: by 2002:a1c:81d7:: with SMTP id c206mr12110861wmd.140.1605479241622; Sun, 15 Nov 2020 14:27:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhGj6Yggd0xU77iG7riwuhQu/Z80rFsYm8ZlXFmw//AAVknzu6VpPTLWJUnQFulPEpLvzxKg== X-Received: by 2002:a1c:81d7:: with SMTP id c206mr12110842wmd.140.1605479241393; Sun, 15 Nov 2020 14:27:21 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/17] configure: mark vhost-user Linux-only Message-ID: <20201115220740.488850-5-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=ham 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: Laurent Vivier , Peter Maydell , Thomas Huth , Richard Henderson , Stefan Hajnoczi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Stefan Hajnoczi The vhost-user protocol uses the Linux eventfd feature and is typically connected to Linux kvm.ko ioeventfd and irqfd file descriptors. The protocol specification in docs/interop/vhost-user.rst does not describe how platforms without eventfd support work. The QEMU vhost-user devices compile on other POSIX host operating systems because eventfd usage is abstracted in QEMU. The libvhost-user programs in contrib/ do not compile but we failed to notice since they are not built by default. Make it clear that vhost-user is only supported on Linux for the time being. If someone wishes to support it on other platforms then the details can be added to vhost-user.rst and CI jobs can test the feature to prevent bitrot. Signed-off-by: Stefan Hajnoczi Message-Id: <20201110171121.1265142-4-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- configure | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 516f28a088..3fbc2a0c68 100755 --- a/configure +++ b/configure @@ -328,7 +328,7 @@ vhost_net=3D"" vhost_crypto=3D"" vhost_scsi=3D"" vhost_vsock=3D"" -vhost_user=3D"" +vhost_user=3D"no" vhost_user_blk_server=3D"auto" vhost_user_fs=3D"" kvm=3D"auto" @@ -718,7 +718,6 @@ fi case $targetos in MINGW32*) mingw32=3D"yes" - vhost_user=3D"no" audio_possible_drivers=3D"dsound sdl" if check_include dsound.h; then audio_drv_list=3D"dsound" @@ -797,6 +796,7 @@ Linux) audio_possible_drivers=3D"oss alsa sdl pa" linux=3D"yes" linux_user=3D"yes" + vhost_user=3D"yes" ;; esac =20 @@ -2341,9 +2341,8 @@ fi # vhost interdependencies and host support =20 # vhost backends -test "$vhost_user" =3D "" && vhost_user=3Dyes -if test "$vhost_user" =3D "yes" && test "$mingw32" =3D "yes"; then - error_exit "vhost-user isn't available on win32" +if test "$vhost_user" =3D "yes" && test "$linux" !=3D "yes"; then + error_exit "vhost-user is only available on Linux" fi test "$vhost_vdpa" =3D "" && vhost_vdpa=3D$linux if test "$vhost_vdpa" =3D "yes" && test "$linux" !=3D "yes"; then --=20 MST From nobody Sun May 5 14:21:27 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=1605479821; cv=none; d=zohomail.com; s=zohoarc; b=fjEGy3VYE0IjNgXi3+e66qD8Fntb9d2bXWvqF35AhVYnId2KFV0ulciFRb8dLWcB9M+vm91BjVhxCXrgj3ZJtaOnrysLv+tP9BBuTLiAmo8BbPi+pJKQ8oi6bi+i5Dk9VNv5CYlfEIAHKA3pJ3ljPDMX/Hh8PzT1ah3B5d2jYJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479821; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Fy5h6h+m0qqiK7cH1TYiRgHFXaiX1Q/ASMsmRQ7XhRo=; b=ZpW7GEZM6jZzaicUHTviYh4l6G6zxVz+IaQce5BC6FaITMAXPZOHhP2XQLQolFVRnlotshskf2bsJpdjedmxarLUFR6rsfZRP5/oqKsho+Lg1Ox53UmspUxp0DmeCl7+D6c6eyLjyRjkcK2CUT4LukO+PRsFKWKpqEEh73VmtE8= 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 1605479821805678.4811371740469; Sun, 15 Nov 2020 14:37:01 -0800 (PST) Received: from localhost ([::1]:47712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQdo-0000Xp-J8 for importer@patchew.org; Sun, 15 Nov 2020 17:37:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUc-0000EQ-Ju for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49658) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUa-0001YI-Pz for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:30 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-1zXNVQBTNI-ZbyOli-Bkjw-1; Sun, 15 Nov 2020 17:27:25 -0500 Received: by mail-wr1-f71.google.com with SMTP id c8so9902964wrh.16 for ; Sun, 15 Nov 2020 14:27:25 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id j127sm18849572wma.31.2020.11.15.14.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479248; 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: in-reply-to:in-reply-to:references:references; bh=Fy5h6h+m0qqiK7cH1TYiRgHFXaiX1Q/ASMsmRQ7XhRo=; b=DuvbbZ5UEOLHxOTuqYqmlXcS0DtfcJDtLnLxRhToJfkLP2r4ljPXyw4nfx1LJdjmHXAFYz GoxxrR5kZzIwuUxUYAhNkXl+SenBnLbSsd+wQ1GZ2QWabIyeFsICSZaWg6ReqJBuO+0jGP WkYbZQPktg6FJLwSHrJZDg8FfKmQ/jQ= X-MC-Unique: 1zXNVQBTNI-ZbyOli-Bkjw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Fy5h6h+m0qqiK7cH1TYiRgHFXaiX1Q/ASMsmRQ7XhRo=; b=ZAFGUbeIjfOfBibORrV2eUfVxjixvEGN+4WI1TI/OFBUhvQKzEzQScjsaqliqnfgT/ xTHm2GmdY6bl4WSQ0QZdXiG7+i/InyeY3lFDECIO8hBhQs7uscpVdIzWshl8WabJq2sT 4fezAhWjm8n/Pty+m/cIW6T2O6Cns10n7uaWAP3mT8pz55I3XJ70P9SmQq8MU7IZepue GeIlzisQmVYw2dBvimmIt0iWw1NdmswXm4gjNWlIH4N1PewxaWU2Z1/OK5gM+SOaskmq qELHW3Mi9YnI58QMkiZoIpvuqMosDZCesJQiCOqt/XFtePOB07sy8E4FJ9+m14inyZ7r DAxg== X-Gm-Message-State: AOAM5306yko96SZj/eg7mYPLMk3kpbobLlFe4JWRnEXzdO1hb3nqffPU uadTDk87e1gOBB8o0AgvTnzN5gDiiWauDlH8VpScQIBP+AOFkvCqziBrLUwcrVbP41IPwj7BsL2 q2Kp+1jiZknqWIgzoDQzD1uLwrnTDVrU7dae8muWecuRb7PiCjmRINOabNBpK X-Received: by 2002:adf:c803:: with SMTP id d3mr15911888wrh.108.1605479244399; Sun, 15 Nov 2020 14:27:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqPtN56L38gRTqBHFkoTu3KtlfiPTZEJPr2OHIurlmyB0JKYvY1E9VJP6UFrDRtzWWlJlwnA== X-Received: by 2002:adf:c803:: with SMTP id d3mr15911871wrh.108.1605479244220; Sun, 15 Nov 2020 14:27:24 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/17] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off Message-ID: <20201115220740.488850-6-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Igor Mammedov , Ani Sinha , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 GCC 9.3.0 thinks that 'method' can be left uninitialized. This code is already in the "if (bsel || pcihp_bridge_en)" block statement, but it isn't smart enough to figure it out. Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)" block statement to fix (on Ubuntu): ../hw/i386/acpi-build.c: In function 'build_append_pci_bus_devices': ../hw/i386/acpi-build.c:496:9: error: 'method' may be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 496 | aml_append(parent_scope, method); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Fixes: df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off = globally") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201107194045.438027-1-philmd@redhat.com> Acked-by: Ani Sinha Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 45 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4f66642d88..1f5c211245 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -465,34 +465,31 @@ static void build_append_pci_bus_devices(Aml *parent_= scope, PCIBus *bus, */ if (bsel || pcihp_bridge_en) { method =3D aml_method("PCNT", 0, AML_NOTSERIALIZED); - } - /* If bus supports hotplug select it and notify about local events */ - if (bsel) { - uint64_t bsel_val =3D qnum_get_uint(qobject_to(QNum, bsel)); =20 - aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM"))); - aml_append(method, - aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check= */) - ); - aml_append(method, - aml_call2("DVNT", aml_name("PCID"), aml_int(3)/* Eject Request= */) - ); - } + /* If bus supports hotplug select it and notify about local events= */ + if (bsel) { + uint64_t bsel_val =3D qnum_get_uint(qobject_to(QNum, bsel)); =20 - /* Notify about child bus events in any case */ - if (pcihp_bridge_en) { - QLIST_FOREACH(sec, &bus->child, sibling) { - int32_t devfn =3D sec->parent_dev->devfn; - - if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) { - continue; - } - - aml_append(method, aml_name("^S%.02X.PCNT", devfn)); + aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM= "))); + aml_append(method, aml_call2("DVNT", aml_name("PCIU"), + aml_int(1))); /* Device Check */ + aml_append(method, aml_call2("DVNT", aml_name("PCID"), + aml_int(3))); /* Eject Request */ + } + + /* Notify about child bus events in any case */ + if (pcihp_bridge_en) { + QLIST_FOREACH(sec, &bus->child, sibling) { + int32_t devfn =3D sec->parent_dev->devfn; + + if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) { + continue; + } + + aml_append(method, aml_name("^S%.02X.PCNT", devfn)); + } } - } =20 - if (bsel || pcihp_bridge_en) { aml_append(parent_scope, method); } qobject_unref(bsel); --=20 MST From nobody Sun May 5 14:21:27 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=1605479570; cv=none; d=zohomail.com; s=zohoarc; b=P2tctxGn+Oqupg/M6UcaKiaCGTiQqHAAupxQcd8B+pxrQ+7zxbiHqO4mDefqYl+ShouGtdVZeyKMmCK6ueb4JCX2OXuvdeuTYD3kokqfVybXqCy8a3smVgvtAe17Z060w5d/QsHhPVRPxdb6ijXN6CKDkegbkaRQbmRtJgKS3QE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PyhePquJjXL36xXxKxwEa+jhN+G1ZnrpAruInRR4Y4A=; b=mhw1GdEQot7RvzSasj+s3XD9r5/P+tyzgYqxk8CBf/ha56o9Vy84ggN3nw0x5Uv0kXKXShJKNXE0Lv3oSK62NbLWP8op7IPen0uFmyxFYCDocIi0nsB1ZDEGAPmE73/z/MkqaZFPROaEvQ7FfGC2wAF2RdKqjd037K618p+MRas= 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 1605479570816930.4179548117286; Sun, 15 Nov 2020 14:32:50 -0800 (PST) Received: from localhost ([::1]:40778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQZl-0005ug-H0 for importer@patchew.org; Sun, 15 Nov 2020 17:32:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUp-0000P3-90 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUh-0001Yd-R1 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:43 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164--zzcIrpgNAOqIH2lpnsf9w-1; Sun, 15 Nov 2020 17:27:30 -0500 Received: by mail-wm1-f72.google.com with SMTP id u9so7833173wmb.2 for ; Sun, 15 Nov 2020 14:27:30 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n10sm20967179wrx.9.2020.11.15.14.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479254; 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: in-reply-to:in-reply-to:references:references; bh=PyhePquJjXL36xXxKxwEa+jhN+G1ZnrpAruInRR4Y4A=; b=NlGph4UzEzwPjEJLg2INRZKYqW2G7Zp2sgBmqbfGaTAnnXq6KHZSdh47huNetQ3EpwKQDa 4/3KATbpafP7o676YLsl1fOvpiPKp/dOqT0Xx0Th5oiRT5mTWxlyhYoml1WBMjcuxKbE6A yD+TfwhVFM9uc1zFWMlmLw60vonV+6M= X-MC-Unique: -zzcIrpgNAOqIH2lpnsf9w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=PyhePquJjXL36xXxKxwEa+jhN+G1ZnrpAruInRR4Y4A=; b=cXuPsrCIgkUhSg6jAl77Z1RTn7AI9KdaIv5Cu508AMzuuLXlxg5xAAPAdcBaOKtZKN pWXjTtrH/6MMhGUCZr8FlCr6wa5ooWp2fU42TTg4y1rh81W0En6Jd8JynKv7TFnBH6OI Go/umLTtwVPl38QfIlcb4ZFCGErKXQ22VPUd7SRJZghNCJpzdvbuxEpjsjnlPGLaPayn hmw2AmgC6xFFeZDdJLU/nWLM7leBVl7xKWES3eyVpO1GN6qkXjkUIfkpLUOXvGTaIhQM EZYMYJdixWxXjmXelbMSKtMDV56ORpYt139m93U3DZNJeAGb06zJsiA5KbkN32H/e/Qc DUXw== X-Gm-Message-State: AOAM531kRid/6ppKMeZnTxji8LsXeI4w2MINODDK6wZvXx8GD3f/K7r5 9okmpRBeG0urKW/jXyXUZF3ff5foa2GPUOT0FedSVftUe9f8v9vHO3gp2kLjcjw5ezjqfoM/QKw GI2hwu/m33Mnadcrh/E0z3vDyzVjAtTyIhm4RvtUzI5K5OUV2OrzZt9n9Ih0q X-Received: by 2002:a1c:b387:: with SMTP id c129mr12182298wmf.58.1605479248242; Sun, 15 Nov 2020 14:27:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKrOKY/Z2EK7337BwuZGe4JI7S46c9ObJBE3qEocxJjiGaCO/VJAGdV82QB63lV6LnNXygAg== X-Received: by 2002:a1c:b387:: with SMTP id c129mr12182278wmf.58.1605479247834; Sun, 15 Nov 2020 14:27:27 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/17] test: new qTest case to test the vhost-user-blk-server Message-ID: <20201115220740.488850-7-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=ham 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: Laurent Vivier , Peter Maydell , Thomas Huth , Coiby Xu , Stefan Hajnoczi , Paolo Bonzini , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Coiby Xu This test case has the same tests as tests/virtio-blk-test.c except for tests have block_resize. Since vhost-user server can only server one client one time, two instances of vhost-user-blk-server are started by qemu-storage-daemon for the hotplug test. In order to not block scripts/tap-driver.pl, vhost-user-blk-server will send "quit" command to qemu-storage-daemon's QMP monitor. So a function is added to libqtest.c to establish socket connection with socket server. Suggested-by: Thomas Huth Signed-off-by: Coiby Xu Reviewed-by: Stefan Hajnoczi Reviewed-by: Marc-Andr=C3=A9 Lureau Message-id: 20200918080912.321299-7-coiby.xu@gmail.com [Update meson.build to only test when CONFIG_TOOLS has built qemu-storage-daemon. This prevents CI failures with --disable-tools. Also bump RAM to 256 MB because that is the minimum RAM granularity on ppc64 spapr machines. --Stefan] Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-2-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/libqos/libqtest.h | 17 + tests/qtest/libqos/vhost-user-blk.h | 48 ++ tests/qtest/libqos/vhost-user-blk.c | 129 +++++ tests/qtest/libqtest.c | 36 +- tests/qtest/vhost-user-blk-test.c | 751 ++++++++++++++++++++++++++++ tests/qtest/libqos/meson.build | 1 + tests/qtest/meson.build | 2 + 7 files changed, 982 insertions(+), 2 deletions(-) create mode 100644 tests/qtest/libqos/vhost-user-blk.h create mode 100644 tests/qtest/libqos/vhost-user-blk.c create mode 100644 tests/qtest/vhost-user-blk-test.c diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index 724f65aa94..d6236ea7a0 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -132,6 +132,23 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ..= .) void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 +/** + * qtest_socket_client: + * @server_socket_path: the socket server's path + * + * Connect to a socket server. + */ +int qtest_socket_client(char *server_socket_path); + +/** + * qtest_create_state_with_qmp_fd: + * @fd: socket fd + * + * Wrap socket fd in QTestState to make use of qtest_qmp* + * functions + */ +QTestState *qtest_create_state_with_qmp_fd(int fd); + /** * qtest_vqmp_fds: * @s: #QTestState instance to operate on. diff --git a/tests/qtest/libqos/vhost-user-blk.h b/tests/qtest/libqos/vhost= -user-blk.h new file mode 100644 index 0000000000..2a03456a45 --- /dev/null +++ b/tests/qtest/libqos/vhost-user-blk.h @@ -0,0 +1,48 @@ +/* + * libqos driver framework + * + * Based on tests/qtest/libqos/virtio-blk.c + * + * Copyright (c) 2020 Coiby Xu + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#ifndef TESTS_LIBQOS_VHOST_USER_BLK_H +#define TESTS_LIBQOS_VHOST_USER_BLK_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserBlk QVhostUserBlk; +typedef struct QVhostUserBlkPCI QVhostUserBlkPCI; +typedef struct QVhostUserBlkDevice QVhostUserBlkDevice; + +struct QVhostUserBlk { + QVirtioDevice *vdev; +}; + +struct QVhostUserBlkPCI { + QVirtioPCIDevice pci_vdev; + QVhostUserBlk blk; +}; + +struct QVhostUserBlkDevice { + QOSGraphObject obj; + QVhostUserBlk blk; +}; + +#endif diff --git a/tests/qtest/libqos/vhost-user-blk.c b/tests/qtest/libqos/vhost= -user-blk.c new file mode 100644 index 0000000000..58c7e1eb69 --- /dev/null +++ b/tests/qtest/libqos/vhost-user-blk.c @@ -0,0 +1,129 @@ +/* + * libqos driver framework + * + * Based on tests/qtest/libqos/virtio-blk.c + * + * Copyright (c) 2020 Coiby Xu + * + * Copyright (c) 2018 Emanuele Giuseppe Esposito + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "qemu/module.h" +#include "standard-headers/linux/virtio_blk.h" +#include "vhost-user-blk.h" + +#define PCI_SLOT 0x04 +#define PCI_FN 0x00 + +/* virtio-blk-device */ +static void *qvhost_user_blk_get_driver(QVhostUserBlk *v_blk, + const char *interface) +{ + if (!g_strcmp0(interface, "vhost-user-blk")) { + return v_blk; + } + if (!g_strcmp0(interface, "virtio")) { + return v_blk->vdev; + } + + fprintf(stderr, "%s not present in vhost-user-blk-device\n", interface= ); + g_assert_not_reached(); +} + +static void *qvhost_user_blk_device_get_driver(void *object, + const char *interface) +{ + QVhostUserBlkDevice *v_blk =3D object; + return qvhost_user_blk_get_driver(&v_blk->blk, interface); +} + +static void *vhost_user_blk_device_create(void *virtio_dev, + QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserBlkDevice *vhost_user_blk =3D g_new0(QVhostUserBlkDevice, 1); + QVhostUserBlk *interface =3D &vhost_user_blk->blk; + + interface->vdev =3D virtio_dev; + + vhost_user_blk->obj.get_driver =3D qvhost_user_blk_device_get_driver; + + return &vhost_user_blk->obj; +} + +/* virtio-blk-pci */ +static void *qvhost_user_blk_pci_get_driver(void *object, const char *inte= rface) +{ + QVhostUserBlkPCI *v_blk =3D object; + if (!g_strcmp0(interface, "pci-device")) { + return v_blk->pci_vdev.pdev; + } + return qvhost_user_blk_get_driver(&v_blk->blk, interface); +} + +static void *vhost_user_blk_pci_create(void *pci_bus, QGuestAllocator *t_a= lloc, + void *addr) +{ + QVhostUserBlkPCI *vhost_user_blk =3D g_new0(QVhostUserBlkPCI, 1); + QVhostUserBlk *interface =3D &vhost_user_blk->blk; + QOSGraphObject *obj =3D &vhost_user_blk->pci_vdev.obj; + + virtio_pci_init(&vhost_user_blk->pci_vdev, pci_bus, addr); + interface->vdev =3D &vhost_user_blk->pci_vdev.vdev; + + g_assert_cmphex(interface->vdev->device_type, =3D=3D, VIRTIO_ID_BLOCK); + + obj->get_driver =3D qvhost_user_blk_pci_get_driver; + + return obj; +} + +static void vhost_user_blk_register_nodes(void) +{ + /* + * FIXME: every test using these two nodes needs to setup a + * -drive,id=3Ddrive0 otherwise QEMU is not going to start. + * Therefore, we do not include "produces" edge for virtio + * and pci-device yet. + */ + + char *arg =3D g_strdup_printf("id=3Ddrv0,chardev=3Dchar1,addr=3D%x.%x", + PCI_SLOT, PCI_FN); + + QPCIAddress addr =3D { + .devfn =3D QPCI_DEVFN(PCI_SLOT, PCI_FN), + }; + + QOSGraphEdgeOptions opts =3D { }; + + /* virtio-blk-device */ + /** opts.extra_device_opts =3D "drive=3Ddrive0"; */ + qos_node_create_driver("vhost-user-blk-device", vhost_user_blk_device_= create); + qos_node_consumes("vhost-user-blk-device", "virtio-bus", &opts); + qos_node_produces("vhost-user-blk-device", "vhost-user-blk"); + + /* virtio-blk-pci */ + opts.extra_device_opts =3D arg; + add_qpci_address(&opts, &addr); + qos_node_create_driver("vhost-user-blk-pci", vhost_user_blk_pci_create= ); + qos_node_consumes("vhost-user-blk-pci", "pci-bus", &opts); + qos_node_produces("vhost-user-blk-pci", "vhost-user-blk"); + + g_free(arg); +} + +libqos_init(vhost_user_blk_register_nodes); diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index be0fb430dd..ff563cbaba 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -4,11 +4,13 @@ * Copyright IBM, Corp. 2012 * Copyright Red Hat, Inc. 2012 * Copyright SUSE LINUX Products GmbH 2013 + * Copyright Copyright (c) Coiby Xu * * Authors: * Anthony Liguori * Paolo Bonzini * Andreas F=C3=A4rber + * Coiby Xu * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -52,8 +54,7 @@ typedef struct QTestClientTransportOps { QTestRecvFn recv_line; /* for receiving qtest command responses */ } QTestTransportOps; =20 -struct QTestState -{ +struct QTestState { int fd; int qmp_fd; pid_t qemu_pid; /* our child QEMU process */ @@ -635,6 +636,37 @@ QDict *qtest_qmp_receive_dict(QTestState *s) return qmp_fd_receive(s->qmp_fd); } =20 +QTestState *qtest_create_state_with_qmp_fd(int fd) +{ + QTestState *qmp_test_state =3D g_new0(QTestState, 1); + qmp_test_state->qmp_fd =3D fd; + return qmp_test_state; +} + +int qtest_socket_client(char *server_socket_path) +{ + struct sockaddr_un serv_addr; + int sock; + int ret; + int retries =3D 0; + sock =3D socket(PF_UNIX, SOCK_STREAM, 0); + g_assert_cmpint(sock, !=3D, -1); + serv_addr.sun_family =3D AF_UNIX; + snprintf(serv_addr.sun_path, sizeof(serv_addr.sun_path), "%s", + server_socket_path); + + for (retries =3D 0; retries < 3; retries++) { + ret =3D connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_a= ddr)); + if (ret =3D=3D 0) { + break; + } + g_usleep(G_USEC_PER_SEC); + } + + g_assert_cmpint(ret, =3D=3D, 0); + return sock; +} + /** * Allow users to send a message without waiting for the reply, * in the case that they choose to discard all replies up until diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c new file mode 100644 index 0000000000..e7e44f9bf0 --- /dev/null +++ b/tests/qtest/vhost-user-blk-test.c @@ -0,0 +1,751 @@ +/* + * QTest testcase for Vhost-user Block Device + * + * Based on tests/qtest//virtio-blk-test.c + + * Copyright (c) 2014 SUSE LINUX Products GmbH + * Copyright (c) 2014 Marc Mar=C3=AD + * Copyright (c) 2020 Coiby Xu + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest-single.h" +#include "qemu/bswap.h" +#include "qemu/module.h" +#include "standard-headers/linux/virtio_blk.h" +#include "standard-headers/linux/virtio_pci.h" +#include "libqos/qgraph.h" +#include "libqos/vhost-user-blk.h" +#include "libqos/libqos-pc.h" + +#define TEST_IMAGE_SIZE (64 * 1024 * 1024) +#define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000) +#define PCI_SLOT_HP 0x06 + +typedef struct QVirtioBlkReq { + uint32_t type; + uint32_t ioprio; + uint64_t sector; + char *data; + uint8_t status; +} QVirtioBlkReq; + +#ifdef HOST_WORDS_BIGENDIAN +static const bool host_is_big_endian =3D true; +#else +static const bool host_is_big_endian; /* false */ +#endif + +static inline void virtio_blk_fix_request(QVirtioDevice *d, QVirtioBlkReq = *req) +{ + if (qvirtio_is_big_endian(d) !=3D host_is_big_endian) { + req->type =3D bswap32(req->type); + req->ioprio =3D bswap32(req->ioprio); + req->sector =3D bswap64(req->sector); + } +} + +static inline void virtio_blk_fix_dwz_hdr(QVirtioDevice *d, + struct virtio_blk_discard_write_zeroes *dwz_hdr) +{ + if (qvirtio_is_big_endian(d) !=3D host_is_big_endian) { + dwz_hdr->sector =3D bswap64(dwz_hdr->sector); + dwz_hdr->num_sectors =3D bswap32(dwz_hdr->num_sectors); + dwz_hdr->flags =3D bswap32(dwz_hdr->flags); + } +} + +static uint64_t virtio_blk_request(QGuestAllocator *alloc, QVirtioDevice *= d, + QVirtioBlkReq *req, uint64_t data_size) +{ + uint64_t addr; + uint8_t status =3D 0xFF; + QTestState *qts =3D global_qtest; + + switch (req->type) { + case VIRTIO_BLK_T_IN: + case VIRTIO_BLK_T_OUT: + g_assert_cmpuint(data_size % 512, =3D=3D, 0); + break; + case VIRTIO_BLK_T_DISCARD: + case VIRTIO_BLK_T_WRITE_ZEROES: + g_assert_cmpuint(data_size % + sizeof(struct virtio_blk_discard_write_zeroes), = =3D=3D, 0); + break; + default: + g_assert_cmpuint(data_size, =3D=3D, 0); + } + + addr =3D guest_alloc(alloc, sizeof(*req) + data_size); + + virtio_blk_fix_request(d, req); + + qtest_memwrite(qts, addr, req, 16); + qtest_memwrite(qts, addr + 16, req->data, data_size); + qtest_memwrite(qts, addr + 16 + data_size, &status, sizeof(status)); + + return addr; +} + +/* Returns the request virtqueue so the caller can perform further tests */ +static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc) +{ + QVirtioBlkReq req; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint8_t status; + char *data; + QTestState *qts =3D global_qtest; + QVirtQueue *vq; + + features =3D qvirtio_get_features(dev); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_RING_F_EVENT_IDX) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, alloc, 0); + + qvirtio_set_driver_ok(dev); + + /* Write and read with 3 descriptor layout */ + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(alloc, req_addr); + + if (features & (1u << VIRTIO_BLK_F_WRITE_ZEROES)) { + struct virtio_blk_discard_write_zeroes dwz_hdr; + void *expected; + + /* + * WRITE_ZEROES request on the same sector of previous test where + * we wrote "TEST". + */ + req.type =3D VIRTIO_BLK_T_WRITE_ZEROES; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request to check if the sector contains all zeroes */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc(512); + expected =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpmem(data, 512, expected, 512); + g_free(expected); + g_free(data); + + guest_free(alloc, req_addr); + } + + if (features & (1u << VIRTIO_BLK_F_DISCARD)) { + struct virtio_blk_discard_write_zeroes dwz_hdr; + + req.type =3D VIRTIO_BLK_T_DISCARD; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, tru= e); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), + 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + } + + if (features & (1u << VIRTIO_F_ANY_LAYOUT)) { + /* Write and read with 2 descriptor layout */ + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 528, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 513, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(alloc, req_addr); + } + + return vq; +} + +static void basic(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVhostUserBlk *blk_if =3D obj; + QVirtQueue *vq; + + vq =3D test_basic(blk_if->vdev, t_alloc); + qvirtqueue_cleanup(blk_if->vdev->bus, vq, t_alloc); + +} + +static void indirect(void *obj, void *u_data, QGuestAllocator *t_alloc) +{ + QVirtQueue *vq; + QVhostUserBlk *blk_if =3D obj; + QVirtioDevice *dev =3D blk_if->vdev; + QVirtioBlkReq req; + QVRingIndirectDesc *indirect; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint8_t status; + char *data; + QTestState *qts =3D global_qtest; + + features =3D qvirtio_get_features(dev); + g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=3D, = 0); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_EVENT_IDX) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, t_alloc, 0); + qvirtio_set_driver_ok(dev); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(dev, qts, indirect, req_addr, 528, false); + qvring_indirect_desc_add(dev, qts, indirect, req_addr + 528, 1, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + g_free(indirect); + guest_free(t_alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + indirect =3D qvring_indirect_desc_setup(qts, dev, t_alloc, 2); + qvring_indirect_desc_add(dev, qts, indirect, req_addr, 16, false); + qvring_indirect_desc_add(dev, qts, indirect, req_addr + 16, 513, true); + free_head =3D qvirtqueue_add_indirect(qts, vq, indirect); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + g_free(indirect); + guest_free(t_alloc, req_addr); + qvirtqueue_cleanup(dev->bus, vq, t_alloc); +} + +static void idx(void *obj, void *u_data, QGuestAllocator *t_alloc) +{ + QVirtQueue *vq; + QVhostUserBlkPCI *blk =3D obj; + QVirtioPCIDevice *pdev =3D &blk->pci_vdev; + QVirtioDevice *dev =3D &pdev->vdev; + QVirtioBlkReq req; + uint64_t req_addr; + uint64_t capacity; + uint64_t features; + uint32_t free_head; + uint32_t write_head; + uint32_t desc_idx; + uint8_t status; + char *data; + QOSGraphObject *blk_object =3D obj; + QPCIDevice *pci_dev =3D blk_object->get_driver(blk_object, "pci-device= "); + QTestState *qts =3D global_qtest; + + if (qpci_check_buggy_msi(pci_dev)) { + return; + } + + qpci_msix_enable(pdev->pdev); + qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0); + + features =3D qvirtio_get_features(dev); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev, features); + + capacity =3D qvirtio_config_readq(dev, 0); + g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); + + vq =3D qvirtqueue_setup(dev, t_alloc, 0); + qvirtqueue_pci_msix_setup(pdev, (QVirtQueuePCI *)vq, t_alloc, 1); + + qvirtio_set_driver_ok(dev); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 0; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + + /* Write request */ + req.type =3D VIRTIO_BLK_T_OUT; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + strcpy(req.data, "TEST"); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + /* Notify after processing the third request */ + qvirtqueue_set_used_event(qts, vq, 2); + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, false, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + qvirtqueue_kick(qts, dev, vq, free_head); + write_head =3D free_head; + + /* No notification expected */ + status =3D qvirtio_wait_status_byte_no_isr(qts, dev, + vq, req_addr + 528, + QVIRTIO_BLK_TIMEOUT_US); + g_assert_cmpint(status, =3D=3D, 0); + + guest_free(t_alloc, req_addr); + + /* Read request */ + req.type =3D VIRTIO_BLK_T_IN; + req.ioprio =3D 1; + req.sector =3D 1; + req.data =3D g_malloc0(512); + + req_addr =3D virtio_blk_request(t_alloc, dev, &req, 512); + + g_free(req.data); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, 512, true, true); + qvirtqueue_add(qts, vq, req_addr + 528, 1, true, false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + /* We get just one notification for both requests */ + qvirtio_wait_used_elem(qts, dev, vq, write_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + g_assert(qvirtqueue_get_buf(qts, vq, &desc_idx, NULL)); + g_assert_cmpint(desc_idx, =3D=3D, free_head); + + status =3D readb(req_addr + 528); + g_assert_cmpint(status, =3D=3D, 0); + + data =3D g_malloc0(512); + qtest_memread(qts, req_addr + 16, data, 512); + g_assert_cmpstr(data, =3D=3D, "TEST"); + g_free(data); + + guest_free(t_alloc, req_addr); + + /* End test */ + qpci_msix_disable(pdev->pdev); + + qvirtqueue_cleanup(dev->bus, vq, t_alloc); +} + +static void pci_hotplug(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtioPCIDevice *dev1 =3D obj; + QVirtioPCIDevice *dev; + QTestState *qts =3D dev1->pdev->bus->qts; + + /* plug secondary disk */ + qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", + "{'addr': %s, 'chardev': 'char2'}", + stringify(PCI_SLOT_HP) ".0"); + + dev =3D virtio_pci_new(dev1->pdev->bus, + &(QPCIAddress) { .devfn =3D QPCI_DEVFN(PCI_SLOT_H= P, 0) + }); + g_assert_nonnull(dev); + g_assert_cmpint(dev->vdev.device_type, =3D=3D, VIRTIO_ID_BLOCK); + qvirtio_pci_device_disable(dev); + qos_object_destroy((QOSGraphObject *)dev); + + /* unplug secondary disk */ + qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); +} + +/* + * Check that setting the vring addr on a non-existent virtqueue does + * not crash. + */ +static void test_nonexistent_virtqueue(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVhostUserBlkPCI *blk =3D obj; + QVirtioPCIDevice *pdev =3D &blk->pci_vdev; + QPCIBar bar0; + QPCIDevice *dev; + + dev =3D qpci_device_find(pdev->pdev->bus, QPCI_DEVFN(4, 0)); + g_assert(dev !=3D NULL); + qpci_device_enable(dev); + + bar0 =3D qpci_iomap(dev, 0, NULL); + + qpci_io_writeb(dev, bar0, VIRTIO_PCI_QUEUE_SEL, 2); + qpci_io_writel(dev, bar0, VIRTIO_PCI_QUEUE_PFN, 1); + + g_free(dev); +} + +static const char *qtest_qemu_storage_daemon_binary(void) +{ + const char *qemu_storage_daemon_bin; + + qemu_storage_daemon_bin =3D getenv("QTEST_QEMU_STORAGE_DAEMON_BINARY"); + if (!qemu_storage_daemon_bin) { + fprintf(stderr, "Environment variable " + "QTEST_QEMU_STORAGE_DAEMON_BINARY required\n"); + exit(0); + } + + return qemu_storage_daemon_bin; +} + +static void drive_destroy(void *path) +{ + unlink(path); + g_free(path); + qos_invalidate_command_line(); +} + +static char *drive_create(void) +{ + int fd, ret; + /** vhost-user-blk won't recognize drive located in /tmp */ + char *t_path =3D g_strdup("qtest.XXXXXX"); + + /** Create a temporary raw image */ + fd =3D mkstemp(t_path); + g_assert_cmpint(fd, >=3D, 0); + ret =3D ftruncate(fd, TEST_IMAGE_SIZE); + g_assert_cmpint(ret, =3D=3D, 0); + close(fd); + + g_test_queue_destroy(drive_destroy, t_path); + return t_path; +} + +static char sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.XXXXXX"; +static char qmp_sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.qmp.XXX= XXX"; + +static void quit_storage_daemon(void *qmp_test_state) +{ + const char quit_str[] =3D "{ 'execute': 'quit' }"; + + /* Before quiting storate-daemon, quit qemu to avoid dubious messages = */ + qobject_unref(qtest_qmp(global_qtest, quit_str)); + + /* + * Give storage-daemon enough time to wake up&terminate + * vu_client_trip coroutine so the Coroutine object could + * be cleaned up. Otherwise LeakSanitizer would complain + * about memory leaks. + */ + g_usleep(1000); + + qobject_unref(qtest_qmp((QTestState *)qmp_test_state, quit_str)); + g_free(qmp_test_state); +} + +static char *start_vhost_user_blk(GString *cmd_line, int vus_instances) +{ + const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); + int fd, qmp_fd, i; + QTestState *qmp_test_state; + gchar *img_path; + char *sock_path =3D NULL; + char *qmp_sock_path =3D g_strdup(qmp_sock_path_tempate); + GString *storage_daemon_command =3D g_string_new(NULL); + + qmp_fd =3D mkstemp(qmp_sock_path); + g_assert_cmpint(qmp_fd, >=3D, 0); + g_test_queue_destroy(drive_destroy, qmp_sock_path); + + g_string_append_printf(storage_daemon_command, + "exec %s " + "--chardev socket,id=3Dqmp,path=3D%s,server,nowait --monitor c= hardev=3Dqmp ", + vhost_user_blk_bin, qmp_sock_path); + + g_string_append_printf(cmd_line, + " -object memory-backend-memfd,id=3Dmem,size=3D256M,share=3Don= -M memory-backend=3Dmem "); + + for (i =3D 0; i < vus_instances; i++) { + sock_path =3D g_strdup(sock_path_tempate); + fd =3D mkstemp(sock_path); + g_assert_cmpint(fd, >=3D, 0); + g_test_queue_destroy(drive_destroy, sock_path); + /* create image file */ + img_path =3D drive_create(); + g_string_append_printf(storage_daemon_command, + "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " + "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," + "node-name=3Ddisk%i,writable=3Don ", + i, img_path, i, sock_path, i); + + g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", + i + 1, sock_path); + } + + g_test_message("starting vhost-user backend: %s", + storage_daemon_command->str); + pid_t pid =3D fork(); + if (pid =3D=3D 0) { + execlp("/bin/sh", "sh", "-c", storage_daemon_command->str, NULL); + exit(1); + } + g_string_free(storage_daemon_command, true); + + qmp_test_state =3D qtest_create_state_with_qmp_fd( + qtest_socket_client(qmp_sock_path)); + /* + * Ask qemu-storage-daemon to quit so it + * will not block scripts/tap-driver.pl. + */ + g_test_queue_destroy(quit_storage_daemon, qmp_test_state); + + qobject_unref(qtest_qmp(qmp_test_state, "{'execute': 'qmp_capabilities= '}")); + return sock_path; +} + +static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) +{ + start_vhost_user_blk(cmd_line, 1); + return arg; +} + +/* + * Setup for hotplug. + * + * Since vhost-user server only serves one vhost-user client one time, + * another exprot + * + */ +static void *vhost_user_blk_hotplug_test_setup(GString *cmd_line, void *ar= g) +{ + /* "-chardev socket,id=3Dchar2" is used for pci_hotplug*/ + start_vhost_user_blk(cmd_line, 2); + return arg; +} + +static void register_vhost_user_blk_test(void) +{ + QOSGraphTestOptions opts =3D { + .before =3D vhost_user_blk_test_setup, + }; + + /* + * tests for vhost-user-blk and vhost-user-blk-pci + * The tests are borrowed from tests/virtio-blk-test.c. But some tests + * regarding block_resize don't work for vhost-user-blk. + * vhost-user-blk device doesn't have -drive, so tests containing + * block_resize are also abandoned, + * - config + * - resize + */ + qos_add_test("basic", "vhost-user-blk", basic, &opts); + qos_add_test("indirect", "vhost-user-blk", indirect, &opts); + qos_add_test("idx", "vhost-user-blk-pci", idx, &opts); + qos_add_test("nxvirtq", "vhost-user-blk-pci", + test_nonexistent_virtqueue, &opts); + + opts.before =3D vhost_user_blk_hotplug_test_setup; + qos_add_test("hotplug", "vhost-user-blk-pci", pci_hotplug, &opts); +} + +libqos_init(register_vhost_user_blk_test); diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index 1cddf5bdaa..1f5c8f1053 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -32,6 +32,7 @@ libqos_srcs =3D files('../libqtest.c', 'virtio-9p.c', 'virtio-balloon.c', 'virtio-blk.c', + 'vhost-user-blk.c', 'virtio-mmio.c', 'virtio-net.c', 'virtio-pci.c', diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index c19f1c8503..23a70b4613 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -199,6 +199,7 @@ qos_test_ss.add( ) qos_test_ss.add(when: 'CONFIG_VIRTFS', if_true: files('virtio-9p-test.c')) qos_test_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user-test= .c')) +qos_test_ss.add(when: ['CONFIG_LINUX', 'CONFIG_TOOLS'], if_true: files('vh= ost-user-blk-test.c')) =20 tpmemu_files =3D ['tpm-emu.c', 'tpm-util.c', 'tpm-tests.c'] =20 @@ -237,6 +238,7 @@ foreach dir : target_dirs endif qtest_env.set('G_TEST_DBUS_DAEMON', meson.source_root() / 'tests/dbus-vm= state-daemon.sh') qtest_env.set('QTEST_QEMU_BINARY', './qemu-system-' + target_base) + qtest_env.set('QTEST_QEMU_STORAGE_DAEMON_BINARY', './storage-daemon/qemu= -storage-daemon') =20 foreach test : target_qtests # Executables are shared across targets, declare them only the first t= ime we --=20 MST From nobody Sun May 5 14:21:27 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=1605479512; cv=none; d=zohomail.com; s=zohoarc; b=eMhpZyZum62WN53hn/Suo/apHUzyM51Sve0HFZpYS9OMYnjEMjDGinpANBhho5Kx18i2pOyGjce/0dG1GE9W03SxMlSNFHQFit7ZdTdcprPdPcUpHObkaScd+uQmIgZGwIx9rRgsHHCEqTusty5b7yZq9pZ5iKpUyBAewRxQymo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479512; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N+M4OCndGzrhBaI4yH9a7jSixxuaAL/CfpDd7VJ9UxY=; b=MYPsbiwNOkmYJlB21q3QWTxP6tzhIlzTUAJ14gRpKbHL15tIfjtzOE+wc8wymraHNimDFQvBdYYI98D3pfaQagrNGTPygb19HdzkcBMBytfDBhA7rIeEd0fABmo9e3lTSKsw+X4UyUmD0tvV6JL1DaV13Xg0voK1KiyjsVmOX4s= 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 1605479512464185.17300024964254; Sun, 15 Nov 2020 14:31:52 -0800 (PST) Received: from localhost ([::1]:39072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQYo-0005Dn-Cp for importer@patchew.org; Sun, 15 Nov 2020 17:31:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUj-0000Mj-Ss for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUg-0001YZ-N5 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:37 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-iZhnjd66M1Sgzr43-leAhw-1; Sun, 15 Nov 2020 17:27:32 -0500 Received: by mail-wr1-f69.google.com with SMTP id e18so9854415wrs.23 for ; Sun, 15 Nov 2020 14:27:32 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id l13sm20734373wrm.24.2020.11.15.14.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479254; 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: in-reply-to:in-reply-to:references:references; bh=N+M4OCndGzrhBaI4yH9a7jSixxuaAL/CfpDd7VJ9UxY=; b=TR8FcJLF65NUMyVQTVpQD4qpT4tjnPb8+jnf3Qftm9UE95mVoARIed+fpTFNpk8a2GzlBe 6wv9dHa+0pOgxQpqKMJNDzrMwgCic7As59tVL9ByI5g+Gay3yAMFBBvv4PDVWNZtOoyv33 KLuByNOizY5pSBxRdCjTZpmkJS7gY3k= X-MC-Unique: iZhnjd66M1Sgzr43-leAhw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=N+M4OCndGzrhBaI4yH9a7jSixxuaAL/CfpDd7VJ9UxY=; b=Bcl+3WCTcz2GttO/oNaCeX3gIkvRgVwk+vsjNfVO+AlGSqUEpYl7kYTMfwlrpdg7AP RUUYWejyL4aTz7Ia0u7KeE1Ciy4x/VJYI0juJ5z0iucUqvJzR5ezx9RSNSoONYkOw34a PkK/ptKTR7DPQ+MchqmCB97fGRZIafd+2rjw2cR/1gwWVOjoW5n4y7YbN4GO26ehCI88 ePjfR1dirHdW9chgduC3FR8CJFYWmoir7KLjhmdUzED6b7pai84Xx3RDEq37wUbust+4 Gp61nxz5qgpXHs8vylF6WwGL8Ss8g7Io1ld+C4BhTERKxnbEKpQnIam0RVviPZlmSl7y Zfdg== X-Gm-Message-State: AOAM5327s4Qm0wRmcCPm7H3cVrbwxkCRVmjqp+pGf07dI7KAxCrMUmvR Bq0RFl9LFKGVQs+Zte5fQFBXre5RJrBnn4OyVAYZnutQVBb9WB7c8GhtJVD9OElV3h7mYuOAHXu cUUZ8OYyFgrc3nSP0s6g+kOUo9GaHSXk5gQMM9GhCkxX9C0aAgy6R8rqW3rHu X-Received: by 2002:a1c:f017:: with SMTP id a23mr4092454wmb.56.1605479250719; Sun, 15 Nov 2020 14:27:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzt3XYj9/+HcVzcj1UaDSo/xpMBPo/W5bGFORBAGZdthK8iLUEXLhhP3+4S5SOCuJcYkbH4BA== X-Received: by 2002:a1c:f017:: with SMTP id a23mr4092434wmb.56.1605479250383; Sun, 15 Nov 2020 14:27:30 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/17] tests/qtest: add multi-queue test case to vhost-user-blk-test Message-ID: <20201115220740.488850-8-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=ham 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: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi Message-id: 20201001144604.559733-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-3-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 81 +++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index e7e44f9bf0..31f2335f97 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -559,6 +559,67 @@ static void pci_hotplug(void *obj, void *data, QGuestA= llocator *t_alloc) qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); } =20 +static void multiqueue(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtioPCIDevice *pdev1 =3D obj; + QVirtioDevice *dev1 =3D &pdev1->vdev; + QVirtioPCIDevice *pdev8; + QVirtioDevice *dev8; + QTestState *qts =3D pdev1->pdev->bus->qts; + uint64_t features; + uint16_t num_queues; + + /* + * The primary device has 1 queue and VIRTIO_BLK_F_MQ is not enabled. = The + * VIRTIO specification allows VIRTIO_BLK_F_MQ to be enabled when ther= e is + * only 1 virtqueue, but --device vhost-user-blk-pci doesn't do this (= which + * is also spec-compliant). + */ + features =3D qvirtio_get_features(dev1); + g_assert_cmpint(features & (1u << VIRTIO_BLK_F_MQ), =3D=3D, 0); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI)); + qvirtio_set_features(dev1, features); + + /* Hotplug a secondary device with 8 queues */ + qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", + "{'addr': %s, 'chardev': 'char2', 'num-queues': 8= }", + stringify(PCI_SLOT_HP) ".0"); + + pdev8 =3D virtio_pci_new(pdev1->pdev->bus, + &(QPCIAddress) { + .devfn =3D QPCI_DEVFN(PCI_SLOT_HP, 0) + }); + g_assert_nonnull(pdev8); + g_assert_cmpint(pdev8->vdev.device_type, =3D=3D, VIRTIO_ID_BLOCK); + + qos_object_start_hw(&pdev8->obj); + + dev8 =3D &pdev8->vdev; + features =3D qvirtio_get_features(dev8); + g_assert_cmpint(features & (1u << VIRTIO_BLK_F_MQ), + =3D=3D, + (1u << VIRTIO_BLK_F_MQ)); + features =3D features & ~(QVIRTIO_F_BAD_FEATURE | + (1u << VIRTIO_RING_F_INDIRECT_DESC) | + (1u << VIRTIO_F_NOTIFY_ON_EMPTY) | + (1u << VIRTIO_BLK_F_SCSI) | + (1u << VIRTIO_BLK_F_MQ)); + qvirtio_set_features(dev8, features); + + num_queues =3D qvirtio_config_readw(dev8, + offsetof(struct virtio_blk_config, num_queues)); + g_assert_cmpint(num_queues, =3D=3D, 8); + + qvirtio_pci_device_disable(pdev8); + qos_object_destroy(&pdev8->obj); + + /* unplug secondary disk */ + qpci_unplug_acpi_device_test(qts, "drv1", PCI_SLOT_HP); +} + /* * Check that setting the vring addr on a non-existent virtqueue does * not crash. @@ -643,7 +704,8 @@ static void quit_storage_daemon(void *qmp_test_state) g_free(qmp_test_state); } =20 -static char *start_vhost_user_blk(GString *cmd_line, int vus_instances) +static char *start_vhost_user_blk(GString *cmd_line, int vus_instances, + int num_queues) { const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); int fd, qmp_fd, i; @@ -675,8 +737,8 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances) g_string_append_printf(storage_daemon_command, "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," - "node-name=3Ddisk%i,writable=3Don ", - i, img_path, i, sock_path, i); + "node-name=3Ddisk%i,writable=3Don,num-queues=3D%d ", + i, img_path, i, sock_path, i, num_queues); =20 g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", i + 1, sock_path); @@ -705,7 +767,7 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances) =20 static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) { - start_vhost_user_blk(cmd_line, 1); + start_vhost_user_blk(cmd_line, 1, 1); return arg; } =20 @@ -719,7 +781,13 @@ static void *vhost_user_blk_test_setup(GString *cmd_li= ne, void *arg) static void *vhost_user_blk_hotplug_test_setup(GString *cmd_line, void *ar= g) { /* "-chardev socket,id=3Dchar2" is used for pci_hotplug*/ - start_vhost_user_blk(cmd_line, 2); + start_vhost_user_blk(cmd_line, 2, 1); + return arg; +} + +static void *vhost_user_blk_multiqueue_test_setup(GString *cmd_line, void = *arg) +{ + start_vhost_user_blk(cmd_line, 2, 8); return arg; } =20 @@ -746,6 +814,9 @@ static void register_vhost_user_blk_test(void) =20 opts.before =3D vhost_user_blk_hotplug_test_setup; qos_add_test("hotplug", "vhost-user-blk-pci", pci_hotplug, &opts); + + opts.before =3D vhost_user_blk_multiqueue_test_setup; + qos_add_test("multiqueue", "vhost-user-blk-pci", multiqueue, &opts); } =20 libqos_init(register_vhost_user_blk_test); --=20 MST From nobody Sun May 5 14:21:27 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=1605479366; cv=none; d=zohomail.com; s=zohoarc; b=Rcrxa5oTmU08jJ80JK407DoUERjlEY4HPZ11vyZ2yg7cmy1QfVbfxf0l2Z/t7HDS4ta5yPQJzRFL12HXh59sDvFGkK5TYWMWF1ku2su23Njclx4GyHSsLwkKN9F7jAFxZulCV2NDWlJNCEvQDi4QFTE8Q+LbyqWOaydWCSugfGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479366; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=It/XdS4d9zKSvjqJB30A2ix7VujguCEuPG80WbLkr+Y=; b=Lji/qEV4qBIBd0mkZh5Bf9818xY+TfldVzl4Giu2WsexetY2MjGDVnV3hNS5yvfW6D1DWOsBKXvpjflwCmm2/l6mBYfdWbeSCwJ2AUfueMouQOk9NY2eI/mZrE0tOIhxxFivcQV6GDYaZRUfJ8zQwUkvDCN3Ih3JiKYbS8Ukhus= 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 1605479366497906.9972498844036; Sun, 15 Nov 2020 14:29:26 -0800 (PST) Received: from localhost ([::1]:60318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQWT-00029L-BF for importer@patchew.org; Sun, 15 Nov 2020 17:29:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUn-0000No-C1 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUj-0001Yj-7P for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:41 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-569-IIfDG8tTNnGkgjGOSJUhhA-1; Sun, 15 Nov 2020 17:27:34 -0500 Received: by mail-wr1-f69.google.com with SMTP id h11so9778911wrq.20 for ; Sun, 15 Nov 2020 14:27:34 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id t74sm17809883wmt.8.2020.11.15.14.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479256; 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: in-reply-to:in-reply-to:references:references; bh=It/XdS4d9zKSvjqJB30A2ix7VujguCEuPG80WbLkr+Y=; b=V+CgqreJVcn1bRp2pjVmhOAR3NHBGJmkB7z7DISOHHSs/RT3/mXMVklhB078aMLEB7WhS3 8+ub7LzqNf9LBeF6rh8zS78pVJLYohMoIkNDLItmipRQh8lzpKgo509BRjf/HHBF6MuULi U0w5CkGpFHYurXh6XsKNUNCfHf+eu9s= X-MC-Unique: IIfDG8tTNnGkgjGOSJUhhA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=It/XdS4d9zKSvjqJB30A2ix7VujguCEuPG80WbLkr+Y=; b=l2D8uGYYr/MbY0tIAMoZLDwCGY0Ix6h7ltD4Zc8iVBu5T3LXnHdns8OywF5Z1KkaAe /ws857c43Fbz4BPk90gnKtfz8TSD1x3J5MrTogJ2NYCJ/J+MrPa2Cmcc0thPHlkICvfv 46vAawmR5JTmuUMijiu1LawAqJxLhlZtgIew4y4ht+GcLt/HN2k2jBd/wtypZC17SfL1 XIkSAsgp8Y2RVohjWwCymMa7R1maoC2Hwy1tl1yNuRQGibaNpLswgbNMlPjU5cXJWUeN Zndp2xkv4lKfPYCzYJ/lhdjpTMOE8H+WiKMy6UQd2BvuQctKpqvBFcHN1cucJCJQgKY4 dvcA== X-Gm-Message-State: AOAM533kWGHpSx9T7bzPjbZ3dBC9PIcQBtMwxjAzx0hohc7kRuqRuoRQ IaZ00IfRRMOWvz95zwgtJdwhWrvi7PTo8T6L/kXoyEmLZJ8Y0tATN22t2vgfZxgreAk6Y/4TjXX JAFTpEhbBMn5GqJ6nPKIk20IehBSZ0zBIPHa9HsRujWZ6AwiBBPkISBtpUjAc X-Received: by 2002:a5d:4e46:: with SMTP id r6mr15862343wrt.218.1605479253413; Sun, 15 Nov 2020 14:27:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvM5iSh1i+Pga6+bpRn/yhF08GgnnUNQl489H1cP51V7usAPCG8kCfhoCioE148oU2HWBlDQ== X-Received: by 2002:a5d:4e46:: with SMTP id r6mr15862331wrt.218.1605479253184; Sun, 15 Nov 2020 14:27:33 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/17] libqtest: add qtest_socket_server() Message-ID: <20201115220740.488850-9-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi There is a qtest_socket_client() API. Add an equivalent qtest_socket_server() API that returns a new UNIX domain socket in the listen state. The code for this was already there but only used internally in init_socket(). Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-4-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/libqos/libqtest.h | 8 +++++++ tests/qtest/libqtest.c | 40 ++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index d6236ea7a0..8792c09398 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -132,6 +132,14 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ..= .) void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 +/** + * qtest_socket_server: + * @socket_path: the UNIX domain socket path + * + * Create and return a listen socket file descriptor, or abort on failure. + */ +int qtest_socket_server(const char *socket_path); + /** * qtest_socket_client: * @server_socket_path: the socket server's path diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index ff563cbaba..50a30f8e1f 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -82,24 +82,8 @@ static void qtest_client_set_rx_handler(QTestState *s, Q= TestRecvFn recv); =20 static int init_socket(const char *socket_path) { - struct sockaddr_un addr; - int sock; - int ret; - - sock =3D socket(PF_UNIX, SOCK_STREAM, 0); - g_assert_cmpint(sock, !=3D, -1); - - addr.sun_family =3D AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + int sock =3D qtest_socket_server(socket_path); qemu_set_cloexec(sock); - - do { - ret =3D bind(sock, (struct sockaddr *)&addr, sizeof(addr)); - } while (ret =3D=3D -1 && errno =3D=3D EINTR); - g_assert_cmpint(ret, !=3D, -1); - ret =3D listen(sock, 1); - g_assert_cmpint(ret, !=3D, -1); - return sock; } =20 @@ -643,6 +627,28 @@ QTestState *qtest_create_state_with_qmp_fd(int fd) return qmp_test_state; } =20 +int qtest_socket_server(const char *socket_path) +{ + struct sockaddr_un addr; + int sock; + int ret; + + sock =3D socket(PF_UNIX, SOCK_STREAM, 0); + g_assert_cmpint(sock, !=3D, -1); + + addr.sun_family =3D AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); + + do { + ret =3D bind(sock, (struct sockaddr *)&addr, sizeof(addr)); + } while (ret =3D=3D -1 && errno =3D=3D EINTR); + g_assert_cmpint(ret, !=3D, -1); + ret =3D listen(sock, 1); + g_assert_cmpint(ret, !=3D, -1); + + return sock; +} + int qtest_socket_client(char *server_socket_path) { struct sockaddr_un serv_addr; --=20 MST From nobody Sun May 5 14:21:27 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=1605479890; cv=none; d=zohomail.com; s=zohoarc; b=jU+EC+z4xX3yHBTBWVoiJAhoNRiLT6LejfiUmvY2hPOOAh+0cQU6aYHxZTXHUAuxrS/EjPzD7JT8zA+l9lJevv1Q919TKA/sS3Z3Y77so2ivjqgff2A0DtUdpb/1zqt2bHhvPVGFfKYmHDccCzbmqKfRP53bezfqA4EU80MM2Ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479890; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4+w2ArNp2PrP72MUGD7pF5zA08i1iTOBucY2T4SXC6I=; b=XfNILEK0UjtNLylJfC/aG6QqhpDLPNA6c7ne2lbcuU6reffPHGgRfsJvdxKeH644vBjVBGy3bKwFQKUWGRHmbUDrZOj1sIUg4fmwY4VO8dU+hjSG0KiPsAQG4FJk6W5VGi2eno5H29kNvjuSf7cE9jOlx/l25UCP+2zP0N3ETyA= 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 1605479890530671.2617888108484; Sun, 15 Nov 2020 14:38:10 -0800 (PST) Received: from localhost ([::1]:49420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQev-0001OA-71 for importer@patchew.org; Sun, 15 Nov 2020 17:38:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUr-0000QI-E7 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUn-0001Yv-2G for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:45 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-473-_GrPjuX5PCKjcEKsSMofdw-1; Sun, 15 Nov 2020 17:27:37 -0500 Received: by mail-wm1-f72.google.com with SMTP id 8so7774726wmg.6 for ; Sun, 15 Nov 2020 14:27:37 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id e5sm18480404wrs.84.2020.11.15.14.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479259; 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: in-reply-to:in-reply-to:references:references; bh=4+w2ArNp2PrP72MUGD7pF5zA08i1iTOBucY2T4SXC6I=; b=O6uawHO4z/dcPjGP8jdPAIaPw9mFjhlQn5brEkIF3B+MPaIYAlhXrCKvas1bMvTZnNU438 N5m4OGzPyfN0Xu/ICkbvXMhl4qCm0m2LN6FgzIHQaoFuutaa4qaMx1gPAXlalzdho7NeJ/ MhdRcgNQ1kaSvUA7M+dd3dfVb0sAhdI= X-MC-Unique: _GrPjuX5PCKjcEKsSMofdw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4+w2ArNp2PrP72MUGD7pF5zA08i1iTOBucY2T4SXC6I=; b=M0y3EkcKwiOrcj9JBa+G0uaHxMMIf9NN29KlyInoIB+5jkcgobSOt9Ri/N2BaL+nP5 iZiXJ6gRxWo9lDAit+3gH1lLoqtJe9X3GvGrV8dNV4m1hNNg2jB6tvBJA+6p69Ydr5W9 9OwawX5b6GhczdkQv0e7oF7cvuWxBbLwJaB4UZvA9Wk16Ptu2XidDrumMvI5ue2HIWPy dQFDd490+k6ImtwC2M6xCkEnFuYe78KLWaYvT5frGT5puvyyWyfXo/MB8m2FHVRhXy+3 pIVoQ9BlyuJ/8Qc8ndB1i7W0v+GSMjlJfDkcK5UqZmyQ6FFE+CoVRStgYfWxkK8s4Y2M ewcw== X-Gm-Message-State: AOAM531SvAr3/CaRGPx8qmCZEMAZ5EMbOUEQSBDEUs65yBRiZSfHVFKe r/xvMq+ihiGxlxiKJ1K6iUe2UO6AdNa9IwM+1vn0zrDJjHF8z3oBtFPBrvIk6OSAUNAZ0VN4Wj9 TLj8ERYVjCZGybuhpjCatR2GdSutBrB/sdkncNvfJs6oJ2KJk1jbM1JDKlw0w X-Received: by 2002:adf:fec6:: with SMTP id q6mr16205988wrs.168.1605479256148; Sun, 15 Nov 2020 14:27:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcBn6Agy7lvOTzZeTkZt0jSJaWxalUhhg6qUG+vhF7I0pVs+MUCMDglOebxMO/tLOPMbaPYg== X-Received: by 2002:adf:fec6:: with SMTP id q6mr16205972wrs.168.1605479255928; Sun, 15 Nov 2020 14:27:35 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/17] vhost-user-blk-test: rename destroy_drive() to destroy_file() Message-ID: <20201115220740.488850-10-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The function is used not just for image files but also for UNIX domain sockets (QMP monitor and vhost-user-blk). Reflect that in the name. Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-5-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 31f2335f97..f05f14c192 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -658,7 +658,8 @@ static const char *qtest_qemu_storage_daemon_binary(voi= d) return qemu_storage_daemon_bin; } =20 -static void drive_destroy(void *path) +/* g_test_queue_destroy() cleanup function for files */ +static void destroy_file(void *path) { unlink(path); g_free(path); @@ -678,7 +679,7 @@ static char *drive_create(void) g_assert_cmpint(ret, =3D=3D, 0); close(fd); =20 - g_test_queue_destroy(drive_destroy, t_path); + g_test_queue_destroy(destroy_file, t_path); return t_path; } =20 @@ -717,7 +718,7 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances, =20 qmp_fd =3D mkstemp(qmp_sock_path); g_assert_cmpint(qmp_fd, >=3D, 0); - g_test_queue_destroy(drive_destroy, qmp_sock_path); + g_test_queue_destroy(destroy_file, qmp_sock_path); =20 g_string_append_printf(storage_daemon_command, "exec %s " @@ -731,7 +732,7 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances, sock_path =3D g_strdup(sock_path_tempate); fd =3D mkstemp(sock_path); g_assert_cmpint(fd, >=3D, 0); - g_test_queue_destroy(drive_destroy, sock_path); + g_test_queue_destroy(drive_file, sock_path); /* create image file */ img_path =3D drive_create(); g_string_append_printf(storage_daemon_command, --=20 MST From nobody Sun May 5 14:21:27 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=1605480305; cv=none; d=zohomail.com; s=zohoarc; b=e3c835mH87OCFyQL0GrNc2ig4zBCIepnQcw71M1CtdIMPYx7KdV322We/I9cmJDCm8R3UYu7K3GVUI5LpVmKEt1BRkXpWk2tkklsUJakTGVt/O77dfG1sztwnbIFsPHjC1eUCDXBGtsso9Q7QfcOXzoCfqB62yhIrPnJo+5+S54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605480305; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zTT+QspY2RC2p8vFIONzBrHlF4S2EYY9M3J05nONmoE=; b=AqI4/MYnDOV2F6kPf9hzw067W6IBL1yZ1e2riVSrAPky57Maz1WJBxuMyeo4zbMmIQKe5HEHB07wNRJf+bXZH+tYsYlgHTzMMv6mxy2cgHK6Kmjfr+04cBlXd+sedQlZvTWiOweBIi69/sh5iwiwuDt6o6BiLrY63Arry8O4hto= 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 160548030529526.985281463508045; Sun, 15 Nov 2020 14:45:05 -0800 (PST) Received: from localhost ([::1]:39166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQlc-0000Tz-3Y for importer@patchew.org; Sun, 15 Nov 2020 17:45:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQX8-00043V-W8 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:30:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQX6-0001jh-6k for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:30:06 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-kiIrGab5Mxyws4ec5Lwppw-1; Sun, 15 Nov 2020 17:27:40 -0500 Received: by mail-wr1-f69.google.com with SMTP id e18so9854874wrs.23 for ; Sun, 15 Nov 2020 14:27:40 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n67sm17534557wmf.25.2020.11.15.14.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479403; 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: in-reply-to:in-reply-to:references:references; bh=zTT+QspY2RC2p8vFIONzBrHlF4S2EYY9M3J05nONmoE=; b=YF+nqasi+gOPh4F52c4AaLkDvc5Z0tqSfh0a4GbuPYsVYBS9JjpJ+kKfscj0MxpL+8lwsW Yf/T+ZsuyVu0MJHCvps/6pXHtFQ4SyHI6FYV8frlMQngKeGDdQpacXyiSqpI5J/WwwQ0o4 L12HxPNAT7i7aVS6BMAcAL4mIxHD7fg= X-MC-Unique: kiIrGab5Mxyws4ec5Lwppw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zTT+QspY2RC2p8vFIONzBrHlF4S2EYY9M3J05nONmoE=; b=QsUUvjMNwKth0smgx5SDf6XylZ/Z+fA3M7JneXGCqrTZYInHPspkIZKkJVXativkJ9 wE4O5Jzl6tml7DkN+c4jJ+LG9O9chnZwaMcpmvEFJpiSLApPx5PVgx4sjjvGnTRXlBOi lSLiIG8bpeK3OqCuF/joHAYaQaZ54AU1iGJ3euSTpjyvmZ130ki8WkmxD3+PFmGjKptt BpmNMikYOXSKYO9hLzskmwKei9Q23Ot3992hFn7XSfmP38POAHasij3Y9KE/ba8NDELy rqiwaSt8jbOWdyT1VL/jHBfL5SSMqM4lrhltasK1nj7JNpgaUTwXAcipHvbnLGj3tu5O LvHw== X-Gm-Message-State: AOAM5336+kwtJSpyFqDTMgeOGA5lu4P/aI2SR8bCpliEwCdr+utvt8F3 Tfkm99OroYp0Ih/sMpmmUkUVJ5kz52lGy+c45xos4a+RlEDXDNaJ7M8FkYUJp6Y7NjvdL9iIhc+ /h0MQPqA1jrXSXBAKvPRHov0p47bALQHz9QV4JN2rZWD8MEY85q+GZYzeZpJG X-Received: by 2002:a1c:b387:: with SMTP id c129mr12182645wmf.58.1605479258879; Sun, 15 Nov 2020 14:27:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDAjNpFaEpSUIaOmdiyt/vAJY33DSesloYMeHiqAHxxAeumfF6Rb4yIhJhC8WsKDcNwQvD1g== X-Received: by 2002:a1c:b387:: with SMTP id c129mr12182630wmf.58.1605479258660; Sun, 15 Nov 2020 14:27:38 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/17] vhost-user-blk-test: close fork child file descriptors Message-ID: <20201115220740.488850-11-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Do not leave stdin and stdout open after fork. stdout is the tap-driver.pl pipe. If we keep the pipe open then tap-driver.pl will not detect that qos-test has terminated and it will hang. Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-6-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index f05f14c192..4019a72ac0 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -749,6 +749,15 @@ static char *start_vhost_user_blk(GString *cmd_line, i= nt vus_instances, storage_daemon_command->str); pid_t pid =3D fork(); if (pid =3D=3D 0) { + /* + * Close standard file descriptors so tap-driver.pl pipe detects w= hen + * our parent terminates. + */ + close(0); + close(1); + open("/dev/null", O_RDONLY); + open("/dev/null", O_WRONLY); + execlp("/bin/sh", "sh", "-c", storage_daemon_command->str, NULL); exit(1); } --=20 MST From nobody Sun May 5 14:21:27 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=1605479520; cv=none; d=zohomail.com; s=zohoarc; b=MbouBns3T1J74bj6W+DgGw9C+JZGOJ8fzEAP3hnh/MtYb74ctvP+vPkhFuqobGMm2EcbKqbpon4sBoNtrcj1mTSuVJWsmADfFCjVXKeD0neq1V0t6oA38cqONNcmNbnzwCTfZ3d0iZdeJbjx+fX02i6NObL5Xg1zYhzqXubfj4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479520; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iWsO4tI4todI9tjh9pOi03bo9125ZEGAQbWUj8yyq+s=; b=DdnQBm5exHMmodsOEi1z5szrDtMMzzOT2qFen/6keGriiwi9XVqtzrytRtiq3qY6pkUuIZe7IaZLqETUoR2+KgLo1uUGAQq26TfpHFWn8NLSxUy1c1nxY8L9KN36WEZ/XqVkmEsI44l+cRicdmZ+gEqq7HDQYZQdBw4Q5uemI24= 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 1605479520555307.5146670454882; Sun, 15 Nov 2020 14:32:00 -0800 (PST) Received: from localhost ([::1]:39522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQYx-0005PN-Cp for importer@patchew.org; Sun, 15 Nov 2020 17:31:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUu-0000SL-Mg for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUs-0001ZE-BP for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:48 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-FASzANa9P4eOVZGC23YZPQ-1; Sun, 15 Nov 2020 17:27:43 -0500 Received: by mail-wr1-f72.google.com with SMTP id h11so9779347wrq.20 for ; Sun, 15 Nov 2020 14:27:43 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id n11sm19420769wru.38.2020.11.15.14.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479265; 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: in-reply-to:in-reply-to:references:references; bh=iWsO4tI4todI9tjh9pOi03bo9125ZEGAQbWUj8yyq+s=; b=h64pUX8c8oaq1FDQ6YUgINgCyzRWOGMWOntJM60Sa1tb9+OEy+ONQj+XFiGbFJluZI4D+W mwPOP+1NoH2MmctlmXbqNzLbFS7V47uArtuXRWnmdkgmVeDL0AFZNvP+jfsREZwlabTM2v f5xltNP39C59wOPfUxvvY6IGDLDZNxQ= X-MC-Unique: FASzANa9P4eOVZGC23YZPQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iWsO4tI4todI9tjh9pOi03bo9125ZEGAQbWUj8yyq+s=; b=oligH5vSGNRuysH/B7XKxgqUK0FRHMmYQvLvYs1WPiZicd38B7LIEhbENrtBiTBENR kWcOWEvfz9BMhkBh8BxiVuqyAkunsnOSrezbEhHbZ7Y0BhuTOPw6zESHTCt6c0xeuBn9 +MkZvVej0T7zo7Li5n7D8oya4cGsZBSlsfkISd05XFxdlfKDu3thP21stxIsS4UI00AV atGsCgfGLlKcWtDrhyD1Mq1tKnstaOHvNT9QRXPrifDoztnsqPJNafZDlt1N63/pREiR tBIC8uSRvKhkXSGxywtAU2ltteVdID3DNpxecdZvsbQycItNVGsOZIfFBL6sPe01AgOO oLuw== X-Gm-Message-State: AOAM532HG6jkUaTxoTm11QfvSiQmhaUQtbosKMtiBF+lShqlgARTuX6E j1m31Tw8Gj2xlK7DWTzlBF4lYD+CG3knZIs+sqYXuDIyXojh+c6wo4CFMnYaqsOJCewPD9tZnqh oFkQoy1WC+FMZGHfa7f+4skSIcw2pk3C19ORSufsaZFBnLIL+eZgx0TeEsZ1h X-Received: by 2002:adf:f644:: with SMTP id x4mr16305196wrp.5.1605479261967; Sun, 15 Nov 2020 14:27:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJws0dhCUzt0ISFlAq5Cc2RSqUG8fGEjo3gmpPyCrHG5J6/78IFFB2o1Yi0Mg0VSwZ6LH9XIrA== X-Received: by 2002:adf:f644:: with SMTP id x4mr16305184wrp.5.1605479261819; Sun, 15 Nov 2020 14:27:41 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/17] vhost-user-blk-test: drop unused return value Message-ID: <20201115220740.488850-12-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=ham 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: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The sock_path return value was unused and bogus (it doesn't make sense when there are multiple drives because only the last path is arbitrarily returned). Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-7-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 4019a72ac0..c5ff610d7a 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -705,8 +705,8 @@ static void quit_storage_daemon(void *qmp_test_state) g_free(qmp_test_state); } =20 -static char *start_vhost_user_blk(GString *cmd_line, int vus_instances, - int num_queues) +static void start_vhost_user_blk(GString *cmd_line, int vus_instances, + int num_queues) { const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); int fd, qmp_fd, i; @@ -772,7 +772,6 @@ static char *start_vhost_user_blk(GString *cmd_line, in= t vus_instances, g_test_queue_destroy(quit_storage_daemon, qmp_test_state); =20 qobject_unref(qtest_qmp(qmp_test_state, "{'execute': 'qmp_capabilities= '}")); - return sock_path; } =20 static void *vhost_user_blk_test_setup(GString *cmd_line, void *arg) --=20 MST From nobody Sun May 5 14:21:27 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=1605480104; cv=none; d=zohomail.com; s=zohoarc; b=gOzxnWKSpgbVG8VjgHm/+hXi/IKOpXsZxlHMa5hRgwYEHac38XOy0cxfHPzrjLkSFIKRzpYOXIu+Gh5F+zt5XZOhlVbQyRzpn+LF1B1HsFcifsOJMWukSVMKjutI+g9Y6zxTPkUKp/JIpe0xe/fc/0E18kZy0pOA2b7j6ujuMTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605480104; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=G6ydD8nywIYgDA5NaMvjnA+TxKcYXavN/x/Q6gxOBVg=; b=RlUqafl0z4UdTsS8slr0CfkTZqTMXaavk3o30peVyR4njPL9hPl8WXPB3WhGyvm/yahCa/CsNxrf2JcS37CpERuFGFZJ1sqS2Axv/AcoIvoIQ15SlDqbiM1grLUj/Y6zdJNXpyhljZMpaVgS72GTcoxEc5/ZrONFodn6lJjH4GE= 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 1605480104127135.8012694130092; Sun, 15 Nov 2020 14:41:44 -0800 (PST) Received: from localhost ([::1]:57858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQiM-0004rk-Qv for importer@patchew.org; Sun, 15 Nov 2020 17:41:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQUw-0000Tb-Ph for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUu-0001ZS-ES for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:50 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-bGWS2gEDP9KvQJRCWttEMA-1; Sun, 15 Nov 2020 17:27:45 -0500 Received: by mail-wm1-f70.google.com with SMTP id h9so7810298wmf.8 for ; Sun, 15 Nov 2020 14:27:45 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id j4sm19713228wrn.83.2020.11.15.14.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479267; 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: in-reply-to:in-reply-to:references:references; bh=G6ydD8nywIYgDA5NaMvjnA+TxKcYXavN/x/Q6gxOBVg=; b=OBArtDCuP5T+rhcy2hu5aMRH3cG811mD94i3QWSfh9YwoUK1zCUAPd6JJSnPMaABqtPgQ/ vicU4vOipbR5QOejukR6yNXakjaYLLWL5lbUFRFs1dxjhb2hVDWZI/+nL5Yi5J7iINLHZW NyZGt6cx95GMcXqB+5dIrbSHgsiafEw= X-MC-Unique: bGWS2gEDP9KvQJRCWttEMA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=G6ydD8nywIYgDA5NaMvjnA+TxKcYXavN/x/Q6gxOBVg=; b=c7oQN7ng6WVux/qdybZUgm5VbKZE52wnNBWcMxb2oTdN0NQWcFeNwrgF1uSNZ0qB35 NXvZZ8c6/J30MyjEtwXNgrOk7QRoHILGKdDlN0zxaNBToLU5NaJju+4vPvQMyFLTXhZD n0IQQLdzOY3YHOYNW3FiO0s2lt5U4c09cagDYy7z31T5uiPqdZZ4IngLf7q/szFgmN9i 3BKiwO4L5zE4W1jPQ885ULJFgrP0N6CSnQ9saCQZ/ptgPtpYymbuxWqh2qEpQ4ajKS7z 5zsn3yBllf3M6I8Bqrp47hw2P/toICBcZwojAfXrhFQub7P9xZouM3orJ/laZJjaP0uj Hi4A== X-Gm-Message-State: AOAM531fJkH83LuTo2dykhCHoUb/aJCEnivfymZg/gUW/GF7Afoi2uRP pxd83+uZPZB+sewJq9wCT6CF6slzYArujI+TBiS1IeXOkkOgnG7GQYvhFAOYg3kvjIoofgW2LLk dIjUVvEAhbvZHSfOGb2tG7TSeK8/6FurfbyRMbIdLvKdXEeDboUxQWeZjP+Pz X-Received: by 2002:a5d:4f12:: with SMTP id c18mr16007724wru.304.1605479264570; Sun, 15 Nov 2020 14:27:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwS3CE1e8KxIsnbH1qUfcogx8I+53eDx83qrPFJKSUlb918vML+74YNmn9LOcL3uINcY8JY/g== X-Received: by 2002:a5d:4f12:: with SMTP id c18mr16007712wru.304.1605479264413; Sun, 15 Nov 2020 14:27:44 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/17] vhost-user-blk-test: fix races by using fd passing Message-ID: <20201115220740.488850-13-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , Paolo Bonzini 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Pass the QMP and vhost-user-blk server sockets as file descriptors. That way the sockets are already open and in a listen state when the QEMU process is launched. This solves the race with qemu-storage-daemon startup where the UNIX domain sockets may not be ready yet when QEMU attempts to connect. It also saves us sleeping for 1 second if the qemu-storage-daemon QMP socket is not ready yet. Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-8-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 42 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index c5ff610d7a..e52340cffb 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -683,8 +683,22 @@ static char *drive_create(void) return t_path; } =20 -static char sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.XXXXXX"; -static char qmp_sock_path_tempate[] =3D "/tmp/qtest.vhost_user_blk.qmp.XXX= XXX"; +static char *create_listen_socket(int *fd) +{ + int tmp_fd; + char *path; + + /* No race because our pid makes the path unique */ + path =3D g_strdup_printf("/tmp/qtest-%d-sock.XXXXXX", getpid()); + tmp_fd =3D mkstemp(path); + g_assert_cmpint(tmp_fd, >=3D, 0); + close(tmp_fd); + unlink(path); + + *fd =3D qtest_socket_server(path); + g_test_queue_destroy(destroy_file, path); + return path; +} =20 static void quit_storage_daemon(void *qmp_test_state) { @@ -709,37 +723,33 @@ static void start_vhost_user_blk(GString *cmd_line, i= nt vus_instances, int num_queues) { const char *vhost_user_blk_bin =3D qtest_qemu_storage_daemon_binary(); - int fd, qmp_fd, i; + int qmp_fd, i; QTestState *qmp_test_state; gchar *img_path; - char *sock_path =3D NULL; - char *qmp_sock_path =3D g_strdup(qmp_sock_path_tempate); + char *qmp_sock_path; GString *storage_daemon_command =3D g_string_new(NULL); =20 - qmp_fd =3D mkstemp(qmp_sock_path); - g_assert_cmpint(qmp_fd, >=3D, 0); - g_test_queue_destroy(destroy_file, qmp_sock_path); + qmp_sock_path =3D create_listen_socket(&qmp_fd); =20 g_string_append_printf(storage_daemon_command, "exec %s " - "--chardev socket,id=3Dqmp,path=3D%s,server,nowait --monitor c= hardev=3Dqmp ", - vhost_user_blk_bin, qmp_sock_path); + "--chardev socket,id=3Dqmp,fd=3D%d,server,nowait --monitor cha= rdev=3Dqmp ", + vhost_user_blk_bin, qmp_fd); =20 g_string_append_printf(cmd_line, " -object memory-backend-memfd,id=3Dmem,size=3D256M,share=3Don= -M memory-backend=3Dmem "); =20 for (i =3D 0; i < vus_instances; i++) { - sock_path =3D g_strdup(sock_path_tempate); - fd =3D mkstemp(sock_path); - g_assert_cmpint(fd, >=3D, 0); - g_test_queue_destroy(drive_file, sock_path); + int fd; + char *sock_path =3D create_listen_socket(&fd); + /* create image file */ img_path =3D drive_create(); g_string_append_printf(storage_daemon_command, "--blockdev driver=3Dfile,node-name=3Ddisk%d,filename=3D%s " - "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dunix,a= ddr.path=3D%s," + "--export type=3Dvhost-user-blk,id=3Ddisk%d,addr.type=3Dfd,add= r.str=3D%d," "node-name=3Ddisk%i,writable=3Don,num-queues=3D%d ", - i, img_path, i, sock_path, i, num_queues); + i, img_path, i, fd, i, num_queues); =20 g_string_append_printf(cmd_line, "-chardev socket,id=3Dchar%d,path= =3D%s ", i + 1, sock_path); --=20 MST From nobody Sun May 5 14:21:27 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=1605480288; cv=none; d=zohomail.com; s=zohoarc; b=jMc+6gD35zrZmvgDEW2QXJUxTS+Y/lzsHP6mZMWx7dRgqVaVqLLOfO+gXOubHu4o4r+Y5ZCt/bivxHLPunu80Cjg8uruTyPAikjearUZ8AVc7OJ4D+4TY2Woy7i1VdLjoYKs+GxYBaJvkBdLqhCag10SbAyMbY15Ref/MluFZDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605480288; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sj68cdCA9LyFZYlFjD9WVlfQAIJDumEclBu2gkC8660=; b=NvF9zbws1F70E/RI2fpPDkrn5XHf7+qKF1v0LEosccWHfSZ4opmK2f34AIZDhcMgydVhbyCGkX9ma6ASSAAIi0HNlnJSPR9lpY1kiiRJPWZ3/RNX8PIRlD4Vy+JN8tAmvH/ktNGL5XdG8oLNXSVN7p6qk7HX6MR5pH60cGk7LoA= 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 1605480288458572.0886117973449; Sun, 15 Nov 2020 14:44:48 -0800 (PST) Received: from localhost ([::1]:37786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQlL-0008J1-Db for importer@patchew.org; Sun, 15 Nov 2020 17:44:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQV0-0000bN-GQ for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQUy-0001aO-2l for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:54 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-6x-Xy6o5O32hhgL6BcrgHA-1; Sun, 15 Nov 2020 17:27:49 -0500 Received: by mail-wr1-f72.google.com with SMTP id z7so8646532wrl.14 for ; Sun, 15 Nov 2020 14:27:49 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id v67sm18150973wma.17.2020.11.15.14.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479271; 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: in-reply-to:in-reply-to:references:references; bh=Sj68cdCA9LyFZYlFjD9WVlfQAIJDumEclBu2gkC8660=; b=AAF5jKdK6I5l5ZYKWGW0xBn9BDq+n6Cy0WXjC9dcM2sa4/z/ueqRyAdUUEDxmCruVPMJpl fVes4o0u7waORvxtyGnCov9N5/ycZkntGXq6v0MZX+MQWx9IBi2ndC3fXY8emGDEf6utux YNcR2Iq6ljZr853UjyKQxu6z5rt2FUM= X-MC-Unique: 6x-Xy6o5O32hhgL6BcrgHA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Sj68cdCA9LyFZYlFjD9WVlfQAIJDumEclBu2gkC8660=; b=ANC7ezmUR8wG0NnX8PTHu+32IR+BBtDj/2ZbETmGHCR+IWDncmin+3K9CLcTgLdHx+ DZVI89VKVZbhOnKG53VqQNkUBg1gswrhqQjB/Y6biT8xvsmmKzgPPzucjlWPK7yfh/1S XdZYU+G1vHkNeQ3zh90hrIJDhWRB5tDA6vo9OdCkxz1W0Lx3VFFk+sSBLef/3zppGxUO 3G/CdV4dBwvUCY1Jo5gKJRGjXiGqKT9Ma6PZ+szi70c4ylDFdroSz41K+2eUhzJIatE/ S0NeYc52LwewosIblTMqG8ke0DeFxC5POn6fy0W0mHeYP0nf5k9CPVo5qbgkzOMY5Q0o DWLQ== X-Gm-Message-State: AOAM530D4Uk8DMb/c3ijC1MR7n4SLwP/aAf46BEQ+6P/2DDCc6TozqkU 329NGhuVYVnxh1CPOTnchRUei45DuUAcsJVyIqIohQlowygcadW6TBq9zzOZ4pDumZKQSDYWU6Y LHs+z6nVleClQTbqJHDMkAWFMFNEJngUzlLOQYAt95v0PLRT7jWV3KcQJ0bzU X-Received: by 2002:adf:f00f:: with SMTP id j15mr16318561wro.102.1605479267624; Sun, 15 Nov 2020 14:27:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJFkyqk6CGEvE7AFiICdAlqODMsjeeNCqRzN3uytBRK/aH3+s782aVIvmhFVnXwozAp1r8Dw== X-Received: by 2002:adf:f00f:: with SMTP id j15mr16318539wro.102.1605479267400; Sun, 15 Nov 2020 14:27:47 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/17] block/export: port virtio-blk discard/write zeroes input validation Message-ID: <20201115220740.488850-14-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Coiby Xu , Max Reitz , Stefan Hajnoczi 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Validate discard/write zeroes the same way we do for virtio-blk. Some of these checks are mandated by the VIRTIO specification, others are internal to QEMU. Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-9-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- block/export/vhost-user-blk-server.c | 115 +++++++++++++++++++++------ 1 file changed, 92 insertions(+), 23 deletions(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 62672d1cb9..3295d3c951 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -22,6 +22,8 @@ =20 enum { VHOST_USER_BLK_NUM_QUEUES_DEFAULT =3D 1, + VHOST_USER_BLK_MAX_DISCARD_SECTORS =3D 32768, + VHOST_USER_BLK_MAX_WRITE_ZEROES_SECTORS =3D 32768, }; struct virtio_blk_inhdr { unsigned char status; @@ -58,30 +60,101 @@ static void vu_blk_req_complete(VuBlkReq *req) free(req); } =20 +static bool vu_blk_sect_range_ok(VuBlkExport *vexp, uint64_t sector, + size_t size) +{ + uint64_t nb_sectors =3D size >> BDRV_SECTOR_BITS; + uint64_t total_sectors; + + if (nb_sectors > BDRV_REQUEST_MAX_SECTORS) { + return false; + } + if ((sector << BDRV_SECTOR_BITS) % vexp->blk_size) { + return false; + } + blk_get_geometry(vexp->export.blk, &total_sectors); + if (sector > total_sectors || nb_sectors > total_sectors - sector) { + return false; + } + return true; +} + static int coroutine_fn -vu_blk_discard_write_zeroes(BlockBackend *blk, struct iovec *iov, +vu_blk_discard_write_zeroes(VuBlkExport *vexp, struct iovec *iov, uint32_t iovcnt, uint32_t type) { + BlockBackend *blk =3D vexp->export.blk; struct virtio_blk_discard_write_zeroes desc; - ssize_t size =3D iov_to_buf(iov, iovcnt, 0, &desc, sizeof(desc)); + ssize_t size; + uint64_t sector; + uint32_t num_sectors; + uint32_t max_sectors; + uint32_t flags; + int bytes; + + /* Only one desc is currently supported */ + if (unlikely(iov_size(iov, iovcnt) > sizeof(desc))) { + return VIRTIO_BLK_S_UNSUPP; + } + + size =3D iov_to_buf(iov, iovcnt, 0, &desc, sizeof(desc)); if (unlikely(size !=3D sizeof(desc))) { - error_report("Invalid size %zd, expect %zu", size, sizeof(desc)); - return -EINVAL; + error_report("Invalid size %zd, expected %zu", size, sizeof(desc)); + return VIRTIO_BLK_S_IOERR; } =20 - uint64_t range[2] =3D { le64_to_cpu(desc.sector) << 9, - le32_to_cpu(desc.num_sectors) << 9 }; - if (type =3D=3D VIRTIO_BLK_T_DISCARD) { - if (blk_co_pdiscard(blk, range[0], range[1]) =3D=3D 0) { - return 0; + sector =3D le64_to_cpu(desc.sector); + num_sectors =3D le32_to_cpu(desc.num_sectors); + flags =3D le32_to_cpu(desc.flags); + max_sectors =3D (type =3D=3D VIRTIO_BLK_T_WRITE_ZEROES) ? + VHOST_USER_BLK_MAX_WRITE_ZEROES_SECTORS : + VHOST_USER_BLK_MAX_DISCARD_SECTORS; + + /* This check ensures "num_sectors << BDRV_SECTOR_BITS" fits in an int= */ + if (unlikely(num_sectors > max_sectors)) { + return VIRTIO_BLK_S_IOERR; + } + + bytes =3D num_sectors << BDRV_SECTOR_BITS; + + if (unlikely(!vu_blk_sect_range_ok(vexp, sector, bytes))) { + return VIRTIO_BLK_S_IOERR; + } + + /* + * The device MUST set the status byte to VIRTIO_BLK_S_UNSUPP for disc= ard + * and write zeroes commands if any unknown flag is set. + */ + if (unlikely(flags & ~VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP)) { + return VIRTIO_BLK_S_UNSUPP; + } + + if (type =3D=3D VIRTIO_BLK_T_WRITE_ZEROES) { + int blk_flags =3D 0; + + if (flags & VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP) { + blk_flags |=3D BDRV_REQ_MAY_UNMAP; } - } else if (type =3D=3D VIRTIO_BLK_T_WRITE_ZEROES) { - if (blk_co_pwrite_zeroes(blk, range[0], range[1], 0) =3D=3D 0) { - return 0; + + if (blk_co_pwrite_zeroes(blk, sector << BDRV_SECTOR_BITS, + bytes, blk_flags) =3D=3D 0) { + return VIRTIO_BLK_S_OK; + } + } else if (type =3D=3D VIRTIO_BLK_T_DISCARD) { + /* + * The device MUST set the status byte to VIRTIO_BLK_S_UNSUPP for + * discard commands if the unmap flag is set. + */ + if (unlikely(flags & VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP)) { + return VIRTIO_BLK_S_UNSUPP; + } + + if (blk_co_pdiscard(blk, sector << BDRV_SECTOR_BITS, bytes) =3D=3D= 0) { + return VIRTIO_BLK_S_OK; } } =20 - return -EINVAL; + return VIRTIO_BLK_S_IOERR; } =20 static void coroutine_fn vu_blk_virtio_process_req(void *opaque) @@ -170,19 +243,13 @@ static void coroutine_fn vu_blk_virtio_process_req(vo= id *opaque) } case VIRTIO_BLK_T_DISCARD: case VIRTIO_BLK_T_WRITE_ZEROES: { - int rc; - if (!vexp->writable) { req->in->status =3D VIRTIO_BLK_S_IOERR; break; } =20 - rc =3D vu_blk_discard_write_zeroes(blk, &elem->out_sg[1], out_num,= type); - if (rc =3D=3D 0) { - req->in->status =3D VIRTIO_BLK_S_OK; - } else { - req->in->status =3D VIRTIO_BLK_S_IOERR; - } + req->in->status =3D vu_blk_discard_write_zeroes(vexp, elem->out_sg, + out_num, type); break; } default: @@ -352,10 +419,12 @@ vu_blk_initialize_config(BlockDriverState *bs, config->min_io_size =3D cpu_to_le16(1); config->opt_io_size =3D cpu_to_le32(1); config->num_queues =3D cpu_to_le16(num_queues); - config->max_discard_sectors =3D cpu_to_le32(32768); + config->max_discard_sectors =3D + cpu_to_le32(VHOST_USER_BLK_MAX_DISCARD_SECTORS); config->max_discard_seg =3D cpu_to_le32(1); config->discard_sector_alignment =3D cpu_to_le32(config->blk_size >> 9= ); - config->max_write_zeroes_sectors =3D cpu_to_le32(32768); + config->max_write_zeroes_sectors + =3D cpu_to_le32(VHOST_USER_BLK_MAX_WRITE_ZEROES_SECTORS); config->max_write_zeroes_seg =3D cpu_to_le32(1); } =20 --=20 MST From nobody Sun May 5 14:21:27 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=1605479839; cv=none; d=zohomail.com; s=zohoarc; b=ec+fg1gzBJb2YBPm0xhGyU14G0I2IdTL/fmtnSMxqkBYdUoR2JIqvhhyKdwRG038sPU79dYVNJDd1u1d9bftm5Db57yYBHFEXCz/Ti6Apn6wR/T/vgP6vWtRO1qfUNkGk7zJ8DN9isk8KFxPtzB23VUSAGACPcLplof5nQ5SVVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479839; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hNj3O+0UUhM/CTz4F1SZ3hwV0N3LMiDYPqcb3nWx72c=; b=eKvc95tSPDCBpKRQCBeB4E3l4uZKuZWYTmOMPEmF8Hl9f2q1tLWDkTZaudKko3K4DJFHkMIKw+Li3t6FNqznFG7/MUilmjZDf0sOxKUjFwDT1+jMB1CysQr/q1qAlJ2Bi+2U4vuKOBq5T5wKCUkhImbDgWQWhxxoJR5Wsg5Dufg= 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 1605479839503893.317143899745; Sun, 15 Nov 2020 14:37:19 -0800 (PST) Received: from localhost ([::1]:48640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQe6-00013l-7y for importer@patchew.org; Sun, 15 Nov 2020 17:37:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQV2-0000gQ-HZ for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23455) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQV0-0001aX-Ej for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:56 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-MnseJFlAN1ypql6tNfBXSg-1; Sun, 15 Nov 2020 17:27:52 -0500 Received: by mail-wr1-f72.google.com with SMTP id d8so9840661wrr.10 for ; Sun, 15 Nov 2020 14:27:51 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id 6sm13626931wrn.72.2020.11.15.14.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479273; 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: in-reply-to:in-reply-to:references:references; bh=hNj3O+0UUhM/CTz4F1SZ3hwV0N3LMiDYPqcb3nWx72c=; b=W9WN25Fv+ZOR7B/6HGt7yNa45ky1z+jygVQp61Yzpz7tCM59Dm1HPhaNEpUHRswWBVZRfn sRn7BI9GoKET4qQvv6P1K6B9jZp74P6ftJG0Z94/cDhEPyQYpzVCWSwRumZcRJRf5zxAWU al9SHVUWw0tgB8AQmF6R3ZsWAHGeCXw= X-MC-Unique: MnseJFlAN1ypql6tNfBXSg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hNj3O+0UUhM/CTz4F1SZ3hwV0N3LMiDYPqcb3nWx72c=; b=FtJxBDOQn5Cd/psruPNu/nDZLgVvqNDhM9wBEV6uBRGQc1DWe2fpe953gMLlL5Zmvn vkHLshg3QaWdZS4jCzfGf9c9g2B47i4kXB20BjdTAmjJGc45ipDvucszhsTCVoOGuMaX 3OVaBKBML4K48rcpj6wTus9L+bf/Aetl7XOPxSh9FBnYK/ATFK0EIfzOTg5r72vbQZZt z15O0ZVPLddzlJ7W73gcTBaaMBslAeldVErlZOODDaduboMAr4jfH2y8bdQf2dCVef3B fwuxnBipZq2rBtd/IU6ockGdRhzH/oiUKndRnlp3uEbx87gZyhpRXKw9tKwVreicm3eT pGtQ== X-Gm-Message-State: AOAM530jsqTOD3T0j+/nG0c//bLEwh0rrEBCjJ5sydfCwUxS9QgYB4Dl 8Dc4Q2kUGlz1EBSCIcK9rVk3py/NBYoFke+TkZppP/ebyk3SYsDGKcIOOMpPaGR0PSyYWHPZmEr WHRoLBjUZ7y0g4hAztDajTxJkchKUIAw1XVKnsxYdK6Je6TwXVWB9JLwBzvO6 X-Received: by 2002:adf:f549:: with SMTP id j9mr16313495wrp.324.1605479270599; Sun, 15 Nov 2020 14:27:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ+W5NVksGMGKLmkvVKMsAG2ILyPeS0+wlJXlTBD6YchM2lUDjMVpPoA21C00YlcD0fyimlQ== X-Received: by 2002:adf:f549:: with SMTP id j9mr16313476wrp.324.1605479270355; Sun, 15 Nov 2020 14:27:50 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/17] vhost-user-blk-test: test discard/write zeroes invalid inputs Message-ID: <20201115220740.488850-15-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Thomas Huth , qemu-block@nongnu.org, Laurent Vivier , Coiby Xu , Max Reitz , Stefan Hajnoczi , Paolo Bonzini 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Exercise input validation code paths in block/export/vhost-user-blk-server.c. Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-10-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- block/export/vhost-user-blk-server.c | 4 +- tests/qtest/vhost-user-blk-test.c | 124 +++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 2 deletions(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 3295d3c951..d88e41714d 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -248,8 +248,8 @@ static void coroutine_fn vu_blk_virtio_process_req(void= *opaque) break; } =20 - req->in->status =3D vu_blk_discard_write_zeroes(vexp, elem->out_sg, - out_num, type); + req->in->status =3D vu_blk_discard_write_zeroes(vexp, out_iov, out= _num, + type); break; } default: diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index e52340cffb..991a018c55 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -90,6 +90,124 @@ static uint64_t virtio_blk_request(QGuestAllocator *all= oc, QVirtioDevice *d, return addr; } =20 +static void test_invalid_discard_write_zeroes(QVirtioDevice *dev, + QGuestAllocator *alloc, + QTestState *qts, + QVirtQueue *vq, + uint32_t type) +{ + QVirtioBlkReq req; + struct virtio_blk_discard_write_zeroes dwz_hdr; + struct virtio_blk_discard_write_zeroes dwz_hdr2[2]; + uint64_t req_addr; + uint32_t free_head; + uint8_t status; + + /* More than one dwz is not supported */ + req.type =3D type; + req.data =3D (char *) dwz_hdr2; + dwz_hdr2[0].sector =3D 0; + dwz_hdr2[0].num_sectors =3D 1; + dwz_hdr2[0].flags =3D 0; + dwz_hdr2[1].sector =3D 1; + dwz_hdr2[1].num_sectors =3D 1; + dwz_hdr2[1].flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr2[0]); + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr2[1]); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr2)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr2), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr2), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr2)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_UNSUPP); + + guest_free(alloc, req_addr); + + /* num_sectors must be less than config->max_write_zeroes_sectors */ + req.type =3D type; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 0xffffffff; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_IOERR); + + guest_free(alloc, req_addr); + + /* sector must be less than the device capacity */ + req.type =3D type; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D TEST_IMAGE_SIZE / 512 + 1; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D 0; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_IOERR); + + guest_free(alloc, req_addr); + + /* reserved flag bits must be zero */ + req.type =3D type; + req.data =3D (char *) &dwz_hdr; + dwz_hdr.sector =3D 0; + dwz_hdr.num_sectors =3D 1; + dwz_hdr.flags =3D ~VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP; + + virtio_blk_fix_dwz_hdr(dev, &dwz_hdr); + + req_addr =3D virtio_blk_request(alloc, dev, &req, sizeof(dwz_hdr)); + + free_head =3D qvirtqueue_add(qts, vq, req_addr, 16, false, true); + qvirtqueue_add(qts, vq, req_addr + 16, sizeof(dwz_hdr), false, true); + qvirtqueue_add(qts, vq, req_addr + 16 + sizeof(dwz_hdr), 1, true, + false); + + qvirtqueue_kick(qts, dev, vq, free_head); + + qvirtio_wait_used_elem(qts, dev, vq, free_head, NULL, + QVIRTIO_BLK_TIMEOUT_US); + status =3D readb(req_addr + 16 + sizeof(dwz_hdr)); + g_assert_cmpint(status, =3D=3D, VIRTIO_BLK_S_UNSUPP); + + guest_free(alloc, req_addr); +} + /* Returns the request virtqueue so the caller can perform further tests */ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc) { @@ -231,6 +349,9 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGues= tAllocator *alloc) g_free(data); =20 guest_free(alloc, req_addr); + + test_invalid_discard_write_zeroes(dev, alloc, qts, vq, + VIRTIO_BLK_T_WRITE_ZEROES); } =20 if (features & (1u << VIRTIO_BLK_F_DISCARD)) { @@ -259,6 +380,9 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGues= tAllocator *alloc) g_assert_cmpint(status, =3D=3D, 0); =20 guest_free(alloc, req_addr); + + test_invalid_discard_write_zeroes(dev, alloc, qts, vq, + VIRTIO_BLK_T_DISCARD); } =20 if (features & (1u << VIRTIO_F_ANY_LAYOUT)) { --=20 MST From nobody Sun May 5 14:21:27 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=1605479819; cv=none; d=zohomail.com; s=zohoarc; b=h9yQTMfxf7YLshcHa9K5I8ydKg6dYlyKuBbwzuyUaA9OP/ZCPkFk7ve9mweCiX3KVB49UgR/7sw15nSJSWfSgpWaFZdP3OLP0vxkLgDSrFSImHqHn+YkcYlQV748ZGha9S8j5+IZpCcRAQ/DKotN9EHaoRlzfFLWiI4u3/zlMJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605479819; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YyzcHr5pc04nBGrUs6cDVbhWISou0mXaM0HOd2coAqQ=; b=a7eInUGEsZcWDZmYsdTqPR9CILH8rbwLxm2Ubo3OS7xET9jt8vxeTIfKECFAcY2z/RAacahTOpOwQVqb9hjabRRcpDaTJoiCbrgkT5Yo3dos+XB8Q/OHz0AcHMaCdN4blFo14uwCdMXq+lC7cTADizKmyX2VMKbsAKRlLWRSLKo= 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 1605479819589687.4838631155886; Sun, 15 Nov 2020 14:36:59 -0800 (PST) Received: from localhost ([::1]:47510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQdl-0000Nr-W4 for importer@patchew.org; Sun, 15 Nov 2020 17:36:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQV5-0000nH-5W for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQV3-0001an-CX for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:27:58 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-HYbVd5XFPYSHnPaNEoJHng-1; Sun, 15 Nov 2020 17:27:54 -0500 Received: by mail-wr1-f70.google.com with SMTP id h29so9781111wrb.13 for ; Sun, 15 Nov 2020 14:27:54 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id t74sm17810566wmt.8.2020.11.15.14.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479276; 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: in-reply-to:in-reply-to:references:references; bh=YyzcHr5pc04nBGrUs6cDVbhWISou0mXaM0HOd2coAqQ=; b=GNzITIogQg/ky7wY5NLYOgNzzmTN18Glq7l75a8Stq/xzFejvJqeuQNcOFWCevwOpq6r51 SPzEfXyGElj9Q0rMYGCm4vYRKWW4Dirjy6qkFRFJoxwetSQHhDmNzx6x1I5JzMgEjuzgnT yMkGu2iC7Ah/Kdlxot2TJi7Qo9fOhDU= X-MC-Unique: HYbVd5XFPYSHnPaNEoJHng-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YyzcHr5pc04nBGrUs6cDVbhWISou0mXaM0HOd2coAqQ=; b=Sa/hOTB9Idge863/HxE+YrUP7jBhpt4+nndqfM5TaZXDhZ20iX1IHwcKknhOB1sC/x 4gLwF2+IjMqgE0oil/nAIeOPGVPVsXQrqRVTWDLyeSjmn9KgJ8cYBmVp1x8hk2hDxPhX mOAAaiqd0Kg7NzxXQPBqfGg9LGWrdwFs6ePkp1CK4Jf5QfSkP58256s8etvtKTpfiYwl yp3kKSkT9Uz0ogGaTYxHA0/xyI4yauULS41ddL6LqeQSpNn2X5IqbIyfFeyWJPTk2O/1 2DI7dGBWb0O6yAzGHpXGu/JNpnbr4kVDQFIrgx6gAOtN5EoyQpg7Bi5T/JIkWuXVih5i 45tQ== X-Gm-Message-State: AOAM5304rEqgVdgArvSj4lpqmjwXQgjN4zz2ArD9v5RtB5tY83fQiGhG B3UJVfFfdnqLLo/MybcqL4MNKmdQSHqLvajw+w58bfciSWbLdMveJ9Uml7jaia7CQ84PzxILFAY l1pAQWZCGqQ2A5ID8xO6HwD9hD5AzTOPmadlGQXyHZDInvMgypgx7+k9/OaDp X-Received: by 2002:a7b:c308:: with SMTP id k8mr12162974wmj.76.1605479273333; Sun, 15 Nov 2020 14:27:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiBV0BfKIjzqEP7c1f2dUze+a2fGG1cQ+0nYrhFZy96TkLi/mO129cta4PJnvqG7dCAIr+uA== X-Received: by 2002:a7b:c308:: with SMTP id k8mr12162955wmj.76.1605479273116; Sun, 15 Nov 2020 14:27:53 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/17] block/export: port virtio-blk read/write range check Message-ID: <20201115220740.488850-16-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Coiby Xu , Max Reitz , Stefan Hajnoczi 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 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Check that the sector number and byte count are valid. Signed-off-by: Stefan Hajnoczi Message-Id: <20201111124331.1393747-11-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- block/export/vhost-user-blk-server.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index d88e41714d..6d7fd0fec3 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -214,9 +214,23 @@ static void coroutine_fn vu_blk_virtio_process_req(voi= d *opaque) QEMUIOVector qiov; if (is_write) { qemu_iovec_init_external(&qiov, out_iov, out_num); + + if (unlikely(!vu_blk_sect_range_ok(vexp, req->sector_num, + qiov.size))) { + req->in->status =3D VIRTIO_BLK_S_IOERR; + break; + } + ret =3D blk_co_pwritev(blk, offset, qiov.size, &qiov, 0); } else { qemu_iovec_init_external(&qiov, in_iov, in_num); + + if (unlikely(!vu_blk_sect_range_ok(vexp, req->sector_num, + qiov.size))) { + req->in->status =3D VIRTIO_BLK_S_IOERR; + break; + } + ret =3D blk_co_preadv(blk, offset, qiov.size, &qiov, 0); } if (ret >=3D 0) { --=20 MST From nobody Sun May 5 14:21:27 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=1605480133; cv=none; d=zohomail.com; s=zohoarc; b=I/LrvrH/x8+1fKfTaqn/xphoDQGjtxNay+nQLcL0CdaeqiABS0S4bEaYRQLcGrmlmZY0xaHtcfxJFFHD2eCUcqwCnY/z8fJ99M9JqAoWQNs668FmvMpLUye6J8T25N4JrvVqa50XjU3no98R+HEqHfsgPv5xY7Yyo8x6b33sOr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605480133; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jNBQehzeHZf620Wy5iH4Q5itvrw949b87YQTXO/Cb1Q=; b=S+Ytx8ReoF+j1j9B2xIwb1g34RYmSPBy2MRCT2Ld7PxvOBpUlMPlyq73q2JOk7UeG+qUUwjbtt57d9RjRY+B5x3YlPNH38IwajNJDI5VCKW4ZLapbo7uOhIDPDOMfiViPdB4I8mgSs/1M65mINxRX1Xn2DlkfZ0BpvYHLZOvyqQ= 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 16054801338081004.4204537422404; Sun, 15 Nov 2020 14:42:13 -0800 (PST) Received: from localhost ([::1]:59070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQiq-0005Tx-HQ for importer@patchew.org; Sun, 15 Nov 2020 17:42:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQVA-00011t-FE for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:28:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQV8-0001b4-E2 for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:28:04 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-265-1aTfaOptMGiQCmTNfMb91Q-1; Sun, 15 Nov 2020 17:27:57 -0500 Received: by mail-wm1-f72.google.com with SMTP id g3so7739433wmh.9 for ; Sun, 15 Nov 2020 14:27:57 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id q5sm16382583wrf.41.2020.11.15.14.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479281; 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: in-reply-to:in-reply-to:references:references; bh=jNBQehzeHZf620Wy5iH4Q5itvrw949b87YQTXO/Cb1Q=; b=YMwZLuXUxWbpvfuK1s4EF20+j8xQ1smv9G8H3nvmJ9gZAWS4ZCGFJVIKh+cUadVp+qnvSD y9f5pnkJVXTsbyqyfiHSHL6W6MzAnIFkCVQBTfzlLMv+SpLFroWmRCORCLYlO2FkQn5/Kq iiMBDm2XOsiU6gTtOngt7qf6IioQ0f8= X-MC-Unique: 1aTfaOptMGiQCmTNfMb91Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jNBQehzeHZf620Wy5iH4Q5itvrw949b87YQTXO/Cb1Q=; b=Bujb3wPSgGjTrQAvQGgABOTjnOXy6TQn29MYO4yu5WORRfaHPsJSHpaJpNaKqRu65Z 7AYSslLQ4HaxmRWdDaZHXoZ690aOuDgO75nYt7mEVLtKEBMnK1pGpep2kWIXLQPlZA4A 5G769zzSIz09Usmu3QEdyB1zCqVU3BPcyEsKRsjeOFNy/A9z9Undq6M9CPb9jmYBdQPg g+PB7BrDhy/ZBjbKPXT6HmqdvHq0s9ept664YXHTg/eS6aAOx0Dwq8qZGsteoX7GZKpe XG11oEaFwZX3ME2E4NJ5suGD0U+qL8BBnh/QrZyhTowOijDALCvBh45fTEfywfc+eHWp qWqQ== X-Gm-Message-State: AOAM531P+oWODztdvYRC+dtoQ4ulUoVIoc1RZfOYLbAcImCfHcheMV2+ ucQJVGrK5/jO/B/AxoEXa6trC+5wU23fNd3T3fDJ/GCyhS1Ml+9cTsNS0lsdm20vamWnfh18Xv7 CYWZCQjH71/gWFQV6+n2Bi0yB559w135ojOz/lMup5msiKDyuPg0Vb/PEvlG0 X-Received: by 2002:a5d:4e46:: with SMTP id r6mr15863237wrt.218.1605479276185; Sun, 15 Nov 2020 14:27:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpsgZiqiK1laYk3oa6PqbMLPx9gxEVcNdVQ/RxWq7EoSXmFX2yo1ZT5ZmwSC8nlvqK2CUDkA== X-Received: by 2002:a5d:4e46:: with SMTP id r6mr15863215wrt.218.1605479275970; Sun, 15 Nov 2020 14:27:55 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 16/17] contrib/libvhost-user: Fix bad printf format specifiers Message-ID: <20201115220740.488850-17-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 16:39:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Raphael Norwitz , AlexChen , Stefan Hajnoczi , Euler Robot , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" From: AlexChen We should use printf format specifier "%u" instead of "%d" for argument of type "unsigned int". Reported-by: Euler Robot Signed-off-by: Alex Chen Message-Id: <5FA28106.6000901@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/libvhost-user/libvhost-user.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index bfec8a881a..5c73ffdd6b 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -701,7 +701,7 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { return false; } =20 - DPRINT("Adding region: %d\n", dev->nregions); + DPRINT("Adding region: %u\n", dev->nregions); DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n", msg_region->guest_phys_addr); DPRINT(" memory_size: 0x%016"PRIx64"\n", @@ -848,7 +848,7 @@ vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg= *vmsg) VhostUserMemory m =3D vmsg->payload.memory, *memory =3D &m; dev->nregions =3D memory->nregions; =20 - DPRINT("Nregions: %d\n", memory->nregions); + DPRINT("Nregions: %u\n", memory->nregions); for (i =3D 0; i < dev->nregions; i++) { void *mmap_addr; VhostUserMemoryRegion *msg_region =3D &memory->regions[i]; @@ -938,7 +938,7 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg) return vu_set_mem_table_exec_postcopy(dev, vmsg); } =20 - DPRINT("Nregions: %d\n", memory->nregions); + DPRINT("Nregions: %u\n", memory->nregions); for (i =3D 0; i < dev->nregions; i++) { void *mmap_addr; VhostUserMemoryRegion *msg_region =3D &memory->regions[i]; @@ -1049,8 +1049,8 @@ vu_set_vring_num_exec(VuDev *dev, VhostUserMsg *vmsg) unsigned int index =3D vmsg->payload.state.index; unsigned int num =3D vmsg->payload.state.num; =20 - DPRINT("State.index: %d\n", index); - DPRINT("State.num: %d\n", num); + DPRINT("State.index: %u\n", index); + DPRINT("State.num: %u\n", num); dev->vq[index].vring.num =3D num; =20 return false; @@ -1105,8 +1105,8 @@ vu_set_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg) unsigned int index =3D vmsg->payload.state.index; unsigned int num =3D vmsg->payload.state.num; =20 - DPRINT("State.index: %d\n", index); - DPRINT("State.num: %d\n", num); + DPRINT("State.index: %u\n", index); + DPRINT("State.num: %u\n", num); dev->vq[index].shadow_avail_idx =3D dev->vq[index].last_avail_idx =3D = num; =20 return false; @@ -1117,7 +1117,7 @@ vu_get_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg) { unsigned int index =3D vmsg->payload.state.index; =20 - DPRINT("State.index: %d\n", index); + DPRINT("State.index: %u\n", index); vmsg->payload.state.num =3D dev->vq[index].last_avail_idx; vmsg->size =3D sizeof(vmsg->payload.state); =20 @@ -1478,8 +1478,8 @@ vu_set_vring_enable_exec(VuDev *dev, VhostUserMsg *vm= sg) unsigned int index =3D vmsg->payload.state.index; unsigned int enable =3D vmsg->payload.state.num; =20 - DPRINT("State.index: %d\n", index); - DPRINT("State.enable: %d\n", enable); + DPRINT("State.index: %u\n", index); + DPRINT("State.enable: %u\n", enable); =20 if (index >=3D dev->max_queues) { vu_panic(dev, "Invalid vring_enable index: %u", index); @@ -1728,7 +1728,7 @@ vu_handle_vring_kick(VuDev *dev, VhostUserMsg *vmsg) return false; } =20 - DPRINT("Got kick message: handler:%p idx:%d\n", + DPRINT("Got kick message: handler:%p idx:%u\n", dev->vq[index].handler, index); =20 if (!dev->vq[index].started) { @@ -1772,7 +1772,7 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg) DPRINT("Request: %s (%d)\n", vu_request_to_string(vmsg->request), vmsg->request); DPRINT("Flags: 0x%x\n", vmsg->flags); - DPRINT("Size: %d\n", vmsg->size); + DPRINT("Size: %u\n", vmsg->size); =20 if (vmsg->fd_num) { int i; --=20 MST From nobody Sun May 5 14:21:27 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=1605480091; cv=none; d=zohomail.com; s=zohoarc; b=eptF1WhWNMev+4A2OjKNS84YjC8ijK4GSgmfDd6t464seyHZKHNFw8uhEbFEJ7yCSMuOTu63JOmxIoLhHusw4qO7nCbkQ6+WBWAokAU9u6Zlt1TnYMrLwMD5I1BJCi7reFT2HLbOp9yFqn5AEbHc9GZOiEP0ydPaGE9FCV18IdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605480091; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eTDyF8qZ/+kyOvEMv/zkAMXekpV6mWj/zaDDozu+j7g=; b=iRuGQKdAJnb7pmerYZaNxCUdOlMktdPbf1MuGbsCc39eqwd/94JD/OMsgjGgnrcJ87q7M/F+2fQDAMUyT/OyQPCMu0rCaM4aF2SArBOujayAIFgk1Xb01+kwTleIJs+mpLVy/xGthhO7yLJmaVl0K+EwlAnP65C106WDnNOyrp0= 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 1605480091972990.7826861597331; Sun, 15 Nov 2020 14:41:31 -0800 (PST) Received: from localhost ([::1]:57368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1keQiA-0004eC-A9 for importer@patchew.org; Sun, 15 Nov 2020 17:41:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keQY7-00059X-Ub for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:31:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57114) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1keQY5-00022d-5n for qemu-devel@nongnu.org; Sun, 15 Nov 2020 17:31:07 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-516-ulJksqMvOI6qhboLzqSv0A-1; Sun, 15 Nov 2020 17:28:00 -0500 Received: by mail-wm1-f71.google.com with SMTP id u123so7774768wmu.5 for ; Sun, 15 Nov 2020 14:28:00 -0800 (PST) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id i11sm20553636wro.85.2020.11.15.14.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2020 14:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605479464; 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: in-reply-to:in-reply-to:references:references; bh=eTDyF8qZ/+kyOvEMv/zkAMXekpV6mWj/zaDDozu+j7g=; b=izupUJ0eVDgfSzTz6WNKbsOYMuJI7uFzhBFOkRrUlCeIZiGjzR8shND9KfPA8rlNxqsjoe rG0PvnNYg/lrmu/qPp/njFjQaM+x8S5lxxSbfVCTXS2osuaqq/qo2HWfuUwcsb7i+Su2ZH PfS34mKqnkI0+wVCC3BGzW9QSUK+jSE= X-MC-Unique: ulJksqMvOI6qhboLzqSv0A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eTDyF8qZ/+kyOvEMv/zkAMXekpV6mWj/zaDDozu+j7g=; b=Bok6WUOL54xNeABaM029s9940ydSXOLOgEAQx1PypLG9JavKTHlbPYTZ37SdTRUs8I gunwOCNznQ8BFQdBZnG7cMtiZ7GrZtAHUs3LoVNXem97EcXDtJeREQs4B2TVGpMezgjX ASoi9yOB+OrgzcF4XRRjMZJT3P5CgWbIgKTez0kzT3OBGdkhTXPR7iuT29o33qmBeeSs z3rh/Mspg0Rq6ghTsKzNUEHnnXvq4fG5VycnorKpOTITn0PL08T3HeqxGApcKpUuQIOg rHzM+iTdWRbIM6g5uLL1BMQDpxuzcEIuxRxnJBlI7r8Z8bCP24LrT/KK1w3yLCVDicEE tH8Q== X-Gm-Message-State: AOAM532f/IOGakrlQSyHUuXFe4SeDWu1EPepb9mOeY6qYkb7ieoRxyzK hqSms2NCkszx9AJMqsw1FDhypX2gcDON4u5Pq8R4MwsyacZc4qGfvKrTu61c2wk/9Vk02gDuvsB ZJEnrrf1WfalGD4aGBNVdOZVet+MIuH/hLmJ3llI3CxfVxzovGP3BZVKcIGtq X-Received: by 2002:adf:f906:: with SMTP id b6mr15874155wrr.244.1605479278715; Sun, 15 Nov 2020 14:27:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHBgrC1JX1YB6mBve5qxMgW1rryENpjvFcfCa5Ef0WRz5jjZZPEmw5NtVaPaUD72Z8VrSoGg== X-Received: by 2002:adf:f906:: with SMTP id b6mr15874140wrr.244.1605479278531; Sun, 15 Nov 2020 14:27:58 -0800 (PST) Date: Sun, 15 Nov 2020 17:27:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 17/17] vhost-user-blk/scsi: Fix broken error handling for socket call Message-ID: <20201115220740.488850-18-mst@redhat.com> References: <20201115220740.488850-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201115220740.488850-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=63.128.21.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/15 17:27:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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=ham 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: AlexChen , Peter Maydell , Raphael Norwitz , Euler Robot 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 Content-Type: text/plain; charset="utf-8" From: AlexChen When socket() fails, it returns -1, 0 is the normal return value and should= not return error. Reported-by: Euler Robot Signed-off-by: AlexChen Message-Id: <5F9A5B48.9030509@huawei.com> Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-blk/vhost-user-blk.c | 2 +- contrib/vhost-user-scsi/vhost-user-scsi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-b= lk/vhost-user-blk.c index caad88637e..dc981bf945 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -476,7 +476,7 @@ static int unix_sock_new(char *unix_fn) assert(unix_fn); =20 sock =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (sock <=3D 0) { + if (sock < 0) { perror("socket"); return -1; } diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user= -scsi/vhost-user-scsi.c index 3c912384e9..0f9ba4b2a2 100644 --- a/contrib/vhost-user-scsi/vhost-user-scsi.c +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c @@ -320,7 +320,7 @@ static int unix_sock_new(char *unix_fn) assert(unix_fn); =20 sock =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (sock <=3D 0) { + if (sock < 0) { perror("socket"); return -1; } --=20 MST