[libvirt] [PATCH 5/5] virsh: use new virNetworkDefineXMLFlags when available.

Laine Stump laine at laine.org
Mon Aug 20 14:29:43 UTC 2012


On 08/20/2012 06:46 AM, Osier Yang wrote:
> On 2012年08月20日 14:17, Laine Stump wrote:
>> Currently there is no practical difference between this and using the
>> old virNetworkDefinXML API, it just allows using the new API to make
>> sure it's working.
>>
>> Soon there will be a flag defined for the new function (to request
>> changes in re-definitions of existing+active networks take effect
>> immediately), and virsh will add support for that flag.
>> ---
>>   tools/virsh-network.c | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/virsh-network.c b/tools/virsh-network.c
>> index 49ec34f..414ca86 100644
>> --- a/tools/virsh-network.c
>> +++ b/tools/virsh-network.c
>> @@ -181,6 +181,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
>>       const char *from = NULL;
>>       bool ret = true;
>>       char *buffer;
>> +    unsigned flags = 0;
>>
>>       if (!vshConnectionUsability(ctl, ctl->conn))
>>           return false;
>> @@ -191,7 +192,16 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd
>> *cmd)
>>       if (virFileReadAll(from, VIRSH_MAX_XML_FILE,&buffer)<  0)
>>           return false;
>>
>> -    network = virNetworkDefineXML(ctl->conn, buffer);
>> +    network = virNetworkDefineXMLFlags(ctl->conn, buffer, flags);
>> +
>> +    if (network == NULL&&  last_error->code == VIR_ERR_NO_SUPPORT) {
>
> It should reset the error before trying the old API:
>
> vshResetLibvirtError();

Yep, I missed that. Thanks!

>
>
>> +        /* fall back to older function that doesn't take flags.  note
>> +         * that if we want to use flags in the future, we'll have to
>> +         * error out here when flags != 0.
>> +         */
>> +        network = virNetworkDefineXML(ctl->conn, buffer);
>> +    }
>> +
>>       VIR_FREE(buffer);
>>
>>       if (network != NULL) {
>
> ACK with the nit fixed (with wondering why not use new API
> in virsh when the flags is/are supported though).

Just a way of assuring that everything is in place and working. :-)




More information about the libvir-list mailing list