Created attachment 657995 [details] anaconda-tb-_pjRJa Description of problem: vgcreate fails when asked to create a volume group named "ñ". NB: The traceback in the attached anaconda-tb-_pjRJa was duped to Bug 870586. Version-Release number of selected component (if applicable): anaconda 18.35 Fedora-18-Beta-x86_64-Live-Desktop.iso How reproducible: First try. Steps to Reproduce: 1. Create a volume group named "ñ". 2. Begin installation. Actual results: New volume group name "ñ" is invalid Expected results: The volume group name "ñ" is rejected before installation starts. Additional info: [snippet from attached anaconda-tb-_pjRJa] ... 22:53:53,035 INFO program: Running... lvm vgcreate -s 4m --config devices { filter=["r|/loop5$|","r|/loop6$|","r|/loop7$|"] } ñ /dev/sda2 22:53:53,057 ERR program: New volume group name "ñ" is invalid 22:53:53,059 ERR program: Run `vgcreate --help' for more information. ... Tested with: $ qemu-kvm -m 2048 -hda f18-test-2.img -cdrom ~/xfr/fedora/F18/F18-Beta/Final/Fedora-18-Beta-x86_64-Live-Desktop.iso -usb -vga qxl -boot menu=on -usbdevice mouse
Created attachment 658347 [details] anaconda-tb-CR6I2w corresponding to reproducer Here's a reproducer and the corresponding log file: Create an empty 12 GB disk image: $ qemu-img create f18-test-2.img 12G Start the Live CD and update the installer: $ qemu-kvm -m 2048 -hda f18-test-2.img -cdrom ~/xfr/fedora/F18/F18-Beta/Final/Fedora-18-Beta-x86_64-Live-Desktop.iso -usb -vga qxl -boot menu=on -usbdevice mouse Start the installer. Proceed to Manual Partitioning. Auto-create storage devices. Click Root. Expand Customize... Click Volume Group: fedora Click Create a new volume group ... For Name, enter "ñ".[1] Click Save. Click Finish Partitioning. Click Begin Installation. Exception occurs at Creating lvmpv on /dev/sda3: DeviceCreateError: ('vgcreate failed for \xc3\xb1: running lvm vgcreate -s 4m --config devices { filter=["r|/loop5$|","r|/loop6$|","r|/loop7$|"] } \xc3\xb1 /dev/sda3 failed', '\xc3\xb1') [1] "ñ" is copied from here: >>> import babel >>> print babel.Locale.parse('es_ES').display_name español (España)
The lvm man page has a whole section on valid names. My question: Does LVM provide a library function that validates names against these minutia? :-) VALID NAMES The following characters are valid for VG and LV names: a-z A-Z 0-9 + _ . - VG and LV names cannot begin with a hyphen. There are also various reserved names that are used internally by lvm that can not be used as LV or VG names. A VG cannot be called anything that exists in /dev/ at the time of creation, nor can it be called '.' or '..'. A LV cannot be called '.' '..' 'snapshot' or 'pvmove'. The LV name may also not contain the strings '_mlog', '_mimage', '_rim‐ age', '_tdata', '_tmeta'.
It certainly would be helpful if there were something we could call so we didn't have to know these rules ourselves.
At the moment, vgcreate/lvcreate --test is the only option. There could be a library call.
Created attachment 667114 [details] anaconda-tb-_bVbgz with DeviceCreateError exception after a long VG name was entered The lvm man page doesn't say what the maximum length of a volume group name is.
There is indeed an lvm validate_name() function, but it does not appear to be exported in lvm2-devel: $ less -N lvm2-2_02_98/lib/misc/lvm-string.h ... 22 #define NAME_LEN 128 ... 33 int validate_name(const char *n); ... $ less -N lvm2-2_02_98/lib/misc/lvm-string.c ... 66 /* 67 * Device layer names are all of the form <vg>-<lv>-<layer>, any 68 * other hyphens that appear in these names are quoted with yet 69 * another hyphen. The top layer of any device has no layer 70 * name. eg, vg0-lvol0. 71 */ 72 int validate_name(const char *n) 73 { 74 register char c; 75 register int len = 0; 76 77 if (!n || !*n) 78 return 0; 79 80 /* Hyphen used as VG-LV separator - ambiguity if LV starts with it */ 81 if (*n == '-') 82 return 0; 83 84 if (!strcmp(n, ".") || !strcmp(n, "..")) 85 return 0; 86 87 while ((len++, c = *n++)) 88 if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+') 89 return 0; 90 91 if (len > NAME_LEN) 92 return 0; 93 94 return 1; 95 } ...
There appears to be a Python interface to lvm: http://git.fedorahosted.org/cgit/lvm2.git/tree/python The example doesn't use any try/except blocks, so it may not be ready for production use ...
*** Bug 889611 has been marked as a duplicate of this bug. ***
So what is the focus of this bugzilla? The volume group name "ñ" will remain invalid. We aren't going to change that. Is this a request for python name validation functions?
Per Comment 3, this is a request for a Python name-validation function. Revising bug summary accordingly. Since this function would be validating names entered by users, it would be helpful if the function could return a Python exception object with an error message identifying the error more specifically, so the user wouldn't have to guess and try again. 1. name longer than N characters 2. character not in [list of valid characters] 3. name already in use 4. ...
(In reply to comment #10) > Per Comment 3, this is a request for a Python name-validation function. > Revising bug summary accordingly. > > Since this function would be validating names entered by users, it would be > helpful if the function could return a Python exception object with an error > message identifying the error more specifically, so the user wouldn't have > to guess and try again. > > 1. name longer than N characters > 2. character not in [list of valid characters] > 3. name already in use > 4. ... This seems reasonable. However, until anaconda picks up and uses the python bindings for lvm (instead of command line) they should really do some type of validation in anaconda.
Patch committed upstream adds this functionality: http://www.redhat.com/archives/lvm-devel/2013-November/msg00085.html Will be included in next release (2.02.105)
Currently (Fedora 20), it seems that anaconda removes any unsupported characters from VG/LV names before trying to issue an LVM command. The patch mentioned here will also get into the release within next update, but only for recent Fedoras. Marking as closed/nextrelease.