diff --git a/lib/cli.py b/lib/cli.py
index 885bd7005bcfb926edbf7de5bff6b4a48dd4049c..f81f1aa298efa54120da6b2a262a419f46f3ad56 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -2861,7 +2861,7 @@ def _WarnUnknownFields(fdefs):
 
 def GenericList(resource, fields, names, unit, separator, header, cl=None,
                 format_override=None, verbose=False, force_filter=False,
-                namefield=None, qfilter=None):
+                namefield=None, qfilter=None, isnumeric=False):
   """Generic implementation for listing all items of a resource.
 
   @param resource: One of L{constants.QR_VIA_LUXI}
@@ -2889,12 +2889,17 @@ def GenericList(resource, fields, names, unit, separator, header, cl=None,
     L{qlang.MakeFilter} for details)
   @type qfilter: list or None
   @param qfilter: Query filter (in addition to names)
+  @param isnumeric: bool
+  @param isnumeric: Whether the namefield's type is numeric, and therefore
+    any simple filters built by namefield should use integer values to
+    reflect that
 
   """
   if not names:
     names = None
 
-  namefilter = qlang.MakeFilter(names, force_filter, namefield=namefield)
+  namefilter = qlang.MakeFilter(names, force_filter, namefield=namefield,
+                                isnumeric=isnumeric)
 
   if qfilter is None:
     qfilter = namefilter
diff --git a/lib/qlang.py b/lib/qlang.py
index 3942b45c6803405c2640b90e4374e59fef6bfd78..e52924337230f9609bce41aa08735f1dbf9f5680 100644
--- a/lib/qlang.py
+++ b/lib/qlang.py
@@ -290,17 +290,24 @@ def _CheckGlobbing(text):
   return bool(frozenset(text) & GLOB_DETECTION_CHARS)
 
 
-def _MakeFilterPart(namefield, text):
+def _MakeFilterPart(namefield, text, isnumeric=False):
   """Generates filter for one argument.
 
   """
-  if _CheckGlobbing(text):
+  if isnumeric:
+    try:
+      number = int(text)
+    except (TypeError, ValueError), err:
+      raise errors.OpPrereqError("Invalid integer passed: %s" % str(err),
+                                 errors.ECODE_INVAL)
+    return [OP_EQUAL, namefield, number]
+  elif _CheckGlobbing(text):
     return [OP_REGEXP, namefield, utils.DnsNameGlobPattern(text)]
   else:
     return [OP_EQUAL, namefield, text]
 
 
-def MakeFilter(args, force_filter, namefield=None):
+def MakeFilter(args, force_filter, namefield=None, isnumeric=False):
   """Try to make a filter from arguments to a command.
 
   If the name could be a filter it is parsed as such. If it's just a globbing
@@ -314,6 +321,9 @@ def MakeFilter(args, force_filter, namefield=None):
   @type namefield: string
   @param namefield: Name of field to use for simple filters (use L{None} for
     a default of "name")
+  @type isnumeric: bool
+  @param isnumeric: Whether the namefield type is numeric, as opposed to
+    the default string type; this influences how the filter is built
   @rtype: list
   @return: Query filter
 
@@ -331,7 +341,8 @@ def MakeFilter(args, force_filter, namefield=None):
 
     result = ParseFilter(filter_text)
   elif args:
-    result = [OP_OR] + map(compat.partial(_MakeFilterPart, namefield), args)
+    result = [OP_OR] + map(compat.partial(_MakeFilterPart, namefield,
+                                          isnumeric=isnumeric), args)
   else:
     result = None