Re: [PATCH] Fix --disable-kvm build regression of commit 8c7d4cb

2009-09-10 Thread Avi Kivity

On 09/10/2009 02:10 AM, Daniel Gollub wrote:

qemu-kvm --disable-kvm build regression of commit 8c7d4cb spotted by
qemu-kvm buildbot:

http://buildbot.b1-systems.de/qemu-kvm/builders/disable_kvm_i386_debian_5_0/builds/44
http://buildbot.b1-systems.de/qemu-kvm/builders/disable_kvm_x86_64_debian_5_0/builds/42

   


Applied, thanks.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


buildbot failure in qemu-kvm on disable_kvm_i386_debian_5_0

2009-09-10 Thread qemu-kvm
The Buildbot has detected a new failure of disable_kvm_i386_debian_5_0 on 
qemu-kvm.
Full details are available at:
 
http://buildbot.b1-systems.de/qemu-kvm/builders/disable_kvm_i386_debian_5_0/builds/47

Buildbot URL: http://buildbot.b1-systems.de/qemu-kvm/

Buildslave for this Build: b1_qemu_kvm_2

Build Reason: 
Build Source Stamp: [branch next] HEAD
Blamelist: Avi Kivity a...@redhat.com,Bernhard Kauer 
ka...@os.inf.tu-dresden.de,Dustin Kirkland kirkl...@canonical.com,Gerd 
Hoffmann kra...@redhat.com,Glauber Costa glom...@redhat.com,Jean-Christophe 
DUBOIS j...@tribudubois.net,Juan Quintela quint...@redhat.com,Kevin Wolf 
kw...@redhat.com,Luiz Capitulino lcapitul...@redhat.com,Naphtali Sprei 
nsp...@redhat.com,Pierre Riteau pierre.rit...@irisa.fr,Stefan Weil 
w...@mail.berlios.de

BUILD FAILED: failed compile

sincerely,
 -The Buildbot

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][RESEND] qemu-kvm: fix warnings with USE_KVM_DEVICE_ASSIGNMENT disabled

2009-09-10 Thread Daniel Gollub
Fix warnings with USE_KVM_DEVICE_ASSIGNMENT disabled, spotted by buildbot:

http://buildbot.b1-systems.de/qemu-kvm/builders/default_x86_64_debian_5_0/builds/55/steps/compile/logs/warnings

Signed-off-by: Daniel Gollub gol...@b1-systems.de

--
 qemu-kvm.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index e2f3b91..78eeb6f 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -66,8 +66,10 @@ static CPUState *kvm_debug_cpu_requested;
 
 static uint64_t phys_ram_size;
 
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
 /* The list of ioperm_data */
 static LIST_HEAD(, ioperm_data) ioperm_head;
+#endif
 
 //#define DEBUG_MEMREG
 #ifdef DEBUG_MEMREG
@@ -1829,7 +1831,9 @@ static void *ap_main_loop(void *_env)
 {
 CPUState *env = _env;
 sigset_t signals;
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
 struct ioperm_data *data = NULL;
+#endif
 
 current_env = env;
 env-thread_id = kvm_get_thread_id();


-- 
Daniel GollubGeschaeftsfuehrer: Ralph Dehner
FOSS Developer   Unternehmenssitz:  Vohburg
B1 Systems GmbH  Amtsgericht:   Ingolstadt
Mobil: +49-(0)-160 47 73 970 Handelsregister:   HRB 3537
EMail: gol...@b1-systems.de  http://www.b1-systems.de

Adresse: B1 Systems GmbH, Osterfeldstraße 7, 85088 Vohburg
http://pgpkeys.pca.dfn.de/pks/lookup?op=getsearch=0xED14B95C2F8CA78D
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Multiple Port Support for virtio-console

2009-09-10 Thread Amit Shah
On (Wed) Sep 09 2009 [13:41:59], Amit Shah wrote:
 
 Hello all,
 
 Here is a new iteration of the patch series that implements a
 transport for guest and host communications.
 
 I've tested for compatibility (old qemu  new kernel, new qemu  old
 kernel, new qemu  new kernel) and it all works fine*. Migration works
 with the patch Juan just posted.
 
 There are a few items on my todo list but this works well.
 
 New since last send:
 - migrate per-port buffers that are queued up
 - in-qemu api for open/close/read/write of ports.
   - the read() is a callback that's invoked when complete data
 corresponding to one write() request on the guest is available.
 - removed comments from virtio_console.c that are no longer relevant.
 - address review comments by Juan
 
 TODO:
 - Convert all config writes to little endian in qemu / convert from
   little endian to host endian in guest
 - Address a few FIXMEs spread in the code
 - Introduce a watermark to stop a rogue host process flooding guest
   with data
 
 Conditions:
 * Heavy IO on an hvc port and a non-hvc port causes memory corruption
   each time, same place. It could be realted to locking but I doubt
   that. This still has to be sorted out

I can't reproduce this badness anymore with the linux-next kernel in the
guest.

So I request the maintainers to please review this patchset for and
consider for inclusion.

Thanks,
Amit
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fix missing prototype warning with USE_KVM_DEVICE_ASSIGNMENT disabled

