]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_blockjob: process QEMU_MONITOR_JOB_STATUS_PENDING signal
authorPavel Hrdina <phrdina@redhat.com>
Wed, 22 Jun 2022 10:13:45 +0000 (12:13 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 9 Jan 2023 12:32:48 +0000 (13:32 +0100)
QEMU emits this signal when the job finished its work and is about to be
finalized. If the job is started with autofinalize disabled the job
waits for user input to finalize the job.

This will be used by snapshot delete code.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_backup.c
src/qemu/qemu_blockjob.c
src/qemu/qemu_blockjob.h

index c7721812a57c4240aa1d6917630fa71f0603cee8..6a5aacd9f6d8888904eb29c62efaefafd1485f26 100644 (file)
@@ -1035,6 +1035,7 @@ qemuBackupNotifyBlockjobEnd(virDomainObj *vm,
             case QEMU_BLOCKJOB_STATE_NEW:
             case QEMU_BLOCKJOB_STATE_RUNNING:
             case QEMU_BLOCKJOB_STATE_ABORTING:
+            case QEMU_BLOCKJOB_STATE_PENDING:
             case QEMU_BLOCKJOB_STATE_PIVOTING:
             case QEMU_BLOCKJOB_STATE_LAST:
             default:
index a7aa7b3940926d3f5dc16649a7b4bdf301573a6b..cb2d05d71de8ce94eb5567a713fcf2d05c1adc71 100644 (file)
@@ -55,6 +55,7 @@ VIR_ENUM_IMPL(qemuBlockjobState,
               "running",
               "concluded",
               "aborting",
+              "pending",
               "pivoting");
 
 VIR_ENUM_IMPL(qemuBlockjob,
@@ -531,6 +532,8 @@ qemuBlockJobRefreshJobs(virDomainObj *vm)
                 if (job->state == QEMU_BLOCKJOB_STATE_NEW ||
                     job->state == QEMU_BLOCKJOB_STATE_RUNNING)
                     job->newstate = newstate;
+            } else if (newstate == QEMU_BLOCKJOB_STATE_PENDING) {
+                job->newstate = newstate;
             }
             /* don't update the job otherwise */
         }
@@ -1563,6 +1566,19 @@ qemuBlockJobEventProcess(virQEMUDriver *driver,
         job->newstate = -1;
         break;
 
+    case QEMU_BLOCKJOB_STATE_PENDING:
+        /* Similarly as for 'ready' state we should handle it only when
+         * previous state was 'new' or 'running' as there are other cases
+         * when it can be emitted by QEMU. Currently we need this only when
+         * deleting non-active external snapshots. */
+        if (job->state == QEMU_BLOCKJOB_STATE_NEW ||
+            job->state == QEMU_BLOCKJOB_STATE_RUNNING) {
+            job->state = job->newstate;
+            qemuDomainSaveStatus(vm);
+        }
+        job->newstate = -1;
+        break;
+
     case QEMU_BLOCKJOB_STATE_NEW:
     case QEMU_BLOCKJOB_STATE_RUNNING:
     case QEMU_BLOCKJOB_STATE_LAST:
@@ -1684,13 +1700,16 @@ qemuBlockjobConvertMonitorStatus(int monitorstatus)
         ret = QEMU_BLOCKJOB_STATE_CONCLUDED;
         break;
 
+    case QEMU_MONITOR_JOB_STATUS_PENDING:
+        ret = QEMU_BLOCKJOB_STATE_PENDING;
+        break;
+
     case QEMU_MONITOR_JOB_STATUS_UNKNOWN:
     case QEMU_MONITOR_JOB_STATUS_CREATED:
     case QEMU_MONITOR_JOB_STATUS_RUNNING:
     case QEMU_MONITOR_JOB_STATUS_PAUSED:
     case QEMU_MONITOR_JOB_STATUS_STANDBY:
     case QEMU_MONITOR_JOB_STATUS_WAITING:
-    case QEMU_MONITOR_JOB_STATUS_PENDING:
     case QEMU_MONITOR_JOB_STATUS_ABORTING:
     case QEMU_MONITOR_JOB_STATUS_UNDEFINED:
     case QEMU_MONITOR_JOB_STATUS_NULL:
index 741d8df6c5d948a89fa5180e976b09293c2947c2..e9b283da2036408c8b7c305d46438c581722c527 100644 (file)
@@ -41,6 +41,7 @@ typedef enum {
     QEMU_BLOCKJOB_STATE_CONCLUDED, /* job has finished, but it's unknown
                                       whether it has failed or not */
     QEMU_BLOCKJOB_STATE_ABORTING,
+    QEMU_BLOCKJOB_STATE_PENDING,
     QEMU_BLOCKJOB_STATE_PIVOTING,
     QEMU_BLOCKJOB_STATE_LAST
 } qemuBlockjobState;