conf: add ability to configure a vdpa block disk device

vDPA block devices can be configured as follows:

    <disk type='vhostvdpa'>
      <source dev='/dev/vhost-vdpa-0'/>
    </disk>

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jonathon Jongsma 2023-02-06 14:20:01 -06:00
parent 78862b67e1
commit 1df106cc20
13 changed files with 63 additions and 3 deletions

View File

@ -2678,6 +2678,11 @@ paravirtualized driver is specified via the ``disk`` element.
</source>
<target dev='vdf' bus='virtio'/>
</disk>
<disk type='vhostvdpa' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/vhost-vdpa-0' />
<target dev='vdg' bus='virtio'/>
</disk>
</devices>
...
@ -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 values
for this attribute are "floppy", "disk", "cdrom", and "lun", defaulting to
@ -2879,6 +2885,15 @@ paravirtualized driver is specified via the ``disk`` element.
``<disk>`` XML for this disk type. Additionally features such as blockjobs,
incremental backups and snapshots are not supported for this disk type.
``vhostvdpa``
Enables the hypervisor to connect to a vDPA block device. Requires shared
memory configured for the VM, for more details see ``access`` mode for
``memoryBacking`` element (See `Memory Backing`_).
The ``source`` element has a mandatory attribute ``dev`` that specifies
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.

View File

@ -197,6 +197,7 @@ virCHMonitorBuildDiskJson(virJSONValue *disks, virDomainDiskDef *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);

View File

@ -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 = 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->vhostuser);
break;
case VIR_STORAGE_TYPE_VHOST_VDPA:
virBufferEscapeString(&attrBuf, " dev='%s'", src->vdpadev);
break;
case VIR_STORAGE_TYPE_NONE:
case VIR_STORAGE_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,

View File

@ -1811,6 +1811,7 @@
<ref name="diskSourceVolume"/>
<ref name="diskSourceNvme"/>
<ref name="diskSourceVhostUser"/>
<ref name="diskSourceVhostVdpa"/>
</choice>
</define>
@ -2381,6 +2382,18 @@
</element>
</define>
<define name="diskSourceVhostVdpa">
<attribute name="type">
<value>vhostvdpa</value>
</attribute>
<element name="source">
<attribute name="dev">
<ref name="absFilePath"/>
</attribute>
<empty/>
</element>
</define>
<define name="diskTargetDev">
<data type="string">
<param name="pattern">(ioemu:)?(fd|hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+</param>

View File

@ -47,7 +47,8 @@ VIR_ENUM_IMPL(virStorage,
"network",
"volume",
"nvme",
"vhostuser"
"vhostuser",
"vhostvdpa"
);
@ -834,6 +835,7 @@ virStorageSourceCopy(const virStorageSource *src,
def->tlsCertdir = g_strdup(src->tlsCertdir);
def->tlsHostname = g_strdup(src->tlsHostname);
def->query = g_strdup(src->query);
def->vdpadev = g_strdup(src->vdpadev);
if (src->sliceStorage)
def->sliceStorage = virStorageSourceSliceCopy(src->sliceStorage);
@ -958,6 +960,7 @@ virStorageSourceIsSameLocation(virStorageSource *a,
break;
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;

View File

@ -43,6 +43,7 @@ typedef enum {
VIR_STORAGE_TYPE_VOLUME,
VIR_STORAGE_TYPE_NVME,
VIR_STORAGE_TYPE_VHOST_USER,
VIR_STORAGE_TYPE_VHOST_VDPA,
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;

View File

@ -1525,6 +1525,7 @@ xenFormatXLDiskSrc(virStorageSource *src, char **srcstr)
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",

View File

@ -873,6 +873,11 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src,
return NULL;
break;
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 disk type"));
@ -2320,6 +2325,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorageSource *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;
case VIR_STORAGE_TYPE_NONE:

View File

@ -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",

View File

@ -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;
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:

View File

@ -446,6 +446,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDef *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(virDomainSnapshotDiskDef *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(virDomainSnapshotDiskDef *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,

View File

@ -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));

View File

@ -583,6 +583,7 @@ virStorageSourceUpdatePhysicalSize(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 -1;