From patchwork Tue Feb 25 15:13:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1244344 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KoCLNAk2; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48RjG33Wpdz9sQt for ; Wed, 26 Feb 2020 02:16:59 +1100 (AEDT) Received: from localhost ([::1]:58550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6bxB-0004uW-9I for incoming@patchwork.ozlabs.org; Tue, 25 Feb 2020 10:16:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55335) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6btm-0007d9-0o for qemu-devel@nongnu.org; Tue, 25 Feb 2020 10:13:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6btk-00016d-Qy for qemu-devel@nongnu.org; Tue, 25 Feb 2020 10:13:25 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:39469 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6btk-00016K-Me for qemu-devel@nongnu.org; Tue, 25 Feb 2020 10:13:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582643604; 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=GbXYhzT4HdCqyN2iskP5pyuuGP3IhftOdhWxCQdQeVU=; b=KoCLNAk21C1LLpIEYxyUpGeTOFLnXHVc8p38pIWh9LEp/3iQYx7B7buxqR+UNpPaO3PCBh gSUAthDQw5jvP6oHDK/bwFRVP8SEm459hJKS802o50cb716WBvYHbzc4sB46jlu0P34VFx M85QFDC+HKprgjAvIt76PvuXVqcpuxs= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-1pr1NmO4O4yHJ42nByxWhw-1; Tue, 25 Feb 2020 10:13:20 -0500 X-MC-Unique: 1pr1NmO4O4yHJ42nByxWhw-1 Received: by mail-qk1-f198.google.com with SMTP id q123so15343304qkb.1 for ; Tue, 25 Feb 2020 07:13:20 -0800 (PST) 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=XWpi8uIuYqDgAxSrNx/dNPfjKOUMUQTkfVlQ2qW7D7Y=; b=jTAEI3N322Z2O1oHsnrYi9vBQ07q9Eodyg0UekP0NOMlqgZ57tCzSU1fMJsQWJjar7 mmn+cu+0mXrlBtLoGbexVr/Hxef+A9vABjt5954stoBnbC6kwTSRK42ISPDtEOjZ3V/8 OIB2wSN/fNbYPsbKx2VGILvAKfoEIGMGIAXs9npQ3J52Ka1XRMO251WDzOMSo9LwAVDi wKV6s8RnS3sqjvwuRwRMWI1NA4h2BViBjfRPpA8VKYII6s3wV4xAMirZk4+Y6k5cHShg P0ZYF8z4pRpbGjJsiNRHLgdoMw7p3EUVnOR261DnOR7ztUwmqp4RP0lkH/ZAw4SinLUS x0aA== X-Gm-Message-State: APjAAAXPREH2K23o2BZnpBYE1nUdt3r5f6smLNLzre7b5wxHMfV6FEGI GfxVjTB5u1f2P3/nhZJsNi3O/4dNdNSWKg29VxgQRpo0A4dMKdN1FpslTLMZOGAlSw3raVObzvi sV8o7XKLg50sBbmU= X-Received: by 2002:a05:6214:1494:: with SMTP id bn20mr51323187qvb.43.1582643599414; Tue, 25 Feb 2020 07:13:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwYrjURwrUF8SqAALIsRsrcflyHpX1TwEyCa35tge0RQnzsgo/Eo2WYpuxXb352YKUszu3SaA== X-Received: by 2002:a05:6214:1494:: with SMTP id bn20mr51323167qvb.43.1582643599203; Tue, 25 Feb 2020 07:13:19 -0800 (PST) Received: from redhat.com (bzq-79-178-2-214.red.bezeqint.net. [79.178.2.214]) by smtp.gmail.com with ESMTPSA id c45sm7795604qtd.43.2020.02.25.07.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 07:13:18 -0800 (PST) Date: Tue, 25 Feb 2020 10:13:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/32] vhost-user-blk: convert to new virtio_delete_queue Message-ID: <20200225151210.647797-11-mst@redhat.com> References: <20200225151210.647797-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200225151210.647797-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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, Pan Nengyuan , Max Reitz , Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Pan Nengyuan use the new virtio_delete_queue function to cleanup. Signed-off-by: Pan Nengyuan Message-Id: <20200224041336.30790-3-pannengyuan@huawei.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-blk.h | 3 ++- hw/block/vhost-user-blk.c | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-user-blk.h index 108bfadeeb..05ea0ad183 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -36,7 +36,8 @@ typedef struct VHostUserBlk { struct vhost_dev dev; struct vhost_inflight *inflight; VhostUserState vhost_user; - struct vhost_virtqueue *vqs; + struct vhost_virtqueue *vhost_vqs; + VirtQueue **virtqs; guint watch; bool connected; } VHostUserBlk; diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 2eba8b9db0..12925a47ec 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -306,7 +306,7 @@ static int vhost_user_blk_connect(DeviceState *dev) s->connected = true; s->dev.nvqs = s->num_queues; - s->dev.vqs = s->vqs; + s->dev.vqs = s->vhost_vqs; s->dev.vq_index = 0; s->dev.backend_features = 0; @@ -420,13 +420,14 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); + s->virtqs = g_new(VirtQueue *, s->num_queues); for (i = 0; i < s->num_queues; i++) { - virtio_add_queue(vdev, s->queue_size, - vhost_user_blk_handle_output); + s->virtqs[i] = virtio_add_queue(vdev, s->queue_size, + vhost_user_blk_handle_output); } s->inflight = g_new0(struct vhost_inflight, 1); - s->vqs = g_new0(struct vhost_virtqueue, s->num_queues); + s->vhost_vqs = g_new0(struct vhost_virtqueue, s->num_queues); s->watch = 0; s->connected = false; @@ -458,11 +459,12 @@ reconnect: return; virtio_err: - g_free(s->vqs); + g_free(s->vhost_vqs); g_free(s->inflight); for (i = 0; i < s->num_queues; i++) { - virtio_del_queue(vdev, i); + virtio_delete_queue(s->virtqs[i]); } + g_free(s->virtqs); virtio_cleanup(vdev); vhost_user_cleanup(&s->vhost_user); } @@ -478,12 +480,13 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp) NULL, NULL, NULL, false); vhost_dev_cleanup(&s->dev); vhost_dev_free_inflight(s->inflight); - g_free(s->vqs); + g_free(s->vhost_vqs); g_free(s->inflight); for (i = 0; i < s->num_queues; i++) { - virtio_del_queue(vdev, i); + virtio_delete_queue(s->virtqs[i]); } + g_free(s->virtqs); virtio_cleanup(vdev); vhost_user_cleanup(&s->vhost_user); }