libvirt/SOURCES/libvirt-qemu-Don-t-store-disk-alias-in-qemuAgentDiskInfo.patch

193 lines
7.2 KiB
Diff
Raw Normal View History

From b4840a983e10b8cca99fa50ed3cf99af370a19c9 Mon Sep 17 00:00:00 2001
Message-Id: <b4840a983e10b8cca99fa50ed3cf99af370a19c9@dist-git>
From: Jonathon Jongsma <jjongsma@redhat.com>
Date: Thu, 20 Feb 2020 10:52:25 -0600
Subject: [PATCH] qemu: Don't store disk alias in qemuAgentDiskInfo
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The qemuAgentDiskInfo structure is filled with information received from
the agent command response, except for the 'alias' field, which is
retrieved from the vm definition. Limit this structure only to data that
was received from the agent message.
This is another intermediate step in moving the responsibility for
searching the vmdef from qemu_agent.c to qemu_driver.c so that we can
avoid holding an agent job and a normal job at the same time.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 306b4cb070b8f57a22a261d1f097283f4ef84e65)
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1759566
Message-Id: <20200220165227.11491-4-jjongsma@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_agent.c | 64 ++++++++++++++++++++++++-------------------
1 file changed, 36 insertions(+), 28 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 077b5538de..4739faeed8 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1847,7 +1847,6 @@ qemuAgentSetTime(qemuAgentPtr mon,
typedef struct _qemuAgentDiskInfo qemuAgentDiskInfo;
typedef qemuAgentDiskInfo *qemuAgentDiskInfoPtr;
struct _qemuAgentDiskInfo {
- char *alias;
char *serial;
virPCIDeviceAddress pci_controller;
char *bus_type;
@@ -1876,7 +1875,6 @@ qemuAgentDiskInfoFree(qemuAgentDiskInfoPtr info)
return;
VIR_FREE(info->serial);
- VIR_FREE(info->alias);
VIR_FREE(info->bus_type);
VIR_FREE(info->devnode);
VIR_FREE(info);
@@ -1902,7 +1900,8 @@ qemuAgentFSInfoFree(qemuAgentFSInfoPtr info)
}
static virDomainFSInfoPtr
-qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent)
+qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
+ virDomainDefPtr vmdef)
{
virDomainFSInfoPtr ret = NULL;
size_t i;
@@ -1920,8 +1919,19 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent)
ret->ndevAlias = agent->ndisks;
- for (i = 0; i < ret->ndevAlias; i++)
- ret->devAlias[i] = g_strdup(agent->disks[i]->alias);
+ for (i = 0; i < ret->ndevAlias; i++) {
+ qemuAgentDiskInfoPtr agentdisk = agent->disks[i];
+ virDomainDiskDefPtr diskDef;
+
+ if (!(diskDef = virDomainDiskByAddress(vmdef,
+ &agentdisk->pci_controller,
+ agentdisk->bus,
+ agentdisk->target,
+ agentdisk->unit)))
+ continue;
+
+ ret->devAlias[i] = g_strdup(diskDef->dst);
+ }
return ret;
@@ -1932,8 +1942,7 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent)
static int
qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
- qemuAgentFSInfoPtr fsinfo,
- virDomainDefPtr vmdef)
+ qemuAgentFSInfoPtr fsinfo)
{
size_t ndisks;
size_t i;
@@ -1956,7 +1965,6 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
virJSONValuePtr jsondisk = virJSONValueArrayGet(jsondisks, i);
virJSONValuePtr pci;
qemuAgentDiskInfoPtr disk;
- virDomainDiskDefPtr diskDef;
const char *val;
if (!jsondisk) {
@@ -2007,14 +2015,6 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
GET_DISK_ADDR(pci, &disk->pci_controller.function, "function");
#undef GET_DISK_ADDR
- if (!(diskDef = virDomainDiskByAddress(vmdef,
- &disk->pci_controller,
- disk->bus,
- disk->target,
- disk->unit)))
- continue;
-
- disk->alias = g_strdup(diskDef->dst);
}
return 0;
@@ -2026,8 +2026,7 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
*/
static int
qemuAgentGetFSInfoInternal(qemuAgentPtr mon,
- qemuAgentFSInfoPtr **info,
- virDomainDefPtr vmdef)
+ qemuAgentFSInfoPtr **info)
{
size_t i;
int ret = -1;
@@ -2143,7 +2142,7 @@ qemuAgentGetFSInfoInternal(qemuAgentPtr mon,
goto cleanup;
}
- if (qemuAgentGetFSInfoFillDisks(disk, info_ret[i], vmdef) < 0)
+ if (qemuAgentGetFSInfoFillDisks(disk, info_ret[i]) < 0)
goto cleanup;
}
@@ -2173,14 +2172,14 @@ qemuAgentGetFSInfo(qemuAgentPtr mon,
size_t i;
int nfs;
- nfs = qemuAgentGetFSInfoInternal(mon, &agentinfo, vmdef);
+ nfs = qemuAgentGetFSInfoInternal(mon, &agentinfo);
if (nfs < 0)
return ret;
if (VIR_ALLOC_N(info_ret, nfs) < 0)
goto cleanup;
for (i = 0; i < nfs; i++) {
- if (!(info_ret[i] = qemuAgentFSInfoToPublic(agentinfo[i])))
+ if (!(info_ret[i] = qemuAgentFSInfoToPublic(agentinfo[i], vmdef)))
goto cleanup;
}
@@ -2215,7 +2214,7 @@ qemuAgentGetFSInfoParams(qemuAgentPtr mon,
size_t i, j;
int nfs;
- if ((nfs = qemuAgentGetFSInfoInternal(mon, &fsinfo, vmdef)) < 0)
+ if ((nfs = qemuAgentGetFSInfoInternal(mon, &fsinfo)) < 0)
return nfs;
if (virTypedParamsAddUInt(params, nparams, maxparams,
@@ -2262,13 +2261,22 @@ qemuAgentGetFSInfoParams(qemuAgentPtr mon,
param_name, fsinfo[i]->ndisks) < 0)
goto cleanup;
for (j = 0; j < fsinfo[i]->ndisks; j++) {
+ virDomainDiskDefPtr diskdef = NULL;
qemuAgentDiskInfoPtr d = fsinfo[i]->disks[j];
- g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.%zu.alias", i, j);
- if (d->alias &&
- virTypedParamsAddString(params, nparams, maxparams,
- param_name, d->alias) < 0)
- goto cleanup;
+ /* match the disk to the target in the vm definition */
+ diskdef = virDomainDiskByAddress(vmdef,
+ &d->pci_controller,
+ d->bus,
+ d->target,
+ d->unit);
+ if (diskdef) {
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.%zu.alias", i, j);
+ if (diskdef->dst &&
+ virTypedParamsAddString(params, nparams, maxparams,
+ param_name, diskdef->dst) < 0)
+ goto cleanup;
+ }
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
"fs.%zu.disk.%zu.serial", i, j);
--
2.25.0