[libvirt PATCH 1/5] conf: add ability to configure a vdpa block disk device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



vDPA block devices can be configured as follows:

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

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 docs/formatdomain.rst             | 19 +++++++++++++++++--
 src/ch/ch_monitor.c               |  1 +
 src/conf/domain_conf.c            |  7 +++++++
 src/conf/schemas/domaincommon.rng | 13 +++++++++++++
 src/conf/storage_source_conf.c    |  6 +++++-
 src/conf/storage_source_conf.h    |  1 +
 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, 60 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index c3526439bf..778c04506c 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -2666,6 +2666,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>
    ...
 
@@ -2676,8 +2681,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.5.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
@@ -2855,6 +2861,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.
diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
index d902bc6959..607c969e67 100644
--- a/src/ch/ch_monitor.c
+++ b/src/ch/ch_monitor.c
@@ -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);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0edb1bda9d..cd9d895292 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7511,6 +7511,9 @@ virDomainStorageSourceParse(xmlNodePtr node,
         if (virDomainDiskSourceVHostUserParse(node, src, xmlopt, ctxt) < 0)
             return -1;
         break;
+    case VIR_STORAGE_TYPE_VHOST_VDPA:
+        src->path = virXMLPropString(node, "dev");
+        break;
     case VIR_STORAGE_TYPE_NONE:
     case VIR_STORAGE_TYPE_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -22290,6 +22293,10 @@ virDomainDiskSourceFormat(virBuffer *buf,
         virDomainDiskSourceVhostuserFormat(&attrBuf, &childBuf, src->vhostuser);
         break;
 
+    case VIR_STORAGE_TYPE_VHOST_VDPA:
+        virBufferEscapeString(&attrBuf, " dev='%s'", src->path);
+        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/domaincommon.rng
index c1725bb511..ac33c442c3 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -1824,6 +1824,7 @@
       <ref name="diskSourceVolume"/>
       <ref name="diskSourceNvme"/>
       <ref name="diskSourceVhostUser"/>
+      <ref name="diskSourceVhostVdpa"/>
     </choice>
   </define>
 
@@ -2394,6 +2395,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>
diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c
index 99061e4df7..0953770a52 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"
 );
 
 
@@ -957,6 +958,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:
@@ -1053,6 +1055,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;
@@ -1245,6 +1248,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 c6187dda59..f6cf1c09d6 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,
 
     VIR_STORAGE_TYPE_LAST
 } virStorageType;
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index 77f9f112f0..cb22425ebf 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -1523,6 +1523,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:
         break;
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 8b2159f845..35312fb7d4 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -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"));
@@ -2321,6 +2326,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:
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a19902988c..22deac2a9b 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:
         break;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index ed41a03851..a610f230e2 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,
@@ -1626,6 +1627,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:
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 91de8b0c31..e74ab7d46c 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -400,6 +400,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,
@@ -418,6 +419,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,
@@ -462,6 +464,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,
@@ -604,6 +607,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 04d0c9df73..9dce908cfe 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -632,6 +632,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_source.c
index 47fc1edbd2..dc31d1bf50 100644
--- a/src/storage_file/storage_source.c
+++ b/src/storage_file/storage_source.c
@@ -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;
-- 
2.40.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux