[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [virt-tools-list] Statically compiling virt-rescue ?



I've added a few patches upstream to make static linking work, and it
is [surprisingly] possible to get it to work.

You'll have to check out libguestfs from git.  Read the README file
very carefully, and get familiar with building from source.  This is
easier on a recent Fedora machine or VM.

Once you are comfortable building libguestfs from source, configure it
like this:

  ./configure --without-libvirt --enable-static
  make clean
  make

To build a static virt-rescue you'll need to first build or install
the following static libraries:

         *-static in Fedora?
  file          no              self-built
  fuse          no              self-built
  glibc         yes
  libconfig     no              self-built
  pcre          yes
  xz (liblzma)  yes
  yajl          no              self-built
  zlib          yes

and then build a static virt-rescue binary like this:

  make -C rescue clean
  make -C rescue all CFLAGS=-static LDFLAGS=-all-static V=1

$ ll rescue/virt-rescue
-rwxrwxr-x. 1 rjones rjones 8170304 Mar 28 10:27 rescue/virt-rescue
$ file rescue/virt-rescue
rescue/virt-rescue: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=7de92afbc9da27ea97d6312638b4f6f368dfb628, not stripped

Now build a fixed appliance[1]:

  mkdir /tmp/appliance
  ./run libguestfs-make-fixed-appliance /tmp/appliance

Now you have all the bits required for a static virt-rescue.

I'll assume that qemu exists on the Xen server, or you can just
install that from a package, or build a recent qemu from source on the
Xen server.  You'll need a recent qemu, so if the Xen server has some
old qemu then it's not going to work - build qemu from source in that
case.

Copy the virt-rescue binary and the fixed appliance directory to the
Xen server.

Note that the fixed appliance contains a large sparse file ('root'),
and if you don't use the appropriate method to copy it, then you'll
end up making it non-sparse and taking a large amount of space.

Run it like this:

  export LIBGUESTFS_QEMU=/path/to/qemu
  export LIBGUESTFS_PATH=/path/to/appliance
  ./virt-rescue [normal parameters ...]

If it doesn't work, then also set:

  export LIBGUESTFS_DEBUG=1
  export LIBGUESTFS_TRACE=1

Good luck!

Rich.

[1] http://libguestfs.org/libguestfs-make-fixed-appliance.1.html

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]