Skip to contentSkip to conversation

xl create: endless loop

DISCUSSION Applied Christoph Egger 5 participants 21 messages Oct 18, 2010 – Dec 14, 2010

lore
Share & tools
lore
#0 lore raw

Hi!

I cannot start a guest with 'xl create' due to an endless loop in libxl.c, function libxl__get_free_memory_slack():

There is this code snippet:

retry:

    free_mem_slack_s = libxl__xs_read(gc, XBT_NULL, free_mem_slack_path);
    if (!free_mem_slack_s) {
        rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
        if (rc < 0)
            return rc;
        goto retry;
    } else {

libxl__xs_read() returns 0 and libxl__fill_dom0_memory_info() also returns 0. So there's a loop of retries.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#1 lore raw
Quoted 17 lines · On Monday 18 October 2010 14:50:35 Christoph Egger wrote:

Hi!

I cannot start a guest with 'xl create' due to an endless loop in libxl.c, function libxl__get_free_memory_slack():

There is this code snippet:

retry:

    free_mem_slack_s = libxl__xs_read(gc, XBT_NULL, free_mem_slack_path);
    if (!free_mem_slack_s) {
        rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
        if (rc < 0)
            return rc;
        goto retry;
    } else {
Quoted 2 lines

libxl__xs_read() returns 0 and libxl__fill_dom0_memory_info() also returns
0. So there's a loop of retries.

Attached patch fixes the endless loop.

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
tools/libxl/libxl.c +1 -1
diff -r 9d8d6b93114e tools/libxl/libxl.c
@@ -2836,7 +2836,7 @@ retry:
     free_mem_slack_s = libxl__xs_read(gc, XBT_NULL, free_mem_slack_path);
     if (!free_mem_slack_s) {
         rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
-        if (rc < 0)
+        if (rc <= 0)
             return rc;
         goto retry;
     } else {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 18 lines · Christoph Egger
Quoted 17 lines · On Monday 18 October 2010 14:50:35 Christoph Egger wrote:

Hi!

I cannot start a guest with 'xl create' due to an endless loop in libxl.c, function libxl__get_free_memory_slack():

There is this code snippet:

retry:

    free_mem_slack_s = libxl__xs_read(gc, XBT_NULL, free_mem_slack_path);
    if (!free_mem_slack_s) {
        rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
        if (rc < 0)
            return rc;
        goto retry;
    } else {
Quoted 6 lines
Quoted 2 lines

libxl__xs_read() returns 0 and libxl__fill_dom0_memory_info() also returns
0. So there's a loop of retries.

Attached patch fixes the endless loop.

thanks for the patch but this cannot possibly be the right fix:

tools/libxl/libxl.c +1 -1
diff -r 9d8d6b93114e tools/libxl/libxl.c
@@ -2836,7 +2836,7 @@ retry:
     free_mem_slack_s = libxl__xs_read(gc, XBT_NULL, free_mem_slack_path);
     if (!free_mem_slack_s) {
         rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
-        if (rc < 0)
+        if (rc <= 0)
             return rc;
         goto retry;
     } else {

the idea is that libxl__fill_dom0_memory_info should fill the missing informations in xenstore so that we can go ahead and try to read them again and the second time should be successful. Libxl__fill_dom0_memory_info returns 0 on success, so it is correct to goto retry in that case.

The bug must be in libxl__fill_dom0_memory_info that doesn't return error when it should.
Does the appended patch works for you?

---

tools/libxl/libxl.c +6 -3
diff -r 00b92112b055 tools/libxl/libxl.c
@@ -2793,11 +2793,11 @@ retry_transaction:
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
+        goto out;
 
     libxl__xs_write(gc, t, target_path, "%"PRIu32,
             (uint32_t) info.current_memkb);
@@ -2816,9 +2816,12 @@ retry_transaction:
     rc = 0;
 
 out:
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
+        else
+            rc = ERROR_FAIL;
+    }
 
 
     return rc;
#3 lore raw
Quoted 75 lines · On Thursday 21 October 2010 16:11:55 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger
Quoted 17 lines · On Monday 18 October 2010 14:50:35 Christoph Egger wrote:

Hi!

I cannot start a guest with 'xl create' due to an endless loop in libxl.c, function libxl__get_free_memory_slack():

There is this code snippet:

retry:
free_mem_slack_s = libxl__xs_read(gc, XBT_NULL,

free_mem_slack_path); if (!free_mem_slack_s) {
        rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
        if (rc < 0)
            return rc;
        goto retry;
    } else {
Quoted 6 lines
Quoted 2 lines

libxl__xs_read() returns 0 and libxl__fill_dom0_memory_info() also returns 0. So there's a loop of retries.

Attached patch fixes the endless loop.

thanks for the patch but this cannot possibly be the right fix:

diff -r 9d8d6b93114e tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -2836,7 +2836,7 @@ retry:
     free_mem_slack_s = libxl__xs_read(gc, XBT_NULL, free_mem_slack_path);
     if (!free_mem_slack_s) {
         rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
-        if (rc < 0)
+        if (rc <= 0)
             return rc;
         goto retry;
     } else {

the idea is that libxl__fill_dom0_memory_info should fill the missing informations in xenstore so that we can go ahead and try to read them again and the second time should be successful. Libxl__fill_dom0_memory_info returns 0 on success, so it is correct to goto retry in that case.

The bug must be in libxl__fill_dom0_memory_info that doesn't return error when it should.
Does the appended patch works for you?

---

diff -r 00b92112b055 tools/libxl/libxl.c

tools/libxl/libxl.c +2 -2
@@ -2793,11 +2793,11 @@ retry_transaction:
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
+        goto out;
 
     libxl__xs_write(gc, t, target_path, "%"PRIu32,
             (uint32_t) info.current_memkb);
@@ -2816,9 +2816,12 @@ retry_transaction:
     rc = 0;
 
 out:

tools/libxl/libxl.c retry_transaction: · line 2827

Quoted 10 lines
tools/libxl/libxl.c +4 -1
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
+        else
+            rc = ERROR_FAIL;
+    }
 
 
     return rc;

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#4 lore raw
Quoted 90 lines · On Wednesday 03 November 2010 17:12:47 Christoph Egger wrote:
Quoted 75 lines · On Thursday 21 October 2010 16:11:55 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger
Quoted 17 lines · On Monday 18 October 2010 14:50:35 Christoph Egger wrote:

Hi!

I cannot start a guest with 'xl create' due to an endless loop in libxl.c, function libxl__get_free_memory_slack():

There is this code snippet:

retry:
free_mem_slack_s = libxl__xs_read(gc, XBT_NULL,

free_mem_slack_path); if (!free_mem_slack_s) {
        rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
        if (rc < 0)
            return rc;
        goto retry;
    } else {
Quoted 6 lines
Quoted 2 lines

libxl__xs_read() returns 0 and libxl__fill_dom0_memory_info() also returns 0. So there's a loop of retries.

Attached patch fixes the endless loop.

thanks for the patch but this cannot possibly be the right fix:

diff -r 9d8d6b93114e tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -2836,7 +2836,7 @@ retry:
     free_mem_slack_s = libxl__xs_read(gc, XBT_NULL,
 free_mem_slack_path); if (!free_mem_slack_s) {
         rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
-        if (rc < 0)
+        if (rc <= 0)
             return rc;
         goto retry;
     } else {

the idea is that libxl__fill_dom0_memory_info should fill the missing informations in xenstore so that we can go ahead and try to read them again and the second time should be successful. Libxl__fill_dom0_memory_info returns 0 on success, so it is correct to goto retry in that case.

The bug must be in libxl__fill_dom0_memory_info that doesn't return error when it should.
Does the appended patch works for you?

---

diff -r 00b92112b055 tools/libxl/libxl.c

tools/libxl/libxl.c +2 -2
@@ -2793,11 +2793,11 @@ retry_transaction:
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
+        goto out;
 
     libxl__xs_write(gc, t, target_path, "%"PRIu32,
             (uint32_t) info.current_memkb);
@@ -2816,9 +2816,12 @@ retry_transaction:
     rc = 0;
 
 out:

tools/libxl/libxl.c retry_transaction: · line 2827

Quoted 10 lines
tools/libxl/libxl.c +4 -1
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
+        else
+            rc = ERROR_FAIL;
+    }
 
 
     return rc;

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

Quoted 16 lines
    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }

A slightly modified version works.

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
tools/libxl/libxl.c +6 -6
diff -r 8f66a16efee0 tools/libxl/libxl.c
@@ -2787,17 +2787,15 @@ retry_transaction:
             rc = ERROR_FAIL;
             goto out;
         }
-        rc = 0;
-        goto out;
     }
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
+        goto out;
 
     libxl__xs_write(gc, t, target_path, "%"PRIu32,
             (uint32_t) info.current_memkb);
@@ -2816,10 +2814,12 @@ retry_transaction:
     rc = 0;
 
 out:
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
-
+        else
+            rc = ERROR_FAIL;
+    }
 
     return rc;
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw

Did the patch apply? This issue still exist in xen-unstable(22364).

best regards
yang

Quoted 132 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Christoph Egger
Sent: Thursday, November 04, 2010 11:40 PM
To: [email protected]
Cc: Jackson; Stefano Stabellini
Subject: Re: [Xen-devel][PATCH] xl create: endless loop

Quoted 65 lines · On Wednesday 03 November 2010 17:12:47 Christoph Egger wrote:
Quoted 64 lines · On Thursday 21 October 2010 16:11:55 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger
Quoted 17 lines · On Monday 18 October 2010 14:50:35 Christoph Egger wrote:

Hi!

I cannot start a guest with 'xl create' due to an endless loop in libxl.c, function libxl__get_free_memory_slack():

There is this code snippet:

retry:
free_mem_slack_s = libxl__xs_read(gc, XBT_NULL,

free_mem_slack_path); if (!free_mem_slack_s) {
        rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
        if (rc < 0)
            return rc;
        goto retry;
    } else {
Quoted 6 lines
Quoted 2 lines

libxl__xs_read() returns 0 and libxl__fill_dom0_memory_info() also returns 0. So there's a loop of retries.

Attached patch fixes the endless loop.

thanks for the patch but this cannot possibly be the right fix:

diff -r 9d8d6b93114e tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -2836,7 +2836,7 @@ retry:
     free_mem_slack_s = libxl__xs_read(gc, XBT_NULL,
 free_mem_slack_path); if (!free_mem_slack_s) {
         rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
-        if (rc < 0)
+        if (rc <= 0)
             return rc;
         goto retry;
     } else {

the idea is that libxl__fill_dom0_memory_info should fill the missing informations in xenstore so that we can go ahead and try to read them again and the second time should be successful. Libxl__fill_dom0_memory_info returns 0 on success, so it is correct to goto retry in that case.

The bug must be in libxl__fill_dom0_memory_info that doesn't return error when it should.
Does the appended patch works for you?

---

diff -r 00b92112b055 tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -2793,11 +2793,11 @@ retry_transaction:
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
Quoted 7 lines

tools/libxl/libxl.c retry_transaction:

Quoted 7 lines
tools/libxl/libxl.c +1 -1
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
+        goto out;
 
     libxl__xs_write(gc, t, target_path, "%"PRIu32,
             (uint32_t) info.current_memkb); @@ -2816,9 +2816,12

@@

Quoted 18 lines
Quoted 4 lines

retry_transaction:

     rc = 0;

out:

tools/libxl/libxl.c retry_transaction: · line 2824

Quoted 10 lines
tools/libxl/libxl.c +4 -1
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
+        else
+            rc = ERROR_FAIL;
+    }
 
 
     return rc;

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

Quoted 16 lines
    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }

A slightly modified version works.

--
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632

#6 lore raw
Quoted 1 line · Yang Z

Did the patch apply? This issue still exist in xen-unstable(22364).

Yes.

Quoted 126 lines

best regards
yang

Quoted 122 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Christoph Egger Sent: Thursday, November 04, 2010 11:40 PM
To: [email protected]
Cc: Jackson; Stefano Stabellini
Subject: Re: [Xen-devel][PATCH] xl create: endless loop

Quoted 65 lines · On Wednesday 03 November 2010 17:12:47 Christoph Egger wrote:
Quoted 64 lines · On Thursday 21 October 2010 16:11:55 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger
Quoted 17 lines · On Monday 18 October 2010 14:50:35 Christoph Egger wrote:

Hi!

I cannot start a guest with 'xl create' due to an endless loop in libxl.c, function libxl__get_free_memory_slack():

There is this code snippet:

retry:
free_mem_slack_s = libxl__xs_read(gc, XBT_NULL,

free_mem_slack_path); if (!free_mem_slack_s) {
        rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
        if (rc < 0)
            return rc;
        goto retry;
    } else {
Quoted 6 lines
Quoted 2 lines

libxl__xs_read() returns 0 and libxl__fill_dom0_memory_info() also returns 0. So there's a loop of retries.

Attached patch fixes the endless loop.

thanks for the patch but this cannot possibly be the right fix:

diff -r 9d8d6b93114e tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -2836,7 +2836,7 @@ retry:
     free_mem_slack_s = libxl__xs_read(gc, XBT_NULL,
 free_mem_slack_path); if (!free_mem_slack_s) {
         rc = libxl__fill_dom0_memory_info(gc, &target_memkb);
-        if (rc < 0)
+        if (rc <= 0)
             return rc;
         goto retry;
     } else {

the idea is that libxl__fill_dom0_memory_info should fill the missing informations in xenstore so that we can go ahead and try to read them again and the second time should be successful. Libxl__fill_dom0_memory_info returns 0 on success, so it is correct to goto retry in that case.

The bug must be in libxl__fill_dom0_memory_info that doesn't return error when it should.
Does the appended patch works for you?

---

diff -r 00b92112b055 tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -2793,11 +2793,11 @@ retry_transaction:
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
Quoted 7 lines

tools/libxl/libxl.c retry_transaction:

Quoted 7 lines
tools/libxl/libxl.c +1 -1
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
+        goto out;
 
     libxl__xs_write(gc, t, target_path, "%"PRIu32,
             (uint32_t) info.current_memkb); @@ -2816,9 +2816,12

@@

Quoted 18 lines
Quoted 4 lines

retry_transaction:

     rc = 0;

out:

tools/libxl/libxl.c retry_transaction: · line 2824

Quoted 10 lines
tools/libxl/libxl.c +4 -1
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
+        else
+            rc = ERROR_FAIL;
+    }
 
 
     return rc;

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

Quoted 15 lines
    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }

A slightly modified version works.

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#7 lore raw
In reply to Christoph Egger
Quoted 20 lines · Christoph Egger

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }

The problem you are having is that somebody in your system is setting a target for dom0 without setting freemem-slack. Are you still running xend at boot?

Currently libxl__fill_dom0_memory_info assumes that both values are set initially at the same time (by libxl__fill_dom0_memory_info). This patch should fix the issue, I would appreciate if you could test it.

---

libxl: do not assume target and freemem-slack are written at the same time

tools/libxl/libxl.c +34 -22
diff -r 7188d1e4b0e1 tools/libxl/libxl.c
@@ -2779,18 +2779,25 @@ static int libxl__fill_dom0_memory_info(
     int rc;
     libxl_dominfo info;
     libxl_physinfo physinfo;
-    char *target = NULL, *endptr = NULL;
+    char *target = NULL, *staticmax = NULL, *freememslack = 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";
     xs_transaction_t t;
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    uint32_t free_mem_slack = 0;
+    uint32_t free_mem_slack_kb = 0;
 
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
 
     target = libxl__xs_read(gc, t, target_path);
+    staticmax = libxl__xs_read(gc, t, target_path);
+    freememslack = libxl__xs_read(gc, t, target_path);
+    if (target && staticmax && freememslack) {
+        rc = 0;
+        goto out;
+    }
+
     if (target) {
         *target_memkb = strtoul(target, &endptr, 10);
         if (*endptr != '\0') {
@@ -2799,38 +2806,43 @@ retry_transaction:
             rc = ERROR_FAIL;
             goto out;
         }
-        rc = 0;
-        goto out;
     }
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
-
-    libxl__xs_write(gc, t, target_path, "%"PRIu32,
-            (uint32_t) info.current_memkb);
-    libxl__xs_write(gc, t, max_path, "%"PRIu32,
-            (uint32_t) info.max_memkb);
-
-    free_mem_slack = (uint32_t) (PAGE_TO_MEMKB(physinfo.total_pages) -
-            info.current_memkb);
-    /* From empirical measurements the free_mem_slack shouldn't be more
-     * than 15% of the total memory present on the system. */
-    if (free_mem_slack > PAGE_TO_MEMKB(physinfo.total_pages) * 0.15)
-        free_mem_slack = PAGE_TO_MEMKB(physinfo.total_pages) * 0.15;
-    libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32, free_mem_slack);
-
-    *target_memkb = (uint32_t) info.current_memkb;
+        goto out;
+
+    if (target == NULL) {
+        libxl__xs_write(gc, t, target_path, "%"PRIu32,
+                (uint32_t) info.current_memkb);
+        *target_memkb = (uint32_t) info.current_memkb;
+    }
+    if (staticmax == NULL)
+        libxl__xs_write(gc, t, max_path, "%"PRIu32,
+                (uint32_t) info.max_memkb);
+
+    if (freememslack == NULL) {
+        free_mem_slack_kb = (uint32_t) (PAGE_TO_MEMKB(physinfo.total_pages) -
+                info.current_memkb);
+        /* From empirical measurements the free_mem_slack shouldn't be more
+         * than 15% of the total memory present on the system. */
+        if (free_mem_slack_kb > PAGE_TO_MEMKB(physinfo.total_pages) * 0.15)
+            free_mem_slack_kb = PAGE_TO_MEMKB(physinfo.total_pages) * 0.15;
+        libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32, free_mem_slack_kb);
+    }
     rc = 0;
 
 out:
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
+        else
+            rc = ERROR_FAIL;
+    }
 
 
     return rc;
