mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuMonitorBlockJobInfo: Store 'ready' and 'ready_present' separately
Don't make the logic confusing by representing the 3 options using an integer with negative values. Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
29976c0de9
commit
0f7b80691b
@ -14650,17 +14650,18 @@ qemuBlockJobInfoTranslate(qemuMonitorBlockJobInfoPtr rawInfo,
|
||||
* and end are zero, in which case qemu hasn't started the
|
||||
* job yet. */
|
||||
if (!info->cur && !info->end) {
|
||||
if (rawInfo->ready > 0) {
|
||||
info->cur = info->end = 1;
|
||||
} else if (!rawInfo->ready) {
|
||||
if (rawInfo->ready_present) {
|
||||
info->end = 1;
|
||||
if (rawInfo->ready)
|
||||
info->cur = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* If qemu reports that it's not ready yet don't make the job go to
|
||||
* cur == end as some apps wrote code polling this instead of waiting for
|
||||
* the ready event */
|
||||
if (rawInfo->ready == 0 &&
|
||||
if (rawInfo->ready_present &&
|
||||
!rawInfo->ready &&
|
||||
info->cur == info->end &&
|
||||
info->cur > 0)
|
||||
info->cur -= 1;
|
||||
|
@ -1117,7 +1117,8 @@ struct _qemuMonitorBlockJobInfo {
|
||||
unsigned long long bandwidth; /* in bytes/s */
|
||||
virDomainBlockJobCursor cur;
|
||||
virDomainBlockJobCursor end;
|
||||
int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
|
||||
bool ready_present;
|
||||
bool ready;
|
||||
};
|
||||
|
||||
GHashTable *qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
|
||||
|
@ -5049,7 +5049,6 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJobs,
|
||||
qemuMonitorBlockJobInfoPtr info = NULL;
|
||||
const char *device;
|
||||
const char *type;
|
||||
bool ready;
|
||||
|
||||
if (!(device = virJSONValueObjectGetString(entry, "device"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
@ -5067,9 +5066,6 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJobs,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* assume we don't know the state */
|
||||
info->ready = -1;
|
||||
|
||||
if (!(type = virJSONValueObjectGetString(entry, "type"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("entry was missing 'type'"));
|
||||
@ -5104,8 +5100,8 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJobs,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectGetBoolean(entry, "ready", &ready) == 0)
|
||||
info->ready = ready;
|
||||
if (virJSONValueObjectGetBoolean(entry, "ready", &info->ready) == 0)
|
||||
info->ready_present = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -8176,8 +8176,8 @@ qemuProcessRefreshLegacyBlockjob(void *payload,
|
||||
return -1;
|
||||
|
||||
if (disk->mirror) {
|
||||
if (info->ready == 1 ||
|
||||
(info->ready == -1 && info->end == info->cur)) {
|
||||
if ((!info->ready_present && info->end == info->cur) ||
|
||||
info->ready) {
|
||||
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_READY;
|
||||
job->state = VIR_DOMAIN_BLOCK_JOB_READY;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user