[libvirt] [PATCH] qemu: Prohibit migration of guests with host devices

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. --- 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 f68995f..16f34f7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10380,6 +10380,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; @@ -10709,6 +10722,9 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn, goto cleanup; } + if (!qemuDomainIsMigratable(def)) + goto cleanup; + /* Target domain name, maybe renamed. */ if (dname) { VIR_FREE(def->name); @@ -10976,6 +10992,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

On Thu, Oct 14, 2010 at 09:38:27AM +0200, Jiri Denemark wrote:
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. --- src/qemu/qemu_driver.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
ACK, good idea. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Thu, Oct 14, 2010 at 09:59:18AM +0100, Daniel P. Berrange wrote:
On Thu, Oct 14, 2010 at 09:38:27AM +0200, Jiri Denemark wrote:
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. --- src/qemu/qemu_driver.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
ACK, good idea.
yup, ACK However over long term this may have to be revisited, I have heard about attempts to work around that limitation, but in the current state that's the right thing to do :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Thu, Oct 14, 2010 at 11:45:37AM +0200, Daniel Veillard wrote:
On Thu, Oct 14, 2010 at 09:59:18AM +0100, Daniel P. Berrange wrote:
On Thu, Oct 14, 2010 at 09:38:27AM +0200, Jiri Denemark wrote:
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. --- src/qemu/qemu_driver.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
ACK, good idea.
yup, ACK
However over long term this may have to be revisited, I have heard about attempts to work around that limitation, but in the current state that's the right thing to do :-)
The workarounds have all be along the lines of 'unplug the device' before and 'plug it back in' afterwards :-) Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Jiri Denemark