Federico Simoncelli has uploaded a new change for review.

Change subject: [wip] hooks: add the nested virtualization hook
......................................................................

[wip] hooks: add the nested virtualization hook

If the nested virtualization is enabled in your kvm module this hook
will expose it to the guests.

Change-Id: I08c24c1b932370577e9687d75e292cd7c40f8e5d
Signed-off-by: Federico Simoncelli <[email protected]>
---
M configure.ac
M vdsm.spec.in
M vdsm_hooks/Makefile.am
A vdsm_hooks/nestedvt/Makefile.am
A vdsm_hooks/nestedvt/before_vm_start.py
5 files changed, 92 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/25/9225/1

diff --git a/configure.ac b/configure.ac
index 5d8b238..bd92fb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,6 +203,7 @@
        vdsm_hooks/hugepages/Makefile
        vdsm_hooks/isolatedprivatevlan/Makefile
        vdsm_hooks/Makefile
+       vdsm_hooks/nestedvt/Makefile
        vdsm_hooks/numa/Makefile
        vdsm_hooks/pincpu/Makefile
        vdsm_hooks/promisc/Makefile
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 5daea0b..47ce21e 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -284,6 +284,14 @@
 by using <filterref filter='clean-traffic'/> libvirt filter
 and by adding custom filter: isolatedprivatevlan-vdsm.xml
 
+%package hook-nestedvt
+Summary:        Nested Virtualization support for VDSM
+BuildArch:      noarch
+
+%description hook-nestedvt
+If the nested virtualization is enabled in your kvm module
+this hook will expose it to the guests.
+
 %package hook-numa
 Summary:        numa sopport for VDSM
 BuildArch:      noarch
@@ -853,6 +861,10 @@
 %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_isolatedprivatevlan
 %config(noreplace) %{_sysconfdir}/libvirt/nwfilter/isolatedprivatevlan-vdsm.xml
 
+%files hook-nestedvt
+%defattr(-, root, root, -)
+%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_nestedvt
+
 %files hook-numa
 %defattr(-, root, root, -)
 %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_numa
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index e6a8280..4ef163a 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -31,6 +31,7 @@
        hostusb \
        hugepages \
        isolatedprivatevlan \
+       nestedvt \
        numa \
        pincpu \
        promisc \
diff --git a/vdsm_hooks/nestedvt/Makefile.am b/vdsm_hooks/nestedvt/Makefile.am
new file mode 100644
index 0000000..b480407
--- /dev/null
+++ b/vdsm_hooks/nestedvt/Makefile.am
@@ -0,0 +1,32 @@
+#
+# Copyright 2012 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+include $(top_srcdir)/build-aux/Makefile.subs
+
+EXTRA_DIST = \
+       before_vm_start.py
+
+install-data-local:
+       $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+       $(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
+               $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_nestedvt
+
+uninstall-local:
+       $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_nestedvt
diff --git a/vdsm_hooks/nestedvt/before_vm_start.py 
b/vdsm_hooks/nestedvt/before_vm_start.py
new file mode 100755
index 0000000..446a487
--- /dev/null
+++ b/vdsm_hooks/nestedvt/before_vm_start.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+#
+# Copyright 2012 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import hooking
+
+cpu_nested_features = {
+    "kvm_intel": "vmx",
+    "kvm_amd": "svm",
+}
+
+for kvm_mod in ("kvm_intel", "kvm_amd"):
+    kvm_mod_path = "/sys/module/%s/parameters/nested" % kvm_mod
+    try:
+        with file(kvm_mod_path) as f:
+            if f.readline().strip() == "Y":
+                break
+    except IOError:
+        pass
+else:
+    kvm_mod = None
+
+if kvm_mod:
+    domxml = hooking.read_domxml()
+    feature_vmx = domxml.createElement("feature")
+    feature_vmx.setAttribute("name", cpu_nested_features[kvm_mod])
+    feature_vmx.setAttribute("policy", "require")
+    domxml.getElementsByTagName("cpu")[0].appendChild(feature_vmx)
+    hooking.write_domxml(domxml)


--
To view, visit http://gerrit.ovirt.org/9225
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08c24c1b932370577e9687d75e292cd7c40f8e5d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to