[libvirt] [PATCH] Adding support for IVM
Eric Blake
eblake at redhat.com
Wed Jun 16 21:01:45 UTC 2010
On 06/16/2010 02:47 PM, Eric Blake wrote:
> On 06/16/2010 01:22 PM, Eduardo Otubo wrote:
>> Fixing all pointed in the previous email.
>> Thanks for all the comments.
>>
>> @@ -488,11 +498,45 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
>> return virBufferContentAndReset(&tex_ret);
>> }
>>
>> +static char *
>> +hmc_helper(int system_type, const char *managed_system)
>> +{
>> + char *unsafe = NULL;
>> + if (system_type == HMC)
>> + virAsprintf(&unsafe, "-m %s", managed_system);
>> + else
>> + unsafe[0] = 0;
>> + return unsafe;
>
> Unfortunately, for the IVM case, this dereferences NULL :(
>
> And it has the problem that it is not thread-safe.
>
> I'm going to try my hand at tweaking this patch to use virBuffer
> instead, but we are getting closer...
Here's what I'm thinking, at which point we don't need hmc_helper after all:
diff --git i/src/phyp/phyp_driver.c w/src/phyp/phyp_driver.c
index e111a47..1aea417 100644
--- i/src/phyp/phyp_driver.c
+++ w/src/phyp/phyp_driver.c
@@ -542,13 +542,18 @@ phypGetLparID(LIBSSH2_SESSION * session, const
char *managed_system,
char *char_ptr;
char *cmd = NULL;
char *ret = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (virAsprintf(&cmd,
- "lssyscfg -r lpar %s --filter lpar_names=%s -F
lpar_id",
- hmc_helper(system_type, managed_system), name) < 0) {
+ virBufferAddLit(&buf, "lssyscfg -r lpar");
+ if (system_type == HMC)
+ virBufferVSprintf(&buf, " -m %s", managed_system);
+ virBufferVSprintf(&buf, " --filter lpar_names=%s -F lpar_id", name);
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
virReportOOMError();
- goto err;
+ return -1;
}
+ cmd = virBufferContentAndReset(&buf);
ret = phypExec(session, cmd, &exit_status, conn);
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100616/8e02504e/attachment-0001.sig>
More information about the libvir-list
mailing list