mirror of
https://github.com/libvirt/libvirt.git
synced 2025-01-08 07:03:19 -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) {
|
if (data->chardevDef) {
|
||||||
g_autoptr(virJSONValue) props = NULL;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
|
|
||||||
if (qemuChardevGetBackendProps(data->chardevDef, false,
|
if (qemuChardevGetBackendProps(data->chardevDef, false, data->qemuCaps,
|
||||||
data->chardevAlias, NULL, &props) < 0)
|
data->chardevAlias, NULL, &props) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ struct qemuBlockStorageSourceAttachData {
|
|||||||
|
|
||||||
char *driveCmd;
|
char *driveCmd;
|
||||||
|
|
||||||
|
virQEMUCaps *qemuCaps; /* borrowed from VM, valid only for chardev-backed source */
|
||||||
virDomainChrSourceDef *chardevDef;
|
virDomainChrSourceDef *chardevDef;
|
||||||
char *chardevAlias;
|
char *chardevAlias;
|
||||||
bool chardevAdded;
|
bool chardevAdded;
|
||||||
|
@ -143,6 +143,7 @@ qemuChardevBackendAddSocketAddressUNIX(virJSONValue **backendData,
|
|||||||
int
|
int
|
||||||
qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||||
bool commandline,
|
bool commandline,
|
||||||
|
virQEMUCaps *qemuCaps,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
const char **backendType,
|
const char **backendType,
|
||||||
virJSONValue **props)
|
virJSONValue **props)
|
||||||
@ -213,6 +214,7 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
|||||||
virTristateBool waitval = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool waitval = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
virTristateBool server = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool server = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
int reconnect = -1;
|
int reconnect = -1;
|
||||||
|
long long reconnect_ms = -1;
|
||||||
|
|
||||||
*backendType = "socket";
|
*backendType = "socket";
|
||||||
|
|
||||||
@ -243,10 +245,17 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
|||||||
reconnect = 0;
|
reconnect = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reconnect != -1 &&
|
||||||
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS)) {
|
||||||
|
reconnect_ms = reconnect * 1000;
|
||||||
|
reconnect = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(props,
|
if (virJSONValueObjectAdd(props,
|
||||||
"T:server", server,
|
"T:server", server,
|
||||||
"T:wait", waitval,
|
"T:wait", waitval,
|
||||||
"k:reconnect", reconnect,
|
"k:reconnect", reconnect,
|
||||||
|
"K:reconnect-ms", reconnect_ms,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -257,6 +266,7 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
|||||||
virTristateBool telnet = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool telnet = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
virTristateBool server = VIR_TRISTATE_BOOL_ABSENT;
|
virTristateBool server = VIR_TRISTATE_BOOL_ABSENT;
|
||||||
int reconnect = -1;
|
int reconnect = -1;
|
||||||
|
long long reconnect_ms = -1;
|
||||||
|
|
||||||
*backendType = "socket";
|
*backendType = "socket";
|
||||||
|
|
||||||
@ -280,6 +290,12 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
|||||||
else if (chr->data.tcp.reconnect.enabled == VIR_TRISTATE_BOOL_NO)
|
else if (chr->data.tcp.reconnect.enabled == VIR_TRISTATE_BOOL_NO)
|
||||||
reconnect = 0;
|
reconnect = 0;
|
||||||
|
|
||||||
|
if (reconnect != -1 &&
|
||||||
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS)) {
|
||||||
|
reconnect_ms = reconnect * 1000;
|
||||||
|
reconnect = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (qemuChardevBackendAddSocketAddressInet(props, "addr",
|
if (qemuChardevBackendAddSocketAddressInet(props, "addr",
|
||||||
commandline, NULL,
|
commandline, NULL,
|
||||||
chr->data.tcp.host,
|
chr->data.tcp.host,
|
||||||
@ -291,6 +307,7 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
|||||||
"T:server", server,
|
"T:server", server,
|
||||||
"T:wait", waitval,
|
"T:wait", waitval,
|
||||||
"k:reconnect", reconnect,
|
"k:reconnect", reconnect,
|
||||||
|
"K:reconnect-ms", reconnect_ms,
|
||||||
"S:tls-creds", chrSourcePriv->tlsCredsAlias,
|
"S:tls-creds", chrSourcePriv->tlsCredsAlias,
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -462,7 +479,8 @@ qemuChardevBuildCommandline(virCommand *cmd,
|
|||||||
bool useJSON = virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_JSON);
|
bool useJSON = virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_JSON);
|
||||||
const char *backendType = NULL;
|
const char *backendType = NULL;
|
||||||
|
|
||||||
if (qemuChardevGetBackendProps(dev, !useJSON, charAlias, &backendType, &props) < 0)
|
if (qemuChardevGetBackendProps(dev, !useJSON, qemuCaps, charAlias,
|
||||||
|
&backendType, &props) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (useJSON) {
|
if (useJSON) {
|
||||||
|
@ -17,6 +17,7 @@ qemuChardevBuildCommandline(virCommand *cmd,
|
|||||||
int
|
int
|
||||||
qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
|
||||||
bool commandline,
|
bool commandline,
|
||||||
|
virQEMUCaps *qemuCaps,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
const char **backendType,
|
const char **backendType,
|
||||||
virJSONValue **props);
|
virJSONValue **props);
|
||||||
|
@ -2027,7 +2027,7 @@ qemuBuildDiskSourceCommandLine(virCommand *cmd,
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
||||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
|
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk, qemuCaps)))
|
||||||
return -1;
|
return -1;
|
||||||
} else if (!qemuDiskBusIsSD(disk->bus)) {
|
} else if (!qemuDiskBusIsSD(disk->bus)) {
|
||||||
if (virStorageSourceIsEmpty(disk->src))
|
if (virStorageSourceIsEmpty(disk->src))
|
||||||
@ -10824,18 +10824,21 @@ qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDef *disk)
|
|||||||
/**
|
/**
|
||||||
* qemuBuildStorageSourceAttachPrepareChardev:
|
* qemuBuildStorageSourceAttachPrepareChardev:
|
||||||
* @src: disk source to prepare
|
* @src: disk source to prepare
|
||||||
|
* @qemuCaps: qemu capabilities object borrowed for chardev backend generation
|
||||||
*
|
*
|
||||||
* Prepare qemuBlockStorageSourceAttachData *for vhost-user disk
|
* Prepare qemuBlockStorageSourceAttachData *for vhost-user disk
|
||||||
* to be used with -chardev.
|
* to be used with -chardev.
|
||||||
*/
|
*/
|
||||||
static qemuBlockStorageSourceAttachData *
|
static qemuBlockStorageSourceAttachData *
|
||||||
qemuBuildStorageSourceAttachPrepareChardev(virDomainDiskDef *disk)
|
qemuBuildStorageSourceAttachPrepareChardev(virDomainDiskDef *disk,
|
||||||
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
|
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
|
||||||
|
|
||||||
data = g_new0(qemuBlockStorageSourceAttachData, 1);
|
data = g_new0(qemuBlockStorageSourceAttachData, 1);
|
||||||
|
|
||||||
data->chardevDef = disk->src->vhostuser;
|
data->chardevDef = disk->src->vhostuser;
|
||||||
|
data->qemuCaps = qemuCaps;
|
||||||
data->chardevAlias = qemuDomainGetVhostUserChrAlias(disk->info.alias);
|
data->chardevAlias = qemuDomainGetVhostUserChrAlias(disk->info.alias);
|
||||||
|
|
||||||
return g_steal_pointer(&data);
|
return g_steal_pointer(&data);
|
||||||
@ -10937,14 +10940,15 @@ qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDef *disk)
|
|||||||
* disk's backend via -chardev.
|
* disk's backend via -chardev.
|
||||||
*/
|
*/
|
||||||
qemuBlockStorageSourceChainData *
|
qemuBlockStorageSourceChainData *
|
||||||
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk)
|
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk,
|
||||||
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
g_autoptr(qemuBlockStorageSourceAttachData) elem = NULL;
|
g_autoptr(qemuBlockStorageSourceAttachData) elem = NULL;
|
||||||
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
|
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
|
||||||
|
|
||||||
data = g_new0(qemuBlockStorageSourceChainData, 1);
|
data = g_new0(qemuBlockStorageSourceChainData, 1);
|
||||||
|
|
||||||
if (!(elem = qemuBuildStorageSourceAttachPrepareChardev(disk)))
|
if (!(elem = qemuBuildStorageSourceAttachPrepareChardev(disk, qemuCaps)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem);
|
VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem);
|
||||||
|
@ -106,7 +106,8 @@ qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDef *disk);
|
|||||||
|
|
||||||
|
|
||||||
qemuBlockStorageSourceChainData *
|
qemuBlockStorageSourceChainData *
|
||||||
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk);
|
qemuBuildStorageSourceChainAttachPrepareChardev(virDomainDiskDef *disk,
|
||||||
|
virQEMUCaps *qemuCaps);
|
||||||
|
|
||||||
|
|
||||||
qemuBlockStorageSourceChainData *
|
qemuBlockStorageSourceChainData *
|
||||||
|
@ -243,7 +243,8 @@ qemuDomainDetachExtensionDevice(qemuMonitor *mon,
|
|||||||
static int
|
static int
|
||||||
qemuHotplugChardevAttach(qemuMonitor *mon,
|
qemuHotplugChardevAttach(qemuMonitor *mon,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
virDomainChrSourceDef *def)
|
virDomainChrSourceDef *def,
|
||||||
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) props = NULL;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
g_autofree char *ptypath = NULL;
|
g_autofree char *ptypath = NULL;
|
||||||
@ -277,7 +278,7 @@ qemuHotplugChardevAttach(qemuMonitor *mon,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuChardevGetBackendProps(def, false, alias, NULL, &props) < 0)
|
if (qemuChardevGetBackendProps(def, false, qemuCaps, alias, NULL, &props) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorAttachCharDev(mon, &props, &ptypath) < 0)
|
if (qemuMonitorAttachCharDev(mon, &props, &ptypath) < 0)
|
||||||
@ -719,7 +720,7 @@ qemuDomainAttachDiskGeneric(virDomainObj *vm,
|
|||||||
disk->src->readonly = true;
|
disk->src->readonly = true;
|
||||||
|
|
||||||
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
||||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
|
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk, priv->qemuCaps)))
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src)))
|
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src)))
|
||||||
@ -1370,7 +1371,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
|
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);
|
qemuDomainObjExitMonitor(vm);
|
||||||
virDomainAuditNet(vm, NULL, net, "attach", false);
|
virDomainAuditNet(vm, NULL, net, "attach", false);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1846,7 +1847,7 @@ qemuDomainAttachRedirdevDevice(virQEMUDriver *driver,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitor(vm);
|
qemuDomainObjEnterMonitor(vm);
|
||||||
|
|
||||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, redirdev->source) < 0)
|
if (qemuHotplugChardevAttach(priv->mon, charAlias, redirdev->source, priv->qemuCaps) < 0)
|
||||||
goto exit_monitor;
|
goto exit_monitor;
|
||||||
chardevAdded = true;
|
chardevAdded = true;
|
||||||
|
|
||||||
@ -2115,7 +2116,7 @@ qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
|||||||
qemuFDPassDirectTransferMonitor(charpriv->directfd, priv->mon) < 0)
|
qemuFDPassDirectTransferMonitor(charpriv->directfd, priv->mon) < 0)
|
||||||
goto exit_monitor;
|
goto exit_monitor;
|
||||||
|
|
||||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, chr->source) < 0)
|
if (qemuHotplugChardevAttach(priv->mon, charAlias, chr->source, priv->qemuCaps) < 0)
|
||||||
goto exit_monitor;
|
goto exit_monitor;
|
||||||
chardevAttached = true;
|
chardevAttached = true;
|
||||||
|
|
||||||
@ -2225,7 +2226,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver,
|
|||||||
qemuDomainObjEnterMonitor(vm);
|
qemuDomainObjEnterMonitor(vm);
|
||||||
|
|
||||||
if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD &&
|
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;
|
goto exit_monitor;
|
||||||
chardevAdded = true;
|
chardevAdded = true;
|
||||||
|
|
||||||
@ -2899,7 +2900,7 @@ qemuDomainAttachShmemDevice(virDomainObj *vm,
|
|||||||
qemuDomainObjEnterMonitor(vm);
|
qemuDomainObjEnterMonitor(vm);
|
||||||
|
|
||||||
if (shmem->server.enabled) {
|
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;
|
goto exit_monitor;
|
||||||
} else {
|
} else {
|
||||||
if (qemuMonitorAddObject(priv->mon, &props, &memAlias) < 0)
|
if (qemuMonitorAddObject(priv->mon, &props, &memAlias) < 0)
|
||||||
@ -3296,7 +3297,7 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitor(vm);
|
qemuDomainObjEnterMonitor(vm);
|
||||||
|
|
||||||
if (qemuHotplugChardevAttach(priv->mon, charAlias, chardev) < 0)
|
if (qemuHotplugChardevAttach(priv->mon, charAlias, chardev, priv->qemuCaps) < 0)
|
||||||
goto exit_monitor;
|
goto exit_monitor;
|
||||||
chardevAdded = true;
|
chardevAdded = true;
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ testQemuMonitorJSONAttachChardev(const void *opaque)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuChardevGetBackendProps(data->chr, false, "alias", NULL, &props) < 0)
|
if (qemuChardevGetBackendProps(data->chr, false, NULL, "alias", NULL, &props) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((rc = qemuMonitorAttachCharDev(qemuMonitorTestGetMonitor(test), &props, &ptypath)) < 0)
|
if ((rc = qemuMonitorAttachCharDev(qemuMonitorTestGetMonitor(test), &props, &ptypath)) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user