]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: detect if dimm aliases are broken on reconnect
authorPeter Krempa <pkrempa@redhat.com>
Mon, 31 Oct 2016 15:49:49 +0000 (16:49 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 10 Nov 2016 16:36:55 +0000 (17:36 +0100)
Detect on reconnect to a running qemu VM whether the alias of a
hotpluggable memory device (dimm) does not match the dimm slot number
where it's connected to. This is necessary as qemu is actually
considering the alias as machine ABI used to connect the backend object
to the dimm device.

This will require us to keep them consistent so that we can reliably
restore them on migration. In some situations it was currently possible
to create a mismatched configuration and qemu would refuse to restore
the migration stream.

To avoid breaking existing VMs we'll need to keep the old algorithm
though.

src/qemu/qemu_domain.h
src/qemu/qemu_process.c

index 2ee1829c8e503ae703bcb009445de3711f192d33..0c1689b57f722152c3c3f33e3e5fbff72433bf75 100644 (file)
@@ -232,6 +232,9 @@ struct _qemuDomainObjPrivate {
     /* private XML) - need to restore at process reconnect */
     uint8_t *masterKey;
     size_t masterKeyLen;
+
+    /* note whether memory device alias does not correspond to slot number */
+    bool memAliasOrderMismatch;
 };
 
 # define QEMU_DOMAIN_PRIVATE(vm)       \
index 1b67aee727482a23d572a39478891dcf43df7757..09b2a72b53994880c4eb6358592229161f082d1f 100644 (file)
@@ -3205,6 +3205,29 @@ qemuDomainPerfRestart(virDomainObjPtr vm)
     return 0;
 }
 
+
+static void
+qemuProcessReconnectCheckMemAliasOrderMismatch(virDomainObjPtr vm)
+{
+    size_t i;
+    int aliasidx;
+    virDomainDefPtr def = vm->def;
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+
+    if (!virDomainDefHasMemoryHotplug(def) || def->nmems == 0)
+        return;
+
+    for (i = 0; i < def->nmems; i++) {
+        aliasidx = qemuDomainDeviceAliasIndex(&def->mems[i]->info, "dimm");
+
+        if (def->mems[i]->info.addr.dimm.slot != aliasidx) {
+            priv->memAliasOrderMismatch = true;
+            break;
+        }
+    }
+}
+
+
 struct qemuProcessReconnectData {
     virConnectPtr conn;
     virQEMUDriverPtr driver;
@@ -3389,6 +3412,8 @@ qemuProcessReconnect(void *opaque)
     if (qemuProcessUpdateDevices(driver, obj) < 0)
         goto error;
 
+    qemuProcessReconnectCheckMemAliasOrderMismatch(obj);
+
     /* Failure to connect to agent shouldn't be fatal */
     if ((ret = qemuConnectAgent(driver, obj)) < 0) {
         if (ret == -2)