From nobody Sun May 5 18:59:58 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569585463; cv=none; d=zoho.com; s=zohoarc; b=Bit/y/ocH1FXhwltdTMPp+a8YDjg+T1+84frS3f9P+jqPQKDX+kmwe/7YppG6cl7+bXk+d3sISawYRRkj3PB2UobcMzksUyaf5jPjPLVZrWXhthtH4KTq+jLtHvuet0p2CdGlJFbNRehl9M4bc52uu9n035euaw/WCPCSmvlPFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569585463; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=EpC67nCC80ALp12b8GeqZr3+6adMvgUCKNthPhQRugQ=; b=h3CGGOgKFRp6dCNGDAh55XU2/OhW+N7MoS8l7mw/nXIRFTS1dOs0LoeziiWKGnJ9KMSp3jlBpBzJvza/e7Me6yiy6wy396oRuPf1iGKSyikBlzU83fLUz9iA6M98t5+HBQIFjlO+zeW/QyP+ywzBiH8Wqj7h4+udQUbsC0C5hOM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156958546386493.9000897293671; Fri, 27 Sep 2019 04:57:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0357C065116; Fri, 27 Sep 2019 11:57:41 +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 592CB5D6A7; Fri, 27 Sep 2019 11:57:40 +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 46A531803B37; Fri, 27 Sep 2019 11:57:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8RBvaaB031197 for ; Fri, 27 Sep 2019 07:57:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id C4516196B2; Fri, 27 Sep 2019 11:57:36 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E7A4194B6 for ; Fri, 27 Sep 2019 11:57:33 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 27 Sep 2019 13:57:26 +0200 Message-Id: <5a1f83b9ddfa9f0099bf5ab1955556cd561ce07b.1569585446.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu_monitor: s/size_t/ULL/ in qemuMonitorSave{Virtual, Physical}Memory 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 27 Sep 2019 11:57:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" As it turns out, on my 32bit ARM machine size_t is not the same size as ULL. However, @length argument for both functions is type of size_t but it's treated as ULL - for instance when passed to qemuMonitorJSONMakeCommand(). The problem is that because of "U:size" the virJSONValueObjectAddVArgs() expects an ULL argument but on the stack there are size_t and char * arguments (which coincidentally add up to size of ULL). So the created command has only two arguments "val" and incorrect "size" and no "path" which is required. I've tried to find other occurrences of this pattern but at the rest of places where size_t is used it tracks size of an array so that's safe. Signed-off-by: Michal Privoznik --- src/qemu/qemu_monitor.c | 8 ++++---- src/qemu/qemu_monitor.h | 4 ++-- src/qemu/qemu_monitor_json.c | 6 +++--- src/qemu/qemu_monitor_json.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b6d2936872..7959933e7c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2348,10 +2348,10 @@ qemuMonitorChangeMedia(qemuMonitorPtr mon, int qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path) { - VIR_DEBUG("offset=3D%llu length=3D%zu path=3D%s", offset, length, path= ); + VIR_DEBUG("offset=3D%llu length=3D%llu path=3D%s", offset, length, pat= h); =20 QEMU_CHECK_MONITOR(mon); =20 @@ -2362,10 +2362,10 @@ qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon, int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path) { - VIR_DEBUG("offset=3D%llu length=3D%zu path=3D%s", offset, length, path= ); + VIR_DEBUG("offset=3D%llu length=3D%llu path=3D%s", offset, length, pat= h); =20 QEMU_CHECK_MONITOR(mon); =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 8fc11c955e..95de891150 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -726,11 +726,11 @@ int qemuMonitorChangeMedia(qemuMonitorPtr mon, =20 int qemuMonitorSaveVirtualMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path); int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path); =20 int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cdfaf9785a..d99d291d89 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3100,7 +3100,7 @@ int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon, static int qemuMonitorJSONSaveMemory(qemuMonitorPtr mon, const char *cmdtype, unsigned long long offset, - size_t length, + unsigned long long length, const char *path) { int ret =3D -1; @@ -3129,7 +3129,7 @@ static int qemuMonitorJSONSaveMemory(qemuMonitorPtr m= on, =20 int qemuMonitorJSONSaveVirtualMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path) { return qemuMonitorJSONSaveMemory(mon, "memsave", offset, length, path); @@ -3137,7 +3137,7 @@ int qemuMonitorJSONSaveVirtualMemory(qemuMonitorPtr m= on, =20 int qemuMonitorJSONSavePhysicalMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path) { return qemuMonitorJSONSaveMemory(mon, "pmemsave", offset, length, path= ); diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index a608410703..63f569716d 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -118,11 +118,11 @@ int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon, =20 int qemuMonitorJSONSaveVirtualMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path); int qemuMonitorJSONSavePhysicalMemory(qemuMonitorPtr mon, unsigned long long offset, - size_t length, + unsigned long long length, const char *path); =20 int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list