mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
qemu: Use 'qemuFDPassDirect' for 'unix' chardevs
Unix socket chardevs with FD passing need to use the direct mode so we need to convert it to use qemuFDPassDirect. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7e1c24c925
commit
15bdced9b3
@ -1396,8 +1396,8 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev,
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
virBufferAsprintf(&buf, "socket,id=%s", charAlias);
|
||||
if (chrSourcePriv->sourcefd) {
|
||||
virBufferAsprintf(&buf, ",fd=%s", qemuFDPassGetPath(chrSourcePriv->sourcefd));
|
||||
if (chrSourcePriv->directfd) {
|
||||
virBufferAsprintf(&buf, ",fd=%s", qemuFDPassDirectGetPath(chrSourcePriv->directfd));
|
||||
} else {
|
||||
virBufferAddLit(&buf, ",path=");
|
||||
virQEMUBuildBufferEscapeComma(&buf, dev->data.nix.path);
|
||||
@ -1513,9 +1513,13 @@ qemuBuildChardevCommand(virCommand *cmd,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
if (qemuFDPassTransferCommand(chrSourcePriv->sourcefd, cmd) < 0)
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
qemuFDPassDirectTransferCommand(chrSourcePriv->directfd, cmd);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_NULL:
|
||||
@ -4907,12 +4911,11 @@ qemuBuildVideoCommandLine(virCommand *cmd,
|
||||
qemuDomainVideoPrivate *videopriv = QEMU_DOMAIN_VIDEO_PRIVATE(video);
|
||||
g_autoptr(virDomainChrSourceDef) chrsrc = virDomainChrSourceDefNew(priv->driver->xmlopt);
|
||||
g_autofree char *chrAlias = qemuDomainGetVhostUserChrAlias(video->info.alias);
|
||||
g_autofree char *name = g_strdup_printf("%s-vhost-user", video->info.alias);
|
||||
qemuDomainChrSourcePrivate *chrsrcpriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chrsrc);
|
||||
|
||||
chrsrc->type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||
chrsrcpriv->sourcefd = qemuFDPassNewDirect(video->info.alias, priv);
|
||||
|
||||
qemuFDPassAddFD(chrsrcpriv->sourcefd, &videopriv->vhost_user_fd, "-vhost-user");
|
||||
chrsrcpriv->directfd = qemuFDPassDirectNew(name, &videopriv->vhost_user_fd);
|
||||
|
||||
if (qemuBuildChardevCommand(cmd, chrsrc, chrAlias, priv->qemuCaps) < 0)
|
||||
return -1;
|
||||
|
@ -916,6 +916,7 @@ qemuDomainChrSourcePrivateClearFDPass(qemuDomainChrSourcePrivate *priv)
|
||||
|
||||
g_clear_pointer(&priv->sourcefd, qemuFDPassFree);
|
||||
g_clear_pointer(&priv->logfd, qemuFDPassFree);
|
||||
g_clear_pointer(&priv->directfd, qemuFDPassDirectFree);
|
||||
}
|
||||
|
||||
|
||||
|
@ -350,6 +350,7 @@ struct _qemuDomainChrSourcePrivate {
|
||||
|
||||
qemuFDPass *sourcefd;
|
||||
qemuFDPass *logfd;
|
||||
qemuFDPassDirect *directfd;
|
||||
bool wait; /* wait for incoming connections on chardev */
|
||||
|
||||
char *tlsCertPath; /* path to certificates if TLS is requested */
|
||||
|
@ -2133,11 +2133,12 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
||||
if (qemuProcessPrepareHostBackendChardevHotplug(vm, dev) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (charpriv->sourcefd || charpriv->logfd) {
|
||||
if (charpriv->sourcefd || charpriv->logfd || charpriv->directfd) {
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
|
||||
if (qemuFDPassTransferMonitor(charpriv->sourcefd, priv->mon) < 0 ||
|
||||
qemuFDPassTransferMonitor(charpriv->logfd, priv->mon) < 0)
|
||||
qemuFDPassTransferMonitor(charpriv->logfd, priv->mon) < 0 ||
|
||||
qemuFDPassDirectTransferMonitor(charpriv->directfd, priv->mon) < 0)
|
||||
goto exit_monitor;
|
||||
|
||||
qemuDomainObjExitMonitor(vm);
|
||||
|
@ -6724,8 +6724,8 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
|
||||
waitval = VIR_TRISTATE_BOOL_NO;
|
||||
}
|
||||
|
||||
if (chrSourcePriv->sourcefd) {
|
||||
if (!(addr = qemuMonitorJSONBuildFDSocketAddress(qemuFDPassGetPath(chrSourcePriv->sourcefd))))
|
||||
if (chrSourcePriv->directfd) {
|
||||
if (!(addr = qemuMonitorJSONBuildFDSocketAddress(qemuFDPassDirectGetPath(chrSourcePriv->directfd))))
|
||||
return NULL;
|
||||
} else {
|
||||
if (!(addr = qemuMonitorJSONBuildUnixSocketAddress(chr->data.nix.path)))
|
||||
|
@ -6876,6 +6876,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
if (chardev->data.nix.listen) {
|
||||
g_autofree char *name = g_strdup_printf("%s-source", devalias);
|
||||
VIR_AUTOCLOSE sourcefd = -1;
|
||||
|
||||
if (qemuSecuritySetSocketLabel(data->priv->driver->securityManager, data->def) < 0)
|
||||
@ -6887,9 +6888,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
|
||||
sourcefd < 0)
|
||||
return -1;
|
||||
|
||||
charpriv->sourcefd = qemuFDPassNewDirect(devalias, data->priv);
|
||||
|
||||
qemuFDPassAddFD(charpriv->sourcefd, &sourcefd, "-source");
|
||||
charpriv->directfd = qemuFDPassDirectNew(name, &sourcefd);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1019,7 +1019,6 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
|
||||
qemuDomainChrSourcePrivate *charpriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chardev);
|
||||
int fakesourcefd = -1;
|
||||
const char *devalias = NULL;
|
||||
bool usefdset = true;
|
||||
|
||||
if (vm)
|
||||
priv = vm->privateData;
|
||||
@ -1061,13 +1060,22 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||
fakesourcefd = 1750;
|
||||
|
||||
if (fcntl(fakesourcefd, F_GETFD) != -1)
|
||||
abort();
|
||||
|
||||
charpriv->sourcefd = qemuFDPassNew(devalias, priv);
|
||||
qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source");
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||
if (chardev->data.nix.listen)
|
||||
if (chardev->data.nix.listen) {
|
||||
g_autofree char *name = g_strdup_printf("%s-source", devalias);
|
||||
fakesourcefd = 1729;
|
||||
|
||||
usefdset = false;
|
||||
charpriv->directfd = qemuFDPassDirectNew(name, &fakesourcefd);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CHR_TYPE_NMDM:
|
||||
@ -1075,18 +1083,6 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
|
||||
break;
|
||||
}
|
||||
|
||||
if (fakesourcefd != -1) {
|
||||
if (fcntl(fakesourcefd, F_GETFD) != -1)
|
||||
abort();
|
||||
|
||||
if (usefdset)
|
||||
charpriv->sourcefd = qemuFDPassNew(devalias, priv);
|
||||
else
|
||||
charpriv->sourcefd = qemuFDPassNewDirect(devalias, priv);
|
||||
|
||||
qemuFDPassAddFD(charpriv->sourcefd, &fakesourcefd, "-source");
|
||||
}
|
||||
|
||||
if (chardev->logfile) {
|
||||
int fd = 1751;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user