read-write in LIBGUESTFS 1.20
by Evaggelos Balaskas
How can i open a virtual disk in read-write mode ?
# guestmount --rw -d winxp -m /dev/sda1 /media/
# rm -f /media/pagefile.sys
rm: cannot remove ‘/media/pagefile.sys’: Operation not permitted
# cd /media && touch file
touch: cannot touch ‘file’: Permission denied
# cd && fusermount -u /media
I've tried with guestfish also.
I have compiled libguestfs with this conf:
./configure \
PYTHON=/usr/bin/python2 \
--prefix=/usr --libdir=/usr/lib \
--mandir=/usr/share/man \
--sysconfdir=/etc \
--disable-probes \
--disable-gobject \
--enable-introspection=no \
--disable-lua \
--disable-erlang \
--disable-php \
--disable-haskell \
--disable-ruby \
--without-java \
--with-default-attach-method=libvirt
am i missing something ?
--
Evaggelos Balaskas - Unix System Engineer
http://gr.linkedin.com/in/evaggelosbalaskas
11 years, 10 months
Status of libguestfs in Fedora, RHEL
by Richard W.M. Jones
Fedora
│
├── Fedora 16 libguestfs 1.16 (currently 1.16.34)
│
├── Fedora 17 libguestfs 1.18 (currently 1.18.11)
│
├── Fedora 18 libguestfs 1.20 (currently 1.20.0)
│
└── Rawhide libguestfs 1.21 (development releases as usual)
RHEL
│
├── RHEL 5 ancient libguestfs 1.2
│ │ (DO NOT USE this version except with virt-v2v,
│ │ and even then it's far better to use RHEL 6)
│ │
│ └── EPEL 5 libguestfs 1.19 from oldlinux branch, will
│ move to 1.20 soon
│
│
├── RHEL 6
│ │
│ ├── RHEL 6.0 libguestfs 1.2 (no longer supported, DO NOT USE)
│ │
│ ├── RHEL 6.1 libguestfs 1.7.17 (no longer supported)
│ │
│ ├── RHEL 6.2 libguestfs 1.7.17 (no longer supported)
│ │
│ ├── RHEL 6.3 libguestfs 1.16.19 + RHEL patches
│ │
│ ├── RHEL 6.4 libguestfs 1.16.34 + RHEL patches
│ │
│ └── RHEL 6.5 unknown, possibly rebase to 1.20 if
│ there is time and any demand for it
│
│
└── RHEL 7 libguestfs 1.20
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
11 years, 10 months
Release notes appendix for libguestfs 1.20 on Fedora 18
by Richard W.M. Jones
I'm just about to release libguestfs 1.20. This appendix covers
issues specific to Fedora 18.
Fedora 18 defaults to using the libvirt attach-method, meaning that
libvirt is used to create and manage the libguestfs appliance. There
are several benefits to this (see the full release notes). You can
switch back to the ordinary method (directly running qemu) at any time
by doing:
export LIBGUESTFS_ATTACH_METHOD=appliance
There is a bug in libvirt (or perhaps libnl, or somewhere else) which
causes libvirtd to segfault occasionally:
https://bugzilla.redhat.com/show_bug.cgi?id=875741
You will need selinux-policy >= 3.11.1-63.fc18 and
libvirt >= 0.10.2.1-3.fc18 in order to use SELinux in Enforcing mode
giving you the full benefit of sVirt protection. I have tested this
and it all works well for me, but please open bugs if you find any
problems.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/
11 years, 10 months
virt-resize Fatal error: exception Guestfs.Error("e2fsck_f
by Phill Bandelow
We’ve been seeing this a lot lately on generic CentOS 6 rpm installs:
rpm -qa | grep libguestfs
libguestfs-java-1.16.19-1.el6.x86_64
libguestfs-java-devel-1.16.19-1.el6.x86_64
libguestfs-1.16.19-1.el6.x86_64
libguestfs-tools-1.16.19-1.el6.x86_64
libguestfs-javadoc-1.16.19-1.el6.x86_64
libguestfs-devel-1.16.19-1.el6.x86_64
libguestfs-tools-c-1.16.19-1.el6.x86_64
libguestfs-winsupport-1.0-7.el6.x86_64
libguestfs-debuginfo-1.7.17-26.el6.x86_64
[root@torpedo ~]# virt-resize -d --resize /dev/sda2=512M --expand /dev/sda1 /home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz /dev/vg0/kvm105_img
command line: virt-resize -d --resize /dev/sda2=512M --expand /dev/sda1 /home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz /dev/vg0/kvm105_img
Examining /home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz ...
libguestfs: trace: add_drive_opts "/home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz" "readonly:true"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: add_drive_opts "/dev/vg0/kvm105_img" "readonly:false"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: launch
libguestfs: trace: launch = 0
libguestfs: trace: lvm_set_filter "/dev/sda"
libguestfs: trace: lvm_set_filter = 0
libguestfs: trace: available "ntfsprogs ntfs3g"
libguestfs: trace: available = 0
libguestfs: trace: available "btrfs"
libguestfs: trace: available = 0
libguestfs: trace: blockdev_getss "/dev/sdb"
libguestfs: trace: blockdev_getss = 512
libguestfs: trace: blockdev_getsize64 "/dev/sda"
libguestfs: trace: blockdev_getsize64 = 1073741824
libguestfs: trace: blockdev_getsize64 "/dev/sdb"
libguestfs: trace: blockdev_getsize64 = 42949672960
libguestfs: trace: part_get_parttype "/dev/sda"
libguestfs: trace: part_get_parttype = "msdos"
/home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz size 1073741824 bytes
/dev/vg0/kvm105_img size 42949672960 bytes
partition table type: msdos
libguestfs: trace: pvs_full
libguestfs: trace: pvs_full = <struct guestfs_lvm_pv_list *>
libguestfs: trace: part_list "/dev/sda"
libguestfs: trace: part_list = <struct guestfs_partition_list *>
libguestfs: trace: part_get_bootable "/dev/sda" 1
libguestfs: trace: part_get_bootable = 1
libguestfs: trace: part_get_mbr_id "/dev/sda" 1
libguestfs: trace: part_get_mbr_id = 131
libguestfs: trace: vfs_type "/dev/sda1"
libguestfs: trace: vfs_type = "ext4"
libguestfs: trace: mount_ro "/dev/sda1" "/"
libguestfs: trace: mount_ro = 0
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
libguestfs: trace: part_get_bootable "/dev/sda" 2
libguestfs: trace: part_get_bootable = 0
libguestfs: trace: part_get_mbr_id "/dev/sda" 2
libguestfs: trace: part_get_mbr_id = 130
libguestfs: trace: vfs_type "/dev/sda2"
libguestfs: trace: vfs_type = "ext3"
libguestfs: trace: mount_ro "/dev/sda2" "/"
libguestfs: trace: mount_ro = 0
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
libguestfs: trace: lvs
libguestfs: trace: lvs = []
2 partitions found
/dev/sda1:
partition data: 1 1048576-1000341503 (999292928 bytes)
bootable: true
partition ID: 0x83
content: filesystem ext4 (983556096 bytes)
/dev/sda2:
partition data: 2 1000341504-1072693247 (72351744 bytes)
bootable: false
partition ID: 0x82
content: filesystem ext3 (70054912 bytes)
0 logical volumes found
surplus before --expand or --shrink: 41411182592
**********
Summary of changes:
/dev/sda1: This partition will be resized from 953.0M to 39.5G. The
filesystem ext4 on /dev/sda1 will be expanded using the 'resize2fs'
method.
/dev/sda2: This partition will be resized from 69.0M to 512.0M. The
filesystem ext3 on /dev/sda2 will be expanded using the 'resize2fs'
method.
**********
Setting up initial partition table on /dev/vg0/kvm105_img ...
libguestfs: trace: part_init "/dev/sdb" "msdos"
libguestfs: trace: part_init = 0
libguestfs: trace: pread_device "/dev/sda" 446 0
libguestfs: trace: pread_device = "\xebc\x90\x10\x8e\xd0\xbc\x00\xb0\xb8\x00\x00\x8e\xd8\x8e\xc0\xfb\xbe\x00|\xbf\x00\x06\xb9\x00\x02\xf3\xa4\xea!\x06\x00\x00\xbe\xbe\x078\x04u\x0b\x83\xc6\x10\x81\xfe\xfe\x07u\xf3\xeb\x16\xb4\x02\xb0\x01\xbb\x00|\xb2\x80\x8at\x01\x8bL\x02\xcd\x13\xea\x00|\x00\x00\xeb\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00\x00\x00\x00\x00\x00\xff\xfa\x90\x90\xf6\xc2\x80t\x05\xf6\xc2pt\x02\xb2\x80\xeay|\x00\x001\xc0\x8e\xd8\x8e\xd0\xbc\x00 \xfb\xa0d|<\xfft\x02\x88\xc2R\xbb\x17\x04\x80'\x03t\x06\xbe\x88}\xe8\x17\x01\xbe\x05|\xb4A\xbb\xaaU\xcd\x13ZRr=\x81\xfbU\xaau7\x83\xe1\x01t21\xc0\x89D\x04@\x88D\xff\x89D\x02\xc7\x04\x10\x00f\x8b\x1e\|f\x89\\x08f\x8b\x1e`|f\x89\\x0c\xc7D\x06\x00p\xb4B\xcd\x13r\x05\xbb\x00p\xebv\xb4\x08\xcd\x13s\x0d\xf6\xc2\x80\x0f\x84\xd0\x00\xbe\x93}\xe9\x82\x00f\x0f\xb6\xc6\x88d\xff"<truncated, original size 446 bytes>
libguestfs: trace: pwrite_device "/dev/sdb" "\xebc\x90\x10\x8e\xd0\xbc\x00\xb0\xb8\x00\x00\x8e\xd8\x8e\xc0\xfb\xbe\x00|\xbf\x00\x06\xb9\x00\x02\xf3\xa4\xea!\x06\x00\x00\xbe\xbe\x078\x04u\x0b\x83\xc6\x10\x81\xfe\xfe\x07u\xf3\xeb\x16\xb4\x02\xb0\x01\xbb\x00|\xb2\x80\x8at\x01\x8bL\x02\xcd\x13\xea\x00|\x00\x00\xeb\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00\x00\x00\x00\x00\x00\xff\xfa\x90\x90\xf6\xc2\x80t\x05\xf6\xc2pt\x02\xb2\x80\xeay|\x00\x001\xc0\x8e\xd8\x8e\xd0\xbc\x00 \xfb\xa0d|<\xfft\x02\x88\xc2R\xbb\x17\x04\x80'\x03t\x06\xbe\x88}\xe8\x17\x01\xbe\x05|\xb4A\xbb\xaaU\xcd\x13ZRr=\x81\xfbU\xaau7\x83\xe1\x01t21\xc0\x89D\x04@\x88D\xff\x89D\x02\xc7\x04\x10\x00f\x8b\x1e\|f\x89\\x08f\x8b\x1e`|f\x89\\x0c\xc7D\x06\x00p\xb4B\xcd\x13r\x05\xbb\x00p\xebv\xb4\x08\xcd\x13s\x0d\xf6\xc2\x80\x0f\x84\xd0\x00\xbe\x93}\xe9\x82\x00f\x0f\xb6\xc6\x88d\xff"<truncated, original size 446 bytes> 0
libguestfs: trace: pwrite_device = 446
libguestfs: trace: pread_device "/dev/sda" 2097152 512
libguestfs: trace: pread_device = "R\xe8(\x01t\x08V\xbe3\x81\xe8L\x01^\xbf\xf4\x81f\x8b-\x83}\x08\x00\x0f\x84\xe9\x00\x80|\xff\x00tFf\x8b\x1df\x8bM\x04f1\xc0\xb0\x7f9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\xc7\x04\x10\x00\x89D\x02f\x89\\x08f\x89L\x0c\xc7D\x06\x00pP\xc7D\x04\x00\x00\xb4B\xcd\x13\x0f\x82\xbb\x00\xbb\x00p\xebhf\x8bE\x04f\x09\xc0\x0f\x85\xa3\x00f\x8b\x05f1\xd2f\xf74\x88T\x0af1\xd2f\xf7t\x04\x88T\x0b\x89D\x0c;D\x08\x0f\x8d\x83\x00\x8b\x04*D\x0a9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\x8aT\x0d\xc0\xe2\x06\x8aL\x0a\xfe\xc1\x08\xd1\x8al\x0cZR\x8at\x0bP\xbb\x00p\x8e\xc31\xdb\xb4\x02\xcd\x13rP\x8c\xc3\x8eE\x0aX\xc1\xe0\x05\x01E\x0a`\x1e\xc1\xe0\x03\x89\xc11\xff1\xf6\x8e\xdb\xfc\xf3\xa5\x1f\xe8>\x00t\x06\xbe;\x81\xe8c\x00a\x83}\x08\x00\x0f\x85\x1d\xff\x83"<truncated, original size 2097152 bytes>
libguestfs: trace: pwrite_device "/dev/sdb" "R\xe8(\x01t\x08V\xbe3\x81\xe8L\x01^\xbf\xf4\x81f\x8b-\x83}\x08\x00\x0f\x84\xe9\x00\x80|\xff\x00tFf\x8b\x1df\x8bM\x04f1\xc0\xb0\x7f9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\xc7\x04\x10\x00\x89D\x02f\x89\\x08f\x89L\x0c\xc7D\x06\x00pP\xc7D\x04\x00\x00\xb4B\xcd\x13\x0f\x82\xbb\x00\xbb\x00p\xebhf\x8bE\x04f\x09\xc0\x0f\x85\xa3\x00f\x8b\x05f1\xd2f\xf74\x88T\x0af1\xd2f\xf7t\x04\x88T\x0b\x89D\x0c;D\x08\x0f\x8d\x83\x00\x8b\x04*D\x0a9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\x8aT\x0d\xc0\xe2\x06\x8aL\x0a\xfe\xc1\x08\xd1\x8al\x0cZR\x8at\x0bP\xbb\x00p\x8e\xc31\xdb\xb4\x02\xcd\x13rP\x8c\xc3\x8eE\x0aX\xc1\xe0\x05\x01E\x0a`\x1e\xc1\xe0\x03\x89\xc11\xff1\xf6\x8e\xdb\xfc\xf3\xa5\x1f\xe8>\x00t\x06\xbe;\x81\xe8c\x00a\x83}\x08\x00\x0f\x85\x1d\xff\x83"<truncated, original size 2097152 bytes> 512
libguestfs: trace: pwrite_device = 2097152
align_first_partition_and_fix_bootloader = false
libguestfs: trace: part_add "/dev/sdb" "primary" 2048 82835071
libguestfs: trace: part_add = 0
libguestfs: trace: part_add "/dev/sdb" "primary" 82835072 83883647
libguestfs: trace: part_add = 0
Copying /dev/sda1 ...
libguestfs: trace: copy_device_to_device "/dev/sda1" "/dev/sdb1" "size:999292928"
100% ⟦▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓⟧ 00:00
libguestfs: trace: copy_device_to_device = 0
Copying /dev/sda2 ...
libguestfs: trace: copy_device_to_device "/dev/sda2" "/dev/sdb2" "size:72351744"
libguestfs: trace: copy_device_to_device = 0
libguestfs: trace: part_set_bootable "/dev/sdb" 1 true
libguestfs: trace: part_set_bootable = 0
libguestfs: trace: part_set_mbr_id "/dev/sdb" 1 131
libguestfs: trace: part_set_mbr_id = 0
libguestfs: trace: part_set_mbr_id "/dev/sdb" 2 130
libguestfs: trace: part_set_mbr_id = 0
libguestfs: trace: umount_all
libguestfs: trace: umount_all = 0
libguestfs: trace: sync
libguestfs: trace: sync = 0
libguestfs: trace: close
libguestfs: trace: internal_autosync
libguestfs: trace: internal_autosync = 0
libguestfs: trace: kill_subprocess
libguestfs: trace: kill_subprocess = 0
libguestfs: trace: add_drive_opts "/dev/vg0/kvm105_img" "readonly:false"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: launch
libguestfs: trace: launch = 0
Expanding /dev/sda1 using the 'resize2fs' method ...
libguestfs: trace: e2fsck_f "/dev/sda1"
libguestfs: trace: e2fsck_f = -1 (error)
Fatal error: exception Guestfs.Error("e2fsck_f:
/dev/vda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
(i.e., without -a or -p options)")
libguestfs: trace: close
libguestfs: trace: internal_autosync
libguestfs: trace: internal_autosync = 0
libguestfs: trace: kill_subprocess
libguestfs: trace: kill_subprocess = 0
[root@torpedo ~]# rpm -qa | grep libguestfs
libguestfs-tools-c-1.16.19-1.el6.x86_64
libguestfs-winsupport-1.0-7.el6.x86_64
libguestfs-1.16.19-1.el6.x86_64
libguestfs-tools-1.16.19-1.el6.x86_64
libguestfs-javadoc-1.16.19-1.el6.x86_64
libguestfs-devel-1.16.19-1.el6.x86_64
libguestfs-debuginfo-1.7.17-26.el6.x86_64
libguestfs-java-1.16.19-1.el6.x86_64
libguestfs-java-devel-1.16.19-1.el6.x86_64
[root@torpedo ~]#
However on another host it works fine using the same source image:
[root@dev1 ~]# virt-resize -d --resize /dev/sda2=512M --expand /dev/sda1 /home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz /dev/vps/kvm109_img
command line: virt-resize -d --resize /dev/sda2=512M --expand /dev/sda1 /home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz /dev/vps/kvm109_img
Examining /home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz ...
libguestfs: trace: add_drive_opts "/home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz" "readonly:true"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: add_drive_opts "/dev/vps/kvm109_img" "readonly:false"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: launch
libguestfs: trace: launch = 0
libguestfs: trace: lvm_set_filter "/dev/sda"
libguestfs: trace: lvm_set_filter = 0
libguestfs: trace: available "ntfsprogs ntfs3g"
libguestfs: trace: available = 0
libguestfs: trace: available "btrfs"
libguestfs: trace: available = 0
libguestfs: trace: blockdev_getss "/dev/sdb"
libguestfs: trace: blockdev_getss = 512
libguestfs: trace: blockdev_getsize64 "/dev/sda"
libguestfs: trace: blockdev_getsize64 = 1073741824
libguestfs: trace: blockdev_getsize64 "/dev/sdb"
libguestfs: trace: blockdev_getsize64 = 107374182400
libguestfs: trace: part_get_parttype "/dev/sda"
libguestfs: trace: part_get_parttype = "msdos"
/home/solusvm/kvm/template/linux-ubuntu-12.04-server-x86_64-min-gen2-v1.gz size 1073741824 bytes
/dev/vps/kvm109_img size 107374182400 bytes
partition table type: msdos
libguestfs: trace: pvs_full
libguestfs: trace: pvs_full = <struct guestfs_lvm_pv_list *>
libguestfs: trace: part_list "/dev/sda"
libguestfs: trace: part_list = <struct guestfs_partition_list *>
libguestfs: trace: part_get_bootable "/dev/sda" 1
libguestfs: trace: part_get_bootable = 1
libguestfs: trace: part_get_mbr_id "/dev/sda" 1
libguestfs: trace: part_get_mbr_id = 131
libguestfs: trace: vfs_type "/dev/sda1"
libguestfs: trace: vfs_type = "ext4"
libguestfs: trace: mount_ro "/dev/sda1" "/"
libguestfs: trace: mount_ro = 0
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
libguestfs: trace: part_get_bootable "/dev/sda" 2
libguestfs: trace: part_get_bootable = 0
libguestfs: trace: part_get_mbr_id "/dev/sda" 2
libguestfs: trace: part_get_mbr_id = 130
libguestfs: trace: vfs_type "/dev/sda2"
libguestfs: trace: vfs_type = "ext3"
libguestfs: trace: mount_ro "/dev/sda2" "/"
libguestfs: trace: mount_ro = 0
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
libguestfs: trace: lvs
libguestfs: trace: lvs = []
2 partitions found
/dev/sda1:
partition data: 1 1048576-1000341503 (999292928 bytes)
bootable: true
partition ID: 0x83
content: filesystem ext4 (983556096 bytes)
/dev/sda2:
partition data: 2 1000341504-1072693247 (72351744 bytes)
bootable: false
partition ID: 0x82
content: filesystem ext3 (70054912 bytes)
0 logical volumes found
surplus before --expand or --shrink: 105835692032
**********
Summary of changes:
/dev/sda1: This partition will be resized from 953.0M to 99.5G. The
filesystem ext4 on /dev/sda1 will be expanded using the 'resize2fs'
method.
/dev/sda2: This partition will be resized from 69.0M to 512.0M. The
filesystem ext3 on /dev/sda2 will be expanded using the 'resize2fs'
method.
**********
Setting up initial partition table on /dev/vps/kvm109_img ...
libguestfs: trace: part_init "/dev/sdb" "msdos"
libguestfs: trace: part_init = 0
libguestfs: trace: pread_device "/dev/sda" 446 0
libguestfs: trace: pread_device = "\xebc\x90\x10\x8e\xd0\xbc\x00\xb0\xb8\x00\x00\x8e\xd8\x8e\xc0\xfb\xbe\x00|\xbf\x00\x06\xb9\x00\x02\xf3\xa4\xea!\x06\x00\x00\xbe\xbe\x078\x04u\x0b\x83\xc6\x10\x81\xfe\xfe\x07u\xf3\xeb\x16\xb4\x02\xb0\x01\xbb\x00|\xb2\x80\x8at\x01\x8bL\x02\xcd\x13\xea\x00|\x00\x00\xeb\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00\x00\x00\x00\x00\x00\xff\xfa\x90\x90\xf6\xc2\x80t\x05\xf6\xc2pt\x02\xb2\x80\xeay|\x00\x001\xc0\x8e\xd8\x8e\xd0\xbc\x00 \xfb\xa0d|<\xfft\x02\x88\xc2R\xbb\x17\x04\x80'\x03t\x06\xbe\x88}\xe8\x17\x01\xbe\x05|\xb4A\xbb\xaaU\xcd\x13ZRr=\x81\xfbU\xaau7\x83\xe1\x01t21\xc0\x89D\x04@\x88D\xff\x89D\x02\xc7\x04\x10\x00f\x8b\x1e\|f\x89\\x08f\x8b\x1e`|f\x89\\x0c\xc7D\x06\x00p\xb4B\xcd\x13r\x05\xbb\x00p\xebv\xb4\x08\xcd\x13s\x0d\xf6\xc2\x80\x0f\x84\xd0\x00\xbe\x93}\xe9\x82\x00f\x0f\xb6\xc6\x88d\xff"<truncated, original size 446 bytes>
libguestfs: trace: pwrite_device "/dev/sdb" "\xebc\x90\x10\x8e\xd0\xbc\x00\xb0\xb8\x00\x00\x8e\xd8\x8e\xc0\xfb\xbe\x00|\xbf\x00\x06\xb9\x00\x02\xf3\xa4\xea!\x06\x00\x00\xbe\xbe\x078\x04u\x0b\x83\xc6\x10\x81\xfe\xfe\x07u\xf3\xeb\x16\xb4\x02\xb0\x01\xbb\x00|\xb2\x80\x8at\x01\x8bL\x02\xcd\x13\xea\x00|\x00\x00\xeb\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00\x00\x00\x00\x00\x00\xff\xfa\x90\x90\xf6\xc2\x80t\x05\xf6\xc2pt\x02\xb2\x80\xeay|\x00\x001\xc0\x8e\xd8\x8e\xd0\xbc\x00 \xfb\xa0d|<\xfft\x02\x88\xc2R\xbb\x17\x04\x80'\x03t\x06\xbe\x88}\xe8\x17\x01\xbe\x05|\xb4A\xbb\xaaU\xcd\x13ZRr=\x81\xfbU\xaau7\x83\xe1\x01t21\xc0\x89D\x04@\x88D\xff\x89D\x02\xc7\x04\x10\x00f\x8b\x1e\|f\x89\\x08f\x8b\x1e`|f\x89\\x0c\xc7D\x06\x00p\xb4B\xcd\x13r\x05\xbb\x00p\xebv\xb4\x08\xcd\x13s\x0d\xf6\xc2\x80\x0f\x84\xd0\x00\xbe\x93}\xe9\x82\x00f\x0f\xb6\xc6\x88d\xff"<truncated, original size 446 bytes> 0
libguestfs: trace: pwrite_device = 446
libguestfs: trace: pread_device "/dev/sda" 2097152 512
libguestfs: trace: pread_device = "R\xe8(\x01t\x08V\xbe3\x81\xe8L\x01^\xbf\xf4\x81f\x8b-\x83}\x08\x00\x0f\x84\xe9\x00\x80|\xff\x00tFf\x8b\x1df\x8bM\x04f1\xc0\xb0\x7f9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\xc7\x04\x10\x00\x89D\x02f\x89\\x08f\x89L\x0c\xc7D\x06\x00pP\xc7D\x04\x00\x00\xb4B\xcd\x13\x0f\x82\xbb\x00\xbb\x00p\xebhf\x8bE\x04f\x09\xc0\x0f\x85\xa3\x00f\x8b\x05f1\xd2f\xf74\x88T\x0af1\xd2f\xf7t\x04\x88T\x0b\x89D\x0c;D\x08\x0f\x8d\x83\x00\x8b\x04*D\x0a9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\x8aT\x0d\xc0\xe2\x06\x8aL\x0a\xfe\xc1\x08\xd1\x8al\x0cZR\x8at\x0bP\xbb\x00p\x8e\xc31\xdb\xb4\x02\xcd\x13rP\x8c\xc3\x8eE\x0aX\xc1\xe0\x05\x01E\x0a`\x1e\xc1\xe0\x03\x89\xc11\xff1\xf6\x8e\xdb\xfc\xf3\xa5\x1f\xe8>\x00t\x06\xbe;\x81\xe8c\x00a\x83}\x08\x00\x0f\x85\x1d\xff\x83"<truncated, original size 2097152 bytes>
libguestfs: trace: pwrite_device "/dev/sdb" "R\xe8(\x01t\x08V\xbe3\x81\xe8L\x01^\xbf\xf4\x81f\x8b-\x83}\x08\x00\x0f\x84\xe9\x00\x80|\xff\x00tFf\x8b\x1df\x8bM\x04f1\xc0\xb0\x7f9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\xc7\x04\x10\x00\x89D\x02f\x89\\x08f\x89L\x0c\xc7D\x06\x00pP\xc7D\x04\x00\x00\xb4B\xcd\x13\x0f\x82\xbb\x00\xbb\x00p\xebhf\x8bE\x04f\x09\xc0\x0f\x85\xa3\x00f\x8b\x05f1\xd2f\xf74\x88T\x0af1\xd2f\xf7t\x04\x88T\x0b\x89D\x0c;D\x08\x0f\x8d\x83\x00\x8b\x04*D\x0a9E\x08\x7f\x03\x8bE\x08)E\x08f\x01\x05f\x83U\x04\x00\x8aT\x0d\xc0\xe2\x06\x8aL\x0a\xfe\xc1\x08\xd1\x8al\x0cZR\x8at\x0bP\xbb\x00p\x8e\xc31\xdb\xb4\x02\xcd\x13rP\x8c\xc3\x8eE\x0aX\xc1\xe0\x05\x01E\x0a`\x1e\xc1\xe0\x03\x89\xc11\xff1\xf6\x8e\xdb\xfc\xf3\xa5\x1f\xe8>\x00t\x06\xbe;\x81\xe8c\x00a\x83}\x08\x00\x0f\x85\x1d\xff\x83"<truncated, original size 2097152 bytes> 512
libguestfs: trace: pwrite_device = 2097152
align_first_partition_and_fix_bootloader = false
libguestfs: trace: part_add "/dev/sdb" "primary" 2048 208664191
libguestfs: trace: part_add = 0
libguestfs: trace: part_add "/dev/sdb" "primary" 208664192 209712767
libguestfs: trace: part_add = 0
Copying /dev/sda1 ...
libguestfs: trace: copy_device_to_device "/dev/sda1" "/dev/sdb1" "size:999292928"
100% [############################################################################################################################################] 00:00
libguestfs: trace: copy_device_to_device = 0
Copying /dev/sda2 ...
libguestfs: trace: copy_device_to_device "/dev/sda2" "/dev/sdb2" "size:72351744"
libguestfs: trace: copy_device_to_device = 0
libguestfs: trace: part_set_bootable "/dev/sdb" 1 true
libguestfs: trace: part_set_bootable = 0
libguestfs: trace: part_set_mbr_id "/dev/sdb" 1 131
libguestfs: trace: part_set_mbr_id = 0
libguestfs: trace: part_set_mbr_id "/dev/sdb" 2 130
libguestfs: trace: part_set_mbr_id = 0
libguestfs: trace: umount_all
libguestfs: trace: umount_all = 0
libguestfs: trace: sync
libguestfs: trace: sync = 0
libguestfs: trace: close
libguestfs: trace: internal_autosync
libguestfs: trace: internal_autosync = 0
libguestfs: trace: kill_subprocess
libguestfs: trace: kill_subprocess = 0
libguestfs: trace: add_drive_opts "/dev/vps/kvm109_img" "readonly:false"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: launch
libguestfs: trace: launch = 0
Expanding /dev/sda1 using the 'resize2fs' method ...
libguestfs: trace: e2fsck_f "/dev/sda1"
libguestfs: trace: e2fsck_f = 0
libguestfs: trace: resize2fs "/dev/sda1"
libguestfs: trace: resize2fs = 0
Expanding /dev/sda2 using the 'resize2fs' method ...
libguestfs: trace: e2fsck_f "/dev/sda2"
libguestfs: trace: e2fsck_f = 0
libguestfs: trace: resize2fs "/dev/sda2"
libguestfs: trace: resize2fs = 0
libguestfs: trace: umount_all
libguestfs: trace: umount_all = 0
libguestfs: trace: sync
libguestfs: trace: sync = 0
libguestfs: trace: close
libguestfs: trace: internal_autosync
libguestfs: trace: internal_autosync = 0
libguestfs: trace: kill_subprocess
libguestfs: trace: kill_subprocess = 0
Resize operation completed with no errors. Before deleting the old
disk, carefully check that the resized disk boots and works correctly.
[root@dev1 ~]# rpm -qa | grep libguestfs
libguestfs-java-1.16.19-1.el6.x86_64
libguestfs-java-devel-1.16.19-1.el6.x86_64
libguestfs-1.16.19-1.el6.x86_64
libguestfs-tools-1.16.19-1.el6.x86_64
libguestfs-javadoc-1.16.19-1.el6.x86_64
libguestfs-devel-1.16.19-1.el6.x86_64
libguestfs-tools-c-1.16.19-1.el6.x86_64
libguestfs-winsupport-1.0-7.el6.x86_64
libguestfs-debuginfo-1.7.17-26.el6.x86_64
[root@dev1 ~]#
Both the servers are on CentOS 6 using the same kernel and are fully updated.
Regards
Phill
11 years, 10 months
inspect_os error with Win7 image
by Skippy VonDrake
The error message:
hivex_close: do_hivex_close: you must call 'hivex-open' first to
initialize the hivex handle
This is the process flow:
g = guestfs_create ();
guestfs_add_drive_opts (g, diskFile,GUESTFS_ADD_DRIVE_OPTS_FORMAT,
"raw",-1);
guestfs_launch (g)
char **roots = guestfs_inspect_os (g);
guestfs_inspect_os returns NULL, guestfs_last_error(g) returns message above.
And guestfs_last_errno(g) returns 0.
However this same code works fine with a Server2008 image and an XP image.
I copied the verbose output to pastebin: http://pastebin.com/U9Jb6JwH
Suggestions?
11 years, 10 months
[PATCH 1/2] daemon: NFC Use symbolic names in commandrvf
by Matthew Booth
Improve readability of commandrvf() by replacing bare int values for
file descriptors with their symbolic names STD{IN,OUT,ERR}_FILENO.
Also add PIPE_READ and PIPE_WRITE for referencing relevant ends of a pipe.
---
daemon/guestfsd.c | 79 +++++++++++++++++++++++++++++--------------------------
1 file changed, 42 insertions(+), 37 deletions(-)
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 5c84849..4b3dd5f 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -66,6 +66,10 @@ static char *read_cmdline (void);
# define O_CLOEXEC 0
#endif
+/* For improved readability dealing with pipe arrays */
+#define PIPE_READ 0
+#define PIPE_WRITE 1
+
/* If root device is an ext2 filesystem, this is the major and minor.
* This is so we can ignore this device from the point of view of the
* user, eg. in guestfs_list_devices and many other places.
@@ -834,22 +838,22 @@ commandrvf (char **stdoutput, char **stderror, int flags,
signal (SIGPIPE, SIG_DFL);
close (0);
if (flag_copy_stdin) {
- dup2 (stdin_fd[0], 0);
- close (stdin_fd[0]);
- close (stdin_fd[1]);
+ dup2 (stdin_fd[PIPE_READ], STDIN_FILENO);
+ close (stdin_fd[PIPE_READ]);
+ close (stdin_fd[PIPE_WRITE]);
} else {
/* Set stdin to /dev/null (ignore failure) */
ignore_value (open ("/dev/null", O_RDONLY|O_CLOEXEC));
}
- close (so_fd[0]);
- close (se_fd[0]);
+ close (so_fd[PIPE_READ]);
+ close (se_fd[PIPE_READ]);
if (!(flags & COMMAND_FLAG_FOLD_STDOUT_ON_STDERR))
- dup2 (so_fd[1], 1);
+ dup2 (so_fd[PIPE_WRITE], STDOUT_FILENO);
else
- dup2 (se_fd[1], 1);
- dup2 (se_fd[1], 2);
- close (so_fd[1]);
- close (se_fd[1]);
+ dup2 (se_fd[PIPE_WRITE], STDOUT_FILENO);
+ dup2 (se_fd[PIPE_WRITE], STDERR_FILENO);
+ close (so_fd[PIPE_WRITE]);
+ close (se_fd[PIPE_WRITE]);
execvp (argv[0], (void *) argv);
perror (argv[0]);
@@ -866,15 +870,15 @@ commandrvf (char **stdoutput, char **stderror, int flags,
}
if (stdin_pid == 0) { /* Child process copying stdin. */
- close (so_fd[0]);
- close (so_fd[1]);
- close (se_fd[0]);
- close (se_fd[1]);
+ close (so_fd[PIPE_READ]);
+ close (so_fd[PIPE_WRITE]);
+ close (se_fd[PIPE_READ]);
+ close (se_fd[PIPE_WRITE]);
- close (1);
- dup2 (stdin_fd[1], 1);
- close (stdin_fd[0]);
- close (stdin_fd[1]);
+ close (STDOUT_FILENO);
+ dup2 (stdin_fd[PIPE_WRITE], STDOUT_FILENO);
+ close (stdin_fd[PIPE_READ]);
+ close (stdin_fd[PIPE_WRITE]);
if (chroot (sysroot) == -1) {
perror ("chroot");
@@ -884,7 +888,7 @@ commandrvf (char **stdoutput, char **stderror, int flags,
ssize_t n;
char buffer[BUFSIZ];
while ((n = read (fd, buffer, sizeof buffer)) > 0) {
- if (xwrite (1, buffer, n) == -1)
+ if (xwrite (STDOUT_FILENO, buffer, n) == -1)
/* EPIPE error indicates the command process has exited
* early. If the command process fails that will be caught
* by the daemon, and if not, then it's not an error.
@@ -906,23 +910,24 @@ commandrvf (char **stdoutput, char **stderror, int flags,
}
close (fd);
- close (stdin_fd[0]);
- close (stdin_fd[1]);
+ close (stdin_fd[PIPE_READ]);
+ close (stdin_fd[PIPE_WRITE]);
}
/* Parent process. */
- close (so_fd[1]);
- close (se_fd[1]);
+ close (so_fd[PIPE_WRITE]);
+ close (se_fd[PIPE_WRITE]);
FD_ZERO (&rset);
- FD_SET (so_fd[0], &rset);
- FD_SET (se_fd[0], &rset);
+ FD_SET (so_fd[PIPE_READ], &rset);
+ FD_SET (se_fd[PIPE_READ], &rset);
quit = 0;
while (quit < 2) {
again:
rset2 = rset;
- r = select (MAX (so_fd[0], se_fd[0]) + 1, &rset2, NULL, NULL, NULL);
+ r = select (MAX (so_fd[PIPE_READ], se_fd[PIPE_READ]) + 1, &rset2,
+ NULL, NULL, NULL);
if (r == -1) {
if (errno == EINTR)
goto again;
@@ -943,20 +948,20 @@ commandrvf (char **stdoutput, char **stderror, int flags,
*stderror = strdup ("error running external command, "
"see debug output for details");
}
- close (so_fd[0]);
- close (se_fd[0]);
+ close (so_fd[PIPE_READ]);
+ close (se_fd[PIPE_READ]);
waitpid (pid, NULL, 0);
if (stdin_pid >= 0) waitpid (stdin_pid, NULL, 0);
return -1;
}
- if (FD_ISSET (so_fd[0], &rset2)) { /* something on stdout */
- r = read (so_fd[0], buf, sizeof buf);
+ if (FD_ISSET (so_fd[PIPE_READ], &rset2)) { /* something on stdout */
+ r = read (so_fd[PIPE_READ], buf, sizeof buf);
if (r == -1) {
perror ("read");
goto quit;
}
- if (r == 0) { FD_CLR (so_fd[0], &rset); quit++; }
+ if (r == 0) { FD_CLR (so_fd[PIPE_READ], &rset); quit++; }
if (r > 0 && stdoutput) {
so_size += r;
@@ -970,17 +975,17 @@ commandrvf (char **stdoutput, char **stderror, int flags,
}
}
- if (FD_ISSET (se_fd[0], &rset2)) { /* something on stderr */
- r = read (se_fd[0], buf, sizeof buf);
+ if (FD_ISSET (se_fd[PIPE_READ], &rset2)) { /* something on stderr */
+ r = read (se_fd[PIPE_READ], buf, sizeof buf);
if (r == -1) {
perror ("read");
goto quit;
}
- if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; }
+ if (r == 0) { FD_CLR (se_fd[PIPE_READ], &rset); quit++; }
if (r > 0) {
if (verbose)
- ignore_value (write (2, buf, r));
+ ignore_value (write (STDERR_FILENO, buf, r));
if (stderror) {
se_size += r;
@@ -996,8 +1001,8 @@ commandrvf (char **stdoutput, char **stderror, int flags,
}
}
- close (so_fd[0]);
- close (se_fd[0]);
+ close (so_fd[PIPE_READ]);
+ close (se_fd[PIPE_READ]);
/* Make sure the output buffers are \0-terminated. Also remove any
* trailing \n characters from the error buffer (not from stdout).
--
1.7.11.7
11 years, 10 months
[PATCH] Add support for getting and setting GPT partition type GUIDs
by Matthew Booth
New APIs:
part_set_gpt_type
part_get_gpt_type
---
appliance/packagelist.in | 1 +
daemon/parted.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++
generator/actions.ml | 30 +++++++++++
generator/tests_c_api.ml | 7 +++
generator/types.ml | 5 ++
src/MAX_PROC_NR | 2 +-
6 files changed, 173 insertions(+), 1 deletion(-)
diff --git a/appliance/packagelist.in b/appliance/packagelist.in
index 3ad343b..9b0cc09 100644
--- a/appliance/packagelist.in
+++ b/appliance/packagelist.in
@@ -111,6 +111,7 @@ dosfstools
file
findutils
gawk
+gdisk
grep
gzip
jfsutils
diff --git a/daemon/parted.c b/daemon/parted.c
index cc9a84b..01ae91c 100644
--- a/daemon/parted.c
+++ b/daemon/parted.c
@@ -30,6 +30,7 @@
GUESTFSD_EXT_CMD(str_parted, parted);
GUESTFSD_EXT_CMD(str_sfdisk, sfdisk);
+GUESTFSD_EXT_CMD(str_sgdisk, sgdisk);
/* Notes:
*
@@ -802,3 +803,131 @@ do_part_set_mbr_id (const char *device, int partnum, int idbyte)
return 0;
}
+
+int
+do_part_set_gpt_type(const char *device, int partnum, const char *guid)
+{
+ if (partnum <= 0) {
+ reply_with_error ("partition number must be >= 1");
+ return -1;
+ }
+
+ char *typecode = NULL;
+ if (asprintf (&typecode, "%i:%s", partnum, guid) == -1) {
+ reply_with_perror ("asprintf");
+ return -1;
+ }
+
+ char *err = NULL;
+ int r = command (NULL, &err, str_sgdisk, device, "-t", typecode, NULL);
+
+ if (r == -1) {
+ reply_with_error ("%s %s -t %s: %s", str_sgdisk, device, typecode, err);
+ free (typecode);
+ free (err);
+ return -1;
+ }
+ free (typecode);
+ free (err);
+
+ return 0;
+}
+
+char *
+do_part_get_gpt_type(const char *device, int partnum)
+{
+ if (partnum <= 0) {
+ reply_with_error ("partition number must be >= 1");
+ return NULL;
+ }
+
+ char *partnum_str = NULL;
+ if (asprintf (&partnum_str, "%i", partnum) == -1) {
+ reply_with_perror ("asprintf");
+ return NULL;
+ }
+
+ char *out = NULL, *err = NULL;
+ int r = command (&out, &err, str_sgdisk, device, "-i", partnum_str, NULL);
+
+ if (r == -1) {
+ reply_with_error ("%s %s -i %s: %s", str_sgdisk, device, partnum_str, err);
+ free (partnum_str);
+ free (out);
+ free (err);
+ return NULL;
+ }
+ free (partnum_str);
+ free (err);
+
+ if (verbose)
+ fprintf (stderr, "Output of %s %s -i %i:\n", str_sgdisk, device, partnum);
+
+ char **lines = split_lines (out);
+ if (lines == NULL) {
+ reply_with_error ("'%s %s -i %i' returned no output",
+ str_sgdisk, device, partnum);
+ free (out);
+ return NULL;
+ }
+
+ /* Parse the output of sgdisk -i:
+ * Partition GUID code: 21686148-6449-6E6F-744E-656564454649 (BIOS boot partition)
+ * Partition unique GUID: 19AEC5FE-D63A-4A15-9D37-6FCBFB873DC0
+ * First sector: 2048 (at 1024.0 KiB)
+ * Last sector: 411647 (at 201.0 MiB)
+ * Partition size: 409600 sectors (200.0 MiB)
+ * Attribute flags: 0000000000000000
+ * Partition name: 'EFI System Partition'
+ */
+ for (char **i = lines; *i != NULL; i++) {
+ char *line = *i;
+
+ if (verbose) fprintf (stderr, "%s\n", line);
+
+ /* Skip blank lines */
+ if (line[0] == '\0') continue;
+
+ /* Split the line in 2 at the colon */
+ char *colon = strchr (line, ':');
+ if (colon) {
+#define SEARCH "Partition GUID code"
+ if (colon - line == strlen(SEARCH) &&
+ memcmp (line, SEARCH, strlen(SEARCH)) == 0)
+ {
+#undef SEARCH
+ /* The value starts after the colon */
+ char *value = colon + 1;
+
+ /* Skip any leading whitespace */
+ value += strspn (value, " \t");
+
+ /* The value contains only valid GUID characters */
+ size_t value_len = strspn (value, "-0123456789ABCDEF");
+fprintf(stderr, "%zi: %s\n", value_len, value);
+
+ char *ret = malloc (value_len + 1);
+ if (ret == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+
+ memcpy (ret, value, value_len);
+ ret[value_len] = '\0';
+ free (out);
+ return ret;
+ }
+ } else {
+ /* Ignore lines with no colon. Log to stderr so it will show up in
+ * LIBGUESTFS_DEBUG. */
+ fprintf (stderr, "get-gpt-type: unexpected sgdisk output ignored: %s",
+ line);
+ }
+ }
+ free (out);
+
+ /* If we got here it means we didn't find the Partition GUID code */
+ reply_with_error ("sgdisk output did not contain Partition GUID code. "
+ "See LIBGUESTFS_DEBUG output for more details");
+ return NULL;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index f78d851..d8ec323 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -10692,6 +10692,36 @@ not always, the name of a Windows drive, eg. C<E:>." };
Return the list of partitions in the volume named C<volume> in the disk
group with GUID <diskgroup>." };
+ { defaults with
+ name = "part_set_gpt_type";
+ style = RErr, [Device "device"; Int "partnum"; String "guid"], [];
+ proc_nr = Some 392;
+ tests = [];
+ shortdesc = "set the type GUID of a GPT partition";
+ longdesc = "\
+Set the type GUID of numbered GPT partition C<partnum> to C<guid>. Return an
+error if the partition table of C<device> isn't GPT, or if C<guid> is not a
+valid GUID.
+
+See L<http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs>
+for a useful list of type GUIDs." };
+
+ { defaults with
+ name = "part_get_gpt_type";
+ style = RString "guid", [Device "device"; Int "partnum"], [];
+ proc_nr = Some 393;
+ tests = [
+ InitGPT, Always, TestOutput (
+ [["part_set_gpt_type"; "/dev/sda"; "1";
+ "01234567-89AB-CDEF-0123-456789ABCDEF"];
+ ["part_get_gpt_type"; "/dev/sda"; "1"]],
+ "01234567-89AB-CDEF-0123-456789ABCDEF");
+ ];
+ shortdesc = "get the type GUID of a GPT partition";
+ longdesc = "\
+Return the type GUID of numbered GPT partition C<partnum>. Return an error if
+the partition table of C<device> isn't GPT." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
index 116a8b0..2aa78df 100644
--- a/generator/tests_c_api.ml
+++ b/generator/tests_c_api.ml
@@ -442,6 +442,13 @@ and generate_one_test_body name i test_name init test =
["umount_all"];
["lvm_remove_all"];
["part_disk"; "/dev/sda"; "mbr"]]
+ | InitGPT ->
+ pr " /* InitGPT for %s: create /dev/sda1 */\n" test_name;
+ List.iter (generate_test_command_call test_name)
+ [["blockdev_setrw"; "/dev/sda"];
+ ["umount_all"];
+ ["lvm_remove_all"];
+ ["part_disk"; "/dev/sda"; "gpt"]]
| InitBasicFS ->
pr " /* InitBasicFS for %s: create ext2 on /dev/sda1 */\n" test_name;
List.iter (generate_test_command_call test_name)
diff --git a/generator/types.ml b/generator/types.ml
index cff3c6d..a2e3307 100644
--- a/generator/types.ml
+++ b/generator/types.ml
@@ -332,6 +332,11 @@ and test_init =
* Note: for testing filesystem operations, it is quicker to use
* InitScratchFS
*)
+ | InitGPT
+
+ (* Identical to InitPartition, except that the partition table is GPT
+ * instead of MBR.
+ *)
| InitBasicFS
(* /dev/sda:
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index b570ddb..25685cf 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-391
+393
--
1.7.11.7
11 years, 10 months
[PATCH] daemon: Add sentinel attribute to commandf and commandrf
by Matthew Booth
Causes a compiler warning to be emitted if you omit the trailing NULL argument.
---
daemon/daemon.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 8f932d2..df1ba3a 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -100,9 +100,9 @@ extern char **split_lines (char *str);
#define COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN 2048
extern int commandf (char **stdoutput, char **stderror, int flags,
- const char *name, ...);
+ const char *name, ...) __attribute__((sentinel));
extern int commandrf (char **stdoutput, char **stderror, int flags,
- const char *name, ...);
+ const char *name, ...) __attribute__((sentinel));
extern int commandvf (char **stdoutput, char **stderror, int flags,
char const *const *argv);
extern int commandrvf (char **stdoutput, char **stderror, int flags,
--
1.7.11.7
11 years, 10 months
Lua improvements
by Hilko Bengen
Here are a few patches I applied to get the Lua bindings to build
correctly with different versions of Lua.
I am not particularly happy with generating all the test scripts just
for the shebang line. Since it has been a while since I had to edit
autoconf/automake, this was the best I could come up with.
Cheers,
-Hilko
11 years, 10 months