[Libguestfs] [libnbd PATCH v2] nbdsh: Catch nbd.Error from -c arguments

Eric Blake eblake at redhat.com
Tue Sep 22 21:03:07 UTC 2020


On 9/22/20 2:58 PM, Richard W.M. Jones wrote:
> On Tue, Sep 22, 2020 at 11:15:39AM -0500, Eric Blake wrote:
>> +        try:
>> +            for c in args.command:
>> +                if c != '-':
>> +                    exec(c, d, d)
>> +                else:
>> +                    exec(sys.stdin.read(), d, d)
>> +        except nbd.Error as ex:
>> +            if os.environ.get("LIBNBD_DEBUG", "0") == "1":
> 
> Would it be better to use nbd.NBD().get_debug() == True, or
> h.get_debug() == True for this test instead of duplicating the logic
> inside libnbd?

I originally worried about:
  nbdsh -c 'h = None'
which means we can't assume that the handle we opened prior to -c code 
is still valid at the point we catch an exception.  But you have a point 
that opening yet another NBD handle will work.  I'll push the obvious 
followup.

> 
> But sure, let's do this.  ACK.
> 
> Rich.
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list