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(a)redhat.com>
---
src/qemu/qemu_block.c | 2 +-
src/qemu/qemu_block.h | 1 +
src/qemu/qemu_chardev.c | 20 +++++++++++++++++++-
src/qemu/qemu_chardev.h | 1 +
src/qemu/qemu_command.c | 12 ++++++++----
src/qemu/qemu_command.h | 3 ++-
src/qemu/qemu_hotplug.c | 19 ++++++++++---------
tests/qemumonitorjsontest.c | 2 +-
8 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index e739c097ca..692b4d350e 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -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;
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
index f9e961d85d..f13a4a4a9a 100644
--- a/src/qemu/qemu_block.h
+++ b/src/qemu/qemu_block.h
@@ -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;
diff --git a/src/qemu/qemu_chardev.c b/src/qemu/qemu_chardev.c
index b3ed11233b..b6828b6752 100644
--- a/src/qemu/qemu_chardev.c
+++ b/src/qemu/qemu_chardev.c
@@ -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) {
diff --git a/src/qemu/qemu_chardev.h b/src/qemu/qemu_chardev.h
index 0381e0df65..59f258cbe3 100644
--- a/src/qemu/qemu_chardev.h
+++ b/src/qemu/qemu_chardev.h
@@ -17,6 +17,7 @@ qemuChardevBuildCommandline(virCommand *cmd,
int
qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
bool commandline,
+ virQEMUCaps *qemuCaps,
const char *alias,
const char **backendType,
virJSONValue **props);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b4888a5822..c7055ef196 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index dca8877703..309e566f6c 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -106,7 +106,8 @@ qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDef
*disk);
qemuBlockStorageSourceChainData *
-qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk);
+qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk,
+ virQEMUCaps *qemuCaps);
qemuBlockStorageSourceChainData *
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 4d4bcde1bc..1a7b69e5bb 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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;
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index fca4890746..f7fe0fb6f4 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -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)
--
2.46.2