Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen/xen Silence xenbus_read_target() in ENOENT case...



details:   https://anonhg.NetBSD.org/src/rev/a37a2b2e5ec5
branches:  trunk
changeset: 764663:a37a2b2e5ec5
user:      jym <jym%NetBSD.org@localhost>
date:      Fri Apr 29 22:52:02 2011 +0000

description:
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.

diffstat:

 sys/arch/xen/xen/balloon.c |  26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diffs (63 lines):

diff -r 40763f85c148 -r a37a2b2e5ec5 sys/arch/xen/xen/balloon.c
--- a/sys/arch/xen/xen/balloon.c        Fri Apr 29 22:45:41 2011 +0000
+++ b/sys/arch/xen/xen/balloon.c        Fri Apr 29 22:52:02 2011 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index