[libvirt] [PATCH 2/8] qemuBuildVsockDevStr: allow passing a fdprefix

Ján Tomko posted 8 patches 6 years, 11 months ago
[libvirt] [PATCH 2/8] qemuBuildVsockDevStr: allow passing a fdprefix
Posted by Ján Tomko 6 years, 11 months ago
A string prefix for the file descriptor name. Domain startup
uses the numeric value of fd without a prefix, but hotplug
will need to use a prefix because file descriptor names
passed via add-fd cannot start with a number.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_command.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3269c08806..89cd931de6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9915,7 +9915,8 @@ qemuBuildSeccompSandboxCommandLine(virCommandPtr cmd,
 static char *
 qemuBuildVsockDevStr(virDomainDefPtr def,
                      virDomainVsockDefPtr vsock,
-                     virQEMUCapsPtr qemuCaps)
+                     virQEMUCapsPtr qemuCaps,
+                     const char *fdprefix)
 {
     qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -9925,7 +9926,7 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
     virBufferAsprintf(&buf, "%s", device);
     virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
     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)
         goto cleanup;
 
@@ -9950,7 +9951,7 @@ qemuBuildVsockCommandLine(virCommandPtr cmd,
     char *devstr = NULL;
     int ret = -1;
 
-    if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps)))
+    if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps, "")))
         goto cleanup;
 
     virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/8] qemuBuildVsockDevStr: allow passing a fdprefix
Posted by John Ferlan 6 years, 11 months ago
$subj:

qemu: Add prefix for vsock vhostfd

On 05/30/2018 10:57 AM, Ján Tomko wrote:
> A string prefix for the file descriptor name. Domain startup

consider:

Alter qemuBuildVsockDevStr to allow passing a prefix for the vhostfd
file descriptor name.

> uses the numeric value of fd without a prefix, but hotplug
> will need to use a prefix because file descriptor names
> passed via add-fd cannot start with a number.

This doesn't use add-fd, it uses qemuMonitorAddDeviceWithFd - similar
reasoning, just different command.

As an aside, qemuMonitorAddDeviceWithFd has a NULLSTR(fdname), but
passes fdname to qemuMonitorSendFileHandle which just assumes it's there
as does qemuMonitorJSONSendFileHandle ("s:fdname", fdname).

> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1291851
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/qemu_command.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 

Slightly different algorithm than VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO
and SCSIVHost) but who's to say the other 2 are more correct (at least
w/r/t passing the "%d" or "vsockfd%d" string to qemuBuildVsockDevStr
instead of building it in the method). Your call on how to handle.

w/ commit message cleanup...

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list