#8 lore raw
Quoted 20 lines · On Tuesday 09 November 2010 19:08:14 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }
Quoted 3 lines

The problem you are having is that somebody in your system is setting a target for dom0 without setting freemem-slack. Are you still running xend at boot?

Yes, I do.
Xen is booted with dom0_mem.
Dom0 has autoballooning disabled in the kernel.

Quoted 29 lines

Currently libxl__fill_dom0_memory_info assumes that both values are set initially at the same time (by libxl__fill_dom0_memory_info). This patch should fix the issue, I would appreciate if you could test it.

---

libxl: do not assume target and freemem-slack are written at the same time

diff -r 7188d1e4b0e1 tools/libxl/libxl.c

tools/libxl/libxl.c +2 -2
@@ -2779,18 +2779,25 @@ static int libxl__fill_dom0_memory_info(
     int rc;
     libxl_dominfo info;
     libxl_physinfo physinfo;
-    char *target = NULL, *endptr = NULL;
+    char *target = NULL, *staticmax = NULL, *freememslack = 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";
     xs_transaction_t t;
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    uint32_t free_mem_slack = 0;
+    uint32_t free_mem_slack_kb = 0;
 

tools/libxl/libxl.c static int libxl__fill_dom0_memory_info( · line 2799

Quoted 10 lines
tools/libxl/libxl.c +6 -0
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
 
     target = libxl__xs_read(gc, t, target_path);
+    staticmax = libxl__xs_read(gc, t, target_path);
+    freememslack = libxl__xs_read(gc, t, target_path);
+    if (target && staticmax && freememslack) {
+        rc = 0;
+        goto out;
+    }

*target, *staticmax and *freememslack contain the value "5". So with this patch, rc always returns 0 from there.

Christoph

Quoted 69 lines
tools/libxl/libxl.c +2 -17
+
     if (target) {
         *target_memkb = strtoul(target, &endptr, 10);
         if (*endptr != '\0') {
@@ -2799,38 +2806,43 @@ retry_transaction:
             rc = ERROR_FAIL;
             goto out;
         }
-        rc = 0;
-        goto out;
     }
 
     rc = libxl_domain_info(ctx, &info, 0);
     if (rc < 0)
-        return rc;
+        goto out;
 
     rc = libxl_get_physinfo(ctx, &physinfo);
     if (rc < 0)
-        return rc;
-
-    libxl__xs_write(gc, t, target_path, "%"PRIu32,
-            (uint32_t) info.current_memkb);
-    libxl__xs_write(gc, t, max_path, "%"PRIu32,
-            (uint32_t) info.max_memkb);
-
-    free_mem_slack = (uint32_t) (PAGE_TO_MEMKB(physinfo.total_pages) -
-            info.current_memkb);
-    /* From empirical measurements the free_mem_slack shouldn't be more
-     * than 15% of the total memory present on the system. */
-    if (free_mem_slack > PAGE_TO_MEMKB(physinfo.total_pages) * 0.15)
-        free_mem_slack = PAGE_TO_MEMKB(physinfo.total_pages) * 0.15;
-    libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32,

free_mem_slack); -

tools/libxl/libxl.c +13 -1
-    *target_memkb = (uint32_t) info.current_memkb;
+        goto out;
+
+    if (target == NULL) {
+        libxl__xs_write(gc, t, target_path, "%"PRIu32,
+                (uint32_t) info.current_memkb);
+        *target_memkb = (uint32_t) info.current_memkb;
+    }
+    if (staticmax == NULL)
+        libxl__xs_write(gc, t, max_path, "%"PRIu32,
+                (uint32_t) info.max_memkb);
+
+    if (freememslack == NULL) {
+        free_mem_slack_kb = (uint32_t)

(PAGE_TO_MEMKB(physinfo.total_pages) - +
info.current_memkb);
+ /* From empirical measurements the free_mem_slack shouldn't be
more + * than 15% of the total memory present on the system. */ +

     if (free_mem_slack_kb > PAGE_TO_MEMKB(physinfo.total_pages) * 0.15) + 
          free_mem_slack_kb = PAGE_TO_MEMKB(physinfo.total_pages) * 0.15; +
       libxl__xs_write(gc, t, free_mem_slack_path, "%"PRIu32,
free_mem_slack_kb); +    }
     rc = 0;

out:

tools/libxl/libxl.c +4 -1
-    if (!xs_transaction_end(ctx->xsh, t, 0))
+    if (!xs_transaction_end(ctx->xsh, t, 0)) {
         if (errno == EAGAIN)
             goto retry_transaction;
+        else
+            rc = ERROR_FAIL;
+    }
 
 
     return rc;
Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#9 lore raw
Quoted 21 lines · Christoph Egger
Quoted 20 lines · On Tuesday 09 November 2010 19:08:14 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }
Quoted 5 lines
Quoted 3 lines

