Bug 1249918

Summary: Java liguestfs g.part_list gives java.lang.ArrayStoreException
Product: [Community] Virtualization Tools Reporter: keesboog <kees2006>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: kees2006, ptoscano, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-04 10:24:05 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:

Description keesboog 2015-08-04 07:06:41 UTC
Description of problem:

When trying to list the partitions with g.part_list() an unexpected error is thrown from the undelying native method. Other (deprecated or less useful) functions to show the partitions do work.


Version-Release number of selected component (if applicable):
libquestfs-1.24.5 (as distributed via Ubuntu 14.04)

How reproducible:


Steps to Reproduce:
1. use the following code snippet:
            g.launch();

            System.out.println("");
            System.out.println("g.part_list does not work");
            try {
                Partition[] partitions = g.part_list("/dev/sda");
            } catch (Exception ex) {
                    System.err.println(ex);
                    ex.printStackTrace();
            }
            System.out.println("");
            String sfdisk = g.sfdisk_l("/dev/sda");
            System.out.println("g.sfdisk_l works");
            System.out.println("g.sfdisk_l(\"/dev/sda\"): \n" + sfdisk);

            System.out.println("");

            System.out.println("g.listpartitions also works");
            String[] partitions = g.list_partitions();
            System.out.println("");

            System.out.println("partitions: ");
            for (String partition : partitions) {
                    System.out.println("partition: " + partition);
            }
            System.out.println("");
            g.close(); 

2. Compile

3. Execute

Actual results:
g.part_list does not work
java.lang.ArrayStoreException
java.lang.ArrayStoreException
        at com.redhat.et.libguestfs.GuestFS._part_list(Native Method)
        at com.redhat.et.libguestfs.GuestFS.part_list(GuestFS.java:11131)
        at ListPartitions.main(ListPartitions.java:37)

g.sfdisk_l works
g.sfdisk_l("/dev/sda"):

Disk /dev/sda: 1019 cylinders, 162 heads, 62 sectors/track
Units = cylinders of 5142528 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1   *      0+     49-     50-    248832   83  Linux
/dev/sda2         49+   1019-    970-   4868097    5  Extended
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty
/dev/sda5         49+   1019-    970-   4868096   8e  Linux LVM


g.listpartitions also works

partitions:
partition: /dev/sda1
partition: /dev/sda2
partition: /dev/sda5


Expected results:


Additional info:

Comment 1 Richard W.M. Jones 2015-08-04 07:21:27 UTC
Possible dupe of bug 1073906 (I did not check in detail yet).

If it's a dupe then it would be fixed in 1.24.7 and 1.26+.

Also my comment here is relevant:
https://bugzilla.redhat.com/show_bug.cgi?id=1194472#c2

Comment 2 Richard W.M. Jones 2015-08-04 10:24:05 UTC
I checked and this is not reproducible with libguestfs 1.31.1.

There was a problem with Java methods (such as g.part_list) which
used the RStructList method of returning lists of structures.  It
didn't affect the other calls you mention because they use a different
return method in the generator.

This is fixed in 1.24.7 and all recent versions of libguestfs.

*** This bug has been marked as a duplicate of bug 1073906 ***