RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1342337 - Should remind a warning about disk image has a partition when using virt-p2v-make-disk
Summary: Should remind a warning about disk image has a partition when using virt-p2v-...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.3
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard: P2V
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-03 03:16 UTC by mxie@redhat.com
Modified: 2016-11-03 18:00 UTC (History)
6 users (show)

Fixed In Version: libguestfs-1.32.5-7.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:00:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2576 0 normal SHIPPED_LIVE Moderate: libguestfs and virt-p2v security, bug fix, and enhancement update 2016-11-03 12:06:51 UTC

Description mxie@redhat.com 2016-06-03 03:16:06 UTC
Description of problem:
Should remind a warning about disk image has a partition when using virt-p2v-make-disk


Version-Release number of selected component (if applicable):
virt-p2v-1.32.4-1.el7.iso


How reproducible:
100%

Steps to Reproduce:
1.Check usage info in virt-p2v-make-disk manual page, it said disk image shouldn't have a partation

#man virt-p2v-make-disk
EXAMPLES
Write a virt-p2v bootable USB key on /dev/sdX (any existing content on /dev/sdX is erased):

 virt-p2v-make-disk -o /dev/sdX

2.Prepare a 16G usb key, format and make a partition for usb key

2.1 #mkfs -t ext4 /dev/sdc

2.2 #fdisk /dev/sdc

2.3 #fdisk -l
Disk /dev/sdc: 16.0 GB, 16022241280 bytes, 31293440 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x5c970635

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    31293439    15645696   83  Linux

3.Inject the private key to usb key with virt-p2v-make-disk and the building was finished without error about disk image has a partition

# virt-p2v-make-disk -o /dev/sdc1 --inject-ssh-identity id_rsa
[   3.0] Downloading: http://libguestfs.org/download/builder/fedora-23.xz
[   4.4] Planning how to build this image
[   4.4] Uncompressing
[  16.7] Resizing (using virt-resize) to expand the disk to 14.9G
[ 510.4] Opening the new disk
[ 513.9] Setting a random seed
[ 513.9] Updating packages
[1136.0] Installing packages: pcre libxml2 gtk2 /usr/bin/ssh /usr/bin/qemu-nbd curl ethtool hwdata xterm /usr/bin/xinit /usr/bin/Xorg xorg-x11-drivers xorg-x11-fonts-Type1 mesa-dri-drivers metacity NetworkManager nm-connection-editor network-manager-applet dbus-x11 @hardware-support
[1235.0] Uploading: /usr/share/virt-p2v/issue to /etc/issue
[1235.1] Uploading: /usr/share/virt-p2v/issue to /etc/issue.net
[1235.1] Making directory: /usr/libexec
[1235.1] Uploading: /usr/libexec/virt-p2v to /usr/libexec
[1235.1] Changing permissions of /usr/libexec/virt-p2v to 0755
[1235.1] Uploading: /usr/share/virt-p2v/launch-virt-p2v to /usr/bin/
[1235.1] Changing permissions of /usr/bin/launch-virt-p2v to 0755
[1235.1] Uploading: /usr/share/virt-p2v/p2v.service to /etc/systemd/system/
[1235.1] Making directory: /etc/systemd/system/default.target.wants
[1235.1] Linking: /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target
[1235.1] Linking: /etc/systemd/system/default.target.wants/p2v.service -> /etc/systemd/system/p2v.service
[1235.1] Editing: /usr/lib/systemd/system/getty@.service
[1235.2] Editing: /etc/systemd/logind.conf
[1235.2] Uploading: id_rsa to /var/tmp/id_rsa
[1235.2] Editing: /etc/selinux/config
[1235.2] Uploading: /tmp/tmp.8PdSnKAZiU/p2v.conf to /etc/dracut.conf.d/
[1235.2] Running: /tmp/tmp.8PdSnKAZiU/post-install
[1308.0] Setting passwords
[1342.7] Finishing off
                   Output file: /dev/sdc1
                   Output size: 14.9G
                 Output format: raw
            Total usable space: 14.3G
                    Free space: 12.8G (89%)


