Module Name:    src
Committed By:   jym
Date:           Fri Apr 29 22:52:02 UTC 2011

Modified Files:
        src/sys/arch/xen/xen: balloon.c

Log Message:
Silence xenbus_read_target() in ENOENT case (== entry is missing from
Xenstore). The error case does not bring much here; assume that the value
is 0.

Print the error code when writing the ``target'' value fails.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/xen/balloon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/balloon.c
diff -u src/sys/arch/xen/xen/balloon.c:1.8 src/sys/arch/xen/xen/balloon.c:1.9
--- src/sys/arch/xen/xen/balloon.c:1.8	Mon Apr 18 03:04:31 2011
+++ src/sys/arch/xen/xen/balloon.c	Fri Apr 29 22:52:02 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: balloon.c,v 1.8 2011/04/18 03:04:31 rmind Exp $ */
+/* $NetBSD: balloon.c,v 1.9 2011/04/29 22:52:02 jym Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 #define BALLOONDEBUG 0
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.8 2011/04/18 03:04:31 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.9 2011/04/29 22:52:02 jym Exp $");
 
 #include <sys/inttypes.h>
 #include <sys/device.h>
@@ -302,29 +302,37 @@
 
 /*
  * Get value (in KiB) of memory/target in XenStore for current domain
- * A return value of 0 can be considered as bogus.
+ * A return value of 0 can be considered as bogus or absent.
  */
 static unsigned long long
 balloon_xenbus_read_target(void)
 {
 	unsigned long long new_target;
+	int err = xenbus_read_ull(NULL, "memory", "target", &new_target, 0);
 
-	if (0 != xenbus_read_ull(NULL, "memory", "target", &new_target, 0)) {
+	switch(err) {
+	case 0:
+		return new_target;
+	case ENOENT:
+		break;
+	default:
 		device_printf(balloon_sc->sc_dev,
-		    "error, couldn't read xenbus target node\n");
-		return 0;
+		    "error %d, couldn't read xenbus target node\n", err);
+		break;
 	}
 
-	return new_target;
+	return 0;
 }
 
 /* Set memory/target value (in KiB) in XenStore for current domain */
 static void
 balloon_xenbus_write_target(unsigned long long new_target)
 {
-	if (0 != xenbus_printf(NULL, "memory", "target", "%llu", new_target)) {
+	int err = xenbus_printf(NULL, "memory", "target", "%llu", new_target);
+
+	if (err != 0) {
 		device_printf(balloon_sc->sc_dev,
-		    "error, couldn't write xenbus target node\n");
+		    "error %d, couldn't write xenbus target node\n", err);
 	}
 
 	return;

Reply via email to