[libvirt] How to config my VM to use KVM with libvirt?

Jim Paris jim at jtan.com
Tue Jul 21 21:28:27 UTC 2009


Daniel P. Berrange wrote:
> On Tue, Jul 21, 2009 at 09:46:17AM -0400, Jim Paris wrote:
> > Speaking of this, I've noticed that
> > 
> > <domain type='qemu'>
> >   <os>
> >     <type arch='i686' machine='pc'>hvm</type>
> >   </os>
> > </domain>
> > 
> > runs WITH kvm on an x86_64 system.  Is that intended?
> 
> No, its not intended !
...
> I'm actually wondering why we bother with #1 at all. If the
> binary has '-no-kvm' and the domain is 'qemu', then it should
> be used no matter what arch.

Agreed.  Below is a patch which should fix the oversight (lightly
tested).

However, this is going to be a user-visible change and may cause
people to complain that their existing 32-bit domains are unexpectedly
running with -no-kvm.  Is that OK?  Technically it's a misconfiguration.

For the record, I think we've already broken this area once when
0.6.2 came out -- previous to that, even my 64-bit VMs had domain type
"qemu", and libvirt ran my specified kvm binary without -no-kvm.

-jim

>From f7edd4c887512e4fc7c97b12a4f2409244af9eb3 Mon Sep 17 00:00:00 2001
From: Jim Paris <jim at jtan.com>
Date: Tue, 21 Jul 2009 17:07:51 -0400
Subject: [PATCH] Always add -no-kvm and -no-kqemu, if available, for "qemu" domains.

If the qemu binary supports "-no-kvm" and/or "-no-kqemu", they should
always be added for plain "qemu" domains.  Previously, we omitted them
whenever the host and guest architectures implied that they would be
disabled automatically, but that logic was flawed in some cases
(such as i686 and x86_64).

Signed-off-by: Jim Paris <jim at jtan.com>
---
 src/qemu_conf.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 4043d70..f146598 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -977,22 +977,18 @@ int qemudBuildCommandLine(virConnectPtr conn,
     emulator = def->emulator;
 
     /* Need to explicitly disable KQEMU if
-     * 1. Arch matches host arch
-     * 2. Guest domain is 'qemu'
-     * 3. The qemu binary has the -no-kqemu flag
+     * 1. Guest domain is 'qemu'
+     * 2. The qemu binary has the -no-kqemu flag
      */
     if ((qemuCmdFlags & QEMUD_CMD_FLAG_KQEMU) &&
-        STREQ(ut.machine, def->os.arch) &&
         def->virtType == VIR_DOMAIN_VIRT_QEMU)
         disableKQEMU = 1;
 
     /* Need to explicitly disable KVM if
-     * 1. Arch matches host arch
-     * 2. Guest domain is 'qemu'
-     * 3. The qemu binary has the -no-kvm flag
+     * 1. Guest domain is 'qemu'
+     * 2. The qemu binary has the -no-kvm flag
      */
     if ((qemuCmdFlags & QEMUD_CMD_FLAG_KVM) &&
-        STREQ(ut.machine, def->os.arch) &&
         def->virtType == VIR_DOMAIN_VIRT_QEMU)
         disableKVM = 1;
 
-- 
1.6.1.3





More information about the libvir-list mailing list