qemu: check for QEMU_CAPS_DEVICE_VHOST_VSOCK

My commit b8b42ca added support for formatting the vsock
command line without actually checking if it's supported.

Add it to the per-device validation function.

https://bugzilla.redhat.com/show_bug.cgi?id=1291851

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Ján Tomko 2018-06-04 19:37:20 +02:00
parent 52a4078921
commit 8a7003f669
2 changed files with 21 additions and 3 deletions

View File

@ -5283,6 +5283,21 @@ qemuDomainDeviceDefValidateMemory(const virDomainMemoryDef *memory ATTRIBUTE_UNU
} }
static int
qemuDomainDeviceDefValidateVsock(const virDomainVsockDef *vsock ATTRIBUTE_UNUSED,
virQEMUCapsPtr qemuCaps)
{
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_VSOCK)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("vsock device is not supported "
"with this QEMU binary"));
return -1;
}
return 0;
}
static int static int
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def, const virDomainDef *def,
@ -5342,6 +5357,10 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
ret = qemuDomainDeviceDefValidateMemory(dev->data.memory, def); ret = qemuDomainDeviceDefValidateMemory(dev->data.memory, def);
break; break;
case VIR_DOMAIN_DEVICE_VSOCK:
ret = qemuDomainDeviceDefValidateVsock(dev->data.vsock, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_INPUT:
@ -5354,7 +5373,6 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_IOMMU:
case VIR_DOMAIN_DEVICE_VSOCK:
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
break; break;

View File

@ -1212,8 +1212,8 @@ mymain(void)
DO_TEST_STATUS("migration-out-params"); DO_TEST_STATUS("migration-out-params");
DO_TEST_STATUS("migration-out-nbd-tls"); DO_TEST_STATUS("migration-out-nbd-tls");
DO_TEST("vhost-vsock", NONE); DO_TEST("vhost-vsock", QEMU_CAPS_DEVICE_VHOST_VSOCK);
DO_TEST("vhost-vsock-auto", NONE); DO_TEST("vhost-vsock-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK);
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir); virFileDeleteTree(fakerootdir);