From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Allan Webber Subject: bug#22633: Provide a kvm-less qemu / guix system vm Date: Mon, 22 Feb 2016 11:35:30 -0800 Message-ID: <87r3g48rnh.fsf@dustycloud.org> References: <87oabnqhv3.fsf@dustycloud.org> <20160211225009.GA4943@novena-choice-citizen.lan> <87oabm2tfa.fsf@gnu.org> <87ziv595xb.fsf@dustycloud.org> <87twl2xo6c.fsf@gnu.org> <87si0k8th9.fsf@dustycloud.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXwH8-0003bZ-GE for bug-guix@gnu.org; Mon, 22 Feb 2016 14:36:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXwH4-0004Vy-9W for bug-guix@gnu.org; Mon, 22 Feb 2016 14:36:06 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:41347) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXwH4-0004VY-5V for bug-guix@gnu.org; Mon, 22 Feb 2016 14:36:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aXwH3-0002tx-Ry for bug-guix@gnu.org; Mon, 22 Feb 2016 14:36:01 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87si0k8th9.fsf@dustycloud.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 22633@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Christopher Allan Webber writes: > Ludovic Courtès writes: > >> Libkmod honors ‘modprobe.blacklist’ (in ‘kcmdline_parse_result’ in >> libkmod-config.c) and eudev passes KMOD_PROBE_APPLY_BLACKLIST >> unconditionally in udev-builtin-kmod.c (meaning it honors it too.) >> >> However, there’s a hyphen-vs-underscore issue, I think. Namely, the >> file is called ‘kvm-intel.ko’, but the normalized module name is >> ‘kvm_intel’, and this is what libkmod expects (commit 5c7dd5a changes >> our code to normalize module names similarly.) >> >> Could you try with “modprobe.blacklist=kvm_intel”? > > I tried it, and it works! This does mean that /dev/kvm doesn't exist, > so I should be able to write a patch to Guix that disables kvm for qemu > when /dev/kvm is absent. Great! :) This is slightly based off of Leo's preliminary patch, so I included him in the copyright headers. I've tested and it works (in terms of disabling kvm if no /dev/kvm is present) here. Let me know if I need to fix something or if I should push... --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-vm-Only-pass-enable-kvm-to-qemu-if-dev-kvm-is-presen.patch Content-Transfer-Encoding: 8bit >From 852e0049213a0a80cacdcad4aba13ab242c3fbd8 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 22 Feb 2016 11:23:14 -0800 Subject: [PATCH] vm: Only pass "-enable-kvm" to qemu if /dev/kvm is present. * gnu/build/vm.scm (load-in-linux-vm): Only pass "-enable-kvm" flag to qemu if "/dev/kvm" is present. * gnu/system/vm.scm (common-kvm-options): Same as above. --- gnu/build/vm.scm | 19 ++++++++++++++----- gnu/system/vm.scm | 10 +++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index a095f9d..823156d 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -1,5 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès +;;; Copyright © 2016 Christopher Allan Webber +;;; Copyright © 2016 Leo Famulari ;;; ;;; This file is part of GNU Guix. ;;; @@ -97,7 +99,7 @@ the #:references-graphs parameter of 'derivation'." (_ #f)) (unless (zero? - (apply system* qemu "-enable-kvm" "-nographic" "-no-reboot" + (apply system* qemu "-nographic" "-no-reboot" "-m" (number->string memory-size) "-net" "nic,model=virtio" "-virtfs" @@ -111,10 +113,17 @@ the #:references-graphs parameter of 'derivation'." "-initrd" initrd "-append" (string-append "console=ttyS0 --load=" builder) - (if make-disk-image? - `("-drive" ,(string-append "file=" image-file - ",if=virtio")) - '()))) + (append + (if make-disk-image? + `("-drive" ,(string-append "file=" image-file + ",if=virtio")) + '()) + ;; Only enable kvm if we see /dev/kvm exists. + ;; This allows uers without hardware virtualization to still use these + ;; commands. + (if (file-exists? "/dev/kvm") + '("-enable-kvm") + '())))) (error "qemu failed" qemu)) (if make-disk-image? diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index a7c03bd..5235ee3 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -1,5 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès +;;; Copyright © 2016 Christopher Allan Webber +;;; Copyright © 2016 Leo Famulari ;;; ;;; This file is part of GNU Guix. ;;; @@ -457,7 +459,13 @@ with '-virtfs' options for the host file systems listed in SHARED-FS." "\" ")) #~(string-append - " -enable-kvm -no-reboot -net nic,model=virtio \ + ;; Only enable kvm if we see /dev/kvm exists. + ;; This allows uers without hardware virtualization to still use these + ;; commands. + #$(if (file-exists? "/dev/kvm") + " -enable-kvm " + "") + " -no-reboot -net nic,model=virtio \ " #$@(map virtfs-option shared-fs) " \ -net user \ -serial stdio -vga std \ -- 2.6.3 --=-=-=--