From nobody Tue Feb 10 03:44:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652737783; cv=none; d=zohomail.com; s=zohoarc; b=E/7UGAoQuGLwl0tcQpL1B9dcY9ecSfDrolXuuR4BwjaudMxI47rt2C48/0qsQeZOts/fTJmbZBVBPyfR1gRWjRG1VGf+AuyHVxkelIczyr3We6U1npGC/t1KANZAlppqdINPJZPVmVQygsVUpS/VrfiJMR1BvPZnUMcmHduuLUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652737783; 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=8fsb11g7Z/r9felQ/mYfcCmnlXTX8/HfVlLGPmxAWLE=; b=BN/XZU46HNChITg+dlc+3A4Ux7qzRw5joRtk6yv80UP5jQXXIM9iI1sVN+eNdquajCup6XcojacAbiX2pmEmlYtl82CDE3CFdyNnszfIV+qNZPO4f3/YK7TfB8lNQXFzdOztkkLd6ckt/+Dgm9x36p5KMrzzB/fWw5fRmn1Csu8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1652737783953112.3609581022813; Mon, 16 May 2022 14:49:43 -0700 (PDT) Received: from localhost ([::1]:36156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqib0-0007Y8-Uz for importer@patchew.org; Mon, 16 May 2022 17:49:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhk1-0002kR-GQ for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqhjz-0006oQ-OA for qemu-devel@nongnu.org; Mon, 16 May 2022 16:54:57 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-370-OgqDE45LPxG35v9rLO6MSA-1; Mon, 16 May 2022 16:54:54 -0400 Received: by mail-ed1-f69.google.com with SMTP id c17-20020a056402159100b0042ab2e56743so2405426edv.10 for ; Mon, 16 May 2022 13:54:53 -0700 (PDT) Received: from redhat.com ([2.55.131.38]) by smtp.gmail.com with ESMTPSA id u2-20020aa7db82000000b0042617ba63a7sm5714415edt.49.2022.05.16.13.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 13:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652734495; 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=8fsb11g7Z/r9felQ/mYfcCmnlXTX8/HfVlLGPmxAWLE=; b=aSEu8RnKxr4RCLkXO8InHXtzTJ9evxXC6hljl0ZnloBhCwZMEEGskqUzreXLqht2NY+VW+ BF40QOQl1SWL2ZqmN1zJ45CVXyTu9BkcCGDVGkQUccnCJqniJ0GIzPhCCAQoSZL5HnGMDX YdIIArKhp20xDxf6c+ZfpBD+x5QPRjM= X-MC-Unique: OgqDE45LPxG35v9rLO6MSA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=8fsb11g7Z/r9felQ/mYfcCmnlXTX8/HfVlLGPmxAWLE=; b=PPb7TOGvQJg8dgUDKMamXuEU5+jL2hd2Tjwzo8zd0/nc2r31LQkdJGPg2tbUWlOpON OKqOi4nPw+w0OUKv2w8ZMKkGK4RiiYxeB5xFil8JuE7wNUmJAiX7DXohqMjIzuNqitJ8 r5n3McnNgnjZtrO3ukynZS8zGZgrP1pbw+kuVo9UT1WHa/MtT3zJFBGyzFmKD4daXXz8 Nczl++4g8qkoUBZRkaqmpjwVJTjTvoZRzy+mWebO0Zzx8NbUVAFEIIYruzuxCcUJQflw /TNvdzNCndL8O9A8KKSxyOvrdoEph2qmNj7cIUkmn2lWQe1KrEoSceiHAAvB8Lx1rMYg Jyiw== X-Gm-Message-State: AOAM530WpycsjewBklkYTXzwmcpUjn/g9BY8pv0FHbdffz1QWgu9Za8I dDlURhqR2+nXxpdeDAiWIhew0lXWgyFWMkbVRHc1eMu/abbExYC4S0niOQB5pXXzhzum14pm0nZ 7VKm1gPb/JS8CQAhyJDb/CWDhNE64BLCmneAhZPXuxYe0TFEt/QZh/V/GE8cE X-Received: by 2002:a05:6402:4492:b0:428:a206:8912 with SMTP id er18-20020a056402449200b00428a2068912mr15349121edb.279.1652734492631; Mon, 16 May 2022 13:54:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPC746sWguu+Rvh1S03nNJeexy89Hz9+0Zfh1k4tQr5kuChVOsQQ4J+GCim5PwA4/mfrIHBg== X-Received: by 2002:a05:6402:4492:b0:428:a206:8912 with SMTP id er18-20020a056402449200b00428a2068912mr15349091edb.279.1652734492377; Mon, 16 May 2022 13:54:52 -0700 (PDT) Date: Mon, 16 May 2022 16:54:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?Q?Benn=C3=A9e?= , Maxime Coquelin , Stefan Hajnoczi , Raphael Norwitz , Paolo Bonzini , Fam Zheng Subject: [PULL v2 68/86] hw/virtio/vhost-user: don't suppress F_CONFIG when supported Message-ID: <20220516204913.542894-69-mst@redhat.com> References: <20220516204913.542894-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20220516204913.542894-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652737785096100003 From: Alex Benn=C3=A9e Previously we would silently suppress VHOST_USER_PROTOCOL_F_CONFIG during the protocol negotiation if the QEMU stub hadn't implemented the vhost_dev_config_notifier. However this isn't the only way we can handle config messages, the existing vdc->get/set_config can do this as well. Lightly re-factor the code to check for both potential methods and instead of silently squashing the feature error out. It is unlikely that a vhost-user backend expecting to handle CONFIG messages will behave correctly if they never get sent. Fixes: 1c3e5a2617 ("vhost-user: back SET/GET_CONFIG requests with a protoco= l feature") Cc: Maxime Coquelin Cc: Michael S. Tsirkin Cc: Stefan Hajnoczi Signed-off-by: Alex Benn=C3=A9e Message-Id: <20220321153037.3622127-13-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user.c | 44 ++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index e44a41bb70..6e0e8a71a3 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -22,6 +22,7 @@ typedef struct VhostUserState { CharBackend *chr; VhostUserHostNotifier notifier[VIRTIO_QUEUE_MAX]; int memory_slots; + bool supports_config; } VhostUserState; =20 bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp); diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 1b2f7eed98..9be21d07ee 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -121,6 +121,7 @@ static void vhost_user_scsi_realize(DeviceState *dev, E= rror **errp) vsc->dev.backend_features =3D 0; vqs =3D vsc->dev.vqs; =20 + s->vhost_user.supports_config =3D true; ret =3D vhost_dev_init(&vsc->dev, &s->vhost_user, VHOST_BACKEND_TYPE_USER, 0, errp); if (ret < 0) { diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 6c8f722262..b0d417651d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1949,14 +1949,15 @@ static int vhost_user_postcopy_notifier(NotifierWit= hReturn *notifier, static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, Error **errp) { - uint64_t features, protocol_features, ram_slots; + uint64_t features, ram_slots; struct vhost_user *u; + VhostUserState *vus =3D (VhostUserState *) opaque; int err; =20 assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_USER); =20 u =3D g_new0(struct vhost_user, 1); - u->user =3D opaque; + u->user =3D vus; u->dev =3D dev; dev->opaque =3D u; =20 @@ -1967,6 +1968,10 @@ static int vhost_user_backend_init(struct vhost_dev = *dev, void *opaque, } =20 if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) { + bool supports_f_config =3D vus->supports_config || + (dev->config_ops && dev->config_ops->vhost_dev_config_notifier= ); + uint64_t protocol_features; + dev->backend_features |=3D 1ULL << VHOST_USER_F_PROTOCOL_FEATURES; =20 err =3D vhost_user_get_u64(dev, VHOST_USER_GET_PROTOCOL_FEATURES, @@ -1976,19 +1981,34 @@ static int vhost_user_backend_init(struct vhost_dev= *dev, void *opaque, return -EPROTO; } =20 - dev->protocol_features =3D - protocol_features & VHOST_USER_PROTOCOL_FEATURE_MASK; + /* + * We will use all the protocol features we support - although + * we suppress F_CONFIG if we know QEMUs internal code can not sup= port + * it. + */ + protocol_features &=3D VHOST_USER_PROTOCOL_FEATURE_MASK; =20 - if (!dev->config_ops || !dev->config_ops->vhost_dev_config_notifie= r) { - /* Don't acknowledge CONFIG feature if device doesn't support = it */ - dev->protocol_features &=3D ~(1ULL << VHOST_USER_PROTOCOL_F_CO= NFIG); - } else if (!(protocol_features & - (1ULL << VHOST_USER_PROTOCOL_F_CONFIG))) { - error_setg(errp, "Device expects VHOST_USER_PROTOCOL_F_CONFIG " - "but backend does not support it."); - return -EINVAL; + if (supports_f_config) { + if (!virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_CONFIG)) { + error_setg(errp, "vhost-user device %s expecting " + "VHOST_USER_PROTOCOL_F_CONFIG but the vhost-use= r backend does " + "not support it.", dev->vdev->name); + return -EPROTO; + } + } else { + if (virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_CONFIG)) { + warn_reportf_err(*errp, "vhost-user backend supports " + "VHOST_USER_PROTOCOL_F_CONFIG for " + "device %s but QEMU does not.", + dev->vdev->name); + protocol_features &=3D ~(1ULL << VHOST_USER_PROTOCOL_F_CON= FIG); + } } =20 + /* final set of protocol features */ + dev->protocol_features =3D protocol_features; err =3D vhost_user_set_protocol_features(dev, dev->protocol_featur= es); if (err < 0) { error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); --=20 MST