提交 56c6893f 编写于 作者: P Peter Krempa

qemu: Use proper block job name when reconnecting to VM

The hash table returned by qemuMonitorGetAllBlockJobInfo is organized by
the frontend name (which skipps the 'drive-' prefix). While our code
properly matches the jobs to the disk, qemu needs the full job name
including the 'drive-' prefix to be able to identify jobs.

Fix this by adding an argument to qemuMonitorGetAllBlockJobInfo which
does not modify the job name before filling the hash.

This fixes a regression where users would not be able to cancel/pivot
block jobs after restarting libvirtd while a blockjob is running.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 4c4953fb
......@@ -5550,7 +5550,7 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1;
blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon);
blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon, false);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockinfo)
return -1;
......
......@@ -3442,10 +3442,11 @@ qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
virHashTablePtr
qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon)
qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
bool rawjobname)
{
QEMU_CHECK_MONITOR_NULL(mon);
return qemuMonitorJSONGetAllBlockJobInfo(mon);
return qemuMonitorJSONGetAllBlockJobInfo(mon, rawjobname);
}
......@@ -3465,7 +3466,7 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
VIR_DEBUG("alias=%s, info=%p", alias, info);
if (!(all = qemuMonitorGetAllBlockJobInfo(mon)))
if (!(all = qemuMonitorGetAllBlockJobInfo(mon, false)))
return -1;
if ((data = virHashLookup(all, alias))) {
......
......@@ -975,7 +975,8 @@ struct _qemuMonitorBlockJobInfo {
int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
};
virHashTablePtr qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon);
virHashTablePtr qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
bool rawjobname);
int qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
const char *device,
qemuMonitorBlockJobInfoPtr info)
......
......@@ -4662,7 +4662,8 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
static int
qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
virJSONValuePtr entry)
virJSONValuePtr entry,
bool rawjobname)
{
qemuMonitorBlockJobInfoPtr info = NULL;
const char *device;
......@@ -4674,6 +4675,8 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
_("entry was missing 'device'"));
return -1;
}
if (!rawjobname)
device = qemuAliasDiskDriveSkipPrefix(device);
if (VIR_ALLOC(info) < 0 ||
......@@ -4724,7 +4727,8 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
}
virHashTablePtr
qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon,
bool rawjobname)
{
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
......@@ -4756,7 +4760,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
_("missing array element"));
goto error;
}
if (qemuMonitorJSONParseBlockJobInfo(blockJobs, entry) < 0)
if (qemuMonitorJSONParseBlockJobInfo(blockJobs, entry, rawjobname) < 0)
goto error;
}
......
......@@ -317,7 +317,8 @@ int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
unsigned long long speed)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon,
bool rawjobname)
ATTRIBUTE_NONNULL(1);
int qemuMonitorJSONSetLink(qemuMonitorPtr mon,
......
......@@ -8011,7 +8011,7 @@ qemuProcessRefreshLegacyBlockjobs(virQEMUDriverPtr driver,
int ret = -1;
qemuDomainObjEnterMonitor(driver, vm);
blockJobs = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm));
blockJobs = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm), true);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockJobs)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册