mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
phyp: optimize use of sed
Minor speedups by using the full power of sed. * src/phyp/phyp_driver.c (phypGetVIOSFreeSCSIAdapter) (phypDiskType, phypListDefinedDomains): Use fewer processes, by folding other work into sed. (phypGetVIOSPartitionID): Likewise. Also avoid non-portable use of 'sed -s'.
This commit is contained in:
parent
ebc46fea6f
commit
17dedf7cb5
@ -227,8 +227,8 @@ phypGetVIOSPartitionID(virConnectPtr conn)
|
|||||||
virBufferAddLit(&buf, "lssyscfg");
|
virBufferAddLit(&buf, "lssyscfg");
|
||||||
if (system_type == HMC)
|
if (system_type == HMC)
|
||||||
virBufferVSprintf(&buf, " -m %s", managed_system);
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
||||||
virBufferAddLit(&buf, " -r lpar -F lpar_id,lpar_env|grep "
|
virBufferAddLit(&buf, " -r lpar -F lpar_id,lpar_env"
|
||||||
"vioserver|sed -s 's/,.*$//'");
|
"|sed -n '/vioserver/ {\n s/,.*$//\n p\n}'");
|
||||||
if (virBufferError(&buf)) {
|
if (virBufferError(&buf)) {
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -1889,7 +1889,7 @@ phypGetVIOSFreeSCSIAdapter(virConnectPtr conn)
|
|||||||
if (system_type == HMC)
|
if (system_type == HMC)
|
||||||
virBufferAddChar(&buf, '\'');
|
virBufferAddChar(&buf, '\'');
|
||||||
|
|
||||||
virBufferVSprintf(&buf, "|grep -v ',[^.*]'|head -n 1|sed -e 's/,//g'");
|
virBufferVSprintf(&buf, "|sed '/,[^.*]/d; s/,//g; q'");
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
if (virBufferError(&buf)) {
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
@ -3330,7 +3330,7 @@ phypDiskType(virConnectPtr conn, char *backing_device)
|
|||||||
if (system_type == HMC)
|
if (system_type == HMC)
|
||||||
virBufferVSprintf(&buf, " -m %s", managed_system);
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
||||||
virBufferVSprintf(&buf, " -p %d -c \"lssp -field name type "
|
virBufferVSprintf(&buf, " -p %d -c \"lssp -field name type "
|
||||||
"-fmt , -all|grep %s|sed -e 's/^.*,//'\"",
|
"-fmt , -all|sed -n '/%s/ {\n s/^.*,//\n p\n}'\"",
|
||||||
vios_id, backing_device);
|
vios_id, backing_device);
|
||||||
if (virBufferError(&buf)) {
|
if (virBufferError(&buf)) {
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
@ -3398,8 +3398,8 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames)
|
|||||||
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
virBufferAddLit(&buf, "lssyscfg -r lpar");
|
||||||
if (system_type == HMC)
|
if (system_type == HMC)
|
||||||
virBufferVSprintf(&buf, " -m %s", managed_system);
|
virBufferVSprintf(&buf, " -m %s", managed_system);
|
||||||
virBufferVSprintf(&buf, " -F name,state | grep \"Not Activated\" | "
|
virBufferVSprintf(&buf, " -F name,state"
|
||||||
"sed -e 's/,.*$//'");
|
"|sed -n '/Not Activated/ {\n s/,.*$//\n p\n}'");
|
||||||
if (virBufferError(&buf)) {
|
if (virBufferError(&buf)) {
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
|
Loading…
Reference in New Issue
Block a user