From nobody Tue Feb 10 01:16:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686086148; cv=none; d=zohomail.com; s=zohoarc; b=GODWpc7j+HQY+pUOMo/lnIhWQBBF2sy7TUcyV+z0sP9n4Q74v8Scixt7sd5rR451Q8zhwoZhk7hKkWJVjs6N6uXahHQ/xLmXLR+9OI/jTD6l9RS2y4cTqFpoXD4waNUIlPQ2TR4PBH9mgEzkFcQDho0NqmQFsjrHM/j7GrT2YIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686086148; h=Content-Type:Content-Transfer-Encoding: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=rxtOEOquW98eTNxhPorTm/06KCkHhBiUItXVKTOoS78=; b=AwgqXoKZ61eAz7xwqSu18X54v4BcSsdepfo0xfknhkCk6QGQ5bKzvrTvXnF1TAGVb5qDWxrIppJbcuQ0y1ay+5z6zo223iMalmenYxuch+4cl4azbOXIeWivb1fPhgSzjLkPnL71q71n9sWgR/h0D1ztwugVJdu9urRKhvUnfYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1686086148310193.3858953354029; Tue, 6 Jun 2023 14:15:48 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-136-iiRfi6acMDi73gk1zkHQzg-1; Tue, 06 Jun 2023 17:15:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABB301C01E93; Tue, 6 Jun 2023 21:15:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AE279E8D; Tue, 6 Jun 2023 21:15:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 22B6619465BC; Tue, 6 Jun 2023 21:15:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 67D9419465BA for ; Tue, 6 Jun 2023 21:15:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 367911121315; Tue, 6 Jun 2023 21:15:31 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C3561121314 for ; Tue, 6 Jun 2023 21:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686086147; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rxtOEOquW98eTNxhPorTm/06KCkHhBiUItXVKTOoS78=; b=O9ADAb3K3bgp28AReNXVaXAKjb2HF2ccljcTZ3oufoFl6HZwyLLOX7oVj0sm07XdZUECp8 e69o3eTmDXzqoKgvRyEOdjZ0ryFelQwpCVi5lBgEcI3m9Brk2i/BMkk/G/GndNaec3+m6S xWPFo5sw4WKi4XSmn5BMZRu20CJhgTY= X-MC-Unique: iiRfi6acMDi73gk1zkHQzg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 5/5] qemu: Implement support for vDPA block devices Date: Tue, 6 Jun 2023 16:15:30 -0500 Message-Id: <20230606211530.1644273-1-jjongsma@redhat.com> In-Reply-To: <20230606211104.1632426-1-jjongsma@redhat.com> References: <20230606211104.1632426-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686086149881100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Requires recent qemu with support for the virtio-blk-vhost-vdpa device and the ability to pass a /dev/fdset/N path for the vdpa path (8.1.0) Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1900770 --- src/qemu/qemu_block.c | 20 ++++++++-- src/qemu/qemu_domain.c | 25 ++++++++++++ src/qemu/qemu_validate.c | 44 +++++++++++++++++++--- tests/qemuxml2argvdata/disk-vhostvdpa.args | 35 +++++++++++++++++ tests/qemuxml2argvdata/disk-vhostvdpa.xml | 21 +++++++++++ tests/qemuxml2argvtest.c | 2 + 6 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-vhostvdpa.args create mode 100644 tests/qemuxml2argvdata/disk-vhostvdpa.xml diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 35312fb7d4..78f6e63aad 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -778,6 +778,20 @@ qemuBlockStorageSourceGetNVMeProps(virStorageSource *s= rc) } =20 =20 +static virJSONValue * +qemuBlockStorageSourceGetVhostVdpaProps(virStorageSource *src) +{ + virJSONValue *ret =3D NULL; + qemuDomainStorageSourcePrivate *srcpriv =3D QEMU_DOMAIN_STORAGE_SOURCE= _PRIVATE(src); + + ignore_value(virJSONValueObjectAdd(&ret, + "s:driver", "virtio-blk-vhost-vdpa", + "s:path", qemuFDPassGetPath(srcpriv= ->fdpass), + NULL)); + return ret; +} + + static int qemuBlockStorageSourceGetBlockdevGetCacheProps(virStorageSource *src, virJSONValue *props) @@ -874,9 +888,9 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource = *src, break; =20 case VIR_STORAGE_TYPE_VHOST_VDPA: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("vhostvdpa disk type not yet supported")); - return NULL; + if (!(fileprops =3D qemuBlockStorageSourceGetVhostVdpaProps(src))) + return NULL; + break; =20 case VIR_STORAGE_TYPE_VHOST_USER: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2f6b32e394..119e52a7d7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11157,6 +11157,28 @@ qemuDomainPrepareStorageSourceFDs(virStorageSource= *src, } =20 =20 +static int +qemuDomainPrepareStorageSourceVDPA(virStorageSource *src, + qemuDomainObjPrivate *priv) +{ + qemuDomainStorageSourcePrivate *srcpriv =3D NULL; + virStorageType actualType =3D virStorageSourceGetActualType(src); + int vdpafd =3D -1; + + if (actualType !=3D VIR_STORAGE_TYPE_VHOST_VDPA) + return 0; + + if ((vdpafd =3D qemuVDPAConnect(src->path)) < 0) + return -1; + + srcpriv =3D qemuDomainStorageSourcePrivateFetch(src); + + srcpriv->fdpass =3D qemuFDPassNew(src->nodestorage, priv); + qemuFDPassAddFD(srcpriv->fdpass, &vdpafd, "-vdpa"); + return 0; +} + + int qemuDomainPrepareStorageSourceBlockdevNodename(virDomainDiskDef *disk, virStorageSource *src, @@ -11197,6 +11219,9 @@ qemuDomainPrepareStorageSourceBlockdevNodename(virD= omainDiskDef *disk, if (qemuDomainPrepareStorageSourceFDs(src, priv) < 0) return -1; =20 + if (qemuDomainPrepareStorageSourceVDPA(src, priv) < 0) + return -1; + return 0; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 9dce908cfe..67b0944162 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3220,6 +3220,28 @@ qemuValidateDomainDeviceDefDiskTransient(const virDo= mainDiskDef *disk, } =20 =20 +static int +qemuValidateDomainDeviceDefDiskVhost(const virDomainDef *def, + virStorageType storagetype, + virQEMUCapsFlags flag, + virQEMUCaps *qemuCaps) +{ + const char *vhosttype =3D virStorageTypeToString(storagetype); + + if (!virQEMUCapsGet(qemuCaps, flag)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%1$s disk is not supported with this QEMU binary= "), + vhosttype); + return -1; + } + + if (qemuValidateDomainDefVhostUserRequireSharedMemory(def, vhosttype) = < 0) + return -1; + + return 0; +} + + int qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk, const virDomainDef *def, @@ -3281,13 +3303,25 @@ qemuValidateDomainDeviceDefDisk(const virDomainDisk= Def *disk, } =20 if (disk->src->type =3D=3D VIR_STORAGE_TYPE_VHOST_USER) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_BLK)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("vhostuser disk is not supported with this QE= MU binary")); + if (qemuValidateDomainDeviceDefDiskVhost(def, disk->src->type, + QEMU_CAPS_DEVICE_VHOST_US= ER_BLK, + qemuCaps) < 0) return -1; - } + } =20 - if (qemuValidateDomainDefVhostUserRequireSharedMemory(def, "vhostu= ser") < 0) { + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_VHOST_VDPA) { + if (qemuValidateDomainDeviceDefDiskVhost(def, disk->src->type, + QEMU_CAPS_DEVICE_VIRTIO_B= LK_VHOST_VDPA, + qemuCaps) < 0) + return -1; + + if (disk->cachemode !=3D VIR_DOMAIN_DISK_CACHE_DIRECTSYNC && + disk->cachemode !=3D VIR_DOMAIN_DISK_CACHE_DISABLE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk type '%1$s' requires cache mode '%2$s' = or '%3$s'"), + virStorageTypeToString(disk->src->type), + virDomainDiskCacheTypeToString(VIR_DOMAIN_DISK_= CACHE_DIRECTSYNC), + virDomainDiskCacheTypeToString(VIR_DOMAIN_DISK_= CACHE_DISABLE)); return -1; } } diff --git a/tests/qemuxml2argvdata/disk-vhostvdpa.args b/tests/qemuxml2arg= vdata/disk-vhostvdpa.args new file mode 100644 index 0000000000..878f3b5fce --- /dev/null +++ b/tests/qemuxml2argvdata/disk-vhostvdpa.args @@ -0,0 +1,35 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/var/lib/libvirt/qemu/d= omain--1-QEMUGuest1/master-key.aes \ +-machine pc,usb=3Doff,dump-guest-core=3Doff \ +-accel tcg \ +-m 214 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-usb \ +-add-fd set=3D0,fd=3D1732,opaque=3Dlibvirt-1-storage-vdpa \ +-blockdev '{"driver":"virtio-blk-vhost-vdpa","path":"/dev/fdset/0","node-n= ame":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},"auto-rea= d-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"dir= ect":true,"no-flush":false},"driver":"raw","file":"libvirt-1-storage"}' \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x2,drive=3Dlibvirt-1-format,id= =3Dvirtio-disk0,bootindex=3D1,write-cache=3Don \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-vhostvdpa.xml b/tests/qemuxml2argv= data/disk-vhostvdpa.xml new file mode 100644 index 0000000000..0ac3899a34 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-vhostvdpa.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + + + + 1 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d914d8cbea..928375c173 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1224,6 +1224,8 @@ mymain(void) DO_TEST_CAPS_VER("disk-vhostuser-numa", "4.2.0"); DO_TEST_CAPS_LATEST("disk-vhostuser-numa"); DO_TEST_CAPS_LATEST("disk-vhostuser"); + DO_TEST("disk-vhostvdpa", + QEMU_CAPS_DEVICE_VIRTIO_BLK_VHOST_VDPA); DO_TEST_CAPS_LATEST_PARSE_ERROR("disk-device-lun-type-invalid"); DO_TEST_CAPS_LATEST_PARSE_ERROR("disk-attaching-partition-nosupport"); DO_TEST_CAPS_LATEST("disk-usb-device"); --=20 2.40.1