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
|
* and end are zero, in which case qemu hasn't started the
|
||||||
* job yet. */
|
* job yet. */
|
||||||
if (!info->cur && !info->end) {
|
if (!info->cur && !info->end) {
|
||||||
if (rawInfo->ready > 0) {
|
if (rawInfo->ready_present) {
|
||||||
info->cur = info->end = 1;
|
|
||||||
} else if (!rawInfo->ready) {
|
|
||||||
info->end = 1;
|
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
|
/* 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
|
* cur == end as some apps wrote code polling this instead of waiting for
|
||||||
* the ready event */
|
* the ready event */
|
||||||
if (rawInfo->ready == 0 &&
|
if (rawInfo->ready_present &&
|
||||||
|
!rawInfo->ready &&
|
||||||
info->cur == info->end &&
|
info->cur == info->end &&
|
||||||
info->cur > 0)
|
info->cur > 0)
|
||||||
info->cur -= 1;
|
info->cur -= 1;
|
||||||
|
@ -1117,7 +1117,8 @@ struct _qemuMonitorBlockJobInfo {
|
|||||||
unsigned long long bandwidth; /* in bytes/s */
|
unsigned long long bandwidth; /* in bytes/s */
|
||||||
virDomainBlockJobCursor cur;
|
virDomainBlockJobCursor cur;
|
||||||
virDomainBlockJobCursor end;
|
virDomainBlockJobCursor end;
|
||||||
int ready; /* -1 if unknown, 0 if not ready, 1 if ready */
|
bool ready_present;
|
||||||
|
bool ready;
|
||||||
};
|
};
|
||||||
|
|
||||||
GHashTable *qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
|
GHashTable *qemuMonitorGetAllBlockJobInfo(qemuMonitorPtr mon,
|
||||||
|
@ -5049,7 +5049,6 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJobs,
|
|||||||
qemuMonitorBlockJobInfoPtr info = NULL;
|
qemuMonitorBlockJobInfoPtr info = NULL;
|
||||||
const char *device;
|
const char *device;
|
||||||
const char *type;
|
const char *type;
|
||||||
bool ready;
|
|
||||||
|
|
||||||
if (!(device = virJSONValueObjectGetString(entry, "device"))) {
|
if (!(device = virJSONValueObjectGetString(entry, "device"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
@ -5067,9 +5066,6 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJobs,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* assume we don't know the state */
|
|
||||||
info->ready = -1;
|
|
||||||
|
|
||||||
if (!(type = virJSONValueObjectGetString(entry, "type"))) {
|
if (!(type = virJSONValueObjectGetString(entry, "type"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("entry was missing 'type'"));
|
_("entry was missing 'type'"));
|
||||||
@ -5104,8 +5100,8 @@ qemuMonitorJSONParseBlockJobInfo(GHashTable *blockJobs,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectGetBoolean(entry, "ready", &ready) == 0)
|
if (virJSONValueObjectGetBoolean(entry, "ready", &info->ready) == 0)
|
||||||
info->ready = ready;
|
info->ready_present = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -8176,8 +8176,8 @@ qemuProcessRefreshLegacyBlockjob(void *payload,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (disk->mirror) {
|
if (disk->mirror) {
|
||||||
if (info->ready == 1 ||
|
if ((!info->ready_present && info->end == info->cur) ||
|
||||||
(info->ready == -1 && info->end == info->cur)) {
|
info->ready) {
|
||||||
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_READY;
|
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_READY;
|
||||||
job->state = VIR_DOMAIN_BLOCK_JOB_READY;
|
job->state = VIR_DOMAIN_BLOCK_JOB_READY;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user