From nobody Sat May 11 13:10:05 2024 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=1694469237; cv=none; d=zohomail.com; s=zohoarc; b=V7OusJIsir2GgXkiS1SyNfBjoZzt+HGo1C2opnPThZUyJQkDmaIxoSuab59N4HsZJD6Y+Hrk9RDQPPyEjlaIpUlwRW2ljDhIxVwgr/B6HGUwOXYCf7lYv8d1ftYKypVudjbMo/+uxyNF2onP99tRA8ivgDE3sWDC+1jI/T0OLBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694469237; 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=1p62pwciV9LptM3TfxiC97Mzd6pLw662i+neGYHcK/Q=; b=NOEc4lRKYbRJS2M8rO+u+J84CoC3ZhQHgou787hGyxrIB+vDm1xf+1P+dy0YExqlMVlr5wvwdvTT3TLv7vw6cezdVHCGz5oHNKCXxKZ6QwllGDPF3xApKo57mFHRb0LqbV8kBNvDLDUz9w49Tth2N9WS4nB+Ka6TthkwYNekmC4= 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 1694469237574917.3602313137711; Mon, 11 Sep 2023 14:53:57 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-590-xsSPjiEZMlaoKOkdJjT2Hg-1; Mon, 11 Sep 2023 17:53:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93F9529AB404; Mon, 11 Sep 2023 21:53:50 +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 B7DCB40C2064; Mon, 11 Sep 2023 21:53:49 +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 7C21E19465A4; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 771491946597 for ; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 668EA40C6EBF; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4306140C6EA8 for ; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694469236; 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=1p62pwciV9LptM3TfxiC97Mzd6pLw662i+neGYHcK/Q=; b=HduZuJS0mJrA37b9o97+zsCgDm+jChgsUl8QqF+6at1YcwwEVBClN0/3Q9VxckhOeA1C+4 d78I6JtM+1SClmB4DVShGOC2Bv9Up8QpPDeLqtW0eS0Ue8x9Tsni6high/8a1pfWtLTJsb iQGEw+wlQCb1uB/VPU6gihsQ7JlaKnI= X-MC-Unique: xsSPjiEZMlaoKOkdJjT2Hg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/5] conf: add ability to configure a vdpa block disk device Date: Mon, 11 Sep 2023 16:53:43 -0500 Message-ID: <20230911215347.1160427-2-jjongsma@redhat.com> In-Reply-To: <20230911215347.1160427-1-jjongsma@redhat.com> References: <20230911215347.1160427-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.1 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: 1694469239551100003 Content-Type: text/plain; charset="utf-8"; x-default="true" vDPA block devices can be configured as follows: Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- docs/formatdomain.rst | 19 +++++++++++++++++-- src/ch/ch_monitor.c | 1 + src/conf/domain_conf.c | 8 ++++++++ src/conf/schemas/domaincommon.rng | 13 +++++++++++++ src/conf/storage_source_conf.c | 7 ++++++- src/conf/storage_source_conf.h | 2 ++ src/libxl/xen_xl.c | 1 + src/qemu/qemu_block.c | 6 ++++++ src/qemu/qemu_command.c | 1 + src/qemu/qemu_migration.c | 2 ++ src/qemu/qemu_snapshot.c | 4 ++++ src/qemu/qemu_validate.c | 1 + src/storage_file/storage_source.c | 1 + 13 files changed, 63 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index bc469e5f9f..a65edc6703 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2678,6 +2678,11 @@ paravirtualized driver is specified via the ``disk``= element. + + + + + ... =20 @@ -2688,8 +2693,9 @@ paravirtualized driver is specified via the ``disk`` = element. ``type`` Valid values are "file", "block", "dir" ( :since:`since 0.7.5` ), "network" ( :since:`since 0.8.7` ), or "volume" ( :since:`since 1.0.= 5` ), - or "nvme" ( :since:`since 6.0.0` ), or "vhostuser" ( :since:`since 7= .1.0` ) - and refer to the underlying source for the disk. :since:`Since 0.0.3` + or "nvme" ( :since:`since 6.0.0` ), or "vhostuser" ( :since:`since 7= .1.0` ), + or "vhostvdpa" ( :since:`since 9.8.0 (QEMU 8.1.0)`) and refer to the + underlying source for the disk. :since:`Since 0.0.3` ``device`` Indicates how the disk is to be exposed to the guest OS. Possible va= lues for this attribute are "floppy", "disk", "cdrom", and "lun", default= ing to @@ -2879,6 +2885,15 @@ paravirtualized driver is specified via the ``disk``= element. ```` XML for this disk type. Additionally features such as blo= ckjobs, incremental backups and snapshots are not supported for this disk ty= pe. =20 + ``vhostvdpa`` + Enables the hypervisor to connect to a vDPA block device. Requires s= hared + memory configured for the VM, for more details see ``access`` mode f= or + ``memoryBacking`` element (See `Memory Backing`_). + + The ``source`` element has a mandatory attribute ``dev`` that specif= ies + the fully-qualified path to the vhost-vdpa character device (e.g. + ``/dev/vhost-vdpa-0``). + With "file", "block", and "volume", one or more optional sub-elements ``seclabel`` (See `Security label`_) can be used to override the domain security labeling policy for just that source file. diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 200ad6c77b..1691a4efb6 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -197,6 +197,7 @@ virCHMonitorBuildDiskJson(virJSONValue *disks, virDomai= nDiskDef *diskdef) case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_LAST: default: virReportEnumRangeError(virStorageType, diskdef->src->type); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2c8727de54..1f14ef6f23 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7522,6 +7522,10 @@ virDomainStorageSourceParse(xmlNodePtr node, if (virDomainDiskSourceVHostUserParse(node, src, xmlopt, ctxt) < 0) return -1; break; + case VIR_STORAGE_TYPE_VHOST_VDPA: + if (!(src->vdpadev =3D virXMLPropStringRequired(node, "dev"))) + return -1; + break; case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -22386,6 +22390,10 @@ virDomainDiskSourceFormat(virBuffer *buf, virDomainDiskSourceVhostuserFormat(&attrBuf, &childBuf, src->vhost= user); break; =20 + case VIR_STORAGE_TYPE_VHOST_VDPA: + virBufferEscapeString(&attrBuf, " dev=3D'%s'", src->vdpadev); + break; + case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 2f9ba31c0a..1fe9ccb70e 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1811,6 +1811,7 @@ + =20 @@ -2381,6 +2382,18 @@ =20 + + + vhostvdpa + + + + + + + + + (ioemu:)?(fd|hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+<= /param> diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index dcac3a8ff6..f57cb3241d 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -47,7 +47,8 @@ VIR_ENUM_IMPL(virStorage, "network", "volume", "nvme", - "vhostuser" + "vhostuser", + "vhostvdpa" ); =20 =20 @@ -834,6 +835,7 @@ virStorageSourceCopy(const virStorageSource *src, def->tlsCertdir =3D g_strdup(src->tlsCertdir); def->tlsHostname =3D g_strdup(src->tlsHostname); def->query =3D g_strdup(src->query); + def->vdpadev =3D g_strdup(src->vdpadev); =20 if (src->sliceStorage) def->sliceStorage =3D virStorageSourceSliceCopy(src->sliceStorage); @@ -958,6 +960,7 @@ virStorageSourceIsSameLocation(virStorageSource *a, break; =20 case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_BLOCK: @@ -1054,6 +1057,7 @@ virStorageSourceIsLocalStorage(const virStorageSource= *src) * Therefore, we have to return false here. */ case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_LAST: case VIR_STORAGE_TYPE_NONE: return false; @@ -1246,6 +1250,7 @@ virStorageSourceIsRelative(virStorageSource *src) case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: return false; diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index f13e7c756a..f99579bce2 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -43,6 +43,7 @@ typedef enum { VIR_STORAGE_TYPE_VOLUME, VIR_STORAGE_TYPE_NVME, VIR_STORAGE_TYPE_VHOST_USER, + VIR_STORAGE_TYPE_VHOST_VDPA, =20 VIR_STORAGE_TYPE_LAST } virStorageType; @@ -299,6 +300,7 @@ struct _virStorageSource { char *configFile; /* some storage systems use config file as part of the source definition */ char *query; /* query string for HTTP based protocols */ + char *vdpadev; size_t nhosts; virStorageNetHostDef *hosts; size_t ncookies; diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index ab1941454d..f175359307 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1525,6 +1525,7 @@ xenFormatXLDiskSrc(virStorageSource *src, char **srcs= tr) case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index dcdf883926..0b4c2dbcf4 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -873,6 +873,11 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource= *src, return NULL; break; =20 + case VIR_STORAGE_TYPE_VHOST_VDPA: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("vhostvdpa disk type not yet supported")); + return NULL; + case VIR_STORAGE_TYPE_VHOST_USER: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unable to create blockdev props for vhostuser di= sk type")); @@ -2320,6 +2325,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorag= eSource *src, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: return 0; =20 case VIR_STORAGE_TYPE_NONE: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a912ed064f..778958700b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1636,6 +1636,7 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b209e18dff..801b904a73 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -347,6 +347,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn, case VIR_STORAGE_TYPE_DIR: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1618,6 +1619,7 @@ qemuMigrationSrcIsSafe(virDomainDef *def, break; =20 case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_DIR: diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index ec853686d3..cdc8e12cff 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -446,6 +446,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapsh= otDiskDef *snapdisk, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -464,6 +465,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapsh= otDiskDef *snapdisk, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -507,6 +509,7 @@ qemuSnapshotPrepareDiskExternalActive(virDomainSnapshot= DiskDef *snapdisk, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -668,6 +671,7 @@ qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 1346bbfb44..165ab3a66a 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -607,6 +607,7 @@ qemuValidateDomainDefNvram(const virDomainDef *def, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported nvram disk type '%1$s'"), virStorageTypeToString(src->type)); diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index b97bbde619..2cfe3bc325 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -583,6 +583,7 @@ virStorageSourceUpdatePhysicalSize(virStorageSource *sr= c, case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: + case VIR_STORAGE_TYPE_VHOST_VDPA: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: return -1; --=20 2.41.0 From nobody Sat May 11 13:10:05 2024 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=1694469242; cv=none; d=zohomail.com; s=zohoarc; b=G1lWM7RO91k3KZCbIQvyUcwA8u5ra1PAVy3INWhgFekdbFX0r21uYKr3ui2u/UsbqgwD94M6N24Tzwx5MoutQgIrtXjGzUW2jMmZrgdSCN+7bJVVvwRkGp5NMHD9VU8batIzkBRvdCVJi40mhaqE1ms9i2hlXgF1GUTmUGwPmDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694469242; 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=lUD5bBzXmXVS9bMBvJnOmECMW0VmfM5KdXCBjNBqDAY=; b=fXEDYDA7elcNULqXhMr78P2wlVyos2XAl+4gpQpT7zoSFqR65v7nFl4oyGI2eLR9kOC+/ZPRDSFZfLybpkupbFfzmau79lDk+l59y3wFZGmfBn4zY8G2jPZ2dFq80DAtq2cdm+etWRp8b5cLJ6D6ygyBFcrD0VEJ9ZEOfxDpOa0= 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 1694469242818264.29492638548163; Mon, 11 Sep 2023 14:54:02 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-134--1fZ_gwKOAKVOD4j9sfJhQ-1; Mon, 11 Sep 2023 17:53:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5DA9B1C05B0E; Mon, 11 Sep 2023 21:53:51 +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 403D52024CD5; Mon, 11 Sep 2023 21:53:51 +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 BCD451946A50; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C2EAB1946597 for ; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A47D640C6EC0; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78BFC40C6EA8; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694469241; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lUD5bBzXmXVS9bMBvJnOmECMW0VmfM5KdXCBjNBqDAY=; b=aYHDzc/tNSLmJDo1nzUfceGiZQpBLIMvobitimkFCf3HyKgIGMpnIPHrLtSlyLwMN0910G GFir9re/d8En7Oy469FUoaGCv1F6AKJqLlqeXB83PDwWRDTc1RjcS5orABaVcg4pdUPXEH e8LVV6cN90ih48YPJtl9QdqSAvKT/hI= X-MC-Unique: -1fZ_gwKOAKVOD4j9sfJhQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/5] qemu: add virtio-blk-vhost-vdpa capability Date: Mon, 11 Sep 2023 16:53:44 -0500 Message-ID: <20230911215347.1160427-3-jjongsma@redhat.com> In-Reply-To: <20230911215347.1160427-1-jjongsma@redhat.com> References: <20230911215347.1160427-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: , Cc: Peter Krempa Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1694469243584100011 Content-Type: text/plain; charset="utf-8"; x-default="true" Check whether the qemu binary supports the vdpa block driver. We can't rely simply on the existence of the virtio-blk-vhost-vdpa block driver since the first releases of qemu didn't support fd-passing for this driver. So we have to check for the 'fdset' feature on the driver object. This feature will be present in the qemu 8.1.0 release and was merged to qemu in commit 98b126f5. Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml | 1 + 3 files changed, 4 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 87412dd4ec..3a1bfbf74d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -697,6 +697,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 450 */ "run-with.async-teardown", /* QEMU_CAPS_RUN_WITH_ASYNC_TEARD= OWN */ + "virtio-blk-vhost-vdpa", /* QEMU_CAPS_DEVICE_VIRTIO_BLK_VHOS= T_VDPA */ ); =20 =20 @@ -1531,6 +1532,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSc= hemaQueries[] =3D { { "blockdev-add/arg-type/+rbd/encrypt/format/^luks-any", QEMU_CAPS_RBD= _ENCRYPTION_LUKS_ANY }, { "blockdev-add/arg-type/+nbd/tls-hostname", QEMU_CAPS_BLOCKDEV_NBD_TL= S_HOSTNAME }, { "blockdev-add/arg-type/+qcow2/discard-no-unref", QEMU_CAPS_QCOW2_DIS= CARD_NO_UNREF }, + { "blockdev-add/arg-type/+virtio-blk-vhost-vdpa/$fdset", QEMU_CAPS_DEV= ICE_VIRTIO_BLK_VHOST_VDPA}, { "blockdev-snapshot/$allow-write-only-overlay", QEMU_CAPS_BLOCKDEV_SN= APSHOT_ALLOW_WRITE_ONLY }, { "chardev-add/arg-type/backend/+socket/data/reconnect", QEMU_CAPS_CHA= RDEV_RECONNECT }, { "device_add/$json-cli-hotplug", QEMU_CAPS_DEVICE_JSON }, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e51d3fffdc..3c4f7f625b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -676,6 +676,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 450 */ QEMU_CAPS_RUN_WITH_ASYNC_TEARDOWN, /* asynchronous teardown -run-with = async-teardown=3Don|off */ + QEMU_CAPS_DEVICE_VIRTIO_BLK_VHOST_VDPA, /* virtio-blk-vhost-vdpa block= driver */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml b/tests/qemuc= apabilitiesdata/caps_8.1.0_x86_64.xml index 6f8c5a57b7..d266dd0f31 100644 --- a/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_8.1.0_x86_64.xml @@ -197,6 +197,7 @@ + 8001000 43100245 v8.1.0 --=20 2.41.0 From nobody Sat May 11 13:10:05 2024 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=1694469240; cv=none; d=zohomail.com; s=zohoarc; b=N4cqY3ZwAExp+svywnXOSX7Tio/DMt/tWtvkhKPGp4OJIi1LJLhYjObehCnAxwsRKNu5vEgQXb8IdpDc5uacn6prqfwqtAB3lySiPf05HM3Ktg/s3Y3KW7EBnI8NqnLljXqDsVdhu8ZJVfGM2Qh6gF2jSEGJH0NQv4rPNKBL/vU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694469240; 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=/MoJRM20tGLPN2shNKbSdwC5zgXCQICtcw4UTMQqiRk=; b=jSl2YVJ3CXosgO1g/elMbbQob7nH8MWNf+g/uCig/MoMjncJXxAWcK1fEotTItTY5fc+qKfIYjIG70PBWNmP32c5LYgtXbjEAkS9RJU7+BTSVQ6DGsBtLALXpnBxwi8EVhAZ26LdqRUJspltEaOP0oGTNhuDSxXC0ZtfBAiLZ/k= 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 1694469240363582.6528579019064; Mon, 11 Sep 2023 14:54:00 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-644-7w6VsrzeMHCdbd95tfFgjA-1; Mon, 11 Sep 2023 17:53:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B26C29DD99B; Mon, 11 Sep 2023 21:53:51 +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 544962026D4B; Mon, 11 Sep 2023 21:53:51 +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 BCD8B1946A51; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F3B581946597 for ; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E366640C6EC0; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B77CD40C6EBF; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694469239; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/MoJRM20tGLPN2shNKbSdwC5zgXCQICtcw4UTMQqiRk=; b=Ohccai1iDMsfyzj9FqE4UlnqqCix5A2aBI5b9zW/mUnhIWMhy45DDjI8sstRcO4aDC4tB5 GBg02XBk8i0aitp/Mjbzr+j69/eG6gzGu4d6pEcY7fyqrSbnCn/khEEcMXBYKUarqcpZX9 KSoMPCbJVCds5KIHTcYfMLyjQCioUvE= X-MC-Unique: 7w6VsrzeMHCdbd95tfFgjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/5] qemu: make vdpa connect function more generic Date: Mon, 11 Sep 2023 16:53:45 -0500 Message-ID: <20230911215347.1160427-4-jjongsma@redhat.com> In-Reply-To: <20230911215347.1160427-1-jjongsma@redhat.com> References: <20230911215347.1160427-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: , Cc: Peter Krempa Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1694469241005100005 Content-Type: text/plain; charset="utf-8"; x-default="true" qemuInterfaceVDPAConnect() was a helper function for connecting to the vdpa device file. But in order to support other vdpa devices besides network interfaces (e.g. vdpa block devices) make this function a bit more generic. Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/qemu/qemu_command.c | 23 ++++++++++++++++++++++- src/qemu/qemu_command.h | 1 + src/qemu/qemu_interface.c | 23 ----------------------- src/qemu/qemu_interface.h | 2 -- tests/qemuhotplugmock.c | 4 ++-- tests/qemuxml2argvmock.c | 2 +- 6 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 778958700b..e84374b4cf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8533,7 +8533,7 @@ qemuBuildInterfaceConnect(virDomainObj *vm, break; =20 case VIR_DOMAIN_NET_TYPE_VDPA: - if ((vdpafd =3D qemuInterfaceVDPAConnect(net)) < 0) + if ((vdpafd =3D qemuVDPAConnect(net->data.vdpa.devicepath)) < 0) return -1; =20 netpriv->vdpafd =3D qemuFDPassNew(net->info.alias, priv); @@ -10993,3 +10993,24 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTo= p(virStorageSource *top, =20 return g_steal_pointer(&data); } + + +/* qemuVDPAConnect: + * @devicepath: the path to the vdpa device + * + * returns: file descriptor of the vdpa device + */ +int +qemuVDPAConnect(const char *devicepath) +{ + int fd; + + if ((fd =3D open(devicepath, O_RDWR)) < 0) { + virReportSystemError(errno, + _("Unable to open '%1$s' for vdpa device"), + devicepath); + return -1; + } + + return fd; +} diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 55efa45601..341ec43f9a 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -248,3 +248,4 @@ qemuBuildTPMOpenBackendFDs(const char *tpmdev, =20 const char * qemuAudioDriverTypeToString(virDomainAudioType type); virDomainAudioType qemuAudioDriverTypeFromString(const char *str); +int qemuVDPAConnect(const char *devicepath) G_NO_INLINE; diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index e875de48ee..8856bb95a8 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -648,29 +648,6 @@ qemuInterfaceBridgeConnect(virDomainDef *def, } =20 =20 -/* qemuInterfaceVDPAConnect: - * @net: pointer to the VM's interface description - * - * returns: file descriptor of the vdpa device - * - * Called *only* called if actualType is VIR_DOMAIN_NET_TYPE_VDPA - */ -int -qemuInterfaceVDPAConnect(virDomainNetDef *net) -{ - int fd; - - if ((fd =3D open(net->data.vdpa.devicepath, O_RDWR)) < 0) { - virReportSystemError(errno, - _("Unable to open '%1$s' for vdpa device"), - net->data.vdpa.devicepath); - return -1; - } - - return fd; -} - - /* * Returns: -1 on error, 0 on success. Populates net->privateData->slirp if * the slirp helper is needed. diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h index d866beb184..6eed3e6bd7 100644 --- a/src/qemu/qemu_interface.h +++ b/src/qemu/qemu_interface.h @@ -55,5 +55,3 @@ int qemuInterfaceOpenVhostNet(virDomainObj *def, =20 int qemuInterfacePrepareSlirp(virQEMUDriver *driver, virDomainNetDef *net); - -int qemuInterfaceVDPAConnect(virDomainNetDef *net) G_NO_INLINE; diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c index 89d287945a..dd7e2c67e0 100644 --- a/tests/qemuhotplugmock.c +++ b/tests/qemuhotplugmock.c @@ -18,8 +18,8 @@ =20 #include =20 +#include "qemu/qemu_command.h" #include "qemu/qemu_hotplug.h" -#include "qemu/qemu_interface.h" #include "qemu/qemu_process.h" #include "testutilsqemu.h" #include "conf/domain_conf.h" @@ -94,7 +94,7 @@ qemuProcessKillManagedPRDaemon(virDomainObj *vm G_GNUC_UN= USED) } =20 int -qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED) +qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED) { /* need a valid fd or sendmsg won't work. Just open /dev/null */ return open("/dev/null", O_RDONLY); diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 400dd5c020..52c44b2ed0 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -255,7 +255,7 @@ virNetDevBandwidthSetRootQDisc(const char *ifname G_GNU= C_UNUSED, =20 =20 int -qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED) +qemuVDPAConnect(const char *devicepath G_GNUC_UNUSED) { if (fcntl(1732, F_GETFD) !=3D -1) abort(); --=20 2.41.0 From nobody Sat May 11 13:10:05 2024 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=1694469241; cv=none; d=zohomail.com; s=zohoarc; b=bX5k8bvzV0uDrB15iPp5kLBRXskP4RDIPgEnbTU014b3wkfW+WtewH8jMkJBhPqx5diiBggewdoGiZF7BgyPMidm844i2AJ7K7gXUlRy4OxnC5uHDvT9GOnfA0SN5FYjp/hck6rSCcI/v8kum68+gWWloGOy0IRD03ExpKlsfuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694469241; 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=2SZefzKNdXfVptjGGN9rQCxryX0wOB+mhPMRMcsgVjI=; b=hvLEBaf9V30hYA8/NztVYZDkmUX3FoOqR+gSpUkyy9AiScRsAM3XnHFPgrokJMaCvpOi2EaEKW8gRuYJh7GtZQ7yv5JpK1rllICUEtqpyBk8q5k1p0dK90ZUR1Un9O5UOLr6tqoPuNBxINwi16DAoxtalHOXcGMYDeto9vNNjGk= 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 1694469241293103.5496603625395; Mon, 11 Sep 2023 14:54:01 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-hi0qRuGrMKi1AmjrB56gng-1; Mon, 11 Sep 2023 17:53:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48B588A074F; Mon, 11 Sep 2023 21:53:52 +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 320FF40C6EC0; Mon, 11 Sep 2023 21:53:52 +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 04B2F1946A74; Mon, 11 Sep 2023 21:53:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 54AF81946597 for ; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2D57040C6EBF; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0165740C6EA8; Mon, 11 Sep 2023 21:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694469240; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2SZefzKNdXfVptjGGN9rQCxryX0wOB+mhPMRMcsgVjI=; b=h9i4e5gWReuws0PMWPDpUhke8HQmjDc5aLYuFh4GEC1l+gEyVRTmgz98C5DWZ2awBUsQO7 gsuLMEW4ourI7v7VtVy5LsFUrkH4Hk88FAqKYeMQjc47s74NvUZe8ReT3xC/5YxsIfumz6 6ujARbZiCRED8Mee44y7txRHHUYO+KA= X-MC-Unique: hi0qRuGrMKi1AmjrB56gng-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 4/5] qemu: consider vdpa block devices for memlock limits Date: Mon, 11 Sep 2023 16:53:46 -0500 Message-ID: <20230911215347.1160427-5-jjongsma@redhat.com> In-Reply-To: <20230911215347.1160427-1-jjongsma@redhat.com> References: <20230911215347.1160427-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: , Cc: Peter Krempa Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1694469241496100007 Content-Type: text/plain; charset="utf-8"; x-default="true" vDPA block devices will also need the same consideration for memlock limits as other vdpa devices, so consider these devices when calculating memlock limits. Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/qemu/qemu_domain.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c7d64e1b5c..52ea8f649d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9652,7 +9652,7 @@ qemuDomainGetNumNVMeDisks(const virDomainDef *def) =20 =20 static int -qemuDomainGetNumVDPANetDevices(const virDomainDef *def) +qemuDomainGetNumVDPADevices(const virDomainDef *def) { size_t i; int n =3D 0; @@ -9662,6 +9662,14 @@ qemuDomainGetNumVDPANetDevices(const virDomainDef *d= ef) n++; } =20 + for (i =3D 0; i < def->ndisks; i++) { + virStorageSource *src; + for (src =3D def->disks[i]->src; src; src =3D src->backingStore) { + if (src->type =3D=3D VIR_STORAGE_TYPE_VHOST_VDPA) + n++; + } + } + return n; } =20 @@ -9704,7 +9712,7 @@ qemuDomainGetMemLockLimitBytes(virDomainDef *def) =20 nvfio =3D qemuDomainGetNumVFIOHostdevs(def); nnvme =3D qemuDomainGetNumNVMeDisks(def); - nvdpa =3D qemuDomainGetNumVDPANetDevices(def); + nvdpa =3D qemuDomainGetNumVDPADevices(def); /* For device passthrough using VFIO the guest memory and MMIO memory * regions need to be locked persistent in order to allow DMA. * --=20 2.41.0 From nobody Sat May 11 13:10:05 2024 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=1694469241; cv=none; d=zohomail.com; s=zohoarc; b=VqZxfmX4kLrmnvpFkdqBeR+ORUOl4te7aQ2B2Sab4fDbIiBMvkzJQNzDwPXFqH+WgXwqgyPmX5VTbbwpGMB/YirJuQTJn04Y/KgCuf2ssEYdos8Rm/j2KXVAkGfhd+q1SUMHGBXQrIwqd6Sk/ZaSjmiMcv/qxoR314xrU41MIIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694469241; 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=kA/bMntDIOneXkinUNvxqMfYUKi6HgcARuo8sTMqajw=; b=SGHUZmOj+2etSciMwjVg3W/V1DW7d23/7U13AoiToCfywebSkmV994SPKfTIBzn+tJZ/BWFEj6KG8LdcDpl8ZHN3lBg7ny76+cgAv4e2dCzj3ItdIUV8SEUG7qBjcCMurMfOIcMWRvpApwe8PpLFOPpJqvGZK6aVDBqfL8RQ8DM= 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 1694469241307335.84098155964614; Mon, 11 Sep 2023 14:54:01 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-618-rsYHpTuSMUOdEf_G23lcFg-1; Mon, 11 Sep 2023 17:53:56 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C50F63C100BB; Mon, 11 Sep 2023 21:53:52 +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 A2AD6200E4BC; Mon, 11 Sep 2023 21:53:52 +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 07B4419465B3; Mon, 11 Sep 2023 21:53:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 791831946597 for ; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 69B4040C6EBF; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.34.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EC5740C6EA8 for ; Mon, 11 Sep 2023 21:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694469239; 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=kA/bMntDIOneXkinUNvxqMfYUKi6HgcARuo8sTMqajw=; b=hWTmQJ3sS06ksHZEsU2QUm/ZU4iz1idh4ovtzCwIByoJ6eM+ntOyx70EDjODTfJ34xXusb Z6g99EZbjdEAEPw10QCWFpEpQm5wFM5qhr7BlNDJL2si8uSloUT0emAYdxP6FTELWOAyVx Z5Z0bHxG3Q3zyJZoDcYVWzFXjquaO9o= X-MC-Unique: rsYHpTuSMUOdEf_G23lcFg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 5/5] qemu: Implement support for vDPA block devices Date: Mon, 11 Sep 2023 16:53:47 -0500 Message-ID: <20230911215347.1160427-6-jjongsma@redhat.com> In-Reply-To: <20230911215347.1160427-1-jjongsma@redhat.com> References: <20230911215347.1160427-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.6 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: 1694469242066100009 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) Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1900770 Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/qemu/qemu_block.c | 20 ++++++++-- src/qemu/qemu_process.c | 34 +++++++++++++++++ src/qemu/qemu_validate.c | 32 ++++++++++++++-- .../disk-vhostvdpa.x86_64-latest.args | 37 +++++++++++++++++++ tests/qemuxml2argvdata/disk-vhostvdpa.xml | 21 +++++++++++ tests/qemuxml2argvtest.c | 34 +++++++++++++++++ tests/testutilsqemu.c | 11 ++++++ tests/testutilsqemu.h | 2 + 8 files changed, 185 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-vhostvdpa.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-vhostvdpa.xml diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 0b4c2dbcf4..d31bbde0f4 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_process.c b/src/qemu/qemu_process.c index 7a1cdb0302..42837c4a8a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6820,6 +6820,28 @@ qemuProcessPrepareLaunchSecurityGuestInput(virDomain= Obj *vm) } =20 =20 +static int +qemuProcessPrepareHostStorageSourceVDPA(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->vdpadev)) < 0) + return -1; + + srcpriv =3D qemuDomainStorageSourcePrivateFetch(src); + + srcpriv->fdpass =3D qemuFDPassNew(src->nodestorage, priv); + qemuFDPassAddFD(srcpriv->fdpass, &vdpafd, "-vdpa"); + return 0; +} + + static int qemuProcessPrepareHostStorage(virQEMUDriver *driver, virDomainObj *vm, @@ -6856,6 +6878,18 @@ qemuProcessPrepareHostStorage(virQEMUDriver *driver, return -1; } =20 + /* connect to any necessary vdpa block devices */ + for (i =3D vm->def->ndisks; i > 0; i--) { + size_t idx =3D i - 1; + virDomainDiskDef *disk =3D vm->def->disks[idx]; + virStorageSource *src; + + for (src =3D disk->src; virStorageSourceIsBacking(src); src =3D sr= c->backingStore) { + if (qemuProcessPrepareHostStorageSourceVDPA(src, vm->privateDa= ta) < 0) + return -1; + } + } + return 0; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 165ab3a66a..5bae56b00f 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -3175,13 +3175,39 @@ qemuValidateDomainDeviceDefDisk(const virDomainDisk= Def *disk, } =20 if (disk->src->type =3D=3D VIR_STORAGE_TYPE_VHOST_USER) { + const char *vhosttype =3D virStorageTypeToString(disk->src->type); + 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")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%1$s disk is not supported with this QEMU bi= nary"), + vhosttype); + return -1; + } + + if (qemuValidateDomainDefVhostUserRequireSharedMemory(def, vhostty= pe) < 0) + return -1; + } + + if (disk->src->type =3D=3D VIR_STORAGE_TYPE_VHOST_VDPA) { + const char *vhosttype =3D virStorageTypeToString(disk->src->type); + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_BLK_VHOST_VD= PA)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%1$s disk is not supported with this QEMU bi= nary"), + vhosttype); return -1; } =20 - if (qemuValidateDomainDefVhostUserRequireSharedMemory(def, "vhostu= ser") < 0) { + if (qemuValidateDomainDefVhostUserRequireSharedMemory(def, vhostty= pe) < 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.x86_64-latest.args b/tes= ts/qemuxml2argvdata/disk-vhostvdpa.x86_64-latest.args new file mode 100644 index 0000000000..b987455ee4 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-vhostvdpa.x86_64-latest.args @@ -0,0 +1,37 @@ +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 '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-accel tcg \ +-cpu qemu64 \ +-m size=3D219136k \ +-object '{"qom-type":"memory-backend-file","id":"pc.ram","mem-path":"/var/= lib/libvirt/qemu/ram/-1-QEMUGuest1/pc.ram","share":true,"x-use-canonical-pa= th-for-ramblock-id":false,"size":224395264}' \ +-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 \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-add-fd set=3D0,fd=3D801,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 '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"li= bvirt-1-format","id":"virtio-disk0","bootindex":1,"write-cache":"on"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-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 2d06e2a0d1..0dd10f1fab 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -304,6 +304,7 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, =20 for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk =3D vm->def->disks[i]; + virStorageSource *src; =20 /* host cdrom requires special treatment in qemu, mock it */ if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM && @@ -311,6 +312,37 @@ testCompareXMLToArgvCreateArgs(virQEMUDriver *drv, virStorageSourceIsBlockLocal(disk->src) && STREQ(disk->src->path, "/dev/cdrom")) disk->src->hostcdrom =3D true; + + if (info->args.vdpafds) { + for (src =3D disk->src; virStorageSourceIsBacking(src); src = =3D src->backingStore) { + gpointer value; + + if (src->type !=3D VIR_STORAGE_TYPE_VHOST_VDPA) + continue; + + if ((value =3D g_hash_table_lookup(info->args.vdpafds, src= ->vdpadev))) { + int fd =3D GPOINTER_TO_INT(value); + qemuDomainStorageSourcePrivate *srcpriv; + VIR_AUTOCLOSE fakefd =3D open("/dev/zero", O_RDWR); + + if (fcntl(fd, F_GETFD) !=3D -1) { + fprintf(stderr, "fd '%d' is already in use\n", fd); + abort(); + } + + if (dup2(fakefd, fd) < 0) { + fprintf(stderr, "failed to duplicate fake fd: %s", + g_strerror(errno)); + abort(); + } + + srcpriv =3D qemuDomainStorageSourcePrivateFetch(src); + + srcpriv->fdpass =3D qemuFDPassNew(src->nodestorage, pr= iv); + qemuFDPassAddFD(srcpriv->fdpass, &fd, "-vdpa"); + } + } + } } =20 if (vm->def->vsock) { @@ -1129,6 +1161,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_CAPS_ARCH_LATEST_FULL("disk-vhostvdpa", "x86_64", + ARG_VDPA_FD, "/dev/vhost-vdpa-0", 801); 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"); diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index bb3e1b52c5..7f8bf4c01c 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -709,6 +709,17 @@ testQemuInfoSetArgs(struct testQemuInfo *info, break; } =20 + case ARG_VDPA_FD: { + const char *vdpadev =3D va_arg(argptr, char *); + int vdpafd =3D va_arg(argptr, unsigned int); + + if (!info->args.vdpafds) + info->args.vdpafds =3D g_hash_table_new_full(g_str_hash, g= _str_equal, g_free, NULL); + + g_hash_table_insert(info->args.vdpafds, g_strdup(vdpadev), GIN= T_TO_POINTER(vdpafd)); + break; + } + case ARG_END: default: info->args.invalidarg =3D true; diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 2d7e2f7779..8398627f71 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -49,6 +49,7 @@ typedef enum { ARG_CAPS_VARIANT, ARG_CAPS_HOST_CPU_MODEL, ARG_FD_GROUP, /* name, nfds, fd[0], ... fd[n-1] */ + ARG_VDPA_FD, /* vdpadev, fd */ ARG_END, } testQemuInfoArgName; =20 @@ -85,6 +86,7 @@ struct testQemuArgs { qemuTestCPUDef capsHostCPUModel; int gic; GHashTable *fds; + GHashTable *vdpafds; bool invalidarg; }; =20 --=20 2.41.0