Re: Very high memory usage with KVM
Hi Daniel! Aug 4 17:38:39 ss03 kernel: [4.750023] bnx2 :03:00.0: firmware: requesting bnx2/bnx2-mips-06-4.6.16.fw Aug 4 17:38:39 ss03 kernel: [4.751070] bnx2: Can't load firmware file "bnx2/bnx2-mips-06-4.6.16.fw" Aug 4 17:38:39 ss03 kernel: [4.751141] bnx2 :03:00.0: PCI INT A disabled Aug 4 17:38:39 ss03 kernel: [4.751167] bnx2: probe of :03:00.0 failed with error -2 Aug 4 17:38:39 ss03 kernel: [4.751244] bnx2 :05:00.0: PCI INT A -> GSI 17 (level, low) -> IRQ 17 Is bnx2.ko loaded by initramfs? Then the initramfs must contain the requested firmware file. Another possibility is to set FIRMWARE_IN_KERNEL in the kernel config. Bernhard -- 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
[KVM-AUTOTEST PATCH 3/3] KVM test: add AutoIt test to kvm_tests.cfg.sample
Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.cfg.sample | 12 +++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 12e907b..05a1ca7 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -126,6 +126,16 @@ variants: kill_vm_gracefully = no extra_params += " -snapshot" +- autoit: install setup +type = autoit +cdrom = windows/autoit.iso +autoit_binary = D:\AutoIt3.exe +autoit_script_timeout = 600 +autoit_script_params = +variants: +- notepad: +autoit_script = autoit/notepad1.au3 + - shutdown: install setup type = shutdown kill_vm = yes @@ -147,7 +157,7 @@ variants: variants: # Linux section - @Linux: -no timedrift +no timedrift autoit shutdown_command = shutdown -h now reboot_command = shutdown -r now status_test_command = echo $? -- 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
[KVM-AUTOTEST PATCH 2/3] KVM test: add sample AutoIt script
Add a sample autoit script under autoit/. The script is a modified version of the notepad1.au3 example script that ships with AutoIt. Signed-off-by: Michael Goldish --- client/tests/kvm/autoit/notepad1.au3 | 44 ++ 1 files changed, 44 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/autoit/notepad1.au3 diff --git a/client/tests/kvm/autoit/notepad1.au3 b/client/tests/kvm/autoit/notepad1.au3 new file mode 100644 index 000..22e4275 --- /dev/null +++ b/client/tests/kvm/autoit/notepad1.au3 @@ -0,0 +1,44 @@ +; This is a sample AutoIt script, based on the notepad1 sample script by Jonathan Bennett. +; It runs notepad, enters some text and exits. + + +; Exit with a nonzero exit status if the parameter equals 0. +; This is useful for functions that return 0 upon failure. +Func Assert($n) + If $n = 0 Then Exit(1) +EndFunc + +; Wait for a window to exist, activate it, and wait for it to become active. +; If timeout expires while waiting, exit with a nonzero exit status. +Func WaitForWindow($title, $text="", $timeout=60) +Assert(WinWait($title, $text, $timeout)) +WinActivate($title, $text) +Assert(WinWaitActive($title, $text, $timeout)) +EndFunc + +; Run Notepad +Assert(Run("notepad.exe")) + +; Wait up to 10 seconds for Notepad to become active -- +; it is titled "Untitled - Notepad" on English systems +WaitForWindow("Untitled - Notepad", "", 10) + +; Now that the Notepad window is active type some text +Send("Hello from Notepad.{ENTER}1 2 3 4 5 6 7 8 9 10{ENTER}") +Sleep(500) +Send("+{UP 2}") +Sleep(500) + +; Now quit by pressing Alt-f and then x (File menu -> Exit) +Send("!f") +Send("x") + +; Now a screen will pop up and ask to save the changes, the window is called +; "Notepad" and has some text "Yes" and "No" +WaitForWindow("Notepad", "", 10) +Send("n") + +; Now wait for Notepad to close before continuing +WinWaitClose("Untitled - Notepad", "", 10) + +; Finished! -- 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
[KVM-AUTOTEST PATCH 1/3] KVM test: add AutoIt test
Currently the test only logs in, runs a given script and fails if the script takes too long to exit or if its exit status is nonzero. The test expects these parameters: autoit_binary: Path to AutoIt binary in the guest. autoit_script: Path to script in the host. autoit_script_params: Command line parameters to send to the script. autoit_script_timeout: The time duration (in seconds) to wait for the script to exit. The test code can be extended later to add more features. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm.py |1 + client/tests/kvm/kvm_tests.py | 66 + 2 files changed, 67 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index 070e463..4930e80 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -56,6 +56,7 @@ class kvm(test.test): "linux_s3": test_routine("kvm_tests", "run_linux_s3"), "stress_boot": test_routine("kvm_tests", "run_stress_boot"), "timedrift":test_routine("kvm_tests", "run_timedrift"), +"autoit": test_routine("kvm_tests", "run_autoit"), } # Make it possible to import modules from the test's bindir diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index 9cd01e2..743652d 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -776,3 +776,69 @@ def run_timedrift(test, params, env): if drift > drift_threshold_after_rest: raise error.TestFail("Time drift too large after rest period: %.2f%%" % drift_total) + + +def run_autoit(test, params, env): +""" +A wrapper for AutoIt scripts. + +1) Log into a guest. +2) Run AutoIt script. +3) Wait for script execution to complete. +4) Pass/fail according to exit status of script. + +@param test: KVM test object. +@param params: Dictionary with test parameters. +@param env: Dictionary with the test environment. +""" +vm = kvm_utils.env_get_vm(env, params.get("main_vm")) +if not vm: +raise error.TestError("VM object not found in environment") +if not vm.is_alive(): +raise error.TestError("VM seems to be dead; Test requires a living VM") + +logging.info("Waiting for guest to be up...") + +session = kvm_utils.wait_for(vm.remote_login, 240, 0, 2) +if not session: +raise error.TestFail("Could not log into guest") + +try: +logging.info("Logged in; starting script...") + +# Collect test parameters +binary = params.get("autoit_binary") +script = params.get("autoit_script") +script_params = params.get("autoit_script_params") +timeout = float(params.get("autoit_script_timeout", 600)) + +# Send AutoIt script to guest (this code will be replaced once we +# support sending files to Windows guests) +session.sendline("del script.au3") +file = open(kvm_utils.get_path(test.bindir, script)) +for line in file.readlines(): +# Insert a '^' before each character +line = "".join("^" + c for c in line.rstrip()) +if line: +# Append line to the file +session.sendline("echo %s>>script.au3" % line) +file.close() + +session.read_nonblocking(0.1) + +command = "cmd /c %s script.au3 %s" % (binary, script_params) + +logging.info(" Script output ") +status = session.get_command_status(command, +print_func=logging.info, +timeout=timeout) +logging.info(" End of script output ") + +if status is None: +raise error.TestFail("Timeout expired before script execution " + "completed (or something weird happened)") +if status != 0: +raise error.TestFail("Script execution failed") + +finally: +session.close() -- 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] KVM test: Make kvm_config.py to use autotest logging
Make kvm_config.py be able to use the autotest logging infrastructure even in stand alone mode. This way we get the ability of having selective debug mode, and just use the cleaner logging.[debuglevel]('message') syntax instead of resorting to hardcoded [LEVEL] strings in any message. Also, make kvm_config use the optparse library to get options. Script usage: Usage: kvm_config.py [options] Options: -h, --help show this help message and exit -f, --file path to a config file that will be parsed. If not specified, will parse kvm_tests.cfg located inside the kvm test dir. --verbose include debug messages in console output Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/control |4 +- client/tests/kvm/kvm_config.py | 58 --- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/client/tests/kvm/control b/client/tests/kvm/control index 5c5d424..f894bf9 100644 --- a/client/tests/kvm/control +++ b/client/tests/kvm/control @@ -73,12 +73,12 @@ params = { "name": "kvm_install", "shortname": "kvm_install", "type": "kvm_install", -"mode": "release", +#"mode": "release", #"mode": "snapshot", #"mode": "localtar", #"mode": "localsrc", #"mode": "git", -#"mode": "noinstall", +"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 diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 7ff7a07..3237276 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -1,7 +1,8 @@ #!/usr/bin/python -import re, os, sys, StringIO +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. @@ -9,6 +10,13 @@ KVM configuration file utility functions. @copyright: Red Hat 2008-2009 """ + +class KvmLoggingConfig(logging_config.LoggingConfig): +def configure_logging(self, results_dir=None, verbose=False): +super(KvmLoggingConfig, self).configure_logging(use_console=True, +verbose=verbose) + + class config: """ Parse an input file or string that follows the KVM Test Config File format @@ -22,7 +30,8 @@ class config: """ Initialize the list and optionally parse filename. -@param filename: Path of the file that will be taken +@param filename: Path of the file that will be taken. +@param debug: Whether to turn debugging output. """ self.list = [{"name": "", "shortname": "", "depend": []}] self.debug = debug @@ -31,15 +40,6 @@ class config: self.parse_file(filename) -def set_debug(self, debug=False): -""" -Enable or disable debugging output. - -@param debug: Whether debug is enabled (True) or disabled (False). -""" -self.debug = debug - - def parse_file(self, filename): """ Parse filename, return the resulting list and store it in .list. If @@ -413,11 +413,11 @@ class config: if self.debug and not restricted: self.__debug_print("", "Leaving file %s" % words[1]) else: -print ("WARNING: Cannot include %s -- " - "file not found" % filename) +logging.warning("Cannot include %s -- file not found", +filename) else: -print ("WARNING: Cannot include %s because no file is " - "currently open" % words[1]) +logging.warning("Cannot include %s because no file is " +"currently open", words[1]) # Parse multi-line exceptions # (the block is parsed for each dict separately) @@ -462,7 +462,7 @@ class config: str = "%-50s ---> %s" % (str1, str2) else: str = str1 -print str +logging.debug(str) def __modify_list_variants(self, list, name, dep_list, add_to_shortname): @@ -515,16 +515,30 @@ class config: if __name__ == "__main__": -if len(sys.argv) >= 2: -filename = sys.argv[1] -else: +parser = optparse.OptionParser() +parser.add_option('-f', '--file', dest="filename", action='store_true', + help='path to a config file that will be parsed. ' + 'If not specified, will parse kvm_tests.cfg ' + 'located inside the kvm test dir.') +parser.add_option('--verbose', dest="debug", action='store_true', + help='include debug message
Re: [PATCHv4 2/2] virtio: refactor find_vqs
On Tue, 28 Jul 2009 06:03:08 pm Michael S. Tsirkin wrote: > On Tue, Jul 28, 2009 at 12:44:31PM +0930, Rusty Russell wrote: > > On Mon, 27 Jul 2009 01:17:09 am Michael S. Tsirkin wrote: > > > This refactors find_vqs, making it more readable and robust, and fixing > > > two regressions from 2.6.30: > > > - double free_irq causing BUG_ON on device removal > > > - probe failure when vq can't be assigned to msi-x vector > > > (reported on old host kernels) > > > > > > An older version of this patch was tested by Amit Shah. > > > > OK, I've applied both of these; I'd like to see a new test by Amit to > > make sure tho. > > > > I really like this cleanup! I looked harder at this code, and my best > > attempts to untangle it further came to very little. This is what I > > ended up with, but it's all cosmetic and can wait until next merge window. > > See what you think. > > > > Thanks! > > Rusty. > > > > virtio_pci: minor MSI-X cleanups > > > > 1) Rename vp_request_vectors to vp_request_msix_vectors, and take > >non-MSI-X case out to caller. > > I'm not sure this change was for the best: we still have a separate code > path under if !use_msix, only in another place now. See below. > And this seems to break the symmetry between request_ and free_vectors. Yes, but unfortunately request_vectors was never really symmetrical :( That's because we didn't do the request_irq's for the per_vector case, because we don't have the names. This is what prevented me from doing a nice encapsulation. > > - err = vp_request_vectors(vdev, nvectors, per_vq_vectors); > > + if (!use_msix) { > > + /* Old style: one normal interrupt for change and all vqs. */ > > + vp_dev->msix_vectors = 0; > > + vp_dev->per_vq_vectors = false; > > + err = request_irq(vp_dev->pci_dev->irq, vp_interrupt, > > + IRQF_SHARED, dev_name(&vdev->dev), vp_dev); > > + if (!err) > > + vp_dev->intx_enabled = 1; > > shorter as vp_dev->intx_enabled = !err > > > + return err; > > Is that all? Don't we need to create the vqs? Oh, yeah :) This patch applies on top. Basically reverts that part, and renames vector to msix_vector, which I think makes the code more readable. virtio: more PCI minor cleanups Signed-off-by: Rusty Russell --- drivers/virtio/virtio_pci.c | 73 +--- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c @@ -84,7 +84,7 @@ struct virtio_pci_vq_info struct list_head node; /* MSI-X vector (or none) */ - unsigned vector; + unsigned msix_vector; }; /* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */ @@ -349,7 +349,7 @@ error: static struct virtqueue *setup_vq(struct virtio_device *vdev, unsigned index, void (*callback)(struct virtqueue *vq), const char *name, - u16 vector) + u16 msix_vector) { struct virtio_pci_device *vp_dev = to_vp_device(vdev); struct virtio_pci_vq_info *info; @@ -374,7 +374,7 @@ static struct virtqueue *setup_vq(struct info->queue_index = index; info->num = num; - info->vector = vector; + info->msix_vector = msix_vector; size = PAGE_ALIGN(vring_size(num, VIRTIO_PCI_VRING_ALIGN)); info->queue = alloc_pages_exact(size, GFP_KERNEL|__GFP_ZERO); @@ -398,10 +398,10 @@ static struct virtqueue *setup_vq(struct vq->priv = info; info->vq = vq; - if (vector != VIRTIO_MSI_NO_VECTOR) { - iowrite16(vector, vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR); - vector = ioread16(vp_dev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR); - if (vector == VIRTIO_MSI_NO_VECTOR) { + if (msix_vector != VIRTIO_MSI_NO_VECTOR) { + iowrite16(msix_vector, vp_dev->ioaddr+VIRTIO_MSI_QUEUE_VECTOR); + msix_vector = ioread16(vp_dev->ioaddr+VIRTIO_MSI_QUEUE_VECTOR); + if (msix_vector == VIRTIO_MSI_NO_VECTOR) { err = -EBUSY; goto out_assign; } @@ -462,7 +462,8 @@ static void vp_del_vqs(struct virtio_dev list_for_each_entry_safe(vq, n, &vdev->vqs, list) { info = vq->priv; if (vp_dev->per_vq_vectors) - free_irq(vp_dev->msix_entries[info->vector].vector, vq); + free_irq(vp_dev->msix_entries[info->msix_vector].vector, +vq); vp_del_vq(vq); } vp_dev->per_vq_vectors = false; @@ -478,58 +479,56 @@ static int vp_try_to_find_vqs(struct vir bool per_vq_vectors) { struct virtio_pci_device
Re: virtio-blk performance and MSI
On Sun, Aug 09, 2009 at 01:01:35PM +0300, Avi Kivity wrote: > On 08/06/2009 07:35 PM, Christoph Hellwig wrote: >> Michael suggested to me a while ago to try MSI with virtio-blk and I >> played with this small patch: >> >> >> Index: qemu-kvm/hw/virtio-blk.c >> === >> --- qemu-kvm.orig/hw/virtio-blk.c >> +++ qemu-kvm/hw/virtio-blk.c >> @@ -416,6 +416,7 @@ VirtIODevice *virtio_blk_init(DeviceStat >> s->vdev.get_config = virtio_blk_update_config; >> s->vdev.get_features = virtio_blk_get_features; >> s->vdev.reset = virtio_blk_reset; >> +s->vdev.nvectors = 2; some whitespace damage btw >> s->bs = bs; >> s->rq = NULL; >> if (strlen(ps = (char *)drive_get_serial(bs))) >> >> which gave about 5% speedups on 4k sized reads and writes, see the full >> iozone output I attached. Now getting the information about using >> multiple MSI vectors from the command line to virtio-blk similar to how >> virtio-net does seems extremly messy right now. Waiting for Gerd's >> additional qdev patches to make it easier as a qdev property. >> >> > > Looks good. Anthony, I think this applies upstream? This applies upstream, but we also need the flag to change # of vectors: for loading old images, but also for troubleshooting. Thus the qdev dependency. -- MST -- 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: [Qemu-devel] Re: virtio-blk performance and MSI
On Sun, Aug 09, 2009 at 09:13:13PM +0200, Christoph Hellwig wrote: > On Sun, Aug 09, 2009 at 08:49:23PM +0300, Avi Kivity wrote: > > Sorry, confused. Upstream doesn't use kvm for msi (everything's done in > > userspace). What exactly blocks us here? > > Hmm, good question. Michael, do you know if we can just enabled > MSI unconditionally in upstream qemu, or are there guests that can't > cope with it? Upstream or not, block should request MSI by default, the code in hw/msi checks that host kernel can support it and only enables when it's safe. And AFAIK all guests can cope with it but only if they are rebooted. So we must have a flag to change the # of vectors, to have ability to load images and migrate from state stored by old qemu. And of course this option is also useful for troubleshooting. -- MST -- 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: [Qemu-devel] Re: virtio-blk performance and MSI
On Sun, Aug 09, 2009 at 07:41:00PM +0200, Christoph Hellwig wrote: > On Sun, Aug 09, 2009 at 01:01:35PM +0300, Avi Kivity wrote: > > Looks good. Anthony, I think this applies upstream? > > This applies upstream, but as mentioned we can't just use it as-is. > We'll very recent kvm kernel support for multiple MSI vectors, and > when the host doesn't have it even 2.6.30 crashes badly in the guest. I think the problems were in qemu-kvm and that they are fixed now. Could you verify please? > -- > 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 -- 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: [Qemu-devel] Re: virtio-blk performance and MSI
On Sun, Aug 09, 2009 at 08:49:23PM +0300, Avi Kivity wrote: > Sorry, confused. Upstream doesn't use kvm for msi (everything's done in > userspace). What exactly blocks us here? Hmm, good question. Michael, do you know if we can just enabled MSI unconditionally in upstream qemu, or are there guests that can't cope with it? -- 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: [Qemu-devel] Re: virtio-blk performance and MSI
On 08/09/2009 08:41 PM, Christoph Hellwig wrote: On Sun, Aug 09, 2009 at 01:01:35PM +0300, Avi Kivity wrote: Looks good. Anthony, I think this applies upstream? This applies upstream, but as mentioned we can't just use it as-is. We'll very recent kvm kernel support for multiple MSI vectors, and when the host doesn't have it even 2.6.30 crashes badly in the guest. Sorry, confused. Upstream doesn't use kvm for msi (everything's done in userspace). What exactly blocks us here? -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. -- 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: [Qemu-devel] Re: virtio-blk performance and MSI
On Sun, Aug 09, 2009 at 01:01:35PM +0300, Avi Kivity wrote: > Looks good. Anthony, I think this applies upstream? This applies upstream, but as mentioned we can't just use it as-is. We'll very recent kvm kernel support for multiple MSI vectors, and when the host doesn't have it even 2.6.30 crashes badly in the guest. -- 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
[ kvm-Bugs-2834538 ] low network speed with Windows virtio NIC drivers
Bugs item #2834538, was opened at 2009-08-09 17:23 Message generated for change (Tracker Item Submitted) made by unki You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=893831&aid=2834538&group_id=180599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Andreas Unterkircher (unki) Assigned to: Nobody/Anonymous (nobody) Summary: low network speed with Windows virtio NIC drivers Initial Comment: Host-CPU: 2x Intel Xeon E5420 (Quad cores) Host: KVM 85 Host: 64-bit Guest: Windows XP (SP3) and Windows 2003 (SP2) We are powering several guests on a KVM host. All of them using TAP interfaces bridged together via one bridge. Within the guests we installed the lasted virtio NIC drivers (from that ISO file). While the Interface status show that the interfaces are set to 1Gbit/s, the maximum bandwidth we can achieve is about 100-120Mbit/s (tested with iperf). Funilly, one the same host, two Debian Lenny guests (so using 2.6.26 with builtin virtio modules) can achieve the full bandwidth of 1Gbit/s and more without a problem. So we suspect that the Windows virtio drivers for the NICs are causing this problem. How can we track down that problem? Can we provide more infos? We are willing to help in debuggig! Thx, Andreas -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=893831&aid=2834538&group_id=180599 -- 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
[KVM-AUTOTEST PATCH 7/7] KVM test: use homemade remote shell server (rss.exe) for all Windows guests
This patch modifies kvm_tests.cfg.sample. 1. It makes all Windows guests use rss.exe, using the new step files and an ISO file named rss.iso, which should be created by the user. rss.iso should contain rss.exe, setuprss.bat and rss.reg. These files are all assumed to be in D:\. 2. Currently WinVista.32, WinVista.64, Win2008.64, Win2003.64 and WinXP.64 can run only the install test. This patch makes them run all available tests, like the other Windows guests. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.cfg.sample | 70 ++--- 1 files changed, 38 insertions(+), 32 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 74901a6..12e907b 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -334,17 +334,16 @@ variants: # Windows section - @Windows: -no autotest +no autotest linux_s3 shutdown_command = shutdown /s /t 0 reboot_command = shutdown /r /t 0 status_test_command = echo %errorlevel% shell_prompt = "C:\\.{0,50}>" -username = Administrator -password = 123456 -shell_client = ssh +shell_client = nc shell_port = 22 -file_transfer_client = scp -file_transfer_port = 22 +# File transfers are currently unsupported +#file_transfer_client = scp +#file_transfer_port = 22 migrate: migration_test_command = ver && vol @@ -378,8 +377,8 @@ variants: md5sum_1m = dd28fba196d366d56fe774bd93df5527 user = user setup: -steps = Win2000-32-setupssh.steps -cdrom = windows/setupssh.iso +steps = Win2000-32-rss.steps +cdrom = windows/rss.iso - WinXP.32: image_name = winXP-32 @@ -390,11 +389,11 @@ variants: md5sum_1m = b473bf75af2d1269fec8958cf0202bfd user = user setup: -steps = WinXP-32-setupssh.steps -cdrom = windows/setupssh.iso +steps = WinXP-32-rss.steps +cdrom = windows/rss.iso - WinXP.64: -only install +no reboot image_name = winXP-64 install: steps = WinXP-64.steps @@ -402,6 +401,9 @@ variants: md5sum = 8d3f007ec9c2060cec8a50ee7d7dc512 md5sum_1m = e812363ff427effc512b7801ee70e513 user = user +setup: +steps = WinXP-64-rss.steps +cdrom = windows/rss.iso - Win2003: image_size = 20G @@ -418,11 +420,10 @@ variants: md5sum_1m = 37c2fdec15ac4ec16aa10fdfdb338aa3 user = user setup: -steps = Win2003-32-setupssh.steps -cdrom = windows/setupssh.iso +steps = Win2003-32-rss.steps +cdrom = windows/rss.iso - 64: -only install image_name = win2003-64 install: steps = Win2003-64.steps @@ -430,37 +431,42 @@ variants: md5sum = 5703f87c9fd77d28c05ffadd3354dbbd md5sum_1m = 439393c384116aa09e08a0ad047dcea8 user = user +setup: +steps = Win2003-64-rss.steps +cdrom = windows/rss.iso - WinVista: -only install image_name = winvista image_size = 20G variants: - 32: image_name += -32 -steps = Win-Vista-32.steps -cdrom = windows/WindowsVista-32.iso -md5sum = 1008f323d5170c8e614e52ccb85c0491 -md5sum_1m = c724e9695da483bc0fd59e426eaefc72 +install: +steps = Win-Vista-32.steps +cdrom = windows/WindowsVista-32.iso +md5sum = 1008f323d5170c8e614e52ccb85c0491 +md5sum_1m = c724e9695da483bc0fd59e426eaefc72 +setup: +steps = WinVista-32-rss.steps +cdrom = windows/rss.iso - 64: image_name += -64 -steps = Win-Vista-64.steps -cdrom = windows/WindowsVista-64.iso -
[KVM-AUTOTEST PATCH 6/7] KVM test: shutdown test: do not close session immediately after shutdown command
If the session is closed immediately after a command is sent, the command may not be executed. To overcome this, first wait for the guest to shut down, and then close the session. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.py | 18 ++ 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index d98dbae..9cd01e2 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -80,18 +80,20 @@ def run_shutdown(test, params, env): if not session: raise error.TestFail("Could not log into guest") -logging.info("Logged in") +try: +logging.info("Logged in") -# Send the VM's shutdown command -session.sendline(vm.get_params().get("shutdown_command")) -session.close() +# Send the VM's shutdown command +session.sendline(vm.get_params().get("shutdown_command")) +logging.info("Shutdown command sent; waiting for guest to go down...") -logging.info("Shutdown command sent; waiting for guest to go down...") +if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1): +raise error.TestFail("Guest refuses to go down") -if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1): -raise error.TestFail("Guest refuses to go down") +logging.info("Guest is down") -logging.info("Guest is down") +finally: +session.close() def run_migration(test, params, env): -- 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
[KVM-AUTOTEST PATCH 5/7] KVM test: stepmaker.py: Do not attempt to use undefined variable 'version'
The version variable is used even though it is no longer defined. This patch fixes this. Signed-off-by: Michael Goldish --- client/tests/kvm/stepmaker.py |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/client/tests/kvm/stepmaker.py b/client/tests/kvm/stepmaker.py index 6f1e6a1..e478350 100644 --- a/client/tests/kvm/stepmaker.py +++ b/client/tests/kvm/stepmaker.py @@ -47,8 +47,7 @@ class StepMaker(stepeditor.StepMakerWindow): self.time_when_done_clicked = time.time() self.time_when_actions_completed = time.time() -self.steps_file.write("# Generated by Step Maker version %s\n" % - version) +self.steps_file.write("# Generated by Step Maker\n") self.steps_file.write("# Generated on %s\n" % time.asctime()) self.steps_file.write("# uname -a: %s\n" % commands.getoutput("uname -a")) -- 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
[KVM-AUTOTEST PATCH 4/7] KVM test: step file tests: do not fail when receiving an invalid screendump
Warn, instead of failing, when receiving an invalid PPM screendump. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_guest_wizard.py | 11 ++- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py index 732e427..4efb0e9 100644 --- a/client/tests/kvm/kvm_guest_wizard.py +++ b/client/tests/kvm/kvm_guest_wizard.py @@ -88,14 +88,15 @@ def barrier_2(vm, words, params, debug_dir, data_scrdump_filename, logging.error("Could not fetch screendump") continue -# Make sure image is valid -if not ppm_utils.image_verify_ppm_file(scrdump_filename): -failure_message = "got invalid screendump" -break - # Read image file (w, h, data) = ppm_utils.image_read_from_ppm_file(scrdump_filename) +# Make sure image is valid +if not ppm_utils.image_verify_ppm_file(scrdump_filename): +logging.warn("Got invalid screendump: dimensions: %dx%d, " + "data size: %d" % (w, h, len(data))) +continue + # Compute md5sum of whole image whole_image_md5sum = ppm_utils.image_md5sum(w, h, data) -- 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
[KVM-AUTOTEST PATCH 3/7] KVM test: Step files to setup the new remote shell server on Windows guests
This patch adds step files for Win2008.32, Win2008.64, WinVista.32, WinVista.64, Win2003.32, Win2003.64, WinXP.32, WinXP.64 and Win2000. I tried to make them as short as possible in order to minimize the chance of failure. This patch also adds the missing shutdown procedure to the end of the Win2008.64 installation step file. All files have been tested and seem to work properly, except Win2008.64, which enters a reboot loop during installation (with several KVM versions). This is not a step file problem, but the step file may contain errors because it couldn't be properly tested. Signed-off-by: Michael Goldish --- client/tests/kvm/steps/Win2000-32-rss.steps | 52 + client/tests/kvm/steps/Win2003-32-rss.steps | 49 +++ client/tests/kvm/steps/Win2003-64-rss.steps | 47 ++ client/tests/kvm/steps/Win2008-32-rss.steps | 49 +++ client/tests/kvm/steps/Win2008-64-rss.steps | 52 + client/tests/kvm/steps/Win2008-64.steps | 30 ++- client/tests/kvm/steps/WinVista-32-rss.steps | 54 ++ client/tests/kvm/steps/WinVista-64-rss.steps | 54 ++ client/tests/kvm/steps/WinXP-32-rss.steps| 31 +++ client/tests/kvm/steps/WinXP-64-rss.steps| 34 10 files changed, 451 insertions(+), 1 deletions(-) create mode 100644 client/tests/kvm/steps/Win2000-32-rss.steps create mode 100644 client/tests/kvm/steps/Win2003-32-rss.steps create mode 100644 client/tests/kvm/steps/Win2003-64-rss.steps create mode 100644 client/tests/kvm/steps/Win2008-32-rss.steps create mode 100644 client/tests/kvm/steps/Win2008-64-rss.steps create mode 100644 client/tests/kvm/steps/WinVista-32-rss.steps create mode 100644 client/tests/kvm/steps/WinVista-64-rss.steps create mode 100644 client/tests/kvm/steps/WinXP-32-rss.steps create mode 100644 client/tests/kvm/steps/WinXP-64-rss.steps diff --git a/client/tests/kvm/steps/Win2000-32-rss.steps b/client/tests/kvm/steps/Win2000-32-rss.steps new file mode 100644 index 000..34fa5f4 --- /dev/null +++ b/client/tests/kvm/steps/Win2000-32-rss.steps @@ -0,0 +1,52 @@ +# +step 43.16 +screendump 20080101_01_5b659c177604f5eefd34042a02463519.ppm +# reached desktop; close "Getting Started" dialog +barrier_2 86 12 120 58 deecf2363bbf8725264e9da8dd7a0c4e 216 +# Sending keys: alt-f4 +key alt-f4 +# +step 45.98 +screendump 20080101_02_e47965a8e2b13c234b2024caaf1cd8d2.ppm +# open start menu +barrier_2 83 62 283 219 34bb8f3f22754e871514abbc5a2d588a 14 +# Sending keys: ctrl-esc +key ctrl-esc +# +step 47.91 +screendump 20080101_03_b7fb19d51b89cb288639f2d528c6dd70.ppm +# run... +barrier_2 100 63 33 383 9f18731457b7d11c50ab92b81642c393 10 +# Sending keys: up up +key up +key up +# +step 49.98 +screendump 20080101_04_e7a3f3fa3157129829c1526b0ad048e9.ppm +barrier_2 43 19 63 389 32d9745c40deacbbed050934ecb22928 10 +# Sending keys: ret +key ret +# +step 53.13 +screendump 20080101_05_34cd11237ca61f9cf23dcacc4fd84826.ppm +# run "d:\setuprss" +barrier_2 53 75 254 306 9234a91426b8d28650cd6d2ddd60c0ff 16 +# Sending keys: d shift-0x27 0x2b s e t u p r s s ret +key d +key shift-0x27 +key 0x2b +key s +key e +key t +key u +key p +key r +key s +key s +key ret +# +step unknown +screendump 20080101_14_e47965a8e2b13c234b2024caaf1cd8d2.ppm +# make sure we're done +sleep 20 +barrier_2 88 65 284 220 8ea5bd06fc592f91cdc322f4ed954469 120 diff --git a/client/tests/kvm/steps/Win2003-32-rss.steps b/client/tests/kvm/steps/Win2003-32-rss.steps new file mode 100644 index 000..a194f6b --- /dev/null +++ b/client/tests/kvm/steps/Win2003-32-rss.steps @@ -0,0 +1,49 @@ +# +step 25.16 +screendump 20080101_01_315f40a7863d9981afc999c525abd698.ppm +barrier_2 48 13 425 231 4da32ca10d3191bc95eba6552c1e3d4d 180 +# Sending keys: ctrl-alt-delete +key ctrl-alt-delete +# +step 27.98 +screendump 20080101_02_9c888fc55dbcff4c54b2c8ca9abea561.ppm +# login +barrier_2 32 11 469 230 3b7b1974fe99ef2ceee9d49e2885253f 30 +# Sending keys: ret +key ret +# +step 40.75 +screendump 20080101_03_b29321f21ff99f7570213c9e53b2806a.ppm +barrier_2 66 45 209 233 f8e61ca0d97b8af750fe7c3451401498 90 +# Sending keys: alt-f4 +key alt-f4 +# +step 43.99 +screendump 20080101_04_4e23508d4bf604e5939c9a715bde4e33.ppm +# run command +barrier_2 63 41 213 229 61e4e55ac2f0bc30a92d141363c1895a 16 +# Sending keys: 0xdc-r +key 0xdc-r +# +step 49.52 +screendump 20080101_06_f959391507e8a2eb9af10a802db56d7e.ppm +# run "d:\setuprss" +barrier_2 261 34 57 307 62d58248f633ce2
[KVM-AUTOTEST PATCH 2/7] KVM test: Batch script that prepares a Windows guest for remote access
setuprss.bat copies rss.exe to C:\, makes it run at startup, disables the firewall, sets a known password for the administrator account, makes it logon automatically, and does some Vista/2008 specific things. The script requires administrator privileges. Usage: setuprss.bat [full path to executable] e.g.: setuptrss.bat D:\rss.exe If used without parameters, rss.exe will be copied from the directory in which setuprss.bat resides. Signed-off-by: Michael Goldish --- client/tests/kvm/deps/rss.reg | 15 +++ client/tests/kvm/deps/setuprss.bat | 19 +++ 2 files changed, 34 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/deps/rss.reg create mode 100644 client/tests/kvm/deps/setuprss.bat diff --git a/client/tests/kvm/deps/rss.reg b/client/tests/kvm/deps/rss.reg new file mode 100644 index 000..b285d40 --- /dev/null +++ b/client/tests/kvm/deps/rss.reg @@ -0,0 +1,15 @@ +Windows Registry Editor Version 5.00 + +[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run] +"Remote Shell Server"="C:\\rss.exe 22" + +[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\winlogon] +"AutoAdminLogon"="1" +"DefaultUserName"="Administrator" +"DefaultPassword"="1q2w3eP" + +[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System] +"EnableLUA"=dword: + +[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows NT\Reliability] +"ShutdownReasonOn"=dword: diff --git a/client/tests/kvm/deps/setuprss.bat b/client/tests/kvm/deps/setuprss.bat new file mode 100644 index 000..1e4b5a7 --- /dev/null +++ b/client/tests/kvm/deps/setuprss.bat @@ -0,0 +1,19 @@ +set rsspath=%1 +if [%1]==[] set rsspath=%~dp0\rss.exe +copy %rsspath% C:\rss.exe + +net user Administrator /active:yes +net user Administrator 1q2w3eP +netsh firewall set opmode disable + +reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "Remote Shell Server" /d "C:\rss.exe 22" /t REG_SZ /f +reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon" /v "AutoAdminLogon" /d "1" /t REG_SZ /f +reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon" /v "DefaultUserName" /d "Administrator" /t REG_SZ /f +reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon" /v "DefaultPassword" /d "1q2w3eP" /t REG_SZ /f +reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /d "0" /t REG_DWORD /f +reg add "HKLM\Software\Policies\Microsoft\Windows NT\Reliability" /v "ShutdownReasonOn" /d "0" /t REG_DWORD /f + +rem Just in case reg.exe is missing (e.g. Windows 2000): +regedit /s %~dp0\rss.reg + +start /B C:\rss.exe -- 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
[KVM-AUTOTEST PATCH 1/7] KVM test: Simple remote shell server for use with Windows guests
This server provides clients with an interactive cmd.exe shell. It uses no encryption or authentication. Usage: rss.exe [port] The default port is 22. Signed-off-by: Michael Goldish --- client/tests/kvm/deps/rss.cpp | 467 + 1 files changed, 467 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/deps/rss.cpp diff --git a/client/tests/kvm/deps/rss.cpp b/client/tests/kvm/deps/rss.cpp new file mode 100644 index 000..29e4957 --- /dev/null +++ b/client/tests/kvm/deps/rss.cpp @@ -0,0 +1,467 @@ +// Simple remote shell server +// Author: Michael Goldish +// Much of the code here was adapted from Microsoft code samples. + +// Usage: rss.exe [port] +// If no port is specified the default is 22. + +#define _WIN32_WINNT 0x0500 + +#include +#include +#include + +#pragma comment(lib, "ws2_32.lib") + +int port = 22; + +HWND hMainWindow = NULL; +HWND hTextBox = NULL; + +struct client_info { +SOCKET socket; +sockaddr_in addr; +int pid; +HANDLE hJob; +HANDLE hChildOutputRead; +HANDLE hChildInputWrite; +HANDLE hThreadChildToSocket; +}; + +void ExitOnError(char *message, BOOL winsock = 0) +{ +LPVOID system_message; +char buffer[512]; + +int error_code; +if (winsock) +error_code = WSAGetLastError(); +else +error_code = GetLastError(); + +WSACleanup(); + +FormatMessage( +FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, +NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), +(LPTSTR)&system_message, 0, NULL); + +sprintf(buffer, +"%s!\n" +"Error code = %d\n" +"Error message = %s", +message, error_code, (char *)system_message); + +MessageBox(hMainWindow, buffer, "Error", MB_OK | MB_ICONERROR); + +LocalFree(system_message); +ExitProcess(1); +} + +void AppendMessage(char *message) +{ +int length = GetWindowTextLength(hTextBox); +SendMessage(hTextBox, EM_SETSEL, (WPARAM)length, (LPARAM)length); +SendMessage(hTextBox, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)message); +} + +void FormatStringForPrinting(char *dst, char *src, int size) +{ +int j = 0; + +for (int i = 0; i < size && src[i]; i++) { +if (src[i] == '\n') { +dst[j++] = '\\'; +dst[j++] = 'n'; +} else if (src[i] == '\r') { +dst[j++] = '\\'; +dst[j++] = 'r'; +} else if (src[i] == '\t') { +dst[j++] = '\\'; +dst[j++] = 't'; +} else if (src[i] == '\\') { +dst[j++] = '\\'; +dst[j++] = '\\'; +} else dst[j++] = src[i]; +} +dst[j] = 0; +} + +char* GetClientIPAddress(client_info *ci) +{ +char *address = inet_ntoa(ci->addr.sin_addr); +if (address) +return address; +else +return "unknown"; +} + +DWORD WINAPI ChildToSocket(LPVOID client_info_ptr) +{ +char buffer[1024], message[1024]; +client_info ci; +DWORD bytes_read; +int bytes_sent; + +memcpy(&ci, client_info_ptr, sizeof(ci)); + +while (1) { +// Read data from the child's STDOUT/STDERR pipes +if (!ReadFile(ci.hChildOutputRead, + buffer, sizeof(buffer), + &bytes_read, NULL) || !bytes_read) { +if (GetLastError() == ERROR_BROKEN_PIPE) +break; // Pipe done -- normal exit path +else +ExitOnError("ReadFile failed"); // Something bad happened +} +// Send data to the client +bytes_sent = send(ci.socket, buffer, bytes_read, 0); +/* +// Make sure all the data was sent +if (bytes_sent != bytes_read) { +sprintf(message, +"ChildToSocket: bytes read (%d) != bytes sent (%d)", +bytes_read, bytes_sent); +ExitOnError(message, 1); +} +*/ +} + +AppendMessage("Child exited\r\n"); +shutdown(ci.socket, SD_BOTH); + +return 0; +} + +DWORD WINAPI SocketToChild(LPVOID client_info_ptr) +{ +char buffer[256], formatted_buffer[768]; +char message[1024], client_info_str[256]; +client_info ci; +DWORD bytes_written; +int bytes_received; + +memcpy(&ci, client_info_ptr, sizeof(ci)); + +sprintf(client_info_str, "address %s, port %d", +GetClientIPAddress(&ci), ci.addr.sin_port); + +sprintf(message, "New client connected (%s)\r\n", client_info_str); +AppendMessage(message); + +while (1) { +// Receive data from the socket +ZeroMemory(buffer, sizeof(buffer)); +bytes_received = recv(ci.socket, buffer, sizeof(buffer), 0); +if (bytes_received <= 0) +break; +// Report the data received +FormatStringForPrinting(formatted_buffer, buffer, sizeof(buffer)); +sprintf(message, "Client (%s) entered text: \"%s\"\r\n", +client_info_str, formatted_buffer
[KVM-AUTOTEST PATCH 0/7] KVM test: support for the new remote shell server for Windows
This patch set adds the source code of rss.exe as well as a batch file that prepares Windows guests for remote access (using rss.exe). It adds 3 files under deps/ dir: rss.cpp, setuprss.bat and rss.reg. The latter is required for Windows 2000 which seems to lack the reg command. This set also adds steps files to setup rss.exe on all Windows guests. It also contains a few small fixes which are somewhat unrelated but are needed for the step files to function properly. -- 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: [RFC PATCH v2 19/19] virtio: add a vbus transport
Gregory Haskins wrote: We add a new virtio transport for accessing backends located on vbus. This complements the existing transports for virtio-pci, virtio-s390, and virtio-lguest that already exist. Signed-off-by: Gregory Haskins Very interesting... I'm somewhat confused by what you're advocating vbus as. I'm trying to figure out how we converge vbus and virtio and become one big happy family :-) What parts of it do you think are better than virtio? Should we forget about venet and just focus on virtio-net on top of virtio-vbus assuming that we can prove venet-tap/virtio-vbus/virtio-net is just as good as venet-tap/vbus/venet? If we can prove that an in-kernel virtio-net backend/virtio-pci/virtio-net does just as well as venet-tap/virtio-vbus/virtio-net does that mean that vbus is no longer needed? If you concede that the transport mechanisms can be identical, are you really advocating the discovering and configuration mechanisms in vbus? Is that what we should be focusing on? Do you care only about the host mechanisms or do you also require the guest infrastructure to be present? I think two paravirtual I/O frameworks for KVM is a bad thing. It duplicates a ton of code and will very likely lead to user unhappiness. Regards, Anthony Liguori -- 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
[KVM-AUTOTEST PATCH] KVM test: kvm_subprocess: make is_alive() much shorter
Use a much shorter and simpler is_alive() instead of the current one. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_subprocess.py | 25 + 1 files changed, 1 insertions(+), 24 deletions(-) diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py index 41b9d80..dcb20cc 100644 --- a/client/tests/kvm/kvm_subprocess.py +++ b/client/tests/kvm/kvm_subprocess.py @@ -214,8 +214,6 @@ class kvm_spawn: # Wait for the server to complete its initialization while not "Server %s ready" % self.id in sub.stdout.readline(): pass -# Remember the start time for is_alive() -self.start_time = time.time() # Open the reading pipes self.reader_fds = {} @@ -366,28 +364,7 @@ class kvm_spawn: """ Return True if the process is running. """ -pid = self.get_shell_pid() -# See if the PID exists -try: -os.kill(pid, 0) -except: -return False -# Make sure the PID belongs to the original process -filename = "/proc/%d/cmdline" % pid -try: -file = open(filename, "r") -cmdline = file.read() -file.close() -except: -# If we couldn't find the file for some reason, skip the check -return True -# If this process is new (less than 10 secs old) skip the check -if hasattr(self, "start_time") and time.time() < self.start_time + 10: -return True -# Perform the check -if self.id in cmdline: -return True -return False +return _locked(self.lock_server_running_filename) def close(self, sig=signal.SIGTERM): -- 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
[KVM-AUTOTEST PATCH 6/6] KVM test: allow the user to specify the paths of the qemu and qemu-img binaries
Currently, qemu and qemu-img are accessed via symlinks that must be present in test.bindir (the KVM test dir). This patch adds new parameters qemu_binary and qemu_img_binary, which specify the paths of the qemu and qemu-img binaries. They may be absolute paths or relative to test.bindir (the KVM test dir). In kvm_tests.cfg.sample they are set to 'qemu' and 'qemu-img', which means the binaries are expected to be found in test.bindir, which is the current behavior. Adding these parameters results in slightly cleaner code, but also allows for some more flexibility in defining tests. For example, the user can 'variant' on the parameter qemu_binary, i.e. define several variants of a test set that differ only in this parameter. This will make the test set run several times, each time using a different pre-installed version of qemu. The parameters also make it possible to use pre-installed qemu and qemu-img that reside somewhere outside the Autotest dir, e.g. in /usr/bin. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_preprocessing.py | 18 +++--- client/tests/kvm/kvm_tests.cfg.sample |2 ++ client/tests/kvm/kvm_vm.py| 33 ++--- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 17a82f4..7c16305 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -12,7 +12,6 @@ def preprocess_image(test, params): @param params: A dict containing image preprocessing parameters. @note: Currently this function just creates an image if requested. """ -qemu_img_path = os.path.join(test.bindir, "qemu-img") image_filename = kvm_vm.get_image_filename(params, test.bindir) create_image = False @@ -20,13 +19,13 @@ def preprocess_image(test, params): if params.get("force_create_image") == "yes": logging.debug("'force_create_image' specified; creating image...") create_image = True -elif params.get("create_image") == "yes" and not \ -os.path.exists(image_filename): +elif (params.get("create_image") == "yes" and not + os.path.exists(image_filename)): logging.debug("Creating image...") create_image = True if create_image: -if not kvm_vm.create_image(params, qemu_img_path, test.bindir): +if not kvm_vm.create_image(params, test.bindir): message = "Could not create image" logging.error(message) raise error.TestError(message) @@ -42,16 +41,13 @@ def preprocess_vm(test, params, env, name): @param env: The environment (a dict-like object). @param name: The name of the VM object. """ -qemu_path = os.path.join(test.bindir, "qemu") - logging.debug("Preprocessing VM '%s'..." % name) vm = kvm_utils.env_get_vm(env, name) if vm: logging.debug("VM object found in environment") else: logging.debug("VM object does not exist; creating it") -vm = kvm_vm.VM(name, params, qemu_path, test.bindir, - env.get("address_cache")) +vm = kvm_vm.VM(name, params, test.bindir, env.get("address_cache")) kvm_utils.env_register_vm(env, name, vm) start_vm = False @@ -70,14 +66,13 @@ def preprocess_vm(test, params, env, name): logging.debug("VM is not alive; starting it...") start_vm = True elif vm.make_qemu_command() != vm.make_qemu_command(name, params, -qemu_path, test.bindir): logging.debug("VM's qemu command differs from requested one; " "restarting it...") start_vm = True if start_vm: -if not vm.create(name, params, qemu_path, test.bindir, for_migration): +if not vm.create(name, params, test.bindir, for_migration): message = "Could not start VM" logging.error(message) raise error.TestError(message) @@ -247,7 +242,8 @@ def preprocess(test, params, env): # Get the KVM userspace version and write it as a keyval logging.debug("Fetching KVM userspace version...") -qemu_path = os.path.join(test.bindir, "qemu") +qemu_path = kvm_utils.get_path(test.bindir, params.get("qemu_binary", + "qemu")) version_line = commands.getoutput("%s -help | head -n 1" % qemu_path) exp = re.compile("[Vv]ersion .*?,") match = exp.search(version_line) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index baebd64..74901a6 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -15,6 +15,8 @@ kill_vm = no kill_vm_gracefully = yes # Some default VM params +qemu_binary = qemu +qemu_im
[KVM-AUTOTEST PATCH 5/6] KVM test: treat all user specified paths equally
(This patch breaks compatibility with existing config files.) The user must now specify paths relative to test.bindir whenever a path is required. For example, image filenames specified in the config file should now begin with 'images/', cdrom filenames should begin with 'isos/' and stepfile filenames should begin with 'steps/'. This patch modifies kvm_vm.py, kvm_preprocessing.py, kvm_guest_wizard.py, stepmaker.py and and kvm_tests.cfg.sample. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_guest_wizard.py |2 +- client/tests/kvm/kvm_preprocessing.py | 21 ++- client/tests/kvm/kvm_tests.cfg.sample |5 ++ client/tests/kvm/kvm_vm.py| 106 - client/tests/kvm/stepmaker.py |2 +- 5 files changed, 51 insertions(+), 85 deletions(-) diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py index 73b830e..732e427 100644 --- a/client/tests/kvm/kvm_guest_wizard.py +++ b/client/tests/kvm/kvm_guest_wizard.py @@ -185,7 +185,7 @@ def run_steps(test, params, env): steps_filename = params.get("steps") if not steps_filename: raise error.TestError("Steps filename not specified") -steps_filename = os.path.join(test.bindir, "steps", steps_filename) +steps_filename = kvm_utils.get_path(test.bindir, steps_filename) if not os.path.exists(steps_filename): raise error.TestError("Steps file not found: %s" % steps_filename) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index a5a32dc..17a82f4 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -13,8 +13,7 @@ def preprocess_image(test, params): @note: Currently this function just creates an image if requested. """ qemu_img_path = os.path.join(test.bindir, "qemu-img") -image_dir = os.path.join(test.bindir, "images") -image_filename = kvm_vm.get_image_filename(params, image_dir) +image_filename = kvm_vm.get_image_filename(params, test.bindir) create_image = False @@ -27,7 +26,7 @@ def preprocess_image(test, params): create_image = True if create_image: -if not kvm_vm.create_image(params, qemu_img_path, image_dir): +if not kvm_vm.create_image(params, qemu_img_path, test.bindir): message = "Could not create image" logging.error(message) raise error.TestError(message) @@ -44,9 +43,6 @@ def preprocess_vm(test, params, env, name): @param name: The name of the VM object. """ qemu_path = os.path.join(test.bindir, "qemu") -image_dir = os.path.join(test.bindir, "images") -iso_dir = os.path.join(test.bindir, "isos") -script_dir = test.bindir logging.debug("Preprocessing VM '%s'..." % name) vm = kvm_utils.env_get_vm(env, name) @@ -54,7 +50,7 @@ def preprocess_vm(test, params, env, name): logging.debug("VM object found in environment") else: logging.debug("VM object does not exist; creating it") -vm = kvm_vm.VM(name, params, qemu_path, image_dir, iso_dir, script_dir, +vm = kvm_vm.VM(name, params, qemu_path, test.bindir, env.get("address_cache")) kvm_utils.env_register_vm(env, name, vm) @@ -75,16 +71,13 @@ def preprocess_vm(test, params, env, name): start_vm = True elif vm.make_qemu_command() != vm.make_qemu_command(name, params, qemu_path, -image_dir, -iso_dir, -script_dir): +test.bindir): logging.debug("VM's qemu command differs from requested one; " "restarting it...") start_vm = True if start_vm: -if not vm.create(name, params, qemu_path, image_dir, iso_dir, - script_dir, for_migration): +if not vm.create(name, params, qemu_path, test.bindir, for_migration): message = "Could not start VM" logging.error(message) raise error.TestError(message) @@ -101,10 +94,8 @@ def postprocess_image(test, params): @param test: An Autotest test object. @param params: A dict containing image postprocessing parameters. """ -image_dir = os.path.join(test.bindir, "images") - if params.get("remove_image") == "yes": -kvm_vm.remove_image(params, image_dir) +kvm_vm.remove_image(params, test.bindir) def postprocess_vm(test, params, env, name): diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 8238f3e..baebd64 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -634,5 +
[KVM-AUTOTEST PATCH 4/6] KVM test: allow for regex matching of keys in the config parser
Allow for statements with the following syntax: regex ?= value (set) regex ?+= value(append) regex ?<= value(prepend) These operations are performed only for keys that match regex. The whole key name must match the expression, so if regex is a regular string, only the key whose name equals this string is modified. This is useful for modifying all parameters of a certain type regardless of the objects they apply to. For example, the following parameters specify the cdrom filenames for different objects: cdrom_vm1, cdrom_vm2, cdrom. It is now possible to modify all of them with a statement such cdrom.* ?<= shared_ which would prepend the string 'shared_' to all cdrom filenames. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_config.py | 34 +++--- 1 files changed, 23 insertions(+), 11 deletions(-) diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 7ff7a07..b7bddbd 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -316,20 +316,32 @@ class config: for filter in filters: filtered_list = self.filter(filter, filtered_list) # Apply the operation to the filtered list -for dict in filtered_list: -if op_found == "=": +if op_found == "=": +for dict in filtered_list: dict[key] = value -elif op_found == "+=": +elif op_found == "+=": +for dict in filtered_list: dict[key] = dict.get(key, "") + value -elif op_found == "<=": +elif op_found == "<=": +for dict in filtered_list: dict[key] = value + dict.get(key, "") -elif op_found.startswith("?") and dict.has_key(key): -if op_found == "?=": -dict[key] = value -elif op_found == "?+=": -dict[key] = dict.get(key, "") + value -elif op_found == "?<=": -dict[key] = value + dict.get(key, "") +elif op_found.startswith("?"): +exp = re.compile("^(%s)$" % key) +if op_found == "?=": +for dict in filtered_list: +for key in dict.keys(): +if exp.match(key): +dict[key] = value +elif op_found == "?+=": +for dict in filtered_list: +for key in dict.keys(): +if exp.match(key): +dict[key] = dict.get(key, "") + value +elif op_found == "?<=": +for dict in filtered_list: +for key in dict.keys(): +if exp.match(key): +dict[key] = value + dict.get(key, "") # Parse 'no' and 'only' statements elif words[0] == "no" or words[0] == "only": -- 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
[KVM-AUTOTEST PATCH 3/6] KVM test: add a function that translates user specified paths to real ones
If a user specified path is an absolute one, it is returned as is. If it's relative, it's appended to a certain base path. This function is meant to allow framework and test code to treat all user specified paths equally. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_utils.py | 15 +++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 4c4753b..5e9e90d 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -677,6 +677,21 @@ def find_free_ports(start_port, end_port, count): # The following are miscellaneous utility functions. +def get_path(base_path, user_path): +""" +Translate a user specified path to a real path. +If user_path is relative, append it to base_path. +If user_path is absolute, return it as is. + +@param base_path: The base path of relative user specified paths. +@param user_path: The user specified path. +""" +if os.path.isabs(user_path): +return user_path +else: +return os.path.join(base_path, user_path) + + def generate_random_string(length): """ Return a random string using alphanumeric characters. -- 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
[KVM-AUTOTEST PATCH 1/6] KVM test: rename SSH related parameters and functions and add new ones
(This patch breaks compatibility with existing config files.) We now support both SSH and Telnet for communicating with guests, and will soon use Netcat as well. It makes no sense to keep 'ssh' in the names of many remote shell related functions and parameters. Therefore the following renaming was performed: Functions: ssh_login -> remote_login scp_to_remote -> copy_files_to scp_from_remote -> copy_files_from Config parameters: ssh_port -> shell_port guest_port_ssh -> guest_port_remote_shell ssh_prompt -> shell_prompt ssh_status_test_command -> status_test_command cmd_shutdown -> shutdown_command cmd_reboot -> reboot_command Also, new parameters were added: shell_client (ssh, telnet or nc) file_transfer_client (currently only scp) file_transfer_port The parameter use_telnet was removed, as well as the function VM.ssh(). Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.cfg.sample | 47 - client/tests/kvm/kvm_tests.py | 52 +++--- client/tests/kvm/kvm_utils.py | 26 --- client/tests/kvm/kvm_vm.py| 121 - 4 files changed, 127 insertions(+), 119 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 3a4bf64..8238f3e 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -17,12 +17,12 @@ kill_vm_gracefully = yes # Some default VM params mem = 512 image_size = 10G -ssh_port = 22 +shell_port = 22 display = vnc # Port redirections -redirs = ssh -guest_port_ssh = 22 +redirs = remote_shell +guest_port_remote_shell = 22 # NIC parameters nic_mode = tap @@ -146,16 +146,20 @@ variants: # Linux section - @Linux: no timedrift -cmd_shutdown = shutdown -h now -cmd_reboot = shutdown -r now -ssh_status_test_command = echo $? +shutdown_command = shutdown -h now +reboot_command = shutdown -r now +status_test_command = echo $? username = root password = 123456 +shell_client = ssh +shell_port = 22 +file_transfer_client = scp +file_transfer_port = 22 variants: - Fedora: no setup -ssh_prompt = "\[r...@.{0,50}][\#\$] " +shell_prompt = "\[r...@.{0,50}][\#\$] " variants: - 8.32: @@ -237,7 +241,7 @@ variants: md5sum_1m = 768ca32503ef92c28f2d144f2a87e4d0 - @Ubuntu: -ssh_prompt = "r...@.{0,50}[\#\$] " +shell_prompt = "r...@.{0,50}[\#\$] " variants: - Ubuntu-6.10-32: @@ -269,7 +273,7 @@ variants: - RHEL: no setup -ssh_prompt = "\[r...@.{0,50}][\#\$] " +shell_prompt = "\[r...@.{0,50}][\#\$] " variants: - 5.3.i386: @@ -329,12 +333,17 @@ variants: # Windows section - @Windows: no autotest -cmd_shutdown = shutdown /s /t 0 -cmd_reboot = shutdown /r /t 0 -ssh_prompt = "C:\\.{0,50}>" -ssh_status_test_command = echo %errorlevel% +shutdown_command = shutdown /s /t 0 +reboot_command = shutdown /r /t 0 +status_test_command = echo %errorlevel% +shell_prompt = "C:\\.{0,50}>" username = Administrator password = 123456 +shell_client = ssh +shell_port = 22 +file_transfer_client = scp +file_transfer_port = 22 + migrate: migration_test_command = ver && vol stress_boot: @@ -394,8 +403,8 @@ variants: - Win2003: image_size = 20G -cmd_shutdown = shutdown /s /f /t 0 -cmd_reboot = shutdown /r /f /t 0 +shutdown_command = shutdown /s /f /t 0 +reboot_command = shutdown /r /f /t 0 variants: - 32: @@ -443,10 +452,10 @@ variants: - Win2008: image_name = win2008 image_size = 20G -cmd_shutdown = shutdown /s /f /t 0 -cmd_reboot = shutdown /r /f /t 0 -ssh_port = 23 -guest_port_ssh = 23 +shutdown_command = shutdown /s /f /t 0 +reboot_command = shutdown /r /f /t 0 +shell_port = 23 +guest_port_remote_shell = 23 use_telnet = yes username = Administrator password = 1q2w3eP diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index d146929..3fa0837 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -29,7 +29,7 @@ def run_boot(test, params, env): logging.info("Waiting for guest to be up...") -session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2
[KVM-AUTOTEST PATCH 2/6] KVM test: support Netcat as a remote shell client
This is useful for Windows guests that will use the homemade remote shell server. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_utils.py | 17 + client/tests/kvm/kvm_vm.py|3 +++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index d1c9781..4c4753b 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -562,6 +562,23 @@ def telnet(host, port, username, password, prompt, timeout=10): return remote_login(command, password, prompt, "\r\n", timeout) +def netcat(host, port, username, password, prompt, timeout=10): +""" +Log into a remote host (guest) using Netcat. + +@param host: Hostname or IP address +@param username: Username (if required) +@param password: Password (if required) +@param prompt: Shell prompt (regular expression) +@timeout: Time in seconds that we will wait before giving up on logging +into the host. + +@return: kvm_spawn object on success and None on failure. +""" +command = "nc %s %s" % (host, port) +return remote_login(command, password, prompt, "\n", timeout) + + # The following are utility functions related to ports. def is_sshd_running(host, port, timeout=10.0): diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 4a862bd..7bc3d75 100644 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -727,6 +727,9 @@ class VM: elif client == "telnet": session = kvm_utils.telnet(address, port, username, password, prompt, timeout) +elif client == "nc": +session = kvm_utils.netcat(address, port, username, password, + prompt, timeout) if session: session.set_status_test_command(self.params.get("status_test_" -- 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
[KVM-AUTOTEST PATCH 0/6] KVM test: configuration interface changes
This patch set modifies the names and functionality of several config parameters and adds new ones. It also adds support for Netcat as a remote shell client. It breaks compatibility with existing test configurations. -- 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
virDomainCreateLinux() failed QEMU quit during console startup bind() failed
Hi, Please help me with the creation of new Virtual m/c on Ubuntu 8.04.3 over KVM on top of 2.6.24-24-generic  Kernel. This is a Dell m/c. I am using Fedora 8 ISO image as the virtual OS. Following is the error: Unable to complete install ' virDomainCreateLinux() failed QEMU quit during console startup bind() failed Traceback (most recent call last):  File "/usr/share/virt-manager/ virtManager/create.py", line 620, in do_install    dom = guest.start_install(False, meter = meter)  File "/usr/lib/python2.5/site-packages/virtinst/Guest.py", line 820, in start_install    return self._do_install(consolecb, meter)  File "/usr/lib/python2.5/site-packages/virtinst/Guest.py", line 841, in _do_install    self.domain = self.conn.createLinux(install_xml, 0)  File "/usr/lib/python2.5/site-packages/libvirt.py", line 585, in createLinux    if ret is None:raise libvirtError('virDomainCreateLinux() failed', conn=self) libvirtError: virDomainCreateLinux() failed QEMU quit during console startup bind() failed ' Appreciate any pointers :) Regards, Kris -- 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: [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
On 08/09/2009 06:14 PM, Gleb Natapov wrote: We don't have many users of the old interface now. So what I propose is to retain old interface for use with old binaries, but limit the number of GSI entries to small number. New code should use new interface. Still, we complicate the interface for userspace. Correct sharing is not the problem, but two levels of indirection still is (one indirection is to find list element another is to call function by pointer). irqfd can cache the entries locally if it proves to be a problem. -- 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
Re: [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
On Sun, Aug 09, 2009 at 06:14:32PM +0300, Avi Kivity wrote: > On 08/09/2009 06:07 PM, Gleb Natapov wrote: >>> It's still an "install handle, call handle" interface. Maybe it would >>> have been better to start off with your new interface, but having both >>> is too much for too little gain. >>> >>> >> Is it not too late to change interface? There was no released kernel with >> irqfd yet. And this just adds another level of indirection and one more >> point of false cache sharing. >> > > No irqfd, but we do have irq routing. The sharing isn't a problem since > it's read only. > We don't have many users of the old interface now. So what I propose is to retain old interface for use with old binaries, but limit the number of GSI entries to small number. New code should use new interface. Correct sharing is not the problem, but two levels of indirection still is (one indirection is to find list element another is to call function by pointer). -- Gleb. -- 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: [PATCH 08/10] Move IO APIC to its own lock.
On Sun, Aug 09, 2009 at 06:10:07PM +0300, Avi Kivity wrote: > On 08/09/2009 05:57 PM, Gleb Natapov wrote: >> On Sun, Aug 09, 2009 at 05:54:30PM +0300, Avi Kivity wrote: >> >>> On 08/09/2009 03:41 PM, Gleb Natapov wrote: >>> Introduce new function kvm_notifier_set_irq() that should be used to change irq line level from irq notifiers. When irq notifier change irq line level it calls into irq chip code recursively. The function avoids taking a lock recursively. >>> This looks really horrible. I don't have an alternative yet, but I'll >>> think of one. >>> >> I agree this is not nice. This is needed only for device assignment >> case. That explains why I don't like device assignment :) > > Well, implementation problems can be fixed. Other issues with device > assignment cannot. > >> The problem >> is that the only communication channel from guest to assigned device that >> goes through the host is interrupt injection/acknowledgement, so we try to >> do things (lowering IRQ) on this path that usually are done somewhere else. >> > > You can queue the injection somehow (work struct? special purpose queue > examined after unlock?) and avoid the recursive locking. > We can't. Line status should be update here and now. Otherwise interrupt will be immediately reinjected. -- Gleb. -- 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: [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
On 08/09/2009 06:07 PM, Gleb Natapov wrote: It's still an "install handle, call handle" interface. Maybe it would have been better to start off with your new interface, but having both is too much for too little gain. Is it not too late to change interface? There was no released kernel with irqfd yet. And this just adds another level of indirection and one more point of false cache sharing. No irqfd, but we do have irq routing. The sharing isn't a problem since it's read only. -- 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
Re: [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
On Sun, Aug 09, 2009 at 06:01:15PM +0300, Avi Kivity wrote: > On 08/09/2009 05:52 PM, Gleb Natapov wrote: >> On Sun, Aug 09, 2009 at 05:56:30PM +0300, Avi Kivity wrote: >> >>> On 08/09/2009 03:41 PM, Gleb Natapov wrote: >>> Sending of MSI using IRQ routing is an artificial concept and potentially big number of MSIs (2048 per device) make it also inefficient. This patch adds an interface to inject MSI messages from userspace to lapic logic directly. The patch also reduces the maximum number of IRQ routing entries to 128 since MSIs will no longer go there and 128 entries cover 5 ioapics and this ought to be enough for anybody. >>> In the future many MSIs will be triggered via irqfds, and those >>> require irq routing. >>> >>> >> Why? My plan is to change irqfd to use the MSI functions. >> >> > > It's still an "install handle, call handle" interface. Maybe it would > have been better to start off with your new interface, but having both > is too much for too little gain. > Is it not too late to change interface? There was no released kernel with irqfd yet. And this just adds another level of indirection and one more point of false cache sharing. -- Gleb. -- 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: [PATCH 08/10] Move IO APIC to its own lock.
On 08/09/2009 05:57 PM, Gleb Natapov wrote: On Sun, Aug 09, 2009 at 05:54:30PM +0300, Avi Kivity wrote: On 08/09/2009 03:41 PM, Gleb Natapov wrote: Introduce new function kvm_notifier_set_irq() that should be used to change irq line level from irq notifiers. When irq notifier change irq line level it calls into irq chip code recursively. The function avoids taking a lock recursively. This looks really horrible. I don't have an alternative yet, but I'll think of one. I agree this is not nice. This is needed only for device assignment case. That explains why I don't like device assignment :) Well, implementation problems can be fixed. Other issues with device assignment cannot. The problem is that the only communication channel from guest to assigned device that goes through the host is interrupt injection/acknowledgement, so we try to do things (lowering IRQ) on this path that usually are done somewhere else. You can queue the injection somehow (work struct? special purpose queue examined after unlock?) and avoid the recursive locking. -- 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
Re: [PATCH 08/10] Move IO APIC to its own lock.
On Sun, Aug 09, 2009 at 05:54:30PM +0300, Avi Kivity wrote: > On 08/09/2009 03:41 PM, Gleb Natapov wrote: >> Introduce new function kvm_notifier_set_irq() that should be used >> to change irq line level from irq notifiers. When irq notifier >> change irq line level it calls into irq chip code recursively. The >> function avoids taking a lock recursively. >> > > This looks really horrible. I don't have an alternative yet, but I'll > think of one. I agree this is not nice. This is needed only for device assignment case. That explains why I don't like device assignment :) The problem is that the only communication channel from guest to assigned device that goes through the host is interrupt injection/acknowledgement, so we try to do things (lowering IRQ) on this path that usually are done somewhere else. -- Gleb. -- 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: [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
On 08/09/2009 05:52 PM, Gleb Natapov wrote: On Sun, Aug 09, 2009 at 05:56:30PM +0300, Avi Kivity wrote: On 08/09/2009 03:41 PM, Gleb Natapov wrote: Sending of MSI using IRQ routing is an artificial concept and potentially big number of MSIs (2048 per device) make it also inefficient. This patch adds an interface to inject MSI messages from userspace to lapic logic directly. The patch also reduces the maximum number of IRQ routing entries to 128 since MSIs will no longer go there and 128 entries cover 5 ioapics and this ought to be enough for anybody. In the future many MSIs will be triggered via irqfds, and those require irq routing. Why? My plan is to change irqfd to use the MSI functions. It's still an "install handle, call handle" interface. Maybe it would have been better to start off with your new interface, but having both is too much for too little gain. -- 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
Re: [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
On Sun, Aug 09, 2009 at 05:56:30PM +0300, Avi Kivity wrote: > On 08/09/2009 03:41 PM, Gleb Natapov wrote: > >Sending of MSI using IRQ routing is an artificial concept and potentially > >big number of MSIs (2048 per device) make it also inefficient. This > >patch adds an interface to inject MSI messages from userspace to lapic > >logic directly. The patch also reduces the maximum number of IRQ routing > >entries to 128 since MSIs will no longer go there and 128 entries cover > >5 ioapics and this ought to be enough for anybody. > > In the future many MSIs will be triggered via irqfds, and those > require irq routing. > Why? My plan is to change irqfd to use the MSI functions. -- Gleb. -- 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: [PATCH 07/10] Move irq notifiers lists to its own locking.
On 08/09/2009 05:49 PM, Gleb Natapov wrote: On Sun, Aug 09, 2009 at 05:52:30PM +0300, Avi Kivity wrote: On 08/09/2009 03:41 PM, Gleb Natapov wrote: Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h |1 + virt/kvm/irq_comm.c | 16 virt/kvm/kvm_main.c |1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ce28cb7..8791ce8 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -178,6 +178,7 @@ struct kvm { spinlock_t irq_routing_lock; struct hlist_head mask_notifier_list; struct hlist_head irq_ack_notifier_list; + spinlock_t irq_notifier_list_lock; Again, why? Because later patches remove irq_lock entirely and lock is need for write even with rcu. So instead of reusing irq_lock to protect those structures on write I introduce locks with self descriptive names. I prefer a /* protected by irq_lock */ rather than lock proliferation. Locks should be split only if they are contended, and your rcu work removes any possible contention. -- 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
Re: [Autotest] [PATCH] KVM test: Make kvm_config.py to use autotest logging
- "Lucas Meneghel Rodrigues" wrote: > On Sat, Aug 8, 2009 at 3:32 PM, Michael Goldish > wrote: > > How can we set the verbosity level for stand-alone execution, e.g. > > enable/disable debug output when running ./kvm_config.py > kvm_tests.cfg? > > On the main program execution we could add a OptionParser instance > that parses a --verbose flag, and we pass verbose to the logging > system config statement > > logging_manager.configure_logging(KvmLoggingConfig(), verbose=True) > > I will re-write the patch with that, thanks! OK, but then we should get rid of the 'debug' param in config.__init__(). I hope OptionParser won't make the code much longer. > > - Original Message - > > From: "Lucas Meneghel Rodrigues" > > To: autot...@test.kernel.org > > Cc: kvm@vger.kernel.org, mgold...@redhat.com, "Lucas Meneghel > Rodrigues" > > Sent: Saturday, August 8, 2009 8:37:14 PM (GMT+0200) Auto-Detected > > Subject: [PATCH] KVM test: Make kvm_config.py to use autotest > logging > > > > Make kvm_config.py be able to use the autotest logging > > infrastructure even in stand alone mode. This way we > > get the ability of having selective debug mode, and > > just use the cleaner logging.[debuglevel]('message') > > syntax instead of resorting to hardcoded [LEVEL] > > strings in any message. > > > > Signed-off-by: Lucas Meneghel Rodrigues > > --- > >  client/tests/kvm/kvm_config.py |  26 ++ > >  1 files changed, 18 insertions(+), 8 deletions(-) > > > > diff --git a/client/tests/kvm/kvm_config.py > b/client/tests/kvm/kvm_config.py > > index 7ff7a07..e2cf5be 100755 > > --- a/client/tests/kvm/kvm_config.py > > +++ b/client/tests/kvm/kvm_config.py > > @@ -1,7 +1,8 @@ > >  #!/usr/bin/python > > -import re, os, sys, StringIO > > +import logging, re, os, sys, StringIO > >  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. > > @@ -9,6 +10,12 @@ KVM configuration file utility functions. > > �...@copyright: Red Hat 2008-2009 > >  """ > > > > +class KvmLoggingConfig(logging_config.LoggingConfig): > > +   def configure_logging(self, results_dir=None, verbose=False): > > +     super(KvmLoggingConfig, > self).configure_logging(use_console=True, > > +                            >  verbose=verbose) > > + > > + > >  class config: > >   """ > >   Parse an input file or string that follows the KVM Test Config > File format > > @@ -413,11 +420,11 @@ class config: > >             if self.debug and not restricted: > >               self.__debug_print("", "Leaving file %s" > % words[1]) > >           else: > > -             print ("WARNING: Cannot include %s -- " > > -                "file not found" % filename) > > +             logging.warning("Cannot include %s -- file > not found", > > +                     filename) > >         else: > > -           print ("WARNING: Cannot include %s because no > file is " > > -              "currently open" % words[1]) > > +           logging.warning("Cannot include %s because no > file is " > > +                   "currently open", words[1]) > > > >       # Parse multi-line exceptions > >       # (the block is parsed for each dict separately) > > @@ -462,7 +469,7 @@ class config: > >       str = "%-50s ---> %s" % (str1, str2) > >     else: > >       str = str1 > > -     print str > > +     logging.debug(str) > > > > > >   def __modify_list_variants(self, list, name, dep_list, > add_to_shortname): > > @@ -519,12 +526,15 @@ if __name__ == "__main__": > >     filename = sys.argv[1] > >   else: > >     filename = os.path.join(os.path.dirname(sys.argv[0]), > "kvm_tests.cfg") > > +   # Here we configure the stand alone program to use the > autotest > > +   # logging system. > > +   logging_manager.configure_logging(KvmLoggingConfig(), > verbose=True) > >   list = config(filename, debug=True).get_list() > >   i = 0 > >   for dict in list: > > -     print "Dictionary #%d:" % i > > +     logging.debug("Dictionary #%d:", i) > >     keys = dict.keys() > >     keys.sort() > >     for key in keys: > > -       print "   %s = %s" % (key, dict[key]) > > +       logging.debug("   %s = %s", key, dict[key]) > >     i += 1 > > -- > > 1.6.2.5 > > > > ___ > > Autotest mailing list > > autot...@test.kernel.org > > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest > > > > > > -- > Lucas Meneghel -- 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: [PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
On 08/09/2009 03:41 PM, Gleb Natapov wrote: Sending of MSI using IRQ routing is an artificial concept and potentially big number of MSIs (2048 per device) make it also inefficient. This patch adds an interface to inject MSI messages from userspace to lapic logic directly. The patch also reduces the maximum number of IRQ routing entries to 128 since MSIs will no longer go there and 128 entries cover 5 ioapics and this ought to be enough for anybody. In the future many MSIs will be triggered via irqfds, and those require irq routing. -- 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
Re: [PATCH 07/10] Move irq notifiers lists to its own locking.
On Sun, Aug 09, 2009 at 05:52:30PM +0300, Avi Kivity wrote: > On 08/09/2009 03:41 PM, Gleb Natapov wrote: >> Signed-off-by: Gleb Natapov >> --- >> include/linux/kvm_host.h |1 + >> virt/kvm/irq_comm.c | 16 >> virt/kvm/kvm_main.c |1 + >> 3 files changed, 10 insertions(+), 8 deletions(-) >> >> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h >> index ce28cb7..8791ce8 100644 >> --- a/include/linux/kvm_host.h >> +++ b/include/linux/kvm_host.h >> @@ -178,6 +178,7 @@ struct kvm { >> spinlock_t irq_routing_lock; >> struct hlist_head mask_notifier_list; >> struct hlist_head irq_ack_notifier_list; >> +spinlock_t irq_notifier_list_lock; >> > > Again, why? > Because later patches remove irq_lock entirely and lock is need for write even with rcu. So instead of reusing irq_lock to protect those structures on write I introduce locks with self descriptive names. -- Gleb. -- 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: [PATCH 08/10] Move IO APIC to its own lock.
On 08/09/2009 03:41 PM, Gleb Natapov wrote: Introduce new function kvm_notifier_set_irq() that should be used to change irq line level from irq notifiers. When irq notifier change irq line level it calls into irq chip code recursively. The function avoids taking a lock recursively. This looks really horrible. I don't have an alternative yet, but I'll think of one. -- 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
Re: [PATCH 07/10] Move irq notifiers lists to its own locking.
On 08/09/2009 03:41 PM, Gleb Natapov wrote: Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h |1 + virt/kvm/irq_comm.c | 16 virt/kvm/kvm_main.c |1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ce28cb7..8791ce8 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -178,6 +178,7 @@ struct kvm { spinlock_t irq_routing_lock; struct hlist_head mask_notifier_list; struct hlist_head irq_ack_notifier_list; + spinlock_t irq_notifier_list_lock; Again, why? -- 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
Re: [PATCH 06/10] Move irq routing to its own locking.
On 08/09/2009 03:41 PM, Gleb Natapov wrote: Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h |1 + virt/kvm/irq_comm.c |4 ++-- virt/kvm/kvm_main.c |1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d573652..ce28cb7 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -175,6 +175,7 @@ struct kvm { struct mutex irq_lock; #ifdef CONFIG_HAVE_KVM_IRQCHIP struct kvm_irq_routing_table *irq_routing; + spinlock_t irq_routing_lock; Why is this needed? The irq routing table adds very little contention since it is rcu locked. -- 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
Re: [PATCH 01/10] Change irq routing table to use gsi indexed array.
On 08/09/2009 03:41 PM, Gleb Natapov wrote: Use gsi indexed array instead of scanning all entries on each interrupt injection. Also maintain back mapping from irqchip/pin to gsi to speedup interrupt acknowledgment notifications. Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h | 11 +- virt/kvm/irq_comm.c | 87 - virt/kvm/kvm_main.c |1 - 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f814512..a38f576 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -129,7 +129,14 @@ struct kvm_kernel_irq_routing_entry { } irqchip; struct msi_msg msi; }; - struct list_head link; + struct hlist_node link; +}; + +struct kvm_irq_routing_table { + int chip[3][KVM_IOAPIC_NUM_PINS]; + struct kvm_kernel_irq_routing_entry *rt_entries; + u32 max_gsi; That's the table size, no? so call it nr_rt_entries to reflect that (max_* implies an off-by-one). + struct hlist_head map[0]; }; What's this? (comment explaining the type of data). struct kvm { @@ -167,7 +174,7 @@ struct kvm { struct mutex irq_lock; #ifdef CONFIG_HAVE_KVM_IRQCHIP - struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */ Like here. @@ -150,8 +152,9 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) * IOAPIC. So set the bit in both. The guest will ignore * writes to the unused one. */ - list_for_each_entry(e,&kvm->irq_routing, link) - if (e->gsi == irq) { + irq_rt = kvm->irq_routing; + if (irq< irq_rt->max_gsi) irq here is int, so can overflow. I think all paths are protected, but better to change irq to unsigned just in case. + hlist_for_each_entry(e, n,&irq_rt->map[irq], link) { int r = e->set(e, kvm, sig_level); if (r< 0) continue; @@ -163,20 +166,15 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) { - struct kvm_kernel_irq_routing_entry *e; struct kvm_irq_ack_notifier *kian; struct hlist_node *n; - unsigned gsi = pin; + unsigned gsi; trace_kvm_ack_irq(irqchip, pin); - list_for_each_entry(e,&kvm->irq_routing, link) - if (e->type == KVM_IRQ_ROUTING_IRQCHIP&& - e->irqchip.irqchip == irqchip&& - e->irqchip.pin == pin) { - gsi = e->gsi; - break; - } + gsi = kvm->irq_routing->chip[irqchip][pin]; + if (gsi == -1) + gsi = pin; Please separate the reverse map to a separate patch. + new = kzalloc(sizeof(*new) + (max_gsi * sizeof(struct hlist_head)) + + (nr * sizeof(struct kvm_kernel_irq_routing_entry)), + GFP_KERNEL); Wow. -- 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
Re: [Autotest] [PATCH] KVM test: Make kvm_config.py to use autotest logging
On Sat, Aug 8, 2009 at 3:32 PM, Michael Goldish wrote: > How can we set the verbosity level for stand-alone execution, e.g. > enable/disable debug output when running ./kvm_config.py kvm_tests.cfg? On the main program execution we could add a OptionParser instance that parses a --verbose flag, and we pass verbose to the logging system config statement logging_manager.configure_logging(KvmLoggingConfig(), verbose=True) I will re-write the patch with that, thanks! > - Original Message - > From: "Lucas Meneghel Rodrigues" > To: autot...@test.kernel.org > Cc: kvm@vger.kernel.org, mgold...@redhat.com, "Lucas Meneghel Rodrigues" > > Sent: Saturday, August 8, 2009 8:37:14 PM (GMT+0200) Auto-Detected > Subject: [PATCH] KVM test: Make kvm_config.py to use autotest logging > > Make kvm_config.py be able to use the autotest logging > infrastructure even in stand alone mode. This way we > get the ability of having selective debug mode, and > just use the cleaner logging.[debuglevel]('message') > syntax instead of resorting to hardcoded [LEVEL] > strings in any message. > > Signed-off-by: Lucas Meneghel Rodrigues > --- >  client/tests/kvm/kvm_config.py |  26 ++ >  1 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py > index 7ff7a07..e2cf5be 100755 > --- a/client/tests/kvm/kvm_config.py > +++ b/client/tests/kvm/kvm_config.py > @@ -1,7 +1,8 @@ >  #!/usr/bin/python > -import re, os, sys, StringIO > +import logging, re, os, sys, StringIO >  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. > @@ -9,6 +10,12 @@ KVM configuration file utility functions. > �...@copyright: Red Hat 2008-2009 >  """ > > +class KvmLoggingConfig(logging_config.LoggingConfig): > +   def configure_logging(self, results_dir=None, verbose=False): > +     super(KvmLoggingConfig, self).configure_logging(use_console=True, > +                             verbose=verbose) > + > + >  class config: >   """ >   Parse an input file or string that follows the KVM Test Config File format > @@ -413,11 +420,11 @@ class config: >             if self.debug and not restricted: >               self.__debug_print("", "Leaving file %s" % > words[1]) >           else: > -             print ("WARNING: Cannot include %s -- " > -                "file not found" % filename) > +             logging.warning("Cannot include %s -- file not > found", > +                     filename) >         else: > -           print ("WARNING: Cannot include %s because no file is " > -              "currently open" % words[1]) > +           logging.warning("Cannot include %s because no file is " > +                   "currently open", words[1]) > >       # Parse multi-line exceptions >       # (the block is parsed for each dict separately) > @@ -462,7 +469,7 @@ class config: >       str = "%-50s ---> %s" % (str1, str2) >     else: >       str = str1 > -     print str > +     logging.debug(str) > > >   def __modify_list_variants(self, list, name, dep_list, add_to_shortname): > @@ -519,12 +526,15 @@ if __name__ == "__main__": >     filename = sys.argv[1] >   else: >     filename = os.path.join(os.path.dirname(sys.argv[0]), "kvm_tests.cfg") > +   # Here we configure the stand alone program to use the autotest > +   # logging system. > +   logging_manager.configure_logging(KvmLoggingConfig(), verbose=True) >   list = config(filename, debug=True).get_list() >   i = 0 >   for dict in list: > -     print "Dictionary #%d:" % i > +     logging.debug("Dictionary #%d:", i) >     keys = dict.keys() >     keys.sort() >     for key in keys: > -       print "   %s = %s" % (key, dict[key]) > +       logging.debug("   %s = %s", key, dict[key]) >     i += 1 > -- > 1.6.2.5 > > ___ > Autotest mailing list > autot...@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest > -- Lucas Meneghel -- 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: [PATCH] Update cr8 intercept when APIC/CR8 is changed by userspace.
On 08/09/2009 03:17 PM, Gleb Natapov wrote: Since on vcpu entry we do it only if apic is enabled we should do it when TPR is changed while apic is disabled. This happens when windows resets HW without setting TPR to zero. Applied, thanks. @@ -4412,6 +4414,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, vcpu->arch.cr3 = sregs->cr3; kvm_set_cr8(vcpu, sregs->cr8); + update_cr8_intercept(vcpu); mmu_reset_needed |= vcpu->arch.shadow_efer != sregs->efer; kvm_x86_ops->set_efer(vcpu, sregs->efer); Already had this bit, so dropped it. -- 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
[PATCH 10/10] Introduce MSI message sending interface that bypass IRQ routing.
Sending of MSI using IRQ routing is an artificial concept and potentially big number of MSIs (2048 per device) make it also inefficient. This patch adds an interface to inject MSI messages from userspace to lapic logic directly. The patch also reduces the maximum number of IRQ routing entries to 128 since MSIs will no longer go there and 128 entries cover 5 ioapics and this ought to be enough for anybody. Signed-off-by: Gleb Natapov --- arch/ia64/kvm/kvm-ia64.c | 26 ++ arch/x86/kvm/x86.c | 26 ++ include/linux/kvm.h | 10 -- include/linux/kvm_host.h |3 ++- virt/kvm/irq_comm.c | 23 ++- 5 files changed, 76 insertions(+), 12 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 8f1fc3a..c136085 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -195,6 +195,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_IRQCHIP: case KVM_CAP_MP_STATE: case KVM_CAP_IRQ_INJECT_STATUS: + case KVM_CAP_MSI_MSG: r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -1010,6 +1011,31 @@ long kvm_arch_vm_ioctl(struct file *filp, } break; } + case KVM_MSI_MSG: { + struct kvm_irq_routing_msi msg; + struct msi_msg msi; + + r = -EFAULT; + if (copy_from_user(&msg, argp, sizeof msg)) + goto out; + r = -EINVAL; + if (!irqchip_in_kernel(kvm)) + goto out; + if (msg.flags) + goto out; + + msi.address_lo = msg.address_lo; + msi.address_hi = msg.address_hi; + msi.data = msg.data; + + msg.status = kvm_set_msi(kvm, &msi); + if (copy_to_user(argp, &msg, sizeof msg)) { + r = -EFAULT; + goto out; + } + r = 0; + break; + } case KVM_GET_IRQCHIP: { /* 0: PIC master, 1: PIC slave, 2: IOAPIC */ struct kvm_irqchip chip; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index d313462..0e5c946 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1211,6 +1211,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_PIT2: case KVM_CAP_PIT_STATE2: case KVM_CAP_SET_IDENTITY_MAP_ADDR: + case KVM_CAP_MSI_MSG: r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -2296,6 +2297,31 @@ long kvm_arch_vm_ioctl(struct file *filp, } break; } + case KVM_MSI_MSG: { + struct kvm_irq_routing_msi msg; + struct msi_msg msi; + + r = -EFAULT; + if (copy_from_user(&msg, argp, sizeof msg)) + goto out; + r = -EINVAL; + if (!irqchip_in_kernel(kvm)) + goto out; + if (msg.flags) + goto out; + + msi.address_lo = msg.address_lo; + msi.address_hi = msg.address_hi; + msi.data = msg.data; + + msg.status = kvm_set_msi(kvm, &msi); + if (copy_to_user(argp, &msg, sizeof msg)) { + r = -EFAULT; + goto out; + } + r = 0; + break; + } case KVM_GET_IRQCHIP: { /* 0: PIC master, 1: PIC slave, 2: IOAPIC */ struct kvm_irqchip *chip = kmalloc(sizeof(*chip), GFP_KERNEL); diff --git a/include/linux/kvm.h b/include/linux/kvm.h index f8f8900..a326034 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -436,6 +436,7 @@ struct kvm_ioeventfd { #endif #define KVM_CAP_IOEVENTFD 36 #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 +#define KVM_CAP_MSI_MSG 38 #ifdef KVM_CAP_IRQ_ROUTING @@ -447,8 +448,11 @@ struct kvm_irq_routing_irqchip { struct kvm_irq_routing_msi { __u32 address_lo; __u32 address_hi; - __u32 data; - __u32 pad; + union { + __u32 data; + __s32 status; + }; + __u32 flags; }; /* gsi routing entry types */ @@ -593,6 +597,8 @@ struct kvm_irqfd { #define KVM_X86_SETUP_MCE _IOW(KVMIO, 0x9c, __u64) #define KVM_X86_GET_MCE_CAP_SUPPORTED _IOR(KVMIO, 0x9d, __u64) #define KVM_X86_SET_MCE _IOW(KVMIO, 0x9e, struct kvm_x86_mce) +#define KVM_MSI_MSG\ + _IOWR(KVMIO, 0x9f, struct kvm_irq_routing_msi) /* * Deprecated interfaces diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b3db9bf..857f2f4 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -407,6 +407,7 @@ void kvm_get_intr_delivery_bitmask
[PATCH 09/10] Drop kvm->irq_lock lock.
The only thing it protects now is interrupt injection into lapic and this can work lockless. Even now with kvm->irq_lock in place access to lapic is not entirely serialized since vcpu access doesn't take kvm->irq_lock. Signed-off-by: Gleb Natapov --- arch/ia64/kvm/kvm-ia64.c |2 -- arch/x86/kvm/i8254.c |2 -- arch/x86/kvm/lapic.c |2 -- arch/x86/kvm/x86.c |2 -- include/linux/kvm_host.h |1 - virt/kvm/eventfd.c |2 -- virt/kvm/irq_comm.c |6 +- virt/kvm/kvm_main.c |5 + 8 files changed, 2 insertions(+), 20 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index dd7ef2d..8f1fc3a 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -998,10 +998,8 @@ long kvm_arch_vm_ioctl(struct file *filp, goto out; if (irqchip_in_kernel(kvm)) { __s32 status; - mutex_lock(&kvm->irq_lock); status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irq_event.irq, irq_event.level); - mutex_unlock(&kvm->irq_lock); if (ioctl == KVM_IRQ_LINE_STATUS) { irq_event.status = status; if (copy_to_user(argp, &irq_event, diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 1330b2a..f3d3382 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -690,10 +690,8 @@ static void __inject_pit_timer_intr(struct kvm *kvm) struct kvm_vcpu *vcpu; int i; - mutex_lock(&kvm->irq_lock); kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1); kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0); - mutex_unlock(&kvm->irq_lock); /* * Provides NMI watchdog support via Virtual Wire mode. diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index f24d4d0..e41e948 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -501,9 +501,7 @@ static void apic_send_ipi(struct kvm_lapic *apic) irq.trig_mode, irq.level, irq.dest_mode, irq.delivery_mode, irq.vector); - mutex_lock(&apic->vcpu->kvm->irq_lock); kvm_irq_delivery_to_apic(apic->vcpu->kvm, apic, &irq); - mutex_unlock(&apic->vcpu->kvm->irq_lock); } static u32 apic_get_tmcct(struct kvm_lapic *apic) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1ac1695..d313462 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2284,10 +2284,8 @@ long kvm_arch_vm_ioctl(struct file *filp, goto out; if (irqchip_in_kernel(kvm)) { __s32 status; - mutex_lock(&kvm->irq_lock); status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irq_event.irq, irq_event.level); - mutex_unlock(&kvm->irq_lock); if (ioctl == KVM_IRQ_LINE_STATUS) { irq_event.status = status; if (copy_to_user(argp, &irq_event, diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 3610661..b3db9bf 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -172,7 +172,6 @@ struct kvm { struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; #endif - struct mutex irq_lock; #ifdef CONFIG_HAVE_KVM_IRQCHIP struct kvm_irq_routing_table *irq_routing; spinlock_t irq_routing_lock; diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 99017e8..95954ad 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -61,10 +61,8 @@ irqfd_inject(struct work_struct *work) struct _irqfd *irqfd = container_of(work, struct _irqfd, inject); struct kvm *kvm = irqfd->kvm; - mutex_lock(&kvm->irq_lock); kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1); kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 0); - mutex_unlock(&kvm->irq_lock); } /* diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 43ace95..dd9a5ca 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -65,8 +65,6 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src, int i, r = -1; struct kvm_vcpu *vcpu, *lowest = NULL; - WARN_ON(!mutex_is_locked(&kvm->irq_lock)); - if (irq->dest_mode == 0 && irq->dest_id == 0xff && kvm_is_dm_lowest_prio(irq)) printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n"); @@ -118,7 +116,7 @@ static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, return kvm_irq_delivery_to_apic(kvm, NULL, &irq); } -/* This should be called with the kvm->irq_lock mutex held +/* * Return value: * < 0 Interrupt was ignored (masked or not delivered for other re
[PATCH 08/10] Move IO APIC to its own lock.
Introduce new function kvm_notifier_set_irq() that should be used to change irq line level from irq notifiers. When irq notifier change irq line level it calls into irq chip code recursively. The function avoids taking a lock recursively. Signed-off-by: Gleb Natapov --- arch/ia64/kvm/kvm-ia64.c| 27 ++- arch/x86/include/asm/kvm_host.h |2 +- arch/x86/kvm/i8259.c|8 +++-- arch/x86/kvm/lapic.c|5 +--- arch/x86/kvm/x86.c | 30 ++--- include/linux/kvm_host.h|3 +- virt/kvm/ioapic.c | 53 -- virt/kvm/ioapic.h |4 ++- virt/kvm/irq_comm.c | 25 ++ virt/kvm/kvm_main.c |2 +- 10 files changed, 105 insertions(+), 54 deletions(-) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 0ad09f0..dd7ef2d 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -850,9 +850,16 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, r = 0; switch (chip->chip_id) { - case KVM_IRQCHIP_IOAPIC: - memcpy(&chip->chip.ioapic, ioapic_irqchip(kvm), - sizeof(struct kvm_ioapic_state)); + case KVM_IRQCHIP_IOAPIC: { + struct kvm_ioapic *ioapic = ioapic_irqchip(kvm); + if (ioapic) { + spin_lock(&ioapic->lock); + memcpy(&chip->chip.ioapic, ioapic, + sizeof(struct kvm_ioapic_state)); + spin_unlock(&ioapic->lock); + } else + r = -EINVAL; + } break; default: r = -EINVAL; @@ -867,10 +874,16 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip) r = 0; switch (chip->chip_id) { - case KVM_IRQCHIP_IOAPIC: - memcpy(ioapic_irqchip(kvm), - &chip->chip.ioapic, - sizeof(struct kvm_ioapic_state)); + case KVM_IRQCHIP_IOAPIC: { + struct kvm_ioapic *ioapic = ioapic_irqchip(kvm); + if (ioapic) { + spin_lock(&ioapic->lock); + memcpy(ioapic, &chip->chip.ioapic, + sizeof(struct kvm_ioapic_state)); + spin_unlock(&ioapic->lock); + } else + r = -EINVAL; + } break; default: r = -EINVAL; diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 7dfde38..09b2ef9 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -623,7 +623,7 @@ void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, u32 error_code); -int kvm_pic_set_irq(void *opaque, int irq, int level); +int kvm_pic_set_irq(void *opaque, int irq, int level, bool notifier); void kvm_inject_nmi(struct kvm_vcpu *vcpu); diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index 01f1516..d579ff1 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -153,19 +153,21 @@ void kvm_pic_update_irq(struct kvm_pic *s) spin_unlock(&s->lock); } -int kvm_pic_set_irq(void *opaque, int irq, int level) +int kvm_pic_set_irq(void *opaque, int irq, int level, bool notifier) { struct kvm_pic *s = opaque; int ret = -1; - spin_lock(&s->lock); + if (!notifier) + spin_lock(&s->lock); if (irq >= 0 && irq < PIC_NUM_PINS) { ret = pic_set_irq1(&s->pics[irq >> 3], irq & 7, level); pic_update_irq(s); trace_kvm_pic_set_irq(irq >> 3, irq & 7, s->pics[irq >> 3].elcr, s->pics[irq >> 3].imr, ret == 0); } - spin_unlock(&s->lock); + if (!notifier) + spin_unlock(&s->lock); return ret; } diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index ce195f8..f24d4d0 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -471,11 +471,8 @@ static void apic_set_eoi(struct kvm_lapic *apic) trigger_mode = IOAPIC_LEVEL_TRIG; else trigger_mode = IOAPIC_EDGE_TRIG; - if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)) { - mutex_lock(&apic->vcpu->kvm->irq_lock); + if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)) kvm_ioapic_update_eoi(apic->vcpu->kvm, vector, trigger_mode); - mutex_unlock(&apic->vcpu->kvm->irq_lock); - } } static void apic_send_ipi(struct kvm_lapic *apic) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5a69ad1..1ac1695 100644 --- a/arch/x86/kvm/x86.c ++
[PATCH 07/10] Move irq notifiers lists to its own locking.
Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h |1 + virt/kvm/irq_comm.c | 16 virt/kvm/kvm_main.c |1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ce28cb7..8791ce8 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -178,6 +178,7 @@ struct kvm { spinlock_t irq_routing_lock; struct hlist_head mask_notifier_list; struct hlist_head irq_ack_notifier_list; + spinlock_t irq_notifier_list_lock; #endif #ifdef KVM_ARCH_WANT_MMU_NOTIFIER diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 55eb6f6..65f66f1 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -188,17 +188,17 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) void kvm_register_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian) { - mutex_lock(&kvm->irq_lock); + spin_lock(&kvm->irq_notifier_list_lock); hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list); - mutex_unlock(&kvm->irq_lock); + spin_unlock(&kvm->irq_notifier_list_lock); } void kvm_unregister_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian) { - mutex_lock(&kvm->irq_lock); + spin_lock(&kvm->irq_notifier_list_lock); hlist_del_init_rcu(&kian->link); - mutex_unlock(&kvm->irq_lock); + spin_unlock(&kvm->irq_notifier_list_lock); synchronize_rcu(); } @@ -244,18 +244,18 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id) void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, struct kvm_irq_mask_notifier *kimn) { - mutex_lock(&kvm->irq_lock); + spin_lock(&kvm->irq_notifier_list_lock); kimn->irq = irq; hlist_add_head_rcu(&kimn->link, &kvm->mask_notifier_list); - mutex_unlock(&kvm->irq_lock); + spin_unlock(&kvm->irq_notifier_list_lock); } void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, struct kvm_irq_mask_notifier *kimn) { - mutex_lock(&kvm->irq_lock); + spin_lock(&kvm->irq_notifier_list_lock); hlist_del_rcu(&kimn->link); - mutex_unlock(&kvm->irq_lock); + spin_unlock(&kvm->irq_notifier_list_lock); synchronize_rcu(); } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2f4a47e..c108edc 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -947,6 +947,7 @@ static struct kvm *kvm_create_vm(void) spin_lock_init(&kvm->irq_routing_lock); INIT_HLIST_HEAD(&kvm->mask_notifier_list); INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list); + spin_lock_init(&kvm->irq_notifier_list_lock); #endif #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET -- 1.6.3.3 -- 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 01/10] Change irq routing table to use gsi indexed array.
Use gsi indexed array instead of scanning all entries on each interrupt injection. Also maintain back mapping from irqchip/pin to gsi to speedup interrupt acknowledgment notifications. Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h | 11 +- virt/kvm/irq_comm.c | 87 - virt/kvm/kvm_main.c |1 - 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f814512..a38f576 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -129,7 +129,14 @@ struct kvm_kernel_irq_routing_entry { } irqchip; struct msi_msg msi; }; - struct list_head link; + struct hlist_node link; +}; + +struct kvm_irq_routing_table { + int chip[3][KVM_IOAPIC_NUM_PINS]; + struct kvm_kernel_irq_routing_entry *rt_entries; + u32 max_gsi; + struct hlist_head map[0]; }; struct kvm { @@ -167,7 +174,7 @@ struct kvm { struct mutex irq_lock; #ifdef CONFIG_HAVE_KVM_IRQCHIP - struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */ + struct kvm_irq_routing_table *irq_routing; struct hlist_head mask_notifier_list; #endif diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 001663f..2ab807f 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -127,6 +127,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) struct kvm_kernel_irq_routing_entry *e; unsigned long *irq_state, sig_level; int ret = -1; + struct kvm_irq_routing_table *irq_rt; + struct hlist_node *n; trace_kvm_set_irq(irq, level, irq_source_id); @@ -150,8 +152,9 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) * IOAPIC. So set the bit in both. The guest will ignore * writes to the unused one. */ - list_for_each_entry(e, &kvm->irq_routing, link) - if (e->gsi == irq) { + irq_rt = kvm->irq_routing; + if (irq < irq_rt->max_gsi) + hlist_for_each_entry(e, n, &irq_rt->map[irq], link) { int r = e->set(e, kvm, sig_level); if (r < 0) continue; @@ -163,20 +166,15 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) { - struct kvm_kernel_irq_routing_entry *e; struct kvm_irq_ack_notifier *kian; struct hlist_node *n; - unsigned gsi = pin; + unsigned gsi; trace_kvm_ack_irq(irqchip, pin); - list_for_each_entry(e, &kvm->irq_routing, link) - if (e->type == KVM_IRQ_ROUTING_IRQCHIP && - e->irqchip.irqchip == irqchip && - e->irqchip.pin == pin) { - gsi = e->gsi; - break; - } + gsi = kvm->irq_routing->chip[irqchip][pin]; + if (gsi == -1) + gsi = pin; hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link) if (kian->gsi == gsi) @@ -267,22 +265,15 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask) kimn->func(kimn, mask); } -static void __kvm_free_irq_routing(struct list_head *irq_routing) -{ - struct kvm_kernel_irq_routing_entry *e, *n; - - list_for_each_entry_safe(e, n, irq_routing, link) - kfree(e); -} - void kvm_free_irq_routing(struct kvm *kvm) { mutex_lock(&kvm->irq_lock); - __kvm_free_irq_routing(&kvm->irq_routing); + kfree(kvm->irq_routing); mutex_unlock(&kvm->irq_lock); } -static int setup_routing_entry(struct kvm_kernel_irq_routing_entry *e, +static int setup_routing_entry(struct kvm_irq_routing_table *rt, + struct kvm_kernel_irq_routing_entry *e, const struct kvm_irq_routing_entry *ue) { int r = -EINVAL; @@ -309,6 +300,9 @@ static int setup_routing_entry(struct kvm_kernel_irq_routing_entry *e, } e->irqchip.irqchip = ue->u.irqchip.irqchip; e->irqchip.pin = ue->u.irqchip.pin + delta; + if (e->irqchip.pin > KVM_IOAPIC_NUM_PINS) + goto out; + rt->chip[ue->u.irqchip.irqchip][e->irqchip.pin] = ue->gsi; break; case KVM_IRQ_ROUTING_MSI: e->set = kvm_set_msi; @@ -319,6 +313,8 @@ static int setup_routing_entry(struct kvm_kernel_irq_routing_entry *e, default: goto out; } + + hlist_add_head(&e->link, &rt->map[e->gsi]); r = 0; out: return r; @@ -330,43 +326,52 @@ int kvm_set_irq_routing(struct kvm *kvm, unsigned nr, unsigned flags) { - struct
[PATCH 05/10] Protect irq_sources_bitmap by kvm->lock instead of kvm->irq_lock
It is already protected by kvm->lock on device assignment path. Just take the same lock in the PIT code. Signed-off-by: Gleb Natapov --- arch/x86/kvm/i8254.c |2 ++ virt/kvm/irq_comm.c |8 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 82ad523..1330b2a 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -611,7 +611,9 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) if (!pit) return NULL; + mutex_lock(&kvm->lock); pit->irq_source_id = kvm_request_irq_source_id(kvm); + mutex_unlock(&kvm->lock); if (pit->irq_source_id < 0) { kfree(pit); return NULL; diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 02412c3..6b09053 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -207,7 +207,8 @@ int kvm_request_irq_source_id(struct kvm *kvm) unsigned long *bitmap = &kvm->arch.irq_sources_bitmap; int irq_source_id; - mutex_lock(&kvm->irq_lock); + WARN_ON(!mutex_is_locked(&kvm->lock)); + irq_source_id = find_first_zero_bit(bitmap, sizeof(kvm->arch.irq_sources_bitmap)); @@ -218,7 +219,6 @@ int kvm_request_irq_source_id(struct kvm *kvm) ASSERT(irq_source_id != KVM_USERSPACE_IRQ_SOURCE_ID); set_bit(irq_source_id, bitmap); - mutex_unlock(&kvm->irq_lock); return irq_source_id; } @@ -227,9 +227,10 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id) { int i; + /* during vm destruction this function is called without locking */ + WARN_ON(!mutex_is_locked(&kvm->lock) && atomic_read(&kvm->users_count)); ASSERT(irq_source_id != KVM_USERSPACE_IRQ_SOURCE_ID); - mutex_lock(&kvm->irq_lock); if (irq_source_id < 0 || irq_source_id >= sizeof(kvm->arch.irq_sources_bitmap)) { printk(KERN_ERR "kvm: IRQ source ID out of range!\n"); @@ -238,7 +239,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id) for (i = 0; i < KVM_IOAPIC_NUM_PINS; i++) clear_bit(irq_source_id, &kvm->arch.irq_states[i]); clear_bit(irq_source_id, &kvm->arch.irq_sources_bitmap); - mutex_unlock(&kvm->irq_lock); } void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, -- 1.6.3.3 -- 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 06/10] Move irq routing to its own locking.
Signed-off-by: Gleb Natapov --- include/linux/kvm_host.h |1 + virt/kvm/irq_comm.c |4 ++-- virt/kvm/kvm_main.c |1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d573652..ce28cb7 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -175,6 +175,7 @@ struct kvm { struct mutex irq_lock; #ifdef CONFIG_HAVE_KVM_IRQCHIP struct kvm_irq_routing_table *irq_routing; + spinlock_t irq_routing_lock; struct hlist_head mask_notifier_list; struct hlist_head irq_ack_notifier_list; #endif diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 6b09053..55eb6f6 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -368,10 +368,10 @@ int kvm_set_irq_routing(struct kvm *kvm, ++ue; } - mutex_lock(&kvm->irq_lock); + spin_lock(&kvm->irq_routing_lock); old = kvm->irq_routing; rcu_assign_pointer(kvm->irq_routing, new); - mutex_unlock(&kvm->irq_lock); + spin_unlock(&kvm->irq_routing_lock); synchronize_rcu(); new = old; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fcc0c44..2f4a47e 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -944,6 +944,7 @@ static struct kvm *kvm_create_vm(void) if (IS_ERR(kvm)) goto out; #ifdef CONFIG_HAVE_KVM_IRQCHIP + spin_lock_init(&kvm->irq_routing_lock); INIT_HLIST_HEAD(&kvm->mask_notifier_list); INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list); #endif -- 1.6.3.3 -- 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 03/10] Move irq ack notifier list to arch independent code.
Mask irq notifier list is already there. Signed-off-by: Gleb Natapov --- arch/ia64/include/asm/kvm_host.h |1 - arch/x86/include/asm/kvm_host.h |1 - include/linux/kvm_host.h |1 + virt/kvm/irq_comm.c |4 ++-- virt/kvm/kvm_main.c |1 + 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h index d9b6325..a362e67 100644 --- a/arch/ia64/include/asm/kvm_host.h +++ b/arch/ia64/include/asm/kvm_host.h @@ -475,7 +475,6 @@ struct kvm_arch { struct list_head assigned_dev_head; struct iommu_domain *iommu_domain; int iommu_flags; - struct hlist_head irq_ack_notifier_list; unsigned long irq_sources_bitmap; unsigned long irq_states[KVM_IOAPIC_NUM_PINS]; diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index b17d845..7dfde38 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -400,7 +400,6 @@ struct kvm_arch{ struct kvm_pic *vpic; struct kvm_ioapic *vioapic; struct kvm_pit *vpit; - struct hlist_head irq_ack_notifier_list; int vapics_in_nmi_mode; unsigned int tss_addr; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index a38f576..d573652 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -176,6 +176,7 @@ struct kvm { #ifdef CONFIG_HAVE_KVM_IRQCHIP struct kvm_irq_routing_table *irq_routing; struct hlist_head mask_notifier_list; + struct hlist_head irq_ack_notifier_list; #endif #ifdef KVM_ARCH_WANT_MMU_NOTIFIER diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 9cdd984..e0940d5 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -180,7 +180,7 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) gsi = pin; rcu_read_unlock(); - hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link) + hlist_for_each_entry(kian, n, &kvm->irq_ack_notifier_list, link) if (kian->gsi == gsi) kian->irq_acked(kian); } @@ -189,7 +189,7 @@ void kvm_register_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian) { mutex_lock(&kvm->irq_lock); - hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list); + hlist_add_head(&kian->link, &kvm->irq_ack_notifier_list); mutex_unlock(&kvm->irq_lock); } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e8b03ee..fcc0c44 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -945,6 +945,7 @@ static struct kvm *kvm_create_vm(void) goto out; #ifdef CONFIG_HAVE_KVM_IRQCHIP INIT_HLIST_HEAD(&kvm->mask_notifier_list); + INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list); #endif #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET -- 1.6.3.3 -- 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 00/10] make interrupt injection lockless (almost)
kvm->irq_lock protects too much stuff, but still fail to protect everything it was design to protect (see ack notifiers call in pic). I want to make IRQ injection fast path as lockless as possible. This patch series split kvm->irq_lock mutex to smaller spinlocks each one protects only one thing. Irq routing, irq notifier lists and ioapic gain their own spinlock. Pic is already has its own lock. This patch series also makes interrupt injection to lapic lockless (several kvm_irq_delivery_to_apic() may run in parallel), but access to lapic was never fully locked in the first place. VCPU could access lapic in parallel with interrupt injection. Patch 1 changes irq routing data structure to much more efficient one. Patch 10 introduce API that allows to send MSI message without going through irq routing table. This allows us, among other thing, to limit irq routing table to a small number of entries. Gleb Natapov (10): Change irq routing table to use gsi indexed array. Move irq routing data structure to rcu locking Move irq ack notifier list to arch independent code. Convert irq notifiers lists to RCU locking. Protect irq_sources_bitmap by kvm->lock instead of kvm->irq_lock Move irq routing to its own locking. Move irq notifiers lists to its own locking. Move IO APIC to its own lock. Drop kvm->irq_lock lock. Introduce MSI message sending interface that bypass IRQ routing. arch/ia64/include/asm/kvm_host.h |1 - arch/ia64/kvm/kvm-ia64.c | 55 +-- arch/x86/include/asm/kvm_host.h |3 +- arch/x86/kvm/i8254.c |4 +- arch/x86/kvm/i8259.c |8 +- arch/x86/kvm/lapic.c |7 +- arch/x86/kvm/x86.c | 58 +--- include/linux/kvm.h | 10 ++- include/linux/kvm_host.h | 21 +++- virt/kvm/eventfd.c |2 - virt/kvm/ioapic.c| 53 +++ virt/kvm/ioapic.h|4 +- virt/kvm/irq_comm.c | 196 + virt/kvm/kvm_main.c | 11 +- 14 files changed, 277 insertions(+), 156 deletions(-) -- 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 04/10] Convert irq notifiers lists to RCU locking.
Use RCU locking for mask/ack notifiers lists. Signed-off-by: Gleb Natapov --- virt/kvm/irq_comm.c | 20 +++- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index e0940d5..02412c3 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -178,18 +178,18 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin]; if (gsi == -1) gsi = pin; - rcu_read_unlock(); - hlist_for_each_entry(kian, n, &kvm->irq_ack_notifier_list, link) + hlist_for_each_entry_rcu(kian, n, &kvm->irq_ack_notifier_list, link) if (kian->gsi == gsi) kian->irq_acked(kian); + rcu_read_unlock(); } void kvm_register_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian) { mutex_lock(&kvm->irq_lock); - hlist_add_head(&kian->link, &kvm->irq_ack_notifier_list); + hlist_add_head_rcu(&kian->link, &kvm->irq_ack_notifier_list); mutex_unlock(&kvm->irq_lock); } @@ -197,8 +197,9 @@ void kvm_unregister_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian) { mutex_lock(&kvm->irq_lock); - hlist_del_init(&kian->link); + hlist_del_init_rcu(&kian->link); mutex_unlock(&kvm->irq_lock); + synchronize_rcu(); } int kvm_request_irq_source_id(struct kvm *kvm) @@ -245,7 +246,7 @@ void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, { mutex_lock(&kvm->irq_lock); kimn->irq = irq; - hlist_add_head(&kimn->link, &kvm->mask_notifier_list); + hlist_add_head_rcu(&kimn->link, &kvm->mask_notifier_list); mutex_unlock(&kvm->irq_lock); } @@ -253,8 +254,9 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, struct kvm_irq_mask_notifier *kimn) { mutex_lock(&kvm->irq_lock); - hlist_del(&kimn->link); + hlist_del_rcu(&kimn->link); mutex_unlock(&kvm->irq_lock); + synchronize_rcu(); } void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask) @@ -262,11 +264,11 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask) struct kvm_irq_mask_notifier *kimn; struct hlist_node *n; - WARN_ON(!mutex_is_locked(&kvm->irq_lock)); - - hlist_for_each_entry(kimn, n, &kvm->mask_notifier_list, link) + rcu_read_lock(); + hlist_for_each_entry_rcu(kimn, n, &kvm->mask_notifier_list, link) if (kimn->irq == irq) kimn->func(kimn, mask); + rcu_read_unlock(); } void kvm_free_irq_routing(struct kvm *kvm) -- 1.6.3.3 -- 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 02/10] Move irq routing data structure to rcu locking
Signed-off-by: Gleb Natapov --- virt/kvm/irq_comm.c | 15 ++- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 2ab807f..9cdd984 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c @@ -152,7 +152,8 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) * IOAPIC. So set the bit in both. The guest will ignore * writes to the unused one. */ - irq_rt = kvm->irq_routing; + rcu_read_lock(); + irq_rt = rcu_dereference(kvm->irq_routing); if (irq < irq_rt->max_gsi) hlist_for_each_entry(e, n, &irq_rt->map[irq], link) { int r = e->set(e, kvm, sig_level); @@ -161,6 +162,7 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) ret = r + ((ret < 0) ? 0 : ret); } + rcu_read_unlock(); return ret; } @@ -172,9 +174,11 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin) trace_kvm_ack_irq(irqchip, pin); - gsi = kvm->irq_routing->chip[irqchip][pin]; + rcu_read_lock(); + gsi = rcu_dereference(kvm->irq_routing)->chip[irqchip][pin]; if (gsi == -1) gsi = pin; + rcu_read_unlock(); hlist_for_each_entry(kian, n, &kvm->arch.irq_ack_notifier_list, link) if (kian->gsi == gsi) @@ -267,9 +271,9 @@ void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask) void kvm_free_irq_routing(struct kvm *kvm) { - mutex_lock(&kvm->irq_lock); + /* Called only during vm destruction. Nobody can use the pointer + at this stage */ kfree(kvm->irq_routing); - mutex_unlock(&kvm->irq_lock); } static int setup_routing_entry(struct kvm_irq_routing_table *rt, @@ -364,8 +368,9 @@ int kvm_set_irq_routing(struct kvm *kvm, mutex_lock(&kvm->irq_lock); old = kvm->irq_routing; - kvm->irq_routing = new; + rcu_assign_pointer(kvm->irq_routing, new); mutex_unlock(&kvm->irq_lock); + synchronize_rcu(); new = old; r = 0; -- 1.6.3.3 -- 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] Update cr8 intercept when APIC/CR8 is changed by userspace.
Since on vcpu entry we do it only if apic is enabled we should do it when TPR is changed while apic is disabled. This happens when windows resets HW without setting TPR to zero. Signed-off-by: Gleb Natapov diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 44777a6..5a69ad1 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -77,6 +77,7 @@ static u64 __read_mostly efer_reserved_bits = 0xfffeULL; #define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU +static void update_cr8_intercept(struct kvm_vcpu *vcpu); static int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, struct kvm_cpuid_entry2 __user *entries); @@ -1629,6 +1630,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu, vcpu_load(vcpu); memcpy(vcpu->arch.apic->regs, s->regs, sizeof *s); kvm_apic_post_state_restore(vcpu); + update_cr8_intercept(vcpu); vcpu_put(vcpu); return 0; @@ -4412,6 +4414,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, vcpu->arch.cr3 = sregs->cr3; kvm_set_cr8(vcpu, sregs->cr8); + update_cr8_intercept(vcpu); mmu_reset_needed |= vcpu->arch.shadow_efer != sregs->efer; kvm_x86_ops->set_efer(vcpu, sregs->efer); -- Gleb. -- 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
[GIT PULL] KVM updates for 2.6.31-rc5
Linus, please pull from git://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-updates/2.6.31 Several critical patches, including a guest-initiated DoS fix, guest memory corruption on AMD, and edge-triggered interrupt mishandling which confuses some Windows variants on SMP. Avi Kivity (1): KVM: ia64: fix build failures due to ia64/unsigned long mismatches Christian Borntraeger (1): KVM: s390: fix wait_queue handling Gleb Natapov (1): KVM: Avoid redelivery of edge interrupt before next edge Jan Kiszka (3): KVM: Fix KVM_GET_MSR_INDEX_LIST KVM: VMX: Fix locking order in handle_invalid_guest_state KVM: VMX: Fix locking imbalance on emulation failure Marcelo Tosatti (5): KVM: PIT: fix kpit_elapsed division by zero KVM: x86: verify MTRR/PAT validity KVM: SVM: force new asid on vcpu migration KVM: MMU: handle n_free_mmu_pages > n_alloc_mmu_pages in kvm_mmu_change_mmu_pages KVM: MMU: limit rmap chain length Michael S. Tsirkin (1): KVM: fix ack not being delivered when msi present Stephen Rothwell (1): KVM: Make KVM_HPAGES_PER_HPAGE unsigned long to avoid build error on powerpc arch/ia64/kvm/mmio.c|6 +++- arch/ia64/kvm/vcpu.c|6 ++-- arch/ia64/kvm/vcpu.h| 13 + arch/powerpc/include/asm/kvm_host.h |2 +- arch/s390/kvm/interrupt.c |2 +- arch/x86/kvm/i8254.c|3 ++ arch/x86/kvm/mmu.c | 48 ++ arch/x86/kvm/svm.c |6 ++-- arch/x86/kvm/vmx.c |6 ++-- arch/x86/kvm/x86.c | 44 +--- include/linux/kvm_host.h|1 + virt/kvm/ioapic.c | 10 +++--- virt/kvm/irq_comm.c |4 ++- 13 files changed, 110 insertions(+), 41 deletions(-) -- 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: Biweekly KVM Test report, kernel 0b972... qemu f2593...
On 08/09/2009 02:32 PM, Avi Kivity wrote: I see that the guest is in stopped state after migration, issuing the cont command in the monitor unhalts it. Anthony, was this a planned change, or is it a regression? Okay, looks like a regression. I fixed this in qemu-kvm.git and send a patch for upstream. This did show up in my own regression tests but I ignored it for some reason... -- 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
Re: Biweekly KVM Test report, kernel 0b972... qemu f2593...
On 08/07/2009 09:11 AM, Xu, Jiajun wrote: On Wednesday, August 05, 2009 9:15 PM Avi Kivity wrote: Two New Issues: 1. Guest will be no response after migration https://sourceforge.net/tracker/?func=detail&atid=893831&aid=28 32401&group_id=180599 What kind of guest is this? We tried RHEL5.3 and Windows XP, both met the same issue. I see that the guest is in stopped state after migration, issuing the cont command in the monitor unhalts it. Anthony, was this a planned change, or is it a regression? -- 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
Re: [PATCH v5 6/6] VT-d: support the device IOTLB
On Mon, 2009-05-18 at 13:51 +0800, Yu Zhao wrote: > > +static struct device_domain_info *iommu_support_dev_iotlb( > + struct dmar_domain *domain, int segment, u8 bus, u8 devfn) > +{ > + int found = 0; > + unsigned long flags; > + struct device_domain_info *info; > + struct intel_iommu *iommu = device_to_iommu(segment, bus, > devfn); > + > + if (!ecap_dev_iotlb_support(iommu->ecap)) > + return NULL; > + > + if (!iommu->qi) > + return NULL; > + > + spin_lock_irqsave(&device_domain_lock, flags); > + list_for_each_entry(info, &domain->devices, link) > + if (info->bus == bus && info->devfn == devfn) { > + found = 1; > + break; > + } > + spin_unlock_irqrestore(&device_domain_lock, flags); What if there's more than one device? You only enable ATS for the first device that supports it, and ignore the others? -- David WoodhouseOpen Source Technology Centre david.woodho...@intel.com Intel Corporation -- 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: virtio-blk performance and MSI
On 08/06/2009 07:35 PM, Christoph Hellwig wrote: Michael suggested to me a while ago to try MSI with virtio-blk and I played with this small patch: Index: qemu-kvm/hw/virtio-blk.c === --- qemu-kvm.orig/hw/virtio-blk.c +++ qemu-kvm/hw/virtio-blk.c @@ -416,6 +416,7 @@ VirtIODevice *virtio_blk_init(DeviceStat s->vdev.get_config = virtio_blk_update_config; s->vdev.get_features = virtio_blk_get_features; s->vdev.reset = virtio_blk_reset; +s->vdev.nvectors = 2; s->bs = bs; s->rq = NULL; if (strlen(ps = (char *)drive_get_serial(bs))) which gave about 5% speedups on 4k sized reads and writes, see the full iozone output I attached. Now getting the information about using multiple MSI vectors from the command line to virtio-blk similar to how virtio-net does seems extremly messy right now. Waiting for Gerd's additional qdev patches to make it easier as a qdev property. Looks good. Anthony, I think this applies upstream? -- 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
Re: [PATCH]: Always use KVM_VERSION to build version number
On 08/07/2009 03:31 PM, Chris Lalancette wrote: Avi, Trying to use libvirt with development snapshots of qemu-kvm is a bit problematic. The trouble is that for all development snapshots, the value that gets placed into this string: QEMU PC emulator version 0.10.0 (kvm-devel), Copyright (c) 2003-2008 Is always kvm-devel. That means we can't tell if this is a kvm development snapshot built yesterday, or 6 months ago, which means that in turn we can't tell what features are available. While we can always tell people building their own qemu to force it by echoing a value into KVM_VERSION, it would be much better if this were done by default. Something like kvm-88-devel, which would signify that this the development happening after kvm-88, leading towards kvm-89. Would you accept something like the patch below, which would require you to edit the KVM_VERSION file twice during a release (once right before the release, to change it to kvm-89, and once right after the release to change it back to kvm-89-devel)? This is problematic in two ways. One is that I am basically guaranteed to forget to edit the file (which is why the release scripts generate the name based on the tag). On fix is to use git describe --match to find out what's the closest release. But this is still quite bad as it doesn't account for branches and forks. How about adding 'qemu -describe-features' which will output, one line per feature, what's supported (and limits where applicable)? I understand libvirt already does this for some features using -help; this is simply a formalization of that hack. -- 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
Re: [PATCH 1/1] net: fix vnet_hdr bustage with slirp
On 08/07/2009 11:47 AM, Mark McLoughlin wrote: slirp has started using VLANClientState::opaque and this has caused the kvm specific tap_has_vnet_hdr() hack to break because we blindly use this opaque pointer even if it is not a tap client. Add yet another hack to check that we're actually getting called with a tap client. Applied, thanks. [Needed on stable-0.11 too] There as well. -- 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
Re: [PATCH] kvm: Add COPYING file
On 08/07/2009 07:29 PM, Bruce Rogers wrote: kvm-kmod sources have no COPYING file. This patch adds it. 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
Re: segfault with windows XP guest
On 08/08/2009 03:56 AM, Gene Horodecki wrote: Hi there, I currently have about five guests set up with KVM, one of them being windows XP. I am having trouble with the windows XP one. It will works for a bit and then the process dies with the following in the kern.log: kvm[5593]: segfault at 29c ip 004316d8 sp 7fff0766bed0 error 4 in kvm[40+1e] Once the process dies once, then it keeps happening. The virtual machine will hardly boot now and it just crashes with this error. No major load on the windows VM, acpi enabled, a single 20Gb raw disk. Really hoping to get this working, thanks! Please generate a core dump and a stack trace. You may need to ./configure --disable-strip so that debug symbols are retained. -- 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
Re: [PATCH 0/21] Nested SVM cleanups v2
On 08/07/2009 12:49 PM, Joerg Roedel wrote: Hi, this is the second and extended version of my patchset to clean up the code for SVM virtualization in KVM. The patchset was tested with KVM on KVM and showed no regressions. It was tested with Nested Paging and with Shadow Paging on the first-level guest. As a major change this patchset enables the nested SVM code by default. It is still required to start qemu with -enable-nesting, though. 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
Re: [PATCH v5 6/6] VT-d: support the device IOTLB
On Mon, 2009-05-18 at 13:51 +0800, Yu Zhao wrote: > Enable the device IOTLB (i.e. ATS) for both the bare metal and KVM > environments. Hmmm. Your iommu_flush_dev_iotlb() function takes the _global_ spinlock 'device_domain_lock'. And you do this unconditionally -- you aren't even calling it only for domains which have ATS-capable devices attached. How about using a flag similar to iommu_snooping, which is recalculated only when you add or remove a device? And only calling iommu_flush_dev_iotlb() if that's set? -- David WoodhouseOpen Source Technology Centre david.woodho...@intel.com Intel Corporation -- 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
qcow2 corruption - seems to be fixed in kvm-85 and later :-)
Hi, Sometimes it's nice to find a mail with good news. A while back I reported corruption with qcow2, with the subject "qcow2 corruption observed, fixed by reverting old change". I'd noticed that kvm-83 was corrupting a Windows 2k disk image, which was failing to boot, blue screening quite early. I found there was a qcow2 bug introduced from kvm-72 to kvm-73, and another from kvm-76 to kvm-77. Reverting both fixed this symptom. In order to check the bug later, I kept a copy of the disk image which blue screened. It still crashes with kvm-84. The release notes indicate there were some qcow2 fixes in that version; they were not enough to fix this problem. There were more qcow2 fixes in kvm-85. Happily, I can now report that kvm-85 and kvm-88 both boot this image with no apparent problems, and I will be deleting this junk disk image now that I'm confident no further testing is required :-) Thanks! -- Jamie -- 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: Very high memory usage with KVM
On 08/08/2009 03:54 AM, Daniel Bareiro wrote: My guess is that it is due to poor swapping with pre-2.6.27 hosts. 15 GB used out of 16GB total is just 6% reserve, which may be a bit too low. With a 2.6.27 host some small amount of memory would be swapped out, before that you'd see thrashing. Another way to check is to drop one guest (or reduce total memory needed by 1GB) and see if you get the same results or if things improve. I was testing in another equipment of similar characteristics with 4 VMs of 3.5 GiB of RAM on LVM and rather less the 16 GB of RAM in use in the host machine and 4 GIB available of the 8 GIB of swap, and after to update to KVM-88 the use of virtual memory improved enough. At the moment these are the statistics of memory usage: r...@ss03:~# free total used free sharedbuffers cached Mem: 1646339667009009762496 02805756 391884 -/+ buffers/cache:3503260 12960136 Swap: 8319948 08319948 Still I didn't update the kernel, so I am using KVM-88 with kernel 2.6.24-19. I would like to know if this can have some disadvantage, since in the official site of the project I was reading that kernel has to be 2.6.25 or newer to run the kvm 76 userspace (or any newer release). I think it's just luck; with kernel < 2.6.27 swapping behaviour will not be very good. The reason by which I didn't update kernel is because I was with some problems with the network interface on the host machine. Perhaps this problem is off-topic, but if somebody can help me with this, then it would contribute whereupon it can improve the KVM performance. Please take it to netdev, perhaps they can help you with this. -- 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
Re: [PATCH 0/3] PIC fixes
On 08/04/2009 03:30 PM, Gleb Natapov wrote: Ack notifiers called at wrong time in PIC. kvm_vcpu_kick() can be called under spinlock now, so code can be simplified. 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
Re: [PATCH 0/7] AlacrityVM guest drivers Reply-To:
On 08/06/2009 07:55 PM, Gregory Haskins wrote: Based on this, I will continue my efforts surrounding to use of vbus including its use to accelerate KVM for AlacrityVM. If I can find a way to do this in such a way that KVM upstream finds acceptable, I would be very happy and will work towards whatever that compromise might be. OTOH, if the KVM community is set against the concept of a generalized/shared backend, and thus wants to use some other approach that does not involve vbus, that is fine too. Choice is one of the great assets of open source, eh? :) KVM upstream (me) doesn't have much say regarding vbus. I am not a networking expert and I'm not the virtio or networking stack maintainer, so I'm not qualified to accept or reject the code. What I am able to do is make sure that kvm can efficiently work with any driver/device stack; this is why ioeventfd/irqfd were merged. I still think vbus is a duplication of effort; I understand vbus has larger scope than virtio, but I still think these problems could have been solved within the existing virtio stack. -- 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