1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

qemu: Add prefix for vsock vhostfd

Alter qemuBuildVsockDevStr to allow passing a prefix for
the vhostfd file descriptor name. Domain startup uses
the numeric value of fd without a prefix, but hotplug
will need to use a prefix because passed file descriptor
names cannot start with a number.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Ján Tomko 2018-05-30 12:52:51 +02:00
parent 5048aa527a
commit 7ecafb4a2b

View File

@ -9915,7 +9915,8 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd,
static char * static char *
qemuBuildVsockDevStr(virDomainDefPtr def, qemuBuildVsockDevStr(virDomainDefPtr def,
virDomainVsockDefPtr vsock, virDomainVsockDefPtr vsock,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps,
const char *fdprefix)
{ {
qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData; qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
@ -9925,7 +9926,7 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
virBufferAsprintf(&buf, "%s", device); virBufferAsprintf(&buf, "%s", device);
virBufferAsprintf(&buf, ",id=%s", vsock->info.alias); virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid); virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid);
virBufferAsprintf(&buf, ",vhostfd=%u", priv->vhostfd); virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd);
if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0) if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0)
goto cleanup; goto cleanup;
@ -9950,7 +9951,7 @@ qemuBuildVsockCommandLine(virCommandPtr cmd,
char *devstr = NULL; char *devstr = NULL;
int ret = -1; int ret = -1;
if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps))) if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps, "")))
goto cleanup; goto cleanup;
virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);