The problem you are having is that somebody in your system is setting a target for dom0 without setting freemem-slack. Are you still running xend at boot?

Yes, I do.

running xend alongside xl is not recommended, it could cause bugs, especially if you don't disable autoballooning

Quoted 3 lines

Xen is booted with dom0_mem.
Dom0 has autoballooning disabled in the kernel.

You still need to disable autoballooning in xl, setting autoballooning to 0 in /etc/xen/xl.conf

Quoted 32 lines
Quoted 32 lines

Currently libxl__fill_dom0_memory_info assumes that both values are set initially at the same time (by libxl__fill_dom0_memory_info). This patch should fix the issue, I would appreciate if you could test it.

---

libxl: do not assume target and freemem-slack are written at the same time

diff -r 7188d1e4b0e1 tools/libxl/libxl.c

tools/libxl/libxl.c +2 -2
@@ -2779,18 +2779,25 @@ static int libxl__fill_dom0_memory_info(
     int rc;
     libxl_dominfo info;
     libxl_physinfo physinfo;
-    char *target = NULL, *endptr = NULL;
+    char *target = NULL, *staticmax = NULL, *freememslack = 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";
     xs_transaction_t t;
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    uint32_t free_mem_slack = 0;
+    uint32_t free_mem_slack_kb = 0;
 
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
 
Quoted 11 lines

tools/libxl/libxl.c static int libxl__fill_dom0_memory_info( · line 2799

Quoted 7 lines
tools/libxl/libxl.c +6 -0
     target = libxl__xs_read(gc, t, target_path);
+    staticmax = libxl__xs_read(gc, t, target_path);
+    freememslack = libxl__xs_read(gc, t, target_path);
+    if (target && staticmax && freememslack) {
+        rc = 0;
+        goto out;
+    }

*target, *staticmax and *freememslack contain the value "5". So with this patch, rc always returns 0 from there.

that is correct: the values are there, so there is no need to write them to xenstore again, and the caller should be able to read the target correctly

#10 lore raw

This issue still exist in my side with latest xen unstable. Did the fixed patch work for you?

best regards
yang

Quoted 104 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefano Stabellini
Sent: Wednesday, November 10, 2010 7:53 PM
To: Christoph Egger
Cc: [email protected]; Ian Jackson; Stefano Stabellini
Subject: Re: [Xen-devel][PATCH] xl create: endless loop

Quoted 21 lines · Christoph Egger
Quoted 20 lines · On Tuesday 09 November 2010 19:08:14 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }
Quoted 5 lines
Quoted 3 lines

The problem you are having is that somebody in your system is setting a target for dom0 without setting freemem-slack. Are you still running xend at boot?

Yes, I do.

running xend alongside xl is not recommended, it could cause bugs, especially if you don't disable autoballooning

Quoted 3 lines

Xen is booted with dom0_mem.
Dom0 has autoballooning disabled in the kernel.

You still need to disable autoballooning in xl, setting autoballooning to 0 in /etc/xen/xl.conf

Quoted 12 lines
Quoted 12 lines

Currently libxl__fill_dom0_memory_info assumes that both values are set initially at the same time (by libxl__fill_dom0_memory_info). This patch should fix the issue, I would appreciate if you could test it.

---

libxl: do not assume target and freemem-slack are written at the same time

Quoted 9 lines

tools/libxl/libxl.c static int libxl__fill_dom0_memory_info( · line 2782

Quoted 9 lines

diff -r 7188d1e4b0e1 tools/libxl/libxl.c

tools/libxl/libxl.c +1 -1
@@ -2779,18 +2779,25 @@ static int libxl__fill_dom0_memory_info(
     int rc;
     libxl_dominfo info;
     libxl_physinfo physinfo;
-    char *target = NULL, *endptr = NULL;
+    char *target = NULL, *staticmax = NULL, *freememslack = NULL,

*endptr

Quoted 3 lines

tools/libxl/libxl.c static int libxl__fill_dom0_memory_info( · line 2785

Quoted 3 lines
tools/libxl/libxl.c +0 -0
 = 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";

Quoted 16 lines
Quoted 5 lines
tools/libxl/libxl.c +1 -1
     xs_transaction_t t;
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    uint32_t free_mem_slack = 0;
+    uint32_t free_mem_slack_kb = 0;
 

tools/libxl/libxl.c static int libxl__fill_dom0_memory_info( · line 2799

Quoted 10 lines
tools/libxl/libxl.c +6 -0
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
 
     target = libxl__xs_read(gc, t, target_path);
+    staticmax = libxl__xs_read(gc, t, target_path);
+    freememslack = libxl__xs_read(gc, t, target_path);
+    if (target && staticmax && freememslack) {
+        rc = 0;
+        goto out;
+    }
Quoted 3 lines

*target, *staticmax and *freememslack contain the value "5". So with this patch, rc always returns 0 from there.

that is correct: the values are there, so there is no need to write them to xenstore again, and the caller should be able to read the target correctly

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#11 lore raw
Quoted 2 lines · Yang Z

This issue still exist in my side with latest xen unstable. Did the fixed patch work for you?

Do you have autoballoon (in /etc/xen/xl.conf) set to 0 or 1? Do you pass dom0_mem as Xen command line option?

If you pass dom0_mem to Xen, then autoballoon should be set to 0. If that's not the case, how much memory do you have on your testbox? How big is the VM you are trying to start?

#12 lore raw

Yes I have the dom0_mem in xen command line. But I think the autoballoon is disable by default since there had an annotate before it, if it not I think we should add some comments like "autoballoon default is enable" as we see in the xmexample.hvm.

And the another question is why I should to disable the autoballoon manually in the xl.conf? why don't you to add a check in the xl to see whether the autoballon is enable or disable?

best regards
yang

Quoted 19 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, November 16, 2010 10:07 PM
To: Zhang, Yang Z
Cc: Stefano Stabellini; Christoph Egger; [email protected]; Ian Jackson
Subject: RE: [Xen-devel][PATCH] xl create: endless loop

Quoted 1 line · Yang Z

This issue still exist in my side with latest xen unstable. Did the fixed patch

work for you?

Quoted 1 line

Do you have autoballoon (in /etc/xen/xl.conf) set to 0 or 1? Do you pass dom0_mem as Xen command line option?

If you pass dom0_mem to Xen, then autoballoon should be set to 0. If that's not the case, how much memory do you have on your testbox? How big is the VM you are trying to start?

#13 lore raw
Quoted 2 lines · Yang Z

Yes I have the dom0_mem in xen command line. But I think the autoballoon is disable by default since there had an annotate before it, if it not I think we should add some comments like "autoballoon default is enable" as we see in the xmexample.hvm.

Autoballoon is enabled by default, a comment would probably be good

Quoted 2 lines

And the another question is why I should to disable the autoballoon manually in the xl.conf? why don't you to add a check in the xl to see whether the autoballon is enable or disable?

Good question. The problem is: how should I write this check? AFAIK there is no clear way to know if autoballooning should be enabled or disabled, apart from parsing the xen command line options, but it seems really ugly to me.

In any case, could you please try disabling autoballooning and let me know if you still have this issue?

#14 lore raw
Quoted 23 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, November 16, 2010 10:40 PM
To: Zhang, Yang Z
Cc: Stefano Stabellini; Christoph Egger; [email protected]; Ian Jackson
Subject: RE: [Xen-devel][PATCH] xl create: endless loop

Quoted 1 line · Yang Z

Yes I have the dom0_mem in xen command line. But I think the autoballoon is

disable by default since there had an annotate before it, if it not I think we should add some comments like "autoballoon default is enable" as we see in the xmexample.hvm.

Quoted 1 line

Autoballoon is enabled by default, a comment would probably be good

Quoted 1 line

And the another question is why I should to disable the autoballoon manually

in the xl.conf? why don't you to add a check in the xl to see whether the autoballon is enable or disable?

Quoted 1 line
Quoted 7 lines

Good question. The problem is: how should I write this check? AFAIK there is no clear way to know if autoballooning should be enabled or disabled, apart from parsing the xen command line options, but it seems really ugly to me.

In any case, could you please try disabling autoballooning and let me know if you still have this issue?

It works with disable the autoballoon. Thanks for you help.

And a question with qcow issue I reported in another mail. Since our automation test is based in qcow images, because copy raw images take a long times(we have 60+ case), so will anyone to take a look at this issue? it will block our automation test with xl.

best regards
yang

#15 lore raw
Quoted 28 lines · Yang Z
Quoted 28 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, November 16, 2010 10:40 PM
To: Zhang, Yang Z
Cc: Stefano Stabellini; Christoph Egger; [email protected]; Ian Jackson
Subject: RE: [Xen-devel][PATCH] xl create: endless loop

Quoted 1 line · Yang Z

Yes I have the dom0_mem in xen command line. But I think the autoballoon is

disable by default since there had an annotate before it, if it not I think we should add some comments like "autoballoon default is enable" as we see in the xmexample.hvm.

Quoted 1 line

Autoballoon is enabled by default, a comment would probably be good

Quoted 1 line

And the another question is why I should to disable the autoballoon manually

in the xl.conf? why don't you to add a check in the xl to see whether the autoballon is enable or disable?

Quoted 1 line

Good question. The problem is: how should I write this check? AFAIK there is no clear way to know if autoballooning should be enabled or disabled, apart from parsing the xen command line options, but it seems really ugly to me.

Quoted 6 lines
Quoted 2 lines

In any case, could you please try disabling autoballooning and let me know if you still have this issue?

It works with disable the autoballoon. Thanks for you help.

And a question with qcow issue I reported in another mail. Since our automation test is based in qcow images, because copy raw images take a long times(we have 60+ case), so will anyone to take a look at this issue? it will block our automation test with xl.

Daniel, do you have any ideas?

#16 lore raw
Quoted 29 lines · Stefano Stabellini
Quoted 28 lines · Yang Z
Quoted 28 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, November 16, 2010 10:40 PM
To: Zhang, Yang Z
Cc: Stefano Stabellini; Christoph Egger; [email protected]; Ian Jackson
Subject: RE: [Xen-devel][PATCH] xl create: endless loop

Quoted 1 line · Yang Z

Yes I have the dom0_mem in xen command line. But I think the autoballoon is

disable by default since there had an annotate before it, if it not I think we should add some comments like "autoballoon default is enable" as we see in the xmexample.hvm.

Quoted 1 line

Autoballoon is enabled by default, a comment would probably be good

Quoted 1 line

And the another question is why I should to disable the autoballoon manually

in the xl.conf? why don't you to add a check in the xl to see whether the autoballon is enable or disable?

Quoted 1 line

Good question. The problem is: how should I write this check? AFAIK there is no clear way to know if autoballooning should be enabled or disabled, apart from parsing the xen command line options, but it seems really ugly to me.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

In any case, could you please try disabling autoballooning and let me know if you still have this issue?

It works with disable the autoballoon. Thanks for you help.

And a question with qcow issue I reported in another mail. Since our automation test is based in qcow images, because copy raw images take a long times(we have 60+ case), so will anyone to take a look at this issue? it will block our automation test with xl.

Daniel, do you have any ideas?

Not the slightest. Just proof that: Are we talking about blktap qcow or qemu? Still trying to find that mail.

Daniel

#17 lore raw
Quoted 43 lines · On Wednesday 17 November 2010 03:50:51 Daniel Stodden wrote:
Quoted 42 lines · Stefano Stabellini
Quoted 40 lines · Yang Z
Quoted 26 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, November 16, 2010 10:40 PM
To: Zhang, Yang Z
Cc: Stefano Stabellini; Christoph Egger; [email protected]; Ian Jackson
Subject: RE: [Xen-devel][PATCH] xl create: endless loop

Quoted 2 lines · Yang Z

Yes I have the dom0_mem in xen command line. But I think the autoballoon is

disable by default since there had an annotate before it, if it not I think we should add some comments like "autoballoon default is enable" as we see in the xmexample.hvm.

Autoballoon is enabled by default, a comment would probably be good

Quoted 2 lines

And the another question is why I should to disable the autoballoon manually

in the xl.conf? why don't you to add a check in the xl to see whether the autoballon is enable or disable?

Quoted 7 lines

Good question. The problem is: how should I write this check? AFAIK there is no clear way to know if autoballooning should be enabled or disabled, apart from parsing the xen command line options, but it seems really ugly to me.

In any case, could you please try disabling autoballooning and let me know if you still have this issue?

It works with disable the autoballoon. Thanks for you help.

And a question with qcow issue I reported in another mail. Since our automation test is based in qcow images, because copy raw images take a long times(we have 60+ case), so will anyone to take a look at this issue? it will block our automation test with xl.

Quoted 4 lines
Quoted 1 line

Daniel, do you have any ideas?

Not the slightest. Just proof that: Are we talking about blktap qcow or qemu? Still trying to find that mail.

xl links against blktap2, qemu links against blktap. I think, this may cause some random behaviour.
qemu should move to blktap2 and drop blktap from the tools then.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
#18 lore raw
Quoted 7 lines · Christoph Egger
Quoted 2 lines

Not the slightest. Just proof that: Are we talking about blktap qcow or qemu? Still trying to find that mail.

xl links against blktap2, qemu links against blktap. I think, this may cause some random behaviour.
qemu should move to blktap2 and drop blktap from the tools then.

Is blktap support in qemu even used anywhere?
Maybe with xend and the XCP kernel because xl and new pvops kernels don't even work with blktap.

I think we should probably remove it.

#19 lore raw
In reply to Stefano Stabellini
Quoted 80 lines · On Wednesday 10 November 2010 12:52:42 Stefano Stabellini wrote:
Quoted 21 lines · Christoph Egger
Quoted 20 lines · On Tuesday 09 November 2010 19:08:14 Stefano Stabellini wrote:
Quoted 18 lines · Christoph Egger

No, this patch has no effect for me.
In libxl__fill_dom0_memory_info(), the code path goes that way:

    t = xs_transaction_start(ctx->xsh);

    target = libxl__xs_read(gc, t, target_path);
    if (target) {    <-- target contains "5"
        *target_memkb = strtoul(target, &endptr, 10);
        if (*endptr != '\0') {     <-- *endptr contains '\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;    <-- take this jump with rc being 0
    }
Quoted 5 lines
Quoted 3 lines

The problem you are having is that somebody in your system is setting a target for dom0 without setting freemem-slack. Are you still running xend at boot?

Yes, I do.

running xend alongside xl is not recommended, it could cause bugs, especially if you don't disable autoballooning

Quoted 33 lines
Quoted 33 lines

Currently libxl__fill_dom0_memory_info assumes that both values are set initially at the same time (by libxl__fill_dom0_memory_info). This patch should fix the issue, I would appreciate if you could test it.

---

libxl: do not assume target and freemem-slack are written at the same time

diff -r 7188d1e4b0e1 tools/libxl/libxl.c

tools/libxl/libxl.c +2 -2
@@ -2779,18 +2779,25 @@ static int libxl__fill_dom0_memory_info(
     int rc;
     libxl_dominfo info;
     libxl_physinfo physinfo;
-    char *target = NULL, *endptr = NULL;
+    char *target = NULL, *staticmax = NULL, *freememslack = 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"; xs_transaction_t t;
     libxl_ctx *ctx = libxl__gc_owner(gc);
-    uint32_t free_mem_slack = 0;
+    uint32_t free_mem_slack_kb = 0;
 
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
 
Quoted 10 lines

tools/libxl/libxl.c static int libxl__fill_dom0_memory_info( · line 2799

Quoted 7 lines
tools/libxl/libxl.c +6 -0
     target = libxl__xs_read(gc, t, target_path);
+    staticmax = libxl__xs_read(gc, t, target_path);
+    freememslack = libxl__xs_read(gc, t, target_path);
+    if (target && staticmax && freememslack) {
+        rc = 0;
+        goto out;
+    }

*target, *staticmax and *freememslack contain the value "5". So with this patch, rc always returns 0 from there.

that is correct: the values are there, so there is no need to write them to xenstore again, and the caller should be able to read the target correctly

Quoted 5 lines
Quoted 2 lines

Xen is booted with dom0_mem.
Dom0 has autoballooning disabled in the kernel.

You still need to disable autoballooning in xl, setting autoballooning to 0 in /etc/xen/xl.conf

Yes, that makes the patch work for me. I have success in booting the guest the first time with 'xl create'.

Please commit the patch.

Christoph

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
Applied
#20 lore raw

Re: [PATCH] xl create: endless loop [and 1 more messages]

Stefano Stabellini writes ("Re: [Xen-devel][PATCH] xl create: endless loop"):

Quoted 1 line

libxl: do not assume target and freemem-slack are written at the same time

I have applied this patch, thanks.

Ian.