1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

backup: Store 'apiFlags' in private section of virDomainBackupDef

'qemuBackupJobTerminate' needs the API flags to see whether
VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL. Unfortunately when called via
qemuProcessReconnect()->qemuProcessStop() early (e.g. if the qemu
process died while we were reconnecting) the job is cleared temporarily
so that other APIs can be called. This would mean that we couldn't clean
up the files in some cases.

Save the 'apiFlags' inside the backup object and set it from the
'qemuDomainJobObj' 'apiFlags' member when reconnecting to a VM.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-03-11 16:14:17 +01:00
parent 7b8f78a3af
commit aa372e5a01
3 changed files with 11 additions and 4 deletions

View File

@ -99,6 +99,8 @@ struct _virDomainBackupDef {
unsigned long long pull_tmp_total;
char *errmsg; /* error message of failed sub-blockjob */
unsigned int apiFlags; /* original flags used when starting the job */
};
typedef enum {

View File

@ -560,7 +560,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData;
size_t i;
if (!(priv->job.apiFlags & VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL) &&
if (!(priv->backup->apiFlags & VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL) &&
(priv->backup->type == VIR_DOMAIN_BACKUP_TYPE_PULL ||
(priv->backup->type == VIR_DOMAIN_BACKUP_TYPE_PUSH &&
jobstatus != QEMU_DOMAIN_JOB_STATUS_COMPLETED))) {
@ -766,6 +766,8 @@ qemuBackupBegin(virDomainObjPtr vm,
if (def->type == VIR_DOMAIN_BACKUP_TYPE_PULL)
pull = true;
def->apiFlags = flags;
/* we'll treat this kind of backup job as an asyncjob as it uses some of the
* infrastructure for async jobs. We'll allow standard modify-type jobs
* as the interlocking of conflicting operations is handled on the block

View File

@ -96,6 +96,7 @@
#include "virthreadjob.h"
#include "virutil.h"
#include "storage_source.h"
#include "backup_conf.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@ -8315,12 +8316,14 @@ qemuProcessReconnect(void *opaque)
g_clear_object(&data->identity);
VIR_FREE(data);
cfg = virQEMUDriverGetConfig(driver);
priv = obj->privateData;
qemuDomainObjRestoreJob(obj, &oldjob);
if (oldjob.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
cfg = virQEMUDriverGetConfig(driver);
priv = obj->privateData;
if (oldjob.asyncJob == QEMU_ASYNC_JOB_BACKUP && priv->backup)
priv->backup->apiFlags = oldjob.apiFlags;
/* expect that libvirt might have crashed during VM start, so prevent
* cleanup of transient disks */