]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: fix crash when migrateuri has no scheme
authorLuyao Huang <lhuang@redhat.com>
Wed, 11 Feb 2015 08:30:32 +0000 (16:30 +0800)
committerJán Tomko <jtomko@redhat.com>
Wed, 11 Feb 2015 12:20:30 +0000 (13:20 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1191355

When we attempt to migrate a vm with a migrateuri that has no scheme:

 # virsh migrate test4 --live qemu+ssh://lhuang/system --migrateuri 127.0.0.1

target libvirtd will crash because uri->scheme is NULL in
qemuMigrationPrepareDirect on this line:

     if (STRNEQ(uri->scheme, "tcp") &&

Add a value check before this line. Also fix a bug like this in
doNativeMigrate, that could only happen when destination libvirtd
returned an incorrect URI.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_migration.c

index 879b1bf40f456306bb67791e6139dba697884a28..4506d87042667f9d27a447b0e6c9507663fad0da 100644 (file)
@@ -3281,6 +3281,13 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
         if (!(uri = qemuMigrationParseURI(uri_in, &well_formed_uri)))
             goto cleanup;
 
+        if (uri->scheme == NULL) {
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("missing scheme in migration URI: %s"),
+                           uri_in);
+            goto cleanup;
+        }
+
         if (STRNEQ(uri->scheme, "tcp") &&
             STRNEQ(uri->scheme, "rdma")) {
             virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
@@ -4083,6 +4090,13 @@ static int doNativeMigrate(virQEMUDriverPtr driver,
     if (!(uribits = qemuMigrationParseURI(uri, NULL)))
         return -1;
 
+    if (uribits->scheme == NULL) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("missing scheme in migration URI: %s"),
+                       uri);
+        goto cleanup;
+    }
+
     if (STREQ(uribits->scheme, "rdma")) {
         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_RDMA)) {
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",