qemuMigrationSrcToFile: Don't cross-contaminate 'flags' variable

The meaning of 'flags' is context dependant. 'qemuMigrationSrcToFile'
expects 'virDomainSaveRestoreFlags' rather than migration flags which is
not expected based on the location of the function.

Why this is wrong is clearly visible in 'doCoreDump' which passes in
'dump_flags' which are actually 'virDomainCoreDumpFlags' and the values
are different:

 VIR_DUMP_BYPASS_CACHE = (1 << 2)

 VIR_DOMAIN_SAVE_BYPASS_CACHE = 1 << 0

Since it checks only for VIR_DOMAIN_SAVE_BYPASS_CACHE pass it in as a
boolean instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa committed 2025-12-10 11:07:34 +01:00
1 parent 4469a61553
commit 61ae36fa0b
4 files changed
+11 -7

No files matched your search

+3 -1
View File
@@ -3137,7 +3137,9 @@ doCoreDump(virQEMUDriver *driver,
goto cleanup;
if (qemuMigrationSrcToFile(driver, vm, path, &fd, compressor,
dump_params, dump_flags, VIR_ASYNC_JOB_DUMP) < 0)
dump_params,
(dump_flags & VIR_DUMP_BYPASS_CACHE),
VIR_ASYNC_JOB_DUMP) < 0)
goto cleanup;
}
+4 -4
View File
@@ -7210,7 +7210,7 @@ qemuMigrationSrcToSparseFile(virQEMUDriver *driver,
virDomainObj *vm,
const char *path,
int *fd,
unsigned int flags,
bool bypassCache,
virDomainAsyncJob asyncJob)
{
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
@@ -7222,7 +7222,7 @@ qemuMigrationSrcToSparseFile(virQEMUDriver *driver,
/* When using directio with mapped-ram, qemu needs two fds. One with
* O_DIRECT set writing the memory, and another without it set for
* writing small bits of unaligned state. */
if ((flags & VIR_DOMAIN_SAVE_BYPASS_CACHE)) {
if (bypassCache) {
directFlag = virFileDirectFdFlag();
if (directFlag < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -7259,7 +7259,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
int *fd,
virCommand *compressor,
qemuMigrationParams *migParams,
unsigned int flags,
bool bypassCache,
virDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
@@ -7293,7 +7293,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm,
if (migParams &&
qemuMigrationParamsCapEnabled(migParams, QEMU_MIGRATION_CAP_MAPPED_RAM))
rc = qemuMigrationSrcToSparseFile(driver, vm, path, fd, flags, asyncJob);
rc = qemuMigrationSrcToSparseFile(driver, vm, path, fd, bypassCache, asyncJob);
else
rc = qemuMigrationSrcToLegacyFile(driver, vm, *fd, compressor, asyncJob);
+1 -1
View File
@@ -244,7 +244,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver,
int *fd,
virCommand *compressor,
qemuMigrationParams *migParams,
unsigned int flags,
bool bypassCache,
virDomainAsyncJob asyncJob)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
+3 -1
View File
@@ -501,7 +501,9 @@ qemuSaveImageCreate(virQEMUDriver *driver,
goto cleanup;
/* Perform the migration */
if (qemuMigrationSrcToFile(driver, vm, path, &fd, compressor, saveParams, flags, asyncJob) < 0)
if (qemuMigrationSrcToFile(driver, vm, path, &fd, compressor, saveParams,
(flags & VIR_DOMAIN_SAVE_BYPASS_CACHE),
asyncJob) < 0)
goto cleanup;
/* Touch up file header to mark image complete. */