[virt-tools-list] Statically compiling virt-rescue ?

Richard W.M. Jones rjones at redhat.com
Fri Mar 27 22:58:59 UTC 2015


[Sorry - I didn't see this email until now as virt-rescue is part of
the http://libguestfs.org project and so normally uses a different
mailing list]

On Tue, Mar 17, 2015 at 11:29:29AM +0000, Keith Roberts wrote:
> Hi all.
>
> I’d like to create a statically-linked version of virt-rescue that I
> can compile on my laptop then deploy that binary locally onto a xen
> server hosting VM’s to run virt-rescue on the VM images from there
> locally.

Note that as well as the rather large list of shared libraries,
virt-rescue has a few other dependencies:

 - a non-Xen kernel
 - supermin
 - qemu (even required when the hypervisor is Xen)

[...]

> Is it possible to statically compile virt-rescue with all the above
> required libraries built into the executable, along the lines of the
> mysql statically-linked binary?

I made a pretty valiant attempt to build a static libguestfs +
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]=c0151b6bc99684e970ebad993c4985ee90afb319, not stripped
  $ ll rescue/virt-rescue
  -rwxrwxr-x. 1 rjones rjones 8009264 Mar 27 22:50 rescue/virt-rescue

Unfortunately it fundamentally doesn't work, because none of the
`__attribute__((constructor))'s in the code are ever called[1].  This
means, for example, that no backends get registered with the main
code.

This is a bug, but not one that anyone has noticed until now.

Rich.

[1] https://stackoverflow.com/questions/1202494/why-doesnt-attribute-constructor-work-in-a-static-library

-- 
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




More information about the virt-tools-list mailing list