2009-09-10 Thread Daniel Gollub
Fixes warning about missing kvm_arch_do_ioperm prototype with
USE_KVM_DEVICE_ASSIGNMENT disabled.

/var/lib/buildbot/qemu-kvm/default_x86_64_debian_5_0/build/qemu-kvm-x86.c:1635: 
warning: no previous prototype for 'kvm_arch_do_ioperm'

Patch only build-tested with i386 and x86_64 - not ia64!


Spotted by buildbot:
http://buildbot.b1-systems.de/qemu-kvm/builders/default_i386_debian_5_0/builds/59/steps/compile/logs/warnings
http://buildbot.b1-systems.de/qemu-kvm/builders/default_x86_64_debian_5_0/builds/57/steps/compile/logs/warnings


Signed-off-by: Daniel Gollub gol...@b1-systems.de

---
 qemu-kvm-ia64.c |2 ++
 qemu-kvm-x86.c  |2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/qemu-kvm-ia64.c b/qemu-kvm-ia64.c
index 062fbd4..8485452 100644
--- a/qemu-kvm-ia64.c
+++ b/qemu-kvm-ia64.c
@@ -136,11 +136,13 @@ void kvm_arch_cpu_reset(CPUState *env)
 }
 }
 
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
 void kvm_arch_do_ioperm(void *_data)
 {
 struct ioperm_data *data = _data;
 ioperm(data-start_port, data-num, data-turn_on);
 }
+#endif
 
 void kvm_arch_process_irqchip_events(CPUState *env)
 {
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index f80d82b..92fff7c 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1632,11 +1632,13 @@ void kvm_arch_update_guest_debug(CPUState *env, struct 
kvm_guest_debug *dbg)
 }
 #endif
 
+#ifdef USE_KVM_DEVICE_ASSIGNMENT
 void kvm_arch_do_ioperm(void *_data)
 {
 struct ioperm_data *data = _data;
 ioperm(data-start_port, data-num, data-turn_on);
 }