Actual results:
As above description

Expected results:
Because building need a long time, it will save customer's time if the building could be failed with a warning or error "disk image shouldn't have a partiation "
 
Additional info:

Comment 2 Richard W.M. Jones 2016-06-03 08:10:12 UTC
I posted a patch for this yesterday.  The new output has a
warning which reads:

  virt-builder: warning: output device (/dev/sdb1) is a partition.  If you
  are writing to a USB key or external drive then you probably need to write
  to the whole device, not to a partition.  If this warning is wrong then you
  can disable it with --no-warn-if-partition

https://www.redhat.com/archives/libguestfs/2016-June/msg00002.html

Comment 4 zhoujunqin 2016-06-27 09:17:05 UTC
I can reproduce this issue with build:
# rpm -q virt-v2v virt-p2v
virt-v2v-1.32.4-3.el7.x86_64
virt-p2v-1.32.4-3.el7.noarch

Then try to verify with new build:
virt-v2v-1.32.5-6.el7.x86_64
virt-p2v-1.32.5-6.el7.noarch

Steps:
1. Prepare a USB device with 1 partition
# fdisk -l /dev/sdb

Disk /dev/sdb: 16.0 GB, 16022241280 bytes, 31293440 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8f3f3a11

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    31293439    15645696   83  Linux

2. Use virt-p2v-make-disk creates a bootable disk image or USB key containing virt-p2v to this USB device.

# virt-p2v-make-disk -o /dev/sdb1 
virt-builder: warning: output device (/dev/sdb1) is a partition.  If you 
are writing to a USB key or external drive then you probably need to write 
to the whole device, not to a partition.  If this warning is wrong then you 
can disable it with --no-warn-if-partition
[   2.6] Downloading: http://libguestfs.org/download/builder/fedora-24.xz
[  12.8] Planning how to build this image
[  12.8] Uncompressing
[  19.5] Resizing (using virt-resize) to expand the disk to 14.9G
[ 508.2] Opening the new disk
[ 510.8] Setting a random seed
[ 510.8] Updating packages
[ 721.2] Installing packages: pcre libxml2 gtk2 /usr/bin/ssh /usr/bin/qemu-nbd curl ethtool hwdata pciutils hdparm smartmontools util-linux xterm /usr/bin/xinit /usr/bin/Xorg xorg-x11-drivers xorg-x11-fonts-Type1 dejavu-sans-fonts dejavu-sans-mono-fonts mesa-dri-drivers metacity NetworkManager nm-connection-editor network-manager-applet dbus-x11 net-tools @hardware-support
[1014.4] Uploading: /usr/share/virt-p2v/issue to /etc/issue
[1014.4] Uploading: /usr/share/virt-p2v/issue to /etc/issue.net
[1014.4] Making directory: /usr/libexec
[1014.4] Uploading: /usr/libexec/virt-p2v to /usr/libexec
[1014.4] Changing permissions of /usr/libexec/virt-p2v to 0755
[1014.4] Uploading: /usr/share/virt-p2v/launch-virt-p2v to /usr/bin/
[1014.4] Changing permissions of /usr/bin/launch-virt-p2v to 0755
[1014.4] Uploading: /usr/share/virt-p2v/p2v.service to /etc/systemd/system/
[1014.4] Making directory: /etc/systemd/system/default.target.wants
[1014.4] Linking: /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target
[1014.5] Linking: /etc/systemd/system/default.target.wants/p2v.service -> /etc/systemd/system/p2v.service
[1014.5] Editing: /usr/lib/systemd/system/getty@.service
[1014.6] Editing: /etc/systemd/logind.conf
[1014.6] Editing: /etc/selinux/config
[1014.6] Uploading: /tmp/tmp.TCh3Ea6cfq/p2v.conf to /etc/dracut.conf.d/
[1014.6] Running: /tmp/tmp.TCh3Ea6cfq/post-install
[1134.3] Setting passwords
[1180.1] Finishing off
                   Output file: /dev/sdb1
                   Output size: 14.9G
                 Output format: raw
            Total usable space: 14.3G
                    Free space: 12.9G (90%)

