]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: Refresh data from qemu monitor after migration
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Sep 2017 14:16:08 +0000 (16:16 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 27 Sep 2017 07:09:14 +0000 (09:09 +0200)
Some values we read from the qemu monitor may be changed with the actual
state by the incoming migration. This means that we should refresh
certain things only after the migration has finished.

This is mostly visible in the cdrom tray state, which is by default
closed but may be opened by the guest OS. This would be refreshed before
qemu transferred the actual state and thus libvirt would think that the
tray is closed.

Note that this patch moves only a few obvious query commands. Others may
be moved later after individual assessment.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1463168

src/qemu/qemu_process.c

index c104985aa6868b283eb89707292566518c7ff46a..929a0d2e96eeabd7f6abe0097419690dc495aa43 100644 (file)
@@ -5787,14 +5787,6 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuProcessSetLinkStates(driver, vm, asyncJob) < 0)
         goto cleanup;
 
-    VIR_DEBUG("Fetching list of active devices");
-    if (qemuDomainUpdateDeviceList(driver, vm, asyncJob) < 0)
-        goto cleanup;
-
-    VIR_DEBUG("Updating info of memory devices");
-    if (qemuDomainUpdateMemoryDeviceInfo(driver, vm, asyncJob) < 0)
-        goto cleanup;
-
     VIR_DEBUG("Setting initial memory amount");
     if (qemuProcessSetupBalloon(driver, vm, asyncJob) < 0)
         goto cleanup;
@@ -5806,14 +5798,6 @@ qemuProcessLaunch(virConnectPtr conn,
         qemuProcessRefreshBalloonState(driver, vm, asyncJob) < 0)
         goto cleanup;
 
-    VIR_DEBUG("Detecting actual memory size for video device");
-    if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0)
-        goto cleanup;
-
-    VIR_DEBUG("Updating disk data");
-    if (qemuProcessRefreshDisks(driver, vm, asyncJob) < 0)
-        goto cleanup;
-
     if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY &&
         qemuProcessAutoDestroyAdd(driver, vm, conn) < 0)
         goto cleanup;
@@ -5831,6 +5815,41 @@ qemuProcessLaunch(virConnectPtr conn,
 }
 
 
+/**
+ * qemuProcessRefreshState:
+ * @driver: qemu driver data
+ * @vm: domain to refresh
+ * @asyncJob: async job type
+ *
+ * This function gathers calls to refresh qemu state after startup. This
+ * function is called after a deferred migration finishes so that we can update
+ * state influenced by the migration stream.
+ */
+static int
+qemuProcessRefreshState(virQEMUDriverPtr driver,
+                        virDomainObjPtr vm,
+                        qemuDomainAsyncJob asyncJob)
+{
+    VIR_DEBUG("Fetching list of active devices");
+    if (qemuDomainUpdateDeviceList(driver, vm, asyncJob) < 0)
+        return -1;
+
+    VIR_DEBUG("Updating info of memory devices");
+    if (qemuDomainUpdateMemoryDeviceInfo(driver, vm, asyncJob) < 0)
+        return -1;
+
+    VIR_DEBUG("Detecting actual memory size for video device");
+    if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0)
+        return -1;
+
+    VIR_DEBUG("Updating disk data");
+    if (qemuProcessRefreshDisks(driver, vm, asyncJob) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 /**
  * qemuProcessFinishStartup:
  *
@@ -5847,6 +5866,9 @@ qemuProcessFinishStartup(virConnectPtr conn,
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     int ret = -1;
 
+    if (qemuProcessRefreshState(driver, vm, asyncJob) < 0)
+        goto cleanup;
+
     if (startCPUs) {
         VIR_DEBUG("Starting domain CPUs");
         if (qemuProcessStartCPUs(driver, vm, conn,