From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Hajnoczi Subject: Re: Invoking guest os script, without guest having network connectivity? Date: Mon, 26 Nov 2012 12:06:00 +0100 Message-ID: <20121126110600.GD963@stefanha-thinkpad.redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm To: Shlomi Tsadok Return-path: Received: from mail-ee0-f46.google.com ([74.125.83.46]:59662 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754581Ab2KZLGD (ORCPT ); Mon, 26 Nov 2012 06:06:03 -0500 Received: by mail-ee0-f46.google.com with SMTP id e53so4386589eek.19 for ; Mon, 26 Nov 2012 03:06:02 -0800 (PST) Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Sat, Nov 24, 2012 at 06:40:39PM +0200, Shlomi Tsadok wrote: > I'm looking for a way to configure the guest networking(including IP) > dynamically, using a custom script, right after VM creation. > > Is there a similar feature in KVM/Libvirt as the Invoke-VMScript in of > VMware's PowerCLI? > It allows you to run a script in the guest OS, even before the guest > has networking connectivity (the host talks to the vmtools agent > that's installed in the guest). The QEMU guest agent (qemu-ga) has features that may allow you to do this. I'm not familiar enough with it to give details, here are some alternatives: If you provide a kernel + initramfs externally (outside the guest disk image) you can add files to the initramfs. This allows you to customize boot up. Alternatively you can use PXE booting to achieve the same thing. Finally, you could edit the disk image using libguestfs or qemu-nbd before booting it for the first time. This gives you a chance to customize configuration and startup files. Stefan