Result:
After step2, We can get a clear warning when output device is a partition:

virt-builder: warning: output device (/dev/sdb1) is a partition.  If you 
are writing to a USB key or external drive then you probably need to write 
to the whole device, not to a partition.  If this warning is wrong then you 
can disable it with --no-warn-if-partition

Then try with "--no-warn-if-partition" but failed.
# virt-p2v-make-disk -o /dev/sdb1 --no-warn-if-partition
virt-p2v-make-disk: unrecognized option '--no-warn-if-partition'
virt-p2v-make-disk: problem parsing the command line arguments

So rjones, please help me have a look about option '--no-warn-if-partition', how make it work, thanks.

Comment 5 Richard W.M. Jones 2016-06-27 09:24:13 UTC
Moving back to ASSIGNED.  I will add --no-warn-if-partition to
virt-p2v-make-disk too.

Comment 7 Richard W.M. Jones 2016-06-27 10:42:10 UTC
Added this option to virt-p2v-make-disk in this commit:
https://github.com/libguestfs/libguestfs/commit/07137ea565653ca22e055cef09a08add6ad5f1c9

Comment 9 mxie@redhat.com 2016-06-28 10:54:33 UTC
Verify bug with new build:
virt-v2v-1.32.5-7.el7.x86_64

Steps:
1.Check --no-warn-if-partition info in virt-builder manual page
# man virt-builder
--no-warn-if-partition
           Do not emit a warning if the output device is a partition.  This warning avoids a common user
           error when writing to a USB key or external drive, when you should normally write to the whole
           device (--output /dev/sdX), not to a partition on the device (--output /dev/sdX1).  Use this
           option to suppress this warning.

2. Prepare a USB device with 1 partition
# fdisk -l

 Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    31293439    15645696   83  Linux

3. Use virt-p2v-make-disk to build p2v to USB key without parameter "--no-warn-if-partition", there is a warning about partition and the building process will not show details info like before

# virt-p2v-make-disk -o /dev/sdb1
virt-builder: warning: output device (/dev/sdb1) is a partition.  If you 
are writing to a USB key or external drive then you probably need to write 
to the whole device, not to a partition.  If this warning is wrong then you 
can disable it with --no-warn-if-partition
[   2.8] Downloading: http://libguestfs.org/download/builder/fedora-24.xz
                                                                           3.4%

4. Use virt-p2v-make-disk to build p2v to USB key with parameter "--no-warn-if-partition", there is no a warning about partition 

# virt-p2v-make-disk -o /dev/sdb1 --no-warn-if-partition
[   3.1] Downloading: http://libguestfs.org/download/builder/fedora-24.xz
                                                                           0.8%

Result now:
According to step4's result,arameter "--no-warn-if-partition" works well


Hi rjones

I have some query with fixing method of this bug, because using virt-p2v-make-disk to build p2v to USB key which has partition, the host can't boot into the usb key after building, the building has no any meaning, besides ,building need a long time, it will waste customer's time, why not failed this building directly using error "output device (/dev/sdb1) is a partition" ? Thanks

Comment 10 Richard W.M. Jones 2016-06-28 13:39:05 UTC
I sort of agree with you.  The problem is that only virt-builder
knows that the output is a partition, but we want to allow virt-builder
(in the general case) to write to partitions as well as whole block
devices.  virt-p2v-make-disk doesn't "know" that the output is a
partition, so it cannot do anything here.

There's no good answer here, but at least there is a warning.

Comment 11 mxie@redhat.com 2016-06-29 08:48:33 UTC
According to comment 9 and comment 10, the bug has been fixed, so move the bug from ON_QA to VERIFIED

Comment 13 errata-xmlrpc 2016-11-03 18:00:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2576.html


Note You need to log in before you can comment on or make changes to this bug.