[libvirt] [PATCH] SetAutostart and GetAutostart in openvz driver

Evgeniy Sokolov evg at openvz.org
Wed Jul 9 14:48:25 UTC 2008


> 
> I realize you are just following the existing pattern used in OpenVZ
> driver, but this piece of code is horrible. 
> 
> sprintf'ing into a string, then parsing that string and turning it back 
> into a list of argv[] strings, with no escaping of special characters,
> or quoting. eg if the vm name had a space in it it'll mis-parse it.
In fact, names of VMs are always numbers in OpenVZ.
> 
> Just declare the command argv straight into a char*[], eg
> 
>   const char *prog[] = {
>      VZCTL,
>      "set",
>      vm->vmdef->name,
>      "--onboot",
>      autostart ? "yes" : "no",
>      "--save"
>   }
>   ret = virExec(conn, prog, &pid, -1, &outfd, &errfd)
> 
> See the storage_backend_logical.c file for examples of this kind of approach
> 
> We should put other uses of convCmdbufExec() on the TODO list for removal
> in the future.
Ok. Moreover, many code is needed to rewrite.

Daniel, thanks for review!

fixed patch is attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-openvz-setautostart.diff
Type: text/x-patch
Size: 4991 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20080709/5322104f/attachment-0001.bin>


More information about the libvir-list mailing list