On 06/23/2011 04:58 AM, 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 ++++++ Incomplete. Missing tools/virsh.pod. > 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; The more uses we find for flags, the more I'm glad we've been making all new APIs support them :) > +++ 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")}, Probably more useful when using a long-running 'virsh', as opposed to a shorter 'virsh start --autokill' :) Conditional ACK, once you also document the new virsh flags. -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list