[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC PATCH 9/23] Tools/libxl: Inform device model to create a guest with a vIOMMU device



From: Chao Gao <chao.gao@xxxxxxxxx>

A new device, xen_viommu, is added to qemu. In xen side, we can inform device
model to create a guest with a vIOMMU device through "-device xen_viommu" when
a viommu has been configurated in guest configuration file. Some specific
parameters are passed through xenstore. Qemu will create a dummy device to
preserve the address range and the dummy device will launch a viommu creation
and destruction throuth libxc interface.

Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx>
---
 tools/libxl/libxl_create.c | 12 +++++++++++-
 tools/libxl/libxl_dm.c     |  9 +++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index e741b9a..7954186 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -453,7 +453,7 @@ int libxl__domain_build(libxl__gc *gc,
         vments[4] = "start_time";
         vments[5] = GCSPRINTF("%lu.%02d", 
start_time.tv_sec,(int)start_time.tv_usec/10000);
 
-        localents = libxl__calloc(gc, 9, sizeof(char *));
+        localents = libxl__calloc(gc, 11, sizeof(char *));
         i = 0;
         localents[i++] = "platform/acpi";
         localents[i++] = libxl__acpi_defbool_val(info) ? "1" : "0";
@@ -472,6 +472,11 @@ int libxl__domain_build(libxl__gc *gc,
                                    info->u.hvm.mmio_hole_memkb << 10);
             }
         }
+        if (info->u.hvm.viommu.base_addr) {
+            localents[i++] = "viommu/base_addr";
+            localents[i++] =
+                GCSPRINTF("%"PRIu64, info->u.hvm.viommu.base_addr);
+        }
 
         break;
     case LIBXL_DOMAIN_TYPE_PV:
@@ -680,6 +685,11 @@ retry_transaction:
                     GCSPRINTF("%s/attr", dom_path),
                     rwperm, ARRAY_SIZE(rwperm));
 
+    if (info->type == LIBXL_DOMAIN_TYPE_HVM)
+        libxl__xs_mknod(gc, t,
+                        GCSPRINTF("%s/viommu", dom_path),
+                        noperm, ARRAY_SIZE(noperm));
+
     if (libxl_defbool_val(info->driver_domain)) {
         /*
          * Create a local "libxl" directory for each guest, since we might want
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 281058d..f7fb81e 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1252,6 +1252,15 @@ static int libxl__build_device_model_args_new(libxl__gc 
*gc,
             flexarray_append(dm_args, "-net");
             flexarray_append(dm_args, "none");
         }
+
+        if ( !libxl_defbool_is_default(b_info->u.hvm.viommu.intremap)
+             && libxl_defbool_val(b_info->u.hvm.viommu.intremap) )
+        {
+            flexarray_append(dm_args, "-device");
+            flexarray_append(dm_args,
+                             GCSPRINTF("xen_viommu,cap=%ld",
+                                       b_info->u.hvm.viommu.cap));
+        }
     } else {
         if (!sdl && !vnc) {
             flexarray_append(dm_args, "-nographic");
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.