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