Skip to contentSkip to conversation

Error message for device not found at blkif.py

PATCH In review Glauber de Oliveira Costa 2 participants 5 messages Oct 18, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Error message for device not found at blkif.py

Hi,

if blkdev_name_to_number() fails to assign a number to the specified device, it returns None, causing a far-away-from-self-explanatory message to be delivered. Better test for this condition and say exactly what happened.

Signature · 3 lines
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"
./tools/python/build/lib.linux-x86_64-2.4/xen/xend/server/blkif.py renamed from ./tools/python/build/lib.linux-x86_64-2.4/xen/xend/server/blkif.py.orig +3 -0
@@ -81,6 +81,9 @@ class BlkifController(DevController):
                          'acm_policy' : policy})
 
         devid = blkif.blkdev_name_to_number(dev)
+        if not devid:
+            raise VmError('Unable to find number for device (%s)'%(dev))
+
         front = { 'virtual-device' : "%i" % devid,
                   'device-type' : dev_type
                 }

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

#1 lore raw

Instead of throwing a VmError, could you subclass VmError with a more specific error and throw that?

That will pass higher level info about the error to xm which means we can do a better job in there (this is especially important when we eventually localize xm).

Thanks,

Anthony Liguori

Quoted 32 lines · Glauber de Oliveira Costa

Hi,

if blkdev_name_to_number() fails to assign a number to the specified device, it returns None, causing a far-away-from-self-explanatory message to be delivered. Better test for this condition and say exactly what happened.

------------------------------------------------------------------------

./tools/python/build/lib.linux-x86_64-2.4/xen/xend/server/blkif.py renamed from ./tools/python/build/lib.linux-x86_64-2.4/xen/xend/server/blkif.py.orig +3 -1
@@ -81,6 +81,9 @@ class BlkifController(DevController):
                          'acm_policy' : policy})
 
         devid = blkif.blkdev_name_to_number(dev)
+        if not devid:
+            raise VmError('Unable to find number for device (%s)'%(dev))
+
         front = { 'virtual-device' : "%i" % devid,
                   'device-type' : dev_type
                 }
 
 
------------------------------------------------------------------------

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

#2 lore raw
Quoted 2 lines · Anthony Liguori

Instead of throwing a VmError, could you subclass VmError with a more specific error and throw that?

Fore sure I can. But what does this condition have so differently from others that justifies that for it only? Although I agree with you that such a specificiness is good, VmError is being thrown everywhere, meaning that your proposal would require touching a great amount of code change. Is there any plans/opposals for that?

Signature · 3 lines
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"
#3 lore raw
Quoted 6 lines · Glauber de Oliveira Costa
Quoted 2 lines · Anthony Liguori

Instead of throwing a VmError, could you subclass VmError with a more specific error and throw that?

Fore sure I can. But what does this condition have so differently from others that justifies that for it only?

Good question. Previously, we only threw opaque errors back over the wire. A few months ago, we changed that so that we could pass exceptions over the wire with specific Fault ids. The new Xend API should be even better for this.

So, the answer we know have the ability to do useful things with this info so it's now a best practice for new code :-)

I'm not suggesting you go change everything, just in your patch.

Regards,

Anthony Liguori

Quoted 6 lines

Although I agree with you that
such a specificiness is good, VmError is being thrown everywhere, meaning that your proposal would require touching a great amount of code change. Is there any plans/opposals for that?

#4 lore raw
In reply to Glauber de Oliveira Costa
Quoted 9 lines · Glauber de Oliveira Costa
Quoted 2 lines · Anthony Liguori

Instead of throwing a VmError, could you subclass VmError with a more specific error and throw that?

Fore sure I can. But what does this condition have so differently from
others that justifies that for it only? Although I agree with you that such a specificiness is good, VmError is being thrown everywhere, meaning that your proposal would require touching a great amount of code change. Is there any plans/opposals for that?

BTW, check out tools/python/xen/xend/XendError.py for an example of where we're doing this.

Regards,

Anthony Liguori