While this is no functional change, whole channel definition is
going to be needed very soon. Moreover, while touching this obey
const correctness rule in qemuAgentOpen() - so far it was passed
regular pointer to channel config even though the function is
expected to not change pointee at all. Pass const pointer
instead.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_agent.c | 2 +-
src/qemu/qemu_agent.h | 2 +-
src/qemu/qemu_domain.c | 11 ++++-------
src/qemu/qemu_domain.h | 2 +-
src/qemu/qemu_process.c | 4 ++--
5 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 5735ed8..f979f82 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -710,7 +710,7 @@ qemuAgentIO(int watch, int fd, int events, void *opaque)
qemuAgentPtr
qemuAgentOpen(virDomainObjPtr vm,
- virDomainChrSourceDefPtr config,
+ const virDomainChrSourceDef *config,
qemuAgentCallbacksPtr cb)
{
qemuAgentPtr mon;
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 7cbf8eb..c092504 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -44,7 +44,7 @@ struct _qemuAgentCallbacks {
qemuAgentPtr qemuAgentOpen(virDomainObjPtr vm,
- virDomainChrSourceDefPtr config,
+ const virDomainChrSourceDef *config,
qemuAgentCallbacksPtr cb);
void qemuAgentClose(qemuAgentPtr mon);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 55d5e71..e8c291f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3704,10 +3704,9 @@ qemuDomainSupportsBlockJobs(virDomainObjPtr vm,
* Returns the pointer to the channel definition that is used to access the
* guest agent if the agent is configured or NULL otherwise.
*/
-virDomainChrSourceDefPtr
+virDomainChrDefPtr
qemuFindAgentConfig(virDomainDefPtr def)
{
- virDomainChrSourceDefPtr config = NULL;
size_t i;
for (i = 0; i < def->nchannels; i++) {
@@ -3716,13 +3715,11 @@ qemuFindAgentConfig(virDomainDefPtr def)
if (channel->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO)
continue;
- if (STREQ_NULLABLE(channel->target.name, "org.qemu.guest_agent.0"))
{
- config = &channel->source;
- break;
- }
+ if (STREQ_NULLABLE(channel->target.name, "org.qemu.guest_agent.0"))
+ return channel;
}
- return config;
+ return NULL;
}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 82495dc..7fc4fff 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -487,7 +487,7 @@ int qemuDomainAlignMemorySizes(virDomainDefPtr def);
void qemuDomainMemoryDeviceAlignSize(virDomainDefPtr def,
virDomainMemoryDefPtr mem);
-virDomainChrSourceDefPtr qemuFindAgentConfig(virDomainDefPtr def);
+virDomainChrDefPtr qemuFindAgentConfig(virDomainDefPtr def);
bool qemuDomainMachineIsQ35(const virDomainDef *def);
bool qemuDomainMachineIsI440FX(const virDomainDef *def);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5133804..43092d4 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -203,7 +203,7 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1;
qemuAgentPtr agent = NULL;
- virDomainChrSourceDefPtr config = qemuFindAgentConfig(vm->def);
+ virDomainChrDefPtr config = qemuFindAgentConfig(vm->def);
if (!config)
return 0;
@@ -223,7 +223,7 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
virObjectUnlock(vm);
agent = qemuAgentOpen(vm,
- config,
+ &config->source,
&agentCallbacks);
virObjectLock(vm);
--
2.4.10