Baochuan Wu
2016-Apr-07 14:12 UTC
[Libguestfs] Help: Is it possible to use libguestfs in Xen guest OS
Hi All,
I installed CentOS 7 as Xen Guest OS(DomU OS), I wonder if it is possible
to use libguestfs in this CentOS 7 VM? libguestfs-test-tools reports error:
*-bash-4.2# libguestfs-test-tool *
************************************************************
* IMPORTANT NOTICE
*
* When reporting bugs, include the COMPLETE, UNEDITED
* output below in your bug report.
*
************************************************************
LIBGUESTFS_BACKEND=libvirt
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/opt/vpxxcm/conversion
SELinux: sh: getenforce: command not found
guestfs_get_append: (null)
guestfs_get_autosync: 1
guestfs_get_backend: libvirt
guestfs_get_backend_settings: []
guestfs_get_cachedir: /var/tmp
guestfs_get_direct: 0
guestfs_get_hv: /usr/libexec/qemu-kvm
guestfs_get_memsize: 500
guestfs_get_network: 0
guestfs_get_path: /usr/lib64/guestfs
guestfs_get_pgroup: 0
guestfs_get_program: libguestfs-test-tool
guestfs_get_recovery_proc: 1
guestfs_get_selinux: 0
guestfs_get_smp: 1
guestfs_get_tmpdir: /tmp
guestfs_get_trace: 0
guestfs_get_verbose: 1
host_cpu: x86_64
Launching appliance, timeout set to 600 seconds.
libguestfs: launch: program=libguestfs-test-tool
libguestfs: launch: version=1.28.1rhel=7,release=1.55.el7.centos.2,libvirt
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: libvirt
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=libvirt
libguestfs: launch: tmpdir=/tmp/libguestfsqw6Xky
libguestfs: launch: umask=0022
libguestfs: launch: euid=0
libguestfs: libvirt version = 1002017 (1.2.17)
libguestfs: guest random name = guestfs-eln5avlfeu8xgpd8
libguestfs: [00000ms] connect to libvirt
libguestfs: opening libvirt handle: URI = qemu:///system, auth default+wrapper,
flags = 0
libguestfs: successfully opened libvirt handle: conn = 0x7f08e0053d80
libguestfs: qemu version (reported by libvirt) = 1005003 (1.5.3)
libguestfs: [00001ms] get libvirt capabilities
libguestfs: [00002ms] parsing capabilities XML
libguestfs: [00003ms] build appliance
libguestfs: [00003ms] begin building supermin appliance
libguestfs: [00003ms] run supermin
libguestfs: command: run: /usr/bin/supermin5
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-0/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu x86_64
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-0/appliance.d
supermin: version: 5.1.10
supermin: rpm: detected RPM version 4.11
supermin: package handler: fedora/rpm
supermin: acquiring lock on /var/tmp/.guestfs-0/lock
supermin: if-newer: output does not need rebuilding
libguestfs: [00011ms] finished building supermin appliance
libguestfs: command: run: qemu-img
libguestfs: command: run: \ create
libguestfs: command: run: \ -f qcow2
libguestfs: command: run: \ -o
backing_file=/var/tmp/.guestfs-0/appliance.d/root,backing_fmt=raw
libguestfs: command: run: \ /tmp/libguestfsqw6Xky/overlay2
Formatting '/tmp/libguestfsqw6Xky/overlay2', fmt=qcow2 size=4294967296
backing_file='/var/tmp/.guestfs-0/appliance.d/root'
backing_fmt='raw'
encryption=off cluster_size=65536 lazy_refcounts=off
libguestfs: set_socket_create_context: context_new failed: kernel: Invalid
argument [you can ignore this UNLESS using SELinux + sVirt]
libguestfs: [00031ms] create libvirt XML
libguestfs: command: run: dmesg | grep -Eoh 'lpj=[[:digit:]]+'
libguestfs: read_lpj_from_dmesg: calculated lpj=2200086
libguestfs: libvirt XML:\n<?xml version="1.0"?>\n<domain
type="qemu"
xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">\n
<name>guestfs-eln5avlfeu8xgpd8</name>\n <memory
unit="MiB">500</memory>\n
<currentMemory unit="MiB">500</currentMemory>\n
<vcpu>1</vcpu>\n <clock
offset="utc">\n <timer name="rtc"
tickpolicy="catchup"/>\n <timer
name="pit" tickpolicy="delay"/>\n <timer
name="hpet" present="no"/>\n
</clock>\n <os>\n <type>hvm</type>\n
<kernel>/var/tmp/.guestfs-0/appliance.d/kernel</kernel>\n
<initrd>/var/tmp/.guestfs-0/appliance.d/initrd</initrd>\n
<cmdline>panic=1 console=ttyS0 udevtimeout=6000 udev.event-timeout=6000
no_timer_check lpj=2200086 acpi=off printk.time=1 cgroup_disable=memory
root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm</cmdline>\n
<bios
useserial="yes"/>\n </os>\n
<on_reboot>destroy</on_reboot>\n <devices>\n
<controller type="scsi" index="0"
model="virtio-scsi"/>\n <disk
device="disk" type="file">\n <source
file="/tmp/libguestfsqw6Xky/scratch.1"/>\n <target
dev="sda"
bus="scsi"/>\n <driver name="qemu"
type="raw" cache="unsafe"/>\n
<address type="drive" controller="0" bus="0"
target="0" unit="0"/>\n
</disk>\n <disk type="file" device="disk">\n
<source
file="/tmp/libguestfsqw6Xky/overlay2"/>\n <target
dev="sdb"
bus="scsi"/>\n <driver name="qemu"
type="qcow2" cache="unsafe"/>\n
<address type="drive" controller="0" bus="0"
target="1" unit="0"/>\n
<shareable/>\n </disk>\n <serial
type="unix">\n <source
mode="connect"
path="/tmp/libguestfsqw6Xky/console.sock"/>\n <target
port="0"/>\n </serial>\n <channel
type="unix">\n <source
mode="connect"
path="/tmp/libguestfsqw6Xky/guestfsd.sock"/>\n <target
type="virtio" name="org.libguestfs.channel.0"/>\n
</channel>\n
</devices>\n <qemu:commandline>\n <qemu:env
name="TMPDIR"
value="/var/tmp"/>\n </qemu:commandline>\n</domain>\n
libguestfs: command: run: ls
libguestfs: command: run: \ -a
libguestfs: command: run: \ -l
libguestfs: command: run: \ -Z /var/tmp/.guestfs-0
libguestfs: drwxr-xr-x root root ? .
libguestfs: drwxrwxrwt root root ? ..
libguestfs: drwxr-xr-x root root ?
appliance.d
libguestfs: -rw-r--r-- root root ? lock
libguestfs: command: run: ls
libguestfs: command: run: \ -a
libguestfs: command: run: \ -l
libguestfs: command: run: \ -Z /tmp/libguestfsqw6Xky
libguestfs: drwxr-xr-x root root ? .
libguestfs: drwxrwxrwt root root ? ..
libguestfs: srw-rw---- root qemu ?
console.sock
libguestfs: srw-rw---- root qemu ?
guestfsd.sock
libguestfs: -rw-r--r-- root root ? overlay2
libguestfs: -rw-r--r-- root root ? scratch.1
libguestfs: -rwxr-xr-x root root ?
umask-check
libguestfs: [00041ms] launch libvirt guest
libguestfs: error: could not create appliance through libvirt.
Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct
Original error from libvirt: internal error: process exited while
connecting to monitor: Cannot set up guest memory 'pc.ram': Cannot
allocate
memory
[code=1 domain=10]
libguestfs-test-tool: failed to launch appliance
libguestfs: closing guestfs handle 0x7f08e0053620 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfsqw6Xky
*-bash-4.2# export LIBGUESTFS_BACKEND=direct*
*-bash-4.2# libguestfs-test-tool *
************************************************************
* IMPORTANT NOTICE
*
* When reporting bugs, include the COMPLETE, UNEDITED
* output below in your bug report.
*
************************************************************
LIBGUESTFS_BACKEND=direct
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/opt/vpxxcm/conversion
SELinux: sh: getenforce: command not found
guestfs_get_append: (null)
guestfs_get_autosync: 1
guestfs_get_backend: direct
guestfs_get_backend_settings: []
guestfs_get_cachedir: /var/tmp
guestfs_get_direct: 0
guestfs_get_hv: /usr/libexec/qemu-kvm
guestfs_get_memsize: 500
guestfs_get_network: 0
guestfs_get_path: /usr/lib64/guestfs
guestfs_get_pgroup: 0
guestfs_get_program: libguestfs-test-tool
guestfs_get_recovery_proc: 1
guestfs_get_selinux: 0
guestfs_get_smp: 1
guestfs_get_tmpdir: /tmp
guestfs_get_trace: 0
guestfs_get_verbose: 1
host_cpu: x86_64
Launching appliance, timeout set to 600 seconds.
libguestfs: launch: program=libguestfs-test-tool
libguestfs: launch: version=1.28.1rhel=7,release=1.55.el7.centos.2,libvirt
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: libvirt
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=direct
libguestfs: launch: tmpdir=/tmp/libguestfsvt8tnf
libguestfs: launch: umask=0022
libguestfs: launch: euid=0
libguestfs: is_openable: /dev/kvm: No such file or directory
libguestfs: [00000ms] begin building supermin appliance
libguestfs: [00000ms] run supermin
libguestfs: command: run: /usr/bin/supermin5
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-0/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu x86_64
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-0/appliance.d
supermin: version: 5.1.10
supermin: rpm: detected RPM version 4.11
supermin: package handler: fedora/rpm
supermin: acquiring lock on /var/tmp/.guestfs-0/lock
supermin: if-newer: output does not need rebuilding
libguestfs: [00013ms] finished building supermin appliance
libguestfs: [00013ms] begin testing qemu features
libguestfs: command: run: /usr/libexec/qemu-kvm
libguestfs: command: run: \ -display none
libguestfs: command: run: \ -help
libguestfs: command: run: /usr/libexec/qemu-kvm
libguestfs: command: run: \ -display none
libguestfs: command: run: \ -version
libguestfs: qemu version 1.5
libguestfs: command: run: /usr/libexec/qemu-kvm
libguestfs: command: run: \ -display none
libguestfs: command: run: \ -machine accel=kvm:tcg
libguestfs: command: run: \ -device ?
libguestfs: [00099ms] finished testing qemu features
libguestfs: command: run: dmesg | grep -Eoh 'lpj=[[:digit:]]+'
libguestfs: read_lpj_from_dmesg: calculated lpj=2200086
[00107ms] /usr/libexec/qemu-kvm \
-global virtio-blk-pci.scsi=off \
-nodefconfig \
-enable-fips \
-nodefaults \
-display none \
-machine accel=kvm:tcg \
-m 500 \
-no-reboot \
-rtc driftfix=slew \
-no-hpet \
-global kvm-pit.lost_tick_policy=discard \
-kernel /var/tmp/.guestfs-0/appliance.d/kernel \
-initrd /var/tmp/.guestfs-0/appliance.d/initrd \
-device virtio-scsi-pci,id=scsi \
-drive
file=/tmp/libguestfsvt8tnf/scratch.1,cache=unsafe,format=raw,id=hd0,if=none
\
-device scsi-hd,drive=hd0 \
-drive
file=/var/tmp/.guestfs-0/appliance.d/root,snapshot=on,id=appliance,cache=unsafe,if=none
\
-device scsi-hd,drive=appliance \
-device virtio-serial-pci \
-serial stdio \
-device sga \
-chardev socket,path=/tmp/libguestfsvt8tnf/guestfsd.sock,id=channel0 \
-device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
-append 'panic=1 console=ttyS0 udevtimeout=6000 udev.event-timeout=6000
no_timer_check lpj=2200086 acpi=off printk.time=1 cgroup_disable=memory
root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=xterm'
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
Cannot set up guest memory 'pc.ram': Cannot allocate memory
libguestfs: error: appliance closed the connection unexpectedly, see
earlier error messages
libguestfs: child_cleanup: 0x7fd127b2d620: child process died
libguestfs: sending SIGTERM to process 17471
libguestfs: error: /usr/libexec/qemu-kvm exited with error status 1, see
debug messages above
libguestfs: error: guestfs_launch failed, see earlier error messages
libguestfs-test-tool: failed to launch appliance
libguestfs: closing guestfs handle 0x7fd127b2d620 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfsvt8tnf
-bash-4.2#
After running "*export LIBGUESTFS_BACKEND=direct*", it seems
libguestfs
will launch another VM inside my VM. Is this necessary?
Any response is highly appreciated.
Thanks,
Allen
Richard W.M. Jones
2016-Apr-07 21:54 UTC
Re: [Libguestfs] Help: Is it possible to use libguestfs in Xen guest OS
On Thu, Apr 07, 2016 at 10:12:07PM +0800, Baochuan Wu wrote:> Hi All, > > I installed CentOS 7 as Xen Guest OS(DomU OS), I wonder if it is possible > to use libguestfs in this CentOS 7 VM? libguestfs-test-tools reports error:[...]> Original error from libvirt: internal error: process exited while > connecting to monitor: Cannot set up guest memory 'pc.ram': Cannot allocate > memory[...]> Cannot set up guest memory 'pc.ram': Cannot allocate memory > libguestfs: error: appliance closed the connection unexpectedly, see > earlier error messagesIt looks as if you VM has very limited RAM, not enough to start up the qemu instance. If you give your VM more memory, then libguestfs should work fine. We run libguestfs nested all the time.> After running "*export LIBGUESTFS_BACKEND=direct*", it seems libguestfs > will launch another VM inside my VM. Is this necessary?That's how libguestfs works: http://libguestfs.org/guestfs-internals.1.html Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Baochuan Wu
2016-Apr-08 00:14 UTC
Re: [Libguestfs] Help: Is it possible to use libguestfs in Xen guest OS
Thanks Rich. Best Regards, Allen 2016-04-08 5:54 GMT+08:00 Richard W.M. Jones <rjones@redhat.com>:> On Thu, Apr 07, 2016 at 10:12:07PM +0800, Baochuan Wu wrote: > > Hi All, > > > > I installed CentOS 7 as Xen Guest OS(DomU OS), I wonder if it is possible > > to use libguestfs in this CentOS 7 VM? libguestfs-test-tools reports > error: > [...] > > Original error from libvirt: internal error: process exited while > > connecting to monitor: Cannot set up guest memory 'pc.ram': Cannot > allocate > > memory > [...] > > Cannot set up guest memory 'pc.ram': Cannot allocate memory > > libguestfs: error: appliance closed the connection unexpectedly, see > > earlier error messages > > It looks as if you VM has very limited RAM, not enough to start up the > qemu instance. If you give your VM more memory, then libguestfs > should work fine. We run libguestfs nested all the time. > > > After running "*export LIBGUESTFS_BACKEND=direct*", it seems libguestfs > > will launch another VM inside my VM. Is this necessary? > > That's how libguestfs works: > > http://libguestfs.org/guestfs-internals.1.html > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat > http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > virt-df lists disk usage of guests without needing to install any > software inside the virtual machine. Supports Linux and Windows. > http://people.redhat.com/~rjones/virt-df/ >