diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 64c8f6cc09f8be874bf602748d0a5d4c6549c222..c5677cdb058b8d1438310dc8a8c86b57a9723d09 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -65,6 +65,7 @@ virDomainBackupDefFree(virDomainBackupDefPtr def) return; g_free(def->incremental); + g_free(def->errmsg); virStorageNetHostDefFree(1, def->server); for (i = 0; i < def->ndisks; i++) { diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h index 672fd52ee7541f15f574d7363343dcba79b8aa28..b5685317c56c2c9f1d04bd1d51eeb7971ec27654 100644 --- a/src/conf/backup_conf.h +++ b/src/conf/backup_conf.h @@ -79,6 +79,8 @@ struct _virDomainBackupDef { unsigned long long push_total; unsigned long long pull_tmp_used; unsigned long long pull_tmp_total; + + char *errmsg; /* error message of failed sub-blockjob */ }; typedef enum { diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 03d34c9378b2dcac347bc71f21ff67d9561d1907..80fc5d77f800dc5cad2c6ea0a158192980c534be 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -650,6 +650,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm, priv->job.completed->stats.backup.tmp_total = priv->backup->pull_tmp_total; priv->job.completed->status = jobstatus; + priv->job.completed->errmsg = g_strdup(priv->backup->errmsg); qemuDomainEventEmitJobCompleted(priv->driver, vm); @@ -951,6 +952,7 @@ void qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, virDomainDiskDefPtr disk, qemuBlockjobState state, + const char *errmsg, unsigned long long cur, unsigned long long end, int asyncJob) @@ -964,8 +966,8 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, virDomainBackupDefPtr backup = priv->backup; size_t i; - VIR_DEBUG("vm: '%s', disk:'%s', state:'%d'", - vm->def->name, disk->dst, state); + VIR_DEBUG("vm: '%s', disk:'%s', state:'%d' errmsg:'%s'", + vm->def->name, disk->dst, state, NULLSTR(errmsg)); if (!backup) return; @@ -985,6 +987,10 @@ qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, backup->push_total += end; } + /* record first error message */ + if (!backup->errmsg) + backup->errmsg = g_strdup(errmsg); + for (i = 0; i < backup->ndisks; i++) { virDomainBackupDiskDefPtr backupdisk = backup->disks + i; diff --git a/src/qemu/qemu_backup.h b/src/qemu/qemu_backup.h index 3321ba0b6f25c291058dbb84e2fc617c980ccc23..b19c3bf1c9f6a8865a7f3d0f72a389103830b5dc 100644 --- a/src/qemu/qemu_backup.h +++ b/src/qemu/qemu_backup.h @@ -38,6 +38,7 @@ void qemuBackupNotifyBlockjobEnd(virDomainObjPtr vm, virDomainDiskDefPtr disk, qemuBlockjobState state, + const char *errmsg, unsigned long long cur, unsigned long long end, int asyncJob); diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 2032c0c1c5d78b9c1fa162556d7d5539d6a9855e..b9eecd3f982b7f3079c6741500d8acf45cf3bbf9 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1435,7 +1435,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriverPtr driver, g_autoptr(qemuBlockStorageSourceAttachData) backend = NULL; g_autoptr(virJSONValue) actions = NULL; - qemuBackupNotifyBlockjobEnd(vm, job->disk, newstate, + qemuBackupNotifyBlockjobEnd(vm, job->disk, newstate, job->errmsg, progressCurrent, progressTotal, asyncJob); if (job->data.backup.store && diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0378a833b911593a874d0e44aba0ee1d2c6b03ff..d63ec2313b6f8afb70fa6c25675b4cfa23a9a132 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -836,6 +836,10 @@ qemuDomainBackupJobInfoToParams(qemuDomainJobInfoPtr jobInfo, VIR_DOMAIN_JOB_SUCCESS) < 0) return -1; + if (jobInfo->errmsg && + virTypedParamListAddString(par, jobInfo->errmsg, VIR_DOMAIN_JOB_ERRMSG) < 0) + return -1; + *nparams = virTypedParamListStealParams(par, params); *type = qemuDomainJobStatusToType(jobInfo->status); return 0;