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

[Xen-devel] [PATCH RFC] Supporting more than 4 emulated NICs


  • To: "xen-devel" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Charles Arnold" <carnold@xxxxxxxx>
  • Date: Tue, 15 May 2018 11:34:45 -0600
  • Delivery-date: Tue, 15 May 2018 17:34:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Some time ago this bug was written up,

https://bugs.xenproject.org/xen/bug/46
"qemu-upstream: limitation on 4 emulated NICs prevents guest from starting
unless PV override is used."

While there were some proposed patches and discussion in the bug and on the
mailing list back in 2014/2015 to address this issue it hasn't seen much
movement since then.

The last proposed patch in the bug by Stefano Stabellini is below with some
small adjustments I've made.

What is the status of this patch? Does it break migration?


libxl: account for romfile memory

Account for memory needed for emulated network card rom files.
Assume 256K for each romfile.

Reviewed-by: Charles Arnold <carnold@xxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index f0fd5fd..56a0575 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -471,7 +471,8 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
         return ERROR_FAIL;
     }
 
-    if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + size) < 0) {
+    if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + size
+       + libxl__get_rom_memory_kb(gc, domid, d_config)) < 0) {
         LOGE(ERROR, "Couldn't set max memory");
         return ERROR_FAIL;
     }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c582894..ec99fc0 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -102,8 +102,9 @@
 #define LIBXL_XENCONSOLE_LIMIT 1048576
 #define LIBXL_XENCONSOLE_PROTOCOL "vt100"
 #define LIBXL_MAXMEM_CONSTANT 1024
+#define LIBXL_ROMSIZE_KB 256
 #define LIBXL_PV_EXTRA_MEMORY 1024
-#define LIBXL_HVM_EXTRA_MEMORY 2048
+#define LIBXL_HVM_EXTRA_MEMORY (LIBXL_MAXMEM_CONSTANT + 1024)
 #define LIBXL_MIN_DOM0_MEM (128*1024)
 #define LIBXL_INVALID_GFN (~(uint64_t)0)
 #define LIBXL_VGA_HOLE_SIZE 0x20
@@ -1200,6 +1201,13 @@ _hidden char * libxl__domain_pvcontrol_read(libxl__gc 
*gc,
 _hidden int libxl__domain_pvcontrol_write(libxl__gc *gc, xs_transaction_t t,
                                           uint32_t domid, const char *cmd);
 
+/* Returns the amount of extra mem required to allocate roms or an libxl
+ * error code on error.
+ * The *d_config parameter is optional.
+ */
+_hidden int libxl__get_rom_memory_kb(libxl__gc *gc, uint32_t domid,
+                                     libxl_domain_config *d_config);
+
 /* from xl_device */
 _hidden char *libxl__device_disk_string_of_backend(libxl_disk_backend backend);
 _hidden char *libxl__device_disk_string_of_format(libxl_disk_format format);
diff --git a/tools/libxl/libxl_mem.c b/tools/libxl/libxl_mem.c
index e551e09..b6f9440 100644
--- a/tools/libxl/libxl_mem.c
+++ b/tools/libxl/libxl_mem.c
@@ -17,6 +17,30 @@
 #include "libxl_internal.h"
 #include "libxl_arch.h"
 
+int libxl__get_rom_memory_kb(libxl__gc *gc, uint32_t domid, 
libxl_domain_config *d_config)
+{
+    int i, count_rom, rc;
+    libxl_domain_config local_d_config;
+
+    if (d_config == NULL) {
+        libxl_domain_config_init(&local_d_config);
+        rc = libxl__get_domain_configuration(gc, domid, &local_d_config);
+        if (rc < 0)
+            return rc;
+        d_config = &local_d_config;
+    }
+
+    if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV)
+        return 0;
+
+    for (i = 0, count_rom = 0; i < d_config->num_nics; i++) {
+        if (d_config->nics[i].nictype == LIBXL_NIC_TYPE_VIF_IOEMU)
+            count_rom++;
+    }
+
+    return count_rom*LIBXL_ROMSIZE_KB;
+}
+
 /*
  * Set the maximum memory size of the domain in the hypervisor. There is no
  * change of the current memory size involved. The specified memory size can
@@ -74,11 +98,13 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, 
uint64_t max_memkb)
         goto out;
     }
 
-    rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + size);
+    rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + size
+                             + libxl__get_rom_memory_kb(gc, domid, NULL));
     if (rc != 0) {
         LOGED(ERROR, domid,
-              "xc_domain_setmaxmem domid=%d memkb=%"PRIu64" failed ""rc=%d\n",
-              domid, max_memkb + size, rc);
+              "xc_domain_setmaxmem domid=%d memkb=%"PRIu64" failed rc=%d\n",
+              domid, max_memkb + size +
+              libxl__get_rom_memory_kb(gc, domid, NULL), rc);
         goto out;
     }
 
@@ -286,11 +312,12 @@ retry_transaction:
 
     if (enforce) {
         memorykb = new_target_memkb + videoram;
-        r = xc_domain_setmaxmem(ctx->xch, domid, memorykb + size);
+        r = xc_domain_setmaxmem(ctx->xch, domid, memorykb + size
+                + libxl__get_rom_memory_kb(gc, domid, NULL));
         if (r != 0) {
             LOGED(ERROR, domid,
                   "xc_domain_setmaxmem memkb=%"PRIu64" failed ""rc=%d\n",
-                  memorykb + size,
+                  memorykb + size + libxl__get_rom_memory_kb(gc, domid, NULL),
                   r);
             abort_transaction = 1;
             rc = ERROR_FAIL;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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