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: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-06-11 16:42:53 +02:00
parent 4c4953fb37
commit 56c6893ff5
6 changed files with 18 additions and 11 deletions

View File

@ -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;

View File

@ -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,
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))) {

View File

@ -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)

View File

@ -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,7 +4675,9 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blockJobs,
_("entry was missing 'device'")); _("entry was missing 'device'"));
return -1; return -1;
} }
device = qemuAliasDiskDriveSkipPrefix(device);
if (!rawjobname)
device = qemuAliasDiskDriveSkipPrefix(device);
if (VIR_ALLOC(info) < 0 || if (VIR_ALLOC(info) < 0 ||
virHashAddEntry(blockJobs, device, info) < 0) { virHashAddEntry(blockJobs, device, info) < 0) {
@ -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)
_("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;
} }

View File

@ -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,

View File

@ -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;