Error creating pool: local variable 'srcname' referenced before assignment

Bug #1706313 reported by Marius Gedminas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
virt-manager
Won't Fix
Undecided
virt-manager (Ubuntu)
Triaged
Low
Unassigned

Bug Description

I was trying to add an existing LVM volume group as a storage pool in virt-manager. I filled in the volume group name, then got to the dialog with source and target path entries, didn't know what to put there[*], so left them blank and hit Finish. I then got a popup with this Python traceback in it:

    Traceback (most recent call last):
      File "/usr/share/virt-manager/virtManager/asyncjob.py", line 90, in cb_wrapper
        callback(asyncjob, *args, **kwargs)
      File "/usr/share/virt-manager/virtManager/createpool.py", line 446, in _async_pool_create
        poolobj = self._pool.install(create=True, meter=meter, build=build)
      File "/usr/share/virt-manager/virtinst/storage.py", line 496, in install
        xml = self.get_xml_config()
      File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 834, in get_xml_config
        return self._do_get_xml_config()
      File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 1043, in _do_get_xml_config
        self._add_parse_bits(node)
      File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 1066, in _add_parse_bits
        return self._do_add_parse_bits(node)
      File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 1077, in _do_add_parse_bits
        prop._set_default(self)
      File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 506, in _set_default
        candefault, val = self._default_get_value(xmlbuilder)
      File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 494, in _default_get_value
        return (True, self._default_cb(xmlbuilder))
      File "/usr/share/virt-manager/virtinst/storage.py", line 366, in _default_source_name
        return srcname
    UnboundLocalError: local variable 'srcname' referenced before assignment

--
[*] eventually I figured out I was supposed to put /dev/vgname in the target path field, which worked fine.

ProblemType: Bug
DistroRelease: Ubuntu 17.04
Package: virt-manager 1:1.3.2-3ubuntu4
ProcVersionSignature: Ubuntu 4.10.0-28.32-generic 4.10.17
Uname: Linux 4.10.0-28-generic x86_64
NonfreeKernelModules: zfs zunicode zavl zcommon znvpair
ApportVersion: 2.20.4-0ubuntu4.5
Architecture: amd64
CurrentDesktop: GNOME
Date: Tue Jul 25 13:51:39 2017
InstallationDate: Installed on 2016-09-10 (318 days ago)
InstallationMedia: Ubuntu-GNOME 16.04.1 LTS "Xenial Xerus" - Release amd64 (20160720)
PackageArchitecture: all
SourcePackage: virt-manager
UpgradeStatus: Upgraded to zesty on 2017-04-14 (102 days ago)

Revision history for this message
Marius Gedminas (mgedmin) wrote :
Revision history for this message
In , Marius (marius-redhat-bugs) wrote :

Description of problem:

I was trying to add an existing LVM volume group as a storage pool in virt-manager. I filled in the volume group name, then got to the dialog with source and target path entries, didn't know what to put there (see bug 1316977), so left them blank and hit Finish. I then got a popup with this error.

Version-Release number of selected component (if applicable):

1.3.2

How reproducible:

Always

Steps to Reproduce:
1. Connect to KVM
2. Select Connection Details
3. Go to the Storage tab
4. Hit the + icon at the bottom left
5. Enter a name
6. Select Type: "logical: LVM Volume Group"
7. Hit Next
8. Leave Target Path and Source Path blank
9. Hit Finish

Actual results:

New popup shows up saying "Error creating pool: local variable 'srcname' referenced before assignment", with this traceback in the Details expander:

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 90, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createpool.py", line 446, in _async_pool_create
    poolobj = self._pool.install(create=True, meter=meter, build=build)
  File "/usr/share/virt-manager/virtinst/storage.py", line 496, in install
    xml = self.get_xml_config()
  File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 834, in get_xml_config
    return self._do_get_xml_config()
  File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 1043, in _do_get_xml_config
    self._add_parse_bits(node)
  File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 1066, in _add_parse_bits
    return self._do_add_parse_bits(node)
  File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 1077, in _do_add_parse_bits
    prop._set_default(self)
  File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 506, in _set_default
    candefault, val = self._default_get_value(xmlbuilder)
  File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 494, in _default_get_value
    return (True, self._default_cb(xmlbuilder))
  File "/usr/share/virt-manager/virtinst/storage.py", line 366, in _default_source_name
    return srcname
UnboundLocalError: local variable 'srcname' referenced before assignment

Expected results:

The Finish button is disabled until I enter a target path. Ideally there's some placeholder text in the Target Path that mentions "/dev/vgname", assuming GTK+ supports placeholder text.

Additional info:

Originally filed at https://bugs.launchpad.net/ubuntu/+source/virt-manager/+bug/1706313

Revision history for this message
Marius Gedminas (mgedmin) wrote :
Revision history for this message
In , Cole (cole-redhat-bugs) wrote :

Thanks for the report, fixed upstream now:

commit c4826444e98428d7770c9933428e7b7b0911bbdb (HEAD -> master, origin/master, origin/HEAD)
Author: Cole Robinson <email address hidden>
Date: Thu Aug 3 12:38:37 2017 -0400

    storage: Fix 'srcname' referenced before assignment (bz #1474766)

    https://bugzilla.redhat.com/show_bug.cgi?id=1474766

In fact lack of target path can be valid for logical pools, if the pool name matches and lvm volgroup name on the host. We just had a bug in the code here

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Fixed in:
commit c4826444e98428d7770c9933428e7b7b0911bbdb (HEAD -> master, origin/master, origin/HEAD)
Author: Cole Robinson <email address hidden>
Date: Thu Aug 3 12:38:37 2017 -0400

    storage: Fix 'srcname' referenced before assignment (bz #1474766)

That is part of 1.4.2 which just now appeared in Debian but is too late to sync/merge for Artful due to the Feature Freeze.

But as an individual fix it can be considered, looking into applicability.

Changed in virt-manager (Ubuntu):
status: New → Triaged
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi Marius,
I checked to confirm the actual bug and while it exists and I thank you for your report, its severity is rather low.

I rate it that way for two reasons:
- first of all it is a user error, not adding anything and pressing finish, if correct data is entered things work.
- second and more important, this is not crashing, not even aborting anything. It is essentially just an error message that would be nicer if it read "please enter something in the fields"

I checked and once the user presses close on the error popup he can still enter correct data and go on without an issue.

That said I think it is great that you reported this to get it fixed eventually, but I'd rate it not urgent enough for an SRU into stable releases - not even urgent enough to add it as fix in Artful, instead the next merge will pick it up automatically.

Changed in virt-manager (Ubuntu):
importance: Undecided → Low
Revision history for this message
Marius Gedminas (mgedmin) wrote :

I agree completely.

Thanks!

Changed in virt-manager:
importance: Unknown → Undecided
status: Unknown → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.