[libvirt] [PATCH RFC] helper of copy-storage-* features

Eric Blake eblake at redhat.com
Mon Oct 22 15:39:35 UTC 2012


On 10/21/2012 08:09 PM, Doug Goldstein wrote:
> On Sun, Oct 21, 2012 at 7:53 PM, liguang <lig.fnst at cn.fujitsu.com> wrote:
>> help to create disk images copy-storage-* required,
>> try to do non-shared migration without bothering to
>> create disk images at target by hand.
>>

>> +        } else
>> +            cmd = virCommandNewArgList("rm", "-f", def->disks[i]->src, NULL);
>> +
>> +        if (virCommandRun(cmd, NULL) < 0) {
>> +            goto cleanup;
>> +            virReportSystemError(errno, "%s",
>> +            _("unable create disk images by qemu-img"));
>> +        }
> 
> The error message reported doesn't match what happened when the rm -f
> fails. Also 'cmd' is being leaked here.

Not to mention virCommandRun() is overkill.  Use unlink() here instead,
rather than forking out to an external program.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121022/9c1b86ef/attachment-0001.sig>


More information about the libvir-list mailing list