mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 03:21:19 +00:00
qemu: Store chardev 'wait' flag in chardev source private data
We have just one case when we wish to wait for incomming connections for a listening socket and that is for vhost-user network devices. Passing this via a flag to qemuBuildChrChardevStr is unwieldy. Add a field to qemuDomainChrSourcePrivate and populate it for our special case inside of qemuDomainPrepareChardevSourceOne. Since we wait for incomming connections only on startup of a new VM we also need to pass in a flag whether qemuDomainPrepareChardevSourceOne is called on a new start or on hotplug. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
73871c3a30
commit
5b7a777bc8
@ -5051,7 +5051,7 @@ qemuBuildChrChardevStr(virLogManager *logManager G_GNUC_UNUSED,
|
|||||||
const virDomainChrSourceDef *dev,
|
const virDomainChrSourceDef *dev,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
virQEMUCaps *qemuCaps,
|
virQEMUCaps *qemuCaps,
|
||||||
unsigned int cdevflags)
|
unsigned int cdevflags G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
qemuDomainChrSourcePrivate *chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev);
|
qemuDomainChrSourcePrivate *chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev);
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
@ -5148,7 +5148,7 @@ qemuBuildChrChardevStr(virLogManager *logManager G_GNUC_UNUSED,
|
|||||||
|
|
||||||
if (dev->data.tcp.listen) {
|
if (dev->data.tcp.listen) {
|
||||||
virBufferAddLit(&buf, ",server=on");
|
virBufferAddLit(&buf, ",server=on");
|
||||||
if (cdevflags & QEMU_BUILD_CHARDEV_TCP_NOWAIT)
|
if (!chrSourcePriv->wait)
|
||||||
virBufferAddLit(&buf, ",wait=off");
|
virBufferAddLit(&buf, ",wait=off");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5199,7 +5199,7 @@ qemuBuildChrChardevStr(virLogManager *logManager G_GNUC_UNUSED,
|
|||||||
}
|
}
|
||||||
if (dev->data.nix.listen) {
|
if (dev->data.nix.listen) {
|
||||||
virBufferAddLit(&buf, ",server=on");
|
virBufferAddLit(&buf, ",server=on");
|
||||||
if (cdevflags & QEMU_BUILD_CHARDEV_TCP_NOWAIT)
|
if (!chrSourcePriv->wait)
|
||||||
virBufferAddLit(&buf, ",wait=off");
|
virBufferAddLit(&buf, ",wait=off");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9735,6 +9735,7 @@ qemuDomainPrepareChardevSourceOne(virDomainDeviceDef *dev,
|
|||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
struct qemuDomainPrepareChardevSourceData *data = opaque;
|
struct qemuDomainPrepareChardevSourceData *data = opaque;
|
||||||
|
qemuDomainChrSourcePrivate *charpriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(charsrc);
|
||||||
|
|
||||||
switch ((virDomainDeviceType) dev->type) {
|
switch ((virDomainDeviceType) dev->type) {
|
||||||
|
|
||||||
@ -9750,8 +9751,13 @@ qemuDomainPrepareChardevSourceOne(virDomainDeviceDef *dev,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_DISK:
|
|
||||||
case VIR_DOMAIN_DEVICE_NET:
|
case VIR_DOMAIN_DEVICE_NET:
|
||||||
|
/* when starting a fresh VM, vhost-user network sockets wait for connection */
|
||||||
|
if (!data->hotplug)
|
||||||
|
charpriv->wait = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_DEVICE_DISK:
|
||||||
case VIR_DOMAIN_DEVICE_SHMEM:
|
case VIR_DOMAIN_DEVICE_SHMEM:
|
||||||
case VIR_DOMAIN_DEVICE_LEASE:
|
case VIR_DOMAIN_DEVICE_LEASE:
|
||||||
case VIR_DOMAIN_DEVICE_FS:
|
case VIR_DOMAIN_DEVICE_FS:
|
||||||
|
@ -344,6 +344,7 @@ struct _qemuDomainChrSourcePrivate {
|
|||||||
|
|
||||||
int fd; /* file descriptor of the chardev source */
|
int fd; /* file descriptor of the chardev source */
|
||||||
int logfd; /* file descriptor of the logging source */
|
int logfd; /* file descriptor of the logging source */
|
||||||
|
bool wait; /* wait for incomming connections on chardev */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -866,6 +867,7 @@ int qemuDomainPrepareChannel(virDomainChrDef *chr,
|
|||||||
|
|
||||||
struct qemuDomainPrepareChardevSourceData {
|
struct qemuDomainPrepareChardevSourceData {
|
||||||
virQEMUDriverConfig *cfg;
|
virQEMUDriverConfig *cfg;
|
||||||
|
bool hotplug;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -6777,7 +6777,8 @@ qemuDomainAttachDeviceLive(virDomainObj *vm,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
const char *alias = NULL;
|
const char *alias = NULL;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
struct qemuDomainPrepareChardevSourceData chardevBackendData = { .cfg = cfg };
|
struct qemuDomainPrepareChardevSourceData chardevBackendData = { .cfg = cfg,
|
||||||
|
.hotplug = true };
|
||||||
|
|
||||||
if (qemuDomainDeviceBackendChardevForeachOne(dev,
|
if (qemuDomainDeviceBackendChardevForeachOne(dev,
|
||||||
qemuDomainPrepareChardevSourceOne,
|
qemuDomainPrepareChardevSourceOne,
|
||||||
|
Loading…
Reference in New Issue
Block a user