mirror of
https://github.com/libvirt/libvirt.git
synced 2025-01-06 14:13:27 -06:00
qemu: chardev: Use 'reconnect-ms' instead of deprecated 'reconnect'
qemu-9.2 will deprecate the 'reconnect' field in favor of 'reconnect-ms'. As libvirt currently doesn't track the timeouts in milliseconds we simply convert them to avoid use of the deprecated field. Quite a lot of churn is caused by the need to plumb 'qemuCaps' into the chardev props generator. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
23fa1d2184
commit
baa4edfb79
@ -1685,7 +1685,7 @@ qemuBlockStorageSourceAttachApply(qemuMonitor *mon,
|
||||
if (data->chardevDef) {
|
||||
g_autoptr(virJSONValue) props = NULL;
|
||||
|
||||
if (qemuChardevGetBackendProps(data->chardevDef, false,
|
||||
if (qemuChardevGetBackendProps(data->chardevDef, false, data->qemuCaps,
|
||||
data->chardevAlias, NULL, &props) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -105,6 +105,7 @@ struct qemuBlockStorageSourceAttachData {
|
||||
|
||||
char *driveCmd;
|
||||
|
||||
virQEMUCaps *qemuCaps; /* borrowed from VM, valid only for chardev-backed source */
|
||||
virDomainChrSourceDef *chardevDef;
|
||||
char *chardevAlias;
|
||||
bool chardevAdded;
|
||||
|
@ -143,6 +143,7 @@ qemuChardevBackendAddSocketAddressUNIX(virJSONValue **backendData,
|
||||
int
|
||||
qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||
bool commandline,
|
||||
virQEMUCaps *qemuCaps,
|
||||
const char *alias,
|
||||
const char **backendType,
|
||||
virJSONValue **props)
|
||||
@ -213,6 +214,7 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||
virTristateBool waitval = VIR_TRISTATE_BOOL_ABSENT;
|
||||
virTristateBool server = VIR_TRISTATE_BOOL_ABSENT;
|
||||
int reconnect = -1;
|
||||
long long reconnect_ms = -1;
|
||||
|
||||
*backendType = "socket";
|
||||
|
||||
@ -243,10 +245,17 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||
reconnect = 0;
|
||||
}
|
||||
|
||||
if (reconnect != -1 &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS)) {
|
||||
reconnect_ms = reconnect * 1000;
|
||||
reconnect = -1;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectAdd(props,
|
||||
"T:server", server,
|
||||
"T:wait", waitval,
|
||||
"k:reconnect", reconnect,
|
||||
"K:reconnect-ms", reconnect_ms,
|
||||
NULL) < 0)
|
||||
return -1;
|
||||
}
|
||||
@ -257,6 +266,7 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||
virTristateBool telnet = VIR_TRISTATE_BOOL_ABSENT;
|
||||
virTristateBool server = VIR_TRISTATE_BOOL_ABSENT;
|
||||
int reconnect = -1;
|
||||
long long reconnect_ms = -1;
|
||||
|
||||
*backendType = "socket";
|
||||
|
||||
@ -280,6 +290,12 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||
else if (chr->data.tcp.reconnect.enabled == VIR_TRISTATE_BOOL_NO)
|
||||
reconnect = 0;
|
||||
|
||||
if (reconnect != -1 &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS)) {
|
||||
reconnect_ms = reconnect * 1000;
|
||||
reconnect = -1;
|
||||
}
|
||||
|
||||
if (qemuChardevBackendAddSocketAddressInet(props, "addr",
|
||||
commandline, NULL,
|
||||
chr->data.tcp.host,
|
||||
@ -291,6 +307,7 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||
"T:server", server,
|
||||
"T:wait", waitval,
|
||||
"k:reconnect", reconnect,
|
||||
"K:reconnect-ms", reconnect_ms,
|
||||
"S:tls-creds", chrSourcePriv->tlsCredsAlias,
|
||||
NULL) < 0)
|
||||
return -1;
|
||||
@ -462,7 +479,8 @@ qemuChardevBuildCommandline(virCommand *cmd,
|
||||
bool useJSON = virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_JSON);
|
||||
const char *backendType = NULL;
|
||||
|
||||
if (qemuChardevGetBackendProps(dev, !useJSON, charAlias, &backendType, &props) < 0)
|
||||
if (qemuChardevGetBackendProps(dev, !useJSON, qemuCaps, charAlias,
|
||||
&backendType, &props) < 0)
|
||||
return -1;
|
||||
|
||||
if (useJSON) {
|
||||
|
@ -17,6 +17,7 @@ qemuChardevBuildCommandline(virCommand *cmd,
|
||||
int
|
||||
qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||
bool commandline,
|
||||
virQEMUCaps *qemuCaps,
|
||||
const char *alias,
|
||||
const char **backendType,
|
||||
virJSONValue **props);
|
||||
|
@ -2027,7 +2027,7 @@ qemuBuildDiskSourceCommandLine(virCommand *cmd,
|
||||
size_t i;
|
||||
|
||||
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk, qemuCaps)))
|
||||
return -1;
|
||||
} else if (!qemuDiskBusIsSD(disk->bus)) {
|
||||
if (virStorageSourceIsEmpty(disk->src))
|
||||
@ -10824,18 +10824,21 @@ qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDef *disk)
|
||||
/**
|
||||
* qemuBuildStorageSourceAttachPrepareChardev:
|
||||
* @src: disk source to prepare
|
||||
* @qemuCaps: qemu capabilities object borrowed for chardev backend generation
|
||||
*
|
||||
* Prepare qemuBlockStorageSourceAttachData *for vhost-user disk
|
||||
* to be used with -chardev.
|
||||
*/
|
||||
static qemuBlockStorageSourceAttachData *
|
||||
qemuBuildStorageSourceAttachPrepareChardev(virDomainDiskDef *disk)
|
||||
qemuBuildStorageSourceAttachPrepareChardev(virDomainDiskDef *disk,
|
||||
virQEMUCaps *qemuCaps)
|
||||
{
|
||||
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
|
||||
|
||||
data = g_new0(qemuBlockStorageSourceAttachData, 1);
|
||||
|
||||
data->chardevDef = disk->src->vhostuser;
|
||||
data->qemuCaps = qemuCaps;
|
||||
data->chardevAlias = qemuDomainGetVhostUserChrAlias(disk->info.alias);
|
||||
|
||||
return g_steal_pointer(&data);
|
||||
@ -10937,14 +10940,15 @@ qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDef *disk)
|
||||
* disk's backend via -chardev.
|
||||
*/
|
||||
qemuBlockStorageSourceChainData *
|
||||
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk)
|
||||
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk,
|
||||
virQEMUCaps *qemuCaps)
|
||||
{
|
||||
g_autoptr(qemuBlockStorageSourceAttachData) elem = NULL;
|
||||
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
|
||||
|
||||
data = g_new0(qemuBlockStorageSourceChainData, 1);
|
||||
|
||||
if (!(elem = qemuBuildStorageSourceAttachPrepareChardev(disk)))
|
||||
if (!(elem = qemuBuildStorageSourceAttachPrepareChardev(disk, qemuCaps)))
|
||||
return NULL;
|
||||
|
||||
VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem);
|
||||
|
@ -106,7 +106,8 @@ qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDef *disk);
|
||||
|
||||
|
||||
qemuBlockStorageSourceChainData *
|
||||
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk);
|
||||
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk,
|
||||
virQEMUCaps *qemuCaps);
|
||||
|
||||
|
||||
qemuBlockStorageSourceChainData *
|
||||
|
@ -243,7 +243,8 @@ qemuDomainDetachExtensionDevice(qemuMonitor *mon,
|
||||
static int
|
||||
qemuHotplugChardevAttach(qemuMonitor *mon,
|
||||
const char *alias,
|
||||
virDomainChrSourceDef *def)
|
||||
virDomainChrSourceDef *def,
|
||||
virQEMUCaps *qemuCaps)
|
||||
{
|
||||
g_autoptr(virJSONValue) props = NULL;
|
||||
g_autofree char *ptypath = NULL;
|
||||
@ -277,7 +278,7 @@ qemuHotplugChardevAttach(qemuMonitor *mon,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuChardevGetBackendProps(def, false, alias, NULL, &props) < 0)
|
||||
if (qemuChardevGetBackendProps(def, false, qemuCaps, alias, NULL, &props) < 0)
|
||||
return -1;
|
||||
|
||||
if (qemuMonitorAttachCharDev(mon, &props, &ptypath) < 0)
|
||||
@ -719,7 +720,7 @@ qemuDomainAttachDiskGeneric(virDomainObj *vm,
|
||||
disk->src->readonly = true;
|
||||
|
||||
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk, priv->qemuCaps)))
|
||||
return -1;
|
||||
} else {
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src)))
|
||||
@ -1370,7 +1371,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
|
||||
}
|
||||
|
||||
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
|
||||
if (qemuHotplugChardevAttach(priv->mon, charDevAlias, net->data.vhostuser) < 0) {
|
||||
if (qemuHotplugChardevAttach(priv->mon, charDevAlias, net->data.vhostuser, priv->qemuCaps) < 0) {
|
||||
qemuDomainObjExitMonitor(vm);
|
||||
virDomainAuditNet(vm, NULL, net, "attach", false);
|
||||
goto cleanup;
|
||||
@ -1846,7 +1847,7 @@ qemuDomainAttachRedirdevDevice(virQEMUDriver *driver,
|
||||
|
||||
qemuDomainObjEnterMonitor(vm);
|
||||
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, redirdev->source) < 0)
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, redirdev->source, priv->qemuCaps) < 0)
|
||||
goto exit_monitor;
|
||||
chardevAdded = true;
|
||||
|
||||
@ -2115,7 +2116,7 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
||||
qemuFDPassDirectTransferMonitor(charpriv->directfd, priv->mon) < 0)
|
||||
goto exit_monitor;
|
||||
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, chr->source) < 0)
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, chr->source, priv->qemuCaps) < 0)
|
||||
goto exit_monitor;
|
||||
chardevAttached = true;
|
||||
|
||||
@ -2225,7 +2226,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver,
|
||||
qemuDomainObjEnterMonitor(vm);
|
||||
|
||||
if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD &&
|
||||
qemuHotplugChardevAttach(priv->mon, charAlias, rng->source.chardev) < 0)
|
||||
qemuHotplugChardevAttach(priv->mon, charAlias, rng->source.chardev, priv->qemuCaps) < 0)
|
||||
goto exit_monitor;
|
||||
chardevAdded = true;
|
||||
|
||||
@ -2899,7 +2900,7 @@ qemuDomainAttachShmemDevice(virDomainObj *vm,
|
||||
qemuDomainObjEnterMonitor(vm);
|
||||
|
||||
if (shmem->server.enabled) {
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, shmem->server.chr) < 0)
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, shmem->server.chr, priv->qemuCaps) < 0)
|
||||
goto exit_monitor;
|
||||
} else {
|
||||
if (qemuMonitorAddObject(priv->mon, &props, &memAlias) < 0)
|
||||
@ -3296,7 +3297,7 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver,
|
||||
|
||||
qemuDomainObjEnterMonitor(vm);
|
||||
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, chardev) < 0)
|
||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, chardev, priv->qemuCaps) < 0)
|
||||
goto exit_monitor;
|
||||
chardevAdded = true;
|
||||
|
||||
|
@ -578,7 +578,7 @@ testQemuMonitorJSONAttachChardev(const void *opaque)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemuChardevGetBackendProps(data->chr, false, "alias", NULL, &props) < 0)
|
||||
if (qemuChardevGetBackendProps(data->chr, false, NULL, "alias", NULL, &props) < 0)
|
||||
return -1;
|
||||
|
||||
if ((rc = qemuMonitorAttachCharDev(qemuMonitorTestGetMonitor(test), &props, &ptypath)) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user