[virt-tools-list] Scripting virt-install to automate image building

Anthony Shortland anthony.shortland at me.com
Sun Jan 19 22:05:54 UTC 2014


Hi Cole,

Thanks for the suggestions. Here's where I'm at now:

[root at oel63-virt tmp]# virt-install --name=minimal --ram=512 --vcpus=1 --accelerate --hvm --network network:default --disk=/var/lib/libvirt/images/minimal.img,size=3 --location=http://192.168.122.1/OracleLinux-R6-U3-Server-x86_64-dvd --graphics=none --noautoconsole --wait=-1 --serial=file,path=/tmp/minimal.log '--extra-args=ks=http://192.168.122.1/kickstart/minimal-ks.cfg console=ttyS0'

Starting install...
Retrieving file .treeinfo...                                                                                 | 3.0 kB     00:00 ... 
Retrieving file vmlinuz...                                                                                   | 7.6 MB     00:00 ... 
Retrieving file initrd.img...                                                                                |  58 MB     00:00 ... 
Allocating 'minimal.img'                                                                                     | 3.0 GB     00:00     
Creating domain...                                                                                           |    0 B     00:00     
Domain installation still in progress. Waiting for installation to complete.

... I added "--serial=file,..." in order to log in the install, which ends as follows:

.
,
.
terminating anaconda...done
sending termination signals...done
sending kill signals...Done
disabling swap...
       /dev/dm-1
unmounting filesystems...
       /mnt/runtime done
       disabling /dev/loop0
       /dev/pts done
       /selinux done
       /mnt/sysimage/boot done
       /mnt/sysimage/dev/pts done
       /mnt/sysimage/dev/shm done
       /mnt/sysimage/dev done
       /mnt/sysimage/proc/bus/usb done
       /mnt/sysimage/proc done
       /mnt/sysimage/sys done
       /mnt/sysimage/selinux done
       /mnt/sysimage done
waiting for mdraid sets to become clean...
halting system
System halted.

... the new Linux system is halted since I included the "shutdown" (http://fedoraproject.org/wiki/Anaconda/Kickstart#shutdown) option in the Kickstart file, but virt-install still does not exit.

What event signals completion of domain installation? How can it be triggered from within the guest (which has the thread of execution with Kickstart)? Or do I need to wrap all this in a script, set wait=0, track the logged output and use some sort of virsh command to signal domain installation completion?

Thanks,

Anthony.


> On Jan 19, 2014, at 5:32 AM, Cole Robinson <crobinso at redhat.com> wrote:
> 
>> On 01/19/2014 02:59 AM, Anthony Shortland wrote:
>> We're running version 0.600.0 of virt-install with version 0.10.2 of libvert and version 0.12.1.2 of qemu-kvm on RHEL 6.3.
>> 
>> We're trying to script an automated image build process and want virt-install to exit when Kickstart completes and halts the guest virtual machine (using the "shutdown" option).
>> 
>> The thing is that virt-install hangs indefinitely staying connected to the text console (on ttyS0 with --graphics=none) and only exits on timeout if the --wait option is specified.
>> 
>> Is there any way virt-install can simply wait for the Kickstart to complete and halt the guest and then exit gracefully?
> 
> That's what it should be doing already: when anaconda finishes, it runs
> 'shutdown' in the guest. My guess is that the shutdown request isn't working here.
> 
> Also, if you are doing an automated kickstart install, you don't necessarily
> need to connect to the serial console: virt-install --noautoconsole --wait -1
> will do that.
> 
> Though a crazier option: if you can't find out why the guest OS isn't shutting
> down properly, you could wrap virt-install with a shell script, watch the
> output on the serial console, and when you see some string like 'requesting
> shutdown' or whatever anaconda/init prints, do 'virsh destroy $vmname'
> 
> - Cole
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20140119/e48bdb6c/attachment.htm>


More information about the virt-tools-list mailing list