提交 6e648992 编写于 作者: C Cole Robinson

qemu: Support vsock model=virtio-{non-}transitional

Add <vsock> model handling for virtio transitional devices. Ex:

  <vsock model='virtio-transitional'>
    ...
  </vsock>

* "virtio-transitional" maps to qemu "vhost-vsock-pci-transitional"
* "virtio-non-transitional" maps to qemu "vhost-vsock-pci-non-transitional"
Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 0f5958f5
...@@ -8667,7 +8667,11 @@ qemu-kvm -net nic,model=? /dev/null ...@@ -8667,7 +8667,11 @@ qemu-kvm -net nic,model=? /dev/null
<h3><a id="vsock">Vsock</a></h3> <h3><a id="vsock">Vsock</a></h3>
<p>A vsock host/guest interface. The <code>model</code> attribute <p>A vsock host/guest interface. The <code>model</code> attribute
defaults to <code>virtio</code>. defaults to <code>virtio</code>. <span class="since">Since 5.2.0</span>
<code>model</code> can also be 'virtio-transitional' and
'virtio-non-transitional', see
<a href="#elementsVirtioTransitional">Virtio transitional devices</a>
for more details.
The optional attribute <code>address</code> of the <code>cid</code> The optional attribute <code>address</code> of the <code>cid</code>
element specifies the CID assigned to the guest. If the attribute element specifies the CID assigned to the guest. If the attribute
<code>auto</code> is set to <code>yes</code>, libvirt <code>auto</code> is set to <code>yes</code>, libvirt
......
...@@ -4304,7 +4304,11 @@ ...@@ -4304,7 +4304,11 @@
<element name="vsock"> <element name="vsock">
<optional> <optional>
<attribute name="model"> <attribute name="model">
<value>virtio</value> <choice>
<value>virtio</value>
<value>virtio-transitional</value>
<value>virtio-non-transitional</value>
</choice>
</attribute> </attribute>
</optional> </optional>
<interleave> <interleave>
......
...@@ -996,6 +996,8 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST, ...@@ -996,6 +996,8 @@ VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST,
VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST, VIR_ENUM_IMPL(virDomainVsockModel, VIR_DOMAIN_VSOCK_MODEL_LAST,
"default", "default",
"virtio", "virtio",
"virtio-transitional",
"virtio-non-transitional",
); );
VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST,
......
...@@ -2434,6 +2434,8 @@ struct _virDomainIOMMUDef { ...@@ -2434,6 +2434,8 @@ struct _virDomainIOMMUDef {
typedef enum { typedef enum {
VIR_DOMAIN_VSOCK_MODEL_DEFAULT, VIR_DOMAIN_VSOCK_MODEL_DEFAULT,
VIR_DOMAIN_VSOCK_MODEL_VIRTIO, VIR_DOMAIN_VSOCK_MODEL_VIRTIO,
VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL,
VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL,
VIR_DOMAIN_VSOCK_MODEL_LAST VIR_DOMAIN_VSOCK_MODEL_LAST
} virDomainVsockModel; } virDomainVsockModel;
......
...@@ -507,6 +507,11 @@ qemuBuildVirtioDevStr(virBufferPtr buf, ...@@ -507,6 +507,11 @@ qemuBuildVirtioDevStr(virBufferPtr buf,
has_ntmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL; has_ntmodel = device.data.memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO_NON_TRANSITIONAL;
break; break;
case VIR_DOMAIN_DEVICE_VSOCK:
has_tmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL;
has_ntmodel = device.data.vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL;
break;
case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_SOUND:
...@@ -525,7 +530,6 @@ qemuBuildVirtioDevStr(virBufferPtr buf, ...@@ -525,7 +530,6 @@ qemuBuildVirtioDevStr(virBufferPtr buf,
case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_MEMORY:
case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_IOMMU:
case VIR_DOMAIN_DEVICE_VSOCK:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
default: default:
return 0; return 0;
......
...@@ -974,7 +974,19 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, ...@@ -974,7 +974,19 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
break; break;
case VIR_DOMAIN_DEVICE_VSOCK: case VIR_DOMAIN_DEVICE_VSOCK:
return virtioFlags; switch ((virDomainVsockModel) dev->data.vsock->model) {
case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL:
/* Transitional devices only work in conventional PCI slots */
return pciFlags;
case VIR_DOMAIN_VSOCK_MODEL_VIRTIO:
case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL:
return virtioFlags;
case VIR_DOMAIN_VSOCK_MODEL_DEFAULT:
case VIR_DOMAIN_VSOCK_MODEL_LAST:
return 0;
}
break;
/* These devices don't ever connect with PCI */ /* These devices don't ever connect with PCI */
case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_NVRAM:
......
...@@ -31,6 +31,7 @@ addr=0x1 \ ...@@ -31,6 +31,7 @@ addr=0x1 \
-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \
-device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \
-device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \
-device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
-device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.3,\
addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
...@@ -49,4 +50,6 @@ bus=pci.5,addr=0x0 \ ...@@ -49,4 +50,6 @@ bus=pci.5,addr=0x0 \
id=rng0,bus=pci.6,addr=0x0 \ id=rng0,bus=pci.6,addr=0x0 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \ resourcecontrol=deny \
-device vhost-vsock-pci,disable-legacy=on,disable-modern=off,id=vsock0,\
guest-cid=4,vhostfd=6789,bus=pci.7,addr=0x0 \
-msg timestamp=on -msg timestamp=on
...@@ -31,6 +31,7 @@ addr=0x1 \ ...@@ -31,6 +31,7 @@ addr=0x1 \
-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \
-device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \ -device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \
-device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \ -device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \
-device pcie-root-port,port=0xf,chassis=8,id=pci.8,bus=pcie.0,addr=0x1.0x7 \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
-device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.3,addr=0x0,\
drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
...@@ -47,4 +48,6 @@ id=hostdev0,bus=pci.4,addr=0x0 \ ...@@ -47,4 +48,6 @@ id=hostdev0,bus=pci.4,addr=0x0 \
-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 \ -device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \ resourcecontrol=deny \
-device vhost-vsock-pci-non-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\
bus=pci.7,addr=0x0 \
-msg timestamp=on -msg timestamp=on
...@@ -27,5 +27,8 @@ ...@@ -27,5 +27,8 @@
</filesystem> </filesystem>
<controller type='usb' model='none'/> <controller type='usb' model='none'/>
<memballoon model='virtio-non-transitional'/> <memballoon model='virtio-non-transitional'/>
<vsock model='virtio-non-transitional'>
<cid auto='no' address='4'/>
</vsock>
</devices> </devices>
</domain> </domain>
...@@ -45,4 +45,6 @@ bus=pci.2,addr=0x5 \ ...@@ -45,4 +45,6 @@ bus=pci.2,addr=0x5 \
id=rng0,bus=pci.2,addr=0x6 \ id=rng0,bus=pci.2,addr=0x6 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \ resourcecontrol=deny \
-device vhost-vsock-pci,disable-legacy=off,disable-modern=off,id=vsock0,\
guest-cid=4,vhostfd=6789,bus=pci.2,addr=0x7 \
-msg timestamp=on -msg timestamp=on
...@@ -43,4 +43,6 @@ id=hostdev0,bus=pci.2,addr=0x4 \ ...@@ -43,4 +43,6 @@ id=hostdev0,bus=pci.2,addr=0x4 \
-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \ -device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x6 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
resourcecontrol=deny \ resourcecontrol=deny \
-device vhost-vsock-pci-transitional,id=vsock0,guest-cid=4,vhostfd=6789,\
bus=pci.2,addr=0x7 \
-msg timestamp=on -msg timestamp=on
...@@ -27,5 +27,8 @@ ...@@ -27,5 +27,8 @@
</filesystem> </filesystem>
<controller type='usb' model='none'/> <controller type='usb' model='none'/>
<memballoon model='virtio-transitional'/> <memballoon model='virtio-transitional'/>
<vsock model='virtio-transitional'>
<cid auto='no' address='4'/>
</vsock>
</devices> </devices>
</domain> </domain>
...@@ -60,6 +60,11 @@ ...@@ -60,6 +60,11 @@
<target chassis='7' port='0xe'/> <target chassis='7' port='0xe'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
</controller> </controller>
<controller type='pci' index='8' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='8' port='0xf'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
</controller>
<filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'> <filesystem type='mount' accessmode='passthrough' model='virtio-non-transitional'>
<source dir='/export/fs1'/> <source dir='/export/fs1'/>
<target dir='fs1'/> <target dir='fs1'/>
...@@ -83,5 +88,9 @@ ...@@ -83,5 +88,9 @@
<backend model='random'>/dev/urandom</backend> <backend model='random'>/dev/urandom</backend>
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/> <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
</rng> </rng>
<vsock model='virtio-non-transitional'>
<cid auto='no' address='4'/>
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
</vsock>
</devices> </devices>
</domain> </domain>
...@@ -62,5 +62,9 @@ ...@@ -62,5 +62,9 @@
<backend model='random'>/dev/urandom</backend> <backend model='random'>/dev/urandom</backend>
<address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/> <address type='pci' domain='0x0000' bus='0x02' slot='0x06' function='0x0'/>
</rng> </rng>
<vsock model='virtio-transitional'>
<cid auto='no' address='4'/>
<address type='pci' domain='0x0000' bus='0x02' slot='0x07' function='0x0'/>
</vsock>
</devices> </devices>
</domain> </domain>
...@@ -1259,13 +1259,15 @@ mymain(void) ...@@ -1259,13 +1259,15 @@ mymain(void)
QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
QEMU_CAPS_DEVICE_VHOST_VSOCK);
DO_TEST("virtio-non-transitional", DO_TEST("virtio-non-transitional",
QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE,
QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
QEMU_CAPS_DEVICE_VHOST_VSOCK);
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir); virFileDeleteTree(fakerootdir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册