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