On Thu, Jun 28, 2012 at 04:06:38PM -0400, Guido Trotter wrote:
> Still doesn't work for git am, sorry.
> Would you mind sending it to the list with git send-email ?

Guido, FYI it's possible to git am it - just remove the extra header,
and un-wrap the 2 lines which were wrapped by the email client:

 - if hvp[constants.HV_REBOOT_BEHAVIOR …
 - # TODO: Add a check

Attached to this email is the git-am-able file :)

iustin
>From 7565c856efe5ddda635e4723724cc7118ac28151 Mon Sep 17 00:00:00 2001
From: Jack <[email protected]>
Date: Thu, 28 Jun 2012 20:39:17 +0400
Subject: [PATCH] Add PCI passthrough for hvm xen

---
 lib/constants.py         |    3 +++
 lib/hypervisor/hv_xen.py |    9 ++++++++-
 lib/query.py             |    1 +
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/lib/constants.py b/lib/constants.py
index b76863e..d3d3e7b 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -769,6 +769,7 @@ HV_VHOST_NET = "vhost_net"
 HV_KVM_USE_CHROOT = "use_chroot"
 HV_CPU_MASK = "cpu_mask"
 HV_MEM_PATH = "mem_path"
+HV_PASSTHROUGH = "pci_pass"
 HV_BLOCKDEV_PREFIX = "blockdev_prefix"
 HV_REBOOT_BEHAVIOR = "reboot_behavior"

@@ -823,6 +824,7 @@ HVS_PARAMETER_TYPES = {
   HV_KVM_USE_CHROOT: VTYPE_BOOL,
   HV_CPU_MASK: VTYPE_STRING,
   HV_MEM_PATH: VTYPE_STRING,
+  HV_PASSTHROUGH: VTYPE_STRING,
   HV_BLOCKDEV_PREFIX: VTYPE_STRING,
   HV_REBOOT_BEHAVIOR: VTYPE_STRING,
   }
@@ -1759,6 +1761,7 @@ HVC_DEFAULTS = {
     HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
     HV_USE_LOCALTIME: False,
     HV_BLOCKDEV_PREFIX: "hd",
+    HV_PASSTHROUGH: "",
     HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
     HV_CPU_MASK: CPU_PINNING_ALL,
     },
diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py
index a757617..8a4dd05 100644
--- a/lib/hypervisor/hv_xen.py
+++ b/lib/hypervisor/hv_xen.py
@@ -736,6 +736,8 @@ class XenHvmHypervisor(XenHypervisor):
     constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
     # TODO: Add a check for the blockdev prefix (matching [a-z:] or similar).
     constants.HV_BLOCKDEV_PREFIX: hv_base.NO_CHECK,
+    # Add PCI passthrough
+    constants.HV_PASSTHROUGH:  hv_base.NO_CHECK,
     constants.HV_REBOOT_BEHAVIOR:
       hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS),
     constants.HV_CPU_MASK: hv_base.OPT_MULTI_CPU_MASK_CHECK,
@@ -834,7 +836,12 @@ class XenHvmHypervisor(XenHypervisor):
       disk_data.append(iso)

     config.write("disk = [%s]\n" % (",".join(disk_data)))
-
+    # Add PCI passthrough
+    pci_pass_arr = []
+    pci_pass = hvp[constants.HV_PASSTHROUGH]
+    if pci_pass:
+        pci_pass_arr = pci_pass.split(";")
+        config.write("pci = %s \n" % pci_pass_arr)
     config.write("on_poweroff = 'destroy'\n")
     if hvp[constants.HV_REBOOT_BEHAVIOR] == constants.INSTANCE_REBOOT_ALLOWED:
       config.write("on_reboot = 'restart'\n")
diff --git a/lib/query.py b/lib/query.py
index cd8fdbe..190b154 100644
--- a/lib/query.py
+++ b/lib/query.py
@@ -1772,6 +1772,7 @@ def _GetInstanceParameterFields():
     constants.HV_NIC_TYPE: "NIC_type",
     constants.HV_PAE: "PAE",
     constants.HV_VNC_BIND_ADDRESS: "VNC_bind_address",
+    constants.HV_PASSTHROUGH: "pci_pass",
     }

   fields = [
-- 
1.7.2.5

Reply via email to