From nobody Mon Apr 29 15:57:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507548383752455.6843528934337; Mon, 9 Oct 2017 04:26:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12A9481E01; Mon, 9 Oct 2017 11:26:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 255CC61B88; Mon, 9 Oct 2017 11:26:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E0A4118355C7; Mon, 9 Oct 2017 11:26:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v99B2rwZ028888 for ; Mon, 9 Oct 2017 07:02:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79C31612B3; Mon, 9 Oct 2017 11:02:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74CE75D9C1 for ; Mon, 9 Oct 2017 11:02:51 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F015F356F6 for ; Mon, 9 Oct 2017 11:02:50 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v99B0h7C114908 for ; Mon, 9 Oct 2017 07:02:50 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dg4yx0fkw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 09 Oct 2017 07:02:50 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Oct 2017 12:02:48 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 9 Oct 2017 12:02:47 +0100 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v99B2iwF27459746; Mon, 9 Oct 2017 11:02:46 GMT Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v99B2ZSp018989; Mon, 9 Oct 2017 22:02:35 +1100 Received: from powerkvmpok002.pok.stglabs.ibm.com (powerkvmpok002.pok.stglabs.ibm.com [9.114.13.10]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v99B2Xjo018912; Mon, 9 Oct 2017 22:02:34 +1100 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 12A9481E01 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 12A9481E01 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F015F356F6 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=kmp@linux.vnet.ibm.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F015F356F6 From: Kothapally Madhu Pavan To: libvir-list@redhat.com Date: Mon, 9 Oct 2017 16:32:38 +0530 X-TM-AS-MML: disable x-cbid: 17100911-0008-0000-0000-0000049DCAB8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17100911-0009-0000-0000-00001E2F46B6 Message-Id: <1507546958-64895-1-git-send-email-kmp@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-09_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710090160 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 205 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 09 Oct 2017 11:02:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 09 Oct 2017 11:02:51 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'kmp@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.72 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Kothapally Madhu Pavan Subject: [libvirt] [PATCH] qemu: Changes in parsing qemu commandline memory section X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 09 Oct 2017 11:26:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Existing qemuParseCommandLineMem() will parse "-m 4G" format string. This patch allows it to parse "-m size=3D8126464k,slots=3D32,maxmem=3D33554= 432k" format along with existing format. Signed-off-by: Kothapally Madhu Pavan --- src/qemu/qemu_parse_command.c | 89 +++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 77 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 37e1149..c30e8ed 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1629,26 +1629,91 @@ static int qemuParseCommandLineMem(virDomainDefPtr dom, const char *val) { - unsigned long long mem; + unsigned long long mem =3D 0; + unsigned long long size =3D 0; + unsigned long long maxmem =3D 0; + unsigned int slots =3D 0; char *end; + size_t i; + int nkws; + char **kws; + char **vals; + int n; + int ret =3D -1; =20 - if (virStrToLong_ull(val, &end, 10, &mem) < 0) { + if (qemuParseKeywords(val, &kws, &vals, &nkws, 1) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse memory level '%s'"), val); - return -1; + _("cannot parse memory '%s'"), val); + goto cleanup; } =20 - if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot scale memory: %s"), - virGetLastErrorMessage()); - return -1; + for (i =3D 0; i < nkws; i++) { + if (vals[i] =3D=3D NULL) { + if (i > 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse memory '%s'"), val); + goto cleanup; + } + if (virStrToLong_ull(kws[i], &end, 10, &mem) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse memory level '%s'"), kws[i]= ); + goto cleanup; + } + if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot scale memory: %s"), + virGetLastErrorMessage()); + goto cleanup; + } + + size =3D mem; + + } else { + if (STREQ(kws[i], "size") || STREQ(kws[i], "maxmem")) { + if (virStrToLong_ull(vals[i], &end, 10, &mem) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse memory level '%s'"), va= ls[i]); + goto cleanup; + } + if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0)= { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot scale memory: %s"), + virGetLastErrorMessage()); + goto cleanup; + } + + STREQ(kws[i], "size") ? (size =3D mem) : (maxmem =3D mem); + + } + if (STREQ(kws[i], "slots")) { + if (virStrToLong_i(vals[i], &end, 10, &n) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse slots value '%s'"), val= s[i]); + goto cleanup; + } +=20 + slots =3D n; + + } + } } =20 - virDomainDefSetMemoryTotal(dom, mem / 1024); - dom->mem.cur_balloon =3D mem / 1024; + virDomainDefSetMemoryTotal(dom, size / 1024); + dom->mem.cur_balloon =3D size / 1024; + dom->mem.memory_slots =3D slots; + dom->mem.max_memory =3D maxmem; =20 - return 0; + ret =3D 0; + + cleanup: + for (i =3D 0; i < nkws; i++) { + VIR_FREE(kws[i]); + VIR_FREE(vals[i]); + } + VIR_FREE(kws); + VIR_FREE(vals); + + return ret; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list