Skip to contentSkip to conversation

Fix parameter check of xm dmesg

PATCH Applied Masaki Kanno 2 participants 2 messages Oct 31, 2006 – Nov 1, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix parameter check of xm dmesg

Hi,

I found a small bug in xm dmesg command. Even if I gave xm dmesg command a wrong parameter, xm dmesg command did not become an error.

# xm dmesg xyz
 __  __            _____  ___                     _        _     _      
 \ \/ /___ _ __   |___ / / _ \    _   _ _ __  ___| |_ __ _| |__ | | ___ 
  \  // _ \ '_ \    |_ \| | | |__| | | | '_ \/ __| __/ _` | '_ \| |/ _ \
  /  \  __/ | | |  ___) | |_| |__| |_| | | | \__ \ || (_| | |_) | |  __/
 /_/\_\___|_| |_| |____(_)___/    \__,_|_| |_|___/\__\__,_|_.__/|_|\___|

http://www.cl.cam.ac.uk/netos/xen
University of Cambridge Computer Laboratory

Xen version 3.0-unstable (root@) () Tue Oct 31 11:06:09 JST 2006 Latest ChangeSet: Mon Oct 30 17:35:11 2006 +0000 12033:b21246720fde

(XEN) Command line: /xen-3.0-unstable.gz
(XEN) Physical RAM map:
<snip>

This patch adds a checking of wrong parameter into xm dmesg command. If wrong parameter is given, xm dmesg command shows the following error messages.

# xm dmesg xyz
Error: No parameter required
Usage: xm dmesg [-c|--clear]

Read and/or clear Xend's message buffer.
-c, --clear Clear dmesg buffer

Best regards,
Kan

tools/python/xen/xm/main.py +14 -17
diff -r b21246720fde tools/python/xen/xm/main.py
@@ -1032,26 +1032,23 @@ def xm_dmesg(args):
 def xm_dmesg(args):
     arg_check(args, "dmesg", 0, 1)
     
-    gopts = Opts(use="""[-c|--clear]
-
-Read Xen's message buffer (boot output, warning and error messages) or clear
-its contents if the [-c|--clear] flag is specified.
-""")
-
-    gopts.opt('clear', short='c',
-              fn=set_true, default=0,
-              use="Clear the contents of the Xen message buffer.")
-    # Work around for gopts
-    myargs = args
-    myargs.insert(0, 'dmesg')
-    gopts.parse(myargs)
-    
-    if len(myargs) not in (1, 2):
-        err('Invalid arguments: ' + str(myargs))
+    try:
+        (options, params) = getopt.gnu_getopt(args, 'c', ['clear'])
+    except getopt.GetoptError, opterr:
+        err(opterr)
+        sys.exit(1)
+    
+    use_clear = 0
+    for (k, v) in options:
+        if k in ['-c', '--clear']:
+            use_clear = 1
+    
+    if len(params) :
+        err("No parameter required")
         usage('dmesg')
         sys.exit(1)
 
-    if not gopts.vals.clear:
+    if not use_clear:
         print server.xend.node.dmesg.info()
     else:
         server.xend.node.dmesg.clear()

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

Applied
#1 lore raw

On Tue, Oct 31, 2006 at 03:07:57PM +0900, Masaki Kanno wrote:

Content-Description: Mail message body

Quoted 31 lines

Hi,

I found a small bug in xm dmesg command. Even if I gave xm dmesg command a wrong parameter, xm dmesg command did not become an error.

# xm dmesg xyz
 __  __            _____  ___                     _        _     _      
 \ \/ /___ _ __   |___ / / _ \    _   _ _ __  ___| |_ __ _| |__ | | ___ 
  \  // _ \ '_ \    |_ \| | | |__| | | | '_ \/ __| __/ _` | '_ \| |/ _ \
  /  \  __/ | | |  ___) | |_| |__| |_| | | | \__ \ || (_| | |_) | |  __/
 /_/\_\___|_| |_| |____(_)___/    \__,_|_| |_|___/\__\__,_|_.__/|_|\___|

http://www.cl.cam.ac.uk/netos/xen
University of Cambridge Computer Laboratory

Xen version 3.0-unstable (root@) () Tue Oct 31 11:06:09 JST 2006 Latest ChangeSet: Mon Oct 30 17:35:11 2006 +0000 12033:b21246720fde

(XEN) Command line: /xen-3.0-unstable.gz
(XEN) Physical RAM map:
<snip>

This patch adds a checking of wrong parameter into xm dmesg command. If wrong parameter is given, xm dmesg command shows the following error messages.

# xm dmesg xyz
Error: No parameter required
Usage: xm dmesg [-c|--clear]
Quoted 5 lines

Read and/or clear Xend's message buffer.
-c, --clear Clear dmesg buffer

Applied, thank you.

Ewan.