On Thu, Jun 23, 2011 at 11:58:18AM +0100, Daniel P. Berrange wrote: > If an application is using libvirt + KVM as a piece of its > internal infrastructure to perform a specific task, it can > be desirable to guarentee the VM dies when the virConnectPtr > disconnects from libvirtd. This ensures the app can't leak > any VMs it was using. Adding VIR_DOMAIN_START_AUTOKILL as > a flag when starting guests enables this to be done. > > * include/libvirt/libvirt.h.in: All VIR_DOMAIN_START_AUTOKILL > * src/qemu/qemu_driver.c: Support automatic killing of guests > upon connection close > * tools/virsh.c: Add --autokill flag to 'start' and 'create' > commands > --- > include/libvirt/libvirt.h.in | 1 + > src/qemu/qemu_driver.c | 27 ++++++++++++++++++--------- > tools/virsh.c | 6 ++++++ > 3 files changed, 25 insertions(+), 9 deletions(-) > > diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in > index 3f634e6..a827697 100644 > --- a/include/libvirt/libvirt.h.in > +++ b/include/libvirt/libvirt.h.in > @@ -234,6 +234,7 @@ typedef virDomainInfo *virDomainInfoPtr; > typedef enum { > VIR_DOMAIN_NONE = 0, /* Default behavior */ > VIR_DOMAIN_START_PAUSED = 1 << 0, /* Launch guest in paused state */ > + VIR_DOMAIN_START_AUTOKILL = 1 << 1, /* Automatically kill guest when virConnectPtr is closed */ > } virDomainCreateFlags; I'm thinking perhaps I should rename that to AUTODESTROY instead, since that matches the terminology we use here. 'kill' is specific to UNIX processes, and if we want to extend the autodestroy concept to storage pools or virtual networks, AUTODESTROY makes more sense. > diff --git a/tools/virsh.c b/tools/virsh.c > index fcd254d..dedf883 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c > @@ -1305,6 +1305,7 @@ static const vshCmdOptDef opts_create[] = { > {"console", VSH_OT_BOOL, 0, N_("attach to console after creation")}, > #endif > {"paused", VSH_OT_BOOL, 0, N_("leave the guest paused after creation")}, > + {"autokill", VSH_OT_BOOL, 0, N_("automatically kill the guest when virsh disconnects")}, > {NULL, 0, 0, NULL} > }; And '--autodestroy' here instead Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list