golang binding help
by Vasiliy Tolstov
Hello. I'm very happy with libguestfs, but now i'm try to write packer
plugin to strip images:
1) resize filesystem to minimum
2) resize partitions to minimum
3) create/resize file with needed size
But golang binding have not docs. Is that possible to generate
something suitable to godoc.org to determine api methods and
input,output variables for functions?
--
Vasiliy Tolstov,
e-mail: v.tolstov(a)selfip.ru
jabber: vase(a)selfip.ru
10 years, 4 months
File not found by ext2_lookup
by Gleb Voronich
Hello,
I've been trying to clone one disk image (LVM) to another using virt-resize.
Unfortunately I get the following error:
# virt-resize /dev/vm/vm6 /dev/vm/vm7
supermin helper [00004ms] finished creating kernel
supermin helper [00251ms] finished mke2fs
<domain type='kvm'>
supermin helper [00252ms] visiting /usr/lib64/guestfs/supermin.d
supermin helper [00252ms] visiting /usr/lib64/guestfs/supermin.d/base.img.gz
supermin helper [03505ms] visiting
/usr/lib64/guestfs/supermin.d/daemon.img.gz
supermin helper [03527ms] visiting /usr/lib64/guestfs/supermin.d/hostfiles
libguestfs: trace: launch = -1 (error)
Fatal error: exception Guestfs.Error("supermin-helper exited with error
status 1, see debug messages above")
libguestfs: trace: close
Is there any known issue that could cause this?
I have CentOS 7.0.1406 at the host node at CentOS 6.5 at the guest.
Thanks.
10 years, 4 months
[PATCH] sparsify: Add --tmp prebuilt:file option.
by Richard W.M. Jones
This option allows oVirt to pass a prebuilt qcow2 file to use as the
temporary overlay. The file must be qcow2, and must have indisk as a
backing file - the code does minimal checks to ensure this is correct.
Example usage:
qemu-img create -f qcow2 -b indisk overlay.qcow2
virt-sparsify indisk --tmp prebuilt:overlay.qcow2 outdisk
Note this only applies in copying mode.
---
sparsify/cmdline.ml | 2 +-
sparsify/copying.ml | 54 ++++++++++++++++++++++++++++++++--------------
sparsify/virt-sparsify.pod | 27 +++++++++++++++++++++++
3 files changed, 66 insertions(+), 17 deletions(-)
diff --git a/sparsify/cmdline.ml b/sparsify/cmdline.ml
index 11e5895..a99c851 100644
--- a/sparsify/cmdline.ml
+++ b/sparsify/cmdline.ml
@@ -80,7 +80,7 @@ let parse_cmdline () =
"-o", Arg.Set_string option, s_"option" ^ " " ^ s_"Add qemu-img options";
"-q", Arg.Set quiet, " " ^ s_"Quiet output";
"--quiet", Arg.Set quiet, ditto;
- "--tmp", Arg.Set_string tmp, s_"block|dir" ^ " " ^ s_"Set temporary block device or directory";
+ "--tmp", Arg.Set_string tmp, s_"block|dir|prebuilt:file" ^ " " ^ s_"Set temporary block device, directory or prebuilt file";
"-v", Arg.Set verbose, " " ^ s_"Enable debugging messages";
"--verbose", Arg.Set verbose, ditto;
"-V", Arg.Unit display_version, " " ^ s_"Display version and exit";
diff --git a/sparsify/copying.ml b/sparsify/copying.ml
index 5afb22f..b167b0c 100644
--- a/sparsify/copying.ml
+++ b/sparsify/copying.ml
@@ -33,7 +33,8 @@ open Cmdline
external statvfs_free_space : string -> int64 =
"virt_sparsify_statvfs_free_space"
-type tmp_place = Directory of string | Block_device of string
+type tmp_place =
+| Directory of string | Block_device of string | Prebuilt_file of string
let run indisk outdisk check_tmpdir compress convert
format ignores machine_readable option tmp_param
@@ -74,12 +75,26 @@ let run indisk outdisk check_tmpdir compress convert
| None -> Directory Filename.temp_dir_name (* $TMPDIR or /tmp *)
| Some dir when is_directory dir -> Directory dir
| Some dev when is_block_device dev -> Block_device dev
+ | Some file when string_prefix file "prebuilt:" ->
+ let file = String.sub file 9 (String.length file - 9) in
+ if not (Sys.file_exists file) then
+ error (f_"--tmp prebuilt:file: %s: file does not exist") file;
+ let g = new G.guestfs () in
+ if trace then g#set_trace true;
+ if verbose then g#set_verbose true;
+ if g#disk_format file <> "qcow2" then
+ error (f_"--tmp prebuilt:file: %s: file format is not qcow2") file;
+ if not (g#disk_has_backing_file file) then
+ error (f_"--tmp prebuilt:file: %s: file does not have backing file")
+ file;
+ Prebuilt_file file
| Some path ->
- error (f_"--tmp parameter must point to a directory or a block device") in
+ error (f_"--tmp parameter must point to a directory, block device or prebuilt file") in
(* Check there is enough space in temporary directory. *)
(match tmp_place with
- | Block_device _ -> ()
+ | Block_device _
+ | Prebuilt_file _ -> ()
| Directory tmpdir ->
(* Get virtual size of the input disk. *)
let virtual_size = (new G.guestfs ())#disk_virtual_size indisk in
@@ -136,31 +151,38 @@ You can ignore this warning or change it to a hard failure using the
| Block_device device ->
printf (f_"Create overlay device %s to protect source disk ...\n%!")
device
+ | Prebuilt_file file ->
+ printf (f_"Using prebuilt file %s as overlay ...\n%!") file
);
- let tmp =
- match tmp_place with
- | Directory temp_dir ->
- let tmp = Filename.temp_file ~temp_dir "sparsify" ".qcow2" in
- unlink_on_exit tmp;
- tmp
-
- | Block_device device -> device in
-
- (* Create it with the indisk as the backing file. *)
+ (* Create 'tmp' with the indisk as the backing file. *)
(* XXX Old code used to:
* - detect if compat=1.1 was supported
* - add lazy_refcounts option
*)
- let () =
+ let create tmp =
let g = new G.guestfs () in
if trace then g#set_trace true;
if verbose then g#set_verbose true;
g#disk_create
~backingfile:indisk ?backingformat:format ~compat:"1.1"
- tmp "qcow2" Int64.minus_one in
+ tmp "qcow2" Int64.minus_one
+ in
- tmp in
+ match tmp_place with
+ | Directory temp_dir ->
+ let tmp = Filename.temp_file ~temp_dir "sparsify" ".qcow2" in
+ unlink_on_exit tmp;
+ create tmp;
+ tmp
+
+ | Block_device device ->
+ create device;
+ device
+
+ | Prebuilt_file file ->
+ (* Don't create anything, use the prebuilt file as overlay. *)
+ file in
if not quiet then
printf (f_"Examine source disk ...\n%!");
diff --git a/sparsify/virt-sparsify.pod b/sparsify/virt-sparsify.pod
index bb7dbae..3b6cebd 100644
--- a/sparsify/virt-sparsify.pod
+++ b/sparsify/virt-sparsify.pod
@@ -262,6 +262,33 @@ L</TMPDIR> environment variable.
You cannot use this option and I<--in-place> together.
+=item B<--tmp> prebuilt:file
+
+In copying mode only, the specialized option I<--tmp prebuilt:file>
+(where C<prebuilt:> is a literal string) causes virt-sparsify to use
+the qcow2 C<file> as temporary space.
+
+=over 4
+
+=item *
+
+The file B<must> be freshly formatted as qcow2, with indisk as the
+backing file.
+
+=item *
+
+If you rerun virt-sparsify, you B<must> recreate the file before
+each run.
+
+=item *
+
+Virt-sparsify does not delete the file.
+
+=back
+
+This option is used by oVirt which requires a specially formatted
+temporary file.
+
=item B<-v>
=item B<--verbose>
--
1.9.0
10 years, 4 months
Libguestfs in CentOS 7.0
by Richard W.M. Jones
Libguestfs in CentOS 7.0 is broken at the moment.
You will see this error:
supermin-helper: ext2: parent directory not found: centos-release: File not found by ext2_lookup
At the moment I'm not sure why this happens. The tests ran
successfully when libguestfs was built (according to the build logs
now published at buildlogs.centos.org).
There are two ways to fix this:
(1) [Recommended] Use the RHEL 7.1 preview packages:
https://www.redhat.com/archives/libguestfs/2014-May/msg00090.html
These preview packages are:
- easy to install
- use supermin 5 which is far more robust
- have a much more featureful version of libguestfs
- are similar to the libguestfs packages we will ship in RHEL 7.1
I have verified that the preview packages work fine on CentOS 7.0.
(2) Alternately, edit /usr/lib64/guestfs/supermin.d/hostfiles and
remove all the lines that contain the substring `redhat-release'.
Thanks: Rob Oakes for reporting the problem and suggesting the second fix.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
10 years, 4 months
Attention packagers: libguestfs 1.27.21: firstboot support and Windows
by Richard W.M. Jones
Starting in libguestfs 1.27.21, we're able to install firstboot
scripts into Windows guests. Initially this is just for virt-v2v, but
I will extend the feature to virt-sysprep/virt-customize.
How this may affect Debian and other downstream packagers is as follows:
In order to do this we have to install a program called 'rhsrvany.exe'.
If this program is found in /usr/share/virt-tools/rhsrvany.exe then it
is copied into the Windows guest and the registry of the guest is
modified so that rhsrvany will run once at next boot. rhsrvany then
chain-runs the actual firstboot script (usually a .bat file).
rhsrvany is a Windows program that was written by Red Hat, comes with
source, and is under a GPLv2+ license. However it does require the 32 bit
mingw-w64 [sic] toolchain to build.
The source is here:
https://github.com/rwmjones/rhsrvany
This is how we build it in Fedora (look at the .spec file):
http://pkgs.fedoraproject.org/cgit/mingw-srvany.git/tree/
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
10 years, 4 months
[PATCH] mllib: introduce Mkdtemp.temp_dir
by Pino Toscano
Add a simple function to ease the usage of Mkdtemp.mkdtemp.
---
mllib/mkdtemp.ml | 5 +++++
mllib/mkdtemp.mli | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/mllib/mkdtemp.ml b/mllib/mkdtemp.ml
index 2e64862..353b04b 100644
--- a/mllib/mkdtemp.ml
+++ b/mllib/mkdtemp.ml
@@ -16,4 +16,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*)
+open Common_utils
+
external mkdtemp : string -> string = "virt_builder_mkdtemp"
+
+let temp_dir ?(base_dir = Filename.temp_dir_name) prefix suffix =
+ mkdtemp (base_dir // (prefix ^ "XXXXXX" ^ suffix))
diff --git a/mllib/mkdtemp.mli b/mllib/mkdtemp.mli
index 674e6f2..9abb10c 100644
--- a/mllib/mkdtemp.mli
+++ b/mllib/mkdtemp.mli
@@ -18,3 +18,10 @@
val mkdtemp : string -> string
(** [mkdtemp pattern] Tiny wrapper to the C [mkdtemp]. *)
+
+val temp_dir : ?base_dir:string -> string -> string -> string
+(** [temp_dir prefix suffix] creates a new unique temporary directory.
+
+ The optional [~base_dir:string] changes the base directory where
+ to create the new temporary directory; if not specified, the default
+ [Filename.temp_dir_name] is used. *)
--
1.9.3
10 years, 4 months
[PATCH] inspect: ignore /etc/fstab with no entries (RHBZ#1113156).
by Pino Toscano
Just like no /etc/fstab is not an error, having one with no entries
shouldn't be an issue either.
With systemd, this could be a valid setup, with mount points set its own
way.
---
src/inspect-fs-unix.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index 739a431..89236ab 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -960,11 +960,6 @@ check_fstab (guestfs_h *g, struct inspect_fs *fs)
if (entries == NULL)
return -1;
- if (entries[0] == NULL) {
- error (g, _("could not parse /etc/fstab or empty file"));
- return -1;
- }
-
for (entry = entries; *entry != NULL; entry++) {
CLEANUP_FREE char *spec = NULL;
CLEANUP_FREE char *mp = NULL;
--
1.9.3
10 years, 4 months
回复: Re: cannot connect to channel device
by fangtuo90
No SELinux or AppArmor is used. qemu.conf shows it's running by root user. I did "virsh start" operation under root and the error remains. Should I change the permission attributes of files under /var/lib/libvirt/qemu ?
BTW, could you please tell me the libvirt mailing list address? Thanks.
从三星移动设备发送
-------- 原始邮件 --------
发件人: "Richard W.M. Jones" <rjones(a)redhat.com>
日期: 2014-07-07 16:16 (GMT+08:00)
收件人: fangtuo90 <fangtuo90(a)gmail.com>
抄送: libguestfs(a)redhat.com
主题: Re: [Libguestfs] cannot connect to channel device
On Mon, Jul 07, 2014 at 09:23:05AM +0800, fangtuo90 wrote:
> Here is what I got.
> root@ubuntu:/home/john# virsh start ubuntu2
> error: Failed to start domain ubuntu2
> error: internal error Process exited while reading console log output: char device redirected to /dev/pts/1
> bind(unix:/var/lib/libvirt/qemu/ubuntu2.libguestfs): Permission denied
> chardev: opening backend "socket" failed: Permission denied
>
> root@ubuntu:/home/john# ll /var/lib/libvirt/qemu/
> total 20
> drwxr-x--- 5 libvirt-qemu kvm 4096 Jul 5 14:44 ./
> drwxr-xr-x 8 root root 4096 May 20 04:18 ../
> drwxr-xr-x 2 libvirt-qemu kvm 4096 May 20 04:18 dump/
> drwxr-xr-x 2 libvirt-qemu kvm 4096 May 20 04:18 save/
> drwxr-xr-x 2 libvirt-qemu kvm 4096 May 20 04:18 snapshot/
I'm guessing this is some kind of permissions or SELinux labelling
problem, but I don't know specifically what the problem is.
Have a look at the libvirt configuration file /etc/libvirt/qemu.conf
to see what user qemu runs as. Also if using SELinux or AppArmor then
look for alerts there.
You might be better off asking on the libvirt-users mailing list.
Rich.
> root@ubuntu:/home/john# cat /etc/libvirt/qemu/ubuntu2.xml
> <!--
> WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
> OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
> virsh edit ubuntu2
> or other application using the libvirt API.
> -->
>
> <domain type='kvm' xmlns:qemu='/schemas/domain/qemu/1.0'>
> <qemu:commandline>
> <qemu:arg value='-s'/>
> </qemu:commandline>
> <name>ubuntu2</name>
> <uuid>03f4c36d-9509-05dd-167d-d2613d1dd883</uuid>
> <memory>1024000</memory>
> <currentMemory>1024000</currentMemory>
> <vcpu>1</vcpu>
> <os>
> <type arch='x86_64' machine='pc-1.0'>hvm</type>
> <boot dev='hd'/>
> </os>
> <features>
> <acpi/>
> <apic/>
> <pae/>
> </features>
> <clock offset='utc'/>
> <on_poweroff>destroy</on_poweroff>
> <on_reboot>restart</on_reboot>
> <on_crash>restart</on_crash>
> <devices>
> <emulator>/usr/bin/kvm</emulator>
> <disk type='file' device='disk'>
> <driver name='qemu' type='qcow2'/>
> <source file='/home/john/ubuntu-1204-vm.img'/>
> <target dev='hda' bus='ide'/>
> <address type='drive' controller='0' bus='0' unit='0'/>
> </disk>
> <controller type='ide' index='0'>
> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
> </controller>
> <interface type='bridge'>
> <mac address='52:54:00:d4:7d:07'/>
> <source bridge='br0'/>
> <model type='virtio'/>
> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
> </interface>
> <serial type='pty'>
> <target port='0'/>
> </serial>
> <console type='pty'>
> <target type='serial' port='0'/>
> </console>
> <input type='mouse' bus='ps2'/>
> <graphics type='vnc' port='-1' autoport='yes'/>
> <sound model='ich6'>
> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
> </sound>
> <video>
> <model type='cirrus' vram='9216' heads='1'/>
> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
> </video>
> <memballoon model='virtio'>
> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
> </memballoon>
> <channel type='unix'>
> <source mode='bind' path='/var/lib/libvirt/qemu/ubuntu2.libguestfs' />
> <target type='virtio' name='org.libguestfs.channel.0' />
> </channel>
> </devices>
> </domain>
>
> When I deleted the <channel>...</channel> part, it will start normally. But I need it to use guestfish with --live option.
> _______________________________________________
> Libguestfs mailing list
> Libguestfs(a)redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
10 years, 4 months
cannot connect to channel device
by fangtuo90
Here is what I got.
root@ubuntu:/home/john# virsh start ubuntu2
error: Failed to start domain ubuntu2
error: internal error Process exited while reading console log output: char device redirected to /dev/pts/1
bind(unix:/var/lib/libvirt/qemu/ubuntu2.libguestfs): Permission denied
chardev: opening backend "socket" failed: Permission denied
root@ubuntu:/home/john# ll /var/lib/libvirt/qemu/
total 20
drwxr-x--- 5 libvirt-qemu kvm 4096 Jul 5 14:44 ./
drwxr-xr-x 8 root root 4096 May 20 04:18 ../
drwxr-xr-x 2 libvirt-qemu kvm 4096 May 20 04:18 dump/
drwxr-xr-x 2 libvirt-qemu kvm 4096 May 20 04:18 save/
drwxr-xr-x 2 libvirt-qemu kvm 4096 May 20 04:18 snapshot/
root@ubuntu:/home/john# cat /etc/libvirt/qemu/ubuntu2.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit ubuntu2
or other application using the libvirt API.
-->
<domain type='kvm' xmlns:qemu='/schemas/domain/qemu/1.0'>
<qemu:commandline>
<qemu:arg value='-s'/>
</qemu:commandline>
<name>ubuntu2</name>
<uuid>03f4c36d-9509-05dd-167d-d2613d1dd883</uuid>
<memory>1024000</memory>
<currentMemory>1024000</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64' machine='pc-1.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/john/ubuntu-1204-vm.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:d4:7d:07'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/ubuntu2.libguestfs' />
<target type='virtio' name='org.libguestfs.channel.0' />
</channel>
</devices>
</domain>
When I deleted the <channel>...</channel> part, it will start normally. But I need it to use guestfish with --live option.
10 years, 4 months
Adventures in building libguestfs on non-x86 architectures for Debian
by Hilko Bengen
Hi,
things are progressing slowly, but I feel that eventually I'll be
getting there: supermin can be built on all Linux-based architectures
that are part of Debian/unstable[1] -- (except for sparc, but I'll
ignore that for now.) libguestfs on the other hand currently fails
launching the appliance (necessary for running tests) on everything but
x86 and mips.
Apparently, qemu-system-arm 2.0 as currently available through
Debian/unstable doesn't want to tell us anything about available devices
unless we specify a machine type. The patch below works around that
issue, but I haven't been able to run qemu-system-arm with a supermin
appliance on Debian's armhf porterbox so far: 100% CPU usage, no output
from the kernel.
For armel, there's no kernel with device tree blobs, so I think that I'll
need to use linux-image-versatile there or ignore armel altogether.
powerpc: qemu-system-ppc does not know about the "pseries" machine, I
have figured out that I need to use qemu-system-ppc64 for that. So far,
I haven't been able to manually boot a Supermin appliance using
qemu-system-ppc, either, though.
s390x does not seem to know about virtio-blk-pci.
Cheers,
-Hilko
[1] https://buildd.debian.org/status/package.php?p=supermin
[2] https://buildd.debian.org/status/package.php?p=libguestfs
diff --git a/src/launch-direct.c b/src/launch-direct.c
index 1460c56..2332368 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -1020,6 +1020,10 @@ test_qemu (guestfs_h *g, struct backend_direct_data *data)
guestfs___cmd_add_arg (cmd3, g->hv);
guestfs___cmd_add_arg (cmd3, "-display");
guestfs___cmd_add_arg (cmd3, "none");
+#ifdef MACHINE_TYPE
+ guestfs___cmd_add_arg (cmd3, "-M");
+ guestfs___cmd_add_arg (cmd3, MACHINE_TYPE);
+#endif
guestfs___cmd_add_arg (cmd3, "-machine");
guestfs___cmd_add_arg (cmd3, "accel=kvm:tcg");
guestfs___cmd_add_arg (cmd3, "-device");
10 years, 4 months