On Wed, Jan 09, 2013 at 09:49:31AM -0700, Eric Blake wrote:
On 01/09/2013 03:28 AM, Daniel P. Berrange wrote:
>> We have virDomainDefineXML with no flags, but we have virDomainCreateXML
>> with flags; maybe the better approach is to add a new creation flag that
>> says that in addition to starting the domain, we also make it persistent
>> at the same time.
>>
>> But if we do that, it would argue that 'virsh create --persistent
>> blah.xml' is nicer than 'virsh define --start blah.xml', at least
in
>> that the former needs only 1 API call for new libvirt (but falls back to
>> 2 API calls when talking to older libvirt), while the latter always
>> needs 2 API calls.
>>
>> Or maybe it means we need to add virDomainDefineXMLFlags().
>>
>> Anyone else want to throw some paint on the bikeshed on how best to make
>> the user experience nicer?
>
> While I think the virsh idea is fine, I don't want to see this done
> at the virDomainDefine API level, since it just duplicates functionality
> already present. Just have virsh make an API call to the existing create
> API.
I agree that we don't really need to add virDomainDefineXMLFlags(). But
I'm not quite clear on your stance on adding a new flag to the existing
virDomainCreateXML(). A single API call is always nicer than two API
calls for atomicity reasons. That is, I'm proposing that we add a new
flag, and that:
virDomainCreateXML(conn, xml, VIR_DOMAIN_CREATE_PERSISTENT)
I don't really like this either. I think it is good that the APIs
are separate because it gives applications greater clarity on
error handling. eg with this API you could get an case where
the API defines the XML, starts the VM, fails and then tries
to undefine the XML but fails that too. Now the caller sees an
error, but can't know whether the XML was undefined or not.
If the app does the separate API calls they have full control
over what happens in that situation
be used to both start and define a domain in one call, and only if
that
flag is unrecognized do we fall back to the two-API sequence of
virDomainCreateXML(conn, xml, 0) && virDomainDefineXML(conn, xml)
or the equivalent two-API sequence of
dom=virDomainDefineXML(conn, xml) && virDomainCreate(dom)
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 :|