+#endif
 
 /*
  * Setup x86 specific IRQ routing

-- 
Daniel GollubGeschaeftsfuehrer: Ralph Dehner
FOSS Developer   Unternehmenssitz:  Vohburg
B1 Systems GmbH  Amtsgericht:   Ingolstadt
Mobil: +49-(0)-160 47 73 970 Handelsregister:   HRB 3537
EMail: gol...@b1-systems.de  http://www.b1-systems.de

Adresse: B1 Systems GmbH, Osterfeldstraße 7, 85088 Vohburg
http://pgpkeys.pca.dfn.de/pks/lookup?op=getsearch=0xED14B95C2F8CA78D
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] KVM test: Move top level docstrings, other cleanups

2009-09-10 Thread Lucas Meneghel Rodrigues
In order to prepare for the subsequent changes, made
some cleanups on the kvm source files: I've noticed
that the top level docstrings were going before the
imports block, and that does not follow the pattern
found on other files (my fault). This patch fixes
that problem and fixed some places on scan_results.py
where 80 char line width was not being obeyed. Also,
cleaned up the last places where we were using the
shebang #/usr/bin/env python, which is not the
preferred usage of the shebang across the project.

Signed-off-by: Lucas Meneghel Rodrigues l...@redhat.com
---
 client/tests/kvm/calc_md5sum_1m.py   |8 
 client/tests/kvm/fix_cdkeys.py   |6 +++---
 client/tests/kvm/kvm_config.py   |   10 +-
 client/tests/kvm/kvm_guest_wizard.py |   12 ++--
 client/tests/kvm/kvm_subprocess.py   |8 
 client/tests/kvm/kvm_test_utils.py   |8 
 client/tests/kvm/kvm_tests.py|8 
 client/tests/kvm/kvm_utils.py|   12 ++--
 client/tests/kvm/kvm_vm.py   |6 +++---
 client/tests/kvm/make_html_report.py |   14 +++---
 client/tests/kvm/ppm_utils.py|5 +++--
 client/tests/kvm/scan_results.py |   20 ++--
 client/tests/kvm/stepeditor.py   |8 
 client/tests/kvm/stepmaker.py|   13 +++--
 14 files changed, 70 insertions(+), 68 deletions(-)

diff --git a/client/tests/kvm/calc_md5sum_1m.py 
b/client/tests/kvm/calc_md5sum_1m.py
index 6660d0e..2325673 100755
--- a/client/tests/kvm/calc_md5sum_1m.py
+++ b/client/tests/kvm/calc_md5sum_1m.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-import os, sys
-import kvm_utils
-
+#!/usr/bin/python
 
 Program that calculates the md5sum for the first megabyte of a file.
 It's faster than calculating the md5sum for the whole ISO image.
@@ -10,6 +7,9 @@ It's faster than calculating the md5sum for the whole ISO 
image.
 @author: Uri Lublin (u...@redhat.com)
 
 
+import os, sys
+import kvm_utils
+
 
 if len(sys.argv)  2:
 print 'usage: %s iso-filename' % sys.argv[0]
diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py
index 7a821fa..aa9fc3e 100755
--- a/client/tests/kvm/fix_cdkeys.py
+++ b/client/tests/kvm/fix_cdkeys.py
@@ -1,7 +1,4 @@
 #!/usr/bin/python
-import shutil, os, sys
-import common
-
 
 Program that replaces the CD keys present on a KVM autotest configuration file.
 
@@ -9,6 +6,9 @@ Program that replaces the CD keys present on a KVM autotest 
configuration file.
 @author: u...@redhat.com (Uri Lublin)
 
 
+import shutil, os, sys
+import common
+
 
 def file_to_lines(filename):
 f = open(filename, 'r')
diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index 405de4b..3114c07 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -1,15 +1,15 @@
 #!/usr/bin/python
-import logging, re, os, sys, StringIO, optparse
-import common
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.common_lib import logging_config, logging_manager
-
 
 KVM configuration file utility functions.
 
 @copyright: Red Hat 2008-2009
 
 
+import logging, re, os, sys, StringIO, optparse
+import common
+from autotest_lib.client.common_lib import error
+from autotest_lib.client.common_lib import logging_config, logging_manager
+
 
 class KvmLoggingConfig(logging_config.LoggingConfig):
 def configure_logging(self, results_dir=None, verbose=False):
diff --git a/client/tests/kvm/kvm_guest_wizard.py 
b/client/tests/kvm/kvm_guest_wizard.py
index 3d3f3b2..8bc85f2 100644
--- a/client/tests/kvm/kvm_guest_wizard.py
+++ b/client/tests/kvm/kvm_guest_wizard.py
@@ -1,3 +1,9 @@
+
+Utilities to perform automatic guest installation using step files.
+
+...@copyright: Red Hat 2008-2009
+
+
 import os, time, md5, re, shutil, logging
 from autotest_lib.client.common_lib import utils, error
 import kvm_utils, ppm_utils, kvm_subprocess
@@ -9,12 +15,6 @@ except ImportError:
 'please install python-imaging or the equivalent for your '
 'distro.')
 
-
-Utilities to perform automatic guest installation using step files.
-
-...@copyright: Red Hat 2008-2009
-
-
 
 def handle_var(vm, params, varname):
 var = params.get(varname)
diff --git a/client/tests/kvm/kvm_subprocess.py 
b/client/tests/kvm/kvm_subprocess.py
index c3c48cd..f748586 100755
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -1,14 +1,14 @@
 #!/usr/bin/python
-import sys, subprocess, pty, select, os, time, signal, re, termios, fcntl
-import threading, logging, commands
-import common, kvm_utils
-
 
 A class and functions used for running and controlling child processes.
 
 @copyright: 2008-2009 Red Hat Inc.
 
 
+import sys, subprocess, pty, select, os, time, signal, re, termios, fcntl
+import threading, logging, commands
+import common, kvm_utils
+
 
 def run_bg(command, termination_func=None, output_func=None, output_prefix=,

[PATCH 2/3] KVM test: Removing the fix_cdkeys.py program

2009-09-10 Thread Lucas Meneghel Rodrigues
That is no longer necessary since we handle cd keys on
a separate configuration file.

Signed-off-by: Lucas Meneghel Rodrigues l...@redhat.com
---
 client/tests/kvm/fix_cdkeys.py |   76 
 1 files changed, 0 insertions(+), 76 deletions(-)
 delete mode 100755 client/tests/kvm/fix_cdkeys.py

diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py
deleted file mode 100755
index aa9fc3e..000
--- a/client/tests/kvm/fix_cdkeys.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/python
-
-Program that replaces the CD keys present on a KVM autotest configuration file.
-
-...@copyright: Red Hat 2008-2009
-...@author: u...@redhat.com (Uri Lublin)
-
-
-import shutil, os, sys
-import common
-
-
-def file_to_lines(filename):
-f = open(filename, 'r')
-lines = f.readlines()
-f.close
-return lines
-
-def lines_to_file(filename, lines):
-f = open(filename, 'w')
-f.writelines(lines)
-f.close()
-
-def replace_var_with_val(lines, variables):
-new = []
-for line in lines:
-for (var,val) in variables:
-if var in line:
-print 'replacing %s with %s in %s' % (var, val, line[:-1])
-line = line.replace(var, val)
-print ' ... new line is %s' % (line[:-1])
-new.append(line)
-return new
-
-def filter_comments(line):
-return not line.strip().startswith('#')
-
-def filter_empty(line):
-return len(line.strip()) != 0
-
-def line_to_pair(line):
-x,y = line.split('=', 1)
-return (x.strip(), y.strip())
-
-def read_vars(varfile):
-varlines = file_to_lines(varfile)
-varlines = filter(filter_comments, varlines)
-varlines = filter(filter_empty,varlines)
-vars = map(line_to_pair, varlines)
-return vars
-
-def main(cfgfile, varfile):
-# first save a copy of the original file (if does not exist)
-backupfile = '%s.backup' % cfgfile
-if not os.path.exists(backupfile):
-shutil.copy(cfgfile, backupfile)
-
-vars = read_vars(varfile)
-datalines = file_to_lines(cfgfile)
-newlines = replace_var_with_val(datalines, vars)
-lines_to_file(cfgfile, newlines)
-
-
-if __name__ == '__main__':
-def die(msg, val):
-print msg
-sys.exit(val)
-if len(sys.argv) != 3:
-die('usage: %s kvm_tests-config-file varfile', 1)
-cfgfile = sys.argv[1]
-varfile = sys.argv[2]
-if not os.path.exists(cfgfile):
-die('bad cfgfile %s' % cfgfile, 2)
-if not os.path.exists(varfile):
-die('bad varfile %s' % varfile, 2)
-main(cfgfile, varfile)
-- 
1.6.2.5

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] KVM test: Points user to online documentation

2009-09-10 Thread Lucas Meneghel Rodrigues
 * Renamed BEFORE_YOU_START to README, and point
   to the online documentation in there (it's
   pointless to duplicate procedures).
 * The control file docstring points to the
   top level KVM testing documentation.
 * The kvm class docstring points to the getting
   started guide.

Signed-off-by: Lucas Meneghel Rodrigues l...@redhat.com
---
 client/tests/kvm/BEFORE_YOU_START |   19 ---
 client/tests/kvm/README   |3 +++
 client/tests/kvm/control  |2 ++
 client/tests/kvm/kvm.py   |3 +++
 4 files changed, 8 insertions(+), 19 deletions(-)
 delete mode 100644 client/tests/kvm/BEFORE_YOU_START
 create mode 100644 client/tests/kvm/README

diff --git a/client/tests/kvm/BEFORE_YOU_START 
b/client/tests/kvm/BEFORE_YOU_START
deleted file mode 100644
index 7478d9d..000
--- a/client/tests/kvm/BEFORE_YOU_START
+++ /dev/null
@@ -1,19 +0,0 @@
-Install kvm and load modules.
-Remove 'env' file if exists.
-Remove control.state file if exists.
-
-Copy kvm_tests.cfg.sample into kvm_tests.cfg
-Modify kvm_tests.cfg to your liking.
-Modify control if you prefer to use your own kvm (comment out kvm_install).
-
-Create those symbolic links under kvm or under rootdir
-qemu   - qemu-kvm binary (unless using kvm_install)
-qemu-img   - qemu-img binary (unless using kvm_install)
-isos/  - isos (mount or symlink)
-images/- images (mount or symlink)
-autotest/  - ../../ (an autotest client directroy)
-steps_data/- steps_data dir (when available)
-
-Please make sure qemu points to an installed kvm-qemu executable, and
-not one just compiled in the source directory. An installed executable knows
-where to find its associated data-dir (e.g. for bios).
diff --git a/client/tests/kvm/README b/client/tests/kvm/README
new file mode 100644
index 000..88d2c15
--- /dev/null
+++ b/client/tests/kvm/README
@@ -0,0 +1,3 @@
+In order to get started, please refer to the online documentation:
+
+http://www.linux-kvm.org/page/KVM-Autotest/Client_Install
diff --git a/client/tests/kvm/control b/client/tests/kvm/control
index 2ad8d81..f8390d6 100644
--- a/client/tests/kvm/control
+++ b/client/tests/kvm/control
@@ -16,6 +16,8 @@ DOC = 
 Executes the KVM test framework on a given host. This module is separated in
 minor functions, that execute different tests for doing Quality Assurance on
 KVM (both kernelspace and userspace) code.
+
+For online docs, please refer to http://www.linux-kvm.org/page/KVM-Autotest
 
 
 
diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 4930e80..8e66fc0 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -38,6 +38,9 @@ class kvm(test.test):
 @author: David Huff (dh...@redhat.com)
 @author: Alexey Eromenko (aerom...@redhat.com)
 @author: Mike Burns (mbu...@redhat.com)
+
+@see: http://www.linux-kvm.org/page/KVM-Autotest/Client_Install
+(Online doc - Getting started with KVM testing)
 
 version = 1
 def initialize(self):
-- 
1.6.2.5

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] KVM test: Make install test not strip binaries

2009-09-10 Thread Lucas Meneghel Rodrigues
Don't strip binaries on all supported build methods.

Signed-off-by: Lucas Meneghel Rodrigues l...@redhat.com
---
 client/tests/kvm/kvm_install.py |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/kvm_install.py b/client/tests/kvm/kvm_install.py
index 673445f..148513f 100755
--- a/client/tests/kvm/kvm_install.py
+++ b/client/tests/kvm/kvm_install.py
@@ -271,12 +271,14 @@ class GitInstaller:
 utils.system('make -j %s' % utils.count_cpus())
 logging.info('Building KVM userspace code')
 os.chdir(self.userspace_srcdir)
-utils.system('./configure --prefix=%s' % self.prefix)
+utils.system('./configure --disable-strip --prefix=%s' %
+ self.prefix)
 utils.system('make clean')
 utils.system('make -j %s' % utils.count_cpus())
 else:
 os.chdir(self.userspace_srcdir)
-utils.system('./configure --prefix=%s' % self.prefix)
+utils.system('./configure --disable-strip --prefix=%s' %
+ self.prefix)
 logging.info('Building KVM modules')
 utils.system('make clean')
 utils.system('make -C kernel LINUX=%s sync' % self.kernel_srcdir)
-- 
1.6.2.5

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] ksm support for kvm

2009-09-10 Thread Izik Eidus
Hi,

The following seires add ksm support to the kvm mmu.

Thanks.


--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] add SPTE_HOST_WRITEABLE flag to the shadow ptes

2009-09-10 Thread Izik Eidus
this flag notify that the host physical page we are pointing to from
the spte is write protected, and therefore we cant change its access
to be write unless we run get_user_pages(write = 1).

(this is needed for change_pte support in kvm)

Signed-off-by: Izik Eidus iei...@redhat.com
---
 arch/x86/kvm/mmu.c |   15 +++
 arch/x86/kvm/paging_tmpl.h |   18 +++---
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 62d2f86..a7151b8 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -156,6 +156,8 @@ module_param(oos_shadow, bool, 0644);
 #define CREATE_TRACE_POINTS
 #include mmutrace.h
 
+#define SPTE_HOST_WRITEABLE (1ULL  PT_FIRST_AVAIL_BITS_SHIFT)
+
 #define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
 
 struct kvm_rmap_desc {
@@ -1754,7 +1756,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
unsigned pte_access, int user_fault,
int write_fault, int dirty, int level,
gfn_t gfn, pfn_t pfn, bool speculative,
-   bool can_unsync)
+   bool can_unsync, bool reset_host_protection)
 {
u64 spte;
int ret = 0;
@@ -1781,6 +1783,9 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
spte |= kvm_x86_ops-get_mt_mask(vcpu, gfn,
kvm_is_mmio_pfn(pfn));
 
+   if (reset_host_protection)
+   spte |= SPTE_HOST_WRITEABLE;
+
spte |= (u64)pfn  PAGE_SHIFT;
 
if ((pte_access  ACC_WRITE_MASK)
@@ -1826,7 +1831,8 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 
*sptep,
 unsigned pt_access, unsigned pte_access,
 int user_fault, int write_fault, int dirty,
 int *ptwrite, int level, gfn_t gfn,
-pfn_t pfn, bool speculative)
+pfn_t pfn, bool speculative,
+bool reset_host_protection)
 {
int was_rmapped = 0;
int was_writeble = is_writeble_pte(*sptep);
@@ -1858,7 +1864,8 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 
*sptep,
}
 
if (set_spte(vcpu, sptep, pte_access, user_fault, write_fault,
- dirty, level, gfn, pfn, speculative, true)) {
+ dirty, level, gfn, pfn, speculative, true,
+ reset_host_protection)) {
if (write_fault)
*ptwrite = 1;
kvm_x86_ops-tlb_flush(vcpu);
@@ -1906,7 +1913,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, 
int write,
if (iterator.level == level) {
mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, ACC_ALL,
 0, write, 1, pt_write,
-level, gfn, pfn, false);
+level, gfn, pfn, false, true);
++vcpu-stat.pf_fixed;
break;
}
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index d2fec9c..c9256ee 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -273,9 +273,13 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, 
struct kvm_mmu_page *page,
if (mmu_notifier_retry(vcpu, vcpu-arch.update_pte.mmu_seq))
return;
kvm_get_pfn(pfn);
+   /*
+* we call mmu_set_spte() with reset_host_protection = true beacuse that
+* vcpu-arch.update_pte.pfn was fetched from get_user_pages(write = 1).
+*/
mmu_set_spte(vcpu, spte, page-role.access, pte_access, 0, 0,
 gpte  PT_DIRTY_MASK, NULL, PT_PAGE_TABLE_LEVEL,
-gpte_to_gfn(gpte), pfn, true);
+gpte_to_gfn(gpte), pfn, true, true);
 }
 
 /*
@@ -308,7 +312,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
 user_fault, write_fault,
 gw-ptes[gw-level-1]  PT_DIRTY_MASK,
 ptwrite, level,
-gw-gfn, pfn, false);
+gw-gfn, pfn, false, true);
break;
}
 
@@ -558,6 +562,7 @@ static void FNAME(prefetch_page)(struct kvm_vcpu *vcpu,
 static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
 {
int i, offset, nr_present;
+bool reset_host_protection;
 
offset = nr_present = 0;
 
@@ -595,9 +600,16 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct 
kvm_mmu_page *sp)
 
nr_present++;
pte_access = sp-role.access  FNAME(gpte_access)(vcpu, gpte);
+   if (!(sp-spt[i]  SPTE_HOST_WRITEABLE)) {
+   pte_access = ~PT_WRITABLE_MASK;
+   reset_host_protection = 0;
+   } else 

[PATCH 3/3] add support for change_pte mmu notifiers

2009-09-10 Thread Izik Eidus
this is needed for kvm if it want ksm to directly map pages into its
shadow page tables.

Signed-off-by: Izik Eidus iei...@redhat.com
---
 arch/x86/include/asm/kvm_host.h |1 +
 arch/x86/kvm/mmu.c  |   70 ++
 virt/kvm/kvm_main.c |   14 
 3 files changed, 77 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 6046e6f..594d131 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -797,6 +797,7 @@ asmlinkage void kvm_handle_fault_on_reboot(void);
 #define KVM_ARCH_WANT_MMU_NOTIFIER
 int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
 int kvm_age_hva(struct kvm *kvm, unsigned long hva);
+void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
 int cpuid_maxphyaddr(struct kvm_vcpu *vcpu);
 int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu);
 int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a7151b8..3fd19f2 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -282,6 +282,11 @@ static pfn_t spte_to_pfn(u64 pte)
return (pte  PT64_BASE_ADDR_MASK)  PAGE_SHIFT;
 }
 
+static pte_t ptep_val(pte_t *ptep)
+{
+   return *ptep;
+}
+
 static gfn_t pse36_gfn_delta(u32 gpte)
 {
int shift = 32 - PT32_DIR_PSE36_SHIFT - PAGE_SHIFT;
@@ -748,7 +753,8 @@ static int rmap_write_protect(struct kvm *kvm, u64 gfn)
return write_protected;
 }
 
-static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp)
+static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp,
+  unsigned long data)
 {
u64 *spte;
int need_tlb_flush = 0;
@@ -763,8 +769,48 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long 
*rmapp)
return need_tlb_flush;
 }
 
+static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp,
+unsigned long data)
+{
+   int need_flush = 0;
+   u64 *spte, new_spte;
+   pte_t *ptep = (pte_t *)data;
+   pfn_t new_pfn;
+
+   new_pfn = pte_pfn(ptep_val(ptep));
+   spte = rmap_next(kvm, rmapp, NULL);
+   while (spte) {
+   BUG_ON(!is_shadow_present_pte(*spte));
+   rmap_printk(kvm_set_pte_rmapp: spte %p %llx\n, spte, *spte);
+   need_flush = 1;
+   if (pte_write(ptep_val(ptep))) {
+   rmap_remove(kvm, spte);
+   __set_spte(spte, shadow_trap_nonpresent_pte);
+   spte = rmap_next(kvm, rmapp, NULL);
+   } else {
+   new_spte = *spte ~ (PT64_BASE_ADDR_MASK);
+   new_spte |= new_pfn  PAGE_SHIFT;
+
+   if (!pte_write(ptep_val(ptep))) {
+   new_spte = ~PT_WRITABLE_MASK;
+   new_spte = ~SPTE_HOST_WRITEABLE;
+   if (is_writeble_pte(*spte))
+   kvm_set_pfn_dirty(spte_to_pfn(*spte));
+   }
+   __set_spte(spte, new_spte);
+   spte = rmap_next(kvm, rmapp, spte);
+   }
+   }
+   if (need_flush)
+   kvm_flush_remote_tlbs(kvm);
+
+   return 0;
+}
+
 static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
- int (*handler)(struct kvm *kvm, unsigned long *rmapp))
+ unsigned long data,
+ int (*handler)(struct kvm *kvm, unsigned long *rmapp,
+unsigned long data))
 {
int i, j;
int retval = 0;
@@ -786,13 +832,15 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long 
hva,
if (hva = start  hva  end) {
gfn_t gfn_offset = (hva - start)  PAGE_SHIFT;
 
-   retval |= handler(kvm, memslot-rmap[gfn_offset]);
+   retval |= handler(kvm, memslot-rmap[gfn_offset],
+ data);
 
for (j = 0; j  KVM_NR_PAGE_SIZES - 1; ++j) {
int idx = gfn_offset;
idx /= KVM_PAGES_PER_HPAGE(PT_DIRECTORY_LEVEL + 
j);
retval |= handler(kvm,
-   memslot-lpage_info[j][idx].rmap_pde);
+   memslot-lpage_info[j][idx].rmap_pde,
+   data);
}
}
}
@@ -802,10 +850,16 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long 
hva,
 
 int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
 {
-   return kvm_handle_hva(kvm, hva, kvm_unmap_rmapp);
+   return kvm_handle_hva(kvm, hva, 0, kvm_unmap_rmapp);
+}
+
+void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
+{
+   

Re: [RFC] KVM: x86: conditionally acquire/release slots_lock on entry/exit

2009-09-10 Thread Marcelo Tosatti
On Fri, Aug 28, 2009 at 09:50:36AM +0300, Avi Kivity wrote:
 On 08/28/2009 01:59 AM, Marcelo Tosatti wrote:
 On Thu, Aug 27, 2009 at 07:27:48PM +0300, Avi Kivity wrote:

 On 08/27/2009 06:54 PM, Marcelo Tosatti wrote:
  
 perf report shows heavy overhead from down/up of slots_lock.

 Attempted to remove slots_lock by having vcpus stop on a synchronization
 point, but this introduced further complexity (a vcpu can be scheduled
 out before reaching the synchronization point, and can sched back in at
 points which are slots_lock protected, etc).

 This patch changes vcpu_enter_guest to conditionally release/acquire
 slots_lock in case a vcpu state bit is set.

 vmexit performance improves by 5-10% on UP guest.


 Sorry, it looks pretty complex.
  
 Why?


 There's a new locking protocol in there.  I prefer sticking with the  
 existing kernel plumbing, or it gets more and more difficult knowing who  
 protects what and in what order you can do things.

 Have you considered using srcu? It seems to me down/up_read() can
 be replaced by srcu_read_lock/unlock(), and after proper conversion
 of memslots and io_bus to rcu_assign_pointer(), we can just add
 synchronize_srcu() immediately after changing stuff (of course
 mmu_lock still needs to be held when updating slots).
  
 I don't see RCU as being suitable because in certain operations you
 want to stop writers (on behalf of vcpus), do something, and let them
 continue afterwards. The dirty log, for example. Or any operation that
 wants to modify lockless vcpu specific data.


 kvm_flush_remote_tlbs() (which you'd call after mmu operations), will  
 get cpus out of guest mode, and synchronize_srcu() will wait for them to  
 drop the srcu read lock.  So it really happens naturally: do an RCU  
 update, send some request to all vcpus, synchronize_srcu(), done.

 Also, synchronize_srcu() is limited to preemptible sections.

 io_bus could use RCU, but I think being able to stop vcpus is also a
 different requirement. Do you have any suggestion on how to do it in a
 better way?


 We don't need to stop vcpus, just kick them out of guest mode to let  
 them notice the new data.  SRCU does that well.

Two problems:

1. The removal of memslots/aliases and zapping of mmu (to remove any
shadow pages with stale sp-gfn) must be atomic from the POV of the
pagefault path. Otherwise something like this can happen:

fault path  set_memory_region

walk_addr fetches and validates
table_gfns
delete memslot
synchronize_srcu

fetch creates shadow
page with nonexistant sp-gfn

OR

mmu_alloc_roots pathset_memory_region

delete memslot
root_gfn = vcpu-arch.cr3  PAGE_SHIFT
mmu_check_root(root_gfn)synchronize_rcu
kvm_mmu_get_page()
kvm_mmu_zap_all

Accesses between kvm_mmu_get_page and kvm_mmu_zap_all window can see
shadow pages with stale gfn.

But, if you still think its worthwhile to use RCU, at least handling
gfn_to_memslot / unalias_gfn errors _and_ adding mmu_notifier_retry
invalidation to set_memory_region path will be necessary (so that
gfn_to_pfn validation, in the fault path, is discarded in case
of memslot/alias update).

2. Another complication is that memslot creation and kvm_iommu_map_pages
are not atomic.

create memslot
synchronize_srcu
- vcpu grabs gfn reference without
   iommu mapping.
kvm_iommu_map_pages

Which can be solved by changing kvm_iommu_map_pages (and new gfn_to_pfn
helper) to use base_gfn,npages,hva information from somewhere else other
than visible kvm-memslots (so that when the slot becomes visible its
already iommu mapped).

So it appears to me using RCU introduces more complications / subtle
details than mutual exclusion here. The new request bit which the
original patch introduces is limited to enabling/disabling conditional
acquision of slots_lock (calling it a new locking protocol is unfair)
to improve write acquision latency.

Better ideas/directions welcome.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] KVM test: use a better source for random numbers

2009-09-10 Thread Michael Goldish
Use random.SystemRandom() (which uses /dev/urandom) in
kvm_utils.generate_random_string().
Currently, when running multiple jobs in parallel, the generated strings
occasionally collide, and this is very bad.

Also, don't seed the random number generator in kvm.py.  This is not necessary
and is probably done by default anyway.

Signed-off-by: Michael Goldish mgold...@redhat.com
---
 client/tests/kvm/kvm.py   |5 +
 client/tests/kvm/kvm_utils.py |3 ++-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 4930e80..97c1b00 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -1,4 +1,4 @@
-import sys, os, time, shelve, random, resource, logging, cPickle
+import sys, os, time, shelve, resource, logging, cPickle
 from autotest_lib.client.bin import test
 from autotest_lib.client.common_lib import error
 
@@ -68,9 +68,6 @@ class kvm(test.test):
 import kvm_utils
 import kvm_preprocessing
 
-# Seed the random number generator
-random.seed()
-
 # Enable core dumps
 resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
 
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index ac9ede7..e4c3580 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -676,10 +676,11 @@ def generate_random_string(length):
 
 @length: length of the string that will be generated.
 
+r = random.SystemRandom()
 str = 
 chars = string.letters + string.digits
 while length  0:
-str += random.choice(chars)
+str += r.choice(chars)
 length -= 1
 return str
 
-- 
1.5.4.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] [RFC] KVM test: kvm_tests.cfg.sample: add some scheduler params

2009-09-10 Thread Michael Goldish
used_cpus denotes the number of CPUs required for a test.
used_mem denotes the amount of RAM required for a test.

Signed-off-by: Michael Goldish mgold...@redhat.com
---
 client/tests/kvm/kvm_tests.cfg.sample |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_tests.cfg.sample 
b/client/tests/kvm/kvm_tests.cfg.sample
index 285a38f..5142bbe 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -22,6 +22,10 @@ image_size = 10G
 shell_port = 22
 display = vnc
 
+# Default scheduler params
+used_cpus = 1
+used_mem = 512
+
 # Port redirections
 redirs = remote_shell
 guest_port_remote_shell = 22
@@ -66,6 +70,7 @@ variants:
 migration_test_command = help
 kill_vm_on_error = yes
 iterations = 2
+used_mem = 1024
 
 - autotest: install setup
 type = autotest
@@ -115,6 +120,8 @@ variants:
 kill_vm = yes
 kill_vm_vm1 = no
 kill_vm_gracefully = no
+used_cpus = 5
+used_mem = 2560
 extra_params +=  -snapshot
 
 - autoit:   install setup
@@ -568,6 +575,8 @@ linux_s3:
 variants:
 - @up:
 - smp2:
+used_cpus = 2
+stress_boot: used_cpus = 10
 extra_params +=  -smp 2
 
 
-- 
1.5.4.1

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] [RFC] KVM test: client parallel test execution

2009-09-10 Thread Michael Goldish
This patch adds a control.parallel file that runs several test execution queues
in parallel.

The number of queues is set to the number of CPUs reported by /proc/cpuinfo.
It can be changed by modifying the control file.
The total amount of RAM defaults to 3/4 times what 'free -m' reports.

The scheduler's job is to make sure tests run in parallel only when there are
sufficient resources to allow it.  For example, a test that requires 2 CPUs
will not run together with a test that requires 3 CPUs on a 4 CPU machine.
The same logic applies to RAM.

Note that tests that require more CPUs and/or more RAM than the machine has are
allowed to run alone, e.g. a test that requires 3GB of RAM is allowed to run
on a machine with only 2GB of RAM, but no tests will run in parallel to it.

Currently TAP networking isn't supported by this scheduler because the main MAC
address pool must be divided between the queues (workers).  This should be
straightforward to do but I haven't had the time to do it yet.

scan_results.py can be used to list the test results during and after
execution.

Signed-off-by: Michael Goldish mgold...@redhat.com
---
 client/tests/kvm/control.parallel |  320 +
 1 files changed, 320 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/control.parallel

diff --git a/client/tests/kvm/control.parallel 
b/client/tests/kvm/control.parallel
new file mode 100644
index 000..cec5cee
--- /dev/null
+++ b/client/tests/kvm/control.parallel
@@ -0,0 +1,320 @@
+AUTHOR = 
+u...@redhat.com (Uri Lublin)
+dru...@redhat.com (Dror Russo)
+mgold...@redhat.com (Michael Goldish)
+dh...@redhat.com (David Huff)
+aerom...@redhat.com (Alexey Eromenko)
+mbu...@redhat.com (Mike Burns)
+
+TIME = 'SHORT'
+NAME = 'KVM test'
+TEST_TYPE = 'client'
+TEST_CLASS = 'Virtualization'
+TEST_CATEGORY = 'Functional'
+
+DOC = 
+Executes the KVM test framework on a given host. This module is separated in
+minor functions, that execute different tests for doing Quality Assurance on
+KVM (both kernelspace and userspace) code.
+
+
+
+import sys, os, select, commands, re
+
+#-
+# set English environment (command output might be localized, need to be safe)
+#-
+os.environ['LANG'] = 'en_US.UTF-8'
+
+#-
+# Enable modules import from current directory (tests/kvm)
+#-
+pwd = os.path.join(os.environ['AUTODIR'],'tests/kvm')
+sys.path.append(pwd)
+
+# 
+# create required symlinks
+# 
+# When dispatching tests from autotest-server the links we need do not exist on
+# the host (the client). The following lines create those symlinks. Change
+# 'rootdir' here and/or mount appropriate directories in it.
+#
+# When dispatching tests on local host (client mode) one can either setup kvm
+# links, or same as server mode use rootdir and set all appropriate links and
+# mount-points there. For example, guest installation tests need to know where
+# to find the iso-files.
+#
+# We create the links only if not already exist, so if one already set up the
+# links for client/local run we do not touch the links.
+rootdir='/tmp/kvm_autotest_root'
+iso=os.path.join(rootdir, 'iso')
+images=os.path.join(rootdir, 'images')
+qemu=os.path.join(rootdir, 'qemu')
+qemu_img=os.path.join(rootdir, 'qemu-img')
+
+
+def link_if_not_exist(ldir, target, link_name):
+t = target
+l = os.path.join(ldir, link_name)
+if not os.path.exists(l):
+os.system('ln -s %s %s' % (t, l))
+
+# Create links only if not already exist
+link_if_not_exist(pwd, '../../', 'autotest')
+link_if_not_exist(pwd, iso, 'isos')
+link_if_not_exist(pwd, images, 'images')
+link_if_not_exist(pwd, qemu, 'qemu')
+link_if_not_exist(pwd, qemu_img, 'qemu-img')
+
+# 
+# Params that will be passed to the KVM install/build test
+# 
+params = {
+name: kvm_install,
+shortname: kvm_install,
+type: kvm_install,
+mode: release,
+#mode: snapshot,
+#mode: localtar,
+#mode: localsrc,
+#mode: git,
+#mode: noinstall,
+
+## Are we going to load modules built by this test?
+## Defaults to 'yes', so if you are going to provide only userspace code to
+## be built by this test, please set load_modules to 'no', and make sure
+## the kvm and kvm-[vendor] module is already loaded by the time you start
+## it.
+#load_modules: no,
+
+## Install from a kvm release (mode: release). You can optionally
+## specify a release tag. If you omit it, the test will get the latest
+## release tag available.
+#release_tag: '84',
+release_dir: 'http://downloads.sourceforge.net/kvm/',
+
+##