Baochuan Wu
2016-Jul-12 08:48 UTC
Re: [Libguestfs] Help: Can I access network inside libguestfs?
Thanks Pino for quick response. Actually I use the libguestfs APIs in C++ program. Following your idea, I think I should try guestfs_set_network for this. Please correct me if I have any misunderstanding. Thanks, Allen 2016-07-12 16:38 GMT+08:00 Pino Toscano <ptoscano@redhat.com>:> Hi, > > On Tuesday, 12 July 2016 16:30:17 CEST Baochuan Wu wrote: > > I mounted virtual disks of CentOS 6.4 using libguestfs. After mounting, I > > tried to install some software using yum command. The yum command failed > > because of DNS failure, I think I correctly configured > DNS(/etc/resolv.conf > > in the CentOS virtual disk). > > > > I wonder is it possible to access network inside libguestfs? > > By "mounting", do you mean with guestfish? If so, it has a --network > parameter to enable networking for the guest. Other tools have similar > options to enable and disable the networking, and few of them > (virt-customize, virt-builder, and virt-dib) have networking enabled > by default. > > -- > Pino Toscano
Richard W.M. Jones
2016-Jul-12 10:22 UTC
Re: [Libguestfs] Help: Can I access network inside libguestfs?
On Tue, Jul 12, 2016 at 04:48:06PM +0800, Baochuan Wu wrote:> Thanks Pino for quick response. > Actually I use the libguestfs APIs in C++ program. Following your idea, I > think I should try guestfs_set_network for this.Yes this is correct. Calling: guestfs_set_network (g, 1); should enable the network inside the appliance. For further tips on using yum, have a look at how virt-customize works. In particular you must use "yum -y install ..." to avoid any unwanted interactivity. https://github.com/libguestfs/libguestfs/blob/master/customize/customize_run.ml#L29-L189 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Richard W.M. Jones
2016-Jul-12 10:23 UTC
Re: [Libguestfs] Help: Can I access network inside libguestfs?
On Tue, Jul 12, 2016 at 11:22:24AM +0100, Richard W.M. Jones wrote:> On Tue, Jul 12, 2016 at 04:48:06PM +0800, Baochuan Wu wrote: > > Thanks Pino for quick response. > > Actually I use the libguestfs APIs in C++ program. Following your idea, I > > think I should try guestfs_set_network for this. > > Yes this is correct. Calling: > > guestfs_set_network (g, 1); > > should enable the network inside the appliance.... And I should say you must call this _before_ you call guestfs_launch. Rich.> For further tips on using yum, have a look at how virt-customize > works. In particular you must use "yum -y install ..." to avoid any > unwanted interactivity. > > https://github.com/libguestfs/libguestfs/blob/master/customize/customize_run.ml#L29-L189 > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > virt-p2v converts physical machines to virtual machines. Boot with a > live CD or over the network (PXE) and turn machines into KVM guests. > http://libguestfs.org/virt-v2v > > _______________________________________________ > Libguestfs mailing list > Libguestfs@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-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
Richard W.M. Jones
2016-Jul-13 09:04 UTC
Re: [Libguestfs] Help: Can I access network inside libguestfs?
[Let's keep the replies on the mailing list please] On Wed, Jul 13, 2016 at 11:04:13AM +0800, Baochuan Wu wrote:> Thanks Richard. > I tried guestfs_set_network, and I think I can successfully use yum -y to > install software. It is a little slow.Most of the time is taken running yum and downloading packages ...> My program operates CentOS 6.4 VM virtual disks on CentOS 7, I installed > libguestfs into the CentOS 6.4. After installing, I reboot CentOS 6.4 but I > cannot log into it anymore.You will need to relabel the filesystem after installing packages, see: https://github.com/libguestfs/libguestfs/blob/master/customize/customize_run.ml#L415-L430 Rich. -- 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
Baochuan Wu
2016-Jul-14 02:55 UTC
Re: [Libguestfs] Help: Can I access network inside libguestfs?
Thanks Richard. I followed your guide and it works for me. Thanks, Allen 2016-07-13 17:04 GMT+08:00 Richard W.M. Jones <rjones@redhat.com>:> [Let's keep the replies on the mailing list please] > > On Wed, Jul 13, 2016 at 11:04:13AM +0800, Baochuan Wu wrote: > > Thanks Richard. > > I tried guestfs_set_network, and I think I can successfully use yum -y to > > install software. It is a little slow. > > Most of the time is taken running yum and downloading packages ... > > > My program operates CentOS 6.4 VM virtual disks on CentOS 7, I installed > > libguestfs into the CentOS 6.4. After installing, I reboot CentOS 6.4 > but I > > cannot log into it anymore. > > You will need to relabel the filesystem after installing packages, see: > > > https://github.com/libguestfs/libguestfs/blob/master/customize/customize_run.ml#L415-L430 > > Rich. > > -- > 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 >
Seemingly Similar Threads
- Re: Help: Can I access network inside libguestfs?
- Re: Help: Can I access network inside libguestfs?
- Re: Help: Can I access network inside libguestfs?
- Re: Help: Can I access network inside libguestfs?
- [PATCH v2 4/7] customize: Add module for doing SELinux relabel of filesystem.