Skip to contentSkip to conversation

:libxl__get_free_memory_slack cannot return when creating a vm by xl

PATCH In review Jun Zhu (Intern) 2 participants 4 messages Sep 26, 2010 – Sep 27, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 :libxl__get_free_memory_slack cannot return when creating a vm by xl

Hi,

This patch fixes the problem when xl create invokes libxl__get_free_memory_slack which does not return. In the libxl__fill_dom0_memory_info function, if */memory/target is existed, it returns directly, leaving */memory/freemem-slack still empty. I don't think it is necessory to check */memory/target in the function libxl__fill_dom0_memory_info, since this function is to fill the dom0’s memory info. Moreover, it is not correct to believe that */memory/freemem-slack exists by checking */memory/target.

tools/libxl/libxl.c +0 -16
diff -r 0c102f92d61e tools/libxl/libxl.c
@@ -2779,7 +2779,6 @@ static int libxl__fill_dom0_memory_info(
     int rc;
     libxl_dominfo info;
     libxl_physinfo physinfo;
-    char *target = NULL, *endptr = NULL;
     char *target_path = "/local/domain/0/memory/target";
     char *max_path = "/local/domain/0/memory/static-max";
     char *free_mem_slack_path = "/local/domain/0/memory/freemem-slack";
@@ -2790,19 +2789,6 @@ static int libxl__fill_dom0_memory_info(
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
 
-    target = libxl__xs_read(gc, t, target_path);
-    if (target) {
-        *target_memkb = strtoul(target, &endptr, 10);
-        if (*endptr != '\0') {
-            LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR,
-                    "invalid memory target %s from %s\n", target, target_path);
-            rc = ERROR_FAIL;
-            goto out;
-        }
-        rc = 0;
-        goto out;
-    }
-
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
         return rc;
@@ -2827,12 +2813,10 @@ retry_transaction:
     *target_memkb = (uint32_t) info.current_memkb;
     rc = 0;
 
-out:
     if (!xs_transaction_end(ctx->xsh, t, 0))
         if (errno == EAGAIN)
             goto retry_transaction;
 
-
     return rc;
 }
 

Jun Zhu
Citrix Systems UK

#1 lore raw
Quoted 5 lines · Jun Zhu (Intern)

Hi,

This patch fixes the problem when xl create invokes libxl__get_free_memory_slack which does not return. In the libxl__fill_dom0_memory_info function, if */memory/target is existed, it returns directly, leaving */memory/freemem-slack still empty. I don't think it is necessory to check */memory/target in the function libxl__fill_dom0_memory_info, since this function is to fill the dom0???s memory info. Moreover, it is not correct to believe that */memory/freemem-slack exists by checking */memory/target.

How did you get in the state of having the target on xenstore but not freemem-slack?
If you are using libxl this shouldn't be possible unless you mess around with xenstore directly.

#2 lore raw

Hi,

Quoted 4 lines

How did you get in the state of having the target on xenstore but not freemem-slack?
If you are using libxl this shouldn't be possible unless you mess around with xenstore directly.

I did not try to find where target is created. I think the target is created when dom0 starts. I do nothing related with the dom0 infomation in xenstore.

But, in my opition, it is not enough to check dom0 memory info only by target. BTW, is it consistent with the xm?

Jun Zhu
Citrix Systems UK
________________________________________

#3 lore raw
Quoted 10 lines · Jun Zhu (Intern)

Hi,

Quoted 4 lines

How did you get in the state of having the target on xenstore but not freemem-slack?
If you are using libxl this shouldn't be possible unless you mess around with xenstore directly.

I did not try to find where target is created. I think the target is created when dom0 starts. I do nothing related with the dom0 infomation in xenstore.

Are you starting xend at boot?

Quoted 1 line

But, in my opition, it is not enough to check dom0 memory info only by target.

In that case you should add two more checks for the existance of static-max and freemem-slack, printing a warning if only one or two of the nodes are missing (because this state shouldn't be possible if the user is only using libxl/xl).
If some nodes are missing, we should only write those nodes to xenstore without overwriting the informations that are already there.