Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > ebe084c140192657f9094e135a84202c > files > 111

libvirt-0.8.2-29.el5.src.rpm

From 77438bde5d368549d7493f865b83f932ed60eed3 Mon Sep 17 00:00:00 2001
Message-Id: <77438bde5d368549d7493f865b83f932ed60eed3.1287067706.git.jdenemar@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Wed, 13 Oct 2010 15:51:50 +0200
Subject: [PATCH] qemu: Prohibit migration of guests with host devices

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=573940

Explicitly raising a nice error in the case user tries to migrate a
guest with assigned host devices is much better than waiting for a
mysterious error with no clue for the reason.
(cherry picked from commit f93924f465c1cf9535ba2df88f6d353b7b5169d0)
---
 src/qemu/qemu_driver.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c8a2141..b5233f5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9914,6 +9914,19 @@ static void qemuDomainEventQueue(struct qemud_driver *driver,
 
 /* Migration support. */
 
+static bool ATTRIBUTE_NONNULL(1)
+qemuDomainIsMigratable(virDomainDefPtr def)
+{
+    if (def->nhostdevs > 0) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID,
+                _("Domain with assigned host devices cannot be migrated"));
+        return false;
+    }
+
+    return true;
+}
+
+
 /* Tunnelled migration stream support */
 struct qemuStreamMigFile {
     int fd;
@@ -10243,6 +10256,9 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn,
         goto cleanup;
     }
 
+    if (!qemuDomainIsMigratable(def))
+        goto cleanup;
+
     /* Target domain name, maybe renamed. */
     if (dname) {
         VIR_FREE(def->name);
@@ -10510,6 +10526,9 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
         goto cleanup;
     }
 
+    if (!qemuDomainIsMigratable(def))
+        goto cleanup;
+
     /* Target domain name, maybe renamed. */
     if (dname) {
         VIR_FREE(def->name);
-- 
1.7.3.1