qemu: Implement chardev source setup for disk

Add handling to qemuDomainDeviceBackendChardevForeachOne and callbacks
so that we can later use 'qemuBuildChardevCommand' for vhost-user disks
instead of a custom formatter.

Since we don't pass the FD for the vhost-user connection to qemu all of
the setup can be skipped.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-12-08 10:07:44 +01:00
parent 384699b824
commit 5f2cc74257
3 changed files with 14 additions and 1 deletions

View File

@ -11494,6 +11494,12 @@ qemuDomainDeviceBackendChardevForeachOne(virDomainDeviceDef *dev,
void *opaque)
{
switch ((virDomainDeviceType) dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
if (virStorageSourceGetActualType(dev->data.disk->src) != VIR_STORAGE_TYPE_VHOST_USER)
return 0;
return cb(dev, dev->data.disk->src->vhostuser, opaque);
case VIR_DOMAIN_DEVICE_NET:
if (virDomainNetGetActualType(dev->data.net) != VIR_DOMAIN_NET_TYPE_VHOSTUSER)
return 0;
@ -11524,7 +11530,6 @@ qemuDomainDeviceBackendChardevForeachOne(virDomainDeviceDef *dev,
return cb(dev, dev->data.rng->source.chardev, opaque);
case VIR_DOMAIN_DEVICE_DISK:
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:

View File

@ -6882,6 +6882,10 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
/* this function is also called for the monitor backend which doesn't have
* a 'dev' */
if (dev) {
/* vhost-user disk doesn't use FD passing */
if (dev->type == VIR_DOMAIN_DEVICE_DISK)
return 0;
if (dev->type == VIR_DOMAIN_DEVICE_NET) {
/* due to a historical bug in qemu we don't use FD passtrhough for
* vhost-sockets for network devices */

View File

@ -385,6 +385,10 @@ testPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
qemuDomainChrSourcePrivate *charpriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chardev);
if (dev) {
/* vhost-user disk doesn't use FD passing */
if (dev->type == VIR_DOMAIN_DEVICE_DISK)
return 0;
if (dev->type == VIR_DOMAIN_DEVICE_NET) {
/* due to a historical bug in qemu we don't use FD passtrhough for
* vhost-sockets for network devices */