Bug 1088424

Summary: virt-resize: libguestfs error: part_set_name: parted: /dev/sdb: Error during translation: Invalid or incomplete multibyte or wide character
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: acathrow, mbooth, ppisar, ptoscano
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-22 12:34:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
build.log none

Description Richard W.M. Jones 2014-04-16 15:43:05 UTC
Created attachment 886926 [details]
build.log

Description of problem:

virt-resize test fails in Rawhide with this error:

parted -s -- /dev/sdb name 1 \xef\xbb\xbfprimary
Error during translation: Invalid or incomplete multibyte or wide character
guestfsd: error: parted: /dev/sdb: Error during translation: Invalid or incomplete multibyte or wide character
libguestfs: trace: part_set_name = -1 (error)
virt-resize: libguestfs error: part_set_name: parted: /dev/sdb: Error during translation: Invalid or incomplete multibyte or wide character

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

libguestfs 1.27.5

How reproducible:

Unknown, at least once.
Only happens in Rawhide, and only seems to have started
happening in the last week or so.

Comment 1 Richard W.M. Jones 2014-04-17 07:29:54 UTC
*** Bug 1088738 has been marked as a duplicate of this bug. ***

Comment 2 Pino Toscano 2014-04-17 09:40:19 UTC
It seems things started to change parted in 3.1-18, with patch
  0066-bug-15591-PATCH-libparted-handle-i18n-gpt-partition-.patch

Apparently sgdisk (part of gdisk), which we use to get the partition name in GPT layouts does not cope well with the encoding written in GPT, and returns also the encoding bytes in the output, as you can also see in the output:

  libguestfs: trace: part_get_name "/dev/sda" 1
  guestfsd: main_loop: proc 54 (statvfs) took 0.01 seconds
  guestfsd: main_loop: new request, len 0x38
  parted -m -- /dev/sda unit b print
  sgdisk /dev/sda -i 1
  Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
  Partition unique GUID: 974123F1-DADF-48FF-9AD0-DB41C13E43C7
  First sector: 64 (at 32.0 KiB)
  Last sector: 65599 (at 32.0 MiB)
  Partition size: 65536 sectors (32.0 MiB)
  Attribute flags: 0000000000000000
  Partition name: '\xef\xbb\xbfprimary'
  libguestfs: trace: part_get_name = "\xef\xbb\xbfprimary"

I'm not totally sure whether it is a sgdisk fault (I see in recent versions grew own UTF-16 handling without using ICU, although the ICU code is still there but not preferred).

What could be done is switch part_get_name into querying parted directly instead of using sgdisk, which most probably should have been done that way since the initial implementation (and it's my fault for that). This should reduce the possible discrepancy in output between tools we use.
The only drawback of this approach is that it requires the -m output of parted, although recent enough versions of parted have it (even the old 2.3, currently provided in Debian, has it), so it shouldn't be an issue.

Patch posted to the mailing list:
  https://www.redhat.com/archives/libguestfs/2014-April/msg00048.html

Comment 3 Pino Toscano 2014-04-22 12:34:10 UTC
https://github.com/libguestfs/libguestfs/commit/0316d247706aab7ce7c2225472feeb51fa8b1664
fixes the issue in libguestfs >= 1.27.6.

Comment 4 Pino Toscano 2014-04-22 17:05:31 UTC
https://github.com/libguestfs/libguestfs/commit/7d01aa56f37e40fefece453751ace54def45837e
fixes the issue in libguestfs >= 1.26.1.