提交 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, ...@@ -5550,7 +5550,7 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr driver,
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return -1; return -1;
blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon); blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon, false);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockinfo) if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockinfo)
return -1; return -1;
......
...@@ -3442,10 +3442,11 @@ qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon, ...@@ -3442,10 +3442,11 @@ qemuMonitorBlockJobSetSpeed(qemuMonitorPtr mon,
virHashTablePtr virHashTablePtr
qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon) qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
bool rawjobname)
{ {
QEMU_CHECK_MONITOR_NULL(mon); QEMU_CHECK_MONITOR_NULL(mon);
return qemuMonitorJSONGetAllBlockJobInfo(mon); return qemuMonitorJSONGetAllBlockJobInfo(mon, rawjobname);
} }
...@@ -3465,7 +3466,7 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon, ...@@ -3465,7 +3466,7 @@ qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
VIR_DEBUG("alias=%s, info=%p", alias, info); VIR_DEBUG("alias=%s, info=%p", alias, info);
if (!(all = qemuMonitorGetAllBlockJobInfo(mon))) if (!(all = qemuMonitorGetAllBlockJobInfo(mon, false)))
return -1; return -1;
if ((data = virHashLookup(all, alias))) { if ((data = virHashLookup(all, alias))) {
......
...@@ -975,7 +975,8 @@ struct _qemuMonitorBlockJobInfo { ...@@ -975,7 +975,8 @@ struct _qemuMonitorBlockJobInfo {
int ready; /* -1 if unknown, 0 if not ready, 1 if ready */ 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, int qemuMonitorGetBlockJobInfo(qemuMonitorPtr mon,
const char *device, const char *device,
qemuMonitorBlockJobInfoPtr info) qemuMonitorBlockJobInfoPtr info)
......
...@@ -4662,7 +4662,8 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon, ...@@ -4662,7 +4662,8 @@ int qemuMonitorJSONScreendump(qemuMonitorPtr mon,
static int static int
qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs, qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
virJSONValuePtr entry) virJSONValuePtr entry,
bool rawjobname)
{ {
qemuMonitorBlockJobInfoPtr info = NULL; qemuMonitorBlockJobInfoPtr info = NULL;
const char *device; const char *device;
...@@ -4674,6 +4675,8 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs, ...@@ -4674,6 +4675,8 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
_("entry was missing 'device'")); _("entry was missing 'device'"));
return -1; return -1;
} }
if (!rawjobname)
device = qemuAliasDiskDriveSkipPrefix(device); device = qemuAliasDiskDriveSkipPrefix(device);
if (VIR_ALLOC(info) < 0 || if (VIR_ALLOC(info) < 0 ||
...@@ -4724,7 +4727,8 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs, ...@@ -4724,7 +4727,8 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
} }
virHashTablePtr virHashTablePtr
qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon) qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon,
bool rawjobname)
{ {
virJSONValuePtr cmd = NULL; virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
...@@ -4756,7 +4760,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon) ...@@ -4756,7 +4760,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
_("missing array element")); _("missing array element"));
goto error; goto error;
} }
if (qemuMonitorJSONParseBlockJobInfo(blockJobs, entry) < 0) if (qemuMonitorJSONParseBlockJobInfo(blockJobs, entry, rawjobname) < 0)
goto error; goto error;
} }
......
...@@ -317,7 +317,8 @@ int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon, ...@@ -317,7 +317,8 @@ int qemuMonitorJSONBlockJobSetSpeed(qemuMonitorPtr mon,
unsigned long long speed) unsigned long long speed)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon) virHashTablePtr qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon,
bool rawjobname)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int qemuMonitorJSONSetLink(qemuMonitorPtr mon, int qemuMonitorJSONSetLink(qemuMonitorPtr mon,
......
...@@ -8011,7 +8011,7 @@ qemuProcessRefreshLegacyBlockjobs(virQEMUDriverPtr driver, ...@@ -8011,7 +8011,7 @@ qemuProcessRefreshLegacyBlockjobs(virQEMUDriverPtr driver,
int ret = -1; int ret = -1;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
blockJobs = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm)); blockJobs = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm), true);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockJobs) if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockJobs)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册